author | sandman <sandman> | 2002-10-02 22:28:26 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-02 22:28:26 (UTC) |
commit | f254ef08b354327d70d80690eff84dda15e592fc (patch) (side-by-side diff) | |
tree | 37013c14a062f56f9c9412e560a8573a8c4195c3 /core | |
parent | 7c0ba35db6a55806059bce25413c1a0e1ad939bf (diff) | |
download | opie-f254ef08b354327d70d80690eff84dda15e592fc.zip opie-f254ef08b354327d70d80690eff84dda15e592fc.tar.gz opie-f254ef08b354327d70d80690eff84dda15e592fc.tar.bz2 |
Doh .. forgot the new files
-rw-r--r-- | core/settings/launcher/menusettings.cpp | 159 | ||||
-rw-r--r-- | core/settings/launcher/menusettings.h | 60 |
2 files changed, 219 insertions, 0 deletions
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp new file mode 100644 index 0000000..8d363fa --- a/dev/null +++ b/core/settings/launcher/menusettings.cpp @@ -0,0 +1,159 @@ +/* + This file is part of the OPIE Project + =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#include "menusettings.h" + +#include <qpe/config.h> +#include <qpe/qlibrary.h> +#include <qpe/qpeapplication.h> +#include <qpe/menuappletinterface.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> + + +MenuSettings::MenuSettings ( 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 in O-Menu:" ), this ); + lay-> addWidget ( l ); + + m_list = new QListView ( this ); + m_list-> addColumn ( "foobar" ); + m_list-> header ( )-> hide ( ); + + lay-> addWidget ( m_list ); + + m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this ); + lay-> addWidget ( m_menutabs ); + + QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the O-Menu." )); + QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher as menus in the O-Menu." )); + + connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); + + init ( ); +} + +void MenuSettings::init ( ) +{ + Config cfg ( "StartMenu" ); + 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; + MenuAppletInterface *iface = 0; + + QLibrary *lib = new QLibrary ( path + "/" + *it ); + lib-> queryInterface ( IID_MenuApplet, (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 ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); + iface-> release ( ); + lib-> unload ( ); + + 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; + } else { + delete lib; + } + } + + cfg. setGroup ( "Menu" ); + m_menutabs-> setChecked ( cfg. readBoolEntry ( "LauncherTabs", true )); +} + +void MenuSettings::appletChanged() +{ + m_applets_changed = true; +} + +void MenuSettings::accept ( ) +{ + bool apps_changed = false; + + Config cfg ( "StartMenu" ); + 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_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { + apps_changed = true; + cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); + } + + cfg. write ( ); + + if ( m_applets_changed ) { + QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); + m_applets_changed = false; + } + if ( apps_changed ) { + QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); + } +} + diff --git a/core/settings/launcher/menusettings.h b/core/settings/launcher/menusettings.h new file mode 100644 index 0000000..5986958 --- a/dev/null +++ b/core/settings/launcher/menusettings.h @@ -0,0 +1,60 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> + .>+-= + _;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: + : = ...= . :.=- You should have received a copy of the GNU + -. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., + 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef __MENU_SETTINGS_H__ +#define __MENU_SETTINGS_H__ + +#include <qwidget.h> +#include <qmap.h> + +class QListView; +class QCheckListItem; +class QCheckBox; + + +class MenuSettings : public QWidget { + Q_OBJECT + +public: + MenuSettings ( QWidget *parent = 0, const char *name = 0 ); + + void accept ( ); + +protected slots: + void appletChanged ( ); + +protected: + void init ( ); + +private: + QListView *m_list; + QMap <QString, QCheckListItem *> m_applets; + bool m_applets_changed; + QCheckBox *m_menutabs; +}; + +#endif |