1/*
2 * This file is part of the KDE project
3 * Copyright (C) 2009 Shaun Reich <shaun.reich@kdemail.net>
4 * Copyright (C) 2006-2008 Rafael Fernández López <ereslibre@kde.org>
5 * Copyright (C) 2001 George Staikos <staikos@kde.org>
6 * Copyright (C) 2000 Matej Koss <koss@miesto.sk>
7 * David Faure <faure@kde.org>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License version 2 as published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#include "uiserver.h"
25#include "uiserver_p.h"
26
27#include "progresslistmodel.h"
28#include "progresslistdelegate.h"
29
30#include <QWidget>
31#include <QAction>
32#include <QBoxLayout>
33#include <QCloseEvent>
34#include <QToolBar>
35
36#include <kconfigdialog.h>
37#include <klocale.h>
38#include <kicon.h>
39#include <kdialog.h>
40#include <ksystemtrayicon.h>
41#include <kpushbutton.h>
42
43UiServer::UiServer(ProgressListModel* model)
44 : KXmlGuiWindow(0), m_systemTray(0)
45{
46 //NOTE: if enough people really hate this dialog (having centralized information and such),
47 //I imagine we could somehow forward it to the old dialogs, which would be displayed 1 for each job.
48 //Or create our own. no worries, we'll see how it plays out..
49
50 QString configure = i18n("Configure...");
51
52 toolBar = addToolBar(configure);
53 toolBar->setMovable(false);
54 toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
55
56 QAction *configureAction = toolBar->addAction(configure);
57 configureAction->setIcon(KIcon("configure"));
58 configureAction->setIconText(configure);
59
60 connect(configureAction, SIGNAL(triggered(bool)), this,
61 SLOT(showConfigurationDialog()));
62
63 toolBar->addSeparator();
64
65 listProgress = new QListView(this);
66 listProgress->setAlternatingRowColors(true);
67 listProgress->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
68 listProgress->setUniformItemSizes(true);
69 listProgress->setSelectionMode(QAbstractItemView::NoSelection);
70 listProgress->setModel(model);
71
72 setCentralWidget(listProgress);
73
74 progressListDelegate = new ProgressListDelegate(this, listProgress);
75 progressListDelegate->setSeparatorPixels(5);
76 progressListDelegate->setLeftMargin(10);
77 progressListDelegate->setRightMargin(10);
78 progressListDelegate->setMinimumItemHeight(100);
79 progressListDelegate->setMinimumContentWidth(300);
80 progressListDelegate->setEditorHeight(20);
81 listProgress->setItemDelegate(progressListDelegate);
82
83
84 m_systemTray = new KSystemTrayIcon(this);
85 m_systemTray->setIcon(KSystemTrayIcon::loadIcon("view-process-system"));
86 m_systemTray->setToolTip(i18n("List of running file transfers/jobs (kuiserver)"));
87 m_systemTray->show();
88 resize(450, 450);
89 applySettings();
90}
91
92UiServer::~UiServer()
93{
94}
95
96
97void UiServer::updateConfiguration()
98{
99 Configuration::self()->writeConfig();
100 applySettings();
101}
102
103void UiServer::applySettings()
104{
105 /* not used.
106 int finishedIndex = tabWidget->indexOf(listFinished);
107 if (Configuration::radioMove()) {
108 if (finishedIndex == -1) {
109 tabWidget->addTab(listFinished, i18n("Finished"));
110 }
111 } else if (finishedIndex != -1) {
112 tabWidget->removeTab(finishedIndex);
113 } */
114}
115
116void UiServer::closeEvent(QCloseEvent *event)
117{
118 event->ignore();
119 hide();
120}
121
122void UiServer::showConfigurationDialog()
123{
124 if (KConfigDialog::showDialog("configuration"))
125 return;
126
127 KConfigDialog *dialog = new KConfigDialog(this, "configuration",
128 Configuration::self());
129
130 UIConfigurationDialog *configurationUI = new UIConfigurationDialog(0);
131
132 dialog->addPage(configurationUI, i18n("Behavior"), "configure");
133
134 connect(dialog, SIGNAL(settingsChanged(const QString&)), this,
135 SLOT(updateConfiguration()));
136 dialog->button(KDialog::Help)->hide();
137 dialog->show();
138}
139
140/// ===========================================================
141
142
143UIConfigurationDialog::UIConfigurationDialog(QWidget *parent)
144 : QWidget(parent)
145{
146 setupUi(this);
147 adjustSize();
148}
149
150UIConfigurationDialog::~UIConfigurationDialog()
151{
152}
153
154
155/// ===========================================================
156
157
158#include "uiserver.moc"
159#include "uiserver_p.moc"
160