summaryrefslogtreecommitdiff
path: root/core/settings
authorsandman <sandman>2002-09-12 01:54:38 (UTC)
committer sandman <sandman>2002-09-12 01:54:38 (UTC)
commit5443baf95c52ed0ead459fec48cb877d71a0e427 (patch) (side-by-side diff)
tree80718baad2fda769200ef442bcd7bf4e86ba9c82 /core/settings
parentb35aa16e051554783b30f1551ad7677e382cc823 (diff)
downloadopie-5443baf95c52ed0ead459fec48cb877d71a0e427.zip
opie-5443baf95c52ed0ead459fec48cb877d71a0e427.tar.gz
opie-5443baf95c52ed0ead459fec48cb877d71a0e427.tar.bz2
New launcher/taskbar settings (merge from QPE 1.6 - reworked)
Diffstat (limited to 'core/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/launcher/launcher.pro17
-rw-r--r--core/settings/launcher/launchersettings.cpp39
-rw-r--r--core/settings/launcher/launchersettings.h23
-rw-r--r--core/settings/launcher/main.cpp35
-rw-r--r--core/settings/launcher/tabssettings.cpp177
-rw-r--r--core/settings/launcher/tabssettings.h52
-rw-r--r--core/settings/launcher/taskbarsettings.cpp169
-rw-r--r--core/settings/launcher/taskbarsettings.h35
8 files changed, 547 insertions, 0 deletions
diff --git a/core/settings/launcher/launcher.pro b/core/settings/launcher/launcher.pro
new file mode 100644
index 0000000..a46a22f
--- a/dev/null
+++ b/core/settings/launcher/launcher.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+CONFIG += qt warn_on release
+DESTDIR = $(OPIEDIR)/bin
+HEADERS = launchersettings.h \
+ tabssettings.h \
+ taskbarsettings.h
+
+SOURCES = main.cpp \
+ launchersettings.cpp \
+ tabssettings.cpp \
+ taskbarsettings.cpp
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopie
+TARGET = launchersettings
+
diff --git a/core/settings/launcher/launchersettings.cpp b/core/settings/launcher/launchersettings.cpp
new file mode 100644
index 0000000..b794519
--- a/dev/null
+++ b/core/settings/launcher/launchersettings.cpp
@@ -0,0 +1,39 @@
+
+#include <qlayout.h>
+
+#include <opie/otabwidget.h>
+
+#include "launchersettings.h"
+#include "tabssettings.h"
+#include "taskbarsettings.h"
+
+
+LauncherSettings::LauncherSettings ( ) : QDialog ( 0, "LauncherSettings", false )
+{
+ setCaption ( tr( "Launcher Settings" ));
+
+ QVBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
+
+ OTabWidget *tw = new OTabWidget ( this, "otab" );
+ lay-> addWidget ( tw );
+
+ m_tabs = new TabsSettings ( tw );
+ m_taskbar = new TaskbarSettings ( tw );
+
+ tw-> addTab ( m_taskbar, "appearance/styletabicon.png", tr( "Taskbar" ));
+ tw-> addTab ( m_tabs, "appearance/styletabicon.png", tr( "Tabs" ));
+}
+
+void LauncherSettings::accept ( )
+{
+ m_taskbar-> accept ( );
+ m_tabs-> accept ( );
+
+ QDialog::accept ( );
+}
+
+void LauncherSettings::done ( int r )
+{
+ QDialog::done ( r );
+ close ( );
+}
diff --git a/core/settings/launcher/launchersettings.h b/core/settings/launcher/launchersettings.h
new file mode 100644
index 0000000..c91c765
--- a/dev/null
+++ b/core/settings/launcher/launchersettings.h
@@ -0,0 +1,23 @@
+#ifndef __LAUNCHER_SETTINGS_H__
+#define __LAUNCHER_SETTINGS_H__
+
+#include <qdialog.h>
+
+class TabsSettings;
+class TaskbarSettings;
+
+class LauncherSettings : public QDialog {
+ Q_OBJECT
+
+public:
+ LauncherSettings ( );
+
+ virtual void accept ( );
+ virtual void done ( int r );
+
+private:
+ TabsSettings *m_tabs;
+ TaskbarSettings *m_taskbar;
+};
+
+#endif
diff --git a/core/settings/launcher/main.cpp b/core/settings/launcher/main.cpp
new file mode 100644
index 0000000..ca7102d
--- a/dev/null
+++ b/core/settings/launcher/main.cpp
@@ -0,0 +1,35 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "launchersettings.h"
+
+#include <qpe/qpeapplication.h>
+
+
+int main ( int argc, char** argv )
+{
+ QPEApplication a ( argc,argv );
+
+ LauncherSettings dlg;
+ a. showMainWidget ( &dlg );
+
+ return a. exec ( );
+}
+
diff --git a/core/settings/launcher/tabssettings.cpp b/core/settings/launcher/tabssettings.cpp
new file mode 100644
index 0000000..292c615
--- a/dev/null
+++ b/core/settings/launcher/tabssettings.cpp
@@ -0,0 +1,177 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "tabssettings.h"
+
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+#include <qpe/applnk.h>
+#include <qpe/mimetype.h>
+#include <qpe/qcopenvelope_qws.h>
+#include <qpe/config.h>
+
+#include <qlistview.h>
+#include <qheader.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qwhatsthis.h>
+
+#include <stdlib.h>
+
+TabsSettings::TabsSettings ( QWidget *parent, const char *name )
+ : QWidget ( parent, name )
+{
+ QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
+
+ QLabel *l = new QLabel ( tr( "Launcher Tabs:" ), this );
+ lay-> addWidget ( l );
+
+ m_list = new QListView ( this );
+ m_list-> addColumn ( "foobar" );
+ m_list-> header ( )-> hide ( );
+
+ lay-> addWidget ( m_list );
+
+ QWhatsThis::add ( m_list, tr( "foobar" ));
+
+ init ( );
+}
+
+void TabsSettings::init ( )
+{
+ QListViewItem *lvi;
+
+ AppLnkSet rootFolder( MimeType::appsFolderName ( ));
+ QStringList types = rootFolder. types ( );
+ for ( QStringList::Iterator it = types. begin ( ); it != types. end ( ); ++it ) {
+ lvi = new QListViewItem ( m_list, rootFolder. typeName ( *it ));
+ lvi-> setPixmap ( 0, rootFolder. typePixmap ( *it ));
+ m_ids << *it;
+ }
+ QImage img ( Resource::loadImage ( "DocsIcon" ));
+ QPixmap pix;
+ pix = img. smoothScale ( AppLnk::smallIconSize ( ), AppLnk::smallIconSize ( ));
+ lvi = new QListViewItem ( m_list, tr( "Documents" ));
+ lvi-> setPixmap ( 0, pix );
+ m_ids += "Documents"; // No tr
+
+ readTabSettings ( );
+}
+
+void TabsSettings::readTabSettings ( )
+{
+ Config cfg ( "Launcher" );
+ QString grp ( "Tab %1" ); // No tr
+ m_tabs. clear ( );
+
+ for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) {
+ TabSettings ts;
+ ts. m_view = Icon;
+ ts. m_bg_type = Ruled;
+ ts. m_changed = false;
+
+ cfg. setGroup ( grp. arg ( *it ));
+
+ QString view = cfg. readEntry ( "View", "Icon" );
+ if ( view == "List" ) // No tr
+ ts. m_view = List;
+
+ QString bgType = cfg. readEntry ( "BackgroundType", "Ruled" );
+ if ( bgType == "SolidColor" )
+ ts. m_bg_type = SolidColor;
+ else if ( bgType == "Image" ) // No tr
+ ts. m_bg_type = Image;
+
+ ts. m_bg_image = cfg. readEntry ( "BackgroundImage", "wallpaper/opie" );
+ ts. m_bg_color = cfg. readEntry ( "BackgroundColor" );
+ ts. m_text_color = cfg. readEntry ( "TextColor" );
+ QStringList f = cfg. readListEntry ( "Font", ',' );
+ if ( f. count ( ) == 4 ) {
+ ts. m_font_family = f [0];
+ ts. m_font_size = f [1]. toInt ( );
+ } else {
+ ts. m_font_family = font ( ). family ( );
+ ts. m_font_size = font ( ). pointSize ( );
+ }
+ m_tabs [*it] = ts;
+ }
+}
+
+
+void TabsSettings::accept ( )
+{
+ Config cfg ( "Launcher" );
+
+ // Launcher Tab
+ QString grp ( "Tab %1" ); // No tr
+
+ for ( QStringList::Iterator it = m_ids. begin ( ); it != m_ids. end ( ); ++it ) {
+ TabSettings &tab = m_tabs [*it];
+
+ cfg. setGroup ( grp. arg ( *it ));
+ if ( !tab. m_changed )
+ continue;
+ switch ( tab. m_view ) {
+ case Icon:
+ cfg.writeEntry ( "View", "Icon" );
+ break;
+ case List:
+ cfg.writeEntry ( "View", "List" );
+ break;
+ }
+
+ QCopEnvelope e ( "QPE/Launcher", "setTabView(QString,int)" );
+ e << *it << tab. m_view;
+
+ cfg. writeEntry ( "BackgroundImage", tab. m_bg_image );
+ cfg. writeEntry ( "BackgroundColor", tab. m_bg_color );
+ cfg. writeEntry ( "TextColor", tab. m_text_color );
+
+ QString f = tab. m_font_family + "," + QString::number ( tab. m_font_size ) + ",50,0";
+ cfg. writeEntry ( "Font", f );
+ QCopEnvelope be ( "QPE/Launcher", "setTabBackground(QString,int,QString)" );
+
+ switch ( tab. m_bg_type ) {
+ case Ruled:
+ cfg.writeEntry( "BackgroundType", "Ruled" );
+ be << *it << tab. m_bg_type << QString("");
+ break;
+ case SolidColor:
+ cfg.writeEntry( "BackgroundType", "SolidColor" );
+ be << *it << tab. m_bg_type << tab. m_bg_color;
+ break;
+ case Image:
+ cfg.writeEntry( "BackgroundType", "Image" );
+ be << *it << tab. m_bg_type << tab. m_bg_image;
+ break;
+ }
+
+ QCopEnvelope te( "QPE/Launcher", "setTextColor(QString,QString)" );
+ te << *it << tab. m_text_color;
+
+ QCopEnvelope fe ( "QPE/Launcher", "setFont(QString,QString,int,int,int)" );
+ fe << *it << tab. m_font_family;
+ fe << tab. m_font_size;
+ fe << 50 << 0;
+
+ tab. m_changed = false;
+ }
+}
+
diff --git a/core/settings/launcher/tabssettings.h b/core/settings/launcher/tabssettings.h
new file mode 100644
index 0000000..17b6e25
--- a/dev/null
+++ b/core/settings/launcher/tabssettings.h
@@ -0,0 +1,52 @@
+#ifndef __TABS_SETTINGS_H__
+#define __TABS_SETTINGS_H__
+
+#include <qwidget.h>
+#include <qmap.h>
+
+class QListView;
+
+
+class TabsSettings : public QWidget {
+ Q_OBJECT
+
+public:
+ TabsSettings ( QWidget *parent = 0, const char *name = 0 );
+
+ void accept ( );
+
+ enum ViewMode {
+ Icon,
+ List
+ };
+ enum BackgroundType {
+ Ruled,
+ SolidColor,
+ Image
+ };
+ struct TabSettings {
+ ViewMode m_view;
+ BackgroundType m_bg_type;
+ QString m_bg_image;
+ QString m_bg_color;
+ QString m_text_color;
+ QString m_font_family;
+ int m_font_size;
+ bool m_changed;
+ };
+
+protected:
+ void init ( );
+ void readTabSettings ( );
+
+private:
+ QListView *m_list;
+// QString currentTab;
+ QStringList m_ids;
+ QMap <QString, TabSettings> m_tabs;
+};
+
+
+
+
+#endif
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp
new file mode 100644
index 0000000..8f16951
--- a/dev/null
+++ b/core/settings/launcher/taskbarsettings.cpp
@@ -0,0 +1,169 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "taskbarsettings.h"
+
+#include <qpe/config.h>
+#include <qpe/qlibrary.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/taskbarappletinterface.h>
+#include <qpe/qcopenvelope_qws.h>
+
+#include <qdir.h>
+#include <qlistview.h>
+#include <qcheckbox.h>
+#include <qheader.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qwhatsthis.h>
+
+#include <stdlib.h>
+
+
+TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name )
+ : QWidget ( parent, name )
+{
+ m_applets_changed = false;
+
+ QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
+
+ QLabel *l = new QLabel ( tr( "Load applets:" ), this );
+ lay-> addWidget ( l );
+
+ m_list = new QListView ( this );
+ m_list-> addColumn ( "foobar" );
+ m_list-> header ( )-> hide ( );
+
+ lay-> addWidget ( m_list );
+
+ m_omenu = new QCheckBox ( tr( "Show O-Menu" ), this );
+ lay-> addWidget ( m_omenu );
+
+ m_omenu_tabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this );
+ lay-> addWidget ( m_omenu_tabs );
+
+ QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." ));
+ QWhatsThis::add( m_omenu_tabs, tr( "Adds the contents of the Launcher as menus in the O-Menu." ));
+ QWhatsThis::add( m_omenu, tr( "Check if you want the O-Menu in the taskbar." ));
+
+ connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( )));
+ connect ( m_omenu, SIGNAL( toggled ( bool )), m_omenu_tabs, SLOT( setEnabled ( bool )));
+
+ // This option does not make sense ! (sandman)
+ m_omenu_tabs-> hide ( );
+
+ init ( );
+}
+
+void TaskbarSettings::init ( )
+{
+ Config cfg ( "Taskbar" );
+ cfg. setGroup ( "Applets" );
+ QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
+
+ QString path = QPEApplication::qpeDir ( ) + "/plugins/applets";
+ QStringList list = QDir ( path, "lib*.so" ). entryList ( );
+
+ for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
+ QString name;
+ QPixmap icon;
+ TaskbarNamedAppletInterface *iface = 0;
+
+ QLibrary *lib = new QLibrary ( path + "/" + *it );
+ lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface );
+ if ( iface ) {
+ QString lang = getenv( "LANG" );
+ QTranslator *trans = new QTranslator ( qApp );
+ QString type = (*it). left ((*it). find ("."));
+ QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm";
+ if ( trans-> load ( tfn ))
+ qApp-> installTranslator ( trans );
+ else
+ delete trans;
+ name = iface-> name ( );
+ icon = iface-> icon ( );
+ iface-> release ( );
+ lib-> unload ( );
+ } else {
+ delete lib;
+ name = (*it). mid ( 3 );
+ int sep = name. find( ".so" );
+ if ( sep > 0 )
+ name. truncate ( sep );
+ sep = name. find ( "applet" );
+ if ( sep == (int) name.length ( ) - 6 )
+ name. truncate ( sep );
+ name[0] = name[0]. upper ( );
+ }
+ QCheckListItem *item;
+ item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
+ if ( !icon. isNull ( ))
+ item-> setPixmap ( 0, icon );
+ item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
+ m_applets [*it] = item;
+ }
+
+ cfg. setGroup ( "Menu" );
+
+ m_omenu_tabs-> setChecked ( cfg. readBoolEntry ( "LauncherTabs", true ));
+ m_omenu-> setChecked ( cfg. readBoolEntry ( "ShowMenu", true ));
+
+ m_omenu_tabs-> setEnabled ( m_omenu-> isChecked ( ));
+}
+
+void TaskbarSettings::appletChanged()
+{
+ m_applets_changed = true;
+}
+
+void TaskbarSettings::accept ( )
+{
+ Config cfg ( "Taskbar" );
+ cfg. setGroup ( "Applets" );
+ if ( m_applets_changed ) {
+ QStringList exclude;
+ QMap <QString, QCheckListItem *>::Iterator it;
+ for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
+ if ( !(*it)-> isOn ( ))
+ exclude << it. key ( );
+ }
+ cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
+ }
+ cfg. writeEntry ( "SafeMode", false );
+
+ cfg. setGroup ( "Menu" );
+
+ if ( m_omenu_tabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) {
+ m_applets_changed = true;
+ cfg. writeEntry ( "LauncherTabs", m_omenu_tabs-> isChecked ( ));
+ }
+
+ if ( m_omenu-> isChecked ( ) != cfg. readBoolEntry ( "ShowMenu", true )) {
+ m_applets_changed = true;
+ cfg. writeEntry ( "ShowMenu", m_omenu-> isChecked ( ));
+ }
+ cfg. write ( );
+
+ if ( m_applets_changed ) {
+ QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
+ m_applets_changed = false;
+ }
+}
+
diff --git a/core/settings/launcher/taskbarsettings.h b/core/settings/launcher/taskbarsettings.h
new file mode 100644
index 0000000..b8c6fbb
--- a/dev/null
+++ b/core/settings/launcher/taskbarsettings.h
@@ -0,0 +1,35 @@
+#ifndef __TASKBAR_SETTINGS_H__
+#define __TASKBAR_SETTINGS_H__
+
+#include <qwidget.h>
+#include <qmap.h>
+
+class QListView;
+class QCheckListItem;
+class QCheckBox;
+
+
+class TaskbarSettings : public QWidget {
+ Q_OBJECT
+
+public:
+ TaskbarSettings ( QWidget *parent = 0, const char *name = 0 );
+
+ void accept ( );
+
+protected slots:
+ void appletChanged ( );
+
+protected:
+ void init ( );
+
+private:
+ QListView *m_list;
+ QCheckBox *m_omenu;
+ QCheckBox *m_omenu_tabs;
+
+ QMap <QString, QCheckListItem *> m_applets;
+ bool m_applets_changed;
+};
+
+#endif