Commit ad5b9e98 authored by Valeriy Malov's avatar Valeriy Malov
Browse files

Center systemmonitor window properly on multi-screen setup

Summary:
Do not force geometry or window hints when opening systemmonitor
This should let it position properly on a multi-monitor setup and reduce interference with user-set KWin preferences

BUG: 368158
BUG: 356706

Reviewers: #plasma_workspaces, aacid, mart

Reviewed By: mart

Subscribers: davidedmundson, sebas, aacid, graesslin, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D3484
parent 839a727b
......@@ -21,23 +21,15 @@
#include "ksystemactivitydialog.h"
#include <QCloseEvent>
#include <QLayout>
#include <QString>
#include <QAction>
#include <QTreeView>
#include <QIcon>
#include <QWindow>
#include <QDialog>
#include <QDBusConnection>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QScreen>
#include <QTimer>
#include <KSharedConfig>
#include <KConfigGroup>
#include <KWindowConfig>
#include <KWindowSystem>
#include <KLocalizedString>
#include <QDebug>
......@@ -51,7 +43,7 @@ KSystemActivityDialog::KSystemActivityDialog(QWidget *parent)
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
......@@ -60,34 +52,11 @@ KSystemActivityDialog::KSystemActivityDialog(QWidget *parent)
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,8 +84,7 @@ void KSystemActivityDialog::closeEvent(QCloseEvent *event)
event->accept();
}
void KSystemActivityDialog::reject ()
void KSystemActivityDialog::reject()
{
saveDialogSettings();
QDialog::reject();
......@@ -124,17 +92,15 @@ void KSystemActivityDialog::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
......@@ -47,6 +47,8 @@ class KSystemActivityDialog : public QDialog
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;
......@@ -54,9 +56,6 @@ class KSystemActivityDialog : public QDialog
/** Save the settings if the user clicks (x) button on the window */
void closeEvent(QCloseEvent *event) override;
private slots:
void slotInit();
private:
void saveDialogSettings();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment