Changeset View
Changeset View
Standalone View
Standalone View
kstyle/demo/oxygenframedemowidget.cpp
Show All 23 Lines | |||||
24 | // IN THE SOFTWARE. | 24 | // IN THE SOFTWARE. | ||
25 | ////////////////////////////////////////////////////////////////////////////// | 25 | ////////////////////////////////////////////////////////////////////////////// | ||
26 | 26 | | |||
27 | #include "oxygenframedemowidget.h" | 27 | #include "oxygenframedemowidget.h" | ||
28 | 28 | | |||
29 | #include <QButtonGroup> | 29 | #include <QButtonGroup> | ||
30 | 30 | | |||
31 | #include <KComboBox> | 31 | #include <KComboBox> | ||
32 | #include <KMessageWidget> | ||||
32 | 33 | | |||
33 | namespace Oxygen | 34 | namespace Oxygen | ||
34 | { | 35 | { | ||
35 | 36 | | |||
36 | //_____________________________________________________________ | 37 | //_____________________________________________________________ | ||
37 | FrameDemoWidget::FrameDemoWidget( QWidget* parent ): | 38 | FrameDemoWidget::FrameDemoWidget( QWidget* parent ): | ||
38 | DemoWidget( parent ) | 39 | DemoWidget( parent ), | ||
40 | posMsg(nullptr), | ||||
41 | infoMsg(nullptr), | ||||
42 | warnMsg(nullptr), | ||||
43 | errMsg(nullptr) | ||||
39 | { | 44 | { | ||
40 | 45 | | |||
41 | ui.setupUi( this ); | 46 | ui.setupUi( this ); | ||
42 | QButtonGroup* group = new QButtonGroup( this ); | 47 | QButtonGroup* group = new QButtonGroup( this ); | ||
43 | group->addButton( ui.raisedFrameRadioButton ); | 48 | group->addButton( ui.raisedFrameRadioButton ); | ||
44 | group->addButton( ui.plainFrameRadioButton ); | 49 | group->addButton( ui.plainFrameRadioButton ); | ||
45 | group->addButton( ui.sunkenFrameRadioButton ); | 50 | group->addButton( ui.sunkenFrameRadioButton ); | ||
46 | 51 | | |||
47 | connect( ui.raisedFrameRadioButton, SIGNAL(toggled(bool)), SLOT(toggleRaisedFrame(bool)) ); | 52 | connect( ui.raisedFrameRadioButton, SIGNAL(toggled(bool)), SLOT(toggleRaisedFrame(bool)) ); | ||
48 | connect( ui.plainFrameRadioButton, SIGNAL(toggled(bool)), SLOT(togglePlainFrame(bool)) ); | 53 | connect( ui.plainFrameRadioButton, SIGNAL(toggled(bool)), SLOT(togglePlainFrame(bool)) ); | ||
49 | connect( ui.sunkenFrameRadioButton, SIGNAL(toggled(bool)), SLOT(toggleSunkenFrame(bool)) ); | 54 | connect( ui.sunkenFrameRadioButton, SIGNAL(toggled(bool)), SLOT(toggleSunkenFrame(bool)) ); | ||
50 | 55 | | |||
51 | connect( ui.directionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateLayoutDirection(int)) ); | 56 | connect( ui.directionComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateLayoutDirection(int)) ); | ||
52 | connect( ui.flatGroupBoxCheckBox, SIGNAL(toggled(bool)), SLOT(toggleFlatGroupBox(bool)) ); | 57 | connect( ui.flatGroupBoxCheckBox, SIGNAL(toggled(bool)), SLOT(toggleFlatGroupBox(bool)) ); | ||
53 | 58 | | |||
59 | qApp->installEventFilter(this); | ||||
60 | addMessages(); | ||||
61 | } | ||||
62 | | ||||
63 | void FrameDemoWidget::addMessages() | ||||
64 | { | ||||
65 | delete posMsg; | ||||
66 | delete infoMsg; | ||||
67 | delete warnMsg; | ||||
68 | delete errMsg; | ||||
69 | | ||||
70 | posMsg = new KMessageWidget(QStringLiteral("A positive message"), ui.tab); | ||||
71 | posMsg->setMessageType(KMessageWidget::Positive); | ||||
72 | posMsg->setWordWrap(true); | ||||
73 | ui.verticalLayout_4->addWidget(posMsg); | ||||
74 | infoMsg = new KMessageWidget(QStringLiteral("An information message"), ui.tab); | ||||
75 | infoMsg->setMessageType(KMessageWidget::Information); | ||||
76 | infoMsg->setWordWrap(true); | ||||
77 | ui.verticalLayout_4->addWidget(infoMsg); | ||||
78 | warnMsg = new KMessageWidget(QStringLiteral("A warning message"), ui.tab); | ||||
79 | warnMsg->setMessageType(KMessageWidget::Warning); | ||||
80 | warnMsg->setWordWrap(true); | ||||
81 | ui.verticalLayout_4->addWidget(warnMsg); | ||||
82 | errMsg = new KMessageWidget(QStringLiteral("An error message"), ui.tab); | ||||
83 | errMsg->setMessageType(KMessageWidget::Error); | ||||
84 | errMsg->setWordWrap(true); | ||||
85 | ui.verticalLayout_4->addWidget(errMsg); | ||||
86 | } | ||||
87 | | ||||
88 | bool FrameDemoWidget::eventFilter( QObject *obj, QEvent *event ) | ||||
89 | { | ||||
90 | if (event->type() == QEvent::DynamicPropertyChange && obj == qApp) { | ||||
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… | |||||
91 | QDynamicPropertyChangeEvent *e = dynamic_cast<QDynamicPropertyChangeEvent*>(event); | ||||
92 | if (e->propertyName() == QByteArrayLiteral("KDE_COLOR_SCHEME_PATH")) { | ||||
93 | addMessages(); | ||||
94 | } | ||||
95 | } | ||||
96 | return false; | ||||
54 | } | 97 | } | ||
55 | 98 | | |||
56 | //_____________________________________________________________ | 99 | //_____________________________________________________________ | ||
57 | void FrameDemoWidget::updateLayoutDirection( int value ) | 100 | void FrameDemoWidget::updateLayoutDirection( int value ) | ||
58 | { | 101 | { | ||
59 | 102 | | |||
60 | QBoxLayout::Direction direction; | 103 | QBoxLayout::Direction direction; | ||
61 | switch( value ) | 104 | switch( value ) | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |
What do you need this for?