2
* Copyright (C) 2007-2010 John Tapsell <johnflux@gmail.com>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License version 2 as
6
* published by the Free Software Foundation
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details
13
* You should have received a copy of the GNU Library General Public
14
* License along with this program; if not, write to the
15
* Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#include "ksystemactivitydialog.h"
23
#include <QAbstractScrollArea>
24
#include <QCloseEvent>
31
#include <KConfigGroup>
33
#include <KWindowSystem>
35
#include "krunnersettings.h"
37
KSystemActivityDialog::KSystemActivityDialog(QWidget *parent)
38
: KDialog(parent), m_processList(0)
40
setWindowTitle(i18n("System Activity"));
41
setWindowIcon(KIcon(QLatin1String( "utilities-system-monitor" )));
43
setMainWidget(&m_processList);
44
m_processList.setScriptingEnabled(true);
45
setSizeGripEnabled(true);
46
(void)minimumSizeHint(); //Force the dialog to be laid out now
47
layout()->setContentsMargins(0,0,0,0);
48
m_processList.treeView()->setCornerWidget(new QWidget);
50
// Since we kinda act like an application more than just a Window, map the usual ctrl+Q shortcut to close as well
51
QAction *closeWindow = new QAction(this);
52
closeWindow->setShortcut(QKeySequence::Quit);
53
connect(closeWindow, SIGNAL(triggered(bool)), this, SLOT(accept()));
54
addAction(closeWindow);
56
setInitialSize(QSize(650, 420));
57
KConfigGroup cg = KGlobal::config()->group("TaskDialog");
58
restoreDialogSize(cg);
60
m_processList.loadSettings(cg);
61
// Since we default to forcing the window to be KeepAbove, if the user turns this off, remember this
62
const bool keepAbove = KRunnerSettings::keepTaskDialogAbove();
64
KWindowSystem::setState(winId(), NET::KeepAbove );
68
void KSystemActivityDialog::run()
72
KWindowSystem::setOnDesktop(winId(), KWindowSystem::currentDesktop());
73
KWindowSystem::forceActiveWindow(winId());
76
void KSystemActivityDialog::setFilterText(const QString &filterText)
78
m_processList.filterLineEdit()->setText(filterText);
79
m_processList.filterLineEdit()->setFocus();
82
void KSystemActivityDialog::closeEvent(QCloseEvent *event)
89
void KSystemActivityDialog::reject ()
95
void KSystemActivityDialog::saveDialogSettings()
97
//When the user closes the dialog, save the position and the KeepAbove state
98
KConfigGroup cg = KGlobal::config()->group("TaskDialog");
100
m_processList.saveSettings(cg);
102
// Since we default to forcing the window to be KeepAbove, if the user turns this off, remember this
103
bool keepAbove = KWindowSystem::windowInfo(winId(), NET::WMState).hasState(NET::KeepAbove);
104
KRunnerSettings::setKeepTaskDialogAbove(keepAbove);
105
KGlobal::config()->sync();
108
#endif // not Q_WS_WIN