summaryrefslogtreecommitdiff
path: root/core/settings/launcher/taskbarsettings.cpp
authorsandman <sandman>2002-10-02 22:15:33 (UTC)
committer sandman <sandman>2002-10-02 22:15:33 (UTC)
commit7e864eb22b5663ad9771b562fbe901042dc68657 (patch) (unidiff)
treec7cc270012ff2aba51308088b51022b2056f9721 /core/settings/launcher/taskbarsettings.cpp
parentc8d4ed632ac27261219e5824f988a320b96b8ae2 (diff)
downloadopie-7e864eb22b5663ad9771b562fbe901042dc68657.zip
opie-7e864eb22b5663ad9771b562fbe901042dc68657.tar.gz
opie-7e864eb22b5663ad9771b562fbe901042dc68657.tar.bz2
Launcher settings now also supports the new menu applets interface
Diffstat (limited to 'core/settings/launcher/taskbarsettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/launcher/taskbarsettings.cpp68
1 files changed, 38 insertions, 30 deletions
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp
index b5c03c8..5bc5ad2 100644
--- a/core/settings/launcher/taskbarsettings.cpp
+++ b/core/settings/launcher/taskbarsettings.cpp
@@ -43,25 +43,25 @@
43#include <qwhatsthis.h> 43#include <qwhatsthis.h>
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47 47
48TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) 48TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name )
49 : QWidget ( parent, name ) 49 : QWidget ( parent, name )
50{ 50{
51 m_applets_changed = false; 51 m_applets_changed = false;
52 52
53 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); 53 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
54 54
55 QLabel *l = new QLabel ( tr( "Load applets:" ), this ); 55 QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this );
56 lay-> addWidget ( l ); 56 lay-> addWidget ( l );
57 57
58 m_list = new QListView ( this ); 58 m_list = new QListView ( this );
59 m_list-> addColumn ( "foobar" ); 59 m_list-> addColumn ( "foobar" );
60 m_list-> header ( )-> hide ( ); 60 m_list-> header ( )-> hide ( );
61 61
62 lay-> addWidget ( m_list ); 62 lay-> addWidget ( m_list );
63 63
64 QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); 64 QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." ));
65 65
66 connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); 66 connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( )));
67 67
@@ -75,55 +75,63 @@ void TaskbarSettings::init ( )
75 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); 75 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
76 76
77 QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; 77 QString path = QPEApplication::qpeDir ( ) + "/plugins/applets";
78 QStringList list = QDir ( path, "lib*.so" ). entryList ( ); 78 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
79 79
80 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { 80 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
81 QString name; 81 QString name;
82 QPixmap icon; 82 QPixmap icon;
83 TaskbarNamedAppletInterface *iface = 0; 83 TaskbarNamedAppletInterface *iface = 0;
84 84
85 QLibrary *lib = new QLibrary ( path + "/" + *it ); 85 QLibrary *lib = new QLibrary ( path + "/" + *it );
86 lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); 86 lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface );
87 if ( iface ) { 87 if ( iface ) {
88 88 QString lang = getenv( "LANG" );
89 QString lang = getenv( "LANG" ); 89 QTranslator *trans = new QTranslator ( qApp );
90 QTranslator *trans = new QTranslator ( qApp ); 90 QString type = (*it). left ((*it). find ("."));
91 QString type = (*it). left ((*it). find (".")); 91 QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm";
92 QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; 92 if ( trans-> load ( tfn ))
93 if ( trans-> load ( tfn )) 93 qApp-> installTranslator ( trans );
94 qApp-> installTranslator ( trans ); 94 else
95 else 95 delete trans;
96 delete trans; 96 name = iface-> name ( );
97 name = iface-> name ( ); 97 icon = iface-> icon ( );
98 icon = iface-> icon ( );
99 iface-> release ( ); 98 iface-> release ( );
100 lib-> unload ( );
101 } else {
102 delete lib;
103 name = (*it). mid ( 3 );
104 int sep = name. find( ".so" );
105 if ( sep > 0 )
106 name. truncate ( sep );
107 sep = name. find ( "applet" );
108 if ( sep == (int) name.length ( ) - 6 )
109 name. truncate ( sep );
110 name[0] = name[0]. upper ( );
111 } 99 }
112 QCheckListItem *item; 100 if ( !iface ) {
113 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); 101 lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface );
114 if ( !icon. isNull ( )) 102
115 item-> setPixmap ( 0, icon ); 103 if ( iface ) {
116 item-> setOn ( exclude. find ( *it ) == exclude. end ( )); 104 name = (*it). mid ( 3 );
117 m_applets [*it] = item; 105 int sep = name. find( ".so" );
106 if ( sep > 0 )
107 name. truncate ( sep );
108 sep = name. find ( "applet" );
109 if ( sep == (int) name.length ( ) - 6 )
110 name. truncate ( sep );
111 name[0] = name[0]. upper ( );
112 iface-> release ( );
113 }
114 }
115
116 if ( iface ) {
117 QCheckListItem *item;
118 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
119 if ( !icon. isNull ( ))
120 item-> setPixmap ( 0, icon );
121 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
122 m_applets [*it] = item;
123 }
124 lib-> unload ( );
125 delete lib;
118 } 126 }
119} 127}
120 128
121void TaskbarSettings::appletChanged() 129void TaskbarSettings::appletChanged()
122{ 130{
123 m_applets_changed = true; 131 m_applets_changed = true;
124} 132}
125 133
126void TaskbarSettings::accept ( ) 134void TaskbarSettings::accept ( )
127{ 135{
128 Config cfg ( "Taskbar" ); 136 Config cfg ( "Taskbar" );
129 cfg. setGroup ( "Applets" ); 137 cfg. setGroup ( "Applets" );