Fix and simplify UI creation in various effect KCMs
We don't need an intermediate widget class here, we can set up the UI directly, like it's done in several effect KCMs already Not only does this simplify the code, it also fixes crashes due to broken ownership BUG: 477020
This commit is contained in:
parent
51bcf3440f
commit
6a1b1d01b8
16 changed files with 32 additions and 146 deletions
|
@ -25,21 +25,13 @@ K_PLUGIN_CLASS(KWin::MagicLampEffectConfig)
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
MagicLampEffectConfigForm::MagicLampEffectConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
MagicLampEffectConfig::MagicLampEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
, m_ui(widget())
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(widget());
|
||||
layout->addWidget(&m_ui);
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
MagicLampConfig::instance(KWIN_CONFIG);
|
||||
addConfig(MagicLampConfig::self(), &m_ui);
|
||||
addConfig(MagicLampConfig::self(), widget());
|
||||
}
|
||||
|
||||
void MagicLampEffectConfig::save()
|
||||
|
|
|
@ -15,14 +15,6 @@
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class MagicLampEffectConfigForm : public QWidget, public Ui::MagicLampEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MagicLampEffectConfigForm(QWidget *parent);
|
||||
};
|
||||
|
||||
class MagicLampEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -33,7 +25,7 @@ public Q_SLOTS:
|
|||
void save() override;
|
||||
|
||||
private:
|
||||
MagicLampEffectConfigForm m_ui;
|
||||
Ui::MagicLampEffectConfigForm m_ui;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -30,22 +30,13 @@ K_PLUGIN_CLASS(KWin::MagnifierEffectConfig)
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
MagnifierEffectConfigForm::MagnifierEffectConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
MagnifierEffectConfig::MagnifierEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
, m_ui(widget())
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(widget());
|
||||
layout->addWidget(&m_ui);
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
MagnifierConfig::instance(KWIN_CONFIG);
|
||||
addConfig(MagnifierConfig::self(), &m_ui);
|
||||
addConfig(MagnifierConfig::self(), widget());
|
||||
|
||||
connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
|
||||
|
||||
|
|
|
@ -18,13 +18,6 @@ class KActionCollection;
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class MagnifierEffectConfigForm : public QWidget, public Ui::MagnifierEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MagnifierEffectConfigForm(QWidget *parent);
|
||||
};
|
||||
|
||||
class MagnifierEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -35,7 +28,7 @@ public:
|
|||
void defaults() override;
|
||||
|
||||
private:
|
||||
MagnifierEffectConfigForm m_ui;
|
||||
Ui::MagnifierEffectConfigForm m_ui;
|
||||
KActionCollection *m_actionCollection;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,18 +28,10 @@ K_PLUGIN_CLASS(KWin::MouseClickEffectConfig)
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
MouseClickEffectConfigForm::MouseClickEffectConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
MouseClickEffectConfig::MouseClickEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
, m_ui(widget())
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(widget());
|
||||
layout->addWidget(&m_ui);
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
|
||||
|
||||
|
@ -56,7 +48,7 @@ MouseClickEffectConfig::MouseClickEffectConfig(QObject *parent, const KPluginMet
|
|||
m_ui.editor->addCollection(m_actionCollection);
|
||||
|
||||
MouseClickConfig::instance(KWIN_CONFIG);
|
||||
addConfig(MouseClickConfig::self(), &m_ui);
|
||||
addConfig(MouseClickConfig::self(), widget());
|
||||
}
|
||||
|
||||
void MouseClickEffectConfig::save()
|
||||
|
|
|
@ -18,13 +18,6 @@ class KActionCollection;
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class MouseClickEffectConfigForm : public QWidget, public Ui::MouseClickEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MouseClickEffectConfigForm(QWidget *parent);
|
||||
};
|
||||
|
||||
class MouseClickEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -34,7 +27,7 @@ public:
|
|||
void save() override;
|
||||
|
||||
private:
|
||||
MouseClickEffectConfigForm m_ui;
|
||||
Ui::MouseClickEffectConfigForm m_ui;
|
||||
KActionCollection *m_actionCollection;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,21 +30,13 @@ K_PLUGIN_CLASS(KWin::MouseMarkEffectConfig)
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
MouseMarkEffectConfigForm::MouseMarkEffectConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
MouseMarkEffectConfig::MouseMarkEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
, m_ui(widget())
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(widget());
|
||||
layout->addWidget(&m_ui);
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
MouseMarkConfig::instance(KWIN_CONFIG);
|
||||
addConfig(MouseMarkConfig::self(), &m_ui);
|
||||
addConfig(MouseMarkConfig::self(), widget());
|
||||
|
||||
// Shortcut config. The shortcut belongs to the component "kwin"!
|
||||
m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
|
||||
|
|
|
@ -19,13 +19,6 @@ class KActionCollection;
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
class MouseMarkEffectConfigForm : public QWidget, public Ui::MouseMarkEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MouseMarkEffectConfigForm(QWidget *parent);
|
||||
};
|
||||
|
||||
class MouseMarkEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -38,7 +31,7 @@ public:
|
|||
private:
|
||||
void updateSpinBoxSuffix();
|
||||
|
||||
MouseMarkEffectConfigForm m_ui;
|
||||
Ui::MouseMarkEffectConfigForm m_ui;
|
||||
KActionCollection *m_actionCollection;
|
||||
};
|
||||
|
||||
|
|
|
@ -24,9 +24,8 @@ namespace KWin
|
|||
|
||||
ShowPaintEffectConfig::ShowPaintEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
, m_ui(std::make_unique<Ui::ShowPaintEffectConfig>())
|
||||
{
|
||||
m_ui->setupUi(widget());
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
auto *actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
|
||||
|
||||
|
@ -40,20 +39,20 @@ ShowPaintEffectConfig::ShowPaintEffectConfig(QObject *parent, const KPluginMetaD
|
|||
KGlobalAccel::self()->setDefaultShortcut(toggleAction, {});
|
||||
KGlobalAccel::self()->setShortcut(toggleAction, {});
|
||||
|
||||
m_ui->shortcutsEditor->addCollection(actionCollection);
|
||||
m_ui.shortcutsEditor->addCollection(actionCollection);
|
||||
|
||||
connect(m_ui->shortcutsEditor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
|
||||
connect(m_ui.shortcutsEditor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
|
||||
}
|
||||
|
||||
void ShowPaintEffectConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
m_ui->shortcutsEditor->save();
|
||||
m_ui.shortcutsEditor->save();
|
||||
}
|
||||
|
||||
void ShowPaintEffectConfig::defaults()
|
||||
{
|
||||
m_ui->shortcutsEditor->allDefault();
|
||||
m_ui.shortcutsEditor->allDefault();
|
||||
KCModule::defaults();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public Q_SLOTS:
|
|||
void defaults() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::ShowPaintEffectConfig> m_ui;
|
||||
Ui::ShowPaintEffectConfig m_ui;
|
||||
};
|
||||
|
||||
} // namespace KWin
|
||||
|
|
|
@ -29,19 +29,10 @@ K_PLUGIN_CLASS(KWin::ThumbnailAsideEffectConfig)
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
ThumbnailAsideEffectConfigForm::ThumbnailAsideEffectConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
, m_ui(widget())
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(widget());
|
||||
layout->addWidget(&m_ui);
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
|
||||
|
||||
|
|
|
@ -17,14 +17,6 @@ class KActionCollection;
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class ThumbnailAsideEffectConfigForm : public QWidget, public Ui::ThumbnailAsideEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ThumbnailAsideEffectConfigForm(QWidget *parent);
|
||||
};
|
||||
|
||||
class ThumbnailAsideEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -34,7 +26,7 @@ public:
|
|||
void save() override;
|
||||
|
||||
private:
|
||||
ThumbnailAsideEffectConfigForm m_ui;
|
||||
Ui::ThumbnailAsideEffectConfigForm m_ui;
|
||||
KActionCollection *m_actionCollection;
|
||||
};
|
||||
|
||||
|
|
|
@ -32,21 +32,13 @@ namespace KWin
|
|||
|
||||
static const QString s_toggleTrackMouseActionName = QStringLiteral("TrackMouse");
|
||||
|
||||
TrackMouseEffectConfigForm::TrackMouseEffectConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
TrackMouseEffectConfig::TrackMouseEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
{
|
||||
TrackMouseConfig::instance(KWIN_CONFIG);
|
||||
m_ui = new TrackMouseEffectConfigForm(widget());
|
||||
QVBoxLayout *layout = new QVBoxLayout(widget());
|
||||
layout->addWidget(m_ui);
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
addConfig(TrackMouseConfig::self(), m_ui);
|
||||
addConfig(TrackMouseConfig::self(), widget());
|
||||
|
||||
m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
|
||||
m_actionCollection->setComponentDisplayName(i18n("KWin"));
|
||||
|
@ -60,7 +52,7 @@ TrackMouseEffectConfig::TrackMouseEffectConfig(QObject *parent, const KPluginMet
|
|||
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>());
|
||||
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>());
|
||||
|
||||
connect(m_ui->shortcut, &KKeySequenceWidget::keySequenceChanged,
|
||||
connect(m_ui.shortcut, &KKeySequenceWidget::keySequenceChanged,
|
||||
this, &TrackMouseEffectConfig::shortcutChanged);
|
||||
}
|
||||
|
||||
|
@ -75,7 +67,7 @@ void TrackMouseEffectConfig::load()
|
|||
if (QAction *a = m_actionCollection->action(s_toggleTrackMouseActionName)) {
|
||||
auto shortcuts = KGlobalAccel::self()->shortcut(a);
|
||||
if (!shortcuts.isEmpty()) {
|
||||
m_ui->shortcut->setKeySequence(shortcuts.first());
|
||||
m_ui.shortcut->setKeySequence(shortcuts.first());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +85,7 @@ void TrackMouseEffectConfig::save()
|
|||
void TrackMouseEffectConfig::defaults()
|
||||
{
|
||||
KCModule::defaults();
|
||||
m_ui->shortcut->clearKeySequence();
|
||||
m_ui.shortcut->clearKeySequence();
|
||||
}
|
||||
|
||||
void TrackMouseEffectConfig::shortcutChanged(const QKeySequence &seq)
|
||||
|
|
|
@ -18,14 +18,6 @@ class KActionCollection;
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class TrackMouseEffectConfigForm : public QWidget, public Ui::TrackMouseEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TrackMouseEffectConfigForm(QWidget *parent);
|
||||
};
|
||||
|
||||
class TrackMouseEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -41,7 +33,7 @@ private Q_SLOTS:
|
|||
void shortcutChanged(const QKeySequence &seq);
|
||||
|
||||
private:
|
||||
TrackMouseEffectConfigForm *m_ui;
|
||||
Ui::TrackMouseEffectConfigForm m_ui;
|
||||
KActionCollection *m_actionCollection;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,25 +28,15 @@ K_PLUGIN_CLASS(KWin::ZoomEffectConfig)
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
ZoomEffectConfigForm::ZoomEffectConfigForm(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
ZoomEffectConfig::ZoomEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
{
|
||||
ZoomConfig::instance(KWIN_CONFIG);
|
||||
m_ui = new ZoomEffectConfigForm(widget());
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(widget());
|
||||
layout->addWidget(m_ui);
|
||||
addConfig(ZoomConfig::self(), widget());
|
||||
|
||||
addConfig(ZoomConfig::self(), m_ui);
|
||||
|
||||
connect(m_ui->editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
|
||||
connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
|
||||
|
||||
#if !HAVE_ACCESSIBILITY
|
||||
m_ui->kcfg_EnableFocusTracking->setVisible(false);
|
||||
|
@ -117,12 +107,12 @@ ZoomEffectConfig::ZoomEffectConfig(QObject *parent, const KPluginMetaData &data)
|
|||
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_F6));
|
||||
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_F6));
|
||||
|
||||
m_ui->editor->addCollection(actionCollection);
|
||||
m_ui.editor->addCollection(actionCollection);
|
||||
}
|
||||
|
||||
void ZoomEffectConfig::save()
|
||||
{
|
||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||
m_ui.editor->save(); // undo() will restore to this state from now on
|
||||
KCModule::save();
|
||||
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
||||
QStringLiteral("/Effects"),
|
||||
|
|
|
@ -16,14 +16,6 @@
|
|||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class ZoomEffectConfigForm : public QWidget, public Ui::ZoomEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ZoomEffectConfigForm(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
class ZoomEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -34,7 +26,7 @@ public Q_SLOTS:
|
|||
void save() override;
|
||||
|
||||
private:
|
||||
ZoomEffectConfigForm *m_ui;
|
||||
Ui::ZoomEffectConfigForm m_ui;
|
||||
enum MouseTracking {
|
||||
MouseCentred = 0,
|
||||
MouseProportional = 1,
|
||||
|
|
Loading…
Reference in a new issue