theshell/clickablelabel.cpp
2016-05-29 17:03:52 +10:00

38 lines
1 KiB
C++

#include "clickablelabel.h"
ClickableLabel::ClickableLabel(QWidget* parent) :
QLabel(parent)
{
}
void ClickableLabel::mousePressEvent(QMouseEvent *event) {
emit clicked();
event->accept();
}
void ClickableLabel::mouseMoveEvent(QMouseEvent *event) {
event->accept();
}
void ClickableLabel::mouseReleaseEvent(QMouseEvent *event) {
event->accept();
}
bool ClickableLabel::showDisabled() {
return isShowDisabled;
}
void ClickableLabel::setShowDisabled(bool showDisabled) {
isShowDisabled = showDisabled;
QPalette applicationPal = QApplication::palette(new QLabel());
QPalette thisPal = this->palette();
if (isShowDisabled) {
//thisPal.setCurrentColorGroup(QPalette::Disabled);
thisPal.setBrush(QPalette::WindowText, applicationPal.brush(QPalette::Disabled, QPalette::WindowText));
} else {
//thisPal.setCurrentColorGroup(QPalette::Active);
thisPal.setBrush(QPalette::WindowText, applicationPal.brush(QPalette::Normal, QPalette::WindowText));
}
this->setPalette(thisPal);
}