- Adapt to no undo on close in KShortcutsEditor by adding undo where

appropriate.
- Add the necessary KShortcutsEditor::save() calls where missing.
Use KActionCollection::setComponentData() as a better replacement for
KGlobalAccel::overrideMainComponentData().
- Add setProperty(\"isConfigurationAction\", true) for actions that don't belong
to the module modifying them. This replaces the behavior changes otherwise
triggered by KGlobalAccel::overrideMainComponentData(). The most important
behavior change is to not register an action as gone when it is destroyed in
the configuration module. It likely still exists in its proper module.

svn path=/trunk/KDE/kdebase/workspace/; revision=812610
icc-effect-5.14.5
Andreas Hartmetz 2008-05-25 20:31:33 +00:00
parent 2876bf7217
commit db8ca7f784
19 changed files with 120 additions and 43 deletions

View File

@ -53,10 +53,6 @@ CoverSwitchEffectConfig::CoverSwitchEffectConfig(QWidget* parent, const QVariant
load();
}
CoverSwitchEffectConfig::~CoverSwitchEffectConfig()
{
}
void CoverSwitchEffectConfig::load()
{
KCModule::load();

View File

@ -41,7 +41,6 @@ class CoverSwitchEffectConfig : public KCModule
Q_OBJECT
public:
explicit CoverSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
~CoverSwitchEffectConfig();
public slots:
virtual void save();

View File

@ -71,16 +71,16 @@ DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariant
comboLayout->addWidget(mActivateCombo);
layout->addLayout(comboLayout);
KGlobalAccel::self()->overrideMainComponentData(componentData());
KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") );
KActionCollection* actionCollection = new KActionCollection( this, componentData() );
KAction* show = static_cast<KAction*>(actionCollection->addAction( "ShowDesktopGrid" ));
show->setText( i18n("Show Desktop Grid" ));
show->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F8 ));
show->setProperty("isConfigurationAction", true);
KShortcutsEditor* shortcutEditor = new KShortcutsEditor(actionCollection, this,
mShortcutEditor = new KShortcutsEditor(actionCollection, this,
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
connect(shortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
layout->addWidget(shortcutEditor);
connect(mShortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
layout->addWidget(mShortcutEditor);
layout->addStretch();
@ -89,12 +89,14 @@ DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariant
DesktopGridEffectConfig::~DesktopGridEffectConfig()
{
kDebug() ;
kDebug();
// Undo (only) unsaved changes to global key shortcuts
mShortcutEditor->undoChanges();
}
void DesktopGridEffectConfig::load()
{
kDebug() ;
kDebug();
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
@ -122,6 +124,8 @@ void DesktopGridEffectConfig::save()
conf.writeEntry("BorderActivate", activateBorder);
conf.sync();
mShortcutEditor->save(); // undo() will restore to this state from now on
emit changed(false);
EffectsHandler::sendReloadMessage( "desktopgrid" );
}

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class QComboBox;
class QCheckBox;
class KShortcutsEditor;
namespace KWin
{
@ -44,6 +45,7 @@ class DesktopGridEffectConfig : public KCModule
private:
QCheckBox* mSlide;
QComboBox* mActivateCombo;
KShortcutsEditor *mShortcutEditor;
};
} // namespace

View File

@ -39,14 +39,14 @@ namespace KWin
InvertEffectConfig::InvertEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
KGlobalAccel::self()->overrideMainComponentData(componentData());
kDebug() ;
kDebug();
QVBoxLayout* layout = new QVBoxLayout(this);
KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") );
KActionCollection* actionCollection = new KActionCollection( this, componentData() );
KAction* a = static_cast<KAction*>(actionCollection->addAction( "Invert" ));
a->setText( i18n("Toggle Invert Effect" ));
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_I));
a->setProperty("isConfigurationAction", true);
mShortcutEditor = new KShortcutsEditor(actionCollection, this,
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
@ -60,7 +60,9 @@ InvertEffectConfig::InvertEffectConfig(QWidget* parent, const QVariantList& args
InvertEffectConfig::~InvertEffectConfig()
{
kDebug() ;
kDebug();
// Undo (only) unsaved changes to global key shortcuts
mShortcutEditor->undoChanges();
}
void InvertEffectConfig::load()
@ -76,6 +78,8 @@ void InvertEffectConfig::save()
kDebug() ;
KCModule::save();
mShortcutEditor->save(); // undo() will restore to this state from now on
emit changed(false);
EffectsHandler::sendReloadMessage( "invert" );
}

View File

@ -60,7 +60,6 @@ LookingGlassEffectConfig::LookingGlassEffectConfig(QWidget* parent, const QVaria
connect(m_ui->radiusSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
// Shortcut config
KGlobalAccel::self()->overrideMainComponentData(componentData());
m_actionCollection = new KActionCollection( this, componentData() );
m_actionCollection->setConfigGroup("LookingGlass");
m_actionCollection->setConfigGlobal(true);
@ -68,19 +67,30 @@ LookingGlassEffectConfig::LookingGlassEffectConfig(QWidget* parent, const QVaria
KAction* a;
a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ZoomIn));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Plus));
a->setProperty("isConfigurationAction", true);
a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ZoomOut));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus));
a->setProperty("isConfigurationAction", true);
a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ActualSize));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
a->setProperty("isConfigurationAction", true);
//m_ui->editor->addCollection(m_actionCollection);
m_ui->editor->addCollection(m_actionCollection);
load();
}
LookingGlassEffectConfig::~LookingGlassEffectConfig()
{
// Undo (only) unsaved changes to global key shortcuts
m_ui->editor->undoChanges();
}
void LookingGlassEffectConfig::load()
{
kDebug() ;
kDebug();
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("LookingGlass");
@ -106,6 +116,7 @@ void LookingGlassEffectConfig::save()
conf.writeEntry("Radius", m_ui->radiusSpin->value());
m_actionCollection->writeSettings();
m_ui->editor->save(); // undo() will restore to this state from now on
conf.sync();

View File

@ -42,6 +42,7 @@ class LookingGlassEffectConfig : public KCModule
Q_OBJECT
public:
explicit LookingGlassEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
virtual ~LookingGlassEffectConfig();
virtual void save();
virtual void load();

View File

@ -60,7 +60,6 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList
connect(m_ui->spinWidth, SIGNAL(valueChanged(int)), this, SLOT(changed()));
// Shortcut config
KGlobalAccel::self()->overrideMainComponentData(componentData());
m_actionCollection = new KActionCollection( this, componentData() );
m_actionCollection->setConfigGroup("Magnifier");
m_actionCollection->setConfigGlobal(true);
@ -68,14 +67,25 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList
KAction* a;
a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ZoomIn));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Plus));
a->setProperty("isConfigurationAction", true);
a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ZoomOut));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus));
a->setProperty("isConfigurationAction", true);
a = static_cast< KAction* >( m_actionCollection->addAction( KStandardAction::ActualSize));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
a->setProperty("isConfigurationAction", true);
load();
}
MagnifierEffectConfig::~MagnifierEffectConfig()
{
// Undo (only) unsaved changes to global key shortcuts
m_ui->editor->undoChanges();
}
void MagnifierEffectConfig::load()
{
kDebug() ;
@ -105,6 +115,7 @@ void MagnifierEffectConfig::save()
conf.writeEntry("Height", m_ui->spinHeight->value());
m_actionCollection->writeSettings();
m_ui->editor->save(); // undo() will restore to this state from now on
conf.sync();

View File

@ -42,6 +42,7 @@ class MagnifierEffectConfig : public KCModule
Q_OBJECT
public:
explicit MagnifierEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
virtual ~MagnifierEffectConfig();
virtual void save();
virtual void load();

View File

@ -61,20 +61,29 @@ MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList
connect(m_ui->comboColors, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
// Shortcut config
KGlobalAccel::self()->overrideMainComponentData(componentData());
m_actionCollection = new KActionCollection( this, componentData() );
KAction* a = static_cast< KAction* >( m_actionCollection->addAction( "ClearMouseMarks" ));
a->setText( i18n( "Clear Mouse Marks" ));
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
a->setProperty("isConfigurationAction", true);
a = static_cast< KAction* >( m_actionCollection->addAction( "ClearLastMouseMark" ));
a->setText( i18n( "Clear Last Mouse Mark" ));
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F12 ));
a->setProperty("isConfigurationAction", true);
m_ui->editor->addCollection(m_actionCollection);
load();
}
MouseMarkEffectConfig::~MouseMarkEffectConfig()
{
// Undo (only) unsaved changes to global key shortcuts
m_ui->editor->undoChanges();
}
void MouseMarkEffectConfig::load()
{
kDebug() ;
@ -100,6 +109,9 @@ void MouseMarkEffectConfig::save()
conf.writeEntry("LineWidth", m_ui->spinWidth->value());
conf.writeEntry("Color", m_ui->comboColors->color());
m_actionCollection->writeSettings();
m_ui->editor->save(); // undo() will restore to this state from now on
conf.sync();
emit changed(false);

View File

@ -41,7 +41,8 @@ class MouseMarkEffectConfig : public KCModule
{
Q_OBJECT
public:
explicit MouseMarkEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
explicit MouseMarkEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
virtual ~MouseMarkEffectConfig();
virtual void save();
virtual void load();

View File

@ -44,7 +44,7 @@ namespace KWin
PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
kDebug() ;
kDebug();
QGridLayout* layout = new QGridLayout(this);
@ -71,14 +71,17 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Expanding), 4, 0, 1, 3);
// Shortcut config
KGlobalAccel::self()->overrideMainComponentData(componentData());
KActionCollection* actionCollection = new KActionCollection( this );
KActionCollection* actionCollection = new KActionCollection( this, componentData() );
KAction* a = (KAction*)actionCollection->addAction( "Expose" );
a->setText( i18n("Toggle Expose Effect" ));
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F9));
a->setProperty("isConfigurationAction", true);
KAction* b = (KAction*)actionCollection->addAction( "ExposeAll" );
b->setText( i18n("Toggle Expose Effect (incl. other desktops)" ));
b->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::Key_F10));
b->setProperty("isConfigurationAction", true);
mShortcutEditor = new KShortcutsEditor(actionCollection, this,
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
connect(mShortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
@ -86,13 +89,14 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 6, 0, 1, 3);
load();
}
PresentWindowsEffectConfig::~PresentWindowsEffectConfig()
{
kDebug() ;
kDebug();
// Undo (only) unsaved changes to global key shortcuts
mShortcutEditor->undoChanges();
}
void PresentWindowsEffectConfig::addItems(QComboBox* combo)
@ -152,6 +156,8 @@ void PresentWindowsEffectConfig::save()
conf.sync();
mShortcutEditor->save(); // undo() will restore to this state from now on
emit changed(false);
EffectsHandler::sendReloadMessage( "presentwindows" );
}

