-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14355 from ronso0/con-sett-clicklabelcheck
add `WSettingsCheckBoxLabel` to replace the click eventFilter
- Loading branch information
Showing
5 changed files
with
47 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "widget/wsettingscheckboxlabel.h" | ||
|
||
#include <QCheckBox> | ||
#include <QMouseEvent> | ||
|
||
#include "moc_wsettingscheckboxlabel.cpp" | ||
|
||
void WSettingsCheckBoxLabel::mousePressEvent(QMouseEvent* pEvent) { | ||
if (pEvent->buttons().testFlag(Qt::LeftButton)) { | ||
QCheckBox* pCB = qobject_cast<QCheckBox*>(buddy()); | ||
if (pCB) { | ||
pCB->toggle(); | ||
pCB->setFocus(Qt::MouseFocusReason); | ||
} | ||
} | ||
QLabel::mousePressEvent(pEvent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <QLabel> | ||
|
||
/// This is a QLabel for use in controller settings. | ||
/// It is expected to have a QCheckBox buddy assigned. If so, left-click on the | ||
/// label will toggle the checkbox and set focus on it. | ||
class WSettingsCheckBoxLabel : public QLabel { | ||
Q_OBJECT | ||
public: | ||
explicit WSettingsCheckBoxLabel(QWidget* pParent = nullptr, | ||
Qt::WindowFlags flags = Qt::WindowFlags()) | ||
: QLabel(pParent, flags) { | ||
|
||
}; | ||
explicit WSettingsCheckBoxLabel(const QString& text, | ||
QWidget* pParent = nullptr, | ||
Qt::WindowFlags flags = Qt::WindowFlags()) | ||
: QLabel(text, pParent, flags) { | ||
}; | ||
|
||
protected: | ||
void mousePressEvent(QMouseEvent* pEvent) override; | ||
}; |