From 97e4bd53d316ef6096e0aef4f8a78c8a61cd9ca8 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sat, 3 Dec 2011 21:22:45 +0100 Subject: [PATCH 01/12] don't delete the kns3 dialog on application shutdown BUG:288153 --- private/packages.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/private/packages.cpp b/private/packages.cpp index 08016db77..f85d5f724 100644 --- a/private/packages.cpp +++ b/private/packages.cpp @@ -22,6 +22,7 @@ #include #include // FLT_MAX +#include #include #include @@ -82,7 +83,10 @@ PlasmoidPackage::PlasmoidPackage(QObject *parent) PlasmoidPackage::~PlasmoidPackage() { #ifndef PLASMA_NO_KNEWSTUFF - delete m_knsDialog.data(); + if (!QCoreApplication::closingDown()) { + // let it "leak" on application close as this causes crashes otherwise, BUG 288153 + delete m_knsDialog.data(); + } #endif } From ab8e956d57343bda532dfa272f01bd7e5dbc5ad5 Mon Sep 17 00:00:00 2001 From: Jaime Torres Date: Sun, 4 Dec 2011 12:24:35 +0100 Subject: [PATCH 02/12] remove a break; after a return there is no need for a break; after a return (dead code) REVIEW: 103323 --- popupapplet.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/popupapplet.cpp b/popupapplet.cpp index c36350323..07ea3f108 100644 --- a/popupapplet.cpp +++ b/popupapplet.cpp @@ -446,7 +446,6 @@ QSizeF PopupApplet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) cons case Horizontal: { const int size = IconSize(KIconLoader::Panel); return QSizeF(size, size); - break; } default: break; From be08974bfe5fbd0048d366f8beadd4d0f8add19a Mon Sep 17 00:00:00 2001 From: Jaime Torres Date: Sun, 4 Dec 2011 12:25:46 +0100 Subject: [PATCH 03/12] remove dead code remove dead code (see review 103323) --- private/associatedapplicationmanager.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/private/associatedapplicationmanager.cpp b/private/associatedapplicationmanager.cpp index cf8bbe5fc..9da0fd2ce 100644 --- a/private/associatedapplicationmanager.cpp +++ b/private/associatedapplicationmanager.cpp @@ -100,9 +100,6 @@ void AssociatedApplicationManager::setApplication(Plasma::Applet *applet, const QString AssociatedApplicationManager::application(const Plasma::Applet *applet) const { return d->applicationNames.value(applet); - if (!d->applicationNames.contains(applet)) { - connect(applet, SIGNAL(destroyed(QObject *)), this, SLOT(cleanupApplet(QObject *))); - } } void AssociatedApplicationManager::setUrls(Plasma::Applet *applet, const KUrl::List &urls) From 2c5ec1a56a8179b94b1d8e2ec1295c0debc79313 Mon Sep 17 00:00:00 2001 From: Jaime Torres Date: Sun, 4 Dec 2011 12:27:01 +0100 Subject: [PATCH 04/12] change return by break and then add a common return removing dead code (part of review 103323) --- private/style.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/private/style.cpp b/private/style.cpp index e3449f532..adfa9bdee 100644 --- a/private/style.cpp +++ b/private/style.cpp @@ -303,12 +303,13 @@ QRect Style::subControlRect(ComplexControl control, const QStyleOptionComplex *o rect.moveCenter(QPoint(option->rect.center().x(), rect.center().y())); } } - return rect; break; } default: - return rect; + break; } + return rect; + } int Style::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const From 4aa690ccc881cb2c197be02cb192ffb4ea5cb6bc Mon Sep 17 00:00:00 2001 From: Jaime Torres Date: Sun, 4 Dec 2011 12:28:04 +0100 Subject: [PATCH 05/12] return a double usind qMin qMin is a template, use the right datatype for it. part of review 103323 --- widgets/signalplotter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/signalplotter.cpp b/widgets/signalplotter.cpp index aa132dd57..a5646062a 100644 --- a/widgets/signalplotter.cpp +++ b/widgets/signalplotter.cpp @@ -933,7 +933,7 @@ void SignalPlotter::drawPlots(QPainter *p, int top, int w, int h, int horizontal qMax(prev_prev_datapoints[j], prev_prev_prev_datapoints[j]))); double current_minvalue = - qMin(datapoints[j], + qMin(datapoints[j], qMin(prev_datapoints[j], qMin(prev_prev_datapoints[j], prev_prev_prev_datapoints[j]))); From 27531a31732b95e6a50be3bbf5222a870d514ec6 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sun, 4 Dec 2011 13:55:05 +0100 Subject: [PATCH 06/12] the palette gets updated by all sorts of events on the scene now (incl. reparenting!), so make sure the palette is _really_ changing before marking it as custom this fixes widget colours not updating with theme changes -> if, for instance, an offscreen widget is created, this results in a reparenting (to null) and that in turn creates a palette changed event ... which was being intepretted as a custom palette being set and that would disable future updates due to theme changes. this also introduces a small helper which computes the palettes once for use by all widgets as a small performance improvement. BUG:261967 --- CMakeLists.txt | 1 + private/themedwidgetinterface.cpp | 85 +++++++++++++++++++++++++++++++ private/themedwidgetinterface_p.h | 72 +++++++++++++++----------- 3 files changed, 127 insertions(+), 31 deletions(-) create mode 100644 private/themedwidgetinterface.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fd86df12c..e4cad89e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,7 @@ set(plasma_LIB_SRCS private/storage.cpp private/storagethread.cpp private/style.cpp + private/themedwidgetinterface.cpp private/trustedonlyauthorization.cpp private/tooltip.cpp private/wallpaperrenderthread.cpp diff --git a/private/themedwidgetinterface.cpp b/private/themedwidgetinterface.cpp new file mode 100644 index 000000000..399033c55 --- /dev/null +++ b/private/themedwidgetinterface.cpp @@ -0,0 +1,85 @@ +/****************************************************************************** +* Copyright 2011 by Aaron Seigo * +* * +* This library is free software; you can redistribute it and/or * +* modify it under the terms of the GNU Library General Public * +* License as published by the Free Software Foundation; either * +* version 2 of the License, or (at your option) any later version. * +* * +* This library is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * +* Library General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public License * +* along with this library; see the file COPYING.LIB. If not, write to * +* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * +* Boston, MA 02110-1301, USA. * +*******************************************************************************/ + +#include "themedwidgetinterface_p.h" + +#include "theme.h" + +namespace Plasma +{ + +PaletteHelper *PaletteHelper::s_paletteHelper = 0; + +PaletteHelper::PaletteHelper() + : QObject() +{ + generatePalettes(); + connect(Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(generatePalettes())); + connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SLOT(generatePalettes())); +} + +PaletteHelper *PaletteHelper::self() +{ + if (!s_paletteHelper) { + s_paletteHelper = new PaletteHelper; + } + + return s_paletteHelper; +} + +void PaletteHelper::generatePalettes() +{ + Theme *theme = Theme::defaultTheme(); + + QColor color = theme->color(Theme::TextColor); + palette = qApp->palette(); + palette.setColor(QPalette::Normal, QPalette::WindowText, color); + palette.setColor(QPalette::Inactive, QPalette::WindowText, color); + + palette.setColor(QPalette::Normal, QPalette::Link, theme->color(Theme::LinkColor)); + palette.setColor(QPalette::Normal, QPalette::LinkVisited, theme->color(Theme::VisitedLinkColor)); + + qreal alpha = color.alphaF(); + color.setAlphaF(0.6); + palette.setColor(QPalette::Disabled, QPalette::WindowText, color); + color.setAlphaF(alpha); + + palette.setColor(QPalette::Normal, QPalette::Text, color); + palette.setColor(QPalette::Inactive, QPalette::Text, color); + + const QColor buttonColor = Theme::defaultTheme()->color(Theme::ButtonTextColor); + palette.setColor(QPalette::Normal, QPalette::ButtonText, buttonColor); + palette.setColor(QPalette::Inactive, QPalette::ButtonText, buttonColor); + + //FIXME: hardcoded colors .. looks incorrect + palette.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0)); + palette.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0)); + + buttonPalette = palette; + buttonPalette.setColor(QPalette::Normal, QPalette::Text, buttonColor); + buttonPalette.setColor(QPalette::Inactive, QPalette::Text, buttonColor); + + emit palettesUpdated(); +} + + +} // namespace Plasma + +#include "themedwidgetinterface_p.moc" + diff --git a/private/themedwidgetinterface_p.h b/private/themedwidgetinterface_p.h index 624e2f7cb..ac2eeec3b 100644 --- a/private/themedwidgetinterface_p.h +++ b/private/themedwidgetinterface_p.h @@ -28,6 +28,28 @@ namespace Plasma { +class PaletteHelper : public QObject +{ + Q_OBJECT +public: + static PaletteHelper *self(); + +public Q_SLOTS: + void generatePalettes(); + +Q_SIGNALS: + void palettesUpdated(); + +public: + QPalette palette; + QPalette buttonPalette; + +private: + PaletteHelper(); + static PaletteHelper *s_paletteHelper; +}; + + template class ThemedWidgetInterface { @@ -36,10 +58,10 @@ public: : q(publicClass), customPalette(false), customFont(false), - buttonColorForText(false) + buttonColorForText(false), + internalPaletteChange(false) { - QObject::connect(Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(setPalette())); - QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(setPalette())); + QObject::connect(PaletteHelper::self(), SIGNAL(palettesUpdated()), q, SLOT(setPalette())); } void initTheming() @@ -52,33 +74,10 @@ public: void setPalette() { if (!customPalette) { - QColor color = Theme::defaultTheme()->color(Theme::TextColor); - QPalette p = q->palette(); - p.setColor(QPalette::Normal, QPalette::WindowText, color); - p.setColor(QPalette::Inactive, QPalette::WindowText, color); - - p.setColor(QPalette::Normal, QPalette::Link, Theme::defaultTheme()->color(Theme::LinkColor)); - p.setColor(QPalette::Normal, QPalette::LinkVisited, Theme::defaultTheme()->color(Theme::VisitedLinkColor)); - - - qreal alpha = color.alphaF(); - color.setAlphaF(0.6); - p.setColor(QPalette::Disabled, QPalette::WindowText, color); - color.setAlphaF(alpha); - - const QColor buttonColor = Theme::defaultTheme()->color(Theme::ButtonTextColor); - p.setColor(QPalette::Normal, QPalette::Text, buttonColorForText ? buttonColor : color); - p.setColor(QPalette::Inactive, QPalette::Text, buttonColorForText ? buttonColor : color); - - p.setColor(QPalette::Normal, QPalette::ButtonText, buttonColor); - p.setColor(QPalette::Inactive, QPalette::ButtonText, buttonColor); - - //FIXME: hardcoded colors .. looks incorrect - p.setColor(QPalette::Normal, QPalette::Base, QColor(0,0,0,0)); - p.setColor(QPalette::Inactive, QPalette::Base, QColor(0,0,0,0)); - - q->setPalette(p); - customPalette = false; + internalPaletteChange = true; + q->setPalette((buttonColorForText ? PaletteHelper::self()->buttonPalette + : PaletteHelper::self()->palette)); + internalPaletteChange = false; } if (!customFont) { @@ -95,7 +94,10 @@ public: break; case QEvent::PaletteChange: - customPalette = true; + if (!internalPaletteChange && + q->palette() != (buttonColorForText ? PaletteHelper::self()->buttonPalette : PaletteHelper::self()->palette)) { + customPalette = true; + } break; default: @@ -103,6 +105,13 @@ public: } } + void setWidget(QWidget *widget) + { + internalPaletteChange = true; + q->setWidget(widget); + internalPaletteChange = false; + } + void event(QEvent *event) { if (event->type() == QEvent::Show) { @@ -114,6 +123,7 @@ public: bool customPalette : 1; bool customFont : 1; bool buttonColorForText : 1; + bool internalPaletteChange : 1; }; } // namespace Plasma From e34c70415e34080498ad665ef494a7ea3f9bcd38 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sun, 4 Dec 2011 13:59:54 +0100 Subject: [PATCH 07/12] git rid of the native member, it's redundant; use d->setWidget which notes that it's not a palette customization --- widgets/textbrowser.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/widgets/textbrowser.cpp b/widgets/textbrowser.cpp index 8e35ab5ce..870d570e0 100644 --- a/widgets/textbrowser.cpp +++ b/widgets/textbrowser.cpp @@ -40,7 +40,6 @@ class TextBrowserPrivate : public ThemedWidgetInterface public: TextBrowserPrivate(TextBrowser *browser) : ThemedWidgetInterface(browser), - native(0), savedMinimumHeight(0), savedMaximumHeight(QWIDGETSIZE_MAX), wasNotFixed(true) @@ -49,7 +48,8 @@ public: void setFixedHeight() { - if (native && native->document() && + KTextBrowser *native = q->nativeWidget(); + if (native->document() && q->sizePolicy().verticalPolicy() == QSizePolicy::Fixed && native->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { native->document()->setTextWidth(q->size().width()); @@ -84,7 +84,7 @@ TextBrowser::TextBrowser(QGraphicsWidget *parent) connect(native, SIGNAL(textChanged()), this, SIGNAL(textChanged())); connect(native, SIGNAL(textChanged()), this, SLOT(setFixedHeight())); native->setWindowIcon(QIcon()); - setWidget(native); + d->setWidget(native); d->native = native; native->setAttribute(Qt::WA_NoSystemBackground); native->setFrameShape(QFrame::NoFrame); @@ -114,12 +114,12 @@ QString TextBrowser::text() const void TextBrowser::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy) { - d->native->setHorizontalScrollBarPolicy(policy); + nativeWidget()->setHorizontalScrollBarPolicy(policy); } void TextBrowser::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy) { - d->native->setVerticalScrollBarPolicy(policy); + nativeWidget()->setVerticalScrollBarPolicy(policy); } void TextBrowser::setStyleSheet(const QString &stylesheet) @@ -173,8 +173,8 @@ void TextBrowser::resizeEvent(QGraphicsSceneResizeEvent *event) void TextBrowser::wheelEvent(QGraphicsSceneWheelEvent *event) { - if (d->native->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff && - d->native->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { + if (nativeWidget()->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff && + nativeWidget()->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { event->ignore(); } else { QGraphicsProxyWidget::wheelEvent(event); From 3948cfb8cf01665122fd8c185dd0196f9490993c Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sun, 4 Dec 2011 14:00:02 +0100 Subject: [PATCH 08/12] use d->setWidget which notes that it's not a palette customization --- widgets/checkbox.cpp | 2 +- widgets/combobox.cpp | 2 +- widgets/groupbox.cpp | 2 +- widgets/label.cpp | 2 +- widgets/lineedit.cpp | 2 +- widgets/radiobutton.cpp | 2 +- widgets/spinbox.cpp | 2 +- widgets/textedit.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/widgets/checkbox.cpp b/widgets/checkbox.cpp index 98a2fa5de..e37405454 100644 --- a/widgets/checkbox.cpp +++ b/widgets/checkbox.cpp @@ -87,7 +87,7 @@ CheckBox::CheckBox(QGraphicsWidget *parent) { QCheckBox *native = new QCheckBox; connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); - setWidget(native); + d->setWidget(native); native->setWindowIcon(QIcon()); native->setAttribute(Qt::WA_NoSystemBackground); diff --git a/widgets/combobox.cpp b/widgets/combobox.cpp index 48a492346..d52eb0ab7 100644 --- a/widgets/combobox.cpp +++ b/widgets/combobox.cpp @@ -166,7 +166,7 @@ void ComboBox::setNativeWidget(KComboBox *nativeWidget) connect(nativeWidget, SIGNAL(currentIndexChanged(const QString &)), this, SIGNAL(textChanged(const QString &))); - setWidget(nativeWidget); + d->setWidget(nativeWidget); nativeWidget->setWindowIcon(QIcon()); nativeWidget->setAttribute(Qt::WA_NoSystemBackground); diff --git a/widgets/groupbox.cpp b/widgets/groupbox.cpp index 4b8379c7f..0abc2ca61 100644 --- a/widgets/groupbox.cpp +++ b/widgets/groupbox.cpp @@ -50,7 +50,7 @@ GroupBox::GroupBox(QGraphicsWidget *parent) d(new GroupBoxPrivate(this)) { QGroupBox *native = new QGroupBox; - setWidget(native); + d->setWidget(native); native->setWindowIcon(QIcon()); native->setAttribute(Qt::WA_NoSystemBackground); d->initTheming(); diff --git a/widgets/label.cpp b/widgets/label.cpp index b73aacb57..a216c6bd7 100644 --- a/widgets/label.cpp +++ b/widgets/label.cpp @@ -105,7 +105,7 @@ Label::Label(QGraphicsWidget *parent) connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString))); connect(native, SIGNAL(linkHovered(QString)), this, SIGNAL(linkHovered(QString))); - setWidget(native); + d->setWidget(native); d->initTheming(); } diff --git a/widgets/lineedit.cpp b/widgets/lineedit.cpp index 708ef3a70..d000439bf 100644 --- a/widgets/lineedit.cpp +++ b/widgets/lineedit.cpp @@ -130,7 +130,7 @@ void LineEdit::setNativeWidget(KLineEdit *nativeWidget) nativeWidget->setWindowFlags(nativeWidget->windowFlags()|Qt::BypassGraphicsProxyWidget); - setWidget(nativeWidget); + d->setWidget(nativeWidget); nativeWidget->setWindowIcon(QIcon()); nativeWidget->setAttribute(Qt::WA_NoSystemBackground); diff --git a/widgets/radiobutton.cpp b/widgets/radiobutton.cpp index dd9952b18..67e08288c 100644 --- a/widgets/radiobutton.cpp +++ b/widgets/radiobutton.cpp @@ -77,7 +77,7 @@ RadioButton::RadioButton(QGraphicsWidget *parent) { QRadioButton *native = new QRadioButton; connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); - setWidget(native); + d->setWidget(native); native->setWindowIcon(QIcon()); native->setAttribute(Qt::WA_NoSystemBackground); d->initTheming(); diff --git a/widgets/spinbox.cpp b/widgets/spinbox.cpp index bacdabdca..9c1c3fe66 100644 --- a/widgets/spinbox.cpp +++ b/widgets/spinbox.cpp @@ -67,7 +67,7 @@ SpinBox::SpinBox(QGraphicsWidget *parent) d->focusIndicator = new FocusIndicator(this, "widgets/lineedit"); - setWidget(native); + d->setWidget(native); native->setWindowIcon(QIcon()); native->setAttribute(Qt::WA_NoSystemBackground); native->setAutoFillBackground(false); diff --git a/widgets/textedit.cpp b/widgets/textedit.cpp index 633aec694..271f6cbfc 100644 --- a/widgets/textedit.cpp +++ b/widgets/textedit.cpp @@ -108,7 +108,7 @@ void TextEdit::setNativeWidget(KTextEdit *nativeWidget) connect(nativeWidget, SIGNAL(textChanged()), this, SIGNAL(textChanged())); nativeWidget->setWindowIcon(QIcon()); - setWidget(nativeWidget); + d->setWidget(nativeWidget); nativeWidget->setAttribute(Qt::WA_NoSystemBackground); nativeWidget->setFrameShape(QFrame::NoFrame); From 57f9668bd15c0120cd4f67daf306312193778d46 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Mon, 5 Dec 2011 00:16:53 +0100 Subject: [PATCH 09/12] config changed is not only called by config dialogs anymore, so more the script forwarding into the public API implementation --- applet.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/applet.cpp b/applet.cpp index 578fa5575..d2461e990 100644 --- a/applet.cpp +++ b/applet.cpp @@ -2177,11 +2177,6 @@ void AppletPrivate::updateShortcuts() void AppletPrivate::propagateConfigChanged() { - if (script && configLoader) { - configLoader->readConfig(); - script->configChanged(); - } - if (isContainment) { Containment *c = qobject_cast(q); if (c) { @@ -2194,6 +2189,12 @@ void AppletPrivate::propagateConfigChanged() void Applet::configChanged() { + if (d->script) { + if (d->configLoader) { + d->configLoader->readConfig(); + } + d->script->configChanged(); + } } void Applet::createConfigurationInterface(KConfigDialog *parent) From abd1d9ddbadb9e0cc4ab85cdbc23ed9c42072c98 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 6 Dec 2011 17:36:39 +0100 Subject: [PATCH 10/12] make shortcuts and sharing settings enable Apply; use a QWeakPointer forthe shortcuts widget --- applet.cpp | 17 +++++++---------- private/applet_p.h | 3 +-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/applet.cpp b/applet.cpp index d2461e990..694d72c84 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1921,6 +1921,7 @@ void Applet::showConfigurationInterface() #ifndef PLASMA_NO_KUTILS KCModuleProxy *module = new KCModuleProxy(kcm); if (module->realModule()) { + connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool))); dialog->addPage(module, module->moduleInfo().moduleName(), module->moduleInfo().icon()); hasPages = true; } else { @@ -2050,11 +2051,11 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog) if (!shortcutEditor) { shortcutEditor = new KKeySequenceWidget(page); - QObject::connect(shortcutEditor, SIGNAL(destroyed(QObject*)), q, SLOT(clearShortcutEditorPtr())); + QObject::connect(shortcutEditor.data(), SIGNAL(keySequenceChanged(QKeySequence)), dialog, SLOT(settingsModified())); } - shortcutEditor->setKeySequence(q->globalShortcut().primary()); - layout->addWidget(shortcutEditor); + shortcutEditor.data()->setKeySequence(q->globalShortcut().primary()); + layout->addWidget(shortcutEditor.data()); layout->addStretch(); dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard"); @@ -2069,7 +2070,9 @@ void AppletPrivate::addPublishPage(KConfigDialog *dialog) QWidget *page = new QWidget; publishUI.setupUi(page); publishUI.publishCheckbox->setChecked(q->isPublished()); + QObject::connect(publishUI.publishCheckbox, SIGNAL(clicked(bool)), dialog, SLOT(settingsModified())); publishUI.allUsersCheckbox->setEnabled(q->isPublished()); + QObject::connect(publishUI.allUsersCheckbox, SIGNAL(clicked(bool)), dialog, SLOT(settingsModified())); QString resourceName = i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on", @@ -2095,15 +2098,10 @@ void AppletPrivate::publishCheckboxStateChanged(int state) } } -void AppletPrivate::clearShortcutEditorPtr() -{ - shortcutEditor = 0; -} - void AppletPrivate::configDialogFinished() { if (shortcutEditor) { - QKeySequence sequence = shortcutEditor->keySequence(); + QKeySequence sequence = shortcutEditor.data()->keySequence(); if (sequence != q->globalShortcut().primary()) { q->setGlobalShortcut(KShortcut(sequence)); emit q->configNeedsSaving(); @@ -2663,7 +2661,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int configLoader(0), actions(AppletPrivate::defaultActions(applet)), activationAction(0), - shortcutEditor(0), itemStatus(UnknownStatus), preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored), modificationsTimer(0), diff --git a/private/applet_p.h b/private/applet_p.h index bd3c1e9e9..3faf5b39b 100644 --- a/private/applet_p.h +++ b/private/applet_p.h @@ -126,7 +126,6 @@ public: void destroyMessageOverlay(); void addGlobalShortcutsPage(KConfigDialog *dialog); void addPublishPage(KConfigDialog *dialog); - void clearShortcutEditorPtr(); void configDialogFinished(); KConfigDialog *generateGenericConfigDialog(); void addStandardConfigurationPages(KConfigDialog *dialog); @@ -193,7 +192,7 @@ public: KAction *activationAction; // configuration - KKeySequenceWidget *shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there + QWeakPointer shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there ItemStatus itemStatus; QString remoteLocation; From 3f7859b5575453dc72d0e2b6d8255254631f0dac Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 6 Dec 2011 17:37:54 +0100 Subject: [PATCH 11/12] if the shortcut hasn't changed, don't try and update it --- applet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applet.cpp b/applet.cpp index 694d72c84..a8b39dcd6 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1567,6 +1567,8 @@ void Applet::setGlobalShortcut(const KShortcut &shortcut) foreach (QWidget *w, widgets) { w->addAction(d->activationAction); } + } else if (d->activationAction->globalShortcut() == shortcut) { + return; } //kDebug() << "before" << shortcut.primary() << d->activationAction->globalShortcut().primary(); From 21c1c05039490d5bac9e47de741b4ae56e17acef Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 6 Dec 2011 17:46:13 +0100 Subject: [PATCH 12/12] this method is no longer in the private class --- applet.h | 1 - 1 file changed, 1 deletion(-) diff --git a/applet.h b/applet.h index 96767520f..54e2b2202 100644 --- a/applet.h +++ b/applet.h @@ -1118,7 +1118,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget Q_PRIVATE_SLOT(d, void selectItemToDestroy()) Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect)) Q_PRIVATE_SLOT(d, void destroyMessageOverlay()) - Q_PRIVATE_SLOT(d, void clearShortcutEditorPtr()) Q_PRIVATE_SLOT(d, void configDialogFinished()) Q_PRIVATE_SLOT(d, void updateShortcuts()) Q_PRIVATE_SLOT(d, void publishCheckboxStateChanged(int state))