summaryrefslogtreecommitdiffstats
path: root/kcontrol/kcontrol
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/kcontrol')
-rw-r--r--kcontrol/kcontrol/KControl.desktop93
-rw-r--r--kcontrol/kcontrol/KControl_NoDisplay.desktop93
-rw-r--r--kcontrol/kcontrol/Makefile.am53
-rw-r--r--kcontrol/kcontrol/about/Makefile.am6
-rw-r--r--kcontrol/kcontrol/about/kcontrol.css54
-rw-r--r--kcontrol/kcontrol/about/main.html64
-rw-r--r--kcontrol/kcontrol/about/top-right-kcontrol.pngbin0 -> 13794 bytes
-rw-r--r--kcontrol/kcontrol/aboutwidget.cpp204
-rw-r--r--kcontrol/kcontrol/aboutwidget.h68
-rw-r--r--kcontrol/kcontrol/cr128-app-kcontrol.pngbin0 -> 12149 bytes
-rw-r--r--kcontrol/kcontrol/cr16-app-kcontrol.pngbin0 -> 887 bytes
-rw-r--r--kcontrol/kcontrol/cr32-app-kcontrol.pngbin0 -> 2375 bytes
-rw-r--r--kcontrol/kcontrol/cr48-app-kcontrol.pngbin0 -> 4134 bytes
-rw-r--r--kcontrol/kcontrol/cr64-app-kcontrol.pngbin0 -> 5941 bytes
-rw-r--r--kcontrol/kcontrol/dockcontainer.cpp257
-rw-r--r--kcontrol/kcontrol/dockcontainer.h86
-rw-r--r--kcontrol/kcontrol/global.cpp116
-rw-r--r--kcontrol/kcontrol/global.h76
-rw-r--r--kcontrol/kcontrol/helpwidget.cpp96
-rw-r--r--kcontrol/kcontrol/helpwidget.h43
-rw-r--r--kcontrol/kcontrol/indexwidget.cpp142
-rw-r--r--kcontrol/kcontrol/indexwidget.h64
-rw-r--r--kcontrol/kcontrol/kcontrolui.rc20
-rw-r--r--kcontrol/kcontrol/kcrootonly.cpp38
-rw-r--r--kcontrol/kcontrol/kcrootonly.h12
-rw-r--r--kcontrol/kcontrol/kinfocenter.desktop109
-rw-r--r--kcontrol/kcontrol/kinfocenterui.rc20
-rw-r--r--kcontrol/kcontrol/main.cpp153
-rw-r--r--kcontrol/kcontrol/main.h42
-rw-r--r--kcontrol/kcontrol/moduleIface.cpp58
-rw-r--r--kcontrol/kcontrol/moduleIface.h54
-rw-r--r--kcontrol/kcontrol/moduleiconview.cpp170
-rw-r--r--kcontrol/kcontrol/moduleiconview.h86
-rw-r--r--kcontrol/kcontrol/modulemenu.cpp105
-rw-r--r--kcontrol/kcontrol/modulemenu.h65
-rw-r--r--kcontrol/kcontrol/modules.cpp345
-rw-r--r--kcontrol/kcontrol/modules.h136
-rw-r--r--kcontrol/kcontrol/moduletreeview.cpp377
-rw-r--r--kcontrol/kcontrol/moduletreeview.h95
-rw-r--r--kcontrol/kcontrol/proxywidget.cpp323
-rw-r--r--kcontrol/kcontrol/proxywidget.h82
-rw-r--r--kcontrol/kcontrol/searchwidget.cpp205
-rw-r--r--kcontrol/kcontrol/searchwidget.h78
-rw-r--r--kcontrol/kcontrol/toplevel.cpp526
-rw-r--r--kcontrol/kcontrol/toplevel.h106
-rw-r--r--kcontrol/kcontrol/version.h2
46 files changed, 4722 insertions, 0 deletions
diff --git a/kcontrol/kcontrol/KControl.desktop b/kcontrol/kcontrol/KControl.desktop
new file mode 100644
index 000000000..c174a867a
--- /dev/null
+++ b/kcontrol/kcontrol/KControl.desktop
@@ -0,0 +1,93 @@
+[Desktop Entry]
+Exec=kcontrol -caption "%c" %i %m
+Icon=kcontrol
+Type=Application
+DocPath=kcontrol/index.html
+X-KDE-StartupNotify=true
+
+Name=Control Center
+Name[af]=Beheer Sentrum
+Name[ar]=مركز التحكم
+Name[az]=İdarə Mərkəzi
+Name[be]=Цэнтр кіравання
+Name[bg]=Контролен център
+Name[bn]=নিয়ন্ত্রণ কেন্দ্র
+Name[br]=Kreizenn ren
+Name[bs]=Kontrolni centar
+Name[ca]=Centre de control
+Name[cs]=Ovládací centrum
+Name[csb]=Centróm kòntrolë
+Name[cy]=Canolfan Rheoli
+Name[da]=Kontrolcenter
+Name[de]=Kontrollzentrum
+Name[el]=Κέντρο ελέγχου
+Name[en_GB]=Control Centre
+Name[eo]=Stircentro
+Name[es]=Centro de control
+Name[et]=Juhtimiskeskus
+Name[eu]=Kontrol gunea
+Name[fa]=مرکز کنترل
+Name[fi]=Ohjauskeskus
+Name[fr]=Centre de configuration de KDE
+Name[fy]=Konfiguraasjesintrum
+Name[ga]=Lárionad Rialaithe
+Name[gl]=Centro de Control
+Name[he]=מרכז הבקרה
+Name[hi]=नियंत्रण केंद्र
+Name[hr]=Upravljačko središte
+Name[hu]=Vezérlőpult
+Name[id]=Pusat Kontrol
+Name[is]=Stjórnborð
+Name[it]=Centro di controllo
+Name[ja]=コントロールセンター
+Name[ka]=საკონტროლო ცენტრი
+Name[kk]=Басқару орталығы
+Name[km]=មជ្ឈមណ្ឌល​បញ្ជា
+Name[ko]=제어판 모듈
+Name[lo]=ສູນຄວບຄຸມ
+Name[lt]=Valdymo centras
+Name[lv]=Vadības Centrs
+Name[mk]=Контролен центар
+Name[mn]=Удирдах төв
+Name[ms]=Pusat Kawalan
+Name[mt]=Ċentru tal-Kontroll
+Name[nb]=Kontrollpanel
+Name[nds]=Kuntrullzentrum
+Name[ne]=नियन्त्रण केन्द्र
+Name[nl]=Configuratiecentrum
+Name[nn]=Kontrollsenter
+Name[nso]=Bogare bja Taolo
+Name[oc]=Centre de control
+Name[pa]=ਕੰਟਰੋਲ ਕੇਂਦਰ
+Name[pl]=Centrum sterowania
+Name[pt]=Centro de Controlo
+Name[pt_BR]=Centro de Controle
+Name[ro]=Centrul de control
+Name[ru]=Центр управления
+Name[rw]=Kugenzura Hagati
+Name[se]=Stivrenguovddáš
+Name[sk]=Ovládacie Centrum
+Name[sl]=Nadzorno središče
+Name[sr]=Контролни центар
+Name[sr@Latn]=Kontrolni centar
+Name[ss]=Sikhungo sekulawula
+Name[sv]=Inställningscentralen
+Name[ta]=கட்டுப்பாட்டு மையம்
+Name[te]=అధికార కేంద్రం
+Name[tg]=Маркази контрол
+Name[th]=ศูนย์ควบคุม
+Name[tr]=Kontrol Merkezi
+Name[tt]=İdärä Üzäge
+Name[uk]=Центр керування
+Name[uz]=Boshqaruv markazi
+Name[uz@cyrillic]=Бошқарув маркази
+Name[ven]=Senthara ya vhulanguli
+Name[vi]=Trung tâm Điều khiển
+Name[wa]=Cinte di contrôle
+Name[xh]=Umbindi Wolawulo
+Name[zh_CN]=控制中心
+Name[zh_TW]=控制中心
+Name[zu]=Indawo Yokulawula
+
+X-DCOP-ServiceType=Unique
+Categories=Qt;KDE;Core;
diff --git a/kcontrol/kcontrol/KControl_NoDisplay.desktop b/kcontrol/kcontrol/KControl_NoDisplay.desktop
new file mode 100644
index 000000000..f19e757f0
--- /dev/null
+++ b/kcontrol/kcontrol/KControl_NoDisplay.desktop
@@ -0,0 +1,93 @@
+[Desktop Entry]
+Exec=kcontrol -caption "%c" %i %m
+Icon=kcontrol
+Type=Application
+DocPath=kcontrol/index.html
+X-KDE-StartupNotify=true
+
+Name=Control Center
+Name[af]=Beheer Sentrum
+Name[ar]=مركز التحكم
+Name[az]=İdarə Mərkəzi
+Name[be]=Цэнтр кіравання
+Name[bg]=Контролен център
+Name[bn]=নিয়ন্ত্রণ কেন্দ্র
+Name[br]=Kreizenn ren
+Name[bs]=Kontrolni centar
+Name[ca]=Centre de control
+Name[cs]=Ovládací centrum
+Name[csb]=Centróm kòntrolë
+Name[cy]=Canolfan Rheoli
+Name[da]=Kontrolcenter
+Name[de]=Kontrollzentrum
+Name[el]=Κέντρο ελέγχου
+Name[en_GB]=Control Centre
+Name[eo]=Stircentro
+Name[es]=Centro de control
+Name[et]=Juhtimiskeskus
+Name[eu]=Kontrol gunea
+Name[fa]=مرکز کنترل
+Name[fi]=Ohjauskeskus
+Name[fr]=Centre de configuration de KDE
+Name[fy]=Konfiguraasjesintrum
+Name[ga]=Lárionad Rialaithe
+Name[gl]=Centro de Control
+Name[he]=מרכז הבקרה
+Name[hi]=नियंत्रण केंद्र
+Name[hr]=Upravljačko središte
+Name[hu]=Vezérlőpult
+Name[id]=Pusat Kontrol
+Name[is]=Stjórnborð
+Name[it]=Centro di controllo
+Name[ja]=コントロールセンター
+Name[ka]=საკონტროლო ცენტრი
+Name[kk]=Басқару орталығы
+Name[km]=មជ្ឈមណ្ឌល​បញ្ជា
+Name[ko]=제어판 모듈
+Name[lo]=ສູນຄວບຄຸມ
+Name[lt]=Valdymo centras
+Name[lv]=Vadības Centrs
+Name[mk]=Контролен центар
+Name[mn]=Удирдах төв
+Name[ms]=Pusat Kawalan
+Name[mt]=Ċentru tal-Kontroll
+Name[nb]=Kontrollpanel
+Name[nds]=Kuntrullzentrum
+Name[ne]=नियन्त्रण केन्द्र
+Name[nl]=Configuratiecentrum
+Name[nn]=Kontrollsenter
+Name[nso]=Bogare bja Taolo
+Name[oc]=Centre de control
+Name[pa]=ਕੰਟਰੋਲ ਕੇਂਦਰ
+Name[pl]=Centrum sterowania
+Name[pt]=Centro de Controlo
+Name[pt_BR]=Centro de Controle
+Name[ro]=Centrul de control
+Name[ru]=Центр управления
+Name[rw]=Kugenzura Hagati
+Name[se]=Stivrenguovddáš
+Name[sk]=Ovládacie Centrum
+Name[sl]=Nadzorno središče
+Name[sr]=Контролни центар
+Name[sr@Latn]=Kontrolni centar
+Name[ss]=Sikhungo sekulawula
+Name[sv]=Inställningscentralen
+Name[ta]=கட்டுப்பாட்டு மையம்
+Name[te]=అధికార కేంద్రం
+Name[tg]=Маркази контрол
+Name[th]=ศูนย์ควบคุม
+Name[tr]=Kontrol Merkezi
+Name[tt]=İdärä Üzäge
+Name[uk]=Центр керування
+Name[uz]=Boshqaruv markazi
+Name[uz@cyrillic]=Бошқарув маркази
+Name[ven]=Senthara ya vhulanguli
+Name[vi]=Trung tâm Điều khiển
+Name[wa]=Cinte di contrôle
+Name[xh]=Umbindi Wolawulo
+Name[zh_CN]=控制中心
+Name[zh_TW]=控制中心
+Name[zu]=Indawo Yokulawula
+
+X-DCOP-ServiceType=Unique
+NoDisplay=true
diff --git a/kcontrol/kcontrol/Makefile.am b/kcontrol/kcontrol/Makefile.am
new file mode 100644
index 000000000..2f2c3a6bc
--- /dev/null
+++ b/kcontrol/kcontrol/Makefile.am
@@ -0,0 +1,53 @@
+#
+# Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+# Copyright (c) 2000 Matthias Elter <elter@kde.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+AM_CPPFLAGS= $(all_includes)
+METASOURCES = AUTO
+
+SUBDIRS = . about
+
+bin_PROGRAMS =
+lib_LTLIBRARIES =
+kdeinit_LTLIBRARIES = kcontrol.la
+
+kcontrol_la_SOURCES = main.cpp toplevel.cpp indexwidget.cpp \
+ helpwidget.cpp dockcontainer.cpp aboutwidget.cpp \
+ moduletreeview.cpp moduleiconview.cpp \
+ moduleIface.cpp moduleIface.skel global.cpp modules.cpp \
+ proxywidget.cpp kcrootonly.cpp searchwidget.cpp
+
+kcontrol_la_LIBADD = $(LIB_KDEUI) $(LIB_KUTILS) $(LIB_KHTML)
+kcontrol_la_LDFLAGS = $(all_libraries) -module -avoid-version
+
+rccontroldir = $(kde_datadir)/kcontrol
+rccontrol_DATA = kcontrolui.rc
+rcinfodir = $(kde_datadir)/kinfocenter
+rcinfo_DATA = kinfocenterui.rc
+
+xdg_apps_DATA = KControl.desktop kinfocenter.desktop
+
+install-data-local:
+ @-rm -f $(DESTDIR)$(kde_bindir)/kinfocenter
+ $(mkinstalldirs) $(DESTDIR)$(kde_bindir)
+ @$(LN_S) kcontrol $(DESTDIR)$(kde_bindir)/kinfocenter
+
+KDE_ICON=AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kcontrol.pot
diff --git a/kcontrol/kcontrol/about/Makefile.am b/kcontrol/kcontrol/about/Makefile.am
new file mode 100644
index 000000000..14e035db7
--- /dev/null
+++ b/kcontrol/kcontrol/about/Makefile.am
@@ -0,0 +1,6 @@
+about_DATA = \
+ top-right-kcontrol.png \
+ main.html \
+ kcontrol.css
+
+aboutdir = $(kde_datadir)/kcontrol/about
diff --git a/kcontrol/kcontrol/about/kcontrol.css b/kcontrol/kcontrol/about/kcontrol.css
new file mode 100644
index 000000000..7e17e6a0d
--- /dev/null
+++ b/kcontrol/kcontrol/about/kcontrol.css
@@ -0,0 +1,54 @@
+
+#headerR {
+ position: absolute;
+ right: 0px;
+ width: 430px;
+ height: 131px;
+ background-image: url(top-right-kcontrol.png);
+}
+
+#title {
+ right: 80px;
+ font-size: x-large;
+}
+
+#tagline {
+ right: 80px;
+ font-size: x-small;
+ text-shadow: #c8c8c8 0px 0px 3px;
+
+}
+
+#barCenter {
+ font-size: x-small;
+}
+
+#tableTitle {
+ font-weight: bold;
+ padding-bottom: 1ex;
+}
+
+.kc_table {
+ font-size: x-small;
+ width: 100%;
+}
+
+.kc_leftcol {
+ width: 30%;
+}
+
+.kc_rightcol {
+ font-weight: bold;
+}
+
+.kc_use_text {
+ margin-bottom: 0;
+ font-size: xx-small;
+}
+
+.kcm_link {
+ color: #000;
+}
+
+/* vim:set sw=2 et nocindent smartindent: */
+
diff --git a/kcontrol/kcontrol/about/main.html b/kcontrol/kcontrol/about/main.html
new file mode 100644
index 000000000..65a0a4c02
--- /dev/null
+++ b/kcontrol/kcontrol/about/main.html
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta name="generator" content=
+ "HTML Tidy for Linux/x86 (vers 1st August 2004), see www.w3.org" />
+
+ <style type="text/css">
+ /*<![CDATA[*/
+ @import "%1"; /* kde_infopage.css */
+ %1 /* maybe @import "kde_infopage_rtl.css"; */
+ @import "kcontrol.css";
+ /*body {font-size: px;}*/
+ /*]]>*/
+ </style>
+</head>
+
+<body>
+ <div id="header">
+ <div id="headerL"/>
+ <div id="headerR"/>
+
+ <div id="title">
+ %2 <!-- Title -->
+ </div>
+
+ <div id="tagline">
+ %3 <!-- Catchphrase -->
+ </div>
+ </div>
+
+ <!-- the bar -->
+ <div id="bar">
+ <div id="barT"><div id="barTL"/><div id="barTR"/><div id="barTC"/></div>
+ <div id="barL">
+ <div id="barR">
+ <div id="barCenter" class="bar_text">
+ %4<!-- Summary -->
+ </div>
+ </div>
+ </div>
+ <div id="barB"><div id="barBL"/><div id="barBR"/><div id="barBC"/></div>
+ </div>
+
+ <!-- the main text box -->
+ <div id="box">
+ <div id="boxT"><div id="boxTL"/><div id="boxTR"/><div id="boxTC"/></div>
+ <div id="boxL">
+ <div id="boxR">
+ <div id="boxCenter">
+ <!--Content-->
+ %5
+ </div>
+ </div>
+ </div>
+ <div id="boxB"><div id="boxBL"/><div id="boxBR"/><div id="boxBC"/></div>
+ </div>
+
+ <div id="footer"><div id="footerL"/><div id="footerR"/></div>
+</body>
+</html>
+<!-- vim:set sw=2 et nocindent smartindent: -->
diff --git a/kcontrol/kcontrol/about/top-right-kcontrol.png b/kcontrol/kcontrol/about/top-right-kcontrol.png
new file mode 100644
index 000000000..bad44f089
--- /dev/null
+++ b/kcontrol/kcontrol/about/top-right-kcontrol.png
Binary files differ
diff --git a/kcontrol/kcontrol/aboutwidget.cpp b/kcontrol/kcontrol/aboutwidget.cpp
new file mode 100644
index 000000000..209b264ec
--- /dev/null
+++ b/kcontrol/kcontrol/aboutwidget.cpp
@@ -0,0 +1,204 @@
+/*
+ Copyright (c) 2000,2001 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <qpainter.h>
+#include <qwhatsthis.h>
+#include <qregexp.h>
+#include <qlayout.h>
+#include <qfile.h>
+
+#include <kstandarddirs.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kpixmap.h>
+#include <kpixmapeffect.h>
+#include <kcursor.h>
+#include <kglobalsettings.h>
+#include <khtml_part.h>
+#include <kapplication.h>
+#include <kiconloader.h>
+
+#include "global.h"
+#include "aboutwidget.h"
+#include "aboutwidget.moc"
+#include "modules.h"
+#include "moduletreeview.h"
+
+static const char kcc_text[] = I18N_NOOP("KDE Control Center");
+
+static const char title_text[] = I18N_NOOP("Configure your desktop environment.");
+
+static const char intro_text[] = I18N_NOOP("Welcome to the \"KDE Control Center\", "
+ "a central place to configure your "
+ "desktop environment. "
+ "Select an item from the index on the left "
+ "to load a configuration module.");
+
+static const char kcc_infotext[] = I18N_NOOP("KDE Info Center");
+
+static const char title_infotext[] = I18N_NOOP("Get system and desktop environment information");
+
+static const char intro_infotext[] = I18N_NOOP("Welcome to the \"KDE Info Center\", "
+ "a central place to find information about your "
+ "computer system.");
+
+static const char use_text[] = I18N_NOOP("Use the \"Search\" field if you are unsure "
+ "where to look for a particular configuration option.");
+
+static const char version_text[] = I18N_NOOP("KDE version:");
+static const char user_text[] = I18N_NOOP("User:");
+static const char host_text[] = I18N_NOOP("Hostname:");
+static const char system_text[] = I18N_NOOP("System:");
+static const char release_text[] = I18N_NOOP("Release:");
+static const char machine_text[] = I18N_NOOP("Machine:");
+
+AboutWidget::AboutWidget(QWidget *parent , const char *name, QListViewItem* category, const QString &caption)
+ : QHBox(parent, name),
+ _moduleList(false),
+ _category(category),
+ _caption(caption)
+{
+ if (_category)
+ _moduleList = true;
+
+ setMinimumSize(400, 400);
+
+ // set qwhatsthis help
+ QWhatsThis::add(this, i18n(intro_text));
+ _viewer = new KHTMLPart( this, "_viewer" );
+ _viewer->widget()->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored );
+ connect( _viewer->browserExtension(),
+ SIGNAL(openURLRequest(const KURL&, const KParts::URLArgs&)),
+ this, SLOT(slotModuleLinkClicked(const KURL&)) );
+ updatePixmap();
+}
+
+void AboutWidget::setCategory( QListViewItem* category, const QString& icon, const QString &caption )
+{
+ _icon = icon;
+ _caption = caption;
+ _category = category;
+ if ( _category )
+ _moduleList = true;
+ else
+ _moduleList = true;
+
+ // Update the pixmap to be shown:
+ updatePixmap();
+}
+
+void AboutWidget::updatePixmap()
+{
+ QString file = locate( "data", "kcontrol/about/main.html" );
+ QFile f( file );
+ f.open( IO_ReadOnly );
+ QTextStream t( &f );
+ QString res = t.read();
+
+ res = res.arg( locate( "data", "kdeui/about/kde_infopage.css" ) );
+ if ( kapp->reverseLayout() )
+ res = res.arg( "@import \"%1\";" ).arg( locate( "data", "kdeui/about/kde_infopage_rtl.css" ) );
+ else
+ res = res.arg( "" );
+
+
+ QString title, intro, caption;
+ if (KCGlobal::isInfoCenter())
+ {
+ res = res.arg(i18n(kcc_infotext))
+ .arg(i18n(title_infotext))
+ .arg(i18n(intro_infotext));
+ }
+ else
+ {
+ res = res.arg(i18n(kcc_text))
+ .arg(i18n(title_text))
+ .arg(i18n(intro_text));
+ }
+
+ QString content;
+
+ if (!_moduleList)
+ {
+ content += "<table class=\"kc_table\">\n";
+#define KC_HTMLROW( a, b ) "<tr><td class=\"kc_leftcol\">" + i18n( a ) + "</td><td class=\"kc_rightcol\">" + b + "</tr>\n"
+ content += KC_HTMLROW( version_text, KCGlobal::kdeVersion() );
+ content += KC_HTMLROW( user_text, KCGlobal::userName() );
+ content += KC_HTMLROW( host_text, KCGlobal::hostName() );
+ content += KC_HTMLROW( system_text, KCGlobal::systemName() );
+ content += KC_HTMLROW( release_text, KCGlobal::systemRelease() );
+ content += KC_HTMLROW( machine_text, KCGlobal::systemMachine() );
+#undef KC_HTMLROW
+ content += "</table>\n";
+ content += "<p class=\"kc_use_text\">" + i18n( use_text ) + "</p>\n";
+ }
+ else
+ {
+ KIconLoader *loader = KGlobal::instance()->iconLoader();
+ QString iconPath;
+ if (!_icon.isEmpty()) {
+ iconPath = loader->iconPath( _icon, KIcon::Toolbar );
+ content += "<div id=\"tableTitle\"><img src=\"" + iconPath +" \"</a>&nbsp;" + _caption + "</div>";
+ }
+
+ content += "<table class=\"kc_table\">\n";
+ // traverse the list
+ QListViewItem* pEntry = _category;
+ while (pEntry != NULL)
+ {
+ QString szName;
+ QString szComment;
+ ConfigModule *module = static_cast<ModuleTreeItem*>(pEntry)->module();
+ /* TODO: work out link */
+ content += "<tr><td class=\"kc_leftcol\">";
+ if (module)
+ {
+ szName = module->moduleName();
+ szComment = module->comment();
+ iconPath = loader->iconPath( module->icon(), KIcon::Small );
+
+ content += "<img src=\"" + iconPath +" \"</a>&nbsp;<a href=\"%1\" class=\"kcm_link\">" + szName + "</a></td><td class=\"kc_rightcol\">" + szComment;
+ KURL moduleURL( QString("kcm://%1").arg(QString().sprintf("%p",module)) );
+ QString linkURL( moduleURL.url() );
+ content = content.arg( linkURL );
+ _moduleMap.insert( linkURL, module );
+ }
+ else
+ {
+ szName = static_cast<ModuleTreeItem*>(pEntry)->caption();
+ content += szName + "</td><td class=\"kc_rightcol\">" + szName;
+ }
+ content += "</td></tr>\n";
+ pEntry = pEntry->nextSibling();
+ }
+ content += "</table>";
+ }
+ _viewer->begin(KURL( file ));
+ _viewer->write( res.arg( content ) );
+ _viewer->end();
+}
+
+void AboutWidget::slotModuleLinkClicked( const KURL& url )
+{
+ ConfigModule* module;
+ module = _moduleMap[url.url()];
+ if ( module )
+ emit moduleSelected( module );
+}
+
diff --git a/kcontrol/kcontrol/aboutwidget.h b/kcontrol/kcontrol/aboutwidget.h
new file mode 100644
index 000000000..e0b51fd54
--- /dev/null
+++ b/kcontrol/kcontrol/aboutwidget.h
@@ -0,0 +1,68 @@
+/*
+ Copyright (c) 2000,2001 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __aboutwidget_h__
+#define __aboutwidget_h__
+
+#include <qwidget.h>
+#include <qlistview.h>
+#include <qhbox.h>
+
+class KCModuleInfo;
+class QPixmap;
+class KPixmap;
+class ConfigModule;
+class KHTMLPart;
+class KURL;
+
+class AboutWidget : public QHBox
+{
+ Q_OBJECT
+
+public:
+ AboutWidget(QWidget *parent, const char *name=0, QListViewItem* category=0, const QString &caption=QString::null);
+
+ /**
+ * Set a new category without creating a new AboutWidget if there is
+ * one visible already (reduces flicker)
+ */
+ void setCategory( QListViewItem* category, const QString& icon, const QString& caption);
+
+signals:
+ void moduleSelected(ConfigModule *);
+
+private slots:
+ void slotModuleLinkClicked( const KURL& );
+
+private:
+ /**
+ * Update the pixmap to be shown. Called from resizeEvent and from
+ * setCategory.
+ */
+ void updatePixmap();
+
+ bool _moduleList;
+ QListViewItem* _category;
+ QString _icon;
+ QString _caption;
+ KHTMLPart *_viewer;
+ QMap<QString,ConfigModule*> _moduleMap;
+};
+
+#endif
diff --git a/kcontrol/kcontrol/cr128-app-kcontrol.png b/kcontrol/kcontrol/cr128-app-kcontrol.png
new file mode 100644
index 000000000..99a89e323
--- /dev/null
+++ b/kcontrol/kcontrol/cr128-app-kcontrol.png
Binary files differ
diff --git a/kcontrol/kcontrol/cr16-app-kcontrol.png b/kcontrol/kcontrol/cr16-app-kcontrol.png
new file mode 100644
index 000000000..64bf8b71d
--- /dev/null
+++ b/kcontrol/kcontrol/cr16-app-kcontrol.png
Binary files differ
diff --git a/kcontrol/kcontrol/cr32-app-kcontrol.png b/kcontrol/kcontrol/cr32-app-kcontrol.png
new file mode 100644
index 000000000..6537ba75e
--- /dev/null
+++ b/kcontrol/kcontrol/cr32-app-kcontrol.png
Binary files differ
diff --git a/kcontrol/kcontrol/cr48-app-kcontrol.png b/kcontrol/kcontrol/cr48-app-kcontrol.png
new file mode 100644
index 000000000..bde85be5f
--- /dev/null
+++ b/kcontrol/kcontrol/cr48-app-kcontrol.png
Binary files differ
diff --git a/kcontrol/kcontrol/cr64-app-kcontrol.png b/kcontrol/kcontrol/cr64-app-kcontrol.png
new file mode 100644
index 000000000..4d4db5d65
--- /dev/null
+++ b/kcontrol/kcontrol/cr64-app-kcontrol.png
Binary files differ
diff --git a/kcontrol/kcontrol/dockcontainer.cpp b/kcontrol/kcontrol/dockcontainer.cpp
new file mode 100644
index 000000000..be2587114
--- /dev/null
+++ b/kcontrol/kcontrol/dockcontainer.cpp
@@ -0,0 +1,257 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <qlabel.h>
+#include <qvbox.h>
+#include <qpixmap.h>
+#include <qfont.h>
+#include <qwhatsthis.h>
+#include <qapplication.h>
+#include <qpushbutton.h>
+
+#include <kapplication.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kiconloader.h>
+
+#include "dockcontainer.h"
+#include "dockcontainer.moc"
+
+#include "global.h"
+#include "modules.h"
+#include "proxywidget.h"
+
+class ModuleTitle : public QHBox
+{
+ public:
+ ModuleTitle( QWidget *parent, const char *name=0 );
+ ~ModuleTitle() {}
+
+ void showTitleFor( ConfigModule *module );
+ void clear();
+
+ protected:
+ QLabel *m_icon;
+ QLabel *m_name;
+};
+
+ModuleTitle::ModuleTitle( QWidget *parent, const char *name )
+ : QHBox( parent, name )
+{
+ QWidget *spacer = new QWidget( this );
+ spacer->setFixedWidth( KDialog::marginHint()-KDialog::spacingHint() );
+ m_icon = new QLabel( this );
+ m_name = new QLabel( this );
+
+ QFont font = m_name->font();
+ font.setPointSize( font.pointSize()+1 );
+ font.setBold( true );
+ m_name->setFont( font );
+
+ setSpacing( KDialog::spacingHint() );
+ if ( QApplication::reverseLayout() )
+ {
+ spacer = new QWidget( this );
+ setStretchFactor( spacer, 10 );
+ }
+ else
+ setStretchFactor( m_name, 10 );
+}
+
+void ModuleTitle::showTitleFor( ConfigModule *config )
+{
+ if ( !config )
+ return;
+
+ QWhatsThis::remove( this );
+ QWhatsThis::add( this, config->comment() );
+ KIconLoader *loader = KGlobal::instance()->iconLoader();
+ QPixmap icon = loader->loadIcon( config->icon(), KIcon::NoGroup, 22 );
+ m_icon->setPixmap( icon );
+ m_name->setText( config->moduleName() );
+
+ show();
+}
+
+void ModuleTitle::clear()
+{
+ m_icon->setPixmap( QPixmap() );
+ m_name->setText( QString::null );
+ kapp->processEvents();
+}
+
+ModuleWidget::ModuleWidget( QWidget *parent, const char *name )
+ : QVBox( parent, name )
+{
+ QHBox* titleLine = new QHBox( this, "titleLine");
+ m_title = new ModuleTitle( titleLine, "m_title" );
+ QPushButton *helpButton = new QPushButton( titleLine );
+ helpButton->setIconSet( SmallIconSet("help") );
+ connect (helpButton, SIGNAL( clicked() ), this, SIGNAL( helpRequest() ) );
+ m_body = new QVBox( this, "m_body" );
+ setStretchFactor( m_body, 10 );
+}
+
+ProxyWidget *ModuleWidget::load( ConfigModule *module )
+{
+ m_title->clear();
+ ProxyWidget *proxy = module->module();
+
+ if ( proxy )
+ {
+ proxy->reparent(m_body, 0, QPoint(0,0), false);
+ proxy->show();
+ m_title->showTitleFor( module );
+ }
+
+ return proxy;
+}
+
+DockContainer::DockContainer(QWidget *parent)
+ : QWidgetStack(parent, "DockContainer")
+ , _basew(0L)
+ , _module(0L)
+{
+ _busyw = new QLabel(i18n("<big><b>Loading...</b></big>"), this);
+ _busyw->setAlignment(AlignCenter);
+ _busyw->setTextFormat(RichText);
+ _busyw->setGeometry(0,0, width(), height());
+ addWidget( _busyw );
+
+ _modulew = new ModuleWidget( this, "_modulew" );
+ connect (_modulew, SIGNAL( helpRequest() ), SLOT( slotHelpRequest() ) );
+ addWidget( _modulew );
+}
+
+DockContainer::~DockContainer()
+{
+ deleteModule();
+}
+
+void DockContainer::setBaseWidget(QWidget *widget)
+{
+ removeWidget( _basew );
+ delete _basew;
+ _basew = 0;
+ if (!widget) return;
+
+ _basew = widget;
+
+ addWidget( _basew );
+ raiseWidget( _basew );
+
+ emit newModule(widget->caption(), "", "");
+}
+
+ProxyWidget* DockContainer::loadModule( ConfigModule *module )
+{
+ QApplication::setOverrideCursor( waitCursor );
+
+ ProxyWidget *widget = _modulew->load( module );
+
+ if (widget)
+ {
+ _module = module;
+ connect(_module, SIGNAL(childClosed()), SLOT(removeModule()));
+ connect(_module, SIGNAL(changed(ConfigModule *)),
+ SIGNAL(changedModule(ConfigModule *)));
+ connect(widget, SIGNAL(quickHelpChanged()), SLOT(quickHelpChanged()));
+
+ raiseWidget( _modulew );
+ emit newModule(widget->caption(), module->docPath(), widget->quickHelp());
+ }
+ else
+ {
+ raiseWidget( _basew );
+ emit newModule(_basew->caption(), "", "");
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ return widget;
+}
+
+bool DockContainer::dockModule(ConfigModule *module)
+{
+ if (module == _module) return true;
+
+ if (_module && _module->isChanged())
+ {
+
+ int res = KMessageBox::warningYesNoCancel(this,
+module ?
+i18n("There are unsaved changes in the active module.\n"
+ "Do you want to apply the changes before running "
+ "the new module or discard the changes?") :
+i18n("There are unsaved changes in the active module.\n"
+ "Do you want to apply the changes before exiting "
+ "the Control Center or discard the changes?"),
+ i18n("Unsaved Changes"),
+ KStdGuiItem::apply(),
+ KStdGuiItem::discard());
+ if (res == KMessageBox::Yes)
+ _module->module()->applyClicked();
+ if (res == KMessageBox::Cancel)
+ return false;
+ }
+
+ raiseWidget( _busyw );
+ kapp->processEvents();
+
+ deleteModule();
+ if (!module) return true;
+
+ ProxyWidget *widget = loadModule( module );
+
+ KCGlobal::repairAccels( topLevelWidget() );
+ return ( widget!=0 );
+}
+
+void DockContainer::removeModule()
+{
+ raiseWidget( _basew );
+ deleteModule();
+
+ if (_basew)
+ emit newModule(_basew->caption(), "", "");
+ else
+ emit newModule("", "", "");
+}
+
+void DockContainer::deleteModule()
+{
+ if(_module) {
+ _module->deleteClient();
+ _module = 0;
+ }
+}
+
+void DockContainer::quickHelpChanged()
+{
+ if (_module && _module->module())
+ emit newModule(_module->module()->caption(), _module->docPath(), _module->module()->quickHelp());
+}
+
+void DockContainer::slotHelpRequest()
+{
+ if (_module && _module->module())
+ _module->module()->helpClicked();
+}
diff --git a/kcontrol/kcontrol/dockcontainer.h b/kcontrol/kcontrol/dockcontainer.h
new file mode 100644
index 000000000..94494cac5
--- /dev/null
+++ b/kcontrol/kcontrol/dockcontainer.h
@@ -0,0 +1,86 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __dockcontainer_h__
+#define __dockcontainer_h__
+
+#include <qwidgetstack.h>
+#include <qvbox.h>
+
+class ConfigModule;
+class ModuleTitle;
+class ProxyWidget;
+class QLabel;
+
+class ModuleWidget : public QVBox
+{
+ Q_OBJECT
+
+ public:
+ ModuleWidget( QWidget *parent, const char *name );
+ ~ModuleWidget() {}
+
+ ProxyWidget* load( ConfigModule *module );
+
+ signals:
+ void helpRequest();
+
+ protected:
+ ModuleTitle *m_title;
+ QVBox *m_body;
+};
+
+class DockContainer : public QWidgetStack
+{
+ Q_OBJECT
+
+public:
+ DockContainer(QWidget *parent=0);
+ virtual ~DockContainer();
+
+ void setBaseWidget(QWidget *widget);
+ QWidget *baseWidget() { return _basew; }
+
+ bool dockModule(ConfigModule *module);
+ ConfigModule *module() { return _module; }
+
+public slots:
+ void removeModule();
+
+protected slots:
+ void quickHelpChanged();
+ void slotHelpRequest();
+
+protected:
+ void deleteModule();
+ ProxyWidget* loadModule( ConfigModule *module );
+
+signals:
+ void newModule(const QString &name, const QString& docPath, const QString &quickhelp);
+ void changedModule(ConfigModule *module);
+
+private:
+ QWidget *_basew;
+ QLabel *_busyw;
+ ModuleWidget *_modulew;
+ ConfigModule *_module;
+
+};
+
+#endif
diff --git a/kcontrol/kcontrol/global.cpp b/kcontrol/kcontrol/global.cpp
new file mode 100644
index 000000000..83d2052b2
--- /dev/null
+++ b/kcontrol/kcontrol/global.cpp
@@ -0,0 +1,116 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/utsname.h>
+#include <kservicegroup.h>
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kuser.h>
+
+#include <qobjectlist.h>
+#include <qaccel.h>
+
+#include "global.h"
+
+bool KCGlobal::_root = false;
+bool KCGlobal::_infocenter = false;
+QStringList KCGlobal::_types;
+QString KCGlobal::_uname = "";
+QString KCGlobal::_hname = "";
+QString KCGlobal::_kdeversion = "";
+QString KCGlobal::_isystem = "";
+QString KCGlobal::_irelease = "";
+QString KCGlobal::_iversion = "";
+QString KCGlobal::_imachine = "";
+IndexViewMode KCGlobal::_viewmode = Icon;
+KIcon::StdSizes KCGlobal::_iconsize = KIcon::SizeMedium;
+QString KCGlobal::_baseGroup = "";
+
+void KCGlobal::init()
+{
+ char buf[256];
+ buf[0] = '\0';
+ if (!gethostname(buf, sizeof(buf)))
+ buf[sizeof(buf)-1] ='\0';
+ QString hostname(buf);
+
+ setHostName(hostname);
+ setUserName(KUser().loginName());
+ setRoot(getuid() == 0);
+
+ setKDEVersion(KDE::versionString());
+
+ struct utsname info;
+ uname(&info);
+
+ setSystemName(info.sysname);
+ setSystemRelease(info.release);
+ setSystemVersion(info.version);
+ setSystemMachine(info.machine);
+}
+
+void KCGlobal::setType(const QCString& s)
+{
+ QString string = s.lower();
+ _types = QStringList::split(',', string);
+}
+
+QString KCGlobal::baseGroup()
+{
+ if ( _baseGroup.isEmpty() )
+ {
+ KServiceGroup::Ptr group = KServiceGroup::baseGroup( _infocenter ? "info" : "settings" );
+ if (group)
+ {
+ _baseGroup = group->relPath();
+ kdDebug(1208) << "Found basegroup = " << _baseGroup << endl;
+ return _baseGroup;
+ }
+ // Compatibility with old behaviour, in case of missing .directory files.
+ if (_baseGroup.isEmpty())
+ {
+ if (_infocenter)
+ {
+ kdWarning() << "No K menu group with X-KDE-BaseGroup=info found ! Defaulting to Settings/Information/" << endl;
+ _baseGroup = QString::fromLatin1("Settings/Information/");
+ }
+ else
+ {
+ kdWarning() << "No K menu group with X-KDE-BaseGroup=settings found ! Defaulting to Settings/" << endl;
+ _baseGroup = QString::fromLatin1("Settings/");
+ }
+ }
+ }
+ return _baseGroup;
+}
+
+void KCGlobal::repairAccels( QWidget * tw )
+{
+ QObjectList * l = tw->queryList( "QAccel" );
+ QObjectListIt it( *l ); // iterate over the buttons
+ QObject * obj;
+ while ( (obj=it.current()) != 0 ) { // for each found object...
+ ++it;
+ ((QAccel*)obj)->repairEventFilter();
+ }
+ delete l; // delete the list, not the objects
+}
diff --git a/kcontrol/kcontrol/global.h b/kcontrol/kcontrol/global.h
new file mode 100644
index 000000000..71fbb55c3
--- /dev/null
+++ b/kcontrol/kcontrol/global.h
@@ -0,0 +1,76 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __global_h__
+#define __global_h__
+
+#include <kicontheme.h>
+
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qcstring.h>
+
+enum IndexViewMode {Icon, Tree};
+
+class KCGlobal
+{
+public:
+
+ static void init();
+
+ static bool isInfoCenter() { return _infocenter; }
+ static bool root() { return _root; }
+ static QStringList types() { return _types; }
+ static QString userName() { return _uname; }
+ static QString hostName() { return _hname; }
+ static QString kdeVersion() { return _kdeversion; }
+ static QString systemName() { return _isystem; }
+ static QString systemRelease() { return _irelease; }
+ static QString systemVersion() { return _iversion; }
+ static QString systemMachine() { return _imachine; }
+ static IndexViewMode viewMode() { return _viewmode; }
+ static KIcon::StdSizes iconSize() { return _iconsize; }
+ static QString baseGroup();
+
+ static void setIsInfoCenter(bool b) { _infocenter = b; }
+ static void setRoot(bool r) { _root = r; }
+ static void setType(const QCString& s);
+ static void setUserName(const QString& n){ _uname = n; }
+ static void setHostName(const QString& n){ _hname = n; }
+ static void setKDEVersion(const QString& n){ _kdeversion = n; }
+ static void setSystemName(const QString& n){ _isystem = n; }
+ static void setSystemRelease(const QString& n){ _irelease = n; }
+ static void setSystemVersion(const QString& n){ _iversion = n; }
+ static void setSystemMachine(const QString& n){ _imachine = n; }
+ static void setViewMode(IndexViewMode m) { _viewmode = m; }
+ static void setIconSize(KIcon::StdSizes s) { _iconsize = s; }
+
+ static void repairAccels( QWidget * tw );
+
+private:
+ static bool _root;
+ static bool _infocenter;
+ static QStringList _types;
+ static QString _uname, _hname, _isystem, _irelease, _iversion, _imachine, _kdeversion;
+ static IndexViewMode _viewmode;
+ static KIcon::StdSizes _iconsize;
+ static QString _baseGroup;
+};
+
+#endif
diff --git a/kcontrol/kcontrol/helpwidget.cpp b/kcontrol/kcontrol/helpwidget.cpp
new file mode 100644
index 000000000..b53fbc8a9
--- /dev/null
+++ b/kcontrol/kcontrol/helpwidget.cpp
@@ -0,0 +1,96 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <qwhatsthis.h>
+
+#include <klocale.h>
+#include <kdebug.h>
+#include <kprocess.h>
+#include <kapplication.h>
+#include <krun.h>
+
+#include "global.h"
+#include "helpwidget.h"
+
+HelpWidget::HelpWidget(QWidget *parent) : QWhatsThis(parent)
+{
+ setBaseText();
+}
+
+void HelpWidget::setText(const QString& docPath, const QString& text)
+{
+ docpath = docPath;
+ if (text.isEmpty() && docPath.isEmpty())
+ setBaseText();
+ else if (docPath.isEmpty())
+ helptext = text;
+ else
+ helptext = (text + i18n("<p>Use the \"What's This?\" (Shift+F1) to get help on specific options.</p><p>To read the full manual click <a href=\"%1\">here</a>.</p>")
+ .arg(docPath.local8Bit()));
+}
+
+void HelpWidget::setBaseText()
+{
+ if (KCGlobal::isInfoCenter())
+ helptext = (i18n("<h1>KDE Info Center</h1>"
+ "There is no quick help available for the active info module."
+ "<br><br>"
+ "Click <a href = \"kinfocenter/index.html\">here</a> to read the general Info Center manual.") );
+ else
+ helptext = (i18n("<h1>KDE Control Center</h1>"
+ "There is no quick help available for the active control module."
+ "<br><br>"
+ "Click <a href = \"kcontrol/index.html\">here</a> to read the general Control Center manual.") );
+}
+
+QString HelpWidget::text() const
+{
+ return helptext;
+}
+
+bool HelpWidget::clicked(const QString & _url)
+{
+ if ( _url.isNull() )
+ return true;
+
+ if ( _url.find('@') > -1 ) {
+ kapp->invokeMailer(_url);
+ return true;
+ }
+
+ KProcess process;
+ KURL url(KURL("help:/"), _url);
+
+ if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
+ process << "khelpcenter"
+ << url.url();
+ process.start(KProcess::DontCare);
+ } else {
+ new KRun(url);
+ }
+ return true;
+}
+
+void HelpWidget::handbookRequest()
+{
+ if (docpath.isEmpty())
+ kdWarning() << "No handbook defined" << endl;
+
+ clicked(docpath);
+}
diff --git a/kcontrol/kcontrol/helpwidget.h b/kcontrol/kcontrol/helpwidget.h
new file mode 100644
index 000000000..08e495096
--- /dev/null
+++ b/kcontrol/kcontrol/helpwidget.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __helpwidget_h__
+#define __helpwidget_h__
+
+class QWidget;
+class QWhatsThis;
+
+class HelpWidget : public QWhatsThis
+{
+public:
+ HelpWidget(QWidget *parent);
+
+ void setText( const QString& docPath, const QString& text);
+ void setBaseText();
+ QString text() const;
+
+ bool clicked(const QString &);
+ void handbookRequest();
+
+private:
+ QString docpath;
+ QString helptext;
+};
+
+#endif
diff --git a/kcontrol/kcontrol/indexwidget.cpp b/kcontrol/kcontrol/indexwidget.cpp
new file mode 100644
index 000000000..d427b5707
--- /dev/null
+++ b/kcontrol/kcontrol/indexwidget.cpp
@@ -0,0 +1,142 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+ Copyright (c) 2003 Frauke Oster <frauke.oster@t-online.de>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <qlistview.h>
+
+
+#include "indexwidget.h"
+#include "indexwidget.moc"
+#include "moduletreeview.h"
+#include "moduleiconview.h"
+
+IndexWidget::IndexWidget(ConfigModuleList *modules, QWidget *parent ,const char *name)
+ : QWidgetStack(parent, name)
+ , _tree(0L)
+ , _icon(0L)
+ , _modules(modules)
+ , viewMode(Icon)
+{
+ activateView(Icon);
+}
+
+IndexWidget::~IndexWidget() {}
+
+void IndexWidget::reload()
+{
+ if (_icon)
+ _icon->fill();
+}
+
+QListViewItem *IndexWidget::firstTreeViewItem()
+{
+ if (_tree)
+ return _tree->firstChild();
+ else
+ return 0L;
+}
+
+
+void IndexWidget::resizeEvent(QResizeEvent *e)
+{
+ QWidgetStack::resizeEvent( e );
+}
+
+void IndexWidget::moduleSelected(ConfigModule *m)
+{
+ const QObject *obj = sender();
+ if(!m) return;
+
+ emit moduleActivated(m);
+
+ if (obj->inherits("ModuleIconView") && _tree)
+ {
+ _tree->makeVisible(m);
+
+ _tree->disconnect(SIGNAL(moduleSelected(ConfigModule*)));
+ _tree->makeSelected(m);
+ connect(_tree, SIGNAL(moduleSelected(ConfigModule*)),
+ this, SLOT(moduleSelected(ConfigModule*)));
+ }
+ else if (obj->inherits("ModuleTreeView") && _icon)
+ {
+ _icon->makeVisible(m);
+
+ _icon->disconnect(SIGNAL(moduleSelected(ConfigModule*)));
+ _icon->makeSelected(m);
+ connect(_icon, SIGNAL(moduleSelected(ConfigModule*)),
+ this, SLOT(moduleSelected(ConfigModule*)));
+ }
+}
+
+void IndexWidget::makeSelected(ConfigModule *module)
+{
+ if (_icon)
+ {
+ _icon->disconnect(SIGNAL(moduleSelected(ConfigModule*)));
+ _icon->makeSelected(module);
+ connect(_icon, SIGNAL(moduleSelected(ConfigModule*)),
+ this, SLOT(moduleSelected(ConfigModule*)));
+ }
+ if (_tree)
+ {
+ _tree->disconnect(SIGNAL(moduleSelected(ConfigModule*)));
+ _tree->makeSelected(module);
+ connect(_tree, SIGNAL(moduleSelected(ConfigModule*)),
+ this, SLOT(moduleSelected(ConfigModule*)));
+ }
+}
+
+void IndexWidget::makeVisible(ConfigModule *module)
+{
+ if (_icon)
+ _icon->makeVisible(module);
+ if (_tree)
+ _tree->makeVisible(module);
+}
+
+void IndexWidget::activateView(IndexViewMode mode)
+{
+ viewMode = mode;
+
+ if (mode == Icon)
+ {
+ if (!_icon)
+ {
+ _icon=new ModuleIconView(_modules, this);
+ _icon->fill();
+ connect(_icon, SIGNAL(moduleSelected(ConfigModule*)),
+ this, SLOT(moduleSelected(ConfigModule*)));
+ }
+ raiseWidget( _icon );
+ }
+ else
+ {
+ if (!_tree)
+ {
+ _tree=new ModuleTreeView(_modules, this);
+ _tree->fill();
+ connect(_tree, SIGNAL(moduleSelected(ConfigModule*)),
+ this, SLOT(moduleSelected(ConfigModule*)));
+ connect(_tree, SIGNAL(categorySelected(QListViewItem*)),
+ this, SIGNAL(categorySelected(QListViewItem*)));
+ }
+ raiseWidget( _tree );
+ }
+}
diff --git a/kcontrol/kcontrol/indexwidget.h b/kcontrol/kcontrol/indexwidget.h
new file mode 100644
index 000000000..0a358aa2e
--- /dev/null
+++ b/kcontrol/kcontrol/indexwidget.h
@@ -0,0 +1,64 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __indexwidget_h__
+#define __indexwidget_h__
+
+#include <qwidgetstack.h>
+
+#include "global.h"
+
+class ConfigModuleList;
+class ConfigModule;
+class ModuleTreeView;
+class ModuleIconView;
+
+class IndexWidget : public QWidgetStack
+{
+ Q_OBJECT
+
+public:
+ IndexWidget(ConfigModuleList *list, QWidget *parent, const char *name=0);
+ virtual ~IndexWidget();
+
+ QListViewItem *firstTreeViewItem();
+public slots:
+ void makeVisible(ConfigModule *module);
+ void makeSelected(ConfigModule *module);
+ void activateView(IndexViewMode);
+ void reload();
+
+protected slots:
+ void moduleSelected(ConfigModule *);
+
+signals:
+ void moduleActivated(ConfigModule *module);
+ void categorySelected(QListViewItem *);
+
+protected:
+ void resizeEvent(QResizeEvent *e);
+
+private:
+ ModuleTreeView *_tree;
+ ModuleIconView *_icon;
+ ConfigModuleList *_modules;
+ IndexViewMode viewMode;
+};
+
+#endif
diff --git a/kcontrol/kcontrol/kcontrolui.rc b/kcontrol/kcontrol/kcontrolui.rc
new file mode 100644
index 000000000..92867beb3
--- /dev/null
+++ b/kcontrol/kcontrol/kcontrolui.rc
@@ -0,0 +1,20 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kcontrol" version="2">
+<MenuBar>
+ <Menu name="view"><text>&amp;View</text>
+ <Menu name="view_mode"><text>&amp;Mode</text>
+ <Action name="activate_iconview"/>
+ <Action name="activate_treeview"/>
+ </Menu>
+ <Menu name="view_iconsize"><text>Icon &amp;Size</text>
+ <Action name="activate_smallicons"/>
+ <Action name="activate_mediumicons"/>
+ <Action name="activate_largeicons"/>
+ <Action name="activate_hugeicons"/>
+ </Menu>
+ </Menu>
+ <Menu name="help">
+ <Action name="help_about_module" append="about_merge"/>
+ </Menu>
+</MenuBar>
+</kpartgui>
diff --git a/kcontrol/kcontrol/kcrootonly.cpp b/kcontrol/kcontrol/kcrootonly.cpp
new file mode 100644
index 000000000..5d3a0ce27
--- /dev/null
+++ b/kcontrol/kcontrol/kcrootonly.cpp
@@ -0,0 +1,38 @@
+/*
+ Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <qlabel.h>
+
+#include <klocale.h>
+
+#include "kcrootonly.h"
+
+KCRootOnly::KCRootOnly(QWidget *parent, const char *name)
+ : KCModule(parent, name)
+{
+ QVBoxLayout *layout=new QVBoxLayout(this);
+ QLabel *label = new QLabel(i18n("<big>You need super user privileges to run this control module.</big><br>"
+ "Click on the \"Administrator Mode\" button below."), this);
+ layout->addWidget(label);
+ label->setAlignment(AlignCenter);
+ label->setTextFormat(RichText);
+ label->setMinimumSize(label->sizeHint());
+}
+
+
diff --git a/kcontrol/kcontrol/kcrootonly.h b/kcontrol/kcontrol/kcrootonly.h
new file mode 100644
index 000000000..e04df7c80
--- /dev/null
+++ b/kcontrol/kcontrol/kcrootonly.h
@@ -0,0 +1,12 @@
+
+#ifndef _kcontrol_kcrootonly_
+#define _kcontrol_kcrootonly_
+
+#include <kcmodule.h>
+
+class KCRootOnly: public KCModule {
+public:
+ KCRootOnly(QWidget *parent, const char *name);
+};
+
+#endif
diff --git a/kcontrol/kcontrol/kinfocenter.desktop b/kcontrol/kcontrol/kinfocenter.desktop
new file mode 100644
index 000000000..cd3e27f0a
--- /dev/null
+++ b/kcontrol/kcontrol/kinfocenter.desktop
@@ -0,0 +1,109 @@
+[Desktop Entry]
+Exec=kinfocenter -caption "%c" %i %m
+Icon=hwinfo
+Type=Application
+DocPath=kinfocenter/index.html
+X-KDE-StartupNotify=true
+OnlyShowIn=KDE;
+
+Name=KInfoCenter
+Name[af]=Inligting Sentrum
+Name[be]=Цэнтр інфармацыі
+Name[bn]=কে-ইনফো-সেন্টার
+Name[csb]=Centróm wëdowiédzë
+Name[de]=Infozentrum
+Name[el]=Κέντρο πληροφοριών
+Name[et]=KDE infokeskus
+Name[he]=מרכז המידע
+Name[ja]=インフォセンター
+Name[mk]=КИнфоцентар
+Name[nds]=KDE-Infozentrum
+Name[ne]=के सूचना केन्द्र
+Name[pa]=ਜਾਣਕਾਰੀ ਕੇਂਦਰ
+Name[pl]=Centrum informacyjne
+Name[pt_BR]=Centro de Informações do KDE
+Name[ro]=Centrul de informații KDE
+Name[rw]=K-AmakuruHagati
+Name[sk]=KDE Informačné centrum
+Name[sv]=Informationscentralen
+Name[ta]=கேதகவல் மையம்
+Name[te]=కెఇన్ఫొసెంటర్
+Name[tg]=КМаркази иттилоот
+Name[th]=ศูนย์ข้อมูล K
+Name[tr]=KDE Bilgi Merkezi
+Name[uz]=Maʼlumot markazi
+Name[uz@cyrillic]=Маълумот маркази
+Name[vi]=Trung tâm Thông tin KDE
+Name[wa]=Cinte d' informåcion KInfo
+GenericName=Info Center
+GenericName[af]=Inligting Sentrum
+GenericName[be]=Цэнтр інфармацыі
+GenericName[bg]=Информационен център
+GenericName[bn]=তথ্য কেন্দ্র
+GenericName[br]=Kreizenn Titouroù
+GenericName[bs]=Info centar
+GenericName[ca]=Centre d'informació
+GenericName[cs]=Informační centrum
+GenericName[csb]=Centróm wëdowiédzë
+GenericName[cy]=Canolfan Gwybodaeth
+GenericName[da]=Infocenter
+GenericName[de]=Infozentrum
+GenericName[el]=Κέντρο πληροφοριών
+GenericName[en_GB]=Info Centre
+GenericName[eo]=Infocentro
+GenericName[es]=Centro de información
+GenericName[et]=Infokeskus
+GenericName[eu]=Info gunea
+GenericName[fa]=مرکز اطلاعات
+GenericName[fi]=Infokeskus
+GenericName[fr]=Centre d'informations
+GenericName[fy]=Ynformaasjesintrum
+GenericName[ga]=Lárionad Eolais
+GenericName[gl]=Centro de Información
+GenericName[he]=מרכז המידע
+GenericName[hr]=Info središte
+GenericName[hu]=Rendszerinformáció
+GenericName[is]=Upplýsingaborð
+GenericName[it]=Centro informazioni
+GenericName[ja]=インフォセンター
+GenericName[ka]=საინფორმაციო ცენტრი
+GenericName[kk]=Мәлімет орталығы
+GenericName[km]=មជ្ឈមណ្ឌល​ព័ត៌មាន
+GenericName[ko]=정보 센터
+GenericName[lt]=Info centras
+GenericName[mk]=Информативен центар
+GenericName[ms]=Pusat Maklumat
+GenericName[nb]=KDEs informasjonssenter
+GenericName[nds]=Infozentrum
+GenericName[ne]=सूचना केन्द्र
+GenericName[nl]=Informatiecentrum
+GenericName[nn]=KDEs informasjonssenter
+GenericName[pa]=ਜਾਣਕਾਰੀ ਕੇਂਦਰ
+GenericName[pl]=Centrum informacyjne
+GenericName[pt]=Centro de Informações
+GenericName[pt_BR]=Centro de Informações
+GenericName[ro]=Centru de informații
+GenericName[ru]=Центр информации
+GenericName[rw]=Amakuru Hagati
+GenericName[se]=Diehtoguovddáš
+GenericName[sk]=Informačné centrum
+GenericName[sl]=Informacijsko središče
+GenericName[sr]=Информациони центар
+GenericName[sr@Latn]=Informacioni centar
+GenericName[sv]=Informationscentralen
+GenericName[ta]=தகவல் மையம்
+GenericName[te]=సమాచార కేంద్రం
+GenericName[tg]=Маркази иттилоот
+GenericName[th]=ศูนย์ข้อมูล
+GenericName[tr]=Bilgi Merkezi
+GenericName[tt]=Beleşmä Üzäge
+GenericName[uk]=Центр інформації
+GenericName[uz]=Maʼlumot markazi
+GenericName[uz@cyrillic]=Маълумот маркази
+GenericName[vi]=Trung tâm Thông tin
+GenericName[wa]=Cinte di contrôle
+GenericName[zh_CN]=信息中心
+GenericName[zh_TW]=資訊中心
+
+X-DCOP-ServiceType=Unique
+Categories=Qt;KDE;System;
diff --git a/kcontrol/kcontrol/kinfocenterui.rc b/kcontrol/kcontrol/kinfocenterui.rc
new file mode 100644
index 000000000..92867beb3
--- /dev/null
+++ b/kcontrol/kcontrol/kinfocenterui.rc
@@ -0,0 +1,20 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="kcontrol" version="2">
+<MenuBar>
+ <Menu name="view"><text>&amp;View</text>
+ <Menu name="view_mode"><text>&amp;Mode</text>
+ <Action name="activate_iconview"/>
+ <Action name="activate_treeview"/>
+ </Menu>
+ <Menu name="view_iconsize"><text>Icon &amp;Size</text>
+ <Action name="activate_smallicons"/>
+ <Action name="activate_mediumicons"/>
+ <Action name="activate_largeicons"/>
+ <Action name="activate_hugeicons"/>
+ </Menu>
+ </Menu>
+ <Menu name="help">
+ <Action name="help_about_module" append="about_merge"/>
+ </Menu>
+</MenuBar>
+</kpartgui>
diff --git a/kcontrol/kcontrol/main.cpp b/kcontrol/kcontrol/main.cpp
new file mode 100644
index 000000000..90e63583c
--- /dev/null
+++ b/kcontrol/kcontrol/main.cpp
@@ -0,0 +1,153 @@
+/*
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+
+/**
+ * Howto debug:
+ * start "kcontrol --nofork" in a debugger.
+ *
+ * If you want to test with command line arguments you need
+ * -after you have started kcontrol in the debugger-
+ * open another shell and run kcontrol with the desired
+ * command line arguments.
+ *
+ * The command line arguments will be passed to the version of
+ * kcontrol in the debugger via DCOP and will cause a call
+ * to newInstance().
+ */
+
+#include <qpaintdevicemetrics.h>
+
+#include <kcmdlineargs.h>
+#include <dcopclient.h>
+#include <kaboutdata.h>
+#include <kglobalsettings.h>
+#include <kconfig.h>
+#include <kdebug.h>
+
+#include "main.h"
+#include "main.moc"
+#include "toplevel.h"
+#include "global.h"
+#include "moduleIface.h"
+
+#include "version.h"
+
+KControlApp::KControlApp()
+ : KUniqueApplication()
+ , toplevel(0)
+{
+ toplevel = new TopLevel();
+
+ setMainWidget(toplevel);
+ KGlobal::setActiveInstance(this);
+
+ // KUniqueApplication does dcop regitration for us
+ ModuleIface *modIface = new ModuleIface(toplevel, "moduleIface");
+
+ connect (modIface, SIGNAL(helpClicked()), toplevel, SLOT(slotHelpRequest()));
+ connect (modIface, SIGNAL(handbookClicked()), toplevel, SLOT(slotHandbookRequest()));
+
+ QRect desk = KGlobalSettings::desktopGeometry(toplevel);
+ KConfig *config = KGlobal::config();
+ config->setGroup("General");
+ // Initial size is:
+ // never bigger than workspace as reported by desk
+ // 940x700 on 96 dpi, 12 pt font
+ // 800x600 on 72 dpi, 12 pt font
+ // --> 368 + 6 x dpiX, 312 + 4 x dpiY
+ // Adjusted for font size
+ QPaintDeviceMetrics pdm(toplevel);
+ int fontSize = toplevel->fontInfo().pointSize();
+ if (fontSize == 0)
+ fontSize = (toplevel->fontInfo().pixelSize() * 72) / pdm.logicalDpiX();
+ int x = config->readNumEntry(QString::fromLatin1("InitialWidth %1").arg(desk.width()),
+ QMIN( desk.width(), 368 + (6*pdm.logicalDpiX()*fontSize)/12 ) );
+ int y = config->readNumEntry(QString::fromLatin1("InitialHeight %1").arg(desk.height()),
+ QMIN( desk.height(), 312 + (4*pdm.logicalDpiX()*fontSize)/12 ) );
+ toplevel->resize(x,y);
+}
+
+KControlApp::~KControlApp()
+{
+ if (toplevel)
+ {
+ KConfig *config = KGlobal::config();
+ config->setGroup("General");
+ QWidget *desk = QApplication::desktop();
+ config->writeEntry(QString::fromLatin1("InitialWidth %1").arg(desk->width()), toplevel->width());
+ config->writeEntry(QString::fromLatin1("InitialHeight %1").arg(desk->height()), toplevel->height());
+ config->sync();
+ }
+ delete toplevel;
+}
+
+extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
+{
+ KLocale::setMainCatalogue("kcontrol");
+ KAboutData aboutKControl( "kcontrol", I18N_NOOP("KDE Control Center"),
+ KCONTROL_VERSION, I18N_NOOP("The KDE Control Center"), KAboutData::License_GPL,
+ I18N_NOOP("(c) 1998-2004, The KDE Control Center Developers"));
+
+ KAboutData aboutKInfoCenter( "kinfocenter", I18N_NOOP("KDE Info Center"),
+ KCONTROL_VERSION, I18N_NOOP("The KDE Info Center"), KAboutData::License_GPL,
+ I18N_NOOP("(c) 1998-2004, The KDE Control Center Developers"));
+
+ QCString argv_0 = argv[0];
+ KAboutData *aboutData;
+ if (argv_0.right(11) == "kinfocenter")
+ {
+ aboutData = &aboutKInfoCenter;
+ KCGlobal::setIsInfoCenter(true);
+ kdDebug(1208) << "Running as KInfoCenter!\n" << endl;
+ }
+ else
+ {
+ aboutData = &aboutKControl;
+ KCGlobal::setIsInfoCenter(false);
+ }
+
+
+ if (argv_0.right(11) == "kinfocenter")
+ aboutData->addAuthor("Helge Deller", I18N_NOOP("Current Maintainer"), "deller@kde.org");
+ else
+ aboutData->addAuthor("Daniel Molkentin", I18N_NOOP("Current Maintainer"), "molkentin@kde.org");
+
+ aboutData->addAuthor("Matthias Hoelzer-Kluepfel",0, "hoelzer@kde.org");
+ aboutData->addAuthor("Matthias Elter",0, "elter@kde.org");
+ aboutData->addAuthor("Matthias Ettrich",0, "ettrich@kde.org");
+ aboutData->addAuthor("Waldo Bastian",0, "bastian@kde.org");
+
+ KCmdLineArgs::init( argc, argv, aboutData );
+ KUniqueApplication::addCmdLineOptions();
+
+ KCGlobal::init();
+
+ if (!KControlApp::start()) {
+ kdDebug(1208) << "kcontrol is already running!\n" << endl;
+ return (0);
+ }
+
+ KControlApp app;
+
+ // show the whole stuff
+ app.mainWidget()->show();
+
+ return app.exec();
+}
diff --git a/kcontrol/kcontrol/main.h b/kcontrol/kcontrol/main.h
new file mode 100644
index 000000000..783e10001
--- /dev/null
+++ b/kcontrol/kcontrol/main.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __main_h__
+#define __main_h__
+
+#include <kuniqueapplication.h>
+
+class TopLevel;
+
+class KControlApp : public KUniqueApplication
+{
+ Q_OBJECT
+
+public:
+ KControlApp();
+ virtual ~KControlApp();
+
+private:
+
+ TopLevel *toplevel;
+
+};
+
+#endif
diff --git a/kcontrol/kcontrol/moduleIface.cpp b/kcontrol/kcontrol/moduleIface.cpp
new file mode 100644
index 000000000..b58f06c26
--- /dev/null
+++ b/kcontrol/kcontrol/moduleIface.cpp
@@ -0,0 +1,58 @@
+/*
+ Copyright (c) 2001 Daniel Molkentin <molkentin@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include "moduleIface.h"
+#include "moduleIface.moc"
+
+#include <kdebug.h>
+#include <kconfig.h>
+
+ModuleIface::ModuleIface(QObject *parent, const char *name)
+ : QObject(parent, name), DCOPObject(name) {
+
+ _parent = static_cast<QWidget *>(parent);
+
+}
+
+ModuleIface::~ModuleIface() {
+}
+
+QFont ModuleIface::getFont() {
+ return _parent->font();
+}
+
+QPalette ModuleIface::getPalette(){
+ kdDebug(1208) << "Returned Palette" << endl;
+ return _parent->palette();
+}
+
+QString ModuleIface::getStyle() {
+ KConfig config( "kdeglobals" );
+ config.setGroup( "General" );
+ return config.readEntry("widgetStyle");
+}
+
+void ModuleIface::invokeHandbook() {
+ emit handbookClicked();
+}
+
+void ModuleIface::invokeHelp() {
+ emit helpClicked();
+}
+
diff --git a/kcontrol/kcontrol/moduleIface.h b/kcontrol/kcontrol/moduleIface.h
new file mode 100644
index 000000000..8c034d5cd
--- /dev/null
+++ b/kcontrol/kcontrol/moduleIface.h
@@ -0,0 +1,54 @@
+/*
+ Copyright (c) 2001 Daniel Molkentin <molkentin@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __moduleIface_h__
+#define __moduleIface_h__
+
+#include <dcopobject.h>
+
+#include <qfont.h>
+#include <qpalette.h>
+#include <qwidget.h>
+
+class ModuleIface : public QObject, public DCOPObject {
+
+Q_OBJECT
+K_DCOP
+
+public:
+ ModuleIface(QObject *parent, const char *name);
+ ~ModuleIface();
+
+k_dcop:
+ QFont getFont();
+ QPalette getPalette();
+ QString getStyle();
+ void invokeHandbook();
+ void invokeHelp();
+
+signals:
+ void handbookClicked();
+ void helpClicked();
+
+private:
+ QWidget *_parent;
+
+};
+
+#endif
diff --git a/kcontrol/kcontrol/moduleiconview.cpp b/kcontrol/kcontrol/moduleiconview.cpp
new file mode 100644
index 000000000..041e6709c
--- /dev/null
+++ b/kcontrol/kcontrol/moduleiconview.cpp
@@ -0,0 +1,170 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+ Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <qheader.h>
+#include <qcursor.h>
+
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kservicegroup.h>
+#include <kiconloader.h>
+
+#include <kdebug.h>
+
+#include "moduleiconview.h"
+#include "moduleiconview.moc"
+#include "modules.h"
+#include "global.h"
+
+
+ModuleIconView::ModuleIconView(ConfigModuleList *list, QWidget * parent, const char * name)
+ : KListView(parent, name)
+ , _path(KCGlobal::baseGroup())
+ , _modules(list)
+{
+ setSorting(1, true);
+ addColumn(QString::null);
+
+ // Needed to enforce a cut of the items label rather than
+ // showing a horizontal scrollbar
+ setResizeMode(LastColumn);
+
+ header()->hide();
+
+ // This is intentionally _not_ connected with executed(), since
+ // honoring doubleclick doesn't make any sense here (changed by
+ // large user demand)
+ connect(this, SIGNAL(clicked(QListViewItem*)),
+ this, SLOT(slotItemSelected(QListViewItem*)));
+}
+
+void ModuleIconView::makeSelected(ConfigModule *m)
+{
+ if (!m) return;
+
+ for (QListViewItem *i = firstChild(); i; i = i->nextSibling())
+ {
+ if(static_cast<ModuleIconItem*>(i)->module() == m)
+ {
+ setSelected(i, true);
+ break;
+ }
+ }
+}
+
+void ModuleIconView::makeVisible(ConfigModule *m)
+{
+ if (!m) return;
+ QString tmp = _modules->findModule(m);
+ if (tmp.isEmpty())
+ return;
+
+ _path = tmp;
+ fill();
+}
+
+void ModuleIconView::fill()
+{
+ clear();
+
+ QPixmap icon;
+ // add our "up" icon if we aren't top level
+ if (_path != KCGlobal::baseGroup())
+ {
+ icon = loadIcon( "back" );
+ // go-back node
+ ModuleIconItem *i = new ModuleIconItem(this, i18n("Back"), icon);
+ i->setOrderNo(0);
+ int last_slash = _path.findRev('/', -2);
+ if (last_slash == -1)
+ i->setTag(QString::null);
+ else
+ i->setTag(_path.left(last_slash+1));
+ }
+
+ int c = 0;
+ QStringList submenus = _modules->submenus(_path);
+ for (QStringList::Iterator it = submenus.begin(); it != submenus.end(); ++it )
+ {
+ QString path = (*it);
+
+ KServiceGroup::Ptr group = KServiceGroup::group(path);
+ if (!group || !group->isValid())
+ continue;
+
+ icon = loadIcon( group->icon() );
+
+ ModuleIconItem *i = new ModuleIconItem(this, group->caption(), icon);
+ i->setTag(path);
+ i->setOrderNo(++c);
+ }
+
+ c = 0;
+ QPtrList<ConfigModule> moduleList = _modules->modules(_path);
+ for (ConfigModule *module=moduleList.first(); module != 0; module=moduleList.next())
+ {
+ icon = loadIcon( module->icon() );
+
+ ModuleIconItem *i = new ModuleIconItem(this, module->moduleName(), icon, module);
+ i->setOrderNo(++c);
+ }
+}
+
+void ModuleIconView::slotItemSelected(QListViewItem* item)
+{
+ QApplication::restoreOverrideCursor();
+ if (!item) return;
+
+ if (static_cast<ModuleIconItem*>(item)->module())
+ {
+ emit moduleSelected(static_cast<ModuleIconItem*>(item)->module());
+ }
+ else
+ {
+ _path = static_cast<ModuleIconItem*>(item)->tag();
+ fill();
+ setCurrentItem(firstChild());
+ }
+}
+
+void ModuleIconView::keyPressEvent(QKeyEvent *e)
+{
+ if( e->key() == Key_Return
+ || e->key() == Key_Enter
+ || e->key() == Key_Space)
+ {
+ if (currentItem())
+ slotItemSelected(currentItem());
+ }
+ else
+ {
+ KListView::keyPressEvent(e);
+ }
+}
+
+QPixmap ModuleIconView::loadIcon( const QString &name )
+{
+ QPixmap icon = DesktopIcon( name, KCGlobal::iconSize() );
+
+ if(icon.isNull())
+ icon = DesktopIcon( "folder", KCGlobal::iconSize() );
+
+ return icon;
+}
diff --git a/kcontrol/kcontrol/moduleiconview.h b/kcontrol/kcontrol/moduleiconview.h
new file mode 100644
index 000000000..4f38a1cad
--- /dev/null
+++ b/kcontrol/kcontrol/moduleiconview.h
@@ -0,0 +1,86 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __moduleiconview_h__
+#define __moduleiconview_h__
+
+#include <klistview.h>
+
+class ConfigModule;
+class ConfigModuleList;
+
+class ModuleIconItem : public KListViewItem
+{
+
+public:
+ ModuleIconItem(QListView *parent, const QString& text, const QPixmap& pm, ConfigModule *m = 0)
+ : KListViewItem(parent, text)
+ , _tag(QString::null)
+ , _module(m)
+ {
+ setPixmap(0, pm);
+ }
+
+ void setConfigModule(ConfigModule* m) { _module = m; }
+ void setTag(const QString& t) { _tag = t; }
+ void setOrderNo(int order)
+ {
+ QString s;
+ setText(1, s.sprintf( "%02d", order ) );
+ }
+
+ ConfigModule* module() { return _module; }
+ QString tag() { return _tag; }
+
+
+private:
+ QString _tag;
+ ConfigModule *_module;
+};
+
+class ModuleIconView : public KListView
+{
+ Q_OBJECT
+
+public:
+ ModuleIconView(ConfigModuleList *list, QWidget * parent = 0, const char * name = 0);
+
+ void makeSelected(ConfigModule* module);
+ void makeVisible(ConfigModule *module);
+ void fill();
+
+signals:
+ void moduleSelected(ConfigModule*);
+
+protected slots:
+ void slotItemSelected(QListViewItem*);
+
+protected:
+ void keyPressEvent(QKeyEvent *);
+ QPixmap loadIcon( const QString &name );
+
+private:
+ QString _path;
+ ConfigModuleList *_modules;
+
+};
+
+
+
+#endif
diff --git a/kcontrol/kcontrol/modulemenu.cpp b/kcontrol/kcontrol/modulemenu.cpp
new file mode 100644
index 000000000..02becb29a
--- /dev/null
+++ b/kcontrol/kcontrol/modulemenu.cpp
@@ -0,0 +1,105 @@
+this file is currently not used.
+this message breaks compilation.
+that is intentional :-]
+
+/*
+ Copyright (c) 2000 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+
+#include <qheader.h>
+#include <qstring.h>
+#include <qptrlist.h>
+#include <qpoint.h>
+#include <qcursor.h>
+
+#include <klocale.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <kiconloader.h>
+#include <kservicegroup.h>
+#include <kdebug.h>
+
+#include "modulemenu.h"
+#include "modulemenu.moc"
+#include "modules.h"
+#include "global.h"
+
+
+ModuleMenu::ModuleMenu(ConfigModuleList *list, QWidget * parent, const char * name)
+ : KPopupMenu(parent, name)
+ , _modules(list)
+{
+ // use large id's to start with...
+ id = 10000;
+
+ fill(this, KCGlobal::baseGroup());
+
+ connect(this, SIGNAL(activated(int)), this, SLOT(moduleSelected(int)));
+}
+
+void ModuleMenu::fill(KPopupMenu *parentMenu, const QString &parentPath)
+{
+ QStringList subMenus = _modules->submenus(parentPath);
+ for(QStringList::ConstIterator it = subMenus.begin();
+ it != subMenus.end(); ++it)
+ {
+ QString path = *it;
+ KServiceGroup::Ptr group = KServiceGroup::group(path);
+ if (!group)
+ continue;
+
+ // create new menu
+ KPopupMenu *menu = new KPopupMenu(parentMenu);
+ connect(menu, SIGNAL(activated(int)), this, SLOT(moduleSelected(int)));
+
+ // Item names may contain ampersands. To avoid them being converted to
+ // accelators, replace them with two ampersands.
+ QString name = group->caption();
+ name.replace("&", "&&");
+
+ parentMenu->insertItem(KGlobal::iconLoader()->loadIcon(group->icon(), KIcon::Desktop, KIcon::SizeSmall)
+ , name, menu);
+
+ fill(menu, path);
+ }
+
+ ConfigModule *module;
+ QPtrList<ConfigModule> moduleList = _modules->modules(parentPath);
+ for (module=moduleList.first(); module != 0; module=moduleList.next())
+ {
+ // Item names may contain ampersands. To avoid them being converted to
+ // accelators, replace them with two ampersands.
+ QString name = module->moduleName();
+ name.replace("&", "&&");
+
+ int realid = parentMenu->insertItem(KGlobal::iconLoader()->loadIcon(module->icon(), KIcon::Desktop, KIcon::SizeSmall)
+ , name, id);
+ _moduleDict.insert(realid, module);
+
+ id++;
+ }
+
+}
+
+void ModuleMenu::moduleSelected(int id)
+{
+ kdDebug(1208) << "Item " << id << " selected" << endl;
+ ConfigModule *module = _moduleDict[id];
+ if (module)
+ emit moduleActivated(module);
+}
diff --git a/kcontrol/kcontrol/modulemenu.h b/kcontrol/kcontrol/modulemenu.h
new file mode 100644
index 000000000..b08140bfc
--- /dev/null
+++ b/kcontrol/kcontrol/modulemenu.h
@@ -0,0 +1,65 @@
+this file is currently not used.
+this message breaks compilation.
+that is intentional :-]
+
+/*
+ Copyright (c) 2000 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __modulemenu_h__
+#define __modulemenu_h__
+
+
+#include <qptrlist.h>
+#include <qstringlist.h>
+#include <qintdict.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qdict.h>
+
+#include <kpopupmenu.h>
+
+
+class ConfigModule;
+class ConfigModuleList;
+
+
+class ModuleMenu : public KPopupMenu
+{
+ Q_OBJECT
+
+public:
+ ModuleMenu(ConfigModuleList *list, QWidget * parent = 0, const char * name = 0);
+
+signals:
+ void moduleActivated(ConfigModule*);
+
+private slots:
+ void moduleSelected(int id);
+
+protected:
+ void fill(KPopupMenu *parentMenu, const QString &parentPath);
+
+private:
+ int id;
+
+ ConfigModuleList *_modules;
+ QIntDict<ConfigModule> _moduleDict;
+};
+
+
+#endif
diff --git a/kcontrol/kcontrol/modules.cpp b/kcontrol/kcontrol/modules.cpp
new file mode 100644
index 000000000..b6d8a2693
--- /dev/null
+++ b/kcontrol/kcontrol/modules.cpp
@@ -0,0 +1,345 @@
+/*
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <unistd.h>
+#include <sys/types.h>
+
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qvbox.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kservicegroup.h>
+#include <kprocess.h>
+#include <qxembed.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+
+
+#include "modules.h"
+#include "modules.moc"
+#include "global.h"
+#include "proxywidget.h"
+#include <kcmoduleloader.h>
+#include "kcrootonly.h"
+
+#include <X11/Xlib.h>
+
+
+template class QPtrList<ConfigModule>;
+
+
+ConfigModule::ConfigModule(const KService::Ptr &s)
+ : KCModuleInfo(s), _changed(false), _module(0), _embedWidget(0),
+ _rootProcess(0), _embedLayout(0), _embedFrame(0), _embedStack(0)
+{
+}
+
+ConfigModule::~ConfigModule()
+{
+ deleteClient();
+}
+
+ProxyWidget *ConfigModule::module()
+{
+ if (_module)
+ return _module;
+
+ bool run_as_root = needsRootPrivileges() && (getuid() != 0);
+
+ KCModule *modWidget = 0;
+
+ if (run_as_root && isHiddenByDefault())
+ modWidget = new KCRootOnly(0, "root_only");
+ else
+ modWidget = KCModuleLoader::loadModule(*this);
+
+ if (modWidget)
+ {
+
+ _module = new ProxyWidget(modWidget, moduleName(), "", run_as_root);
+ connect(_module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
+ connect(_module, SIGNAL(closed()), this, SLOT(clientClosed()));
+ connect(_module, SIGNAL(handbookRequest()), this, SIGNAL(handbookRequest()));
+ connect(_module, SIGNAL(helpRequest()), this, SIGNAL(helpRequest()));
+ connect(_module, SIGNAL(runAsRoot()), this, SLOT(runAsRoot()));
+
+ return _module;
+ }
+
+ return 0;
+}
+
+void ConfigModule::deleteClient()
+{
+ if (_embedWidget)
+ XKillClient(qt_xdisplay(), _embedWidget->embeddedWinId());
+
+ delete _rootProcess;
+ _rootProcess = 0;
+
+ delete _embedWidget;
+ _embedWidget = 0;
+ delete _embedStack;
+ _embedStack = 0;
+ delete _embedFrame;
+ _embedFrame = 0;
+ kapp->syncX();
+
+ if(_module)
+ _module->close(true);
+ _module = 0;
+
+ delete _embedLayout;
+ _embedLayout = 0;
+
+ KCModuleLoader::unloadModule(*this);
+ _changed = false;
+}
+
+void ConfigModule::clientClosed()
+{
+ deleteClient();
+
+ emit changed(this);
+ emit childClosed();
+}
+
+
+void ConfigModule::clientChanged(bool state)
+{
+ setChanged(state);
+ emit changed(this);
+}
+
+
+void ConfigModule::runAsRoot()
+{
+ if (!_module)
+ return;
+
+ delete _rootProcess;
+ delete _embedWidget;
+ delete _embedLayout;
+ delete _embedStack;
+
+ // create an embed widget that will embed the
+ // kcmshell running as root
+ _embedLayout = new QVBoxLayout(_module->parentWidget());
+ _embedFrame = new QVBox( _module->parentWidget() );
+ _embedFrame->setFrameStyle( QFrame::Box | QFrame::Raised );
+ QPalette pal( red );
+ pal.setColor( QColorGroup::Background,
+ _module->parentWidget()->colorGroup().background() );
+ _embedFrame->setPalette( pal );
+ _embedFrame->setLineWidth( 2 );
+ _embedFrame->setMidLineWidth( 2 );
+ _embedLayout->addWidget(_embedFrame,1);
+ // cannot reparent anything else inside QXEmbed, so put the busy label separately
+ _embedStack = new QWidgetStack(_embedFrame);
+ _embedWidget = new KControlEmbed(_embedStack);
+ _module->hide();
+ _embedFrame->show();
+ QLabel *_busy = new QLabel(i18n("<big>Loading...</big>"), _embedStack);
+ _busy->setAlignment(AlignCenter);
+ _busy->setTextFormat(RichText);
+ _busy->setGeometry(0,0, _module->width(), _module->height());
+ _busy->show();
+ _embedStack->raiseWidget(_busy);
+ connect(_embedWidget, SIGNAL( windowEmbedded(WId)), SLOT( embedded()));
+
+ // prepare the process to run the kcmshell
+ QString cmd = service()->exec().stripWhiteSpace();
+ bool kdeshell = false;
+ if (cmd.left(5) == "kdesu")
+ {
+ cmd = cmd.remove(0,5).stripWhiteSpace();
+ // remove all kdesu switches
+ while( cmd.length() > 1 && cmd[ 0 ] == '-' )
+ {
+ int pos = cmd.find( ' ' );
+ cmd = cmd.remove( 0, pos ).stripWhiteSpace();
+ }
+ }
+
+ if (cmd.left(8) == "kcmshell")
+ {
+ cmd = cmd.remove(0,8).stripWhiteSpace();
+ kdeshell = true;
+ }
+
+ // run the process
+ QString kdesu = KStandardDirs::findExe("kdesu");
+ if (!kdesu.isEmpty())
+ {
+ _rootProcess = new KProcess;
+ *_rootProcess << kdesu;
+ *_rootProcess << "--nonewdcop";
+ // We have to disable the keep-password feature because
+ // in that case the modules is started through kdesud and kdesu
+ // returns before the module is running and that doesn't work.
+ // We also don't have a way to close the module in that case.
+ *_rootProcess << "--n"; // Don't keep password.
+ if (kdeshell) {
+ *_rootProcess << QString("%1 %2 --embed %3 --lang %4").arg(locate("exe", "kcmshell")).arg(cmd).arg(_embedWidget->winId()).arg(KGlobal::locale()->language());
+ }
+ else {
+ *_rootProcess << QString("%1 --embed %2 --lang %3").arg(cmd).arg(_embedWidget->winId()).arg( KGlobal::locale()->language() );
+ }
+
+ connect(_rootProcess, SIGNAL(processExited(KProcess*)), this, SLOT(rootExited(KProcess*)));
+
+ if ( !_rootProcess->start(KProcess::NotifyOnExit) )
+ {
+ delete _rootProcess;
+ _rootProcess = 0L;
+ }
+
+ return;
+ }
+
+ // clean up in case of failure
+ delete _embedStack;
+ _embedStack = 0;
+ delete _embedFrame;
+ _embedWidget = 0;
+ delete _embedLayout;
+ _embedLayout = 0;
+ _module->show();
+}
+
+
+void ConfigModule::rootExited(KProcess *)
+{
+ if (_embedWidget->embeddedWinId())
+ XDestroyWindow(qt_xdisplay(), _embedWidget->embeddedWinId());
+
+ delete _embedWidget;
+ _embedWidget = 0;
+
+ delete _rootProcess;
+ _rootProcess = 0;
+
+ delete _embedLayout;
+ _embedLayout = 0;
+
+ delete _module;
+ _module=0;
+
+ _changed = false;
+ emit changed(this);
+ emit childClosed();
+}
+
+void ConfigModule::embedded()
+{
+ _embedStack->raiseWidget(_embedWidget); // put it above the busy label
+}
+
+const KAboutData *ConfigModule::aboutData() const
+{
+ if (!_module) return 0;
+ return _module->aboutData();
+}
+
+
+ConfigModuleList::ConfigModuleList()
+{
+ setAutoDelete(true);
+ subMenus.setAutoDelete(true);
+}
+
+void ConfigModuleList::readDesktopEntries()
+{
+ readDesktopEntriesRecursive( KCGlobal::baseGroup() );
+}
+
+bool ConfigModuleList::readDesktopEntriesRecursive(const QString &path)
+{
+
+ KServiceGroup::Ptr group = KServiceGroup::group(path);
+
+ if (!group || !group->isValid()) return false;
+
+ KServiceGroup::List list = group->entries(true, true);
+
+ if( list.isEmpty() )
+ return false;
+
+ Menu *menu = new Menu;
+ subMenus.insert(path, menu);
+
+ for( KServiceGroup::List::ConstIterator it = list.begin();
+ it != list.end(); it++)
+ {
+ KSycocaEntry *p = (*it);
+ if (p->isType(KST_KService))
+ {
+ KService *s = static_cast<KService*>(p);
+ if (!kapp->authorizeControlModule(s->menuId()))
+ continue;
+
+ ConfigModule *module = new ConfigModule(s);
+ if (module->library().isEmpty())
+ {
+ delete module;
+ continue;
+ }
+
+ append(module);
+ menu->modules.append(module);
+ }
+ else if (p->isType(KST_KServiceGroup) &&
+ readDesktopEntriesRecursive(p->entryPath()) )
+ menu->submenus.append(p->entryPath());
+
+ }
+ return true;
+}
+
+QPtrList<ConfigModule> ConfigModuleList::modules(const QString &path)
+{
+ Menu *menu = subMenus.find(path);
+ if (menu)
+ return menu->modules;
+
+ return QPtrList<ConfigModule>();
+}
+
+QStringList ConfigModuleList::submenus(const QString &path)
+{
+ Menu *menu = subMenus.find(path);
+ if (menu)
+ return menu->submenus;
+
+ return QStringList();
+}
+
+QString ConfigModuleList::findModule(ConfigModule *module)
+{
+ QDictIterator<Menu> it(subMenus);
+ Menu *menu;
+ for(;(menu = it.current());++it)
+ {
+ if (menu->modules.containsRef(module))
+ return it.currentKey();
+ }
+ return QString::null;
+}
diff --git a/kcontrol/kcontrol/modules.h b/kcontrol/kcontrol/modules.h
new file mode 100644
index 000000000..f2364698d
--- /dev/null
+++ b/kcontrol/kcontrol/modules.h
@@ -0,0 +1,136 @@
+/*
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef MODULES_H
+#define MODULES_H
+
+#include <kcmoduleinfo.h>
+#include <qobject.h>
+#include <qdict.h>
+#include <qxembed.h>
+
+template<class ConfigModule> class QPtrList;
+class QStringList;
+class KAboutData;
+class KCModule;
+class ProxyWidget;
+class KProcess;
+class QXEmbed;
+class QVBoxLayout;
+class QVBox;
+class QWidgetStack;
+
+class ConfigModule : public QObject, public KCModuleInfo
+{
+ Q_OBJECT
+
+public:
+
+ ConfigModule(const KService::Ptr &s);
+ ~ConfigModule();
+
+ bool isChanged() { return _changed; };
+ void setChanged(bool changed) { _changed = changed; };
+
+ bool isActive() { return _module != 0; };
+ ProxyWidget *module();
+ const KAboutData *aboutData() const;
+
+
+public slots:
+
+ void deleteClient();
+
+
+private slots:
+
+ void clientClosed();
+ void clientChanged(bool state);
+ void runAsRoot();
+ void rootExited(KProcess *proc);
+ void embedded();
+
+
+signals:
+
+ void changed(ConfigModule *module);
+ void childClosed();
+ void handbookRequest();
+ void helpRequest();
+
+
+private:
+
+ bool _changed;
+ ProxyWidget *_module;
+ QXEmbed *_embedWidget;
+ KProcess *_rootProcess;
+ QVBoxLayout *_embedLayout;
+ QVBox *_embedFrame;
+ QWidgetStack *_embedStack;
+
+};
+
+class ConfigModuleList : public QPtrList<ConfigModule>
+{
+public:
+
+ ConfigModuleList();
+
+ void readDesktopEntries();
+ bool readDesktopEntriesRecursive(const QString &path);
+
+ /**
+ * Returns all submenus of the submenu identified by path
+ */
+ QPtrList<ConfigModule> modules(const QString &path);
+
+ /**
+ * Returns all modules of the submenu identified by path
+ */
+ QStringList submenus(const QString &path);
+
+ /**
+ * Returns the path of the submenu the module is in
+ */
+ QString findModule(ConfigModule *module);
+
+protected:
+
+ class Menu
+ {
+ public:
+ QPtrList<ConfigModule> modules;
+ QStringList submenus;
+ };
+
+ QDict<Menu> subMenus;
+};
+
+class KControlEmbed : public QXEmbed
+ {
+ Q_OBJECT
+ public:
+ KControlEmbed( QWidget* w ) : QXEmbed( w ) {}
+ virtual void windowChanged( WId w ) { if( w ) emit windowEmbedded( w ); }
+ signals:
+ void windowEmbedded( WId w );
+ };
+
+#endif
diff --git a/kcontrol/kcontrol/moduletreeview.cpp b/kcontrol/kcontrol/moduletreeview.cpp
new file mode 100644
index 000000000..f933cfcef
--- /dev/null
+++ b/kcontrol/kcontrol/moduletreeview.cpp
@@ -0,0 +1,377 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <qheader.h>
+#include <qimage.h>
+#include <qpainter.h>
+#include <qbitmap.h>
+
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kservicegroup.h>
+#include <kdebug.h>
+#include <qwhatsthis.h>
+#include <qbitmap.h>
+
+#include "moduletreeview.h"
+#include "moduletreeview.moc"
+#include "modules.h"
+#include "global.h"
+
+static QPixmap appIcon(const QString &iconName)
+{
+ QString path;
+ QPixmap normal = KGlobal::iconLoader()->loadIcon(iconName, KIcon::Small, 0, KIcon::DefaultState, &path, true);
+ // make sure they are not larger than KIcon::SizeSmall
+ if (normal.width() > KIcon::SizeSmall || normal.height() > KIcon::SizeSmall)
+ {
+ QImage tmp = normal.convertToImage();
+ tmp = tmp.smoothScale(KIcon::SizeSmall, KIcon::SizeSmall);
+ normal.convertFromImage(tmp);
+ }
+ return normal;
+}
+
+class ModuleTreeWhatsThis : public QWhatsThis
+{
+public:
+ ModuleTreeWhatsThis( ModuleTreeView* tree)
+ : QWhatsThis( tree ), treeView( tree ) {}
+ ~ModuleTreeWhatsThis(){};
+
+
+ QString text( const QPoint & p) {
+ ModuleTreeItem* i = (ModuleTreeItem*) treeView->itemAt( p );
+ if ( i && i->module() ) {
+ return i->module()->comment();
+ } else if ( i ) {
+ return i18n("The %1 configuration group. Click to open it.").arg( i->text(0) );
+ }
+ return i18n("This treeview displays all available control modules. Click on one of the modules to receive more detailed information.");
+ }
+
+private:
+ ModuleTreeView* treeView;
+};
+
+ModuleTreeView::ModuleTreeView(ConfigModuleList *list, QWidget * parent, const char * name)
+ : KListView(parent, name)
+ , _modules(list)
+{
+ addColumn(QString::null);
+ setColumnWidthMode (0, QListView::Maximum);
+ setAllColumnsShowFocus(true);
+ setResizeMode(QListView::AllColumns);
+ setRootIsDecorated(true);
+ setHScrollBarMode(AlwaysOff);
+ header()->hide();
+
+ new ModuleTreeWhatsThis( this );
+
+ connect(this, SIGNAL(clicked(QListViewItem*)),
+ this, SLOT(slotItemSelected(QListViewItem*)));
+}
+
+void ModuleTreeView::fill()
+{
+ clear();
+
+ QStringList subMenus = _modules->submenus(KCGlobal::baseGroup());
+ for(QStringList::ConstIterator it = subMenus.begin();
+ it != subMenus.end(); ++it)
+ {
+ QString path = *it;
+ ModuleTreeItem* menu = new ModuleTreeItem(this);
+ menu->setGroup(path);
+ fill(menu, path);
+ }
+
+ ConfigModule *module;
+ QPtrList<ConfigModule> moduleList = _modules->modules(KCGlobal::baseGroup());
+ for (module=moduleList.first(); module != 0; module=moduleList.next())
+ {
+ new ModuleTreeItem(this, module);
+ }
+}
+
+void ModuleTreeView::fill(ModuleTreeItem *parent, const QString &parentPath)
+{
+ QStringList subMenus = _modules->submenus(parentPath);
+ for(QStringList::ConstIterator it = subMenus.begin();
+ it != subMenus.end(); ++it)
+ {
+ QString path = *it;
+ ModuleTreeItem* menu = new ModuleTreeItem(parent);
+ menu->setGroup(path);
+ fill(menu, path);
+ }
+
+ ConfigModule *module;
+ QPtrList<ConfigModule> moduleList = _modules->modules(parentPath);
+ for (module=moduleList.first(); module != 0; module=moduleList.next())
+ {
+ new ModuleTreeItem(parent, module);
+ }
+}
+
+
+
+QSize ModuleTreeView::sizeHint() const
+{
+ return QListView::sizeHint().boundedTo(
+ QSize( fontMetrics().maxWidth()*35, QWIDGETSIZE_MAX) );
+}
+
+void ModuleTreeView::makeSelected(ConfigModule *module)
+{
+ ModuleTreeItem *item = static_cast<ModuleTreeItem*>(firstChild());
+
+ updateItem(item, module);
+}
+
+void ModuleTreeView::updateItem(ModuleTreeItem *item, ConfigModule *module)
+{
+ while (item)
+ {
+ if (item->childCount() != 0)
+ updateItem(static_cast<ModuleTreeItem*>(item->firstChild()), module);
+ if (item->module() == module)
+ {
+ setSelected(item, true);
+ break;
+ }
+ item = static_cast<ModuleTreeItem*>(item->nextSibling());
+ }
+}
+
+/*
+void ModuleTreeView::expandItem(QListViewItem *item, QPtrList<QListViewItem> *parentList)
+{
+ while (item)
+ {
+ setOpen(item, parentList->contains(item));
+
+ if (item->childCount() != 0)
+ expandItem(item->firstChild(), parentList);
+ item = item->nextSibling();
+ }
+}
+*/
+void ModuleTreeView::makeVisible(ConfigModule *module)
+{
+ QString path = _modules->findModule(module);
+ if (path.startsWith(KCGlobal::baseGroup()))
+ path = path.mid(KCGlobal::baseGroup().length());
+
+ QStringList groups = QStringList::split('/', path);
+
+ ModuleTreeItem *item = 0;
+ QStringList::ConstIterator it;
+ for (it=groups.begin(); it != groups.end(); ++it)
+ {
+ if (item)
+ item = static_cast<ModuleTreeItem*>(item->firstChild());
+ else
+ item = static_cast<ModuleTreeItem*>(firstChild());
+
+ while (item)
+ {
+ if (item->tag() == *it)
+ {
+ setOpen(item, true);
+ break;
+ }
+ item = static_cast<ModuleTreeItem*>(item->nextSibling());
+ }
+ if (!item)
+ break; // Not found (?)
+ }
+
+ // make the item visible
+ if (item)
+ ensureItemVisible(item);
+}
+
+void ModuleTreeView::slotItemSelected(QListViewItem* item)
+{
+ if (!item) return;
+
+ if (static_cast<ModuleTreeItem*>(item)->module())
+ {
+ emit moduleSelected(static_cast<ModuleTreeItem*>(item)->module());
+ return;
+ }
+ else
+ {
+ emit categorySelected(item);
+ }
+
+ setOpen(item, !item->isOpen());
+
+ /*
+ else
+ {
+ QPtrList<QListViewItem> parents;
+
+ QListViewItem* i = item;
+ while(i)
+ {
+ parents.append(i);
+ i = i->parent();
+ }
+
+ //int oy1 = item->itemPos();
+ //int oy2 = mapFromGlobal(QCursor::pos()).y();
+ //int offset = oy2 - oy1;
+
+ expandItem(firstChild(), &parents);
+
+ //int x =mapFromGlobal(QCursor::pos()).x();
+ //int y = item->itemPos() + offset;
+ //QCursor::setPos(mapToGlobal(QPoint(x, y)));
+ }
+ */
+}
+
+void ModuleTreeView::keyPressEvent(QKeyEvent *e)
+{
+ if (!currentItem()) return;
+
+ if(e->key() == Key_Return
+ || e->key() == Key_Enter
+ || e->key() == Key_Space)
+ {
+ //QCursor::setPos(mapToGlobal(QPoint(10, currentItem()->itemPos()+5)));
+ slotItemSelected(currentItem());
+ }
+ else
+ KListView::keyPressEvent(e);
+}
+
+
+ModuleTreeItem::ModuleTreeItem(QListViewItem *parent, ConfigModule *module)
+ : QListViewItem(parent)
+ , _module(module)
+ , _tag(QString::null)
+ , _maxChildIconWidth(0)
+{
+ if (_module)
+ {
+ setText(0, " " + module->moduleName());
+ _icon = module->icon();
+ setPixmap(0, appIcon(_icon));
+ }
+}
+
+ModuleTreeItem::ModuleTreeItem(QListView *parent, ConfigModule *module)
+ : QListViewItem(parent)
+ , _module(module)
+ , _tag(QString::null)
+ , _maxChildIconWidth(0)
+{
+ if (_module)
+ {
+ setText(0, " " + module->moduleName());
+ _icon = module->icon();
+ setPixmap(0, appIcon(_icon));
+ }
+}
+
+ModuleTreeItem::ModuleTreeItem(QListViewItem *parent, const QString& text)
+ : QListViewItem(parent, " " + text)
+ , _module(0)
+ , _tag(QString::null)
+ , _maxChildIconWidth(0)
+ {}
+
+ModuleTreeItem::ModuleTreeItem(QListView *parent, const QString& text)
+ : QListViewItem(parent, " " + text)
+ , _module(0)
+ , _tag(QString::null)
+ , _maxChildIconWidth(0)
+ {}
+
+void ModuleTreeItem::setPixmap(int column, const QPixmap& pm)
+{
+ if (!pm.isNull())
+ {
+ ModuleTreeItem* p = dynamic_cast<ModuleTreeItem*>(parent());
+ if (p)
+ p->regChildIconWidth(pm.width());
+ }
+
+ QListViewItem::setPixmap(column, pm);
+}
+
+void ModuleTreeItem::regChildIconWidth(int width)
+{
+ if (width > _maxChildIconWidth)
+ _maxChildIconWidth = width;
+}
+
+void ModuleTreeItem::paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align )
+{
+ if (!pixmap(0))
+ {
+ int offset = 0;
+ ModuleTreeItem* parentItem = dynamic_cast<ModuleTreeItem*>(parent());
+ if (parentItem)
+ {
+ offset = parentItem->maxChildIconWidth();
+ }
+
+ if (offset > 0)
+ {
+ QPixmap pixmap(offset, offset);
+ pixmap.fill(Qt::color0);
+ pixmap.setMask(pixmap.createHeuristicMask());
+ QBitmap mask( pixmap.size(), true );
+ pixmap.setMask( mask );
+ QListViewItem::setPixmap(0, pixmap);
+ }
+ }
+
+ QListViewItem::paintCell( p, cg, column, width, align );
+}
+
+
+void ModuleTreeItem::setGroup(const QString &path)
+{
+ KServiceGroup::Ptr group = KServiceGroup::group(path);
+ QString defName = path.left(path.length()-1);
+ int pos = defName.findRev('/');
+ if (pos >= 0)
+ defName = defName.mid(pos+1);
+ if (group && group->isValid())
+ {
+ _icon = group->icon();
+ setPixmap(0, appIcon(_icon));
+ setText(0, " " + group->caption());
+ setTag(defName);
+ setCaption(group->caption());
+ }
+ else
+ {
+ // Should not happen: Installation problem
+ // Let's try to fail softly.
+ setText(0, " " + defName);
+ setTag(defName);
+ }
+}
diff --git a/kcontrol/kcontrol/moduletreeview.h b/kcontrol/kcontrol/moduletreeview.h
new file mode 100644
index 000000000..ecdd2d938
--- /dev/null
+++ b/kcontrol/kcontrol/moduletreeview.h
@@ -0,0 +1,95 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __moduletreeview_h__
+#define __moduletreeview_h__
+
+#include <qpalette.h>
+#include <qptrlist.h>
+#include <qlistview.h>
+#include <klistview.h>
+#include <qdict.h>
+
+
+class ConfigModule;
+class ConfigModuleList;
+class QPainter;
+
+class ModuleTreeItem : public QListViewItem
+{
+
+public:
+ ModuleTreeItem(QListViewItem *parent, ConfigModule *module = 0);
+ ModuleTreeItem(QListViewItem *parent, const QString& text);
+ ModuleTreeItem(QListView *parent, ConfigModule *module = 0);
+ ModuleTreeItem(QListView *parent, const QString& text);
+
+ void setTag(const QString& tag) { _tag = tag; }
+ void setCaption(const QString& caption) { _caption = caption; }
+ void setModule(ConfigModule *m) { _module = m; }
+ QString tag() const { return _tag; };
+ QString caption() const { return _caption; };
+ QString icon() const { return _icon; };
+ ConfigModule *module() { return _module; };
+ void regChildIconWidth(int width);
+ int maxChildIconWidth() { return _maxChildIconWidth; }
+
+ void setPixmap(int column, const QPixmap& pm);
+ void setGroup(const QString &path);
+
+protected:
+ void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align );
+
+private:
+ ConfigModule *_module;
+ QString _tag;
+ QString _caption;
+ int _maxChildIconWidth;
+ QString _icon;
+};
+
+class ModuleTreeView : public KListView
+{
+ Q_OBJECT
+
+public:
+ ModuleTreeView(ConfigModuleList *list, QWidget * parent = 0, const char * name = 0);
+
+ void makeSelected(ConfigModule* module);
+ void makeVisible(ConfigModule *module);
+ void fill();
+ QSize sizeHint() const;
+
+signals:
+ void moduleSelected(ConfigModule*);
+ void categorySelected(QListViewItem*);
+
+protected slots:
+ void slotItemSelected(QListViewItem*);
+
+protected:
+ void updateItem(ModuleTreeItem *item, ConfigModule* module);
+ void keyPressEvent(QKeyEvent *);
+ void fill(ModuleTreeItem *parent, const QString &parentPath);
+
+private:
+ ConfigModuleList *_modules;
+};
+
+#endif
diff --git a/kcontrol/kcontrol/proxywidget.cpp b/kcontrol/kcontrol/proxywidget.cpp
new file mode 100644
index 000000000..6654bfe14
--- /dev/null
+++ b/kcontrol/kcontrol/proxywidget.cpp
@@ -0,0 +1,323 @@
+/*
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <unistd.h> // for getuid()
+
+#include <kpushbutton.h>
+#include <qlayout.h>
+#include <klocale.h>
+#include <kapplication.h>
+#include <kcmodule.h>
+#include <kseparator.h>
+#include <kdialog.h>
+#include <kstdguiitem.h>
+#include <dcopclient.h>
+
+#include <qwhatsthis.h>
+#include <qlabel.h>
+
+#include "global.h"
+#include "proxywidget.h"
+#include "proxywidget.moc"
+
+#include <kdebug.h>
+#include <qtimer.h>
+
+class WhatsThis : public QWhatsThis
+{
+public:
+ WhatsThis( ProxyWidget* parent )
+ : QWhatsThis( parent ), proxy( parent ) {}
+ ~WhatsThis(){};
+
+
+ QString text( const QPoint & ) {
+ if ( !proxy->quickHelp().isEmpty() )
+ return proxy->quickHelp();
+ else
+ return i18n("The currently loaded configuration module.");
+ }
+
+private:
+ ProxyWidget* proxy;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void setVisible(QPushButton *btn, bool vis)
+{
+ if (vis)
+ btn->show();
+ else
+ btn->hide();
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+class RootInfoWidget : public QLabel
+{
+public:
+ RootInfoWidget(QWidget *parent, const char *name);
+ void setRootMsg(const QString& s) { setText(s); }
+};
+
+RootInfoWidget::RootInfoWidget(QWidget *parent, const char *name = 0)
+ : QLabel(parent, name)
+{
+ setFrameShape(QFrame::Box);
+ setFrameShadow(QFrame::Raised);
+
+ setText(i18n("<b>Changes in this module require root access.</b><br>"
+ "Click the \"Administrator Mode\" button to "
+ "allow modifications in this module."));
+
+ QWhatsThis::add(this, i18n("This module requires special permissions, probably "
+ "for system-wide modifications; therefore, it is "
+ "required that you provide the root password to be "
+ "able to change the module's properties. If you "
+ "do not provide the password, the module will be "
+ "disabled."));
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ProxyView : public QScrollView
+{
+public:
+ ProxyView(KCModule *client, const QString& title, QWidget *parent, bool run_as_root, const char *name);
+
+private:
+ virtual void resizeEvent(QResizeEvent *);
+
+ QWidget *contentWidget;
+ KCModule *client;
+ bool scroll;
+};
+
+class ProxyContentWidget : public QWidget
+{
+public:
+ ProxyContentWidget( QWidget* parent ) : QWidget( parent ) {}
+ ~ProxyContentWidget(){}
+
+ // this should be really done by qscrollview in AutoOneFit mode!
+ QSize sizeHint() const { return minimumSizeHint(); }
+};
+
+
+ProxyView::ProxyView(KCModule *_client, const QString&, QWidget *parent, bool run_as_root, const char *name)
+ : QScrollView(parent, name), client(_client)
+{
+ setResizePolicy(QScrollView::AutoOneFit);
+ setFrameStyle( NoFrame );
+ contentWidget = new ProxyContentWidget( viewport() );
+
+ QVBoxLayout* vbox = new QVBoxLayout( contentWidget );
+
+ if (run_as_root && _client->useRootOnlyMsg()) // notify the user
+ {
+ RootInfoWidget *infoBox = new RootInfoWidget(contentWidget);
+ vbox->addWidget( infoBox );
+ QString msg = _client->rootOnlyMsg();
+ if (!msg.isEmpty())
+ infoBox->setRootMsg(msg);
+ vbox->setSpacing(KDialog::spacingHint());
+ }
+ client->reparent(contentWidget,0,QPoint(0,0),true);
+ vbox->addWidget( client );
+ vbox->activate(); // make sure we have a proper minimumSizeHint
+ addChild(contentWidget);
+}
+
+void ProxyView::resizeEvent(QResizeEvent *e)
+{
+ QScrollView::resizeEvent(e);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+ProxyWidget::ProxyWidget(KCModule *client, QString title, const char *name,
+ bool run_as_root)
+ : QWidget(0, name)
+ , _client(client)
+{
+ setCaption(title);
+
+ if (getuid()==0 ) {
+ // Make root modules look as similar as possible...
+ QCString replyType;
+ QByteArray replyData;
+
+ if (kapp->dcopClient()->call("kcontrol", "moduleIface", "getPalette()", QByteArray(),
+ replyType, replyData))
+ if ( replyType == "QPalette") {
+ QDataStream reply( replyData, IO_ReadOnly );
+ QPalette pal;
+ reply >> pal;
+ setPalette(pal);
+ }
+/* // Doesn't work ...
+ if (kapp->dcopClient()->call("kcontrol", "moduleIface", "getStyle()", QByteArray(),
+ replyType, replyData))
+ if ( replyType == "QString") {
+ QDataStream reply( replyData, IO_ReadOnly );
+ QString style;
+ reply >> style;
+ setStyle(style);
+ }
+*/
+ if (kapp->dcopClient()->call("kcontrol", "moduleIface", "getFont()", QByteArray(),
+ replyType, replyData))
+ if ( replyType == "QFont") {
+ QDataStream reply( replyData, IO_ReadOnly );
+ QFont font;
+ reply >> font;
+ setFont(font);
+ }
+ }
+
+ view = new ProxyView(client, title, this, run_as_root, "proxyview");
+ (void) new WhatsThis( this );
+
+ connect(_client, SIGNAL(changed(bool)), SLOT(clientChanged(bool)));
+ connect(_client, SIGNAL(quickHelpChanged()), SIGNAL(quickHelpChanged()));
+
+ _sep = new KSeparator(KSeparator::HLine, this);
+
+ _handbook= new KPushButton( KGuiItem(KStdGuiItem::help().text(),"contents"), this );
+ _default = new KPushButton( KStdGuiItem::defaults(), this );
+ _apply = new KPushButton( KStdGuiItem::apply(), this );
+ _reset = new KPushButton( KGuiItem( i18n( "&Reset" ), "undo" ), this );
+ _root = new KPushButton( KGuiItem(i18n( "&Administrator Mode" )), this );
+
+ bool mayModify = (!run_as_root || !_client->useRootOnlyMsg()) && !KCGlobal::isInfoCenter();
+
+ // only enable the requested buttons
+ int b = _client->buttons();
+ setVisible(_handbook, (b & KCModule::Help));
+ setVisible(_default, mayModify && (b & KCModule::Default));
+ setVisible(_apply, mayModify && (b & KCModule::Apply));
+ setVisible(_reset, mayModify && (b & KCModule::Apply));
+ setVisible(_root, run_as_root);
+
+ // disable initial buttons
+ _apply->setEnabled( false );
+ _reset->setEnabled( false );
+
+ connect(_handbook, SIGNAL(clicked()), SLOT(handbookClicked()));
+ connect(_default, SIGNAL(clicked()), SLOT(defaultClicked()));
+ connect(_apply, SIGNAL(clicked()), SLOT(applyClicked()));
+ connect(_reset, SIGNAL(clicked()), SLOT(resetClicked()));
+ connect(_root, SIGNAL(clicked()), SLOT(rootClicked()));
+
+ QVBoxLayout *top = new QVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+ top->addWidget(view);
+ top->addWidget(_sep);
+
+ QHBoxLayout *buttons = new QHBoxLayout(top, 4);
+ buttons->addWidget(_handbook);
+ buttons->addWidget(_default);
+ if (run_as_root)
+ {
+ buttons->addWidget(_root);
+ }
+
+ buttons->addStretch(1);
+ if (mayModify)
+ {
+ buttons->addWidget(_apply);
+ buttons->addWidget(_reset);
+ }
+
+ top->activate();
+}
+
+ProxyWidget::~ProxyWidget()
+{
+ delete _client;
+}
+
+QString ProxyWidget::quickHelp() const
+{
+ if (_client)
+ return _client->quickHelp();
+ else
+ return "";
+}
+
+void ProxyWidget::handbookClicked()
+{
+ if (getuid()!=0)
+ emit handbookRequest();
+ else
+ kapp->dcopClient()->send("kcontrol", "moduleIface", "invokeHandbook()", QByteArray());
+}
+
+void ProxyWidget::helpClicked()
+{
+ if (getuid()!=0)
+ emit helpRequest();
+ else
+ kapp->dcopClient()->send("kcontrol", "moduleIface", "invokeHelp()", QByteArray());
+}
+
+void ProxyWidget::defaultClicked()
+{
+ clientChanged(true);
+ _client->defaults();
+}
+
+void ProxyWidget::applyClicked()
+{
+ _client->save();
+ clientChanged(false);
+}
+
+void ProxyWidget::resetClicked()
+{
+ _client->load();
+ clientChanged(false);
+}
+
+void ProxyWidget::rootClicked()
+{
+ emit runAsRoot();
+}
+
+void ProxyWidget::clientChanged(bool state)
+{
+ _apply->setEnabled(state);
+ _reset->setEnabled(state);
+
+ // forward the signal
+ emit changed(state);
+}
+
+const KAboutData *ProxyWidget::aboutData() const
+{
+ return _client->aboutData();
+}
+
+// vim: sw=2 sts=2 et
diff --git a/kcontrol/kcontrol/proxywidget.h b/kcontrol/kcontrol/proxywidget.h
new file mode 100644
index 000000000..a06e571de
--- /dev/null
+++ b/kcontrol/kcontrol/proxywidget.h
@@ -0,0 +1,82 @@
+/*
+
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+
+
+#ifndef __PROXYWIDGET_H__
+#define __PROXYWIDGET_H__
+
+
+class QWidget;
+class QPushButton;
+class QFrame;
+
+class KCModule;
+class KAboutData;
+
+#include "dockcontainer.h"
+#include <qscrollview.h>
+
+class ProxyView;
+
+class ProxyWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+
+ ProxyWidget(KCModule *client, QString title, const char *name=0, bool run_as_root = false);
+ ~ProxyWidget();
+
+ QString quickHelp() const;
+ const KAboutData *aboutData() const;
+
+public slots:
+
+ void handbookClicked();
+ void helpClicked();
+ void defaultClicked();
+ void applyClicked();
+ void resetClicked();
+ void rootClicked();
+
+ void clientChanged(bool state);
+
+
+signals:
+
+ void closed();
+ void handbookRequest();
+ void helpRequest();
+ void changed(bool state);
+ void runAsRoot();
+ void quickHelpChanged();
+
+private:
+
+ QPushButton *_handbook, *_default, *_apply, *_reset, *_root;
+ QFrame *_sep;
+ KCModule *_client;
+ ProxyView *view;
+
+};
+
+
+#endif
diff --git a/kcontrol/kcontrol/searchwidget.cpp b/kcontrol/kcontrol/searchwidget.cpp
new file mode 100644
index 000000000..9701d2d20
--- /dev/null
+++ b/kcontrol/kcontrol/searchwidget.cpp
@@ -0,0 +1,205 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+ Copyright (c) 2004 Daniel Molkentin <molkentin@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qsortedlist.h>
+#include <qregexp.h>
+
+#include <klineedit.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <klistbox.h>
+
+#include "searchwidget.h"
+#include "searchwidget.moc"
+
+/**
+ * Helper class for sorting icon modules by name without losing the fileName ID
+ */
+class ModuleItem : public QListBoxPixmap
+{
+public:
+ ModuleItem(ConfigModule *module, QListBox * listbox = 0) :
+ QListBoxPixmap(listbox,
+ KGlobal::iconLoader()->loadIcon(module->icon(), KIcon::Desktop, KIcon::SizeSmall),
+ module->moduleName())
+ , m_module(module)
+ {
+
+ }
+
+ ConfigModule *module() const { return m_module; };
+
+protected:
+ ConfigModule *m_module;
+
+};
+
+KeywordListEntry::KeywordListEntry(const QString& name, ConfigModule* module)
+ : _name(name)
+{
+ if(module)
+ _modules.append(module);
+}
+
+void KeywordListEntry::addModule(ConfigModule* module)
+{
+ if(module)
+ _modules.append(module);
+}
+
+SearchWidget::SearchWidget(QWidget *parent , const char *name)
+ : QWidget(parent, name)
+{
+ _keywords.setAutoDelete(true);
+
+ QVBoxLayout * l = new QVBoxLayout(this, 0, 2);
+
+ // keyword list
+ _keyList = new KListBox(this);
+ QLabel *keyl = new QLabel(_keyList, i18n("&Keywords:"), this);
+
+ l->addWidget(keyl);
+ l->addWidget(_keyList);
+
+ // result list
+ _resultList = new KListBox(this);
+ QLabel *resultl = new QLabel(_resultList, i18n("&Results:"), this);
+
+ l->addWidget(resultl);
+ l->addWidget(_resultList);
+
+
+ connect(_keyList, SIGNAL(highlighted(const QString&)),
+ this, SLOT(slotKeywordSelected(const QString&)));
+
+ connect(_resultList, SIGNAL(selected(QListBoxItem*)),
+ this, SLOT(slotModuleSelected(QListBoxItem *)));
+ connect(_resultList, SIGNAL(clicked(QListBoxItem *)),
+ this, SLOT(slotModuleClicked(QListBoxItem *)));
+}
+
+void SearchWidget::populateKeywordList(ConfigModuleList *list)
+{
+ ConfigModule *module;
+
+ // loop through all control modules
+ for (module=list->first(); module != 0; module=list->next())
+ {
+ if (module->library().isEmpty())
+ continue;
+
+ // get the modules keyword list
+ QStringList kw = module->keywords();
+ kw << module->moduleName();
+
+ // loop through the keyword list to populate _keywords
+ for(QStringList::ConstIterator it = kw.begin(); it != kw.end(); ++it)
+ {
+ QString name = (*it).lower();
+ bool found = false;
+
+ // look if _keywords already has an entry for this keyword
+ for(KeywordListEntry *k = _keywords.first(); k != 0; k = _keywords.next())
+ {
+ // if there is an entry for this keyword, add the module to the entries modul list
+ if (k->moduleName() == name)
+ {
+ k->addModule(module);
+ found = true;
+ break;
+ }
+ }
+
+ // if there is entry for this keyword, create a new one
+ if (!found)
+ {
+ KeywordListEntry *k = new KeywordListEntry(name, module);
+ _keywords.append(k);
+ }
+ }
+ }
+ populateKeyListBox("*");
+}
+
+void SearchWidget::populateKeyListBox(const QString& s)
+{
+ _keyList->clear();
+
+ QStringList matches;
+
+ for(KeywordListEntry *k = _keywords.first(); k != 0; k = _keywords.next())
+ {
+ if ( QRegExp(s, false, true).search(k->moduleName()) >= 0)
+ matches.append(k->moduleName().stripWhiteSpace());
+ }
+
+ for(QStringList::ConstIterator it = matches.begin(); it != matches.end(); it++)
+ _keyList->insertItem(*it);
+
+ _keyList->sort();
+}
+
+void SearchWidget::populateResultListBox(const QString& s)
+{
+ _resultList->clear();
+
+ QPtrList<ModuleItem> results;
+
+ for(KeywordListEntry *k = _keywords.first(); k != 0; k = _keywords.next())
+ {
+ if (k->moduleName() == s)
+ {
+ QPtrList<ConfigModule> modules = k->modules();
+
+ for(ConfigModule *m = modules.first(); m != 0; m = modules.next())
+ new ModuleItem(m, _resultList);
+ }
+ }
+
+ _resultList->sort();
+}
+
+void SearchWidget::searchTextChanged(const QString & s)
+{
+ QString regexp = s;
+ regexp += "*";
+ populateKeyListBox(regexp);
+ if (_keyList->count()==1)
+ _keyList->setSelected(0,true);
+}
+
+void SearchWidget::slotKeywordSelected(const QString & s)
+{
+ populateResultListBox(s);
+}
+
+void SearchWidget::slotModuleSelected(QListBoxItem *item)
+{
+ if (item)
+ emit moduleSelected( static_cast<ModuleItem*>(item)->module() );
+}
+
+void SearchWidget::slotModuleClicked(QListBoxItem *item)
+{
+ if (item)
+ emit moduleSelected( static_cast<ModuleItem*>(item)->module() );
+}
diff --git a/kcontrol/kcontrol/searchwidget.h b/kcontrol/kcontrol/searchwidget.h
new file mode 100644
index 000000000..99aceb7e8
--- /dev/null
+++ b/kcontrol/kcontrol/searchwidget.h
@@ -0,0 +1,78 @@
+/*
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+ Copyright (c) 2004 Daniel Molkentin <molkentin@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __searchwidget_h__
+#define __searchwidget_h__
+
+#include <qwidget.h>
+#include <qptrlist.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+#include "modules.h"
+
+class KListBox;
+class KLineEdit;
+class QListBoxItem;
+
+class KeywordListEntry
+{
+ public:
+ KeywordListEntry(const QString& name, ConfigModule* module);
+
+ void addModule(ConfigModule* module);
+
+ QString moduleName() { return _name; }
+ QPtrList<ConfigModule> modules() { return _modules; }
+
+ private:
+ QString _name;
+ QPtrList<ConfigModule> _modules;
+
+};
+
+class SearchWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ SearchWidget(QWidget *parent, const char *name=0);
+
+ void populateKeywordList(ConfigModuleList *list);
+ void searchTextChanged(const QString &);
+
+signals:
+ void moduleSelected(ConfigModule *);
+
+protected:
+ void populateKeyListBox(const QString& regexp);
+ void populateResultListBox(const QString& keyword);
+
+protected slots:
+ void slotKeywordSelected(const QString &);
+ void slotModuleSelected(QListBoxItem *item);
+ void slotModuleClicked(QListBoxItem *item);
+
+private:
+ KListBox *_keyList, *_resultList;
+ QPtrList<KeywordListEntry> _keywords;
+};
+
+#endif
diff --git a/kcontrol/kcontrol/toplevel.cpp b/kcontrol/kcontrol/toplevel.cpp
new file mode 100644
index 000000000..c7a47e372
--- /dev/null
+++ b/kcontrol/kcontrol/toplevel.cpp
@@ -0,0 +1,526 @@
+/*
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+*/
+
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <kconfig.h>
+#include <kbugreport.h>
+#include <kaboutapplication.h>
+#include <kmessagebox.h>
+#include <kinstance.h>
+#include <kaction.h>
+#include <kwin.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qtabwidget.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+#include "indexwidget.h"
+#include "searchwidget.h"
+#include "helpwidget.h"
+#include "aboutwidget.h"
+#include "proxywidget.h"
+#include "moduletreeview.h"
+#include <stdio.h>
+
+#include "toplevel.h"
+#include "toplevel.moc"
+
+TopLevel::TopLevel(const char* name)
+ : KMainWindow( 0, name, WStyle_ContextHelp )
+ , _active(0), dummyAbout(0)
+{
+ setCaption(QString::null);
+
+ report_bug = 0;
+
+ // read settings
+ KConfig *config = KGlobal::config();
+ config->setGroup("Index");
+ QString viewmode = config->readEntry("ViewMode", "Tree");
+
+ if (viewmode == "Tree")
+ KCGlobal::setViewMode(Tree);
+ else
+ KCGlobal::setViewMode(Icon);
+
+ QString size = config->readEntry("IconSize", "Medium");
+ if (size == "Small")
+ KCGlobal::setIconSize(KIcon::SizeSmall);
+ else if (size == "Large")
+ KCGlobal::setIconSize(KIcon::SizeLarge);
+ else if (size == "Huge")
+ KCGlobal::setIconSize(KIcon::SizeHuge);
+ else
+ KCGlobal::setIconSize(KIcon::SizeMedium);
+
+ // initialize the entries
+ _modules = new ConfigModuleList();
+ _modules->readDesktopEntries();
+
+ for ( ConfigModule* m = _modules->first(); m; m = _modules->next() ) {
+ connect( m, SIGNAL( handbookRequest() ), this, SLOT( slotHandbookRequest() ) );
+ connect( m, SIGNAL( helpRequest() ), this, SLOT( slotHelpRequest() ) );
+ }
+
+ // create the layout box
+ _splitter = new QSplitter( QSplitter::Horizontal, this );
+
+ QFrame* leftFrame = new QFrame ( _splitter );
+ QBoxLayout *leftFrameLayout = new QVBoxLayout( leftFrame );
+
+ QFrame* mSearchFrame = new QFrame( leftFrame );
+ leftFrameLayout->addWidget( mSearchFrame );
+
+ QBoxLayout *searchLayout = new QHBoxLayout( mSearchFrame );
+ searchLayout->setSpacing( KDialog::spacingHint() );
+ searchLayout->setMargin( 6 );
+
+ QPushButton *clearButton = new QPushButton( mSearchFrame );
+ clearButton->setIconSet( KApplication::reverseLayout() ?
+ SmallIconSet( "clear_left" ) : SmallIconSet("locationbar_erase") );
+ searchLayout->addWidget( clearButton );
+ QToolTip::add( clearButton, i18n("Clear search") );
+
+ QLabel *label = new QLabel(i18n("Search:"), mSearchFrame );
+ searchLayout->addWidget( label );
+
+ KLineEdit *searchEdit = new KLineEdit( mSearchFrame );
+ clearButton->setFixedHeight( searchEdit->height() );
+ connect( clearButton, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) );
+ label->setBuddy( searchEdit );
+ searchLayout->addWidget( searchEdit );
+ connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
+ SLOT( slotSearchChanged(const QString &) ) );
+
+ // create the left hand side under search
+ _stack = new QWidgetStack( leftFrame );
+ leftFrameLayout->addWidget( _stack );
+
+ // index tab
+ _index = new IndexWidget(_modules, this);
+ connect(_index, SIGNAL(moduleActivated(ConfigModule*)),
+ this, SLOT(activateModule(ConfigModule*)));
+ _stack->addWidget( _index );
+
+ connect(_index, SIGNAL(categorySelected(QListViewItem*)),
+ this, SLOT(categorySelected(QListViewItem*)));
+
+ // search tab
+ _search = new SearchWidget(this);
+ _search->populateKeywordList(_modules);
+ connect(_search, SIGNAL(moduleSelected(ConfigModule *)),
+ this, SLOT(activateModule(ConfigModule *)));
+
+ _stack->addWidget( _search );
+
+ // set up the right hand side (the docking area)
+ _dock = new DockContainer( _splitter );
+
+ // help widget
+ _help = new HelpWidget(_dock);
+
+ _stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+
+ // Restore sizes
+ config->setGroup("General");
+ QValueList<int> sizes = config->readIntListEntry( "SplitterSizes" );
+ if (!sizes.isEmpty())
+ _splitter->setSizes(sizes);
+
+ // That one does the trick ...
+ _splitter->setResizeMode( leftFrame, QSplitter::KeepSize );
+
+ connect(_dock, SIGNAL(newModule(const QString&, const QString&, const QString&)),
+ this, SLOT(newModule(const QString&, const QString&, const QString&)));
+ connect(_dock, SIGNAL(changedModule(ConfigModule*)),
+ SLOT(changedModule(ConfigModule*)));
+
+ // set the main view
+ setCentralWidget( _splitter );
+
+ // initialize the GUI actions
+ setupActions();
+
+ // activate defaults
+ if (KCGlobal::viewMode() == Tree) {
+ activateTreeView();
+ tree_view->setChecked(true);
+ }
+ else {
+ activateIconView();
+ icon_view->setChecked(true);
+ }
+
+ // insert the about widget
+ if (KCGlobal::isInfoCenter())
+ {
+ AboutWidget *aw = new AboutWidget( this, 0, _index->firstTreeViewItem());
+ connect( aw, SIGNAL( moduleSelected( ConfigModule * ) ),
+ SLOT( activateModule( ConfigModule * ) ) );
+ _dock->setBaseWidget( aw );
+ KWin::setIcons( winId(),
+ KGlobal::iconLoader()->loadIcon("hwinfo", KIcon::NoGroup, 32 ),
+ KGlobal::iconLoader()->loadIcon("hwinfo", KIcon::NoGroup, 16 ) );
+ }
+ else
+ {
+ AboutWidget *aw = new AboutWidget(this);
+ connect( aw, SIGNAL( moduleSelected( ConfigModule * ) ),
+ SLOT( activateModule( ConfigModule * ) ) );
+ _dock->setBaseWidget(aw);
+ }
+}
+
+TopLevel::~TopLevel()
+{
+ KConfig *config = KGlobal::config();
+ config->setGroup("Index");
+ if (KCGlobal::viewMode() == Tree)
+ config->writeEntry("ViewMode", "Tree");
+ else
+ config->writeEntry("ViewMode", "Icon");
+
+ switch (KCGlobal::iconSize())
+ {
+ case KIcon::SizeSmall:
+ config->writeEntry("IconSize", "Small");
+ break;
+ case KIcon::SizeLarge:
+ config->writeEntry("IconSize", "Large");
+ break;
+ case KIcon::SizeHuge:
+ config->writeEntry("IconSize", "Huge");
+ break;
+ default:
+ config->writeEntry("IconSize", "Medium");
+ break;
+ }
+
+ config->setGroup("General");
+ config->writeEntry("SplitterSizes", _splitter->sizes());
+
+ config->sync();
+
+ delete _modules;
+}
+
+bool TopLevel::queryClose()
+{
+ return _dock->dockModule(0);
+}
+
+void TopLevel::setupActions()
+{
+ KStdAction::quit(this, SLOT(close()), actionCollection());
+ KStdAction::keyBindings(guiFactory(), SLOT(configureShortcuts()),
+actionCollection());
+ icon_view = new KRadioAction
+ (i18n("&Icon View"), 0, this, SLOT(activateIconView()),
+ actionCollection(), "activate_iconview");
+ icon_view->setExclusiveGroup( "viewmode" );
+
+ tree_view = new KRadioAction
+ (i18n("&Tree View"), 0, this, SLOT(activateTreeView()),
+ actionCollection(), "activate_treeview");
+ tree_view->setExclusiveGroup( "viewmode" );
+
+ icon_small = new KRadioAction
+ (i18n("&Small"), 0, this, SLOT(activateSmallIcons()),
+ actionCollection(), "activate_smallicons");
+ icon_small->setExclusiveGroup( "iconsize" );
+
+ icon_medium = new KRadioAction
+ (i18n("&Medium"), 0, this, SLOT(activateMediumIcons()),
+ actionCollection(), "activate_mediumicons");
+ icon_medium->setExclusiveGroup( "iconsize" );
+
+ icon_large = new KRadioAction
+ (i18n("&Large"), 0, this, SLOT(activateLargeIcons()),
+ actionCollection(), "activate_largeicons");
+ icon_large->setExclusiveGroup( "iconsize" );
+
+ icon_huge = new KRadioAction
+ (i18n("&Huge"), 0, this, SLOT(activateHugeIcons()),
+ actionCollection(), "activate_hugeicons");
+ icon_huge->setExclusiveGroup( "iconsize" );
+
+ about_module = new KAction(i18n("About Current Module"), 0, this, SLOT(aboutModule()), actionCollection(), "help_about_module");
+ about_module->setEnabled(false);
+
+ // I need to add this so that each module can get a bug reported,
+ // and not just KControl
+ if (KCGlobal::isInfoCenter())
+ createGUI("kinfocenterui.rc");
+ else
+ createGUI("kcontrolui.rc");
+
+ report_bug = actionCollection()->action("help_report_bug");
+ report_bug->setText(i18n("&Report Bug..."));
+ report_bug->disconnect();
+ connect(report_bug, SIGNAL(activated()), SLOT(reportBug()));
+}
+
+void TopLevel::activateIconView()
+{
+ KCGlobal::setViewMode(Icon);
+ _index->activateView(Icon);
+
+ icon_small->setEnabled(true);
+ icon_medium->setEnabled(true);
+ icon_large->setEnabled(true);
+ icon_huge->setEnabled(true);
+
+ switch(KCGlobal::iconSize())
+ {
+ case KIcon::SizeSmall:
+ icon_small->setChecked(true);
+ break;
+ case KIcon::SizeLarge:
+ icon_large->setChecked(true);
+ break;
+ case KIcon::SizeHuge:
+ icon_huge->setChecked(true);
+ break;
+ default:
+ icon_medium->setChecked(true);
+ break;
+ }
+}
+
+void TopLevel::activateTreeView()
+{
+ KCGlobal::setViewMode(Tree);
+ _index->activateView(Tree);
+
+ icon_small->setEnabled(false);
+ icon_medium->setEnabled(false);
+ icon_large->setEnabled(false);
+ icon_huge->setEnabled(false);
+}
+
+void TopLevel::activateSmallIcons()
+{
+ KCGlobal::setIconSize(KIcon::SizeSmall);
+ _index->reload();
+}
+
+void TopLevel::activateMediumIcons()
+{
+ KCGlobal::setIconSize(KIcon::SizeMedium);
+ _index->reload();
+}
+
+void TopLevel::activateLargeIcons()
+{
+ KCGlobal::setIconSize(KIcon::SizeLarge);
+ _index->reload();
+}
+
+void TopLevel::activateHugeIcons()
+{
+ KCGlobal::setIconSize(KIcon::SizeHuge);
+ _index->reload();
+}
+
+void TopLevel::newModule(const QString &name, const QString& docPath, const QString &quickhelp)
+{
+ setCaption(name, false);
+
+ _help->setText( docPath, quickhelp );
+
+ if (!report_bug) return;
+
+ if(name.isEmpty())
+ report_bug->setText(i18n("&Report Bug..."));
+ else
+ report_bug->setText(i18n("Report Bug on Module %1...").arg( handleAmpersand( name)));
+}
+
+void TopLevel::changedModule(ConfigModule *changed)
+{
+ if (!changed)
+ return;
+ setCaption(changed->moduleName(), changed->isChanged() );
+}
+
+void TopLevel::categorySelected(QListViewItem *category)
+{
+ if (_active)
+ {
+ if (_active->isChanged())
+ {
+ int res = KMessageBox::warningYesNoCancel(this, _active ?
+ i18n("There are unsaved changes in the active module.\n"
+ "Do you want to apply the changes before running "
+ "the new module or discard the changes?") :
+ i18n("There are unsaved changes in the active module.\n"
+ "Do you want to apply the changes before exiting "
+ "the Control Center or discard the changes?"),
+ i18n("Unsaved Changes"),
+ KStdGuiItem::apply(),
+ KStdGuiItem::discard());
+ if (res == KMessageBox::Yes)
+ _active->module()->applyClicked();
+ else if (res == KMessageBox::Cancel)
+ return;
+ }
+ }
+ _dock->removeModule();
+ about_module->setText( i18n( "About Current Module" ) );
+ about_module->setIconSet( QIconSet() );
+ about_module->setEnabled( false );
+
+ // insert the about widget
+ QListViewItem *firstItem = category->firstChild();
+ QString caption = static_cast<ModuleTreeItem*>(category)->caption();
+ QString icon = static_cast<ModuleTreeItem*>(category)->icon();
+ if( _dock->baseWidget()->isA( "AboutWidget" ) )
+ {
+ static_cast<AboutWidget *>( _dock->baseWidget() )->setCategory( firstItem, icon, caption);
+ }
+ else
+ {
+ AboutWidget *aw = new AboutWidget( this, 0, firstItem, caption );
+ connect( aw, SIGNAL( moduleSelected( ConfigModule * ) ),
+ SLOT( activateModule( ConfigModule * ) ) );
+ _dock->setBaseWidget( aw );
+ }
+}
+
+
+void TopLevel::activateModule(ConfigModule *mod)
+{
+ if ( _dock->module() == mod )
+ return;
+
+ // tell the index to display the module
+ _index->makeVisible(mod);
+
+ // tell the index to mark this module as loaded
+ _index->makeSelected(mod);
+
+ // dock it
+ if (!_dock->dockModule(mod))
+ {
+ if ( _dock->module() )
+ {
+ _index->makeVisible(_active);
+ _index->makeSelected(_active);
+ }
+ return;
+ }
+
+ _active=mod;
+
+ if (mod->aboutData())
+ {
+ about_module->setText(i18n("Help menu->about <modulename>", "About %1").arg(
+ handleAmpersand( mod->moduleName())));
+ about_module->setIcon(mod->icon());
+ about_module->setEnabled(true);
+ }
+ else
+ {
+ about_module->setText(i18n("About Current Module"));
+ about_module->setIconSet(QIconSet());
+ about_module->setEnabled(false);
+ }
+}
+
+void TopLevel::deleteDummyAbout()
+{
+ delete dummyAbout;
+ dummyAbout = 0;
+}
+
+void TopLevel::slotSearchChanged(const QString& search)
+{
+ if (search.isEmpty())
+ _stack->raiseWidget(_index);
+ else
+ {
+ _stack->raiseWidget(_search);
+ _search->searchTextChanged(search);
+ }
+}
+
+void TopLevel::slotHelpRequest()
+{
+ _help->display(_help->text(), QCursor::pos ( ), _dock);
+}
+
+void TopLevel::slotHandbookRequest()
+{
+ _help->handbookRequest();
+}
+
+void TopLevel::reportBug()
+{
+ // this assumes the user only opens one bug report at a time
+ static char buffer[128];
+
+ dummyAbout = 0;
+ bool deleteit = false;
+
+ if (!_active) // report against kcontrol
+ dummyAbout = const_cast<KAboutData*>(KGlobal::instance()->aboutData());
+ else
+ {
+ if (_active->aboutData())
+ dummyAbout = const_cast<KAboutData*>(_active->aboutData());
+ else
+ {
+ snprintf(buffer, sizeof(buffer), "kcm%s", _active->library().latin1());
+ dummyAbout = new KAboutData(buffer, _active->moduleName().utf8(), "2.0");
+ deleteit = true;
+ }
+ }
+ KBugReport *br = new KBugReport(this, false, dummyAbout);
+ if (deleteit)
+ connect(br, SIGNAL(finished()), SLOT(deleteDummyAbout()));
+ else
+ dummyAbout = 0;
+ br->show();
+}
+
+void TopLevel::aboutModule()
+{
+ KAboutApplication dlg(_active->aboutData());
+ dlg.exec();
+}
+
+QString TopLevel::handleAmpersand( QString modulename ) const
+{
+ if( modulename.contains( '&' )) // double it
+ {
+ for( int i = modulename.length();
+ i >= 0;
+ --i )
+ if( modulename[ i ] == '&' )
+ modulename.insert( i, "&" );
+ }
+ return modulename;
+}
diff --git a/kcontrol/kcontrol/toplevel.h b/kcontrol/kcontrol/toplevel.h
new file mode 100644
index 000000000..02e42a49e
--- /dev/null
+++ b/kcontrol/kcontrol/toplevel.h
@@ -0,0 +1,106 @@
+/*
+ Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+ Copyright (c) 2000 Matthias Elter <elter@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef __TOPLEVEL_H__
+#define __TOPLEVEL_H__
+
+#include <kmainwindow.h>
+#include <qlistview.h>
+
+
+class QSplitter;
+class QWidgetStack;
+
+class KToggleAction;
+class KAction;
+
+class DockContainer;
+class IndexWidget;
+class SearchWidget;
+class HelpWidget;
+class ConfigModule;
+class ConfigModuleList;
+class ModuleTitle;
+
+class TopLevel : public KMainWindow
+{
+ Q_OBJECT
+
+public:
+ TopLevel( const char* name=0 );
+ ~TopLevel();
+
+protected:
+ void setupActions();
+
+protected slots:
+ void activateModule(ConfigModule *);
+ void categorySelected(QListViewItem *category);
+ void newModule(const QString &name, const QString& docPath, const QString &quickhelp);
+ void activateIconView();
+ void activateTreeView();
+
+ void reportBug();
+ void aboutModule();
+
+ void activateSmallIcons();
+ void activateMediumIcons();
+ void activateLargeIcons();
+ void activateHugeIcons();
+
+ void deleteDummyAbout();
+
+ void slotSearchChanged(const QString &);
+ void slotHandbookRequest();
+ void slotHelpRequest();
+
+ void changedModule(ConfigModule *changed);
+
+ bool queryClose();
+
+private:
+
+ QString handleAmpersand( QString ) const;
+
+ QSplitter *_splitter;
+ QWidgetStack *_stack;
+ DockContainer *_dock;
+ ModuleTitle *_title;
+
+ KToggleAction *tree_view, *icon_view;
+ KToggleAction *icon_small, *icon_medium, *icon_large, *icon_huge;
+ KAction *report_bug, *about_module;
+
+ IndexWidget *_index;
+ SearchWidget *_search;
+ HelpWidget *_help;
+
+ ConfigModule *_active;
+ ConfigModuleList *_modules;
+
+ /**
+ * if someone wants to report a bug
+ * against a module with no about data
+ * we construct one for him
+ **/
+ KAboutData *dummyAbout;
+};
+
+#endif
diff --git a/kcontrol/kcontrol/version.h b/kcontrol/kcontrol/version.h
new file mode 100644
index 000000000..f35192739
--- /dev/null
+++ b/kcontrol/kcontrol/version.h
@@ -0,0 +1,2 @@
+#include <kapplication.h>
+#define KCONTROL_VERSION KDE_VERSION_STRING