use profile image as button.
compassLabel->setContentsMargins(0, 0, MARGIN, 0);
compassLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
- m_imageLabel = new QLabel();
- m_imageLabel->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
-
m_nameLabel = new QLabel();
m_nameLabel->setFixedHeight(IMAGE_HEIGHT);
m_distanceImageLabel = new QLabel();
m_distanceImageLabel->setFixedSize(ICON_WIDTH, ICON_HEIGHT);
- m_findButton = new ImageButton(this, ":/res/images/show_position.png",
- ":/res/images/show_position_s.png");
+ m_findButton = new ImageButton(this);
m_updatedLabel = new QLabel();
m_updatedLabel->setWordWrap(true);
infoLayout->addRow(compassLabel, m_locationLabel);
infoLayout->addRow(clockLabel, m_updatedLabel);
- topLayout->addWidget(m_imageLabel);
+ topLayout->addWidget(m_findButton);
topLayout->addWidget(m_nameLabel, 1);
topLayout->addLayout(distanceLayout);
- bottomLayout->addWidget(m_findButton, 0, Qt::AlignTop);
+ bottomLayout->addSpacing(IMAGE_WIDTH);
bottomLayout->addLayout(infoLayout);
layout->addLayout(topLayout, 0);
m_user = user;
- m_imageLabel->setPixmap(m_user->profileImage());
+ m_findButton->setButtonIcon(m_user->profileImage());
QString unit;
double value;
QLabel *m_distanceImageLabel; ///< Distance image for friend label
QLabel *m_distanceTextLabel; ///< Distance text for friend label
ImageButton *m_findButton; ///< Friend find button
- QLabel *m_imageLabel; ///< Image label
QLabel *m_locationLabel; ///< Location label
QPoint m_mousePosition; ///< Current mouse press position
QLabel *m_nameLabel; ///< Name label
{
qDebug() << __PRETTY_FUNCTION__;
- QPixmap iconPixmap(normalIconPictureFileName);
- m_buttonSize = iconPixmap.size(); // Get the button size from the normal state icon picture
- QIcon icon(iconPixmap);
+ if (normalIconPictureFileName != "") {
+ QPixmap iconPixmap(normalIconPictureFileName);
+ m_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 != "")
+ icon.addFile(selectedIconPictureFileName, m_buttonSize, QIcon::Selected);
+
+ setIcon(icon);
+ setIconSize(m_buttonSize);
+ setFixedSize(m_buttonSize);
+ }
+}
- // If there is a picture for selected state, use it instead of a simple highlight change
- if(selectedIconPictureFileName != "")
- icon.addFile(selectedIconPictureFileName, m_buttonSize, QIcon::Selected);
+void ImageButton::setButtonIcon(const QPixmap &image)
+{
+ m_buttonSize = image.size(); // Get the button size from the normal state icon picture
+ QIcon icon(image);
setIcon(icon);
setIconSize(m_buttonSize);
******************************************************************************/
public:
/**
+ * @brief Set button icon.
+ *
+ * @param image image pixmap
+ */
+ void setButtonIcon(const QPixmap &image);
+
+ /**
* @brief Sets the button icon mode
*
* @param mode Button icon mode