diff --git a/systemmonitor/ksystemactivitydialog.h b/systemmonitor/ksystemactivitydialog.h --- a/systemmonitor/ksystemactivitydialog.h +++ b/systemmonitor/ksystemactivitydialog.h @@ -34,7 +34,7 @@ { Q_OBJECT public: - KSystemActivityDialog(QWidget *parent = NULL); + KSystemActivityDialog(QWidget *parent = nullptr); /** Show the dialog and set the focus * @@ -47,19 +47,9 @@ void setFilterText(const QString &filterText); QString filterText() const; - /** Save the settings if the user presses the ESC key */ - void reject() override; + QSize sizeHint() const override; protected: - /** Save the settings if the user clicks (x) button on the window */ - void closeEvent(QCloseEvent *event) override; - - private slots: - void slotInit(); - - private: - void saveDialogSettings(); - KSysGuardProcessList m_processList; }; #endif // not Q_WS_WIN diff --git a/systemmonitor/ksystemactivitydialog.cpp b/systemmonitor/ksystemactivitydialog.cpp --- a/systemmonitor/ksystemactivitydialog.cpp +++ b/systemmonitor/ksystemactivitydialog.cpp @@ -20,25 +20,13 @@ #include "ksystemactivitydialog.h" -#include -#include #include #include -#include #include -#include -#include #include -#include #include #include -#include -#include -#include -#include -#include -#include #include #include #include @@ -53,7 +41,7 @@ mainLayout->addWidget(&m_processList); m_processList.setScriptingEnabled(true); setSizeGripEnabled(true); - (void)minimumSizeHint(); //Force the dialog to be laid out now + layout()->setContentsMargins(0,0,0,0); // Since we kinda act like an application more than just a Window, map the usual ctrl+Q shortcut to close as well @@ -62,34 +50,8 @@ connect(closeWindow, &QAction::triggered, this, &KSystemActivityDialog::accept); addAction(closeWindow); - // We need the resizing to be done once the dialog has been initialized - // otherwise we don't actually have a window. - QTimer::singleShot(0, this, &KSystemActivityDialog::slotInit); -} - -void KSystemActivityDialog::slotInit() -{ - resize(QSize(650, 420)); - - KConfigGroup cg = KSharedConfig::openConfig()->group("TaskDialog"); - KWindowConfig::restoreWindowSize(windowHandle(), cg); - - m_processList.loadSettings(cg); - // Since we default to forcing the window to be KeepAbove, if the user turns this off, remember this - const bool keepAbove = true; // KRunnerSettings::keepTaskDialogAbove(); - if (keepAbove) { - KWindowSystem::setState(winId(), NET::KeepAbove); - } - QDBusConnection con = QDBusConnection::sessionBus(); con.registerObject(QStringLiteral("/"), this, QDBusConnection::ExportAllSlots); - - QRect geom = windowHandle()->screen()->geometry(); - QSize ourSize = windowHandle()->size(); - - int w = ourSize.width(); - int h = ourSize.height(); - setGeometry((geom.width() - w)/2, (geom.height() - h)/2, w, h); } void KSystemActivityDialog::run() @@ -111,32 +73,9 @@ return m_processList.filterLineEdit()->text(); } -void KSystemActivityDialog::closeEvent(QCloseEvent *event) +QSize KSystemActivityDialog::sizeHint() const { - saveDialogSettings(); - event->accept(); -} - - -void KSystemActivityDialog::reject () -{ - saveDialogSettings(); - QDialog::reject(); -} - -void KSystemActivityDialog::saveDialogSettings() -{ - //When the user closes the dialog, save the position and the KeepAbove state - KConfigGroup cg = KSharedConfig::openConfig()->group("TaskDialog"); - KWindowConfig::saveWindowSize(windowHandle(), cg); - m_processList.saveSettings(cg); - - // Since we default to forcing the window to be KeepAbove, if the user turns this off, remember this - // vHanda: Temporarily commented out - // bool keepAbove = KWindowSystem::windowInfo(winId(), NET::WMState).hasState(NET::KeepAbove); - // KRunnerSettings::setKeepTaskDialogAbove(keepAbove); - KSharedConfig::openConfig()->sync(); + return QSize(650, 420); } #endif // not Q_WS_WIN -