View File

@ -39,14 +39,14 @@ namespace KWin
SharpenEffectConfig::SharpenEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
KGlobalAccel::self()->overrideMainComponentData(componentData());
kDebug() ;
kDebug();
QVBoxLayout* layout = new QVBoxLayout(this);
KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") );
KActionCollection* actionCollection = new KActionCollection( this, componentData() );
KAction* a = static_cast<KAction*>(actionCollection->addAction( "Sharpen" ));
a->setText( i18n("Toggle Sharpen Effect" ));
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_S));
a->setProperty("isConfigurationAction", true);
mShortcutEditor = new KShortcutsEditor(actionCollection, this,
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
@ -60,12 +60,14 @@ SharpenEffectConfig::SharpenEffectConfig(QWidget* parent, const QVariantList& ar
SharpenEffectConfig::~SharpenEffectConfig()
{
kDebug() ;
kDebug();
// Undo (only) unsaved changes to global key shortcuts
mShortcutEditor->undoChanges();
}
void SharpenEffectConfig::load()
{
kDebug() ;
kDebug();
KCModule::load();
emit changed(false);
@ -76,6 +78,8 @@ void SharpenEffectConfig::save()
kDebug() ;
KCModule::save();
mShortcutEditor->save(); // undo() will restore to this state from now on
emit changed(false);
EffectsHandler::sendReloadMessage( "sharpen" );
}

View File

@ -56,7 +56,6 @@ SnowEffectConfig::SnowEffectConfig(QWidget* parent, const QVariantList& args) :
connect(m_ui->minSizeFlake, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->maxSizeFlake, SIGNAL(valueChanged(int)), this, SLOT(changed()));
KGlobalAccel::self()->overrideMainComponentData(componentData());
m_actionCollection = new KActionCollection( this, componentData() );
m_actionCollection->setConfigGroup("Snow");
m_actionCollection->setConfigGlobal(true);
@ -64,12 +63,15 @@ SnowEffectConfig::SnowEffectConfig(QWidget* parent, const QVariantList& args) :
KAction* a = (KAction*)m_actionCollection->addAction( "Snow" );
a->setText( i18n("Toggle Snow on Desktop" ));
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_F12 ));
a->setProperty("isConfigurationAction", true);
load();
}
SnowEffectConfig::~SnowEffectConfig()
{
// Undo (only) unsaved changes to global key shortcuts
m_ui->editor->undoChanges();
kDebug() ;
}
@ -103,6 +105,7 @@ void SnowEffectConfig::save()
conf.writeEntry("MaxFlakes", m_ui->maxSizeFlake->value());
m_actionCollection->writeSettings();
m_ui->editor->save(); // undo() will restore to this state from now on
conf.sync();

