style improve
This commit is contained in:
@@ -7,11 +7,7 @@
|
||||
ImageSwitch::ImageSwitch(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
isChecked = false;
|
||||
buttonStyle = ButtonStyle_2;
|
||||
|
||||
imgOffFile = ":/image/imageswitch/btncheckoff2.png";
|
||||
imgOnFile = ":/image/imageswitch/btncheckon2.png";
|
||||
imgFile = imgOffFile;
|
||||
setButtonStyle(ButtonStyle_1);
|
||||
}
|
||||
|
||||
void ImageSwitch::mousePressEvent(QMouseEvent*)
|
||||
@@ -19,7 +15,7 @@ void ImageSwitch::mousePressEvent(QMouseEvent*)
|
||||
imgFile = isChecked ? imgOffFile : imgOnFile;
|
||||
isChecked = !isChecked;
|
||||
this->update();
|
||||
emit clicked();
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
void ImageSwitch::paintEvent(QPaintEvent*)
|
||||
@@ -48,12 +44,12 @@ ImageSwitch::ButtonStyle ImageSwitch::getButtonStyle() const
|
||||
|
||||
QSize ImageSwitch::sizeHint() const
|
||||
{
|
||||
return QSize(87, 28);
|
||||
return QSize(220, 64);
|
||||
}
|
||||
|
||||
QSize ImageSwitch::minimumSizeHint() const
|
||||
{
|
||||
return QSize(87, 28);
|
||||
return sizeHint();
|
||||
}
|
||||
|
||||
void ImageSwitch::setChecked(bool isChecked)
|
||||
@@ -73,17 +69,17 @@ void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle& buttonStyle)
|
||||
if (buttonStyle == ButtonStyle_1) {
|
||||
imgOffFile = ":/icons/imageswitch/btncheckoff1.png";
|
||||
imgOnFile = ":/icons/imageswitch/btncheckon1.png";
|
||||
this->resize(87, 28);
|
||||
this->resize(sizeHint());
|
||||
}
|
||||
else if (buttonStyle == ButtonStyle_2) {
|
||||
imgOffFile = ":/icons/imageswitch/btncheckoff2.png";
|
||||
imgOnFile = ":/icons/imageswitch/btncheckon2.png";
|
||||
this->resize(87, 28);
|
||||
this->resize(sizeHint());
|
||||
}
|
||||
else if (buttonStyle == ButtonStyle_3) {
|
||||
imgOffFile = ":/icons/imageswitch/btncheckoff3.png";
|
||||
imgOnFile = ":/icons/imageswitch/btncheckon3.png";
|
||||
this->resize(96, 38);
|
||||
this->resize(sizeHint());
|
||||
}
|
||||
|
||||
imgFile = isChecked ? imgOnFile : imgOffFile;
|
||||
|
||||
Reference in New Issue
Block a user