qDebug() << __PRETTY_FUNCTION__;
// If there is a file name provided for icon image, use it as the icon for the button
- if (normalIconPictureFileName != "") {
+ if (!normalIconPictureFileName.isEmpty()) {
QPixmap iconPixmap(normalIconPictureFileName);
QSize buttonSize = iconPixmap.size(); // Get the button size from the normal state icon picture
QIcon icon(iconPixmap);
// If there is a picture for selected state, use it instead of a simple highlight change
- if(selectedIconPictureFileName != "")
+ if(!selectedIconPictureFileName.isEmpty())
icon.addFile(selectedIconPictureFileName, buttonSize, QIcon::Selected);
- setIcon(icon);
- setIconSize(buttonSize);
- setFixedSize(buttonSize);
+ initButton(buttonSize, icon);
}
}
void ImageButton::setButtonIcon(const QPixmap &image)
{
+ qDebug() << __PRETTY_FUNCTION__;
+
QSize buttonSize = image.size(); // Get the button size from the normal state icon picture
QIcon icon(image);
- setIcon(icon);
- setIconSize(buttonSize);
- setFixedSize(buttonSize);
+ initButton(buttonSize, icon);
}
void ImageButton::mousePressEvent(QMouseEvent *event)
return m_buttonMode;
}
+
+void ImageButton::initButton(const QSize &size, const QIcon &icon)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ setIcon(icon);
+ setIconSize(size);
+ setFixedSize(size);
+}