make shortcuts and sharing settings enable Apply; use a QWeakPointer forthe shortcuts widget

This commit is contained in:
Aaron Seigo 2011-12-06 17:36:39 +01:00
parent 57f9668bd1
commit abd1d9ddba
2 changed files with 8 additions and 12 deletions

View File

@ -1921,6 +1921,7 @@ void Applet::showConfigurationInterface()
#ifndef PLASMA_NO_KUTILS #ifndef PLASMA_NO_KUTILS
KCModuleProxy *module = new KCModuleProxy(kcm); KCModuleProxy *module = new KCModuleProxy(kcm);
if (module->realModule()) { if (module->realModule()) {
connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool)));
dialog->addPage(module, module->moduleInfo().moduleName(), module->moduleInfo().icon()); dialog->addPage(module, module->moduleInfo().moduleName(), module->moduleInfo().icon());
hasPages = true; hasPages = true;
} else { } else {
@ -2050,11 +2051,11 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog)
if (!shortcutEditor) { if (!shortcutEditor) {
shortcutEditor = new KKeySequenceWidget(page); 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()); shortcutEditor.data()->setKeySequence(q->globalShortcut().primary());
layout->addWidget(shortcutEditor); layout->addWidget(shortcutEditor.data());
layout->addStretch(); layout->addStretch();
dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard"); dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard");
@ -2069,7 +2070,9 @@ void AppletPrivate::addPublishPage(KConfigDialog *dialog)
QWidget *page = new QWidget; QWidget *page = new QWidget;
publishUI.setupUi(page); publishUI.setupUi(page);
publishUI.publishCheckbox->setChecked(q->isPublished()); publishUI.publishCheckbox->setChecked(q->isPublished());
QObject::connect(publishUI.publishCheckbox, SIGNAL(clicked(bool)), dialog, SLOT(settingsModified()));
publishUI.allUsersCheckbox->setEnabled(q->isPublished()); publishUI.allUsersCheckbox->setEnabled(q->isPublished());
QObject::connect(publishUI.allUsersCheckbox, SIGNAL(clicked(bool)), dialog, SLOT(settingsModified()));
QString resourceName = QString resourceName =
i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on", 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() void AppletPrivate::configDialogFinished()
{ {
if (shortcutEditor) { if (shortcutEditor) {
QKeySequence sequence = shortcutEditor->keySequence(); QKeySequence sequence = shortcutEditor.data()->keySequence();
if (sequence != q->globalShortcut().primary()) { if (sequence != q->globalShortcut().primary()) {
q->setGlobalShortcut(KShortcut(sequence)); q->setGlobalShortcut(KShortcut(sequence));
emit q->configNeedsSaving(); emit q->configNeedsSaving();
@ -2663,7 +2661,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int
configLoader(0), configLoader(0),
actions(AppletPrivate::defaultActions(applet)), actions(AppletPrivate::defaultActions(applet)),
activationAction(0), activationAction(0),
shortcutEditor(0),
itemStatus(UnknownStatus), itemStatus(UnknownStatus),
preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored), preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored),
modificationsTimer(0), modificationsTimer(0),

View File

@ -126,7 +126,6 @@ public:
void destroyMessageOverlay(); void destroyMessageOverlay();
void addGlobalShortcutsPage(KConfigDialog *dialog); void addGlobalShortcutsPage(KConfigDialog *dialog);
void addPublishPage(KConfigDialog *dialog); void addPublishPage(KConfigDialog *dialog);
void clearShortcutEditorPtr();
void configDialogFinished(); void configDialogFinished();
KConfigDialog *generateGenericConfigDialog(); KConfigDialog *generateGenericConfigDialog();
void addStandardConfigurationPages(KConfigDialog *dialog); void addStandardConfigurationPages(KConfigDialog *dialog);
@ -193,7 +192,7 @@ public:
KAction *activationAction; KAction *activationAction;
// configuration // configuration
KKeySequenceWidget *shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there QWeakPointer<KKeySequenceWidget> shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there
ItemStatus itemStatus; ItemStatus itemStatus;
QString remoteLocation; QString remoteLocation;