Changeset View
Changeset View
Standalone View
Standalone View
kstyle/demo/oxygenframedemowidget.cpp
Show All 19 Lines | |||||
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | 23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
24 | // IN THE SOFTWARE. | 24 | // IN THE SOFTWARE. | ||
25 | ////////////////////////////////////////////////////////////////////////////// | 25 | ////////////////////////////////////////////////////////////////////////////// | ||
26 | 26 | | |||
27 | #include "oxygenframedemowidget.h" | 27 | #include "oxygenframedemowidget.h" | ||
28 | #include "config-liboxygen.h" | ||||
28 | 29 | | |||
29 | #include <QButtonGroup> | 30 | #include <QButtonGroup> | ||
30 | 31 | | |||
31 | #include <KComboBox> | 32 | #include <KComboBox> | ||
32 | #include <KMessageWidget> | 33 | #include <KMessageWidget> | ||
34 | #if !OXYGEN_USE_KDE4 | ||||
33 | #include <kwidgetsaddons_version.h> | 35 | #include <kwidgetsaddons_version.h> | ||
36 | #endif | ||||
34 | 37 | | |||
35 | namespace Oxygen | 38 | namespace Oxygen | ||
36 | { | 39 | { | ||
37 | 40 | | |||
38 | //_____________________________________________________________ | 41 | //_____________________________________________________________ | ||
39 | FrameDemoWidget::FrameDemoWidget( QWidget* parent ): | 42 | FrameDemoWidget::FrameDemoWidget( QWidget* parent ): | ||
40 | DemoWidget( parent ), | 43 | DemoWidget( parent ), | ||
41 | posMsg(nullptr), | 44 | posMsg(nullptr), | ||
Show All 11 Lines | 48 | { | |||
53 | connect( ui.raisedFrameRadioButton, SIGNAL(toggled(bool)), SLOT(toggleRaisedFrame(bool)) ); | 56 | connect( ui.raisedFrameRadioButton, SIGNAL(toggled(bool)), SLOT(toggleRaisedFrame(bool)) ); | ||
54 | connect( ui.plainFrameRadioButton, SIGNAL(toggled(bool)), SLOT(togglePlainFrame(bool)) ); | 57 | connect( ui.plainFrameRadioButton, SIGNAL(toggled(bool)), SLOT(togglePlainFrame(bool)) ); | ||
55 | connect( ui.sunkenFrameRadioButton, SIGNAL(toggled(bool)), SLOT(toggleSunkenFrame(bool)) ); | 58 | connect( ui.sunkenFrameRadioButton, SIGNAL(toggled(bool)), SLOT(toggleSunkenFrame(bool)) ); | ||
56 | 59 | | |||
57 | connect( ui.directionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateLayoutDirection(int)) ); | 60 | connect( ui.directionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateLayoutDirection(int)) ); | ||
58 | connect( ui.flatGroupBoxCheckBox, SIGNAL(toggled(bool)), SLOT(toggleFlatGroupBox(bool)) ); | 61 | connect( ui.flatGroupBoxCheckBox, SIGNAL(toggled(bool)), SLOT(toggleFlatGroupBox(bool)) ); | ||
59 | 62 | | |||
60 | addMessages(); | 63 | addMessages(); | ||
61 | #if KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 48, 0) | 64 | #if !OXYGEN_USE_KDE4 && KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 48, 0) | ||
62 | qApp->installEventFilter(this); | 65 | qApp->installEventFilter(this); | ||
63 | #endif | 66 | #endif | ||
64 | } | 67 | } | ||
65 | 68 | | |||
66 | void FrameDemoWidget::addMessages() | 69 | void FrameDemoWidget::addMessages() | ||
67 | { | 70 | { | ||
68 | delete posMsg; | 71 | delete posMsg; | ||
69 | delete infoMsg; | 72 | delete infoMsg; | ||
Show All 13 Lines | |||||
83 | ui.verticalLayout_5->addWidget(infoMsg); | 86 | ui.verticalLayout_5->addWidget(infoMsg); | ||
84 | 87 | | |||
85 | warnMsg = new KMessageWidget(QStringLiteral("A warning message"), ui.msgFrame); | 88 | warnMsg = new KMessageWidget(QStringLiteral("A warning message"), ui.msgFrame); | ||
86 | warnMsg->setMessageType(KMessageWidget::Warning); | 89 | warnMsg->setMessageType(KMessageWidget::Warning); | ||
87 | warnMsg->setWordWrap(true); | 90 | warnMsg->setWordWrap(true); | ||
88 | warnMsg->setIcon(QIcon::fromTheme("dialog-warning")); | 91 | warnMsg->setIcon(QIcon::fromTheme("dialog-warning")); | ||
89 | ui.verticalLayout_5->addWidget(warnMsg); | 92 | ui.verticalLayout_5->addWidget(warnMsg); | ||
90 | 93 | | |||
91 | errMsg = new KMessageWidget(QStringLiteral("An error message"), ui.msgFrame); | 94 | errMsg = new KMessageWidget(QStringLiteral("An error message"), ui.msgFrame); | ||
broulik: What do you need this for? | |||||
That's to catch the event sent to the qApp instance when the theme is changed (to be exact: after KColorSchemeManager sets or changes the KDE_COLOR_SCHEME_PATH property. Without this, the messages don't adapt to reflect the new colours (even the current implementation mixes the window background into its background colour). rjvbb: That's to catch the event sent to the qApp instance when the theme is changed (to be exact… | |||||
I think you're working around a bug here. KColorSchemeManager does qApp->setPalette(KColorScheme::createApplicationPalette(KSharedConfig::openConfig(action->data().toString()))); so the KMessageWidget should get a PaletteChange event and adjust, if not, it's a bug there. broulik: I think you're working around a bug here. `KColorSchemeManager` does
```
qApp->setPalette… | |||||
92 | errMsg->setMessageType(KMessageWidget::Error); | 95 | errMsg->setMessageType(KMessageWidget::Error); | ||
93 | errMsg->setWordWrap(true); | 96 | errMsg->setWordWrap(true); | ||
94 | errMsg->setIcon(QIcon::fromTheme("dialog-error")); | 97 | errMsg->setIcon(QIcon::fromTheme("dialog-error")); | ||
95 | ui.verticalLayout_5->addWidget(errMsg); | 98 | ui.verticalLayout_5->addWidget(errMsg); | ||
96 | 99 | | |||
97 | ui.verticalLayout_5->addStretch(); | 100 | ui.verticalLayout_5->addStretch(); | ||
98 | } | 101 | } | ||
99 | 102 | | |||
100 | bool FrameDemoWidget::eventFilter( QObject *obj, QEvent *event ) | 103 | bool FrameDemoWidget::eventFilter( QObject *obj, QEvent *event ) | ||
101 | { | 104 | { | ||
102 | #if KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 48, 0) | 105 | #if !OXYGEN_USE_KDE4 && KWIDGETSADDONS_VERSION < QT_VERSION_CHECK(5, 48, 0) | ||
103 | if (event->type() == QEvent::DynamicPropertyChange && obj == qApp) { | 106 | if (event->type() == QEvent::DynamicPropertyChange && obj == qApp) { | ||
104 | QDynamicPropertyChangeEvent *e = dynamic_cast<QDynamicPropertyChangeEvent*>(event); | 107 | QDynamicPropertyChangeEvent *e = dynamic_cast<QDynamicPropertyChangeEvent*>(event); | ||
105 | if (e->propertyName() == QByteArrayLiteral("KDE_COLOR_SCHEME_PATH")) { | 108 | if (e->propertyName() == QByteArrayLiteral("KDE_COLOR_SCHEME_PATH")) { | ||
106 | addMessages(); | 109 | addMessages(); | ||
107 | } | 110 | } | ||
108 | } | 111 | } | ||
109 | #else | 112 | #else | ||
110 | Q_UNUSED(obj); | 113 | Q_UNUSED(obj); | ||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
What do you need this for?