256 lines
7.5 KiB
C++
256 lines
7.5 KiB
C++
#include "rm_popup.h"
|
|
#include "../fm_dimensions.h"
|
|
#include "title_widget.h"
|
|
#include "rm_widget_drag.h"
|
|
#include "rm_popup_content_background.h"
|
|
#include "fm_layer.h"
|
|
#include <QComboBox>
|
|
#include <QGraphicsDropShadowEffect>
|
|
#include "fm_button.h"
|
|
#include "../core/fm_strings.h"
|
|
#include "fm_colors.h"
|
|
|
|
#if (MODEL_WATEX)
|
|
#define POPUP_BG_STYLE "popup_bg_widget"
|
|
#else
|
|
#define POPUP_BG_STYLE "bg_widget"
|
|
#endif
|
|
|
|
RMPopup::RMPopup(QWidget *parent, QString title,QString icon, Qt::WindowFlags f) : QDialog(parent,f)
|
|
{
|
|
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint);
|
|
_mainLayout = new QVBoxLayout(this);
|
|
_mainLayout->setSpacing(0);
|
|
#if (MODEL_WATEX)
|
|
_mainLayout->setMargin(1);
|
|
#elif (MODEL_BBVIEWER)
|
|
_mainLayout->setMargin(2);
|
|
#else
|
|
_mainLayout->setMargin(0);
|
|
#endif
|
|
|
|
_title = new TitleWidget(this,title,icon,true);
|
|
_mainLayout->addWidget(_title);
|
|
|
|
_contentWidget = new QWidget(this);
|
|
#if (RM_MODEL_EMT_KR)
|
|
const int CONTENT_BG = FM_THEME_COLOR_M3;
|
|
const int BUTTON_BG = FM_THEME_COLOR_M1;
|
|
#else // RM_MODEL_EMT_KR
|
|
const int CONTENT_BG = 0x3a3a3a;
|
|
const int BUTTON_BG = 0x595959;
|
|
#endif // RM_MODEL_EMT_KR
|
|
|
|
|
|
FMWidgetBackground(_contentWidget,"popup_bg",CONTENT_BG);
|
|
_contentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
|
|
//_contentWidget->setObjectName(POPUP_BG_STYLE);
|
|
_mainLayout->addWidget(_contentWidget);
|
|
|
|
_buttonWidget = new QWidget(this);
|
|
_buttonWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
|
|
//_buttonWidget->setObjectName(POPUP_BG_STYLE);
|
|
FMWidgetBackground(_buttonWidget,"popup_bg",BUTTON_BG);
|
|
|
|
|
|
#if (MODEL_BBVIEWER)
|
|
_buttonWidget->setFixedHeight(34);
|
|
#else
|
|
_buttonWidget->setFixedHeight(43); // 65??
|
|
#endif
|
|
_mainLayout->addWidget(_buttonWidget);
|
|
|
|
_buttonLayout = new QHBoxLayout(_buttonWidget);
|
|
ZERO_LAYOUT(_buttonLayout);
|
|
|
|
if(_title->closeButton != NULL) {
|
|
connect(_title->closeButton,SIGNAL(clicked()),this,SLOT(reject()));
|
|
}
|
|
|
|
_drag = new RMWidgetDrag(this,POPUP_TITLE_BAR_HEIGHT);
|
|
|
|
}
|
|
RMPopup::~RMPopup()
|
|
{
|
|
//qInfo() << __FUNCTION__;
|
|
}
|
|
|
|
void RMPopup::hideCloseButton()
|
|
{
|
|
if(_title != NULL && _title->closeButton != NULL)
|
|
{
|
|
_title->closeButton->setHidden(true);
|
|
}
|
|
}
|
|
#if (LIVE_LANGUAGE_CHANGE)
|
|
int RMPopup::languageIndex = -1;
|
|
|
|
void RMPopup::createLanguageLayout()
|
|
{
|
|
this->setFixedSize(320,160);
|
|
|
|
//RMPopup::RMPopup(parent,title);
|
|
_title->closeButton->setHidden(true);
|
|
|
|
_buttonLayout->setAlignment(Qt::AlignCenter);
|
|
|
|
#if !(LIVE_LANGUAGE2)
|
|
bool bJP = RMLanguage::isJP();
|
|
#endif // #if !(LIVE_LANGUAGE2)
|
|
|
|
// 確認
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
_okButton = RMButton::create2(_buttonWidget,_buttonLayout,"button","ok",QSize(100,24));
|
|
_okButton->setText(FMS::txt("ok"));
|
|
#else
|
|
#if (FORCE_FM_STRING)
|
|
QString okString = FMS::txt("ok");
|
|
#else // FORCE_FM_STRING
|
|
QString okString = bJP ? MKU8("\xe7\xa2\xba\xe8\xaa\x8d") : "OK";
|
|
#endif // FORCE_FM_STRING
|
|
_okButton = RMButton::create(_buttonWidget,_buttonLayout,"button",okString,QSize(100,24));
|
|
_okButton->setText(okString);
|
|
#endif
|
|
connect(_okButton,SIGNAL(clicked()),this,SLOT(accept()));
|
|
|
|
RMLayout::addSpacer(_buttonLayout,10,0);
|
|
|
|
#if (FORCE_FM_STRING)
|
|
QString cancelString = FMS::txt("cancel");
|
|
#else
|
|
// キャンセル
|
|
QString cancelString = bJP ? MKU8("\xe3\x82\xad\xe3\x83\xa3\xe3\x83\xb3\xe3\x82\xbb\xe3\x83\xab") : "Cancel";
|
|
#endif
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
_cancelButton = RMButton::create2(_buttonWidget,
|
|
_buttonLayout,
|
|
"button",
|
|
"cancel",
|
|
QSize(100,24));
|
|
_cancelButton->setText(FMS::txt("cancel"));
|
|
#else // LIVE_LANGUAGE2
|
|
_cancelButton = RMButton::create(_buttonWidget,
|
|
_buttonLayout,
|
|
"button",
|
|
cancelString,
|
|
QSize(100,24));
|
|
_cancelButton->setText(cancelString);
|
|
#endif // LIVE_LANGUAGE2
|
|
|
|
connect(_cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
|
|
|
|
RMLayout::addSpacer(_buttonLayout,20,0);
|
|
|
|
#if !(LIVE_LANGUAGE2)
|
|
bool isJP = RMLanguage::isJP();
|
|
#endif
|
|
|
|
if(RMLanguage::isAuto)
|
|
{
|
|
RMPopup::languageIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
#if !(LIVE_LANGUAGE2)
|
|
RMPopup::languageIndex = bJP ? 1 : 2;
|
|
#else
|
|
RMLanguage* lng = RMLanguage::instance();
|
|
RMPopup::languageIndex = lng->languageIndex(); // 0:AUTO, 1:한국어 2:일본어, 3:영어
|
|
#endif
|
|
}
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(_contentWidget);
|
|
layout->setContentsMargins(10,2,10,2);
|
|
|
|
RMPopupContentBackground* bg = new RMPopupContentBackground(_contentWidget);
|
|
layout->addWidget(bg);
|
|
|
|
QVBoxLayout* contentLayout = new QVBoxLayout(bg);
|
|
//contentLayout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
|
|
contentLayout->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
|
|
|
// 言語
|
|
QWidget* comboWidget = new QWidget(bg);
|
|
contentLayout->addWidget(comboWidget);
|
|
|
|
QHBoxLayout* comboLayout = new QHBoxLayout(comboWidget);
|
|
comboLayout->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
|
comboLayout->setContentsMargins(0,2,8,2);
|
|
comboLayout->setSpacing(3);
|
|
|
|
// 言語
|
|
#if (FORCE_FM_STRING)
|
|
QString title = FMS::txt("language");
|
|
#else
|
|
QString title = isJP ? MKU8("\xe8\xa8\x80\xe8\xaa\x9e") : "Language";
|
|
#endif
|
|
title += ":";
|
|
RMLayout::addLabel(comboWidget,
|
|
comboLayout,
|
|
title,
|
|
"text");
|
|
|
|
RMLayout::addSpacer(contentLayout,0,5);
|
|
|
|
QComboBox* comboBox = new QComboBox(this);
|
|
comboBox->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Preferred);
|
|
comboBox->setFixedWidth(200);
|
|
comboBox->setObjectName("settings");
|
|
comboBox->setMaxVisibleItems(100);
|
|
|
|
// 日本語, 自動
|
|
#if (FORCE_FM_STRING)
|
|
QString autoString = FMS::txt("auto_select");
|
|
|
|
#else //
|
|
QString autoString = isJP ? MKU8("\xe8\x87\xaa\xe5\x8b\x95") : "Auto";
|
|
#endif // #if (FORCE_FM_STRING)
|
|
|
|
#if (LANGUAGE_REMOVE_ENG)
|
|
QStringList items = QStringList() << autoString << MKU8("\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e");
|
|
#else // LANGUAGE_REMOVE_ENG
|
|
#if !(LIVE_LANGUAGE2)
|
|
QStringList items = QStringList() << autoString << MKU8("\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e") << "English";
|
|
#else // LIVE_LANGUAGE2
|
|
QStringList items = QStringList() << autoString << FM_WSTR(L"한국어") << FM_WSTR(L"日本語") << "English";
|
|
#endif // LIVE_LANGUAGE2
|
|
#endif // LANGUAGE_REMOVE_ENG
|
|
|
|
comboBox->addItems(items);
|
|
|
|
//comboBox->setCurrentIndex(realIndex(*value));
|
|
connect(comboBox,SIGNAL(currentIndexChanged(int)),SLOT(onLanguageSelected(int)));
|
|
comboLayout->addWidget(comboBox);
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
comboBox->setCurrentIndex(RMPopup::languageIndex);
|
|
#else
|
|
int current = 0; // AUTO
|
|
if(RMLanguage::isAuto == false)
|
|
{
|
|
current = RMLanguage::isJP() ? 1 : 2;
|
|
}
|
|
comboBox->setCurrentIndex(current);
|
|
#endif
|
|
|
|
#if (RM_MODEL != RM_MODEL_TYPE_MH9000)
|
|
// 言語を選択してください
|
|
#if (FORCE_FM_STRING)
|
|
QString message = FMS::txt("select_language");
|
|
#else
|
|
QString message = isJP ? MKU8("\xe8\xa8\x80\xe8\xaa\x9e\xe3\x82\x92\xe9\x81\xb8\xe6\x8a\x9e\xe3\x81\x97\xe3\x81\xa6\xe3\x81\x8f\xe3\x81\xa0\xe3\x81\x95\xe3\x81\x84") : "Select a language";
|
|
#endif
|
|
RMLayout::addLabel(bg,
|
|
contentLayout,
|
|
message,
|
|
"text");
|
|
#endif //
|
|
}
|
|
void RMPopup::onLanguageSelected(int index)
|
|
{
|
|
RMPopup::languageIndex = index;
|
|
}
|
|
#endif
|