View File

@ -62,7 +62,6 @@ ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget* parent, const QV
connect(m_ui->spinOpacity, SIGNAL(valueChanged(int)), this, SLOT(changed()));
// Shortcut config
KGlobalAccel::self()->overrideMainComponentData(componentData());
m_actionCollection = new KActionCollection( this, componentData() );
m_actionCollection->setConfigGroup("ThumbnailAside");
m_actionCollection->setConfigGlobal(true);
@ -70,10 +69,18 @@ ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget* parent, const QV
KAction* a = (KAction*)m_actionCollection->addAction( "ToggleCurrentThumbnail" );
a->setText( i18n("Toggle Thumbnail for Current Window" ));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::CTRL + Qt::Key_T));
a->setProperty("isConfigurationAction", true);
load();
}
ThumbnailAsideEffectConfig::~ThumbnailAsideEffectConfig()
{
// Undo (only) unsaved changes to global key shortcuts
m_ui->editor->undoChanges();
kDebug() ;
}
void ThumbnailAsideEffectConfig::load()
{
kDebug() ;
@ -106,6 +113,7 @@ void ThumbnailAsideEffectConfig::save()
conf.writeEntry("Opacity", m_ui->spinOpacity->value());
m_actionCollection->writeSettings();
m_ui->editor->save(); // undo() will restore to this state from now on
conf.sync();

View File

@ -41,7 +41,8 @@ class ThumbnailAsideEffectConfig : public KCModule
{
Q_OBJECT
public:
explicit ThumbnailAsideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
explicit ThumbnailAsideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
virtual ~ThumbnailAsideEffectConfig();
virtual void save();
virtual void load();

View File

@ -40,7 +40,6 @@ namespace KWin
TrackMouseEffectConfig::TrackMouseEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
KGlobalAccel::self()->overrideMainComponentData(componentData());
kDebug() ;
QVBoxLayout* layout = new QVBoxLayout(this);

View File

@ -49,8 +49,7 @@ namespace KWin
VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
KGlobalAccel::self()->overrideMainComponentData(componentData());
kDebug() ;
kDebug();
QVBoxLayout* layout = new QVBoxLayout(this);
QHBoxLayout* hlayout = new QHBoxLayout( this );
@ -60,10 +59,12 @@ VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariant
saveVideo->setMode( KFile::Directory | KFile::LocalOnly );
hlayout->addWidget( saveVideo );
layout->addLayout( hlayout );
KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") );
KActionCollection* actionCollection = new KActionCollection( this, componentData() );
KAction* a = static_cast<KAction*>(actionCollection->addAction( "VideoRecord" ));
a->setText( i18n("Toggle Video Recording" ));
a->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::META + Qt::Key_V));
a->setProperty("isConfigurationAction", true);
mShortcutEditor = new KShortcutsEditor(actionCollection, this,
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
@ -77,7 +78,9 @@ VideoRecordEffectConfig::VideoRecordEffectConfig(QWidget* parent, const QVariant
VideoRecordEffectConfig::~VideoRecordEffectConfig()
{
kDebug() ;
kDebug();
// Undo (only) unsaved changes to global key shortcuts
mShortcutEditor->undoChanges();
}
void VideoRecordEffectConfig::load()
@ -98,6 +101,9 @@ void VideoRecordEffectConfig::save()
KConfigGroup conf = EffectsHandler::effectConfig("VideoRecord");
conf.writeEntry("videopath", saveVideo->url().path());
m_actionCollection->writeSettings();
m_ui->editor->save(); // undo() will restore to this state from now on
conf.sync();

View File

@ -39,18 +39,22 @@ namespace KWin
ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
KGlobalAccel::self()->overrideMainComponentData(componentData());
kDebug() ;
kDebug();
QVBoxLayout* layout = new QVBoxLayout(this);
KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") );
KActionCollection* actionCollection = new KActionCollection( this, componentData() );
KAction* a;
a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ZoomIn ));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Equal));
a->setProperty("isConfigurationAction", true);
a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ZoomOut ));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus));
a->setProperty("isConfigurationAction", true);
a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ActualSize ));
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
a->setProperty("isConfigurationAction", true);
mShortcutEditor = new KShortcutsEditor(actionCollection, this,
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
@ -65,6 +69,8 @@ ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) :
ZoomEffectConfig::~ZoomEffectConfig()
{
kDebug() ;
// Undo (only) unsaved changes to global key shortcuts
mShortcutEditor->undoChanges();
}
void ZoomEffectConfig::load()
@ -80,6 +86,8 @@ void ZoomEffectConfig::save()
kDebug() ;
KCModule::save();
mShortcutEditor->save(); // undo() will restore to this state from now on
emit changed(false);
EffectsHandler::sendReloadMessage( "zoom" );
}