diff --git a/systemmonitor/ksystemactivitydialog.h b/systemmonitor/ksystemactivitydialog.h --- a/systemmonitor/ksystemactivitydialog.h +++ b/systemmonitor/ksystemactivitydialog.h @@ -47,16 +47,15 @@ void setFilterText(const QString &filterText); QString filterText() const; + QSize sizeHint() const override; + /** Save the settings if the user presses the ESC key */ void reject() 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(); diff --git a/systemmonitor/ksystemactivitydialog.cpp b/systemmonitor/ksystemactivitydialog.cpp --- a/systemmonitor/ksystemactivitydialog.cpp +++ b/systemmonitor/ksystemactivitydialog.cpp @@ -21,23 +21,15 @@ #include "ksystemactivitydialog.h" #include -#include #include #include -#include #include -#include -#include #include -#include #include #include -#include -#include #include #include -#include #include #include #include @@ -51,43 +43,20 @@ 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 QAction *closeWindow = new QAction(this); closeWindow->setShortcut(QKeySequence::Quit); 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() @@ -115,26 +84,23 @@ event->accept(); } - -void KSystemActivityDialog::reject () +void KSystemActivityDialog::reject() { saveDialogSettings(); QDialog::reject(); } void KSystemActivityDialog::saveDialogSettings() { - //When the user closes the dialog, save the position and the KeepAbove state + // When the user closes the dialog, save the process list setup 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(); } -#endif // not Q_WS_WIN +QSize KSystemActivityDialog::sizeHint() const +{ + return QSize(650, 420); +} +#endif // not Q_WS_WIN