Selectable label in button color edition
This commit is contained in:
@@ -46,7 +46,8 @@ SOURCES += src/main.cpp\
|
||||
src/config/buttonlistview.cpp \
|
||||
src/config/uicoloreditor.cpp \
|
||||
src/config/geneneralconf.cpp \
|
||||
src/flameshotdbusadapter.cpp
|
||||
src/flameshotdbusadapter.cpp \
|
||||
src/config/clickablelabel.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/controller.h \
|
||||
@@ -61,7 +62,8 @@ HEADERS += \
|
||||
src/config/buttonlistview.h \
|
||||
src/config/uicoloreditor.h \
|
||||
src/config/geneneralconf.h \
|
||||
src/flameshotdbusadapter.h
|
||||
src/flameshotdbusadapter.h \
|
||||
src/config/clickablelabel.h
|
||||
|
||||
RESOURCES += \
|
||||
graphics.qrc
|
||||
|
||||
14
src/config/clickablelabel.cpp
Normal file
14
src/config/clickablelabel.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "clickablelabel.h"
|
||||
|
||||
|
||||
ClickableLabel::ClickableLabel(QWidget *parent) : QLabel(parent) {
|
||||
|
||||
}
|
||||
|
||||
ClickableLabel::ClickableLabel(QString s, QWidget *parent) : QLabel(parent) {
|
||||
setText(s);
|
||||
}
|
||||
|
||||
void ClickableLabel::mousePressEvent(QMouseEvent *) {
|
||||
Q_EMIT clicked();
|
||||
}
|
||||
20
src/config/clickablelabel.h
Normal file
20
src/config/clickablelabel.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef CLICKABLELABEL_H
|
||||
#define CLICKABLELABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class ClickableLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ClickableLabel(QWidget *parent = nullptr);
|
||||
ClickableLabel(QString s, QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
private:
|
||||
void mousePressEvent (QMouseEvent *) ;
|
||||
};
|
||||
|
||||
#endif // CLICKABLELABEL_H
|
||||
@@ -16,12 +16,12 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "uicoloreditor.h"
|
||||
#include "clickablelabel.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QSettings>
|
||||
#include <QComboBox>
|
||||
#include <QMap>
|
||||
#include <QLabel>
|
||||
|
||||
UIcolorEditor::UIcolorEditor(QWidget *parent) : QFrame(parent) {
|
||||
setFrameStyle(QFrame::StyledPanel);
|
||||
@@ -90,7 +90,7 @@ void UIcolorEditor::initButtons() {
|
||||
m_buttonMainColor->move(m_buttonMainColor->x() + extraSize/2, m_buttonMainColor->y() + extraSize/2);
|
||||
QHBoxLayout *h1 = new QHBoxLayout();
|
||||
h1->addWidget(frame);
|
||||
m_labelMain = new QLabel(tr("Main Color"), this);
|
||||
m_labelMain = new ClickableLabel(tr("Main Color"), this);
|
||||
h1->addWidget(m_labelMain);
|
||||
vLayout->addLayout(h1);
|
||||
|
||||
@@ -109,7 +109,7 @@ void UIcolorEditor::initButtons() {
|
||||
|
||||
QHBoxLayout *h2 = new QHBoxLayout();
|
||||
h2->addWidget(frame2);
|
||||
m_labelContrast = new QLabel(tr("Contrast Color"), this);
|
||||
m_labelContrast = new ClickableLabel(tr("Contrast Color"), this);
|
||||
m_labelContrast->setStyleSheet("QLabel { color : gray; }");
|
||||
h2->addWidget(m_labelContrast);
|
||||
vLayout->addLayout(h2);
|
||||
@@ -122,6 +122,11 @@ void UIcolorEditor::initButtons() {
|
||||
this, &UIcolorEditor::changeLastButton);
|
||||
connect(m_buttonContrast, &Button::pressedButton,
|
||||
this, &UIcolorEditor::changeLastButton);
|
||||
// clicking the labels chages the button too
|
||||
connect(m_labelMain, &ClickableLabel::clicked,
|
||||
this, [this]{ changeLastButton(m_buttonMainColor); });
|
||||
connect(m_labelContrast, &ClickableLabel::clicked,
|
||||
this, [this]{ changeLastButton(m_buttonContrast); });
|
||||
}
|
||||
|
||||
void UIcolorEditor::updateButtonIcon() {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
class Button;
|
||||
class QLabel;
|
||||
class ClickableLabel;
|
||||
|
||||
class UIcolorEditor : public QFrame {
|
||||
Q_OBJECT
|
||||
@@ -41,9 +41,9 @@ private slots:
|
||||
private:
|
||||
QColor m_uiColor, m_contrastColor;
|
||||
Button *m_buttonMainColor;
|
||||
QLabel *m_labelMain;
|
||||
ClickableLabel *m_labelMain;
|
||||
Button *m_buttonContrast;
|
||||
QLabel *m_labelContrast;
|
||||
ClickableLabel *m_labelContrast;
|
||||
Button *m_lastButtonPressed;
|
||||
color_widgets::ColorWheel *m_colorWheel;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user