mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: adjust to KShortcutsEditor changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
faa738e171
commit
62726382e8
16 changed files with 52 additions and 127 deletions
|
@ -36,7 +36,7 @@ K_PLUGIN_FACTORY(StandardActionsModuleFactory, registerPlugin<StandardActionsMod
|
|||
K_EXPORT_PLUGIN(StandardActionsModuleFactory("kcm_standard_actions"))
|
||||
|
||||
static void dressUpAction(KAction *action, KStandardShortcut::StandardShortcut shortcutId)
|
||||
{
|
||||
{
|
||||
// Remember the shortcutId so we know where to save changes.
|
||||
action->setData(shortcutId);
|
||||
// We have to manually adjust the action. We want to show the
|
||||
|
@ -50,20 +50,17 @@ static void dressUpAction(KAction *action, KStandardShortcut::StandardShortcut s
|
|||
// Set the user defined values as active shortcuts. If the user only
|
||||
// has overwritten the primary shortcut make sure the alternate one
|
||||
// still get's shown
|
||||
if (active[1] == 0)
|
||||
{
|
||||
if (active[1] == 0) {
|
||||
active = QKeySequence(active[0], hardcoded[1]);
|
||||
}
|
||||
action->setShortcut(active, KAction::ActiveShortcut);
|
||||
}
|
||||
action->setShortcut(active, KAction::ActiveShortcut);
|
||||
}
|
||||
|
||||
StandardActionsModule::StandardActionsModule(
|
||||
QWidget *parent,
|
||||
const QVariantList &args )
|
||||
: KCModule(StandardActionsModuleFactory::componentData(), parent, args )
|
||||
,m_editor(NULL)
|
||||
,m_actionCollection(NULL)
|
||||
{
|
||||
StandardActionsModule::StandardActionsModule(QWidget *parent, const QVariantList &args)
|
||||
: KCModule(StandardActionsModuleFactory::componentData(), parent, args),
|
||||
m_editor(nullptr),
|
||||
m_actionCollection(nullptr)
|
||||
{
|
||||
KAboutData about("kcm_standard_actions", 0, ki18n("Standard Shortcuts"), "0.1");
|
||||
StandardActionsModuleFactory::componentData().setAboutData(about);
|
||||
|
||||
|
@ -78,81 +75,67 @@ StandardActionsModule::StandardActionsModule(
|
|||
QVBoxLayout *global = new QVBoxLayout;
|
||||
global->addWidget(m_editor);
|
||||
setLayout(global);
|
||||
}
|
||||
|
||||
|
||||
StandardActionsModule::~StandardActionsModule()
|
||||
{}
|
||||
|
||||
}
|
||||
|
||||
void StandardActionsModule::defaults()
|
||||
{
|
||||
{
|
||||
m_editor->allDefault();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StandardActionsModule::keyChanged()
|
||||
{
|
||||
{
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void StandardActionsModule::load()
|
||||
{
|
||||
{
|
||||
// Create a collection to handle the shortcuts
|
||||
m_actionCollection = new KActionCollection(
|
||||
this,
|
||||
StandardActionsModuleFactory::componentData());
|
||||
m_actionCollection = new KActionCollection(this, StandardActionsModuleFactory::componentData());
|
||||
|
||||
// Keeps track of which shortcut IDs have been added
|
||||
QSet<int> shortcutIdsAdded;
|
||||
|
||||
// Put all shortcuts for standard actions into the collection
|
||||
Q_FOREACH(KStandardAction::StandardAction id, KStandardAction::actionIds())
|
||||
{
|
||||
foreach (KStandardAction::StandardAction id, KStandardAction::actionIds()) {
|
||||
KStandardShortcut::StandardShortcut shortcutId = KStandardAction::shortcutForActionId(id);
|
||||
// If the StandardShortcutId is AccelNone skip configuration for this
|
||||
// action.
|
||||
if (shortcutId == KStandardShortcut::AccelNone || shortcutIdsAdded.contains(shortcutId))
|
||||
{
|
||||
if (shortcutId == KStandardShortcut::AccelNone || shortcutIdsAdded.contains(shortcutId)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Create the action
|
||||
KAction *action = KStandardAction::create(id, NULL, NULL, m_actionCollection);
|
||||
dressUpAction(action, shortcutId);
|
||||
shortcutIdsAdded << shortcutId;
|
||||
}
|
||||
}
|
||||
|
||||
// Put in the remaining standard shortcuts too...
|
||||
for(int i = int(KStandardShortcut::AccelNone) + 1; i < KStandardShortcut::StandardShortcutCount; ++i)
|
||||
{
|
||||
for(int i = int(KStandardShortcut::AccelNone) + 1; i < KStandardShortcut::StandardShortcutCount; ++i) {
|
||||
KStandardShortcut::StandardShortcut shortcutId = static_cast<KStandardShortcut::StandardShortcut>(i);
|
||||
if(!shortcutIdsAdded.contains(shortcutId))
|
||||
{
|
||||
if (!shortcutIdsAdded.contains(shortcutId)) {
|
||||
KAction *action = new KAction(KStandardShortcut::label(shortcutId), this);
|
||||
action->setWhatsThis(KStandardShortcut::whatsThis(shortcutId));
|
||||
dressUpAction(action, shortcutId);
|
||||
m_actionCollection->addAction(KStandardShortcut::name(shortcutId), action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hand the collection to the editor
|
||||
m_editor->addCollection(m_actionCollection, i18n("Standard Shortcuts"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void StandardActionsModule::save()
|
||||
{
|
||||
m_editor->commit();
|
||||
{
|
||||
m_editor->exportConfiguration();
|
||||
|
||||
Q_FOREACH(QAction* action, m_actionCollection->actions())
|
||||
{
|
||||
foreach (QAction* action, m_actionCollection->actions()) {
|
||||
KAction *kaction = qobject_cast<KAction*>(action);
|
||||
|
||||
KStandardShortcut::saveShortcut(
|
||||
static_cast<KStandardShortcut::StandardShortcut>(action->data().toInt())
|
||||
, kaction->shortcut());
|
||||
}
|
||||
static_cast<KStandardShortcut::StandardShortcut>(action->data().toInt()),
|
||||
kaction->shortcut()
|
||||
);
|
||||
}
|
||||
|
||||
KGlobal::config()->sync();
|
||||
KConfigGroup cg(KGlobal::config(), "Shortcuts");
|
||||
|
@ -163,8 +146,9 @@ void StandardActionsModule::save()
|
|||
"The changes have been saved. Please note that:"
|
||||
"<ul><li>Applications need to be restarted to see the changes.</li>"
|
||||
" <li>This change could introduce shortcut conflicts in some applications.</li>"
|
||||
"</ul>" );
|
||||
"</ul>"
|
||||
);
|
||||
KMessageBox::information(this, message, title, "shortcuts_saved_info");
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_standard_actions_module.cpp"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#ifndef STANDARD_ACTIONS_MODULE_H
|
||||
#define STANDARD_ACTIONS_MODULE_H
|
||||
/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
@ -18,32 +16,32 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef STANDARD_ACTIONS_MODULE_H
|
||||
#define STANDARD_ACTIONS_MODULE_H
|
||||
|
||||
#include <KCModule>
|
||||
|
||||
class KActionCollection;
|
||||
class KShortcutsEditor;
|
||||
|
||||
class StandardActionsModule : public KCModule
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
StandardActionsModule(QWidget *parent, const QVariantList &args);
|
||||
~StandardActionsModule();
|
||||
|
||||
/*reimp*/ void save();
|
||||
/*reimp*/ void load();
|
||||
/*reimp*/ void defaults();
|
||||
void save() final;
|
||||
void load() final;
|
||||
void defaults() final;
|
||||
|
||||
private slots:
|
||||
void keyChanged();
|
||||
|
||||
private:
|
||||
|
||||
KShortcutsEditor *m_editor;
|
||||
KActionCollection *m_actionCollection;
|
||||
|
||||
}; // class StandardActionsModule
|
||||
};
|
||||
|
||||
|
||||
#endif /* #ifndef STANDARD_ACTIONS_MODULE_H */
|
||||
#endif // STANDARD_ACTIONS_MODULE_H
|
||||
|
|
|
@ -80,17 +80,11 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList
|
|||
load();
|
||||
}
|
||||
|
||||
MagnifierEffectConfig::~MagnifierEffectConfig()
|
||||
{
|
||||
// Undo (only) unsaved changes to global key shortcuts
|
||||
m_ui->editor->undoChanges();
|
||||
}
|
||||
|
||||
void MagnifierEffectConfig::save()
|
||||
{
|
||||
kDebug(1212) << "Saving config of Magnifier" ;
|
||||
|
||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||
m_ui->editor->exportConfiguration();
|
||||
KCModule::save();
|
||||
EffectsHandler::sendReloadMessage("magnifier");
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ class MagnifierEffectConfig : public KCModule
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit MagnifierEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
virtual ~MagnifierEffectConfig();
|
||||
|
||||
virtual void save();
|
||||
virtual void defaults();
|
||||
|
|
|
@ -74,19 +74,13 @@ MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList
|
|||
load();
|
||||
}
|
||||
|
||||
MouseMarkEffectConfig::~MouseMarkEffectConfig()
|
||||
{
|
||||
// Undo (only) unsaved changes to global key shortcuts
|
||||
m_ui->editor->undoChanges();
|
||||
}
|
||||
|
||||
void MouseMarkEffectConfig::save()
|
||||
{
|
||||
kDebug(1212) << "Saving config of MouseMark" ;
|
||||
KCModule::save();
|
||||
|
||||
m_actionCollection->writeSettings();
|
||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||
m_ui->editor->exportConfiguration();
|
||||
|
||||
EffectsHandler::sendReloadMessage("mousemark");
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ class MouseMarkEffectConfig : public KCModule
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit MouseMarkEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
virtual ~MouseMarkEffectConfig();
|
||||
|
||||
virtual void save();
|
||||
|
||||
|
|
|
@ -80,16 +80,10 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV
|
|||
load();
|
||||
}
|
||||
|
||||
PresentWindowsEffectConfig::~PresentWindowsEffectConfig()
|
||||
{
|
||||
// If save() is called undoChanges() has no effect
|
||||
m_ui->shortcutEditor->undoChanges();
|
||||
}
|
||||
|
||||
void PresentWindowsEffectConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
m_ui->shortcutEditor->save();
|
||||
m_ui->shortcutEditor->exportConfiguration();
|
||||
EffectsHandler::sendReloadMessage("presentwindows");
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ class PresentWindowsEffectConfig : public KCModule
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit PresentWindowsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~PresentWindowsEffectConfig();
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
|
|
|
@ -73,15 +73,10 @@ ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget* parent, const QV
|
|||
load();
|
||||
}
|
||||
|
||||
ThumbnailAsideEffectConfig::~ThumbnailAsideEffectConfig()
|
||||
{
|
||||
// Undo (only) unsaved changes to global key shortcuts
|
||||
m_ui->editor->undoChanges();
|
||||
}
|
||||
|
||||
void ThumbnailAsideEffectConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
m_ui->editor->exportConfiguration();
|
||||
EffectsHandler::sendReloadMessage("thumbnailaside");
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ class ThumbnailAsideEffectConfig : public KCModule
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit ThumbnailAsideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
virtual ~ThumbnailAsideEffectConfig();
|
||||
|
||||
virtual void save();
|
||||
|
||||
|
|
|
@ -58,16 +58,10 @@ WindowGeometryConfig::WindowGeometryConfig(QWidget* parent, const QVariantList&
|
|||
load();
|
||||
}
|
||||
|
||||
WindowGeometryConfig::~WindowGeometryConfig()
|
||||
{
|
||||
// Undo (only) unsaved changes to global key shortcuts
|
||||
myUi->shortcuts->undoChanges();
|
||||
}
|
||||
|
||||
void WindowGeometryConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
myUi->shortcuts->save(); // undo() will restore to this state from now on
|
||||
myUi->shortcuts->exportConfiguration();
|
||||
EffectsHandler::sendReloadMessage("windowgeometry");
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ class WindowGeometryConfig : public KCModule
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit WindowGeometryConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
~WindowGeometryConfig();
|
||||
|
||||
public slots:
|
||||
void save();
|
||||
|
|
|
@ -108,15 +108,9 @@ ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) :
|
|||
load();
|
||||
}
|
||||
|
||||
ZoomEffectConfig::~ZoomEffectConfig()
|
||||
{
|
||||
// Undo (only) unsaved changes to global key shortcuts
|
||||
m_ui->editor->undoChanges();
|
||||
}
|
||||
|
||||
void ZoomEffectConfig::save()
|
||||
{
|
||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||
m_ui->editor->exportConfiguration();
|
||||
KCModule::save();
|
||||
EffectsHandler::sendReloadMessage("zoom");
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ class ZoomEffectConfig : public KCModule
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit ZoomEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
virtual ~ZoomEffectConfig();
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
|
|
|
@ -176,11 +176,6 @@ void KWinDesktopConfig::init()
|
|||
// End check for immutable
|
||||
}
|
||||
|
||||
KWinDesktopConfig::~KWinDesktopConfig()
|
||||
{
|
||||
undo();
|
||||
}
|
||||
|
||||
void KWinDesktopConfig::addAction(const QString &name, const QString &label)
|
||||
{
|
||||
KAction* a = qobject_cast<KAction*>(m_switchDesktopCollection->addAction(name));
|
||||
|
@ -220,7 +215,7 @@ void KWinDesktopConfig::defaults()
|
|||
void KWinDesktopConfig::load()
|
||||
{
|
||||
// This method is called on reset(). So undo all changes.
|
||||
undo();
|
||||
m_editor->importConfiguration();
|
||||
|
||||
// get number of desktops
|
||||
unsigned long properties[] = {NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout };
|
||||
|
@ -318,7 +313,7 @@ void KWinDesktopConfig::save()
|
|||
break;
|
||||
}
|
||||
|
||||
m_editor->save();
|
||||
m_editor->exportConfiguration();
|
||||
|
||||
m_config->sync();
|
||||
// Send signal to all kwin instances
|
||||
|
@ -328,14 +323,6 @@ void KWinDesktopConfig::save()
|
|||
emit changed(false);
|
||||
}
|
||||
|
||||
|
||||
void KWinDesktopConfig::undo()
|
||||
{
|
||||
// The global shortcuts editor makes changes active immediately. In case
|
||||
// of undo we have to undo them manually
|
||||
m_editor->undoChanges();
|
||||
}
|
||||
|
||||
QString KWinDesktopConfig::cachedDesktopName(int desktop)
|
||||
{
|
||||
if (desktop > m_desktopNames.size())
|
||||
|
|
|
@ -49,11 +49,8 @@ class KWinDesktopConfig : public KCModule
|
|||
|
||||
public:
|
||||
explicit KWinDesktopConfig(QWidget* parent, const QVariantList& args);
|
||||
~KWinDesktopConfig();
|
||||
QString cachedDesktopName(int desktop);
|
||||
|
||||
// undo all changes
|
||||
void undo();
|
||||
QString cachedDesktopName(int desktop);
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
|
|
Loading…
Add table
Reference in a new issue