838 lines
28 KiB
C++
838 lines
28 KiB
C++
#include "fm_button.h"
|
|
|
|
#include <QLayout>
|
|
#include <QVariant>
|
|
#include <QStyle>
|
|
#include <QStyleOption>
|
|
#include <QPainter>
|
|
#include <QDebug>
|
|
#include <QEvent>
|
|
#include <QTimer>
|
|
#include <QFile>
|
|
#include "../rm_include.h"
|
|
#if(LIVE_LANGUAGE_CHANGE)
|
|
#include "../core/rm_language.h"
|
|
#endif
|
|
#include "../core/fm_strings.h"
|
|
|
|
FM_COLOR_SET g_default_text_button_color_set[5] = {
|
|
0xDDDDDD, // normal
|
|
0xFFFFFF, // pressed
|
|
0xcc9933, // hover
|
|
0x595959, // disabled
|
|
0xDDDDDD, // checked
|
|
};
|
|
|
|
FMButton::FMButton(QWidget *parent) : RMButton(parent)
|
|
{
|
|
#if (LIVE_LANGUAGE2)
|
|
type = BUTTON_TYPE_UNKNOWN;
|
|
#endif
|
|
}
|
|
FMButton::~FMButton()
|
|
{
|
|
}
|
|
|
|
void FMButton::_setColorStyleSheet(const char* iconName, FM_COLOR_SET* color)
|
|
{
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
background-color: #%color_normal%;\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
background-color: #%color_pressed%;\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
background-color: #%color_hover%;\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
background-color: #%color_checked%;\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
image: url(:/image/%name%_3.png);\
|
|
background-color: #%color_disabled%;\
|
|
}";
|
|
// QString disabledName = QString(iconName) + "_3.png";
|
|
// if(!QFile::exists(":/images/" + disabledName))
|
|
// {
|
|
// src = src.replace("%name%_3.png);","%name%.png); opacity:50;");
|
|
// }
|
|
|
|
//qInfo() << src << __FUNCTION__;
|
|
setStyleSheet(src.replace("%name%",iconName)
|
|
.replace("%color_normal%",FMColor(color[FM_COLOR_SET_NORMAL]))
|
|
.replace("%color_pressed%",FMColor(color[FM_COLOR_SET_PRESSED]))
|
|
.replace("%color_hover%",FMColor(color[FM_COLOR_SET_HOVER]))
|
|
.replace("%color_checked%",FMColor(color[FM_COLOR_SET_CHECKED]))
|
|
.replace("%color_disabled%",FMColor(color[FM_COLOR_SET_DISABLED]))
|
|
.replace("%name%",iconName));
|
|
}
|
|
FMButton* FMButton::btnTypeChecked(QWidget* parent, QLayout* layout,const char* iconName, const char* iconName2, QString toolTip, QSize size, FM_COLOR_SET* color)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
border:1px solid #666666;\
|
|
image: url(:/image/%name%.png);\
|
|
background-color: #%color_normal%;\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
background-color: #%color_pressed%;\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
background-color: #%color_hover%;\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
image: url(:/image/%checked_name%.png);\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
background-color: #%color_disabled%;\
|
|
}";
|
|
btn->setStyleSheet(src.replace("%name%",iconName)
|
|
.replace("%checked_name%",iconName2)
|
|
.replace("%color_normal%",FMColor(color[FM_COLOR_SET_NORMAL]))
|
|
.replace("%color_pressed%",FMColor(color[FM_COLOR_SET_PRESSED]))
|
|
.replace("%color_hover%",FMColor(color[FM_COLOR_SET_HOVER]))
|
|
.replace("%color_checked%",FMColor(color[FM_COLOR_SET_CHECKED]))
|
|
.replace("%color_disabled%",FMColor(color[FM_COLOR_SET_DISABLED]))
|
|
.replace("%name%",iconName));
|
|
|
|
btn->setCheckable(true);
|
|
btn->setObjectName(iconName);
|
|
if(size.width() > 0 && size.height() > 0) {
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
} else if (size.height() > 0) {
|
|
btn->setFixedHeight(size.height());
|
|
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
|
} else if (size.width() > 0) {
|
|
btn->setFixedWidth(size.width());
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
|
|
}
|
|
layout->addWidget(btn);
|
|
return btn;
|
|
}
|
|
FMButton* FMButton::btnTypeText(QWidget* parent, QLayout* layout,QString title, QString toolTip, QSize size, FM_COLOR_SET* color)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
if(title.length() > 0) {
|
|
btn->setText(title);
|
|
}
|
|
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
color : white;\
|
|
font-family: 'Malgun Gothic';\
|
|
font-size: 16px;\
|
|
border:1px solid #666666;\
|
|
background-color: #%color_normal%;\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
background-color: #%color_pressed%;\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
background-color: #%color_hover%;\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
background-color: #%color_checked%;\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
background-color: #%color_disabled%;\
|
|
}";
|
|
btn->setStyleSheet(src.replace("%color_normal%",FMColor(color[FM_COLOR_SET_NORMAL]))
|
|
.replace("%color_pressed%",FMColor(color[FM_COLOR_SET_PRESSED]))
|
|
.replace("%color_hover%",FMColor(color[FM_COLOR_SET_HOVER]))
|
|
.replace("%color_checked%",FMColor(color[FM_COLOR_SET_CHECKED]))
|
|
.replace("%color_disabled%",FMColor(color[FM_COLOR_SET_DISABLED])));
|
|
|
|
//btn->setObjectName(iconName);
|
|
if(size.width() > 0 && size.height() > 0) {
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
} else if (size.height() > 0) {
|
|
btn->setFixedHeight(size.height());
|
|
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
|
} else if (size.width() > 0) {
|
|
btn->setFixedWidth(size.width());
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
|
|
}
|
|
layout->addWidget(btn);
|
|
return btn;
|
|
}
|
|
FMButton* FMButton::btnTypeTextColor(QWidget* parent, QLayout* layout,QString title, QString toolTip, QSize size, FM_COLOR_SET* color)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
if(title.length() > 0) {
|
|
btn->setText(title);
|
|
}
|
|
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
color : #%color_normal%;\
|
|
font-family: 'Fixedsys';\
|
|
font-size: 13px;\
|
|
background-color: transparent;\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
color : #%color_pressed%;\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
color: #%color_hover%;\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
color: #%color_checked%;\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
color: #%color_disabled%;\
|
|
}";
|
|
#else
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
color : #%color_normal%;\
|
|
font-family: 'Malgun Gothic';\
|
|
font-size: 16px;\
|
|
background-color: transparent;\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
color : #%color_pressed%;\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
color: #%color_hover%;\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
color: #%color_checked%;\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
color: #%color_disabled%;\
|
|
}";
|
|
#endif // #RM_MODEL_TYPE_AN6000
|
|
btn->setStyleSheet(src.replace("%color_normal%",FMColor(color[FM_COLOR_SET_NORMAL]))
|
|
.replace("%color_pressed%",FMColor(color[FM_COLOR_SET_PRESSED]))
|
|
.replace("%color_hover%",FMColor(color[FM_COLOR_SET_HOVER]))
|
|
.replace("%color_checked%",FMColor(color[FM_COLOR_SET_CHECKED]))
|
|
.replace("%color_disabled%",FMColor(color[FM_COLOR_SET_DISABLED])));
|
|
|
|
//btn->setObjectName(iconName);
|
|
if(size.width() > 0 && size.height() > 0) {
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
} else if (size.height() > 0) {
|
|
btn->setFixedHeight(size.height());
|
|
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
|
} else if (size.width() > 0) {
|
|
btn->setFixedWidth(size.width());
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
|
|
}
|
|
layout->addWidget(btn);
|
|
return btn;
|
|
}
|
|
FMButton* FMButton::btnEmpty(QWidget* parent, QLayout* layout,QString toolTip, QSize size, FM_COLOR_SET* color)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
border:1px solid #666666;\
|
|
background-color: #%color_normal%;\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
background-color: #%color_pressed%;\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
background-color: #%color_hover%;\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
background-color: #%color_checked%;\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
background-color: #%color_disabled%;\
|
|
}";
|
|
btn->setStyleSheet(src.replace("%color_normal%",FMColor(color[FM_COLOR_SET_NORMAL]))
|
|
.replace("%color_pressed%",FMColor(color[FM_COLOR_SET_PRESSED]))
|
|
.replace("%color_hover%",FMColor(color[FM_COLOR_SET_HOVER]))
|
|
.replace("%color_checked%",FMColor(color[FM_COLOR_SET_CHECKED]))
|
|
.replace("%color_disabled%",FMColor(color[FM_COLOR_SET_DISABLED]))
|
|
);
|
|
|
|
if(size.width() > 0 && size.height() > 0) {
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
} else if (size.height() > 0) {
|
|
btn->setFixedHeight(size.height());
|
|
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
|
} else if (size.width() > 0) {
|
|
btn->setFixedWidth(size.width());
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
|
|
}
|
|
layout->addWidget(btn);
|
|
return btn;
|
|
}
|
|
FMButton* FMButton::btnType0(QWidget* parent, QLayout* layout,const char* iconName, QString toolTip, QSize size, FM_COLOR_SET* color)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
//btn->_setColorStyleSheet(iconName,color);
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
border:1px solid #666666;\
|
|
image: url(:/image/%name%.png);\
|
|
background-color: #%color_normal%;\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
background-color: #%color_pressed%;\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
background-color: #%color_hover%;\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
background-color: #%color_checked%;\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
background-color: #%color_disabled%;\
|
|
}";
|
|
btn->setStyleSheet(src.replace("%name%",iconName)
|
|
.replace("%color_normal%",FMColor(color[FM_COLOR_SET_NORMAL]))
|
|
.replace("%color_pressed%",FMColor(color[FM_COLOR_SET_PRESSED]))
|
|
.replace("%color_hover%",FMColor(color[FM_COLOR_SET_HOVER]))
|
|
.replace("%color_checked%",FMColor(color[FM_COLOR_SET_CHECKED]))
|
|
.replace("%color_disabled%",FMColor(color[FM_COLOR_SET_DISABLED]))
|
|
.replace("%name%",iconName));
|
|
|
|
btn->setObjectName(iconName);
|
|
if(size.width() > 0 && size.height() > 0) {
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
} else if (size.height() > 0) {
|
|
btn->setFixedHeight(size.height());
|
|
btn->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
|
} else if (size.width() > 0) {
|
|
btn->setFixedWidth(size.width());
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
|
|
}
|
|
layout->addWidget(btn);
|
|
return btn;
|
|
}
|
|
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
FMButton* FMButton::btnColor2(QWidget* parent, QLayout* layout, const char* iconName, const char* toolTip, QSize size, FM_COLOR_SET* color)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
#if (LIVE_LANGUAGE2)
|
|
btn->type = BUTTON_TYPE_COLOR_ICON;
|
|
#endif
|
|
|
|
if(toolTip != NULL) {
|
|
btn->setToolTip(FMS::txt(toolTip));
|
|
}
|
|
btn->_setColorStyleSheet(iconName,color);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
layout->addWidget(btn);
|
|
|
|
if(color != NULL) {
|
|
for(int i=0;i<FM_COLOR_SET_COUNT;i++) {
|
|
btn->colorset[i] = color[i];
|
|
}
|
|
}
|
|
|
|
#if(LIVE_LANGUAGE_CHANGE)
|
|
if(toolTip != NULL) {
|
|
RMLanguage::instance()->append(toolTip,RMLanguage::TOOLTIP_TEXT,btn);
|
|
}
|
|
#endif
|
|
return btn;
|
|
}
|
|
#else // LIVE_LANGUAGE2
|
|
FMButton* FMButton::btnColor(QWidget* parent, QLayout* layout, const char* iconName, QString toolTip, QSize size, FM_COLOR_SET* color)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
#if (LIVE_LANGUAGE2)
|
|
btn->type = BUTTON_TYPE_COLOR_ICON;
|
|
#endif
|
|
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
btn->_setColorStyleSheet(iconName,color);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
layout->addWidget(btn);
|
|
#if (LIVE_LANGUAGE2)
|
|
if(color != NULL) {
|
|
for(int i=0;i<FM_COLOR_SET_COUNT;i++) {
|
|
btn->colorset[i] = color[i];
|
|
}
|
|
}
|
|
#endif // #if (LIVE_LANGUAGE2)
|
|
|
|
#if(LIVE_LANGUAGE_CHANGE)
|
|
if(toolTip.length() > 0 ) {
|
|
|
|
#if (SUB_MODEL_BV5000)
|
|
RMLanguage::instance()->append(RMLanguage::instance()->language(),RMLanguage::TOOLTIP_TEXT,btn,toolTip);
|
|
#else
|
|
RMLanguage::instance()->append(RMLanguage::LANGUAGE_JP,RMLanguage::TOOLTIP_TEXT,btn,toolTip);
|
|
#endif
|
|
}
|
|
#endif
|
|
return btn;
|
|
}
|
|
#endif // LIVE_LANGUAGE2
|
|
void FMButton::_setStyleSheet(const char* iconName)
|
|
{
|
|
// border: 1px solid red;
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
image: url(:/image/%name%_2.png);\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
image: url(:/image/%name%_1.png);\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
image: url(:/image/%name%_3.png);\
|
|
}";
|
|
setStyleSheet(src.replace("%name%",iconName));
|
|
}
|
|
void FMButton::_setStaticStyleSheet(const char* iconName)
|
|
{
|
|
// border: 1px solid red;
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
}";
|
|
setStyleSheet(src.replace("%name%",iconName));
|
|
}
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
FMButton* FMButton::btnStatic2(QWidget* parent, QLayout* layout, const char* iconName, const char* toolTip, QSize size)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
btn->type = BUTTON_TYPE_STATIC;
|
|
#endif
|
|
|
|
if(toolTip != NULL) {
|
|
btn->setToolTip(FMS::txt(toolTip));
|
|
}
|
|
btn->_setStaticStyleSheet(iconName);
|
|
//LAYOUT_DEBUG(btn);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
layout->addWidget(btn);
|
|
btn->setEnabled(false);
|
|
if(toolTip != NULL) {
|
|
RMLanguage::instance()->append(toolTip,RMLanguage::TOOLTIP_TEXT,btn);
|
|
}
|
|
return btn;
|
|
}
|
|
#else // LIVE_LANGUAGE2
|
|
FMButton* FMButton::btnStatic(QWidget* parent, QLayout* layout, const char* iconName, QString toolTip, QSize size)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
btn->type = BUTTON_TYPE_STATIC;
|
|
#endif
|
|
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
btn->_setStaticStyleSheet(iconName);
|
|
//LAYOUT_DEBUG(btn);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
layout->addWidget(btn);
|
|
btn->setEnabled(false);
|
|
#if(LIVE_LANGUAGE_CHANGE)
|
|
if(toolTip.length() > 0 ) {
|
|
#if (SUB_MODEL_BV5000)
|
|
RMLanguage::instance()->append(RMLanguage::instance()->language(),RMLanguage::TOOLTIP_TEXT,btn,toolTip);
|
|
#else
|
|
RMLanguage::instance()->append(RMLanguage::LANGUAGE_JP,RMLanguage::TOOLTIP_TEXT,btn,toolTip);
|
|
#endif
|
|
}
|
|
#endif
|
|
return btn;
|
|
}
|
|
#endif // LIVE_LANGUAGE2
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
FMButton* FMButton::btn2(QWidget* parent, QLayout* layout, const char* iconName, const char* toolTip, QSize size, int index)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
btn->type = BUTTON_TYPE_ICON;
|
|
#endif
|
|
if(toolTip != NULL) {
|
|
btn->setToolTip(FMS::txt(toolTip));
|
|
}
|
|
btn->_setStyleSheet(iconName);
|
|
//LAYOUT_DEBUG(btn);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
if(index < 0) {
|
|
layout->addWidget(btn);
|
|
}
|
|
else {
|
|
QHBoxLayout* hl = qobject_cast<QHBoxLayout*>(layout);
|
|
if(hl != NULL) {
|
|
hl->insertWidget(index,btn);
|
|
}
|
|
}
|
|
|
|
if(toolTip != NULL) {
|
|
RMLanguage::instance()->append(toolTip,RMLanguage::TOOLTIP_TEXT,btn);
|
|
}
|
|
return btn;
|
|
}
|
|
#else // LIVE_LANGUAGE2
|
|
FMButton* FMButton::btn(QWidget* parent, QLayout* layout, const char* iconName, QString toolTip, QSize size, int index)
|
|
{
|
|
|
|
FMButton* btn = new FMButton(parent);
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
btn->type = BUTTON_TYPE_ICON;
|
|
#endif
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
btn->_setStyleSheet(iconName);
|
|
//LAYOUT_DEBUG(btn);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
if(index < 0) {
|
|
layout->addWidget(btn);
|
|
}
|
|
else {
|
|
QHBoxLayout* hl = qobject_cast<QHBoxLayout*>(layout);
|
|
if(hl != NULL) {
|
|
hl->insertWidget(index,btn);
|
|
}
|
|
}
|
|
|
|
#if(LIVE_LANGUAGE_CHANGE)
|
|
if(toolTip.length() > 0 ) {
|
|
#if (SUB_MODEL_BV5000)
|
|
RMLanguage::instance()->append(RMLanguage::instance()->language(),RMLanguage::TOOLTIP_TEXT,btn,toolTip);
|
|
#else
|
|
RMLanguage::instance()->append(RMLanguage::LANGUAGE_JP,RMLanguage::TOOLTIP_TEXT,btn,toolTip);
|
|
#endif
|
|
}
|
|
#endif
|
|
return btn;
|
|
}
|
|
#endif // LIVE_LANGUAGE2
|
|
|
|
void FMButton::updateProperty(const char* property,bool enable)
|
|
{
|
|
//qInfo() << "property:" << enable << __FUNCTION__;
|
|
setProperty(property,enable);
|
|
style()->unpolish(this);
|
|
style()->polish(this);
|
|
update();
|
|
}
|
|
|
|
void FMButton::_setPropertyStyleSheet(const char* iconName,const char* property) {
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
image: url(:/image/%name%_2.png);\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
image: url(:/image/%name%_1.png);\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
image: url(:/image/%name%_3.png);\
|
|
}\
|
|
FMButton[%property%=true]\
|
|
{\
|
|
image: url(:/image/%name%_%property%.png);\
|
|
}\
|
|
\
|
|
FMButton:pressed[%property%=true]\
|
|
{\
|
|
image: url(:/image/%name%_%property%_2.png);\
|
|
}\
|
|
FMButton:hover:!pressed[%property%=true]\
|
|
{\
|
|
image: url(:/image/%name%_%property%_1.png);\
|
|
}\
|
|
FMButton:disabled[%property%=true]\
|
|
{\
|
|
image: url(:/image/%name%_%property%_3.png);\
|
|
}";
|
|
//qInfo() << src.replace("%name%",iconName).replace("%property%",property) << __FUNCTION__;
|
|
setStyleSheet(src.replace("%name%",iconName).replace("%property%",property));
|
|
}
|
|
void FMButton::_setCheckStyleSheet(const char* iconName)
|
|
{
|
|
// border: 1px solid red;
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
image: url(:/image/%name%_2.png);\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
image: url(:/image/%name%_1.png);\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
image: url(:/image/%name%_3.png);\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
image: url(:/image/%name%_checked.png);\
|
|
}\
|
|
\
|
|
FMButton:checked:pressed\
|
|
{\
|
|
image: url(:/image/%name%_checked_2.png);\
|
|
}\
|
|
FMButton:checked:hover:!pressed\
|
|
{\
|
|
image: url(:/image/%name%_checked_1.png);\
|
|
}\
|
|
FMButton:checked:disabled\
|
|
{\
|
|
image: url(:/image/%name%_checked_3.png);\
|
|
}";
|
|
setStyleSheet(src.replace("%name%",iconName));
|
|
}
|
|
void FMButton::_setPressCheckStyleSheet(const char* iconName)
|
|
{
|
|
|
|
// border: 1px solid red;
|
|
QString src = "\
|
|
FMButton\
|
|
{\
|
|
image: url(:/image/%name%.png);\
|
|
}\
|
|
\
|
|
FMButton:pressed\
|
|
{\
|
|
image: url(:/image/%name%_2.png);\
|
|
}\
|
|
FMButton:hover:!pressed\
|
|
{\
|
|
image: url(:/image/%name%_1.png);\
|
|
}\
|
|
FMButton:disabled\
|
|
{\
|
|
image: url(:/image/%name%_3.png);\
|
|
}\
|
|
FMButton:checked\
|
|
{\
|
|
image: url(:/image/%name%_1.png);\
|
|
}";
|
|
setStyleSheet(src.replace("%name%",iconName));
|
|
}
|
|
void FMButton::blockFor(int ms)
|
|
{
|
|
setEnabled(false);
|
|
QTimer::singleShot(ms, [this]() {
|
|
setEnabled(true);
|
|
});
|
|
}
|
|
|
|
|
|
#if (LIVE_LANGUAGE2)
|
|
FMButton* FMButton::btnPressCheck2(QWidget* parent, QLayout* layout, const char* iconName, const char* toolTip)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
btn->type = BUTTON_TYPE_CHECK_ICON;
|
|
btn->setCheckable(true);
|
|
if(toolTip != NULL) {
|
|
btn->setToolTip(FMS::txt(toolTip));
|
|
}
|
|
btn->_setPressCheckStyleSheet(iconName);
|
|
//LAYOUT_DEBUG(btn);
|
|
|
|
btn->setObjectName(iconName);
|
|
//btn->setFixedSize(size);
|
|
//btn->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Fixed);
|
|
layout->addWidget(btn);
|
|
|
|
if(toolTip != NULL) {
|
|
RMLanguage::instance()->append(toolTip,RMLanguage::TOOLTIP_TEXT,btn);
|
|
}
|
|
return btn;
|
|
}
|
|
FMButton* FMButton::btnProperty(QWidget* parent, QLayout* layout, const char* iconName, const char* toolTip, const char* property, QSize size)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
btn->type = BUTTON_TYPE_PROPERTY_ICON;
|
|
if(toolTip != NULL) {
|
|
btn->setToolTip(FMS::txt(toolTip));
|
|
}
|
|
btn->_setPropertyStyleSheet(iconName,property);
|
|
//LAYOUT_DEBUG(btn);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
layout->addWidget(btn);
|
|
|
|
if(toolTip != NULL) {
|
|
RMLanguage::instance()->append(toolTip,RMLanguage::TOOLTIP_TEXT,btn);
|
|
}
|
|
return btn;
|
|
}
|
|
|
|
FMButton* FMButton::btnCheck2(QWidget* parent, QLayout* layout, const char* iconName, const char* toolTip, QSize size)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
btn->type = BUTTON_TYPE_CHECK_ICON;
|
|
btn->setCheckable(true);
|
|
if(toolTip != NULL) {
|
|
btn->setToolTip(FMS::txt(toolTip));
|
|
}
|
|
btn->_setCheckStyleSheet(iconName);
|
|
//LAYOUT_DEBUG(btn);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
layout->addWidget(btn);
|
|
|
|
if(toolTip != NULL) {
|
|
RMLanguage::instance()->append(toolTip,RMLanguage::TOOLTIP_TEXT,btn);
|
|
}
|
|
return btn;
|
|
}
|
|
#else // LIVE_LANGUAGE2
|
|
FMButton* FMButton::btnCheck(QWidget* parent, QLayout* layout, const char* iconName, QString toolTip, QSize size)
|
|
{
|
|
FMButton* btn = new FMButton(parent);
|
|
#if (LIVE_LANGUAGE2)
|
|
btn->type = BUTTON_TYPE_CHECK_ICON;
|
|
#endif
|
|
btn->setCheckable(true);
|
|
if(toolTip.length() > 0 ) {
|
|
btn->setToolTip(toolTip);
|
|
}
|
|
btn->_setCheckStyleSheet(iconName);
|
|
//LAYOUT_DEBUG(btn);
|
|
btn->setObjectName(iconName);
|
|
btn->setFixedSize(size);
|
|
btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
|
layout->addWidget(btn);
|
|
|
|
#if(LIVE_LANGUAGE_CHANGE)
|
|
if(toolTip.length() > 0 ) {
|
|
#if (SUB_MODEL_BV5000)
|
|
RMLanguage::instance()->append(RMLanguage::instance()->language(),RMLanguage::TOOLTIP_TEXT,btn,toolTip);
|
|
#else
|
|
RMLanguage::instance()->append(RMLanguage::LANGUAGE_JP,RMLanguage::TOOLTIP_TEXT,btn,toolTip);
|
|
#endif
|
|
}
|
|
#endif
|
|
return btn;
|
|
}
|
|
#endif // LIVE_LANGUAGE2
|
|
|
|
|