summaryrefslogtreecommitdiffstats
path: root/kommander/widgets
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /kommander/widgets
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kommander/widgets')
-rw-r--r--kommander/widgets/Makefile.am35
-rw-r--r--kommander/widgets/aboutdialog.cpp295
-rw-r--r--kommander/widgets/aboutdialog.h72
-rw-r--r--kommander/widgets/buttongroup.cpp159
-rw-r--r--kommander/widgets/buttongroup.h67
-rw-r--r--kommander/widgets/checkbox.cpp151
-rw-r--r--kommander/widgets/checkbox.h67
-rw-r--r--kommander/widgets/closebutton.cpp183
-rw-r--r--kommander/widgets/closebutton.h72
-rw-r--r--kommander/widgets/combobox.cpp210
-rw-r--r--kommander/widgets/combobox.h70
-rw-r--r--kommander/widgets/datepicker.cpp130
-rw-r--r--kommander/widgets/datepicker.h70
-rw-r--r--kommander/widgets/dialog.cpp226
-rw-r--r--kommander/widgets/dialog.h87
-rw-r--r--kommander/widgets/execbutton.cpp241
-rw-r--r--kommander/widgets/execbutton.h94
-rw-r--r--kommander/widgets/fileselector.cpp240
-rw-r--r--kommander/widgets/fileselector.h102
-rw-r--r--kommander/widgets/fontdialog.cpp158
-rw-r--r--kommander/widgets/fontdialog.h50
-rw-r--r--kommander/widgets/groupbox.cpp152
-rw-r--r--kommander/widgets/groupbox.h70
-rw-r--r--kommander/widgets/konsole.cpp153
-rw-r--r--kommander/widgets/konsole.h74
-rw-r--r--kommander/widgets/label.cpp127
-rw-r--r--kommander/widgets/label.h64
-rw-r--r--kommander/widgets/lineedit.cpp182
-rw-r--r--kommander/widgets/lineedit.h72
-rw-r--r--kommander/widgets/listbox.cpp225
-rw-r--r--kommander/widgets/listbox.h67
-rw-r--r--kommander/widgets/pixmaplabel.cpp132
-rw-r--r--kommander/widgets/pixmaplabel.h66
-rw-r--r--kommander/widgets/pixmaps/textbold.xpm27
-rw-r--r--kommander/widgets/pixmaps/textcenter.xpm27
-rw-r--r--kommander/widgets/pixmaps/textitalic.xpm27
-rw-r--r--kommander/widgets/pixmaps/textleft.xpm27
-rw-r--r--kommander/widgets/pixmaps/textright.xpm27
-rw-r--r--kommander/widgets/pixmaps/textunder.xpm27
-rw-r--r--kommander/widgets/plugin.cpp138
-rw-r--r--kommander/widgets/popupmenu.cpp246
-rw-r--r--kommander/widgets/popupmenu.h61
-rw-r--r--kommander/widgets/progressbar.cpp144
-rw-r--r--kommander/widgets/progressbar.h63
-rw-r--r--kommander/widgets/radiobutton.cpp144
-rw-r--r--kommander/widgets/radiobutton.h66
-rw-r--r--kommander/widgets/richtexteditor.cpp249
-rw-r--r--kommander/widgets/richtexteditor.h85
-rw-r--r--kommander/widgets/scriptobject.cpp191
-rw-r--r--kommander/widgets/scriptobject.h68
-rw-r--r--kommander/widgets/slider.cpp121
-rw-r--r--kommander/widgets/slider.h60
-rw-r--r--kommander/widgets/spinboxint.cpp140
-rw-r--r--kommander/widgets/spinboxint.h68
-rw-r--r--kommander/widgets/statusbar.cpp131
-rw-r--r--kommander/widgets/statusbar.h65
-rw-r--r--kommander/widgets/subdialog.cpp146
-rw-r--r--kommander/widgets/subdialog.h70
-rw-r--r--kommander/widgets/table.cpp373
-rw-r--r--kommander/widgets/table.h73
-rw-r--r--kommander/widgets/tabwidget.cpp194
-rw-r--r--kommander/widgets/tabwidget.h60
-rw-r--r--kommander/widgets/textbrowser.cpp139
-rw-r--r--kommander/widgets/textbrowser.h63
-rw-r--r--kommander/widgets/textedit.cpp229
-rw-r--r--kommander/widgets/textedit.h70
-rw-r--r--kommander/widgets/timer.cpp189
-rw-r--r--kommander/widgets/timer.h71
-rw-r--r--kommander/widgets/toolbox.cpp190
-rw-r--r--kommander/widgets/toolbox.h54
-rw-r--r--kommander/widgets/treewidget.cpp512
-rw-r--r--kommander/widgets/treewidget.h87
-rw-r--r--kommander/widgets/widgets.desktop36
-rw-r--r--kommander/widgets/wizard.cpp194
-rw-r--r--kommander/widgets/wizard.h82
75 files changed, 9197 insertions, 0 deletions
diff --git a/kommander/widgets/Makefile.am b/kommander/widgets/Makefile.am
new file mode 100644
index 00000000..51b23251
--- /dev/null
+++ b/kommander/widgets/Makefile.am
@@ -0,0 +1,35 @@
+lib_LTLIBRARIES = libkommanderwidgets.la
+
+# set the include path for X, qt and KDE
+INCLUDES = -I$(top_srcdir)/kommander/widget -I$(top_srcdir)/kommander/factory -I$(top_srcdir)/kommander/plugin $(all_includes)
+
+# the library search path.
+#widgets_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+libkommanderwidgets_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -no-undefined
+
+# the libraries to link against.
+libkommanderwidgets_la_LIBADD = $(LIB_KIO) $(LIB_QT) \
+ $(top_builddir)/kommander/widget/libkommanderwidget.la \
+ $(top_builddir)/kommander/plugin/libkommanderplugin.la \
+ $(top_builddir)/kommander/factory/libkommanderfactory.la
+
+# which sources should be compiled for widgets
+libkommanderwidgets_la_SOURCES = aboutdialog.cpp buttongroup.cpp checkbox.cpp \
+ closebutton.cpp combobox.cpp datepicker.cpp dialog.cpp execbutton.cpp fileselector.cpp \
+ fontdialog.cpp groupbox.cpp konsole.cpp label.cpp lineedit.cpp listbox.cpp \
+ pixmaplabel.cpp plugin.cpp popupmenu.cpp progressbar.cpp radiobutton.cpp \
+ richtexteditor.cpp scriptobject.cpp slider.cpp spinboxint.cpp statusbar.cpp subdialog.cpp \
+ table.cpp tabwidget.cpp textbrowser.cpp textedit.cpp timer.cpp toolbox.cpp \
+ treewidget.cpp wizard.cpp
+
+# these are the headers for your project that won't be installed
+noinst_HEADERS = aboutdialog.h buttongroup.h checkbox.h closebutton.h \
+ combobox.h dialog.h execbutton.h fileselector.h fontdialog.h groupbox.h \
+ groupbox.h label.h lineedit.h listbox.h pixmaplabel.h popupmenu.h radiobutton.h \
+ radiobutton.h richtexteditor.h scriptobject.h spinboxint.h statusbar.h subdialog.h \
+ tabwidget.h textbrowser.h textedit.h toolbox.h treewidget.h wizard.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+KDE_OPTIONS=nofinal
diff --git a/kommander/widgets/aboutdialog.cpp b/kommander/widgets/aboutdialog.cpp
new file mode 100644
index 00000000..7f8c3428
--- /dev/null
+++ b/kommander/widgets/aboutdialog.cpp
@@ -0,0 +1,295 @@
+//
+// C++ Implementation: aboutdialog
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include <qfile.h>
+#include "aboutdialog.h"
+
+#include "kommanderplugin.h"
+#include "specials.h"
+
+#include <kaboutdata.h>
+#include <kaboutapplication.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+
+#include <qtextstream.h>
+
+enum Functions {
+ FirstFunction = 159,
+ Initialize,
+ AddAuthor,
+ AddTranslator,
+ SetDescription,
+ SetHomepage,
+ SetBugAddress,
+ SetLicense,
+ Version,
+ LastFunction
+};
+
+AboutDialog::AboutDialog(QWidget *parent, const char *name)
+ : QLabel(parent, name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ if (KommanderWidget::inEditor)
+ {
+ setPixmap(KGlobal::iconLoader()->loadIcon("kommander", KIcon::NoGroup, KIcon::SizeMedium));
+ setFrameStyle(QFrame::Box | QFrame::Plain);
+ setLineWidth(1);
+ setFixedSize(pixmap()->size());
+ }
+ else
+ setHidden(true);
+
+ m_aboutData = 0L;
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(Initialize, "initialize(QString widget, QString appName, QString icon, QString version, QString copyright)",
+ i18n("Sets information about the application. This is the first method that must me called, any addition to the dialog done before initialization will be ignored."), 5);
+ KommanderPlugin::registerFunction(AddAuthor, "addAuthor(QString widget, QString author, QString task, QString email, QString webAddress)",
+ i18n("Add an author. Only the author name is required."), 2, 5);
+ KommanderPlugin::registerFunction(AddTranslator, "addTranslator(QString widget, QString author, QString email)",
+ i18n("Add a translator. Only the name is required."), 2, 3);
+ KommanderPlugin::registerFunction(SetDescription, "setDescription(QString widget, QString description)",
+ i18n("Set a short description text."), 2);
+ KommanderPlugin::registerFunction(SetHomepage, "setHomepage(QString widget, QString homepage)",
+ i18n("Set a homepage address."), 2);
+ KommanderPlugin::registerFunction(SetBugAddress, "setBugAddress(QString widget, QString address)",
+ i18n("Set an email address, where bugs can be reported."), 2);
+ KommanderPlugin::registerFunction(SetLicense, "setLicense(QString widget, QString license)",
+ i18n("Sets license information of the application. The parameter can be one of the license keys - GPL_V2, LGPL_V2, BSD, ARTISTIC -, or a freely specified text."), 2);
+ KommanderPlugin::registerFunction(Version, "version(QString widget)",
+ i18n("Returns the set version string."), 1);
+}
+
+
+AboutDialog::~AboutDialog()
+{
+ delete m_aboutData;
+ m_aboutData = 0L;
+}
+
+QString AboutDialog::currentState() const
+{
+ return QString("default");
+}
+
+bool AboutDialog::isKommanderWidget() const
+{
+ return true;
+}
+QStringList AboutDialog::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void AboutDialog::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+
+bool AboutDialog::isFunctionSupported(int f)
+{
+ return (f > FirstFunction && f < LastFunction) || f == DCOP::execute;
+}
+
+void AboutDialog::initialize(const QString& appName, const QString &icon, const QString& version, const QString& copyright)
+{
+ delete m_aboutData;
+ m_authors.clear();
+ m_emails.clear();
+ m_tasks.clear();
+ m_addresses.clear();
+ m_description = "";
+ m_homepage = "";
+ m_bugaddress = "";
+ m_version = version;
+ m_appName = appName;
+ m_icon = icon;
+ m_copyright = copyright;
+ m_aboutData = new KAboutData(m_appName, m_appName, m_version);
+ m_aboutData->setCopyrightStatement(m_copyright);
+ if (!m_icon.isEmpty())
+ m_aboutData->setProgramLogo(KGlobal::iconLoader()->loadIcon(m_icon, KIcon::NoGroup, KIcon::SizeMedium).convertToImage());
+}
+
+void AboutDialog::addAuthor(const QString& author, const QString &task, const QString& email, const QString &webAddress)
+{
+ if (!m_aboutData)
+ return;
+ m_authors.append(author);
+ m_emails.append(email);
+ m_tasks.append(task);
+ m_addresses.append(webAddress);
+ m_aboutData->addAuthor(author, task, email, webAddress);
+}
+
+void AboutDialog::addTranslator(const QString& author, const QString& email)
+{
+ if (!m_aboutData)
+ return;
+ m_authors.append(author);
+ m_emails.append(email);
+ m_aboutData->setTranslator(author, email);
+}
+
+void AboutDialog::setDescription(const QString& description)
+{
+ if (!m_aboutData)
+ return;
+ m_description = description;
+ m_aboutData->setShortDescription(m_description);
+}
+
+void AboutDialog::setHomepage(const QString &homepage)
+{
+ if (!m_aboutData)
+ return;
+ m_homepage = homepage;
+ m_aboutData->setHomepage(m_homepage);
+}
+
+void AboutDialog::setBugAddress(const QString &bugAddress)
+{
+ if (!m_aboutData)
+ return;
+ m_bugaddress = bugAddress;
+ m_aboutData->setBugAddress(m_bugaddress);
+}
+
+void AboutDialog::setLicense(const QString &key)
+{
+ if (!m_aboutData)
+ return;
+ QString license = key.upper();
+ QString file;
+ if (key == "GPL_V2")
+ {
+ file = locate("data", "LICENSES/GPL_V2");
+ } else
+ if (key == "LGPL_V2")
+ {
+ file = locate("data", "LICENSES/LGPL_V2");
+ } else
+ if (key == "BSD")
+ {
+ file = locate("data", "LICENSES/BSD");
+ } else
+ if (key == "ARTISTIC")
+ {
+ file = locate("data", "LICENSES/ARTISTIC");
+ }
+ if (file.isEmpty() && !QFile::exists( key ))
+ {
+ if (!key.isEmpty())
+ m_license = key;
+ m_aboutData->setLicenseText(m_license);
+ }
+ else
+ {
+ if (file.isEmpty())
+ {
+ if (!key.isEmpty())
+ file = key;
+ }
+ m_aboutData->setLicenseTextFile(file);
+ }
+
+}
+
+void AboutDialog::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString AboutDialog::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void AboutDialog::populate()
+{
+ setAssociatedText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+void AboutDialog::execute()
+{
+ if (m_aboutData)
+ {
+ KAboutApplication dialog(m_aboutData, this);
+ dialog.exec();
+ }
+}
+
+QString AboutDialog::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case Initialize:
+ {
+ initialize(args[0], args[1], args[2], args[3]);
+ break;
+ }
+ case SetLicense:
+ {
+ setLicense(args[0]);
+ break;
+ }
+ case AddAuthor:
+ {
+ addAuthor(args[0], args[1], args[2], args[3]);
+ break;
+ }
+ case AddTranslator:
+ {
+ addTranslator(args[0], args[1]);
+ break;
+ }
+ case SetDescription:
+ {
+ setDescription(args[0]);
+ break;
+ }
+ case SetHomepage:
+ {
+ setHomepage(args[0]);
+ break;
+ }
+ case SetBugAddress:
+ {
+ setBugAddress(args[0]);
+ break;
+ }
+ case Version:
+ {
+ if (m_aboutData)
+ return m_aboutData->version();
+ break;
+ }
+ case DCOP::execute:
+ {
+ if (m_aboutData)
+ {
+ KAboutApplication dialog(m_aboutData, this);
+ dialog.exec();
+ }
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "aboutdialog.moc"
diff --git a/kommander/widgets/aboutdialog.h b/kommander/widgets/aboutdialog.h
new file mode 100644
index 00000000..0d0249a7
--- /dev/null
+++ b/kommander/widgets/aboutdialog.h
@@ -0,0 +1,72 @@
+//
+// C++ Interface: aboutdialog
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef ABOUTDIALOG_H
+#define ABOUTDIALOG_H
+
+#include <qlabel.h>
+#include <kommanderwidget.h>
+
+class KAboutApplication;
+class KAboutData;
+
+/**
+ @author Andras Mantia <amantia@kdewebdev.org>
+*/
+class AboutDialog : public QLabel, public KommanderWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+public:
+ AboutDialog(QWidget *parent = 0, const char *name = 0);
+
+ ~AboutDialog();
+
+ virtual bool isKommanderWidget() const;
+ virtual QString currentState() const;
+ virtual bool isFunctionSupported(int function);
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+ virtual QStringList associatedText() const;
+ virtual void setAssociatedText(const QStringList&);
+
+public slots:
+ virtual void populate();
+ virtual void execute();
+
+private:
+ void initialize(const QString& appName, const QString &icon, const QString& version, const QString& copyright);
+ void addAuthor(const QString& author, const QString &task, const QString& email, const QString &webAddress);
+ void addTranslator(const QString& author, const QString& email);
+ void setDescription(const QString& description);
+ void setHomepage(const QString &homepage);
+ void setBugAddress(const QString &bugAddress);
+ void setLicense(const QString &license);
+
+ KAboutData *m_aboutData;
+ QString m_version;
+ QString m_appName;
+ QString m_copyright;
+ QString m_icon;
+ QString m_bugaddress;
+ QStringList m_authors;
+ QStringList m_emails;
+ QStringList m_tasks;
+ QStringList m_addresses;
+ QString m_description;
+ QString m_homepage;
+ QString m_license;
+};
+
+#endif
diff --git a/kommander/widgets/buttongroup.cpp b/kommander/widgets/buttongroup.cpp
new file mode 100644
index 00000000..0a6eafc2
--- /dev/null
+++ b/kommander/widgets/buttongroup.cpp
@@ -0,0 +1,159 @@
+/***************************************************************************
+ buttongroup.cpp - Button group widget
+ -------------------
+ copyright : (C) 2002-2004 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+#include <klocale.h>
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qbuttongroup.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include "kommanderplugin.h"
+#include <specials.h>
+#include "buttongroup.h"
+
+#include "radiobutton.h" // include a button header for the compiler with dynamic cast below
+
+enum Functions {
+ FirstFunction = 720,
+ BG_selectedId,
+ LastFunction
+};
+
+ButtonGroup::ButtonGroup(QWidget *a_parent, const char *a_name)
+ : QButtonGroup(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "checked";
+ states << "unchecked";
+ setStates(states);
+ setDisplayStates(states);
+
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(BG_selectedId, "selectedId(QString widget)", i18n("Returns the ID of the selected button."), 1);
+
+}
+
+ButtonGroup::~ButtonGroup()
+{
+}
+
+QString ButtonGroup::currentState() const
+{
+ if (!isCheckable() || isChecked())
+ return "checked";
+ else
+ return "unchecked";
+}
+
+bool ButtonGroup::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList ButtonGroup::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void ButtonGroup::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void ButtonGroup::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText( a_text );
+}
+
+QString ButtonGroup::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void ButtonGroup::populate()
+{
+//FIXME: implement
+}
+
+void ButtonGroup::showEvent(QShowEvent* e)
+{
+ QButtonGroup::showEvent(e);
+ emit widgetOpened();
+}
+
+void ButtonGroup::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool ButtonGroup::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::checked || f == DCOP::setChecked || f == DCOP::geometry || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor || (f >= FirstFunction && f <= LastFunction);
+}
+
+
+QString ButtonGroup::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ {
+ QString text;
+ for (int i = 0; i < count(); i++)
+ if (dynamic_cast<KommanderWidget*>(find(i)))
+ text += (dynamic_cast<KommanderWidget*>(find(i)))->evalAssociatedText();
+ return text;
+ }
+ case DCOP::checked:
+ return QString::number(isChecked());
+ case DCOP::setChecked:
+ setCheckable(true);
+ setChecked(args[0] != "false");
+ break;
+ case BG_selectedId:
+ return QString::number(this->selectedId() );
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "buttongroup.moc"
diff --git a/kommander/widgets/buttongroup.h b/kommander/widgets/buttongroup.h
new file mode 100644
index 00000000..0e123864
--- /dev/null
+++ b/kommander/widgets/buttongroup.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+ buttongroup.h - Buttongroup widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_BUTTONGROUP_H_
+#define _HAVE_BUTTONGROUP_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qbuttongroup.h>
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT ButtonGroup : public QButtonGroup, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget DESIGNABLE false)
+public:
+ ButtonGroup(QWidget *a_parent, const char *a_name);
+ ~ButtonGroup();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void populate();
+
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent* e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/checkbox.cpp b/kommander/widgets/checkbox.cpp
new file mode 100644
index 00000000..e78dbdb8
--- /dev/null
+++ b/kommander/widgets/checkbox.cpp
@@ -0,0 +1,151 @@
+/***************************************************************************
+ checkbox.cpp - Checkbox widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qcheckbox.h>
+#include <qbutton.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "checkbox.h"
+
+CheckBox::CheckBox(QWidget *a_parent, const char *a_name)
+ : QCheckBox(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "unchecked";
+ states << "semichecked";
+ states << "checked";
+ setStates(states);
+ QStringList displayStates;
+ displayStates << "checked";
+ displayStates << "semichecked";
+ displayStates << "unchecked";
+ setDisplayStates(displayStates);
+}
+
+CheckBox::~CheckBox()
+{
+}
+
+QString CheckBox::currentState() const
+{
+ if (state() == QButton::Off)
+ return "unchecked";
+ else if (state() == QButton::NoChange)
+ return "semichecked";
+ else if (state() == QButton::On)
+ return "checked";
+ return QString();
+}
+
+bool CheckBox::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList CheckBox::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void CheckBox::setAssociatedText(const QStringList & a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void CheckBox::setPopulationText(const QString & a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString CheckBox::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void CheckBox::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText(populationText()));
+}
+
+void CheckBox::setWidgetText(const QString& a_text)
+{
+ setText(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void CheckBox::showEvent(QShowEvent* e)
+{
+ QCheckBox::showEvent(e);
+ emit widgetOpened();
+}
+
+bool CheckBox::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::checked || f == DCOP::setChecked || f == DCOP::geometry || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor;
+}
+
+void CheckBox::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+QString CheckBox::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return text();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::checked:
+ return QString::number(isChecked());
+ case DCOP::setChecked:
+ setChecked(args[0] != "false" && args[0] != "0");
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "checkbox.moc"
diff --git a/kommander/widgets/checkbox.h b/kommander/widgets/checkbox.h
new file mode 100644
index 00000000..c9743434
--- /dev/null
+++ b/kommander/widgets/checkbox.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+ checkbox.h - Checkbox widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_CHECKBOX_H_
+#define _HAVE_CHECKBOX_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qstring.h>
+#include <qcheckbox.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT CheckBox : public QCheckBox, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ CheckBox(QWidget *a_parent, const char *a_name);
+ ~CheckBox();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/closebutton.cpp b/kommander/widgets/closebutton.cpp
new file mode 100644
index 00000000..9da9f1a0
--- /dev/null
+++ b/kommander/widgets/closebutton.cpp
@@ -0,0 +1,183 @@
+/***************************************************************************
+ closebutton.cpp - Button that when clicked, closes the dialog it's in
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+#include <kmessagebox.h>
+#include <klocale.h>
+
+/* QT INCLUDES */
+#include <qdialog.h>
+#include <qevent.h>
+#include <qobject.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qwidget.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "closebutton.h"
+
+CloseButton::CloseButton(QWidget* a_parent, const char* a_name)
+ : KPushButton(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ setWriteStdout(true);
+
+ connect(this, SIGNAL(clicked()), this, SLOT(startProcess()));
+
+ QObject *parent = this;
+ while (parent->parent() != 0)
+ {
+ parent = parent->parent();
+ if (parent->inherits("QDialog"))
+ break;
+ }
+ connect(this, SIGNAL(clicked()), parent, SLOT(reject()));
+}
+
+CloseButton::~CloseButton()
+{
+}
+
+QString CloseButton::currentState() const
+{
+ return QString("default");
+}
+
+bool CloseButton::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList CloseButton::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void CloseButton::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void CloseButton::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString CloseButton::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void CloseButton::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText(populationText()));
+}
+
+void CloseButton::setWidgetText(const QString& a_text)
+{
+ setText(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void CloseButton::startProcess()
+{
+ QString at = evalAssociatedText();
+
+ if (!at.isEmpty())
+ {
+ KShellProcess *process = new KShellProcess("/bin/sh");
+ *process << at;
+
+ connect(process, SIGNAL(processExited(KProcess *)), SLOT(endProcess(KProcess *)));
+ connect(process, SIGNAL(receivedStdout(KProcess *, char *, int)), SLOT(appendOutput(KProcess *,
+ char *, int)));
+ connect(process, SIGNAL(receivedStderr(KProcess *, char *, int)), SLOT(appendOutput(KProcess *,
+ char *, int)));
+
+ if (!process->start(KProcess::Block, KProcess::Stdout))
+ {
+ KMessageBox::error(this, i18n("Failed to start shell process."));
+ endProcess(process);
+ return;
+ }
+ } else
+ endProcess(0);
+}
+
+void CloseButton::appendOutput(KProcess *, char *a_buffer, int a_len)
+{
+ char *buffer = new char[a_len + 1];
+ buffer[a_len] = 0;
+ for (int i = 0; i < a_len; ++i)
+ buffer[i] = a_buffer[i];
+
+ QString bufferString(buffer);
+ m_output += bufferString;
+ if (writeStdout())
+ {
+ fputs(buffer, stdout);
+ fflush(stdout);
+ }
+ delete[] buffer;
+}
+
+void CloseButton::endProcess(KProcess *a_process)
+{
+ emit widgetTextChanged(m_output);
+ m_output = "";
+ delete a_process;
+}
+
+bool CloseButton::writeStdout() const
+{
+ return m_writeStdout;
+}
+
+void CloseButton::setWriteStdout(bool a_enable)
+{
+ m_writeStdout = a_enable;
+}
+
+void CloseButton::showEvent(QShowEvent *e)
+{
+ QPushButton::showEvent(e);
+ emit widgetOpened();
+}
+
+bool CloseButton::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText;
+}
+
+QString CloseButton::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return m_output;
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "closebutton.moc"
diff --git a/kommander/widgets/closebutton.h b/kommander/widgets/closebutton.h
new file mode 100644
index 00000000..8b7aa57a
--- /dev/null
+++ b/kommander/widgets/closebutton.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ closebutton.h - Button that when clicked, closes the dialog it's in
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef _HAVE_CLOSEBUTTON_H_
+#define _HAVE_CLOSEBUTTON_H_
+
+/* KDE INCLUDES */
+#include <kpushbutton.h>
+
+/* QT INCLUDES */
+#include <qobject.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT CloseButton : public KPushButton, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+ Q_PROPERTY(bool writeStdout READ writeStdout WRITE setWriteStdout)
+public:
+ CloseButton(QWidget* a_parent, const char* a_name);
+ ~CloseButton();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+ bool writeStdout() const;
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWriteStdout(bool);
+ virtual void setWidgetText(const QString &);
+ virtual void startProcess();
+ virtual void appendOutput(KProcess*, char*, int);
+ virtual void endProcess(KProcess*);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+protected:
+ bool m_writeStdout;
+ QString m_output;
+ void showEvent(QShowEvent* e);
+private:
+};
+
+#endif
diff --git a/kommander/widgets/combobox.cpp b/kommander/widgets/combobox.cpp
new file mode 100644
index 00000000..250d3820
--- /dev/null
+++ b/kommander/widgets/combobox.cpp
@@ -0,0 +1,210 @@
+/***************************************************************************
+ combobox.cpp - Combobox widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+#include <kiconloader.h>
+#include <klocale.h>
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+
+/* OTHER INCLUDES */
+#include <kommanderplugin.h>
+#include <specials.h>
+#include "combobox.h"
+
+enum Functions {
+ FirstFunction = 353, //CHANGE THIS NUMBER TO AN UNIQUE ONE!!!
+ popupList,
+ LastFunction
+};
+
+
+ComboBox::ComboBox(QWidget *a_parent, const char *a_name)
+ : KComboBox(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+
+ connect(this, SIGNAL(activated(int)), this, SLOT(emitWidgetTextChanged(int)));
+
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(popupList, "popupList(QString widget)", i18n("Make the ComboBox expose it's list without mousing around."), 1);
+
+}
+
+ComboBox::~ComboBox()
+{
+}
+
+QString ComboBox::currentState() const
+{
+ return QString("default");
+}
+
+bool ComboBox::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList ComboBox::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void ComboBox::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void ComboBox::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString ComboBox::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void ComboBox::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+void ComboBox::setWidgetText(const QString& a_text)
+{
+ clear();
+ insertStringList(QStringList::split("\n", a_text));
+ emit widgetTextChanged(a_text);
+}
+
+void ComboBox::emitWidgetTextChanged(int a_index)
+{
+ emit widgetTextChanged(text(a_index));
+}
+
+void ComboBox::showEvent(QShowEvent *e)
+{
+ QComboBox::showEvent( e );
+ emit widgetOpened();
+}
+
+void ComboBox::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+
+bool ComboBox::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::selection || f == DCOP::setSelection ||
+ f == DCOP::currentItem || f == DCOP::setCurrentItem || f == DCOP::item ||
+ f == DCOP::removeItem || f == DCOP::insertItem || f == DCOP::insertItems ||
+ f == DCOP::addUniqueItem || f == DCOP::clear || f == DCOP::count || f == DCOP::setEditable || f == DCOP::geometry || f == DCOP::hasFocus || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor || (f >= FirstFunction && f <= LastFunction);
+}
+
+QString ComboBox::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return currentText();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::selection:
+ return currentText();
+ case DCOP::currentItem:
+ return QString::number(currentItem());
+ case DCOP::setCurrentItem:
+ setCurrentItem(args[0].toUInt());
+ break;
+ case DCOP::item:
+ {
+ int i = args[0].toInt();
+ if (i >= 0 && i < count())
+ return text(i);
+ break;
+ }
+ case DCOP::removeItem:
+ removeItem(args[0].toInt());
+ break;
+ case DCOP::insertItem:
+ insertItem(args[0], args[1].toInt());
+ break;
+ case DCOP::insertItems:
+ insertStringList(QStringList::split("\n", args[0]), args[1].toInt());
+ break;
+ case DCOP::addUniqueItem:
+ for (int i=0; i<count(); i++)
+ if (text(i) == args[0])
+ return QString();
+ insertItem(args[0]);
+ break;
+ case DCOP::clear:
+ clear();
+ break;
+ case DCOP::count:
+ return QString::number(count());
+ case DCOP::setSelection:
+ {
+ for (int i = 0; i < count(); i++)
+ if (text(i) == args[0])
+ {
+ setCurrentItem(i);
+ break;
+ }
+ break;
+ }
+ case DCOP::setEditable:
+ setEditable(args[0] != "false" && args[0] != "0");
+ break;
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ case popupList:
+ QComboBox::popup();
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::hasFocus:
+ return QString::number(this->hasFocus());
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "combobox.moc"
diff --git a/kommander/widgets/combobox.h b/kommander/widgets/combobox.h
new file mode 100644
index 00000000..916846d9
--- /dev/null
+++ b/kommander/widgets/combobox.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ combobox.h - Combobox widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_COMBOBOX_H_
+#define _HAVE_COMBOBOX_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kcombobox.h>
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT ComboBox : public KComboBox, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+
+public:
+ ComboBox(QWidget *a_parent, const char *a_name);
+ ~ComboBox();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void populate();
+
+ virtual void emitWidgetTextChanged(int);
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/datepicker.cpp b/kommander/widgets/datepicker.cpp
new file mode 100644
index 00000000..c1b1f834
--- /dev/null
+++ b/kommander/widgets/datepicker.cpp
@@ -0,0 +1,130 @@
+/***************************************************************************
+ combobox.cpp - Combobox widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qdatetime.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "datepicker.h"
+
+DatePicker::DatePicker(QWidget *a_parent, const char *a_name)
+ : KDatePicker(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+}
+
+DatePicker::~DatePicker()
+{
+}
+
+QString DatePicker::currentState() const
+{
+ return QString("default");
+}
+
+bool DatePicker::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList DatePicker::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void DatePicker::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void DatePicker::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString DatePicker::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void DatePicker::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+void DatePicker::setWidgetText(const QString& a_text)
+{
+ setDate(QDate::fromString(a_text, Qt::ISODate));
+ emit widgetTextChanged(a_text);
+}
+
+QString DatePicker::widgetText() const
+{
+ return date().toString(Qt::ISODate);
+}
+
+
+void DatePicker::showEvent(QShowEvent *e)
+{
+ KDatePicker::showEvent( e );
+ emit widgetOpened();
+}
+void DatePicker::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+
+bool DatePicker::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::geometry || f == DCOP::hasFocus ;
+}
+
+QString DatePicker::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return date().toString(Qt::ISODate);
+ case DCOP::setText:
+ setDate(QDate::fromString(args[0], Qt::ISODate));
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::hasFocus:
+ return QString::number(this->hasFocus());
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "datepicker.moc"
diff --git a/kommander/widgets/datepicker.h b/kommander/widgets/datepicker.h
new file mode 100644
index 00000000..0383937a
--- /dev/null
+++ b/kommander/widgets/datepicker.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ combobox.h - Combobox widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_DATEPICKER_H_
+#define _HAVE_DATEPICKER_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kdatepicker.h>
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT DatePicker : public KDatePicker, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+
+public:
+ DatePicker(QWidget *a_parent, const char *a_name);
+ ~DatePicker();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+ virtual QString widgetText() const;
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void populate();
+
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/dialog.cpp b/kommander/widgets/dialog.cpp
new file mode 100644
index 00000000..ef9b727b
--- /dev/null
+++ b/kommander/widgets/dialog.cpp
@@ -0,0 +1,226 @@
+/***************************************************************************
+ dialog.cpp - Main dialog widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+#include <klocale.h>
+
+/* QT INCLUDES */
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qdialog.h>
+#include <qpoint.h>
+#include <qcursor.h>
+#include <qapplication.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "dialog.h"
+#include <myprocess.h>
+#include "kommanderplugin.h"
+
+enum Functions {
+ FirstFunction = 185,
+ D_focusWidget,
+ D_waitCursor,
+ D_restoreCursor,
+ LastFunction
+};
+
+Dialog::Dialog(QWidget *a_parent, const char *a_name, bool a_modal, int a_flags)
+ : QDialog(a_parent, a_name, a_modal, a_flags), KommanderWindow(this)
+{
+ QStringList states;
+ states << "default";
+ states << "initialization";
+ states << "destroy";
+ setStates(states);
+ setDisplayStates(states);
+ m_useShebang = false;
+ m_shebang = "#!/usr/bin/kmdr-executor";
+ m_firstShow = true;
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(D_focusWidget, "focusWidget(QString widget)", i18n("The name of the widget having focus"), 1);
+ KommanderPlugin::registerFunction(D_waitCursor, "waitCursor(QString widget)", i18n("Set a wait cursor. CAUTION: if set more than once an equal number of calls to restore must be made to clear it."), 1);
+ KommanderPlugin::registerFunction(D_restoreCursor, "restoreCursor(QString widget)", i18n("Restore normal curser. NOTE: must be called as many times as wait was."), 1);
+}
+
+Dialog::~Dialog()
+{
+ if (!inEditor)
+ destroy();
+}
+
+QString Dialog::currentState() const
+{
+ return QString("default");
+}
+
+bool Dialog::isKommanderWidget() const
+{
+ return true;
+}
+
+bool Dialog::useInternalParser() const
+{
+ return m_useInternalParser;
+}
+
+void Dialog::setUseInternalParser(bool b)
+{
+ KommanderWidget::useInternalParser = b;
+ m_useInternalParser = b;
+}
+
+
+QStringList Dialog::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void Dialog::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void Dialog::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText( a_text );
+}
+
+QString Dialog::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void Dialog::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText(populationText()));
+}
+
+void Dialog::initialize()
+{
+ const QStringList assoc = associatedText();
+ if (assoc.count() > 1 && !assoc[1].isEmpty())
+ {
+ MyProcess proc(this);
+ proc.run( KommanderWidget::evalAssociatedText(assoc[1]) );
+ }
+}
+
+void Dialog::destroy()
+{
+ const QStringList assoc = associatedText();
+ if (assoc.count() > 2 && !assoc[2].isEmpty())
+ {
+ MyProcess proc(this);
+ proc.run( KommanderWidget::evalAssociatedText(assoc[2]) );
+ }
+}
+
+
+void Dialog::setWidgetText(const QString& a_text)
+{
+ setCaption(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void Dialog::exec()
+{
+ QDialog::exec();
+ emit finished();
+}
+
+void Dialog::show()
+{
+//if the dialog is embedded in a KPart, the show can be called many times.
+//to avoid re-init and sending signals we don't want, in that case call only the
+//QWidget's show method to show the widgets, but don't do any QDialog specific
+//task
+ if (!m_firstShow)
+ {
+ QWidget::show();
+ } else
+ {
+ QDialog::show();
+ if (!inEditor)
+ initialize();
+ m_firstShow = false;
+ }
+}
+
+void Dialog::done(int r)
+{
+/* if (!inEditor)
+ destroy();*/
+ QDialog::done(r);
+}
+
+void Dialog::showEvent(QShowEvent *e)
+{
+ QDialog::showEvent( e );
+ emit widgetOpened();
+}
+
+void Dialog::keyPressEvent( QKeyEvent *e )
+{
+ if ( e->state() == 0 && e->key() == Key_Escape)
+ return;
+ else
+ QDialog::keyPressEvent(e);
+
+}
+
+void Dialog::contextMenuEvent( QContextMenuEvent * e )
+{
+ QDialog::contextMenuEvent( e );
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool Dialog::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::geometry || (f > FirstFunction && f < LastFunction);
+}
+
+QString Dialog::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return caption();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::geometry:
+ return QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ break;
+ case D_focusWidget:
+ return focusWidget()->name();
+ break;
+ case D_waitCursor:
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ break;
+ case D_restoreCursor:
+ QApplication::restoreOverrideCursor();
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "dialog.moc"
diff --git a/kommander/widgets/dialog.h b/kommander/widgets/dialog.h
new file mode 100644
index 00000000..091ff890
--- /dev/null
+++ b/kommander/widgets/dialog.h
@@ -0,0 +1,87 @@
+/***************************************************************************
+ dialog.h - Kommander dialog
+ -------------------
+ copyright : (C) 2002 by Marc Britton <consume@optushome.com.au>
+ (C) 2004 by Andras Mantia <amantia@kde.org>
+ (C) 2004 by Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_DIALOG_H_
+#define _HAVE_DIALOG_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qdialog.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwindow.h>
+#include <kommander_export.h>
+class QShowEvent;
+class KOMMANDER_EXPORT Dialog : public QDialog, public KommanderWindow
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+ Q_PROPERTY(bool useInternalParser READ useInternalParser WRITE setUseInternalParser)
+ Q_PROPERTY(bool useShebang READ useShebang WRITE setUseShebang DESIGNABLE true)
+ Q_PROPERTY(QString shebang READ Shebang WRITE setShebang DESIGNABLE true)
+ Q_OVERRIDE(bool modal DESIGNABLE false)
+
+public:
+ Dialog(QWidget *, const char *, bool = true, int=0);
+ ~Dialog();
+ virtual bool isKommanderWidget() const;
+ virtual bool useInternalParser() const;
+ virtual void setUseInternalParser(bool b);
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+ virtual void show();
+
+ bool useShebang() const { return m_useShebang; }
+ void setUseShebang(bool useit) { m_useShebang = useit; }
+ QString Shebang() const { return m_shebang; }
+ void setShebang(const QString &text) { m_shebang = text; }
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void exec();
+ virtual void populate();
+ virtual void done(int r);
+protected slots:
+ virtual void initialize();
+ virtual void destroy();
+
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void finished();
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent( QShowEvent *e );
+ void keyPressEvent( QKeyEvent * );
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+ QString m_fileName;
+ bool m_useInternalParser;
+ bool m_useShebang; //add m_shebang at the beginning of the dialog code or not
+ bool m_firstShow; //tells if the show method was called before or not
+ QString m_shebang; //#!/usr/bin/kmdr-executor or similar
+};
+
+#endif
diff --git a/kommander/widgets/execbutton.cpp b/kommander/widgets/execbutton.cpp
new file mode 100644
index 00000000..69d06f8b
--- /dev/null
+++ b/kommander/widgets/execbutton.cpp
@@ -0,0 +1,241 @@
+/***************************************************************************
+ execbutton.cpp - Button that runs its text association
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+#include <kapplication.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+/* QT INCLUDES */
+#include <qcursor.h>
+#include <qevent.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qwidget.h>
+#include <qpopupmenu.h>
+#include <qapplication.h>
+#include <qwidgetlist.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <specials.h>
+#include "execbutton.h"
+#include <myprocess.h>
+#include <iostream>
+#include <kommanderplugin.h>
+
+using namespace std;
+
+enum Functions {
+ FirstFunction = 260, //CHANGE THIS NUMBER TO AN UNIQUE ONE!!!
+ EB_isOn,
+ EB_setPopup,
+ EB_setButtonText,
+ LastFunction
+};
+
+ExecButton::ExecButton(QWidget* a_parent, const char* a_name)
+ : KPushButton(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ setWriteStdout(true);
+ setBlockGUI(Button);
+ connect(this, SIGNAL(clicked()), this, SLOT(startProcess()));
+
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(EB_isOn, "isOn(QString widget)", i18n("For use only when button is togle type."), 1);
+ KommanderPlugin::registerFunction(EB_setPopup, "setPopup(QString widget, QString Menu)", i18n("Associate a Kommander PopupMenu with this ExecButton."), 2);
+ KommanderPlugin::registerFunction(EB_setButtonText, "setButtonText(QString widget, QString Text)", i18n("Set the text on the ExecButton."), 2);
+}
+
+ExecButton::~ExecButton()
+{
+}
+
+QString ExecButton::currentState() const
+{
+ return QString("default");
+}
+
+bool ExecButton::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList ExecButton::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void ExecButton::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void ExecButton::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString ExecButton::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void ExecButton::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText(populationText());
+ setWidgetText(txt);
+}
+
+void ExecButton::setWidgetText(const QString& a_text)
+{
+ setText(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void ExecButton::startProcess()
+{
+ QString at = evalAssociatedText().stripWhiteSpace();
+ bool enabledStatus = isEnabled();
+ if (m_blockGUI != None)
+ setEnabled(false);
+ if (m_blockGUI == GUI)
+ KApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ MyProcess* process = new MyProcess(this);
+ process->setBlocking(m_blockGUI == GUI);
+ connect(process, SIGNAL(processExited(MyProcess*)), SLOT(processExited(MyProcess*)));
+ m_output = process->run(at);
+ if (m_blockGUI == GUI)
+ {
+ KApplication::restoreOverrideCursor();
+ if (writeStdout())
+ cout << m_output << flush;
+ }
+ setEnabled(enabledStatus);
+}
+
+
+bool ExecButton::writeStdout() const
+{
+ return m_writeStdout;
+}
+
+void ExecButton::setWriteStdout(bool a_enable)
+{
+ m_writeStdout = a_enable;
+}
+
+void ExecButton::setBlockGUI(Blocking a_enable)
+{
+ m_blockGUI = a_enable;
+}
+
+ExecButton::Blocking ExecButton::blockGUI() const
+{
+ return m_blockGUI;
+}
+
+void ExecButton::processExited(MyProcess* p)
+{
+ if (blockGUI() != None)
+ setEnabled(true);
+ if (p)
+ {
+ m_output = p->output();
+ if (writeStdout())
+ cout << m_output << flush;
+ delete p;
+ }
+}
+
+void ExecButton::showEvent(QShowEvent* e)
+{
+ KPushButton::showEvent(e);
+ emit widgetOpened();
+}
+
+void ExecButton::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool ExecButton::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::execute || f == DCOP::geometry || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor || (f >= FirstFunction && f <= LastFunction);
+}
+
+QString ExecButton::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return m_output;
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::execute:
+ startProcess();
+ break;
+ case EB_isOn:
+ return QString::number(this->isOn() );
+ break;
+ case EB_setButtonText:
+ ExecButton::setText(args[0]);
+ break;
+ case EB_setPopup:
+ {
+ QWidgetList *list = QApplication::allWidgets();
+ QWidgetListIt it( *list );
+ QWidget * w;
+ while ( (w=it.current()) != 0 ) { // for each widget...
+ ++it;
+ if (w->name() == args[0] && w->className() == "PopupMenu")
+ {
+ QPopupMenu *popup = dynamic_cast<QPopupMenu*>(w->child("unnamed", "KPopupMenu"));
+ this->setPopup(popup);
+ }
+ }
+ break;
+ }
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "execbutton.moc"
diff --git a/kommander/widgets/execbutton.h b/kommander/widgets/execbutton.h
new file mode 100644
index 00000000..2e2ea60a
--- /dev/null
+++ b/kommander/widgets/execbutton.h
@@ -0,0 +1,94 @@
+/***************************************************************************
+ execbutton.h - Button that runs its text association
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef _HAVE_EXECBUTTON_H_
+#define _HAVE_EXECBUTTON_H_
+
+/* KDE INCLUDES */
+#include <kpushbutton.h>
+
+/* QT INCLUDES */
+#include <qobject.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+
+class QWidget;
+class KProcess;
+class MyProcess;
+
+class QShowEvent;
+class KOMMANDER_EXPORT ExecButton : public KPushButton, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS(Blocking)
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+ Q_PROPERTY(bool writeStdout READ writeStdout WRITE setWriteStdout)
+ Q_PROPERTY(Blocking blockGUI READ blockGUI WRITE setBlockGUI)
+
+public:
+ ExecButton(QWidget *a_parent, const char *a_name);
+ ~ExecButton();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ // Handle stdout setting
+ virtual void setWriteStdout(bool);
+ bool writeStdout() const;
+ // Handle blocking
+ enum Blocking { None, Button, GUI };
+ virtual void setBlockGUI(Blocking a_enable);
+ Blocking blockGUI() const;
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void populate();
+ virtual void setWidgetText(const QString &);
+
+ // Execute script from associastedText
+ virtual void startProcess();
+ // Process has ended
+ virtual void processExited(MyProcess* p);
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+
+protected:
+ void contextMenuEvent( QContextMenuEvent * e );
+ // Whether output from process should be put in real stdout
+ bool m_writeStdout;
+ // Whether pressing execubtton should block GUI until process ends
+ Blocking m_blockGUI;
+ // Output from process
+ QString m_output;
+ void showEvent( QShowEvent *e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/fileselector.cpp b/kommander/widgets/fileselector.cpp
new file mode 100644
index 00000000..b220b8d9
--- /dev/null
+++ b/kommander/widgets/fileselector.cpp
@@ -0,0 +1,240 @@
+/***************************************************************************
+ fileselector.cpp - File selection widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+
+/* KDE INCLUDES */
+#include <kfiledialog.h>
+#include <klineedit.h>
+#include <kpushbutton.h>
+#include <kurlcompletion.h>
+#include <kiconloader.h>
+
+/* QT INCLUDES */
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qlayout.h>
+#include <qsizepolicy.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "fileselector.h"
+
+FileSelector::FileSelector(QWidget * a_parent, const char *a_name)
+ : QWidget(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+
+ m_lineEdit = new KLineEdit(this);
+
+ m_selectButton = new KPushButton(BarIconSet("fileopen"), "", this);
+
+ m_boxLayout = new QHBoxLayout(this, 0, 11);
+ m_boxLayout->addWidget(m_lineEdit);
+ m_boxLayout->addWidget(m_selectButton);
+
+ setSizePolicy(m_lineEdit->sizePolicy());
+ m_lineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+ m_selectButton->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding));
+
+ connect(m_selectButton, SIGNAL(clicked()), this, SLOT(makeSelection()));
+
+ setSelectionType(Open);
+ setSelectionOpenMultiple(false);
+}
+
+FileSelector::~FileSelector()
+{
+}
+
+QString FileSelector::currentState() const
+{
+ return QString("default");
+}
+
+bool FileSelector::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList FileSelector::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void FileSelector::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void FileSelector::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString FileSelector::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void FileSelector::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText(populationText());
+ setWidgetText(txt);
+}
+
+void FileSelector::setWidgetText(const QString& a_text)
+{
+ m_lineEdit->setText(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+FileSelector::SelectionType FileSelector::selectionType() const
+{
+ return m_selectionType;
+}
+
+void FileSelector::setSelectionType(SelectionType a_selectionType)
+{
+ m_selectionType = a_selectionType;
+ delete m_lineEdit->completionObject();
+ if (m_selectionType == Directory)
+ m_lineEdit->setCompletionObject(new KURLCompletion(KURLCompletion::DirCompletion));
+ else
+ m_lineEdit->setCompletionObject(new KURLCompletion(KURLCompletion::FileCompletion));
+
+}
+
+QString FileSelector::selectionFilter() const
+{
+ return m_filter;
+}
+
+void FileSelector::setSelectionFilter(const QString& a_filter)
+{
+ m_filter = a_filter;
+}
+
+QString FileSelector::selectionCaption() const
+{
+ return m_caption;
+}
+
+void FileSelector::setSelectionCaption(const QString& a_caption)
+{
+ m_caption = a_caption;
+}
+
+bool FileSelector::selectionOpenMultiple() const
+{
+ return m_openMultiple;
+}
+
+void FileSelector::setSelectionOpenMultiple(bool a_openMultiple)
+{
+ m_openMultiple = a_openMultiple;
+}
+
+void FileSelector::makeSelection()
+{
+ QString text;
+ if (m_selectionType == Open && m_openMultiple)
+ text = KFileDialog::getOpenFileNames(m_lineEdit->text(), m_filter, this, m_caption).join("\n");
+ else if (m_selectionType == Open && !m_openMultiple)
+ text = KFileDialog::getOpenFileName(m_lineEdit->text(), m_filter, this, m_caption);
+ else if (m_selectionType == Save)
+ text = KFileDialog::getSaveFileName(m_lineEdit->text(), m_filter, this, m_caption);
+ else if (m_selectionType == Directory)
+ text = KFileDialog::getExistingDirectory(m_lineEdit->text(), this, m_caption);
+
+ if (!text.isEmpty())
+ setWidgetText(text);
+}
+
+QString FileSelector::caption() const
+{
+ return m_selectButton->text();
+}
+
+void FileSelector::setCaption(const QString& a_text)
+{
+ m_selectButton->setText(a_text);
+}
+
+bool FileSelector::showEditor() const
+{
+ return m_lineEdit->isVisible();
+}
+
+void FileSelector::setShowEditor(bool a_visible)
+{
+ if (a_visible)
+ m_lineEdit->show();
+ else
+ m_lineEdit->hide();
+}
+
+void FileSelector::showEvent(QShowEvent * e)
+{
+ QWidget::showEvent(e);
+ emit widgetOpened();
+}
+
+void FileSelector::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool FileSelector::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::selection || f == DCOP::setSelection ||
+ f == DCOP::clear;
+}
+
+QString FileSelector::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return m_lineEdit->text();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::selection:
+ return m_lineEdit->selectedText();
+ case DCOP::setSelection:
+ {
+ int f = m_lineEdit->text().find(args[0]);
+ if (f != -1)
+ m_lineEdit->setSelection(f, args[0].length());
+ break;
+ }
+ case DCOP::clear:
+ setWidgetText(QString::null);
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "fileselector.moc"
diff --git a/kommander/widgets/fileselector.h b/kommander/widgets/fileselector.h
new file mode 100644
index 00000000..9da6847d
--- /dev/null
+++ b/kommander/widgets/fileselector.h
@@ -0,0 +1,102 @@
+/***************************************************************************
+ fileselector.h - File selection widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_FILESELECTOR_H_
+#define _HAVE_FILESELECTOR_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qstring.h>
+#include <qwidget.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+
+class QBoxLayout;
+class KPushButton;
+class KLineEdit;
+
+class QShowEvent;
+class KOMMANDER_EXPORT FileSelector : public QWidget, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+ Q_PROPERTY(bool showEditor READ showEditor WRITE setShowEditor)
+ Q_PROPERTY(QString buttonCaption READ caption WRITE setCaption)
+ Q_PROPERTY(QString selectionFilter READ selectionFilter WRITE setSelectionFilter)
+ Q_PROPERTY(QString selectionCaption READ selectionCaption WRITE setSelectionCaption)
+ Q_PROPERTY(SelectionType selectionType READ selectionType WRITE setSelectionType)
+ Q_ENUMS(SelectionType)
+ Q_PROPERTY(bool selectionOpenMultiple READ selectionOpenMultiple WRITE setSelectionOpenMultiple)
+
+public:
+ FileSelector(QWidget *a_parent, const char *a_name);
+ ~FileSelector();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ enum SelectionType { Open, Save, Directory };
+ SelectionType selectionType() const;
+ void setSelectionType(SelectionType);
+ bool selectionOpenMultiple() const;
+ void setSelectionOpenMultiple(bool);
+ QString selectionFilter() const;
+ void setSelectionFilter(const QString&);
+ QString selectionCaption() const;
+ void setSelectionCaption(const QString&);
+ QString caption() const;
+ void setCaption(const QString&);
+ bool showEditor() const;
+ void setShowEditor(bool);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void makeSelection();
+ virtual void populate();
+
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void contextMenuEvent( QContextMenuEvent * e );
+
+ bool m_openMultiple;
+ QString m_caption;
+ QString m_filter;
+ SelectionType m_selectionType;
+ KLineEdit *m_lineEdit;
+ KPushButton *m_selectButton;
+ QBoxLayout *m_boxLayout;
+ void showEvent(QShowEvent *e);
+private:
+};
+
+#endif
diff --git a/kommander/widgets/fontdialog.cpp b/kommander/widgets/fontdialog.cpp
new file mode 100644
index 00000000..432b2d7f
--- /dev/null
+++ b/kommander/widgets/fontdialog.cpp
@@ -0,0 +1,158 @@
+//
+// C++ Implementation: FontDialog
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "fontdialog.h"
+
+#include "kommanderplugin.h"
+#include "specials.h"
+
+#include <kfontdialog.h>
+#include <kiconloader.h>
+#include <klocale.h>
+
+enum Functions {
+ FirstFunction = 139,
+ SetFont,
+ Family,
+ PointSize,
+ Bold,
+ Italic,
+ LastFunction
+};
+
+FontDialog::FontDialog(QWidget *parent, const char *name)
+ : QLabel(parent, name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ if (KommanderWidget::inEditor)
+ {
+ setPixmap(KGlobal::iconLoader()->loadIcon("kfontcombo", KIcon::NoGroup, KIcon::SizeMedium));
+ setFrameStyle(QFrame::Box | QFrame::Plain);
+ setLineWidth(1);
+ setFixedSize(pixmap()->size());
+ }
+ else
+ setHidden(true);
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(SetFont, "setFont(QString widget, QString family, int pointSize, bool bold, bool italic)",
+ i18n("Sets the default font for the dialog, by specifying the family, the size and other style options."), 2, 5);
+ KommanderPlugin::registerFunction(Family, "family(QString widget)",
+ i18n("Returns the font family."), 1);
+ KommanderPlugin::registerFunction(PointSize, "pointSize(QString widget)",
+ i18n("Returns the font size in point."), 1);
+ KommanderPlugin::registerFunction(Bold, "bold(QString widget)",
+ i18n("Returns true, if the font is bold."), 1);
+ KommanderPlugin::registerFunction(Italic, "italic(QString widget)",
+ i18n("Returns true, if the font is italic."), 1);
+}
+
+FontDialog::~FontDialog()
+{
+}
+
+QString FontDialog::currentState() const
+{
+ return QString("default");
+}
+
+bool FontDialog::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList FontDialog::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void FontDialog::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void FontDialog::setWidgetText(const QString& a_text)
+{
+ KommanderWidget::setAssociatedText(a_text);
+}
+
+void FontDialog::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString FontDialog::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void FontDialog::populate()
+{
+ setAssociatedText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+bool FontDialog::isFunctionSupported(int f)
+{
+ return (f > FirstFunction && f < LastFunction) || f == DCOP::execute;
+}
+
+QString FontDialog::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case SetFont:
+ {
+ m_font.setFamily(args[0]);
+ if (args[1].isEmpty())
+ m_font.setPointSize(12);
+ else
+ m_font.setPointSize(args[1].toInt());
+ m_font.setBold(args[2] == "1" || args[2].upper() == "TRUE");
+ m_font.setItalic(args[3] == "1" || args[3].upper() == "TRUE");
+ break;
+ }
+ case Family:
+ {
+ return m_font.family();
+ break;
+ }
+ case PointSize:
+ {
+ return QString::number(m_font.pointSize());
+ break;
+ }
+ case Bold:
+ {
+ return m_font.bold() ? "1" : "0";
+ }
+ case Italic:
+ {
+ return m_font.italic() ? "1" : "0";
+ }
+ case DCOP::execute:
+ {
+ int result = KFontDialog::getFont( m_font );
+ if ( result == KFontDialog::Accepted )
+ {
+ return m_font.toString();
+ }
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+
+#include "fontdialog.moc"
diff --git a/kommander/widgets/fontdialog.h b/kommander/widgets/fontdialog.h
new file mode 100644
index 00000000..38bf7830
--- /dev/null
+++ b/kommander/widgets/fontdialog.h
@@ -0,0 +1,50 @@
+//
+// C++ Interface: colordialog
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FONTDIALOG_H
+#define FONTDIALOG_H
+
+#include <qlabel.h>
+#include <kommanderwidget.h>
+
+#include <qfont.h>
+
+/**
+ @author Andras Mantia <amantia@kdewebdev.org>
+*/
+class FontDialog : public QLabel, public KommanderWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ FontDialog(QWidget *parent = 0, const char *name = 0);
+
+ ~FontDialog();
+
+ virtual bool isKommanderWidget() const;
+ virtual QString currentState() const;
+ virtual bool isFunctionSupported(int function);
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual QStringList associatedText() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void populate();
+
+ QFont m_font;
+};
+
+#endif
diff --git a/kommander/widgets/groupbox.cpp b/kommander/widgets/groupbox.cpp
new file mode 100644
index 00000000..29947eb1
--- /dev/null
+++ b/kommander/widgets/groupbox.cpp
@@ -0,0 +1,152 @@
+/***************************************************************************
+ groupbox.cpp - Groupbox widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qgroupbox.h>
+#include <qobjectlist.h>
+#include <klocale.h>
+
+/* OTHER INCLUDES */
+#include "kommanderplugin.h"
+#include <specials.h>
+#include "groupbox.h"
+
+
+GroupBox::GroupBox(QWidget *a_parent, const char *a_name)
+ : QGroupBox(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+}
+
+GroupBox::~GroupBox()
+{
+}
+
+QString GroupBox::currentState() const
+{
+ return QString("default");
+}
+
+bool GroupBox::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList GroupBox::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void GroupBox::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void GroupBox::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString GroupBox::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void GroupBox::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText( populationText() );
+//FIXME: setWidgetText( txt );
+}
+
+/* We need to keep track of all widgets created as a child of a groupbox, in order of creation. */
+void GroupBox::insertChild(QObject *a_child)
+{
+ m_childList.append(a_child);
+ QObject::insertChild(a_child);
+}
+
+void GroupBox::removeChild(QObject *a_child)
+{
+ m_childList.remove(a_child);
+ QObject::removeChild(a_child);
+}
+
+void GroupBox::showEvent( QShowEvent *e )
+{
+ QGroupBox::showEvent(e);
+ emit widgetOpened();
+}
+
+void GroupBox::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool GroupBox::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::geometry || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor;
+// || (f >= FirstFunction && f <= LastFunction);
+}
+
+QString GroupBox::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ {
+ QString text;
+ for (QObjectListIt it(m_childList); it.current(); ++it)
+ if (dynamic_cast<KommanderWidget*>(it.current()))
+ text += (dynamic_cast<KommanderWidget*>(it.current()))->evalAssociatedText();
+ return text;
+ }
+ case DCOP::setText:
+ setTitle(args[0]);
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+
+}
+
+#include "groupbox.moc"
diff --git a/kommander/widgets/groupbox.h b/kommander/widgets/groupbox.h
new file mode 100644
index 00000000..b7de75e1
--- /dev/null
+++ b/kommander/widgets/groupbox.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ groupbox.h - Groupbox widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_GROUPBOX_H_
+#define _HAVE_GROUPBOX_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qgroupbox.h>
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qstring.h>
+#include <qobjectlist.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT GroupBox : public QGroupBox, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ GroupBox(QWidget *a_parent, const char *a_name);
+ ~GroupBox();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual void insertChild(QObject*);
+ virtual void removeChild(QObject*);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString &);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ QObjectList m_childList;
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/konsole.cpp b/kommander/widgets/konsole.cpp
new file mode 100644
index 00000000..587f2318
--- /dev/null
+++ b/kommander/widgets/konsole.cpp
@@ -0,0 +1,153 @@
+/***************************************************************************
+ konsole.cpp - Widget that shows output of a process
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* QT INCLUDES */
+#include <qcursor.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qwidget.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <specials.h>
+#include "konsole.h"
+#include <myprocess.h>
+
+Konsole::Konsole(QWidget* a_parent, const char* a_name)
+ : KTextEdit(a_parent, a_name), KommanderWidget(this), mSeenEOL(false), mProcess(false)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+}
+
+Konsole::~Konsole()
+{
+}
+
+QString Konsole::currentState() const
+{
+ return QString("default");
+}
+
+bool Konsole::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList Konsole::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void Konsole::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void Konsole::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString Konsole::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void Konsole::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText(populationText());
+ setWidgetText(txt);
+}
+
+void Konsole::setWidgetText(const QString&)
+{
+// FIXME: emit widgetTextChanged(a_text);
+}
+
+void Konsole::execute()
+{
+ QString at = evalAssociatedText().stripWhiteSpace();
+ if (mProcess)
+ cancel();
+ mSeenEOL = false;
+ mProcess = new MyProcess(this);
+ mProcess->setBlocking(false);
+ connect(mProcess, SIGNAL(processExited(MyProcess*)), SLOT(processExited(MyProcess*)));
+ connect(mProcess, SIGNAL(processReceivedStdout(MyProcess*, char*, int)), SLOT(processReceivedStdout(MyProcess*, char*, int)));
+ setCursor(QCursor(Qt::WaitCursor));
+ mProcess->run(at);
+}
+
+void Konsole::cancel()
+{
+ if (!mProcess)
+ return;
+ mProcess->cancel();
+ processExited(mProcess);
+}
+
+
+void Konsole::processReceivedStdout(MyProcess*, char* buffer, int buflen)
+{
+ QString pBuf = QString::fromLocal8Bit(buffer, buflen);
+ if (mSeenEOL)
+ pBuf = '\n' + pBuf;
+ mSeenEOL = pBuf[pBuf.length()-1] == '\n';
+ if (mSeenEOL)
+ pBuf = pBuf.left(pBuf.length()-1);
+ insert(pBuf);
+}
+
+void Konsole::processExited(MyProcess*)
+{
+ unsetCursor();
+ delete mProcess;
+ mProcess = 0;
+ emit finished();
+}
+
+bool Konsole::isFunctionSupported(int f)
+{
+ return f == DCOP::setText || f == DCOP::text || f == DCOP::clear || f == DCOP::execute || f == DCOP::cancel;
+}
+
+QString Konsole::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::text:
+ return text();
+ case DCOP::clear:
+ clear();
+ break;
+ case DCOP::execute:
+ execute();
+ break;
+ case DCOP::cancel:
+ cancel();
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "konsole.moc"
diff --git a/kommander/widgets/konsole.h b/kommander/widgets/konsole.h
new file mode 100644
index 00000000..a031adef
--- /dev/null
+++ b/kommander/widgets/konsole.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ konsole.h - Widget that shows output of a process
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef _HAVE_KONSOLE_H_
+#define _HAVE_KONSOLE_H_
+
+/* KDE INCLUDES */
+#include <ktextedit.h>
+
+/* QT INCLUDES */
+#include <qobject.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+
+class QWidget;
+class MyProcess;
+
+class KOMMANDER_EXPORT Konsole : public KTextEdit, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_OVERRIDE(bool readOnly DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+
+ public:
+ Konsole(QWidget *a_parent, const char *a_name);
+ ~Konsole();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+ public slots:
+ virtual void populate();
+ virtual void setWidgetText(const QString &);
+ // Execute current script
+ virtual void execute();
+ // Stop executing current script
+ virtual void cancel();
+ // Process has ended
+ virtual void processReceivedStdout(MyProcess*, char* a_buffer, int a_len);
+ virtual void processExited(MyProcess* p);
+ signals:
+ void finished();
+ protected:
+ // Whether last line of output was ended with EOL
+ bool mSeenEOL;
+ // Current process or NULL if there is no process running
+ MyProcess* mProcess;
+};
+
+#endif
diff --git a/kommander/widgets/label.cpp b/kommander/widgets/label.cpp
new file mode 100644
index 00000000..a9a24e3b
--- /dev/null
+++ b/kommander/widgets/label.cpp
@@ -0,0 +1,127 @@
+/***************************************************************************
+ label.cpp - label widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <specials.h>
+#include "label.h"
+
+Label::Label(QWidget *a_parent, const char *a_name)
+ : QLabel(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ if (KommanderWidget::inEditor && a_name)
+ setText(a_name);
+}
+
+Label::~Label()
+{
+}
+
+QString Label::currentState() const
+{
+ return QString("default");
+}
+
+bool Label::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList Label::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void Label::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void Label::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString Label::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void Label::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText(populationText()));
+}
+
+void Label::setWidgetText(const QString& a_text)
+{
+ setText(a_text);
+}
+
+void Label::showEvent(QShowEvent *e)
+{
+ QLabel::showEvent(e);
+ emit widgetOpened();
+}
+
+bool Label::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::clear || f == DCOP::geometry || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor;
+}
+
+QString Label::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return text();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::clear:
+ setWidgetText("");
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "label.moc"
diff --git a/kommander/widgets/label.h b/kommander/widgets/label.h
new file mode 100644
index 00000000..216998db
--- /dev/null
+++ b/kommander/widgets/label.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+ label.h - label widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_LABEL_H_
+#define _HAVE_LABEL_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <qlabel.h>
+
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT Label : public QLabel, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ Label(QWidget *a_parent, const char *a_name);
+ ~Label();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+protected:
+ void showEvent(QShowEvent *e);
+private:
+};
+
+#endif
diff --git a/kommander/widgets/lineedit.cpp b/kommander/widgets/lineedit.cpp
new file mode 100644
index 00000000..d243660a
--- /dev/null
+++ b/kommander/widgets/lineedit.cpp
@@ -0,0 +1,182 @@
+/***************************************************************************
+ lineedit.cpp - Lineedit widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* QT INCLUDES */
+#include <qlayout.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "lineedit.h"
+#include <klocale.h>
+#include <kommanderplugin.h>
+
+enum functions {
+ FirstFunction = 440,
+ LE_clearModified,
+ LastFunction
+};
+
+LineEdit::LineEdit(QWidget *a_parent, const char *a_name)
+ : KLineEdit(a_parent, a_name), KommanderWidget((QObject *)this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+
+ connect(this, SIGNAL(textChanged(const QString &)), this,
+ SIGNAL(widgetTextChanged(const QString &)));
+
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(LE_clearModified, "clearModified(QString widget)", i18n("Clear widget modified status."), 1);
+}
+
+void LineEdit::showEvent(QShowEvent *e)
+{
+ QLineEdit::showEvent(e);
+ emit widgetOpened();
+}
+
+void LineEdit::focusInEvent( QFocusEvent * e)
+{
+ QLineEdit::focusInEvent(e);
+ emit gotFocus();
+}
+
+void LineEdit::focusOutEvent( QFocusEvent * e)
+{
+ QLineEdit::focusOutEvent(e);
+ emit lostFocus();
+}
+
+QString LineEdit::currentState() const
+{
+ return QString("default");
+}
+
+LineEdit::~LineEdit()
+{
+}
+
+bool LineEdit::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList LineEdit::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void LineEdit::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void LineEdit::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString LineEdit::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void LineEdit::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText(populationText());
+ setWidgetText(txt);
+}
+
+void LineEdit::setSelectedWidgetText(const QString& a_text)
+{
+ insert(a_text);
+}
+
+void LineEdit::setWidgetText(const QString& a_text)
+{
+ setText(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void LineEdit::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool LineEdit::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::selection || f == DCOP::setSelection ||
+ f == DCOP::clear || f == DCOP::setEditable || f == DCOP::geometry || f == DCOP::hasFocus || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor || f == DCOP::isModified || (f >= FirstFunction && f <= LastFunction) ;
+}
+
+QString LineEdit::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return text();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::selection:
+ return selectedText();
+ case DCOP::setSelection:
+ setSelectedWidgetText(args[0]);
+ break;
+ case DCOP::clear:
+ setWidgetText("");
+ break;
+ case DCOP::setEditable:
+ setReadOnly(args[0] == "false" || args[0] == "0");
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::hasFocus:
+ return QString::number(this->hasFocus());
+ break;
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ case DCOP::isModified:
+ return isModified() ? "1" : "0";
+ break;
+ case LE_clearModified:
+ this->clearModified();
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+
+#include "lineedit.moc"
diff --git a/kommander/widgets/lineedit.h b/kommander/widgets/lineedit.h
new file mode 100644
index 00000000..8b4d403a
--- /dev/null
+++ b/kommander/widgets/lineedit.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ lineedit.h - Lineedit widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_LINEEDIT_H_
+#define _HAVE_LINEEDIT_H_
+
+/* KDE INCLUDES */
+#include <klineedit.h>
+
+/* QT INCLUDES */
+#include <qtextedit.h>
+#include <qstringlist.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+
+#include <kommander_export.h>
+class QShowEvent;
+
+class KOMMANDER_EXPORT LineEdit : public KLineEdit, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ LineEdit(QWidget *, const char *);
+ virtual ~LineEdit();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void setSelectedWidgetText(const QString &a_text);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString &);
+ void contextMenuRequested(int xpos, int ypos);
+ void gotFocus();
+ void lostFocus();
+protected:
+ virtual void showEvent( QShowEvent *e );
+ void contextMenuEvent( QContextMenuEvent * e );
+ void focusInEvent( QFocusEvent* e);
+ void focusOutEvent( QFocusEvent* e);
+private:
+};
+
+#endif
diff --git a/kommander/widgets/listbox.cpp b/kommander/widgets/listbox.cpp
new file mode 100644
index 00000000..19b1b540
--- /dev/null
+++ b/kommander/widgets/listbox.cpp
@@ -0,0 +1,225 @@
+/***************************************************************************
+ listbox.cpp - Listbox widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+#include <kglobal.h>
+#include <kiconloader.h>
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <specials.h>
+#include "listbox.h"
+
+ListBox::ListBox(QWidget *a_parent, const char *a_name)
+ : KListBox(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+}
+
+ListBox::~ListBox()
+{
+}
+
+QString ListBox::currentState() const
+{
+ return QString("default");
+}
+
+bool ListBox::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList ListBox::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void ListBox::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void ListBox::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString ListBox::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void ListBox::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText(populationText());
+ setWidgetText(txt);
+}
+
+void ListBox::setWidgetText(const QString& a_text)
+{
+ clear();
+ insertStringList(QStringList::split("\n", a_text));
+ emit widgetTextChanged(a_text);
+}
+
+void ListBox::showEvent(QShowEvent *e)
+{
+ QListBox::showEvent(e);
+ emit widgetOpened();
+}
+
+bool ListBox::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::selection || f == DCOP::setSelection ||
+ f == DCOP::insertItems || f == DCOP::insertItem || f == DCOP::removeItem || f == DCOP::clear ||
+ f == DCOP::currentItem || f == DCOP::setCurrentItem || f == DCOP::item || f == DCOP::addUniqueItem ||
+ f == DCOP::findItem || f == DCOP::setPixmap || f == DCOP::count || f == DCOP::geometry || f == DCOP::hasFocus || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor;
+}
+
+void ListBox::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+
+QString ListBox::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::selection:
+ {
+ if (selectionMode() == Single)
+ return currentText();
+ QString value;
+ for (uint i=0; i<count(); i++)
+ if (isSelected(i))
+ value += (value.length() ? "\n" : "") + item(i)->text();
+ return value;
+ }
+ case DCOP::setSelection:
+ {
+ QListBoxItem* found = findItem(args[0], Qt::ExactMatch);
+ if (found)
+ setCurrentItem(index(found));
+ break;
+ }
+ case DCOP::insertItems:
+ insertStringList(QStringList::split("\n", args[0]), args[1].toInt());
+ break;
+ case DCOP::insertItem:
+ insertItem(args[0], args[1].toInt());
+ break;
+ case DCOP::removeItem:
+ removeItem(args[0].toInt());
+ break;
+ case DCOP::clear:
+ clear();
+ break;
+ case DCOP::count:
+ return QString::number(count());
+ case DCOP::currentItem:
+ return QString::number(currentItem());
+ case DCOP::setCurrentItem:
+ {
+ int index = args[0].toInt();
+ if (index < (int)count())
+ setCurrentItem(index);
+ break;
+ }
+ case DCOP::item:
+ {
+ int index = args[0].toInt();
+ if (index >= 0 && index < (int)count())
+ return item(index)->text();
+ else
+ return QString();
+ }
+ case DCOP::addUniqueItem:
+ if (!findItem(args[0], Qt::ExactMatch))
+ insertItem(args[0]);
+ break;
+ case DCOP::findItem:
+ {
+ QListBoxItem* found = findItem(args[0], Qt::ExactMatch);
+ if (!found) found = findItem(args[0], Qt::BeginsWith);
+ if (!found) found = findItem(args[0], Qt::Contains);
+ if (found)
+ return QString::number(index(found));
+ else return QString::number(-1);
+ break;
+ }
+ case DCOP::setPixmap:
+ {
+ QPixmap pixmap = KGlobal::iconLoader()->loadIcon(args[0], KIcon::Small);
+ if (pixmap.isNull())
+ pixmap.load(args[0]);
+ int index = args[1].toInt();
+ if (index == -1)
+ {
+ for (uint i=0; i<count(); i++)
+ changeItem(pixmap, text(i), i);
+ }
+ else if (index < (int)count())
+ changeItem(pixmap, text(index), index);
+ break;
+ }
+ case DCOP::text:
+ {
+ QStringList strings;
+ for(uint i=0; i < count() ; ++i)
+ strings += item(i)->text();
+ return strings.join("\n");
+ }
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::hasFocus:
+ return QString::number(this->hasFocus());
+ break;
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "listbox.moc"
diff --git a/kommander/widgets/listbox.h b/kommander/widgets/listbox.h
new file mode 100644
index 00000000..516e9f86
--- /dev/null
+++ b/kommander/widgets/listbox.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+ listbox.h - Listbox widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_LISTBOX_H_
+#define _HAVE_LISTBOX_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <klistbox.h>
+#include <kommander_export.h>
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT ListBox : public KListBox, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ ListBox(QWidget *a_parent, const char *a_name);
+ ~ListBox();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/pixmaplabel.cpp b/kommander/widgets/pixmaplabel.cpp
new file mode 100644
index 00000000..7d7095e3
--- /dev/null
+++ b/kommander/widgets/pixmaplabel.cpp
@@ -0,0 +1,132 @@
+/***************************************************************************
+ pixmaplabel.cpp - Pixmap label widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qpixmap.h>
+
+/* KDE INCLUDES */
+#include <kglobal.h>
+#include <kiconloader.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <specials.h>
+#include "pixmaplabel.h"
+
+PixmapLabel::PixmapLabel(QWidget *a_parent, const char *a_name)
+ : QLabel(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ if (KommanderWidget::inEditor)
+ setPixmap(KGlobal::iconLoader()->loadIcon("tux", KIcon::NoGroup, 128));
+ setAutoResize(false);
+}
+
+PixmapLabel::~PixmapLabel()
+{
+}
+
+QString PixmapLabel::currentState() const
+{
+ return QString("default");
+}
+
+bool PixmapLabel::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList PixmapLabel::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void PixmapLabel::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void PixmapLabel::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString PixmapLabel::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void PixmapLabel::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText(populationText()));
+}
+
+void PixmapLabel::setWidgetText(const QString& a_text)
+{
+ QPixmap pixmap;
+ if (pixmap.load(a_text))
+ setPixmap(pixmap);
+}
+
+void PixmapLabel::showEvent(QShowEvent *e)
+{
+ QLabel::showEvent(e);
+ emit widgetOpened();
+}
+
+void PixmapLabel::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool PixmapLabel::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::clear || f == DCOP::geometry;
+}
+
+QString PixmapLabel::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::clear:
+ setPixmap(QPixmap());
+ break;
+ case DCOP::text:
+ return text();
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "pixmaplabel.moc"
diff --git a/kommander/widgets/pixmaplabel.h b/kommander/widgets/pixmaplabel.h
new file mode 100644
index 00000000..a932ad1e
--- /dev/null
+++ b/kommander/widgets/pixmaplabel.h
@@ -0,0 +1,66 @@
+/***************************************************************************
+ pixmaplabel.h - Pixmap label widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_PIXMAPLABEL_H_
+#define _HAVE_PIXMAPLABEL_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <qlabel.h>
+
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT PixmapLabel : public QLabel, public KommanderWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ PixmapLabel(QWidget *a_parent, const char *a_name);
+ ~PixmapLabel();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/pixmaps/textbold.xpm b/kommander/widgets/pixmaps/textbold.xpm
new file mode 100644
index 00000000..6787a461
--- /dev/null
+++ b/kommander/widgets/pixmaps/textbold.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static const char * const bold_xpm[] = {
+"22 22 2 1",
+" c None",
+". c #000000",
+" ",
+" ",
+" ",
+" ",
+" ......... ",
+" ... ... ",
+" ... ... ",
+" ... ... ",
+" ... ... ",
+" ... ... ",
+" ........ ",
+" ... .... ",
+" ... .... ",
+" ... ... ",
+" ... ... ",
+" ... ... ",
+" ... ... ",
+" .......... ",
+" ",
+" ",
+" ",
+" "};
diff --git a/kommander/widgets/pixmaps/textcenter.xpm b/kommander/widgets/pixmaps/textcenter.xpm
new file mode 100644
index 00000000..59eeb565
--- /dev/null
+++ b/kommander/widgets/pixmaps/textcenter.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static const char * const center_xpm[] = {
+"22 22 2 1",
+" c None",
+". c #000000",
+" ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ",
+" "};
diff --git a/kommander/widgets/pixmaps/textitalic.xpm b/kommander/widgets/pixmaps/textitalic.xpm
new file mode 100644
index 00000000..4cbee92c
--- /dev/null
+++ b/kommander/widgets/pixmaps/textitalic.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static const char * const italic_xpm[] = {
+"22 22 2 1",
+" c None",
+". c #000000",
+" ",
+" ",
+" ",
+" ",
+" ..... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ... ",
+" ..... ",
+" ",
+" ",
+" ",
+" "};
diff --git a/kommander/widgets/pixmaps/textleft.xpm b/kommander/widgets/pixmaps/textleft.xpm
new file mode 100644
index 00000000..129a93a4
--- /dev/null
+++ b/kommander/widgets/pixmaps/textleft.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static const char * const left_xpm[] = {
+"22 22 2 1",
+" c None",
+". c #000000",
+" ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ",
+" "};
diff --git a/kommander/widgets/pixmaps/textright.xpm b/kommander/widgets/pixmaps/textright.xpm
new file mode 100644
index 00000000..71544c87
--- /dev/null
+++ b/kommander/widgets/pixmaps/textright.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static const char * const right_xpm[] = {
+"22 22 2 1",
+" c None",
+". c #000000",
+" ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ............. ",
+" ",
+" ................. ",
+" ",
+" ",
+" "};
diff --git a/kommander/widgets/pixmaps/textunder.xpm b/kommander/widgets/pixmaps/textunder.xpm
new file mode 100644
index 00000000..37882c45
--- /dev/null
+++ b/kommander/widgets/pixmaps/textunder.xpm
@@ -0,0 +1,27 @@
+/* XPM */
+static const char * const under_xpm[] = {
+"22 22 2 1",
+" c None",
+". c #000000",
+" ",
+" ",
+" ",
+" ",
+" ..... .... ",
+" ... . ",
+" ... . ",
+" ... . ",
+" ... . ",
+" ... . ",
+" ... . ",
+" ... . ",
+" ... . ",
+" ... . ",
+" ... .. ",
+" ... .. ",
+" ...... ",
+" ",
+" ............ ",
+" ",
+" ",
+" "};
diff --git a/kommander/widgets/plugin.cpp b/kommander/widgets/plugin.cpp
new file mode 100644
index 00000000..9319bc00
--- /dev/null
+++ b/kommander/widgets/plugin.cpp
@@ -0,0 +1,138 @@
+/***************************************************************************
+ plugins.cpp - Kommander Plugins
+ -------------------
+ copyright : (C) 2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004-2006 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#include <kommanderplugin.h>
+#include <kiconloader.h>
+
+/* WIDGET INCLUDES */
+#include "buttongroup.h"
+#include "checkbox.h"
+#include "closebutton.h"
+#include "combobox.h"
+#include "datepicker.h"
+#include "dialog.h"
+#include "execbutton.h"
+#include "fileselector.h"
+#include "groupbox.h"
+#include "konsole.h"
+#include "label.h"
+#include "lineedit.h"
+#include "listbox.h"
+#include "pixmaplabel.h"
+#include "progressbar.h"
+#include "radiobutton.h"
+#include "richtexteditor.h"
+#include "scriptobject.h"
+#include "slider.h"
+#include "spinboxint.h"
+#include "statusbar.h"
+#include "subdialog.h"
+#include "tabwidget.h"
+#include "table.h"
+#include "textbrowser.h"
+#include "textedit.h"
+#include "textedit.h"
+#include "timer.h"
+#include "treewidget.h"
+#include "toolbox.h"
+#include "wizard.h"
+#include "popupmenu.h"
+#include "fontdialog.h"
+#include "aboutdialog.h"
+
+class KomStdPlugin : public KommanderPlugin
+{
+public:
+ KomStdPlugin();
+ virtual QWidget *create( const QString &key, QWidget *parent = 0, const char *name = 0 );
+};
+
+KomStdPlugin::KomStdPlugin()
+{
+ const char *group = "Kommander";
+ addWidget("Label", group, "", 0);
+ addWidget("PixmapLabel", group, "", 0);
+ addWidget("LineEdit", group, "", 0);
+ addWidget("Dialog", group, "", 0);
+ addWidget("ExecButton", group, "", 0);
+ addWidget("CloseButton", group, "", 0);
+ addWidget("Konsole", group, "", 0);
+ addWidget("TextEdit", group, "", 0);
+ addWidget("RadioButton", group, "", 0);
+ // addWidget("", group, "");
+ addWidget("GroupBox", group, "", 0);
+ addWidget("ButtonGroup", group, "", 0);
+ addWidget("CheckBox", group, "", 0);
+ addWidget("ComboBox", group, "", 0);
+ addWidget("SpinBoxInt", group, "", 0);
+ // addWidget("Wizard", group, "");
+ addWidget("TabWidget", group, "", 0);
+ addWidget("ToolBox", group, "", new QIconSet(KGlobal::iconLoader()->loadIcon("toolbox", KIcon::NoGroup, KIcon::SizeMedium)), "", true);
+ // addWidget("SubDialog", group, "");
+ addWidget("ListBox", group, "", 0);
+ addWidget("Timer", group, "", 0);
+ addWidget("ScriptObject", group, "", 0);
+ addWidget("RichTextEditor", group, "", 0);
+ addWidget("TreeWidget", group, "", 0);
+ addWidget("StatusBar", group, "", 0);
+ addWidget("TextBrowser", group, "", 0);
+ addWidget("Slider", group, "", 0);
+ addWidget("Table", group, "", 0);
+ addWidget("DatePicker", group, "", 0);
+ addWidget("PopupMenu", group, "", new QIconSet(KGlobal::iconLoader()->loadIcon("contents", KIcon::NoGroup, KIcon::SizeMedium)));
+ addWidget("FontDialog", group, "", new QIconSet(KGlobal::iconLoader()->loadIcon("kfontcombo", KIcon::NoGroup, KIcon::SizeMedium)));
+ addWidget("AboutDialog", group, "", new QIconSet(KGlobal::iconLoader()->loadIcon("kommander", KIcon::NoGroup, KIcon::SizeMedium)));
+}
+
+QWidget *KomStdPlugin::create( const QString &key, QWidget *parent, const char *name )
+{
+ if (key == "ButtonGroup") return new ButtonGroup(parent, name);
+ else if (key == "CheckBox") return new CheckBox(parent, name);
+ else if (key == "CloseButton") return new CloseButton(parent, name);
+ else if (key == "ComboBox") return new ComboBox(parent, name);
+ else if (key == "Dialog") return new Dialog(parent, name);
+ else if (key == "ExecButton") return new ExecButton(parent, name);
+ else if (key == "FileSelector") return new FileSelector(parent, name);
+ else if (key == "GroupBox") return new GroupBox(parent, name);
+ else if (key == "Konsole") return new Konsole(parent, name);
+ else if (key == "Label") return new Label(parent, name);
+ else if (key == "LineEdit") return new LineEdit(parent, name);
+ else if (key == "ListBox") return new ListBox(parent, name);
+ else if (key == "PixmapLabel") return new PixmapLabel(parent, name);
+ else if (key == "ProgressBar") return new ProgressBar(parent, name);
+ else if (key == "RadioButton") return new RadioButton(parent, name);
+ else if (key == "RichTextEditor") return new RichTextEditor(parent, name);
+ else if (key == "ScriptObject") return new ScriptObject(parent, name);
+ else if (key == "Slider") return new Slider(parent, name);
+ else if (key == "SpinBoxInt") return new SpinBoxInt(parent, name);
+ else if (key == "StatusBar") return new StatusBar(parent, name);
+ else if (key == "SubDialog") return new SubDialog(parent, name);
+ else if (key == "Table") return new Table(parent, name);
+ else if (key == "TabWidget") return new TabWidget(parent, name);
+ else if (key == "ToolBox") return new ToolBox(parent, name);
+ else if (key == "TextBrowser") return new TextBrowser(parent, name);
+ else if (key == "TextEdit") return new TextEdit(parent, name);
+ else if (key == "Timer") return new Timer(parent, name);
+ else if (key == "TreeWidget") return new TreeWidget(parent, name);
+ else if (key == "Wizard") return new Wizard(parent, name);
+ else if (key == "DatePicker") return new DatePicker(parent, name);
+ else if (key == "PopupMenu") return new PopupMenu(parent, name);
+ else if (key == "FontDialog") return new FontDialog(parent, name);
+ else if (key == "AboutDialog") return new AboutDialog(parent, name);
+ else return 0;
+}
+
+KOMMANDER_EXPORT_PLUGIN(KomStdPlugin)
diff --git a/kommander/widgets/popupmenu.cpp b/kommander/widgets/popupmenu.cpp
new file mode 100644
index 00000000..696bd0be
--- /dev/null
+++ b/kommander/widgets/popupmenu.cpp
@@ -0,0 +1,246 @@
+//
+// C++ Implementation: popupmenu
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "popupmenu.h"
+#include "specials.h"
+
+#include <qcursor.h>
+
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kpopupmenu.h>
+#include <kommanderplugin.h>
+
+#define INSERTMENUITEM 100
+#define INSERTSEPARATOR 101
+#define CHANGEMENUITEM 102
+#define SETITEMENABLED 103
+#define ITEMENABLED 104
+#define SETITEMVISIBLE 105
+#define SETITEMCHECKED 106
+#define ITEMVISIBLE 107
+#define ITEMCHECKED 108
+#define INSERTSUBMENU 109
+#define LAST_FUNCTION INSERTSUBMENU
+
+PopupMenu::PopupMenu(QWidget *parent, const char *name)
+ : QLabel(parent, name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ if (KommanderWidget::inEditor)
+ {
+ setPixmap(KGlobal::iconLoader()->loadIcon("contents", KIcon::NoGroup, KIcon::SizeMedium));
+ setFrameStyle(QFrame::Box | QFrame::Plain);
+ setLineWidth(1);
+ setFixedSize(pixmap()->size());
+ }
+ else
+ setHidden(true);
+
+ m_menu = new KPopupMenu(this);
+ connect(m_menu, SIGNAL(activated(int)), this, SLOT(slotMenuItemActivated(int)));
+
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(INSERTMENUITEM, "insertMenuItem(QString widget, QString text, QString executeWidget, int index, QString icon)", i18n("Insert an item into the popup menu. The executeWidget's execute method will be run when this item is selected. Returns the id of the inserted item. Use -1 for index to insert to the end. The icon is optional."), 4, 5);
+ KommanderPlugin::registerFunction(INSERTSEPARATOR, "insertSeparator(QString widget, int index)", i18n("Insert a separator item into the popup menu. Use -1 for index to insert to the end."), 2);
+ KommanderPlugin::registerFunction(CHANGEMENUITEM, "changeMenuItem(QString widget, int id, QString text, QString executeWidget, QString icon)", i18n("Change an item specified by id in the popup menu. The executeWidget's execute method will be run when this item is selected."), 4, 5);
+ KommanderPlugin::registerFunction(SETITEMENABLED, "setItemEnabled(QString widget, int id, bool enable)", i18n("Enable the item specified by id in the popup menu."), 3);
+ KommanderPlugin::registerFunction(ITEMENABLED, "itemEnabled(QString widget, int id)", i18n("Check if the item specified by id is enabled."), 2);
+ KommanderPlugin::registerFunction(SETITEMVISIBLE, "setItemVisible(QString widget, int id, bool enable)", i18n("Make the item specified by id visible."), 3);
+ KommanderPlugin::registerFunction(SETITEMCHECKED, "setItemChecked(QString widget, int id, bool enable)", i18n("Apply checked status for the item specified by id."), 3);
+ KommanderPlugin::registerFunction(ITEMVISIBLE, "itemVisible(QString widget, int id)", i18n("Check if the item specified by id is visible."), 2);
+ KommanderPlugin::registerFunction(ITEMCHECKED, "itemChecked(QString widget, int id)", i18n("Verify if the item specified by id is checked."), 2);
+ KommanderPlugin::registerFunction(INSERTSUBMENU, "insertSubmenu(QString widget, QString text, QString menuWidget, int index, QString icon)", i18n("Insert submenu widget into the popup menu. Use -1 for index to insert to the end. The icon is optional."), 4, 5);
+}
+
+
+PopupMenu::~PopupMenu()
+{
+ delete m_menu;
+}
+
+QString PopupMenu::currentState() const
+{
+ return QString("default");
+}
+
+bool PopupMenu::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList PopupMenu::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void PopupMenu::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void PopupMenu::setWidgetText(const QString& a_text)
+{
+ KommanderWidget::setAssociatedText(a_text);
+}
+
+void PopupMenu::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString PopupMenu::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void PopupMenu::popup(int x, int y)
+{
+ m_menu->exec(QPoint(x, y));
+}
+
+void PopupMenu::slotMenuItemActivated(int id)
+{
+ QString widget = m_associations[id];
+ KommanderWidget::evalAssociatedText(QString("#!kommander\n%1.execute(%2)").arg(widget).arg(id));
+}
+
+void PopupMenu::populate()
+{
+ setAssociatedText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+QString PopupMenu::insertSubmenu(const QString& title, const QString &menuWidget, int index, const QString& icon)
+{
+ KommanderWidget *w = widgetByName(menuWidget);
+ if (dynamic_cast<PopupMenu*>(w))
+ {
+ if (icon.isEmpty())
+ return QString::number(m_menu->insertItem(title, dynamic_cast<PopupMenu*>(w)->menu(), index));
+ else
+ return QString::number( m_menu->insertItem(KGlobal::iconLoader()->loadIcon(icon, KIcon::NoGroup, KIcon::SizeMedium), title, dynamic_cast<PopupMenu*>(w)->menu(), index));
+ }
+ return QString();
+}
+
+
+bool PopupMenu::isFunctionSupported(int f)
+{
+ return f == DCOP::clear || f == DCOP::execute || f == DCOP::item || (f >= INSERTMENUITEM && f <= LAST_FUNCTION) || f == DCOP::count || f == DCOP::geometry;
+}
+
+QString PopupMenu::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::clear:
+ m_menu->clear();
+ m_associations.clear();
+ break;
+ case DCOP::execute:
+ m_params = args;
+ evalAssociatedText();
+ break;
+ case INSERTMENUITEM:
+ {
+ uint index = args[2].toInt();
+ int id = -1;
+ if (args[3].isEmpty())
+ id = m_menu->insertItem(args[0], index);
+ else
+ id = m_menu->insertItem(KGlobal::iconLoader()->loadIcon(args[3], KIcon::NoGroup, KIcon::SizeMedium), args[0], index);
+ m_associations[id] = args[1];
+ return QString::number(id);
+ break;
+ }
+ case INSERTSUBMENU:
+ {
+ return insertSubmenu(args[0], args[1], args[2].toInt(), args[3]);
+ break;
+ }
+ case CHANGEMENUITEM:
+ {
+ uint id = args[0].toInt();
+ if (args[3].isEmpty())
+ m_menu->changeItem(id, args[1]);
+ else
+ m_menu->changeItem(id, KGlobal::iconLoader()->loadIcon(args[3], KIcon::NoGroup, KIcon::SizeMedium), args[1]);
+ m_associations[id] = args[2];
+ break;
+ }
+ case INSERTSEPARATOR:
+ {
+ uint index = args[0].toInt();
+ m_menu->insertSeparator(index);
+ }
+ case SETITEMENABLED:
+ {
+ uint id = args[0].toInt();
+ m_menu->setItemEnabled(id, args[1] == "true" || args[1] == "1" ? true : false);
+ break;
+ }
+ case ITEMENABLED:
+ {
+ uint id = args[0].toInt();
+ return m_menu->isItemEnabled(id) ? "1" : "0";
+ break;
+ }
+ case SETITEMVISIBLE:
+ {
+ uint id = args[0].toInt();
+ m_menu->setItemVisible(id, args[1] == "true" || args[1] == "1" ? true : false);
+ break;
+ }
+ case SETITEMCHECKED:
+ {
+ uint id = args[0].toInt();
+ m_menu->setItemChecked(id, args[1] == "true" || args[1] == "1" ? true : false);
+ break;
+ }
+ case ITEMVISIBLE:
+ {
+ uint id = args[0].toInt();
+ return m_menu->isItemVisible(id) ? "1" : "0";
+ break;
+ }
+ case ITEMCHECKED:
+ {
+ uint id = args[0].toInt();
+ return m_menu->isItemChecked(id) ? "1" : "0";
+ break;
+ }
+ case DCOP::item:
+ {
+ uint index = args[0].toInt();
+ return index < m_params.count() ? m_params[index] : QString::null;
+ break;
+ }
+ case DCOP::count:
+ return QString::number(m_menu->count());
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+
+#include "popupmenu.moc"
diff --git a/kommander/widgets/popupmenu.h b/kommander/widgets/popupmenu.h
new file mode 100644
index 00000000..f2db18a6
--- /dev/null
+++ b/kommander/widgets/popupmenu.h
@@ -0,0 +1,61 @@
+//
+// C++ Interface: popupmenu
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef POPUPMENU_H
+#define POPUPMENU_H
+
+#include <qlabel.h>
+#include <qmap.h>
+#include <kommanderwidget.h>
+
+
+class KPopupMenu;
+
+/**
+ @author Andras Mantia <amantia@kdewebdev.org>
+*/
+class PopupMenu : public QLabel, public KommanderWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ PopupMenu(QWidget *parent = 0, const char *name = 0);
+ ~PopupMenu();
+
+ virtual bool isKommanderWidget() const;
+ virtual QString currentState() const;
+ virtual bool isFunctionSupported(int function);
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual QStringList associatedText() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+ KPopupMenu *menu() {return m_menu;}
+
+public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void populate();
+ void popup(int x, int y);
+
+private slots:
+ void slotMenuItemActivated(int id);
+
+private:
+ QString insertSubmenu(const QString& title, const QString &menuWidget, int index, const QString& icon);
+
+ KPopupMenu *m_menu;
+ QMap<int, QString> m_associations;
+ QStringList m_params;
+};
+
+#endif
diff --git a/kommander/widgets/progressbar.cpp b/kommander/widgets/progressbar.cpp
new file mode 100644
index 00000000..874601f5
--- /dev/null
+++ b/kommander/widgets/progressbar.cpp
@@ -0,0 +1,144 @@
+/***************************************************************************
+ progressbar.cpp - ProgressBar widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+#include <klocale.h>
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "progressbar.h"
+#include "kommanderplugin.h"
+
+enum Functions {
+ FirstFunction = 585,
+ PB_setHighlightColor,
+ PB_setHightlightTextColor,
+ LastFunction
+};
+
+ProgressBar::ProgressBar(QWidget *a_parent, const char *a_name)
+ : KProgress(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(PB_setHighlightColor, "setBarColor(QString widget, QString Color)", i18n("Sets the ProgresBar color"), 2);
+ KommanderPlugin::registerFunction(PB_setHightlightTextColor, "setBarTextColor(QString widget, QString Color)", i18n("Sets the ProgresBar text color"), 2);
+}
+
+ProgressBar::~ProgressBar()
+{
+}
+
+QString ProgressBar::currentState() const
+{
+ return QString("default");
+}
+
+bool ProgressBar::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList ProgressBar::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void ProgressBar::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void ProgressBar::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString ProgressBar::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void ProgressBar::populate()
+{
+ setProgress(KommanderWidget::evalAssociatedText(populationText()).toUInt());
+}
+
+void ProgressBar::showEvent(QShowEvent *e)
+{
+ QProgressBar::showEvent(e);
+ emit widgetOpened();
+}
+
+bool ProgressBar::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::clear || f == DCOP::setMaximum || f == DCOP::geometry || (f > FirstFunction && f < LastFunction);
+}
+
+QString ProgressBar::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return QString::number(progress());
+ case DCOP::setText:
+ setProgress(args[0].toUInt());
+ break;
+ case DCOP::clear:
+ setProgress(0);
+ break;
+ case DCOP::setMaximum:
+ setTotalSteps(args[0].toUInt());
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case PB_setHighlightColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ QPalette p = this->palette();
+ p.setColor(QPalette::Active, QColorGroup::Highlight, color);
+ this->setPalette( p, TRUE );
+ break;
+ }
+ case PB_setHightlightTextColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ QPalette p = this->palette();
+ p.setColor(QPalette::Active, QColorGroup::HighlightedText, color);
+ this->setPalette( p, TRUE );
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "progressbar.moc"
diff --git a/kommander/widgets/progressbar.h b/kommander/widgets/progressbar.h
new file mode 100644
index 00000000..b4aa3d94
--- /dev/null
+++ b/kommander/widgets/progressbar.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+ progressbar.h - ProgressBar widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_PROGRESSBAR_H_
+#define _HAVE_PROGRESSBAR_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kprogress.h>
+#include <kommanderwidget.h>
+
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT ProgressBar: public KProgress, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+
+public:
+ ProgressBar(QWidget *a_parent, const char *a_name);
+ ~ProgressBar();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void populate();
+signals:
+ void widgetOpened();
+protected:
+ void showEvent(QShowEvent *e);
+private:
+};
+
+#endif
diff --git a/kommander/widgets/radiobutton.cpp b/kommander/widgets/radiobutton.cpp
new file mode 100644
index 00000000..a7faa91a
--- /dev/null
+++ b/kommander/widgets/radiobutton.cpp
@@ -0,0 +1,144 @@
+/***************************************************************************
+ radiobutton.cpp - Radiobutton class
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qradiobutton.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "radiobutton.h"
+
+RadioButton::RadioButton(QWidget *a_parent, const char *a_name)
+ : QRadioButton(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "unchecked";
+ states << "checked";
+ setStates(states);
+ QStringList displayStates;
+ displayStates << "checked";
+ displayStates << "unchecked";
+ setDisplayStates(displayStates);
+}
+
+RadioButton::~RadioButton()
+{
+}
+
+QString RadioButton::currentState() const
+{
+ return (isChecked() ? "checked" : "unchecked");
+}
+
+bool RadioButton::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList RadioButton::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void RadioButton::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void RadioButton::setWidgetText(const QString &a_text)
+{
+ setText(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void RadioButton::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText( a_text );
+}
+
+QString RadioButton::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void RadioButton::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText( populationText() );
+ setWidgetText( txt );
+}
+
+void RadioButton::showEvent( QShowEvent *e )
+{
+ QRadioButton::showEvent( e );
+ emit widgetOpened();
+}
+
+void RadioButton::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool RadioButton::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::setChecked || f == DCOP::checked || f == DCOP::geometry || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor;
+}
+
+QString RadioButton::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return text();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::setChecked:
+ setChecked(args[0] != "false");
+ break;
+ case DCOP::checked:
+ return QString::number(isOn());
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+
+#include "radiobutton.moc"
diff --git a/kommander/widgets/radiobutton.h b/kommander/widgets/radiobutton.h
new file mode 100644
index 00000000..f9fb5a16
--- /dev/null
+++ b/kommander/widgets/radiobutton.h
@@ -0,0 +1,66 @@
+/***************************************************************************
+ radiobutton.h - Radiobutton widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_RADIOBUTTON_H_
+#define _HAVE_RADIOBUTTON_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qradiobutton.h>
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT RadioButton : public QRadioButton, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ RadioButton(QWidget *a_parent, const char *a_name);
+ ~RadioButton();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString &);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent( QShowEvent *e );
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/richtexteditor.cpp b/kommander/widgets/richtexteditor.cpp
new file mode 100644
index 00000000..eea0b0d6
--- /dev/null
+++ b/kommander/widgets/richtexteditor.cpp
@@ -0,0 +1,249 @@
+/***************************************************************************
+ richtexteditor.cpp - Widget providing simple rich text editing
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+#include <klocale.h>
+
+/* QT INCLUDES */
+#include <qlayout.h>
+#include <qevent.h>
+#include <qtextedit.h>
+#include <qframe.h>
+#include <qwidget.h>
+#include <qlayout.h>
+#include <qtoolbutton.h>
+#include <qpixmap.h>
+#include <qhbuttongroup.h>
+#include <qfont.h>
+#include <qstringlist.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "richtexteditor.h"
+
+/* Pixmaps */
+#include "pixmaps/textbold.xpm"
+#include "pixmaps/textunder.xpm"
+#include "pixmaps/textitalic.xpm"
+#include "pixmaps/textcenter.xpm"
+#include "pixmaps/textleft.xpm"
+#include "pixmaps/textright.xpm"
+
+RichTextEditor::RichTextEditor(QWidget *a_parent, const char *a_name)
+ : QWidget(a_parent, a_name), KommanderWidget((QObject *)this)
+{
+
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+
+ // setup toolbar
+ m_toolbar = new QFrame(this, "buttonBar");
+ m_toolbar->setMinimumSize(0, 32);
+ m_toolbar->setFrameShape(QFrame::NoFrame);
+ m_toolbar->setFrameShadow(QFrame::Plain);
+
+ //setup textedit
+ m_textedit = new QTextEdit(this, "editor");
+ m_textedit->setTextFormat(RichText);
+
+ // layout the widgets
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(m_toolbar);
+ layout->addWidget(m_textedit);
+ layout->setSpacing(1);
+
+ // setup buttons
+ QHBoxLayout *tbLayout = new QHBoxLayout(m_toolbar);
+
+ //bold italic underline left right center link
+ m_formatGroup = new QHButtonGroup(m_toolbar, "formatGroup");
+ //m_formatGroup->setFlat(true);
+ m_alignGroup = new QHButtonGroup(m_toolbar, "alignGroup");
+ //m_alignGroup->setFlat(true);
+ m_alignGroup->setExclusive(true);
+ tbLayout->insertStretch(0);
+ tbLayout->addWidget(m_formatGroup);
+ tbLayout->addWidget(m_alignGroup);
+ tbLayout->insertStretch(3);
+
+ m_buttonTextBold = new QToolButton(m_formatGroup, "textBold");
+ m_buttonTextBold->setPixmap(QPixmap((const char **)bold_xpm));
+ m_buttonTextBold->setToggleButton(true);
+ connect(m_buttonTextBold, SIGNAL(toggled(bool)), this, SLOT(textBold(bool)));
+ m_buttonTextItalic = new QToolButton(m_formatGroup, "textItalic");
+ m_buttonTextItalic->setPixmap(QPixmap((const char **)italic_xpm));
+ m_buttonTextItalic->setToggleButton(true);
+ connect(m_buttonTextItalic, SIGNAL(toggled(bool)), this, SLOT(textItalic(bool)));
+ m_buttonTextUnder = new QToolButton(m_formatGroup, "textUnder");
+ m_buttonTextUnder->setPixmap(QPixmap((const char **)under_xpm));
+ m_buttonTextUnder->setToggleButton(true);
+ connect(m_buttonTextUnder, SIGNAL(toggled(bool)), this, SLOT(textUnder(bool)));
+
+ m_buttonTextLeft = new QToolButton(m_alignGroup, "textLeft");
+ m_buttonTextLeft->setPixmap(QPixmap((const char **)left_xpm));
+ m_buttonTextLeft->setToggleButton(true);
+ m_buttonTextCenter = new QToolButton(m_alignGroup, "textCenter");
+ m_buttonTextCenter->setPixmap(QPixmap((const char **)center_xpm));
+ m_buttonTextCenter->setToggleButton(true);
+ m_buttonTextRight = new QToolButton(m_alignGroup, "textRight");
+ m_buttonTextRight->setPixmap(QPixmap((const char **)right_xpm));
+ m_buttonTextRight->setToggleButton(true);
+
+ connect(m_alignGroup, SIGNAL(clicked(int)), this, SLOT(textAlign(int)));
+ connect(m_textedit, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(fontChanged(const QFont &)));
+ connect(m_textedit, SIGNAL(currentAlignmentChanged(int)), this, SLOT(alignmentChanged(int)));
+
+ connect(m_textedit, SIGNAL(textChanged()), this, SLOT(setTextChanged()));
+
+}
+
+QString RichTextEditor::currentState() const
+{
+ return QString("default");
+}
+
+RichTextEditor::~RichTextEditor()
+{
+}
+
+bool RichTextEditor::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList RichTextEditor::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void RichTextEditor::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void RichTextEditor::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText( a_text );
+}
+
+QString RichTextEditor::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void RichTextEditor::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText( populationText() );
+ setWidgetText( txt );
+}
+
+void RichTextEditor::setWidgetText(const QString &a_text)
+{
+ m_textedit->setText(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void RichTextEditor::setTextChanged()
+{
+ emit widgetTextChanged(m_textedit->text());
+}
+
+void RichTextEditor::textBold(bool a_isOn)
+{
+ m_textedit->setBold(a_isOn);
+}
+
+void RichTextEditor::textUnder(bool a_isOn)
+{
+ m_textedit->setUnderline(a_isOn);
+}
+
+void RichTextEditor::textItalic(bool a_isOn)
+{
+ m_textedit->setItalic(a_isOn);
+}
+
+void RichTextEditor::textAlign(int a_id)
+{
+ QToolButton *b = (QToolButton *)m_alignGroup->find(a_id);
+ if(b == m_buttonTextLeft)
+ m_textedit->setAlignment(Qt::AlignLeft);
+ else if(b == m_buttonTextCenter)
+ m_textedit->setAlignment(Qt::AlignCenter);
+ else if(b == m_buttonTextRight)
+ m_textedit->setAlignment(Qt::AlignRight);
+}
+
+void RichTextEditor::fontChanged(const QFont &a_font)
+{
+ m_buttonTextBold->setOn(a_font.bold());
+ m_buttonTextItalic->setOn(a_font.italic());
+ m_buttonTextUnder->setOn(a_font.underline());
+}
+
+void RichTextEditor::alignmentChanged(int a_alignment)
+{
+ if((a_alignment == AlignAuto) || (a_alignment & AlignLeft))
+ m_buttonTextLeft->setOn(true);
+ else if(a_alignment & AlignHCenter)
+ m_buttonTextCenter->setOn(true);
+ else if(a_alignment & AlignRight)
+ m_buttonTextRight->setOn(true);
+}
+
+void RichTextEditor::showEvent( QShowEvent *e )
+{
+ QWidget::showEvent(e);
+ emit widgetOpened();
+}
+
+void RichTextEditor::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool RichTextEditor::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::clear || f == DCOP::selection || f == DCOP::setEditable;
+}
+
+QString RichTextEditor::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return m_textedit->text();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::selection:
+ return m_textedit->selectedText();
+ case DCOP::clear:
+ setWidgetText("");
+ break;
+ case DCOP::setEditable:
+ m_textedit->setReadOnly(args[0] == "false" || args[0] == "0");
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "richtexteditor.moc"
diff --git a/kommander/widgets/richtexteditor.h b/kommander/widgets/richtexteditor.h
new file mode 100644
index 00000000..4436d73f
--- /dev/null
+++ b/kommander/widgets/richtexteditor.h
@@ -0,0 +1,85 @@
+/***************************************************************************
+ richtexteditor.h - Widget providing simple rich texxt editing
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_RICHTEXTEDITOR_H_
+#define _HAVE_RICHTEXTEDITOR_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qstring.h>
+#include <qwidget.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+
+/* Forward Decls */
+class QTextEdit;
+class QFrame;
+class QToolButton;
+class QHButtonGroup;
+
+class QShowEvent;
+class KOMMANDER_EXPORT RichTextEditor : public QWidget, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ RichTextEditor(QWidget *, const char *);
+ virtual ~RichTextEditor();
+
+ bool isKommanderWidget() const;
+ void setAssociatedText(const QStringList&);
+ QStringList associatedText() const;
+ QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ void setTextChanged();
+ void setWidgetText(const QString &);
+ void textAlign(int);
+ void textBold(bool);
+ void textUnder(bool);
+ void textItalic(bool);
+ void fontChanged(const QFont &);
+ void alignmentChanged(int);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent( QShowEvent *e );
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+ QFrame *m_toolbar;
+ QTextEdit *m_textedit;
+
+ QToolButton *m_buttonTextBold, *m_buttonTextUnder, *m_buttonTextItalic,
+ *m_buttonTextLeft, *m_buttonTextCenter, *m_buttonTextRight;
+
+ QHButtonGroup *m_formatGroup, *m_alignGroup;
+
+};
+
+#endif
diff --git a/kommander/widgets/scriptobject.cpp b/kommander/widgets/scriptobject.cpp
new file mode 100644
index 00000000..859d87d0
--- /dev/null
+++ b/kommander/widgets/scriptobject.cpp
@@ -0,0 +1,191 @@
+/***************************************************************************
+ scriptobject.cpp - Widget for holding scripts
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qwidget.h>
+
+/* KDE INCLUDES */
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include "scriptobject.h"
+#include <myprocess.h>
+#include <specials.h>
+
+ScriptObject::ScriptObject(QWidget *a_parent, const char *a_name)
+ : QLabel(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ if (KommanderWidget::inEditor)
+ {
+ setPixmap(KGlobal::iconLoader()->loadIcon("shellscript", KIcon::NoGroup, KIcon::SizeMedium));
+ setFrameStyle(QFrame::Box | QFrame::Plain);
+ setLineWidth(1);
+ setFixedSize(pixmap()->size());
+ }
+ else
+ setHidden(true);
+}
+
+ScriptObject::~ScriptObject()
+{
+}
+
+QString ScriptObject::currentState() const
+{
+ return QString("default");
+}
+
+bool ScriptObject::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList ScriptObject::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void ScriptObject::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void ScriptObject::setWidgetText(const QString& a_text)
+{
+ KommanderWidget::setAssociatedText(a_text);
+}
+
+void ScriptObject::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString ScriptObject::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void ScriptObject::populate()
+{
+ setAssociatedText(KommanderWidget::evalAssociatedText(populationText()));
+}
+
+QString ScriptObject::executeProcess(bool blocking)
+{
+ int index = ( states().findIndex( currentState()) );
+ if (index == -1)
+ {
+ printError(i18n("Invalid state for associated text."));
+ return QString();
+ }
+ QString evalText = m_associatedText[index];
+
+ if ((KommanderWidget::useInternalParser && !evalText.startsWith("#!")) || evalText.startsWith("#!kommander"))
+ {
+ evalAssociatedText(evalText);
+ return global(widgetName() + "_RESULT");
+ } else
+ {
+ MyProcess process(this);
+ process.setBlocking(blocking);
+ return process.run(evalAssociatedText(evalText));
+ }
+}
+
+void ScriptObject::execute()
+{
+ m_params.clear();
+ executeProcess(true);
+}
+
+void ScriptObject::execute(const QString& s)
+{
+ m_params.clear();
+ m_params.append(s);
+ executeProcess(true);
+}
+
+void ScriptObject::execute(const QString& s1, const QString& s2)
+{
+ m_params.clear();
+ m_params.append(s1);
+ m_params.append(s2);
+ executeProcess(true);
+}
+
+void ScriptObject::execute(int i)
+{
+ m_params.clear();
+ m_params.append(QString::number(i));
+ executeProcess(true);
+}
+
+void ScriptObject::execute(int i, int j)
+{
+ m_params.clear();
+ m_params.append(QString::number(i));
+ m_params.append(QString::number(j));
+ executeProcess(true);
+}
+
+void ScriptObject::execute(bool i)
+{
+ m_params.clear();
+ m_params.append(QString::number(i));
+ executeProcess(true);
+}
+
+bool ScriptObject::isFunctionSupported(int f)
+{
+ return f == DCOP::setText || f == DCOP::clear || f == DCOP::execute || f == DCOP::item
+ || f == DCOP::count;
+}
+
+QString ScriptObject::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::setText:
+ setAssociatedText(args[0]);
+ break;
+ case DCOP::clear:
+ setAssociatedText(QString::null);
+ break;
+ case DCOP::execute:
+ m_params = args;
+ return executeProcess(true);
+ break;
+ case DCOP::item:
+ {
+ uint index = args[0].toInt();
+ return index < m_params.count() ? m_params[index] : QString::null;
+ }
+ case DCOP::count:
+ return QString::number(m_params.count());
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "scriptobject.moc"
diff --git a/kommander/widgets/scriptobject.h b/kommander/widgets/scriptobject.h
new file mode 100644
index 00000000..3906d5e4
--- /dev/null
+++ b/kommander/widgets/scriptobject.h
@@ -0,0 +1,68 @@
+/***************************************************************************
+ scriptobject.h - Widget for holding scripts
+ -------------------
+ copyright : (C) 2002 Marc Britton <consume@optusnet.com.au>
+ (C) 2003-2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ **************************************************************************/
+#ifndef _HAVE_SCRIPTOBJECT_H_
+#define _HAVE_SCRIPTOBJECT_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qlabel.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+
+class KOMMANDER_EXPORT ScriptObject : public QLabel, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+
+public:
+ ScriptObject(QWidget *a_parent, const char *a_name);
+ ~ScriptObject();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void populate();
+ virtual void execute();
+ virtual void execute(const QString&);
+ virtual void execute(const QString&, const QString&);
+ virtual void execute(int);
+ virtual void execute(int, int);
+ virtual void execute(bool);
+signals:
+ void widgetOpened();
+
+protected:
+ virtual QString executeProcess(bool blocking);
+private:
+ QStringList m_params;
+};
+
+#endif
diff --git a/kommander/widgets/slider.cpp b/kommander/widgets/slider.cpp
new file mode 100644
index 00000000..52f6d47a
--- /dev/null
+++ b/kommander/widgets/slider.cpp
@@ -0,0 +1,121 @@
+/***************************************************************************
+ slider.cpp - Slider widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "slider.h"
+
+Slider::Slider(QWidget * a_parent, const char *a_name)
+ : QSlider(a_parent, a_name), KommanderWidget((QObject *) this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+}
+
+QString Slider::currentState() const
+{
+ return QString("default");
+}
+
+Slider::~Slider()
+{
+}
+
+bool Slider::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList Slider::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void Slider::setAssociatedText(const QStringList & a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void Slider::setPopulationText(const QString & a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString Slider::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void Slider::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText(populationText());
+ setWidgetText(txt);
+}
+
+void Slider::setWidgetText(const QString & a_text)
+{
+ setValue(a_text.toInt());
+}
+
+void Slider::showEvent(QShowEvent * e)
+{
+ QSlider::showEvent(e);
+ emit widgetOpened();
+}
+
+bool Slider::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::clear || f == DCOP::setMaximum || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor;
+}
+
+QString Slider::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return QString::number(value());
+ case DCOP::setText:
+ setValue(args[0].toInt());
+ break;
+ case DCOP::clear:
+ setValue(minValue());
+ break;
+ case DCOP::setMaximum:
+ setMaxValue(args[0].toInt());
+ break;
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "slider.moc"
diff --git a/kommander/widgets/slider.h b/kommander/widgets/slider.h
new file mode 100644
index 00000000..59526deb
--- /dev/null
+++ b/kommander/widgets/slider.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ slider.h - Slider widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_SLIDER_H_
+#define _HAVE_SLIDER_H_
+
+/* KDE INCLUDES */
+#include <qslider.h>
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QShowEvent;
+class KOMMANDER_EXPORT Slider: public QSlider, public KommanderWidget
+{
+ Q_OBJECT Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ Slider(QWidget*, const char*);
+ virtual ~Slider();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList &);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString &);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+
+public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void populate();
+
+signals:
+ void widgetOpened();
+
+protected:
+ void showEvent(QShowEvent* e);
+};
+
+#endif
diff --git a/kommander/widgets/spinboxint.cpp b/kommander/widgets/spinboxint.cpp
new file mode 100644
index 00000000..ce013333
--- /dev/null
+++ b/kommander/widgets/spinboxint.cpp
@@ -0,0 +1,140 @@
+/***************************************************************************
+ spinboxint.cpp - Integer spinbox widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qspinbox.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "spinboxint.h"
+
+SpinBoxInt::SpinBoxInt(QWidget *a_parent, const char *a_name)
+ : QSpinBox(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+}
+
+SpinBoxInt::~SpinBoxInt()
+{
+}
+
+QString SpinBoxInt::currentState() const
+{
+ return "default";
+}
+
+bool SpinBoxInt::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList SpinBoxInt::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void SpinBoxInt::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void SpinBoxInt::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString SpinBoxInt::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void SpinBoxInt::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+void SpinBoxInt::setWidgetText(const QString &a_text)
+{
+ setValue(a_text.toInt());
+ emit widgetTextChanged(a_text);
+}
+
+void SpinBoxInt::showEvent( QShowEvent *e )
+{
+ QSpinBox::showEvent(e);
+ emit widgetOpened();
+}
+
+void SpinBoxInt::focusOutEvent( QFocusEvent * e)
+{
+ QSpinBox::focusOutEvent(e);
+ emit lostFocus();
+}
+
+void SpinBoxInt::focusInEvent( QFocusEvent * e)
+{
+ QSpinBox::focusInEvent(e);
+ emit gotFocus();
+}
+
+bool SpinBoxInt::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::setMaximum || f == DCOP::geometry|| f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor;
+}
+
+QString SpinBoxInt::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return cleanText();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::setMaximum:
+ setMaxValue(args[0].toUInt());
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "spinboxint.moc"
diff --git a/kommander/widgets/spinboxint.h b/kommander/widgets/spinboxint.h
new file mode 100644
index 00000000..03c30b24
--- /dev/null
+++ b/kommander/widgets/spinboxint.h
@@ -0,0 +1,68 @@
+/***************************************************************************
+ spinboxint.h - Integer spinbox widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_SPINBOXINT_H_
+#define _HAVE_SPINBOXINT_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstringlist.h>
+#include <qstring.h>
+#include <qspinbox.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT SpinBoxInt : public QSpinBox, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ SpinBoxInt(QWidget *a_parent, const char *a_name);
+ ~SpinBoxInt();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void lostFocus();
+ void gotFocus();
+protected:
+ void showEvent(QShowEvent *e);
+ void focusOutEvent( QFocusEvent* e);
+ void focusInEvent( QFocusEvent* e);
+private:
+};
+
+#endif
diff --git a/kommander/widgets/statusbar.cpp b/kommander/widgets/statusbar.cpp
new file mode 100644
index 00000000..90b23999
--- /dev/null
+++ b/kommander/widgets/statusbar.cpp
@@ -0,0 +1,131 @@
+/***************************************************************************
+ statusbar.cpp - StatusBar widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "statusbar.h"
+
+StatusBar::StatusBar(QWidget *a_parent, const char *a_name)
+ : KStatusBar(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ insertItem(QString::null, 0, 1);
+ setItemAlignment(0, Qt::AlignLeft);
+}
+
+StatusBar::~StatusBar()
+{
+}
+
+QString StatusBar::currentState() const
+{
+ return QString("default");
+}
+
+bool StatusBar::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList StatusBar::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void StatusBar::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void StatusBar::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString StatusBar::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void StatusBar::populate()
+{
+ changeItem(KommanderWidget::evalAssociatedText(populationText()), 0);
+}
+
+void StatusBar::showEvent(QShowEvent *e)
+{
+ QStatusBar::showEvent(e);
+ emit widgetOpened();
+}
+
+void StatusBar::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool StatusBar::isFunctionSupported(int f)
+{
+ return f == DCOP::setText || f == DCOP::insertItem || f == DCOP::removeItem || f == DCOP::clear || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor;
+}
+
+QString StatusBar::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::setText:
+ changeItem(args[0], 0);
+ break;
+ case DCOP::insertItem:
+ if (hasItem(args[1].toInt()))
+ changeItem(args[0], args[1].toInt());
+ else
+ insertItem(args[0], args[1].toInt());
+ break;
+ case DCOP::removeItem:
+ removeItem(args[0].toInt());
+ break;
+ case DCOP::clear:
+ clear();
+ break;
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "statusbar.moc"
diff --git a/kommander/widgets/statusbar.h b/kommander/widgets/statusbar.h
new file mode 100644
index 00000000..4920abca
--- /dev/null
+++ b/kommander/widgets/statusbar.h
@@ -0,0 +1,65 @@
+/***************************************************************************
+ statusbar.h - StatusBar widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_STATUSBAR_H_
+#define _HAVE_STATUSBAR_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kstatusbar.h>
+#include <kommanderwidget.h>
+
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT StatusBar : public KStatusBar, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+
+public:
+ StatusBar(QWidget *a_parent, const char *a_name);
+ ~StatusBar();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/subdialog.cpp b/kommander/widgets/subdialog.cpp
new file mode 100644
index 00000000..4986d174
--- /dev/null
+++ b/kommander/widgets/subdialog.cpp
@@ -0,0 +1,146 @@
+/***************************************************************************
+ subdialog.cpp - Subdialog widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qpushbutton.h>
+#include <qdialog.h>
+
+/* OTHER INCLUDES */
+#include <kdebug.h>
+#include <kommanderfactory.h>
+#include <kommanderwidget.h>
+#include <specials.h>
+#include "subdialog.h"
+
+SubDialog::SubDialog(QWidget *a_parent, const char *a_name)
+ : QPushButton(a_parent, a_name), KommanderWidget(this), m_dialog(0)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+
+ connect(this, SIGNAL(clicked()), this, SLOT(showDialog()));
+
+}
+
+SubDialog::~SubDialog()
+{
+}
+
+QString SubDialog::currentState() const
+{
+ return QString("default");
+}
+
+bool SubDialog::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList SubDialog::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void SubDialog::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void SubDialog::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText( a_text );
+}
+
+QString SubDialog::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void SubDialog::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText( populationText() );
+//FIXME
+}
+
+
+void SubDialog::setKmdrFile(QString a_kmdrFile)
+{
+ m_kmdrFile = a_kmdrFile;
+}
+
+QString SubDialog::kmdrFile() const
+{
+ return m_kmdrFile;
+}
+
+void SubDialog::showDialog()
+{
+ delete m_dialog;
+
+ KommanderFactory::loadPlugins();
+ m_dialog = (QDialog *)KommanderFactory::create(kmdrFile());
+ if(!m_dialog)
+ {
+ kdWarning() << "Creation of sub dialog failed .." << endl;
+ connect(m_dialog, SIGNAL(finished()), this, SLOT(slotFinished()));
+
+ m_dialog->exec();
+ }
+}
+
+void SubDialog::slotFinished()
+{
+ if(m_dialog)
+ {
+ KommanderWidget *atw = dynamic_cast<KommanderWidget *>(m_dialog);
+ if(atw)
+ emit widgetTextChanged(atw->evalAssociatedText());
+ }
+}
+
+void SubDialog::showEvent( QShowEvent *e )
+{
+ QPushButton::showEvent( e );
+ emit widgetOpened();
+}
+
+QString SubDialog::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ {
+ if (!m_dialog)
+ return QString();
+ KommanderWidget *atw = dynamic_cast<KommanderWidget *>(m_dialog);
+ if(atw)
+ return atw->evalAssociatedText();
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "subdialog.moc"
diff --git a/kommander/widgets/subdialog.h b/kommander/widgets/subdialog.h
new file mode 100644
index 00000000..ad19fec5
--- /dev/null
+++ b/kommander/widgets/subdialog.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ subdialog.h - Subdialog widget
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_SUBDIALOG_H_
+#define _HAVE_SUBDIALOG_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qpushbutton.h>
+#include <qobject.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QWidget;
+class QDialog;
+
+class QShowEvent;
+class KOMMANDER_EXPORT SubDialog : public QPushButton, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QString kmdrFile READ kmdrFile WRITE setKmdrFile)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ SubDialog(QWidget *a_parent, const char *a_name);
+ ~SubDialog();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+ QString kmdrFile() const;
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+public slots:
+ void setKmdrFile(QString);
+ virtual void showDialog();
+ virtual void slotFinished();
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString &);
+protected:
+ QDialog *m_dialog;
+ QString m_kmdrFile;
+ void showEvent( QShowEvent *e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/table.cpp b/kommander/widgets/table.cpp
new file mode 100644
index 00000000..358b548b
--- /dev/null
+++ b/kommander/widgets/table.cpp
@@ -0,0 +1,373 @@
+/***************************************************************************
+ table.cpp - Table widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+
+/* KDE INCLUDES */
+#include <klocale.h>
+#include <kglobal.h>
+#include <kmessagebox.h>
+
+/* QT INCLUDES */
+#include <qmetaobject.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qpoint.h>
+
+/* OTHER INCLUDES */
+#include "kommanderplugin.h"
+#include "specials.h"
+#include "table.h"
+
+enum Functions {
+ FirstFunction = 365,
+ TBL_sortColumnExtra,
+ TBL_keepCellVisible,
+ TBL_selectCells,
+ TBL_selectRow,
+ TBL_selectColumn,
+ TBL_setColumnReadOnly,
+ TBL_setRowReadOnly,
+ TBL_rowCount,
+ TBL_colHeader,
+ TBL_rowHeader,
+ LastFunction
+};
+
+
+Table::Table(QWidget *a_parent, const char *a_name)
+ : QTable(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(TBL_sortColumnExtra, "sortColumnExtra(QString widget, int col, bool ascending, bool wholeRows)", i18n("Sets a column to sort ascending or descending. Optionally can sort with rows intact for database use."), 2, 4);
+ KommanderPlugin::registerFunction(TBL_keepCellVisible, "keepCellVisible(QString widget, int row, int col)", i18n("Scrolls the table so the cell indicated is visible."), 3);
+ KommanderPlugin::registerFunction(TBL_selectCells, "selectCells(QString widget, int row, int col, int row, int col)", i18n("Select cells using the upper left and lower right cell addresses<br /><b>Not guaranteed to have KDE4 compatiblility</b>"), 5);
+ KommanderPlugin::registerFunction(TBL_selectRow, "selectRow(QString widget, int row)", i18n("Select the row with the zero based index."), 2);
+ KommanderPlugin::registerFunction(TBL_selectColumn, "selectColumn(QString widget, int col)", i18n("Select the column with the zero based index.<br /><b>Not guaranteed to have KDE4 compatiblility</b>"), 2);
+ KommanderPlugin::registerFunction(TBL_setColumnReadOnly, "setColumnReadOnly(QString widget, int col, bool Readonly)", i18n("Set the column read only using zero based index.<br /><b>Not guaranteed to have KDE4 compatiblility</b>"), 3);
+ KommanderPlugin::registerFunction(TBL_setRowReadOnly, "setRowReadOnly(QString widget, int row, bool Readonly)", i18n("Set the row read only using zero based index.<br /><b>Not guaranteed to have KDE4 compatiblility</b>"), 3);
+ KommanderPlugin::registerFunction(TBL_rowCount, "rowCount(QString widget)", i18n("Returns the number of rows of the table"), 1);
+ KommanderPlugin::registerFunction(TBL_colHeader, "columnHeader(QString widget, int Column)", i18n("Returns the text of the header for the column index"), 2);
+ KommanderPlugin::registerFunction(TBL_rowHeader, "rowHeader(QString widget, int Row)", i18n("Returns the text of the header for the row index"), 2);
+
+}
+
+Table::~Table()
+{
+}
+
+QString Table::currentState() const
+{
+ return QString("default");
+}
+
+bool Table::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList Table::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void Table::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void Table::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString Table::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void Table::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+void Table::setWidgetText(const QString&)
+{
+}
+
+QString Table::selectedArea()
+{
+ QTableSelection sel = selection(currentSelection());
+ return QString("%1,%2,%3,%4").arg(sel.topRow()).arg(sel.leftCol()).arg(sel.bottomRow()).arg(sel.rightCol());
+}
+
+
+bool Table::isFunctionSupported(int f)
+{
+ return f == DCOP::currentColumn || f == DCOP::currentRow || f == DCOP::insertColumn ||
+ f == DCOP::insertRow || f == DCOP::cellText || f == DCOP::setCellText || f == DCOP::setCellWidget || f == DCOP::cellWidget || f == DCOP::columnCount ||
+ f == DCOP::removeRow || f == DCOP::removeColumn || f == DCOP::setColumnCaption ||
+ f == DCOP::setRowCaption || f == DCOP::text || f == DCOP::setText || f == DCOP::selection || f == DCOP::geometry || f == DCOP::hasFocus || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor || (f >= FirstFunction && f <= LastFunction);
+}
+
+void Table::setCellWidget(int row, int col, const QString & _widgetName)
+{
+ KommanderWidget *w = widgetByName(_widgetName);
+ if (w)
+ {
+ QWidget *widget = static_cast<QWidget*>(w->object());
+ if (QTable::cellWidget(row, col) != widget)
+ {
+ setCurrentCell(-1, -1); //hack to not delete the cellwidget after clicking away to another cell.
+//I don't know why it does so, but without this on a click to another cell calls endEdit, which calls
+//clearCellWidget, all this before the currentChanged signal is emitted.
+//this hack does ugly things once table starts scrolling - let's try to minize damage
+//we should have a way to test doe cellWidget looses focus and send it right or down too
+ QTable::ensureCellVisible(row, col);
+ clearCellWidget(row, col);
+ QTable::setCellWidget(row, col, widget);
+ }
+ } else
+ clearCellWidget(row, col);
+}
+
+QString Table::cellWidget(int row, int col)
+{
+
+ QWidget *widget = QTable::cellWidget(row, col);
+ if (widget)
+ {
+ KommanderWidget *w = widgetByName(widget->name());
+ if (w)
+ return widget->name();
+ }
+ return QString();
+}
+
+void Table::setCellText(int row, int col, const QString& text)
+{
+ QWidget *widget = QTable::cellWidget(row, col);
+ if (widget)
+ {
+ KommanderWidget *w = widgetByName(widget->name());
+ if (w)
+ widget->reparent(parentDialog(), QPoint(0,0));
+ }
+ setText(row, col, text);
+ endEdit(row, col, false, false);
+}
+
+void Table::clearCellWidget(int row, int col)
+{
+ QTable::clearCellWidget(row, col); //just for debugging
+}
+
+void Table::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+void Table::columnClicked(int col)
+{
+ emit columnHeaderClicked(col);
+ static bool ascending = TRUE;
+ if (!sorting()) return;
+ ascending=!ascending;
+ sortColumn( col, ascending, TRUE);
+}
+
+QString Table::handleDCOP(int function, const QStringList& args)
+{
+ switch (function)
+ {
+ case DCOP::cellText:
+ return text(args[0].toInt(), args[1].toInt());
+ case DCOP::setCellText:
+ if (numRows() >= args[0].toInt() && numCols() >+ args[1].toInt())
+ setCellText(args[0].toInt(), args[1].toInt(), args[2]);
+ break;
+ case DCOP::setCellWidget:
+ if (numRows() >= args[0].toInt() && numCols() >+ args[1].toInt())
+ setCellWidget(args[0].toInt(), args[1].toInt(), args[2]);
+ break;
+ case DCOP::cellWidget:
+ return cellWidget(args[0].toInt(), args[1].toInt());
+ break;
+ case DCOP::insertRow:
+ insertRows(args[0].toInt(), args.count() == 1 ? 1 : args[1].toInt());
+ break;
+ case DCOP::insertColumn:
+ insertColumns(args[0].toInt(), args.count() == 1 ? 1 : args[1].toInt());
+ break;
+ case DCOP::currentColumn:
+ return QString::number(currentColumn());
+ case DCOP::currentRow:
+ return QString::number(currentRow());
+ case DCOP::columnCount:
+ return QString::number(numCols());
+ break;
+ case DCOP::removeColumn:
+ if (numCols() >= args[0].toInt())
+ {
+ if (!args[1].toInt())
+ removeColumn(args[0].toInt());
+ else
+ {
+ int column = args[0].toInt();
+ int lines = args[1].toInt();
+ for (int i = 0; i < lines; i++)
+ removeColumn(column);
+ }
+ break;
+ }
+ case TBL_rowCount:
+ return QString::number(numRows());
+ break;
+ case DCOP::removeRow:
+ {
+ int row = args[0].toInt();
+ int lines = args[1].toInt();
+ for (int i = 0; i < lines; i++)
+ removeRow(row);
+ break;
+ }
+ case DCOP::setColumnCaption:
+ if (numCols() >= args[0].toInt())
+ horizontalHeader()->setLabel(args[0].toInt(), args[1]);
+ break;
+ case DCOP::setRowCaption:
+ if (numRows() >= args[0].toInt())
+ verticalHeader()->setLabel(args[0].toInt(), args[1]);
+ break;
+ case DCOP::text:
+ {
+ QString rows;
+ for (int r = 0; r < numRows(); r++)
+ {
+ QString row;
+ for (int c = 0; c < numCols(); c++)
+ {
+ if (c)
+ row += '\t';
+ row += text(r,c);
+ }
+ if (r)
+ rows += '\n';
+ rows += row;
+ }
+ return rows;
+ }
+ case DCOP::setText:
+ {
+ int r = 0, c = 0;
+ setNumCols(0);
+ setNumRows(0);
+ QStringList rows;
+ QStringList row;
+ rows = QStringList::split("\n", args[0], true);
+ setNumRows(rows.count());
+ for (QStringList::Iterator it = rows.begin(); it != rows.end(); ++it, ++r)
+ {
+ row = QStringList::split("\t", *it, true);
+ if (!r)
+ setNumCols(row.count());
+ c = 0;
+ for (QStringList::Iterator itr = row.begin(); itr != row.end(); ++itr, ++c)
+ setText(r, c, *itr);
+ }
+ break;
+ }
+ case DCOP::selection:
+ return selectedArea();
+ break;
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ case TBL_sortColumnExtra:
+ if (numCols() >= args[0].toInt())
+ QTable::sortColumn(args[0].toInt(), args[1].toInt(), args[2].toInt());
+ break;
+ case TBL_keepCellVisible:
+ if (numRows() >= args[0].toInt() && numCols() >+ args[1].toInt())
+ QTable::ensureCellVisible(args[0].toInt()-1, args[1].toInt()-1);
+ break;
+ case TBL_selectCells:
+ if (numRows() >= args[0].toInt() && numCols() >+ args[1].toInt() && numRows() >= args[2].toInt() && numCols() >+ args[3].toInt())
+ QTable::selectCells (args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt());
+ break;
+ case TBL_selectRow:
+ if (numRows() >= args[0].toInt())
+ QTable::selectRow (args[0].toInt());
+ break;
+ case TBL_selectColumn:
+ if (numCols() >= args[0].toInt())
+ QTable::selectColumn (args[0].toInt());
+ break;
+ case TBL_setColumnReadOnly:
+ if (numCols() >= args[0].toInt())
+ QTable::setColumnReadOnly (args[0].toInt(), args[1].toUInt());
+ break;
+ case TBL_setRowReadOnly:
+ if (numRows() >= args[0].toInt())
+ QTable::setRowReadOnly (args[0].toInt(), args[1].toUInt());
+ break;
+ case TBL_colHeader:
+ {
+ QHeader* hdr = QTable::horizontalHeader();
+ if (numCols() >= args[0].toInt())
+ return hdr->label(args[0].toInt());
+ else
+ return "No column at index "+args[0];
+ break;
+ }
+ case TBL_rowHeader:
+ {
+ QHeader* hdr = QTable::verticalHeader();
+ if (numRows() >= args[0].toInt())
+ return hdr->label(args[0].toInt());
+ else
+ return "No row at index "+args[0];
+ break;
+ }
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::hasFocus:
+ return QString::number(this->hasFocus());
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "table.moc"
+
diff --git a/kommander/widgets/table.h b/kommander/widgets/table.h
new file mode 100644
index 00000000..26ed3b36
--- /dev/null
+++ b/kommander/widgets/table.h
@@ -0,0 +1,73 @@
+/***************************************************************************
+ table.h - Table widget
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+
+#ifndef _HAVE_TABLE_H_
+#define _HAVE_TABLE_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qtable.h>
+#include <qobject.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+
+class QWidget;
+
+class KOMMANDER_EXPORT Table : public QTable, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_OVERRIDE(bool readOnly DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+
+ public:
+ Table(QWidget *a_parent, const char *a_name);
+ ~Table();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+ virtual void clearCellWidget(int row, int col);
+ virtual void columnClicked(int col);
+ public slots:
+ virtual void populate();
+ virtual void setWidgetText(const QString &);
+ //void adjustColumn(int col);
+ signals:
+ void contextMenuRequested(int xpos, int ypos);
+ void columnHeaderClicked(int col);
+ protected:
+ void contextMenuEvent( QContextMenuEvent * e );
+ private:
+ QString selectedArea();
+ QString cellWidget(int row, int col);
+ void setCellWidget(int row, int col, const QString &widgetName);
+ void setCellText(int row, int col, const QString &text);
+};
+
+#endif
+
diff --git a/kommander/widgets/tabwidget.cpp b/kommander/widgets/tabwidget.cpp
new file mode 100644
index 00000000..ec0a02cf
--- /dev/null
+++ b/kommander/widgets/tabwidget.cpp
@@ -0,0 +1,194 @@
+/***************************************************************************
+ tabwidget.cpp - Widget with tabs
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+#include <klocale.h>
+#include <kiconloader.h>
+
+/* QT INCLUDES */
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qtabwidget.h>
+#include <qtabbar.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include "kommanderplugin.h"
+#include <specials.h>
+#include "tabwidget.h"
+
+enum Functions {
+ FirstFunction = 357,
+ TAB_setTabIcon,
+ TAB_tabLabel,
+ TAB_isTabEnabled,
+ TAB_setTabEnabled,
+ TAB_showTabBar,
+ TAB_setCurrentPage,
+ TAB_setTabLabel,
+ LastFunction
+};
+
+TabWidget::TabWidget(QWidget *a_parent, const char *a_name, int a_flags)
+ : QTabWidget(a_parent, a_name, a_flags), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(TAB_setTabIcon, "setTabIcon(QString widget, int Tab, QString Icon)", i18n("Sets an icon on the specified tab. Index is zero based."), 3);
+ KommanderPlugin::registerFunction(TAB_tabLabel, "tabLabel(QString widget, int Tab)", i18n("Returns the tab label at the given index. Index is zero based."), 2);
+ KommanderPlugin::registerFunction(TAB_isTabEnabled, "isTabEnabled(QString widget, int Tab)", i18n("Returns true if tab at specified index is enabled, otherwise returns false."), 2);
+ KommanderPlugin::registerFunction(TAB_setTabEnabled, "setTabEnabled(QString widget, int Tab, bool Enabled)", i18n("Sets the tab at the given index to enabled or disabled."), 3);
+ KommanderPlugin::registerFunction(TAB_showTabBar, "showTabBar(QString widget, bool Show)", i18n("Show or hide the tabs on the tab widget."), 2);
+ KommanderPlugin::registerFunction(TAB_setCurrentPage, "setCurrentPage(QString widget, QString Page)", i18n("Set the current page by name."), 2);
+ KommanderPlugin::registerFunction(TAB_setTabLabel, "setTabLabel(QString widget, int Tab, QString Text)", i18n("Sets the tab tab label."), 3);
+}
+
+TabWidget::~TabWidget()
+{
+}
+
+QString TabWidget::currentState() const
+{
+ return QString("default");
+}
+
+bool TabWidget::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList TabWidget::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void TabWidget::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void TabWidget::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText( a_text );
+}
+
+QString TabWidget::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void TabWidget::populate()
+{
+}
+
+void TabWidget::showEvent(QShowEvent* e)
+{
+ QTabWidget::showEvent(e);
+ emit widgetOpened();
+}
+
+void TabWidget::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool TabWidget::isFunctionSupported(int f)
+{
+ return f == DCOP::currentItem || f == DCOP::setCurrentItem || f == DCOP::insertTab || (f >= FirstFunction && f <= LastFunction) ;
+}
+
+QString TabWidget::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::currentItem:
+ return QString::number(currentPageIndex());
+ case DCOP::setCurrentItem:
+ setCurrentPage(args[0].toUInt());
+ break;
+ case DCOP::insertTab:
+ insertTab(0L, args[0], args[1].toUInt());
+ break;
+ case TAB_tabLabel:
+ {
+ QString s = this->label(args[0].toInt());
+ return s.remove("&");
+ break;
+ }
+ case TAB_setTabIcon:
+ {
+ QWidget *w = page(args[0].toInt());
+ setTabIconSet(w, KGlobal::iconLoader()->loadIcon(args[1], KIcon::NoGroup, KIcon::SizeMedium));
+ break;
+ }
+ case TAB_isTabEnabled:
+ {
+ QWidget *w = page(args[0].toInt());
+ return QString::number(this->isTabEnabled(w));
+ break;
+ }
+ case TAB_setTabLabel:
+ {
+ QWidget *w = page(args[0].toInt());
+ setTabLabel(w, args[1]);
+ break;
+ }
+ case TAB_setTabEnabled:
+ {
+ QWidget *w = page(args[0].toInt());
+ this->setTabEnabled(w, args[1].toInt());
+ break;
+ }
+ case TAB_setCurrentPage:
+ {
+ int cnt = this->count();
+ int i = 0;
+ bool found = false;
+ while (i < cnt) {
+ QString s = this->label(i);
+ if (s.remove("&") == args[0])
+ {
+ setCurrentPage(i);
+ found = true;
+ break;
+ }
+ i++;
+ }
+ return QString::number(found);
+ break;
+ }
+ case TAB_showTabBar:
+ {
+ QTabBar *t = this->tabBar();
+ if (args[0].toInt() == 1)
+ t->show();
+ else
+ t->hide();
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "tabwidget.moc"
diff --git a/kommander/widgets/tabwidget.h b/kommander/widgets/tabwidget.h
new file mode 100644
index 00000000..48f19232
--- /dev/null
+++ b/kommander/widgets/tabwidget.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ tabwidget.h - Widget with tabs
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_TABWIDGET_H_
+#define _HAVE_TABWIDGET_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qtabwidget.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+class QShowEvent;
+class KOMMANDER_EXPORT TabWidget : public QTabWidget, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ TabWidget(QWidget *, const char *, int=0);
+ ~TabWidget();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+
+public slots:
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+private:
+};
+
+#endif
diff --git a/kommander/widgets/textbrowser.cpp b/kommander/widgets/textbrowser.cpp
new file mode 100644
index 00000000..324bc62c
--- /dev/null
+++ b/kommander/widgets/textbrowser.cpp
@@ -0,0 +1,139 @@
+/***************************************************************************
+ textedit.cpp - Rich text viewing widget with links
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+#include <klocale.h>
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include "kommanderplugin.h"
+#include <specials.h>
+#include "textbrowser.h"
+
+enum Functions {
+ FirstFunction = 420,
+ TBR_setNotifyClick,
+ TBR_isNotifyClick,
+ LastFunction
+};
+
+TextBrowser::TextBrowser(QWidget * a_parent, const char *a_name)
+ : KTextBrowser(a_parent, a_name), KommanderWidget((QObject *) this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(TBR_setNotifyClick, "setNotifyClick(QString widget, bool Set)",i18n("Set notify click to intercept clicks and handle links"), 2, 2);
+ KommanderPlugin::registerFunction(TBR_isNotifyClick, "isNotifyClick(QString widget)",i18n("Set notify click to intercept clicks and handle links"), 1);
+}
+
+QString TextBrowser::currentState() const
+{
+ return QString("default");
+}
+
+TextBrowser::~TextBrowser()
+{
+}
+
+bool TextBrowser::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList TextBrowser::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void TextBrowser::setAssociatedText(const QStringList & a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void TextBrowser::setPopulationText(const QString & a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString TextBrowser::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void TextBrowser::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText(populationText());
+ setWidgetText(txt);
+}
+
+void TextBrowser::setWidgetText(const QString & a_text)
+{
+ setText(a_text);
+}
+
+void TextBrowser::showEvent(QShowEvent * e)
+{
+ QTextBrowser::showEvent(e);
+ emit widgetOpened();
+}
+
+void TextBrowser::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+
+bool TextBrowser::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::selection || f == DCOP::clear || (f >= FirstFunction && f <= LastFunction);
+}
+
+QString TextBrowser::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return text();
+ case DCOP::setText:
+ setText(args[0]);
+ break;
+ case DCOP::selection:
+ return selectedText();
+ case TBR_setNotifyClick:
+ KTextBrowser::setNotifyClick(args[0]);
+ break;
+ case TBR_isNotifyClick:
+ return QString::number(KTextBrowser::isNotifyClick());
+ break;
+ case DCOP::clear:
+ clear();
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "textbrowser.moc"
diff --git a/kommander/widgets/textbrowser.h b/kommander/widgets/textbrowser.h
new file mode 100644
index 00000000..f34e374e
--- /dev/null
+++ b/kommander/widgets/textbrowser.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+ textedit.h - Rich text viewing widget with links
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_TEXTBROWSER_H_
+#define _HAVE_TEXTBROWSER_H_
+
+/* KDE INCLUDES */
+#include <ktextbrowser.h>
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+
+class QShowEvent;
+class KOMMANDER_EXPORT TextBrowser: public KTextBrowser, public KommanderWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ TextBrowser(QWidget*, const char*);
+ virtual ~TextBrowser();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList &);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString &);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+
+public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void populate();
+
+signals:
+ void widgetOpened();
+ void contextMenuRequested(int xpos, int ypos);
+
+protected:
+ void showEvent(QShowEvent* e);
+ void contextMenuEvent( QContextMenuEvent * e );
+};
+
+#endif
diff --git a/kommander/widgets/textedit.cpp b/kommander/widgets/textedit.cpp
new file mode 100644
index 00000000..b59e0513
--- /dev/null
+++ b/kommander/widgets/textedit.cpp
@@ -0,0 +1,229 @@
+/***************************************************************************
+ textedit.cpp - Rich text editing widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+/* QT INCLUDES */
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qstringlist.h>
+#include <qevent.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "textedit.h"
+#include <klocale.h>
+#include <kommanderplugin.h>
+
+enum Functions {
+ FirstFunction = 450, //CHANGE THIS NUMBER TO AN UNIQUE ONE!!!
+ TE_setModified,
+ TE_selectText,
+ TE_paragraphs,
+ TE_length,
+// TE_getCursorPosition,
+ TE_paragraphLength,
+ TE_linesOfParagraph,
+ TE_findText,
+ TE_VAsuperScript,
+ TE_VAnormalScript,
+ LastFunction
+};
+
+TextEdit::TextEdit(QWidget * a_parent, const char *a_name):KTextEdit(a_parent, a_name),
+KommanderWidget((QObject *) this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+
+ connect(this, SIGNAL(textChanged()), this, SLOT(setTextChanged()));
+
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(TE_setModified, "setModified(QString widget, bool Modified)", i18n("Set widget modified status."), 1);
+ KommanderPlugin::registerFunction(TE_selectText, "selectText(QString widget, int paraFrom, int indexFrom, int paraTo, int indexTo)", i18n("Select a block of text using the paragraph number and character index of the line. You can use the cursorPositionChanged(int, int) signal to get this data in real time into a script."), 5);
+ KommanderPlugin::registerFunction(TE_findText, "findText(QString widget, QString Text, bool Case-Sensitive, bool Forward)", i18n("Search for text from the cursor or a specified position. You can specifiy case sensitive search and forward or backward."), 5);
+// KommanderPlugin::registerFunction(TE_findText, "findText(QString widget, QString Text, bool Case-Sensitive, bool Forward, int Paragraph, int Index)", i18n("Search for text from the cursor or a specified position. You can specifiy case sensitive search and forward or backward."), 5, 7);
+ KommanderPlugin::registerFunction(TE_paragraphs, "paragraphs(QString widget)", i18n("Get the number of paragraphs in the widget."), 1);
+ KommanderPlugin::registerFunction(TE_length, "length(QString widget)", i18n("Get the total length of all text."), 1);
+// KommanderPlugin::registerFunction(TE_getCursorPosition, "getCursorPosition(QString widget)", i18n("Get the cursor postion in the form of paragraph and postion integers."), 1);
+ KommanderPlugin::registerFunction(TE_paragraphLength, "paragraphLength(QString widget, int Paragraph)", i18n("Get the length of the paragraph."), 2);
+ KommanderPlugin::registerFunction(TE_linesOfParagraph, "linesOfParagraph(QString widget, int Paragraph)", i18n("Get the number of lines in the paragraph."), 2);
+ KommanderPlugin::registerFunction(TE_VAsuperScript, "setSuperScript(QString widget)", i18n("Use to set superscript."), 1);
+ KommanderPlugin::registerFunction(TE_VAnormalScript, "setNormalScript(QString widget)", i18n("Use to revert from superscript to normal script."), 1);
+}
+
+QString TextEdit::currentState() const
+{
+ return QString("default");
+}
+
+TextEdit::~TextEdit()
+{
+}
+
+bool TextEdit::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList TextEdit::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void TextEdit::setAssociatedText(const QStringList & a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void TextEdit::setPopulationText(const QString & a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString TextEdit::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void TextEdit::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText(populationText()));
+}
+
+void TextEdit::setWidgetText(const QString & a_text)
+{
+ setText(a_text);
+ emit widgetTextChanged(text());
+}
+
+void TextEdit::setTextChanged()
+{
+ emit widgetTextChanged(text());
+}
+
+void TextEdit::focusOutEvent( QFocusEvent * e)
+{
+ QTextEdit::focusOutEvent(e);
+ emit lostFocus();
+}
+
+void TextEdit::focusInEvent( QFocusEvent * e)
+{
+ QTextEdit::focusInEvent(e);
+ emit gotFocus();
+}
+
+void TextEdit::showEvent(QShowEvent * e)
+{
+ QTextEdit::showEvent(e);
+ emit widgetOpened();
+}
+
+void TextEdit::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool TextEdit::isFunctionSupported(int f)
+{
+ return f == DCOP::text || f == DCOP::setText || f == DCOP::selection || f == DCOP::setSelection || f == DCOP::clear || f == DCOP::setEditable || f == DCOP::geometry || f == DCOP::hasFocus || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor || f == DCOP::isModified || (f >= FirstFunction && f <= LastFunction);
+}
+
+QString TextEdit::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::text:
+ return text();
+ case DCOP::setText:
+ setWidgetText(args[0]);
+ break;
+ case DCOP::selection:
+ return selectedText();
+ case DCOP::setSelection:
+ insert(args[0]);
+ break;
+ case DCOP::clear:
+ setWidgetText(QString());
+ break;
+ case DCOP::setEditable:
+ setReadOnly(args[0] == "false" || args[0] == "0");
+ break;
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ case DCOP::isModified:
+ return isModified() ? "1" : "0";
+ break;
+ case TE_setModified:
+ this->setModified(args[0].toInt());
+ break;
+ case TE_selectText:
+ QTextEdit::setSelection(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt());
+ break;
+ case TE_length:
+ return QString::number(QTextEdit::length() );
+ break;
+ /*case TE_getCursorPosition:
+ return QString::number(QTextEdit::getCursorPosition() );
+ break;*/
+ case TE_paragraphLength:
+ return QString::number(QTextEdit::paragraphLength(args[0].toInt() ) );
+ break;
+ case TE_linesOfParagraph:
+ return QString::number(QTextEdit::linesOfParagraph(args[0].toInt() ) );
+ break;
+ case TE_findText:
+ {
+// int para = args[3].toInt();
+// int idx = args[4].toInt();
+// return QString::number(QTextEdit::find(args[0], args[1].toUInt(), false, args[2].toUInt(), para, idx ));
+ return QString::number(QTextEdit::find(args[0], args[1].toUInt(), false ));
+ break;
+ }
+ case TE_VAsuperScript:
+ break;
+ QTextEdit::setVerticalAlignment(AlignSuperScript);
+ case TE_VAnormalScript:
+ QTextEdit::setVerticalAlignment(AlignNormal);
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::hasFocus:
+ return QString::number(this->hasFocus());
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+#include "textedit.moc"
diff --git a/kommander/widgets/textedit.h b/kommander/widgets/textedit.h
new file mode 100644
index 00000000..7f842343
--- /dev/null
+++ b/kommander/widgets/textedit.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ textedit.h - Rich text editing widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_TEXTEDIT_H_
+#define _HAVE_TEXTEDIT_H_
+
+/* KDE INCLUDES */
+#include <ktextedit.h>
+
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+
+class QShowEvent;
+class KOMMANDER_EXPORT TextEdit: public KTextEdit, public KommanderWidget
+{
+ Q_OBJECT Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ TextEdit(QWidget *, const char *);
+ virtual ~TextEdit();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList &);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString &);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+
+public slots:
+ virtual void setTextChanged();
+ virtual void setWidgetText(const QString &);
+ virtual void populate();
+
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+ void lostFocus();
+ void gotFocus();
+
+protected:
+ void showEvent(QShowEvent* e);
+ void contextMenuEvent( QContextMenuEvent * e );
+ void focusOutEvent( QFocusEvent* e);
+ void focusInEvent( QFocusEvent* e);
+};
+
+#endif
diff --git a/kommander/widgets/timer.cpp b/kommander/widgets/timer.cpp
new file mode 100644
index 00000000..9aff1560
--- /dev/null
+++ b/kommander/widgets/timer.cpp
@@ -0,0 +1,189 @@
+/***************************************************************************
+ timer.cpp - Widget for running scripts periodically
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+/* QT INCLUDES */
+#include <qstringlist.h>
+#include <qtimer.h>
+#include <qwidget.h>
+
+/* KDE INCLUDES */
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+
+
+/* OTHER INCLUDES */
+#include <myprocess.h>
+#include <specials.h>
+#include "timer.h"
+#include "kommanderplugin.h"
+#include "specials.h"
+
+
+enum Functions {
+ FirstFunction = 179,
+ SetInterval,
+ LastFunction
+};
+
+Timer::Timer(QWidget *a_parent, const char *a_name)
+ : QLabel(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ if (KommanderWidget::inEditor)
+ {
+ setPixmap(KGlobal::iconLoader()->loadIcon("kalarm", KIcon::NoGroup, KIcon::SizeMedium));
+ setFrameStyle(QFrame::Box | QFrame::Plain);
+ setLineWidth(1);
+ setFixedSize(pixmap()->size());
+ }
+ else
+ setHidden(true);
+
+ mTimer = new QTimer(this);
+ setInterval(5000);
+ setSingleShot(false);
+ connect(mTimer, SIGNAL(timeout()), SLOT(timeout()));
+
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(SetInterval, "setInterval(QString widget, int interval)", i18n("Set the timer timeout interval in ms."), 2);
+}
+
+Timer::~Timer()
+{
+}
+
+int Timer::interval() const
+{
+ return mInterval;
+}
+
+void Timer::setInterval(int a_interval)
+{
+ if (mTimer->isActive())
+ {
+ mTimer->changeInterval(a_interval);
+ }
+ mInterval = a_interval;
+}
+
+bool Timer::singleShot() const
+{
+ return mSingleShot;
+}
+
+void Timer::setSingleShot(bool a_shot)
+{
+ mSingleShot = a_shot;
+}
+
+QString Timer::currentState() const
+{
+ return QString("default");
+}
+
+bool Timer::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList Timer::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void Timer::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void Timer::setWidgetText(const QString& a_text)
+{
+ KommanderWidget::setAssociatedText(a_text);
+}
+
+void Timer::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString Timer::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void Timer::populate()
+{
+ setAssociatedText(KommanderWidget::evalAssociatedText(populationText()));
+}
+
+void Timer::executeProcess(bool blocking)
+{
+ MyProcess process(this);
+ process.setBlocking(blocking);
+ process.run(evalAssociatedText());
+ if (blocking)
+ emit finished();
+}
+
+void Timer::timeout()
+{
+ executeProcess(true);
+}
+
+void Timer::execute()
+{
+ if (mSingleShot)
+ QTimer::singleShot(mInterval, this, SLOT(timeout()));
+ else
+ mTimer->start(mInterval);
+}
+
+void Timer::cancel()
+{
+ mTimer->stop();
+}
+
+
+
+bool Timer::isFunctionSupported(int f)
+{
+ return f == DCOP::setText || f == DCOP::execute || f == DCOP::cancel || (f > FirstFunction && f < LastFunction);
+}
+
+QString Timer::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::setText:
+ setAssociatedText(args[0]);
+ break;
+ case DCOP::execute:
+ execute();
+ break;
+ case DCOP::cancel:
+ cancel();
+ break;
+ case SetInterval:
+ setInterval(args[0].toInt());
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "timer.moc"
diff --git a/kommander/widgets/timer.h b/kommander/widgets/timer.h
new file mode 100644
index 00000000..856ceeb3
--- /dev/null
+++ b/kommander/widgets/timer.h
@@ -0,0 +1,71 @@
+/***************************************************************************
+ timer.h - Widget for running scripts periodically
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ **************************************************************************/
+#ifndef _HAVE_TIMER_H_
+#define _HAVE_TIMER_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qlabel.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+
+class QTimer;
+class KOMMANDER_EXPORT Timer : public QLabel, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+ Q_PROPERTY(int interval READ interval WRITE setInterval)
+ Q_PROPERTY(bool singleShot READ singleShot WRITE setSingleShot)
+
+ public:
+ Timer(QWidget *a_parent, const char *a_name);
+ ~Timer();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+ virtual int interval() const;
+ virtual void setInterval(int a_interval);
+ virtual bool singleShot() const;
+ virtual void setSingleShot(bool a_shot);
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+ public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void populate();
+ virtual void execute();
+ virtual void cancel();
+ protected slots:
+ virtual void timeout();
+ signals:
+ void finished();
+
+ protected:
+ virtual void executeProcess(bool blocking);
+ QTimer* mTimer;
+ int mInterval;
+ bool mSingleShot;
+
+};
+
+#endif
diff --git a/kommander/widgets/toolbox.cpp b/kommander/widgets/toolbox.cpp
new file mode 100644
index 00000000..90a31e46
--- /dev/null
+++ b/kommander/widgets/toolbox.cpp
@@ -0,0 +1,190 @@
+//
+// C++ Implementation: toolbox
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "toolbox.h"
+#include "kommanderplugin.h"
+#include "specials.h"
+
+
+#include <klocale.h>
+
+#define ADDWIDGET 120
+#define CURRENTWIDGET 121
+#define REMOVEWIDGET 122
+#define REMOVEWIDGETAT 123
+#define SETCURRENTWIDGET 124
+#define CURRENTINDEX 125
+#define WIDGETAT 126
+#define INDEXOF 127
+#define FIRST_FUNCTION ADDWIDGET
+#define LAST_FUNCTION INDEXOF
+
+ToolBox::ToolBox(QWidget *parent, const char *name)
+ : QToolBox(parent, name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(ADDWIDGET, "addWidget(QString widget, QString widgetName, QString Label)",
+ i18n("Adds a widget to the toolbox. Returns the index of the widget."), 3);
+ KommanderPlugin::registerFunction(CURRENTWIDGET, "currentWidget(QString widget)",
+ i18n("Returns the name of the active widget."), 1);
+ KommanderPlugin::registerFunction(REMOVEWIDGET, "removeWidget(QString widget, QString widgetName)", i18n("Remove the selected widget, returns the index of the removed widget or -1 if no such widget was found."), 2);
+ KommanderPlugin::registerFunction(REMOVEWIDGETAT, "removeWidgetAt(QString widget, int index)", i18n("Remove the widget from the index position, returns the index of the removed widget or -1 if no widget was found."), 2);
+ KommanderPlugin::registerFunction(SETCURRENTWIDGET, "setCurrentWidget(QString widget, QString widgetName)",
+ i18n("Activates the selected widget."), 2);
+ KommanderPlugin::registerFunction(CURRENTINDEX, "currentIndex(QString widget)",
+ i18n("Returns the index of the active widget."), 1);
+ KommanderPlugin::registerFunction(WIDGETAT, "widgetAt(QString widget, int index)",
+ i18n("Returns the widget having the supplied index."), 2);
+ KommanderPlugin::registerFunction(INDEXOF, "indexOf(QString widget, QString widgetName)",
+ i18n("Returns the index of the widget, -1 if the widget is not part of the toolbox."), 2);
+
+}
+
+
+ToolBox::~ToolBox()
+{
+}
+
+QString ToolBox::currentState() const
+{
+ return QString("default");
+}
+
+bool ToolBox::isKommanderWidget() const
+{
+ return true;
+}
+
+void ToolBox::populate()
+{
+ setAssociatedText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+QStringList ToolBox::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void ToolBox::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void ToolBox::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString ToolBox::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+
+QString ToolBox::addWidget(const QString& widgetName, const QString &label)
+{
+ KommanderWidget *w = widgetByName(widgetName);
+ if (w)
+ {
+ int idx = addItem(dynamic_cast<QWidget*>(w), label);
+ adjustSize();
+ return QString::number(idx);
+ } else
+ return QString("-1");
+
+}
+
+void ToolBox::showEvent(QShowEvent* e)
+{
+ QToolBox::showEvent(e);
+ emit widgetOpened();
+}
+
+void ToolBox::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+bool ToolBox::isFunctionSupported(int f)
+{
+ return f == DCOP::count || f == DCOP::geometry || (f >= FIRST_FUNCTION && f <= LAST_FUNCTION) ;
+}
+
+QString ToolBox::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case ADDWIDGET:
+ return addWidget(args[0], args[1]);
+ break;
+ case CURRENTWIDGET:
+ {
+ QWidget *w = currentItem();
+ if (w)
+ return w->name();
+ else
+ return QString();
+ break;
+ }
+ case SETCURRENTWIDGET:
+ {
+ KommanderWidget *w = widgetByName(args[0]);
+ setCurrentItem(dynamic_cast<QWidget*>(w));
+ return QString();
+ }
+ case REMOVEWIDGET:
+ {
+ KommanderWidget *w = widgetByName(args[0]);
+ return QString::number(removeItem(dynamic_cast<QWidget*>(w)));
+ }
+ case REMOVEWIDGETAT:
+ {
+ QWidget *w = item(args[0].toInt());
+ return QString::number(removeItem(w));
+ }
+ case CURRENTINDEX:
+ {
+ return QString::number(currentIndex());
+ break;
+ }
+ case WIDGETAT:
+ {
+ QWidget *w = item(args[0].toInt());
+ if (w)
+ return w->name();
+ else
+ return QString();
+ break;
+ }
+ case INDEXOF:
+ {
+ KommanderWidget *w = widgetByName(args[0]);
+ return QString::number(indexOf(dynamic_cast<QWidget*>(w)));
+ }
+ case DCOP::count:
+ return QString::number(count());
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+#include "toolbox.moc"
diff --git a/kommander/widgets/toolbox.h b/kommander/widgets/toolbox.h
new file mode 100644
index 00000000..9171aa32
--- /dev/null
+++ b/kommander/widgets/toolbox.h
@@ -0,0 +1,54 @@
+//
+// C++ Interface: toolbox
+//
+// Description:
+//
+//
+// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef TOOLBOX_H
+#define TOOLBOX_H
+
+#include <qtoolbox.h>
+#include <kommanderwidget.h>
+
+/**
+ @author Andras Mantia <amantia@kdewebdev.org>
+*/
+class ToolBox : public QToolBox, public KommanderWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+public:
+ ToolBox(QWidget *parent = 0, const char *name = 0);
+
+ ~ToolBox();
+
+ virtual bool isKommanderWidget() const;
+ virtual QString currentState() const;
+ virtual bool isFunctionSupported(int function);
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual QStringList associatedText() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+public slots:
+ virtual void populate();
+
+signals:
+ void widgetOpened();
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+ QString addWidget(const QString& widgetName, const QString &label);
+
+};
+
+#endif
diff --git a/kommander/widgets/treewidget.cpp b/kommander/widgets/treewidget.cpp
new file mode 100644
index 00000000..578384c5
--- /dev/null
+++ b/kommander/widgets/treewidget.cpp
@@ -0,0 +1,512 @@
+/***************************************************************************
+ treewidget.cpp - Tree/detailed list widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.org>
+ (C) 2008 Andras Mantia <amantia@kdewebdev.org>
+ (C) 2008 Eric Laffoon <eric@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+#include <klocale.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klistview.h>
+
+/* QT INCLUDES */
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qlistview.h>
+
+/* OTHER INCLUDES */
+#include <specials.h>
+#include "treewidget.h"
+#include "kommanderplugin.h"
+#include "specials.h"
+
+#define TW_FUNCTION 275
+#define addColumnTree TW_FUNCTION+1
+#define setAltBackground TW_FUNCTION+2
+#define setColAlignment TW_FUNCTION+3
+//#define colCount TW_FUNCTION+3
+#define colCaption TW_FUNCTION+4
+#define setColWidth TW_FUNCTION+5
+#define setSortCol TW_FUNCTION+6
+#define TW_LAST_FUNCTION setSortCol
+
+enum Functions {
+ FirstFunction = 189,
+ SelectedIndexes,
+ TW_childCount,
+ TW_setOpen,
+ TW_isOpen,
+ LastFunction
+};
+
+TreeWidget::TreeWidget(QWidget *a_parent, const char *a_name)
+ : KListView(a_parent, a_name), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ setStates(states);
+ setDisplayStates(states);
+ setPathSeparator("/");
+ KommanderPlugin::setDefaultGroup(Group::DCOP);
+ KommanderPlugin::registerFunction(SelectedIndexes, "selectedIndexes(QString widget)", "", 1);
+ KommanderPlugin::registerFunction(addColumnTree, "addColumn(QString widget, const QString & label, int width = -1 )", i18n("Add column at end with column header"), 2, 3);
+ KommanderPlugin::registerFunction(setSortCol, "setSortColumn(QString widget, int column, bool ascending=true)", i18n("Set sorting for a column"), 2, 3);
+ //KommanderPlugin::registerFunction(setAltBackground, "setAltBackground(QString widget, const QColor & c)", i18n("Alternate colors in list view"), 2);
+// KommanderPlugin::registerFunction(colCount, "colCount(QString widget)", i18n("Get the column count"), 1);
+ KommanderPlugin::registerFunction(colCaption, "columnCaption(QString widget, int column)", i18n("Get the column caption for column index"), 2);
+ KommanderPlugin::registerFunction(setColWidth, "setColWidth(QString widget, int column, int width)", i18n("Set the pixel width for column index - use 0 to hide"), 3);
+ KommanderPlugin::registerFunction(setColAlignment, "setColumnAlignment(QString widget, int column, QString Alignment)", i18n("Set to <i>left</i>, <i>right</i> or <i>center</i>, case insensitive "), 3);
+ KommanderPlugin::registerFunction(TW_childCount, "childCount(QString widget)", i18n("Get the count of top level items."), 1);
+ KommanderPlugin::registerFunction(TW_setOpen, "setOpen(QString widget, int Index, bool Open)", i18n("Expand or collapse a node."), 3);
+ KommanderPlugin::registerFunction(TW_isOpen, "isOpen(QString widget, int Index)", i18n("See if node is open or closed."), 2);
+}
+
+TreeWidget::~TreeWidget()
+{
+}
+
+QString TreeWidget::pathSeparator() const
+{
+ return m_pathSeparator;
+}
+
+void TreeWidget::setPathSeparator(const QString& a_pathSep)
+{
+ m_pathSeparator = a_pathSep;
+}
+
+void TreeWidget::addItemFromString(const QString& s)
+{
+ QStringList elements = QStringList::split(m_pathSeparator, s, true);
+ if (elements.count() > 1)
+ setRootIsDecorated(true);
+ QListViewItem* parent = 0;
+ if (m_lastPath.size() < elements.count())
+ m_lastPath.resize(elements.count());
+ uint i = 0;
+ for (QStringList::ConstIterator it = elements.begin(); it != elements.end(); ++it)
+ {
+ if (m_lastPath[i] && m_lastPath[i]->text(0) == elements[i])
+ {
+ parent = m_lastPath[i];
+ i++;
+ continue;
+ }
+ else
+ {
+ QListViewItem* item = (i>0) ? parent->firstChild() : firstChild();
+ while (item)
+ {
+ if (item->text(0) == *it)
+ break;
+ item = item->nextSibling();
+ }
+ if (item)
+ parent = item;
+ else
+ parent = itemFromString(parent, *it);
+ m_lastPath.insert(i, parent);
+ i++;
+ }
+ }
+}
+
+QListViewItem* TreeWidget::itemFromString(QListViewItem* parent, const QString& s)
+{
+ QStringList elements;
+ if (s.contains("\t"))
+ elements = QStringList::split("\t", s, true);
+ else
+ elements = QStringList::split("\\t", s, true);
+ int cols = elements.count();
+ if (cols >= columns())
+ cols = columns();
+ QListViewItem* item;
+ if (parent)
+ item = new QListViewItem(parent);
+ else
+ item = new QListViewItem(this);
+ int i = 0;
+ for (QStringList::ConstIterator it = elements.constBegin(); it != elements.constEnd(); ++it)
+ item->setText(i++, *it);
+ return item;
+}
+
+int TreeWidget::itemToIndex(QListViewItem* item)
+{
+// if (!item->isSelected())
+// return -1;
+ QListViewItemIterator it(this);
+ int index = 0;
+ while (it.current()) {
+ if (it.current() == item)
+ return index;
+ ++it;
+ ++index;
+ }
+ return -1;
+}
+
+int TreeWidget::itemToIndexSafe(QListViewItem* item)
+{
+ QListViewItemIterator it(this);
+ int index = 0;
+ while (it.current()) {
+ if (it.current() == item)
+ return index;
+ ++it;
+ ++index;
+ }
+ return -1;
+}
+
+QListViewItem* TreeWidget::indexToItem(int item)
+{
+ QListViewItemIterator it(this);
+ int index = 0;
+ while (it.current()) {
+ if (index == item)
+ return it.current();
+ ++it;
+ ++index;
+ }
+ return 0;
+}
+
+QString TreeWidget::itemText(QListViewItem* item) const
+{
+ if (!item)
+ return QString();
+ QStringList items;
+ for (int i=0; i<columns(); i++)
+ items.append(item->text(i));
+ return items.join("\t");
+}
+
+QString TreeWidget::itemsText()
+{
+ QStringList items;
+ QListViewItemIterator it(this);
+ while (it.current())
+ {
+ QString path = itemPath(it.current());
+ if (path.isEmpty())
+ items.append(itemText(it.current()));
+ else
+ items.append(QString("%1%2%3").arg(path).arg(m_pathSeparator)
+ .arg(itemText(it.current())));
+ ++it;
+ }
+ return items.join("\n");
+}
+
+QString TreeWidget::itemPath(QListViewItem* item) const
+{
+ if (!item)
+ return QString();
+ item = item->parent();
+ if (!item)
+ return QString();
+ QStringList path;
+ while (item)
+ {
+ path.prepend(item->text(0));
+ item = item->parent();
+ }
+ return path.join(m_pathSeparator);
+}
+
+QString TreeWidget::currentState() const
+{
+ return QString("default");
+}
+
+bool TreeWidget::isKommanderWidget() const
+{
+ return true;
+}
+
+void TreeWidget::setCurrentItem(QListViewItem* item)
+{
+ KListView::setCurrentItem(item);
+ setSelected(item, true);
+ ensureItemVisible(item);
+}
+
+QStringList TreeWidget::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void TreeWidget::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void TreeWidget::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText( a_text );
+}
+
+QString TreeWidget::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void TreeWidget::populate()
+{
+ setWidgetText(KommanderWidget::evalAssociatedText( populationText()));
+}
+
+void TreeWidget::setWidgetText(const QString &a_text)
+{
+ handleDCOP(DCOP::setText, a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void TreeWidget::showEvent(QShowEvent* e)
+{
+ QListView::showEvent( e );
+ emit widgetOpened();
+}
+
+void TreeWidget::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+void TreeWidget::setColAlign(int column, const QString& align)
+{
+ if (align.lower() == "left")
+ setColumnAlignment (column, Qt::AlignLeft);
+ else if (align.lower() == "right")
+ setColumnAlignment (column, Qt::AlignRight);
+ else if (align.lower() == "center")
+ setColumnAlignment (column, Qt::AlignCenter);
+}
+
+bool TreeWidget::isFunctionSupported(int f)
+{
+ return f == DCOP::insertItem || f == DCOP::text || f == DCOP::setText || f == DCOP::insertItems ||
+ f == DCOP::selection || f == DCOP::setSelection || f == DCOP::clear || f == DCOP::removeItem ||
+ f == DCOP::currentItem || f == DCOP::setCurrentItem || f == DCOP::findItem || f == DCOP::item ||
+ f == DCOP::itemPath || f == DCOP::itemDepth || f == DCOP::setPixmap || f == DCOP::setColumnCaption || f == DCOP::removeColumn || f == DCOP::columnCount || f == DCOP::geometry || f == DCOP::hasFocus || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor || (f > FirstFunction && f < LastFunction) || (f >= TW_FUNCTION && f <= TW_LAST_FUNCTION);
+}
+
+QString TreeWidget::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::insertItem:
+ addItemFromString(args[0]);
+ break;
+ case DCOP::text:
+ return itemsText();
+ case DCOP::setText:
+ clear(); /* break omitted: setText is equivalent to clear and insertItems */
+ m_lastPath.clear();
+ case DCOP::insertItems:
+ {
+ QStringList items(QStringList::split("\n", args[0], true));
+ for (QStringList::ConstIterator it = items.constBegin(); it != items.constEnd(); ++it)
+ addItemFromString(*it);
+ break;
+ }
+ case TW_setOpen:
+ setOpen(indexToItem(args[0].toInt()), args[1].toInt());
+ break;
+ case TW_isOpen:
+ return QString::number(isOpen(indexToItem(args[0].toInt())));
+ break;
+ case SelectedIndexes:
+ {
+ QString selection = "";
+ QListViewItemIterator it(this);
+ while (it.current())
+ {
+ if (it.current()->isSelected())
+ {
+ selection.append(QString("%1\n").arg(itemToIndexSafe(it.current())));
+ }
+ ++it;
+ }
+ if (!selection.isEmpty())
+ selection = selection.left(selection.length() - 1);
+ return selection;
+ break;
+ }
+ case DCOP::selection:
+ {
+ QString selection = "";
+ QListViewItemIterator it(this);
+ while (it.current())
+ {
+ if (it.current()->isSelected())
+ selection.append(itemText(it.current()) + "\n");
+ ++it;
+ }
+ if (!selection.isEmpty())
+ selection = selection.left(selection.length() - 1);
+ return selection;
+ break;
+ }
+ case DCOP::setSelection:
+ if (selectionModeExt() == Single || selectionModeExt() == NoSelection)
+ setCurrentItem(findItem(args[0], 0));
+ else
+ {
+ clearSelection();
+ QStringList items(QStringList::split("\n", args[0]));
+ for (QStringList::ConstIterator it = items.begin(); it != items.end(); ++it)
+ {
+ QListViewItem* item = findItem(*it, 0);
+ if (item)
+ {
+ item->setSelected(true);
+ ensureItemVisible(item);
+ }
+ }
+ }
+ break;
+ case DCOP::clear:
+ clear();
+ m_lastPath.clear();
+ break;
+ case DCOP::removeItem:
+ {
+ if (args[0].toInt() >= 0 )
+ {
+ delete indexToItem(args[0].toInt());
+ m_lastPath.clear();
+ }
+ break;
+ }
+ case DCOP::currentItem:
+ return QString::number(itemToIndexSafe(currentItem()));
+ break;
+ case DCOP::setCurrentItem:
+ setCurrentItem(indexToItem(args[0].toInt()));
+ break;
+ case DCOP::findItem:
+ if (!args[1])
+ return QString::number(itemToIndexSafe(findItem(args[0], 0)));
+ else
+ {
+ if (args[2].toUInt() && args[3].toUInt())
+ return QString::number(itemToIndexSafe(findItem(args[0], args[1].toInt())));
+ else if (args[2].toUInt())
+ return QString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::CaseSensitive | Qt::Contains)));
+ else if (args[3].toUInt())
+ return QString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::ExactMatch)));
+ else
+ return QString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::Contains)));
+ }
+ break;
+ case DCOP::item:
+ return itemText(indexToItem(args[0].toInt()));
+ break;
+ case DCOP::itemPath:
+ return itemPath(indexToItem(args[0].toInt()));
+ break;
+ case DCOP::itemDepth:
+ {
+ QListViewItem* item = indexToItem(args[0].toInt());
+ return (item) ? QString::number(item->depth()) : QString::number(-1);
+ }
+ case DCOP::setPixmap:
+ {
+ QPixmap pixmap = KGlobal::iconLoader()->loadIcon(args[0], KIcon::Small);
+ if (args[1].toInt() == -1)
+ for (QListViewItemIterator it(this); it.current(); ++it)
+ it.current()->setPixmap(0, pixmap);
+ else
+ {
+ QListViewItem* item = indexToItem(args[1].toInt());
+ if (item)
+ item->setPixmap(0, pixmap);
+ }
+ break;
+ }
+ case DCOP::setColumnCaption:
+ if (columns() >= args[0].toInt())
+ setColumnText(args[0].toInt(), args[1]);
+ break;
+ case DCOP::getBackgroundColor:
+ return this->paletteBackgroundColor().name();
+ break;
+ case DCOP::setBackgroundColor:
+ {
+ QColor color;
+ color.setNamedColor(args[0]);
+ this->setPaletteBackgroundColor(color);
+ break;
+ }
+ case addColumnTree:
+ return QString::number(KListView::addColumn(args[0], args[1].toInt()));
+ break;
+ case setSortCol:
+ KListView::setSorting(args[0].toInt(), args[1].toInt());
+ break;
+ case DCOP::columnCount:
+ return QString::number(QListView::columns() );
+ break;
+ case colCaption:
+ return QListView::columnText(args[0].toInt()) ;
+ break;
+ case setColWidth:
+ QListView::setColumnWidth(args[0].toInt(), args[1].toInt());
+ break;
+ case setColAlignment:
+ setColAlign(args[0].toInt(), args[1]);
+ break;
+ case setAltBackground:
+ KListView::setAlternateBackground(QColor(args[0]));
+ break;
+ case DCOP::removeColumn:
+ {
+ if (!args[1].toInt())
+ removeColumn(args[0].toInt());
+ else
+ {
+ int column = args[0].toInt();
+ int lines = args[1].toInt();
+ for (int i = 0; i < lines; i++)
+ removeColumn(column);
+ }
+ break;
+ }
+ case TW_childCount:
+ return QString::number(childCount());
+ break;
+ case DCOP::geometry:
+ {
+ QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ return geo;
+ break;
+ }
+ case DCOP::hasFocus:
+ return QString::number(this->hasFocus());
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+#include "treewidget.moc"
diff --git a/kommander/widgets/treewidget.h b/kommander/widgets/treewidget.h
new file mode 100644
index 00000000..29d0a747
--- /dev/null
+++ b/kommander/widgets/treewidget.h
@@ -0,0 +1,87 @@
+/***************************************************************************
+ treewidget.h - Tree/detailed list widget
+ -------------------
+ copyright : (C) 2002-2003 Marc Britton <consume@optusnet.com.au>
+ (C) 2004 Michal Rudolf <mrudolf@kdewebdev.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_TREEWIDGET_H_
+#define _HAVE_TREEWIDGET_H_
+
+/* KDE INCLUDES */
+#include <klistview.h>
+
+/* QT INCLUDES */
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qptrvector.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+
+class QWidget;
+
+class QShowEvent;
+class KOMMANDER_EXPORT TreeWidget : public KListView, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+ Q_PROPERTY(QString pathSeparator READ pathSeparator WRITE setPathSeparator)
+
+public:
+ TreeWidget(QWidget *a_parent, const char *a_name);
+ ~TreeWidget();
+ virtual void setCurrentItem(QListViewItem* item);
+ QString pathSeparator() const;
+ void setPathSeparator(const QString& a_pathSep);
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ virtual bool isFunctionSupported(int function);
+public slots:
+ virtual void setWidgetText(const QString&);
+ virtual void populate();
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString&);
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent(QShowEvent *e);
+ void contextMenuEvent( QContextMenuEvent * e );
+ int itemToIndex(QListViewItem* item);
+ int itemToIndexSafe(QListViewItem* item);
+ QString itemText(QListViewItem* item) const;
+ QString itemsText();
+ QListViewItem* indexToItem(int index);
+ QString itemPath(QListViewItem* item) const;
+private:
+ void addItemFromString(const QString& s);
+ QListViewItem* itemFromString(QListViewItem* parent, const QString& s);
+ QPtrVector<QListViewItem> m_lastPath;
+ QString m_pathSeparator;
+ int addColumnTree(const QString & label, int width = -1 );
+ void setSortCol(int column, bool ascending=true);
+ void setAltBackground(const QColor & c);
+ void setColAlign(int column, const QString& align);
+};
+
+#endif
diff --git a/kommander/widgets/widgets.desktop b/kommander/widgets/widgets.desktop
new file mode 100644
index 00000000..f24396de
--- /dev/null
+++ b/kommander/widgets/widgets.desktop
@@ -0,0 +1,36 @@
+[Desktop Entry]
+Name=Widgets
+Name[bg]=Графични обекти
+Name[br]=Widgetoù
+Name[ca]=Estris
+Name[cs]=Widgety
+Name[cy]=Celfigion
+Name[da]=Kontroller
+Name[el]=Γραφικά συστατικά
+Name[et]=Elemendid
+Name[fa]=عناصر
+Name[fi]=Elementit
+Name[fr]=Éléments graphiques
+Name[ga]=Giuirléidí
+Name[hi]=विजेट्स
+Name[hu]=Grafikai elemek
+Name[ja]=ウィジェット
+Name[lt]=Valdikliai
+Name[ms]=Wijet
+Name[ne]=विजेट
+Name[pl]=Elementy interfejsu
+Name[pt]=Elementos
+Name[pt_BR]=Janelas
+Name[ru]=Виджеты
+Name[sl]=Gradniki
+Name[sr]=Контроле
+Name[sr@Latn]=Kontrole
+Name[sv]=Grafiska komponenter
+Name[ta]=சின்னப் படங்கள்
+Name[tg]=Васеъкуниҳо
+Name[tr]=Bileşenler
+Name[uk]=Віджети
+Name[zh_CN]=部件
+Exec=widgets %i %m -caption "%c"
+Type=Application
+Terminal=false
diff --git a/kommander/widgets/wizard.cpp b/kommander/widgets/wizard.cpp
new file mode 100644
index 00000000..7e6a07b4
--- /dev/null
+++ b/kommander/widgets/wizard.cpp
@@ -0,0 +1,194 @@
+/***************************************************************************
+ wizard.cpp - Widget providing a wizard
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+/* KDE INCLUDES */
+#include <kprocess.h>
+
+/* QT INCLUDES */
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qwizard.h>
+#include <qdialog.h>
+
+/* OTHER INCLUDES */
+#include <myprocess.h>
+#include <kommanderfactory.h>
+#include <specials.h>
+#include "wizard.h"
+
+
+Wizard::Wizard(QWidget *a_parent, const char *a_name, bool a_modal, int a_flags)
+ : QWizard(a_parent, a_name, a_modal, a_flags), KommanderWidget(this)
+{
+ QStringList states;
+ states << "default";
+ states << "initialization";
+ states << "destroy";
+ setStates(states);
+ setDisplayStates(states);
+
+ connect(this, SIGNAL(helpClicked()), SLOT(runHelp()));
+}
+
+Wizard::~Wizard()
+{
+ if (!inEditor)
+ destroy();
+}
+
+QString Wizard::currentState() const
+{
+ return QString("default");
+}
+
+bool Wizard::isKommanderWidget() const
+{
+ return true;
+}
+
+QStringList Wizard::associatedText() const
+{
+ return KommanderWidget::associatedText();
+}
+
+void Wizard::setAssociatedText(const QStringList& a_at)
+{
+ KommanderWidget::setAssociatedText(a_at);
+}
+
+void Wizard::setPopulationText(const QString& a_text)
+{
+ KommanderWidget::setPopulationText(a_text);
+}
+
+QString Wizard::populationText() const
+{
+ return KommanderWidget::populationText();
+}
+
+void Wizard::populate()
+{
+ QString txt = KommanderWidget::evalAssociatedText(populationText());
+//FIXME: implement me
+}
+
+void Wizard::setWidgetText(const QString &a_text)
+{
+ setCaption(a_text);
+ emit widgetTextChanged(a_text);
+}
+
+void Wizard::initialize()
+{
+ setFinishEnabled(page(pageCount() - 1), true);
+ const QStringList assoc = associatedText();
+ if (assoc.count() > 1 && !assoc[1].isEmpty())
+ {
+ MyProcess proc(this);
+ proc.run( KommanderWidget::evalAssociatedText(assoc[1]) );
+ }
+}
+
+void Wizard::destroy()
+{
+ const QStringList assoc = associatedText();
+ if (assoc.count() > 2 && !assoc[2].isEmpty())
+ {
+ MyProcess proc(this);
+ proc.run(KommanderWidget::evalAssociatedText(assoc[2]));
+ }
+}
+
+void Wizard::exec()
+{
+ QWizard::exec();
+ emit finished();
+}
+
+void Wizard::show()
+{
+ QWizard::show();
+ if (!inEditor)
+ initialize();
+}
+
+void Wizard::runHelp()
+{
+ if (helpAction() == Command)
+ {
+ KProcess proc;
+ proc << helpActionText();
+ proc.start(KProcess::DontCare, KProcess::NoCommunication);
+ }
+ else if (helpAction() == Dialog)
+ {
+ KommanderFactory::loadPlugins();
+ QDialog *dialog = (QDialog *)KommanderFactory::create(helpActionText());
+ dialog->exec();
+ delete dialog;
+ }
+}
+
+Wizard::HelpAction Wizard::helpAction() const
+{
+ return m_helpAction;
+}
+
+void Wizard::setHelpAction(HelpAction a_helpAction)
+{
+ m_helpAction = a_helpAction;
+}
+
+QString Wizard::helpActionText() const
+{
+ return m_helpActionText;
+}
+
+void Wizard::setHelpActionText(const QString& a_helpActionText)
+{
+ m_helpActionText = a_helpActionText;
+}
+
+
+void Wizard::showEvent(QShowEvent *e)
+{
+ QWizard::showEvent(e);
+ emit widgetOpened();
+}
+
+void Wizard::contextMenuEvent( QContextMenuEvent * e )
+{
+ e->accept();
+ QPoint p = e->globalPos();
+ emit contextMenuRequested(p.x(), p.y());
+}
+
+QString Wizard::handleDCOP(int function, const QStringList& args)
+{
+ switch (function) {
+ case DCOP::setEnabled:
+ setFinishEnabled(page(pageCount() - 1), args[0] != "false");
+ break;
+ default:
+ return KommanderWidget::handleDCOP(function, args);
+ }
+ return QString();
+}
+
+
+
+#include "wizard.moc"
diff --git a/kommander/widgets/wizard.h b/kommander/widgets/wizard.h
new file mode 100644
index 00000000..868a14bc
--- /dev/null
+++ b/kommander/widgets/wizard.h
@@ -0,0 +1,82 @@
+/***************************************************************************
+ wizard.h - Widget providing a wizard
+ -------------------
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optusnet.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+#ifndef _HAVE_WIZARD_H_
+#define _HAVE_WIZARD_H_
+
+/* KDE INCLUDES */
+
+/* QT INCLUDES */
+#include <qwizard.h>
+
+/* OTHER INCLUDES */
+#include <kommanderwidget.h>
+#include <kommander_export.h>
+#include <myprocess.h>
+
+class QShowEvent;
+class KOMMANDER_EXPORT Wizard : public QWizard, public KommanderWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString populationText READ populationText WRITE setPopulationText DESIGNABLE false)
+ Q_PROPERTY(QStringList associations READ associatedText WRITE setAssociatedText DESIGNABLE false)
+ Q_PROPERTY(bool KommanderWidget READ isKommanderWidget)
+ Q_PROPERTY(HelpAction helpAction READ helpAction WRITE setHelpAction)
+ Q_ENUMS(HelpAction)
+ Q_PROPERTY(QString helpActionText READ helpActionText WRITE setHelpActionText)
+
+public:
+ Wizard(QWidget *, const char *, bool = true, int = 0);
+ ~Wizard();
+
+ virtual bool isKommanderWidget() const;
+ virtual void setAssociatedText(const QStringList&);
+ virtual QStringList associatedText() const;
+ virtual QString currentState() const;
+ virtual QString populationText() const;
+ virtual void setPopulationText(const QString&);
+
+ virtual QString handleDCOP(int function, const QStringList& args);
+ enum HelpAction { None, Command, Dialog };
+ HelpAction helpAction() const;
+ void setHelpAction(HelpAction);
+ QString helpActionText() const;
+ void setHelpActionText(const QString&);
+
+public slots:
+ virtual void setWidgetText(const QString &);
+ virtual void exec();
+ virtual void show();
+ virtual void runHelp();
+ virtual void populate();
+protected slots:
+ virtual void initialize();
+ virtual void destroy();
+
+signals:
+ void widgetOpened();
+ void widgetTextChanged(const QString &);
+ void finished();
+ void contextMenuRequested(int xpos, int ypos);
+protected:
+ void showEvent( QShowEvent *e );
+ void contextMenuEvent( QContextMenuEvent * e );
+
+ HelpAction m_helpAction;
+ QString m_helpActionText;
+};
+
+#endif