author | zecke <zecke> | 2004-10-16 00:01:01 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-16 00:01:01 (UTC) |
commit | df14f647ff1a60ca82e0fa9bd91458be146153b8 (patch) (unidiff) | |
tree | 4859961352851a4392e1442f2080c15bff8ad7bc | |
parent | 419f9710c488f56a7a117eb1529970d3371e0094 (diff) | |
download | opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.zip opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.tar.gz opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.tar.bz2 |
Replace QPEApplication::qpeDir() + "/ with
QPEApplication::qpeDir() + "
as it is guranteed that qpeDir() will have '/' as the last
charachter
45 files changed, 80 insertions, 80 deletions
diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp index 195d8a4..8cb9083 100644 --- a/core/applets/multikeyapplet/multikey.cpp +++ b/core/applets/multikeyapplet/multikey.cpp | |||
@@ -1,142 +1,142 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru | 2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "multikey.h" | 15 | #include "multikey.h" |
16 | 16 | ||
17 | /* OPIE */ | 17 | /* OPIE */ |
18 | #include <opie2/otaskbarapplet.h> | 18 | #include <opie2/otaskbarapplet.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | 21 | ||
22 | /* QT */ | 22 | /* QT */ |
23 | #include <qdir.h> | 23 | #include <qdir.h> |
24 | 24 | ||
25 | using namespace Opie::Ui; | 25 | using namespace Opie::Ui; |
26 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") | 26 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") |
27 | { | 27 | { |
28 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); | 28 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); |
29 | connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 29 | connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
30 | this, SLOT(message(const QCString&,const QByteArray&))); | 30 | this, SLOT(message(const QCString&,const QByteArray&))); |
31 | 31 | ||
32 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); | 32 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); |
33 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); | 33 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); |
34 | lang = 0; | 34 | lang = 0; |
35 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); | 35 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); |
36 | setText("EN"); | 36 | setText("EN"); |
37 | popupMenu.insertItem("EN", 0); | 37 | popupMenu.insertItem("EN", 0); |
38 | show(); | 38 | show(); |
39 | } | 39 | } |
40 | 40 | ||
41 | void Multikey::mousePressEvent(QMouseEvent *ev) | 41 | void Multikey::mousePressEvent(QMouseEvent *ev) |
42 | { | 42 | { |
43 | if (!sw_maps.count()) | 43 | if (!sw_maps.count()) |
44 | return; | 44 | return; |
45 | 45 | ||
46 | if (ev->button() == RightButton) { | 46 | if (ev->button() == RightButton) { |
47 | 47 | ||
48 | QPoint p = mapToGlobal(QPoint(0, 0)); | 48 | QPoint p = mapToGlobal(QPoint(0, 0)); |
49 | QSize s = popupMenu.sizeHint(); | 49 | QSize s = popupMenu.sizeHint(); |
50 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | 50 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
51 | p.y() - s.height()), 0); | 51 | p.y() - s.height()), 0); |
52 | 52 | ||
53 | if (opt == -1) | 53 | if (opt == -1) |
54 | return; | 54 | return; |
55 | lang = opt; | 55 | lang = opt; |
56 | 56 | ||
57 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 57 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
58 | e << sw_maps[lang]; | 58 | e << sw_maps[lang]; |
59 | setText(labels[lang]); | 59 | setText(labels[lang]); |
60 | } | 60 | } |
61 | QWidget::mousePressEvent(ev); | 61 | QWidget::mousePressEvent(ev); |
62 | } | 62 | } |
63 | 63 | ||
64 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) | 64 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) |
65 | { | 65 | { |
66 | if (!sw_maps.count()) | 66 | if (!sw_maps.count()) |
67 | return; | 67 | return; |
68 | 68 | ||
69 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; | 69 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; |
70 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 70 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
71 | //odebug << "Lang=" << lang << ", count=" << sw_maps.count() << ", lab=" << labels[lang].ascii() << "" << oendl; | 71 | //odebug << "Lang=" << lang << ", count=" << sw_maps.count() << ", lab=" << labels[lang].ascii() << "" << oendl; |
72 | e << sw_maps[lang]; | 72 | e << sw_maps[lang]; |
73 | setText(labels[lang]); | 73 | setText(labels[lang]); |
74 | } | 74 | } |
75 | 75 | ||
76 | void Multikey::message(const QCString &message, const QByteArray &data) | 76 | void Multikey::message(const QCString &message, const QByteArray &data) |
77 | { | 77 | { |
78 | if ( message == "setsw(QString,QString)" ) { | 78 | if ( message == "setsw(QString,QString)" ) { |
79 | 79 | ||
80 | QDataStream stream(data, IO_ReadOnly); | 80 | QDataStream stream(data, IO_ReadOnly); |
81 | QString maps, current_map; | 81 | QString maps, current_map; |
82 | stream >> maps >> current_map; | 82 | stream >> maps >> current_map; |
83 | QStringList sw = QStringList::split(QChar('|'), maps); | 83 | QStringList sw = QStringList::split(QChar('|'), maps); |
84 | sw.append(current_map); | 84 | sw.append(current_map); |
85 | 85 | ||
86 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); | 86 | QDir map_dir(QPEApplication::qpeDir() + "share/multikey/", "*.keymap"); |
87 | lang = 0; | 87 | lang = 0; |
88 | labels.clear(); | 88 | labels.clear(); |
89 | sw_maps.clear(); | 89 | sw_maps.clear(); |
90 | popupMenu.clear(); | 90 | popupMenu.clear(); |
91 | 91 | ||
92 | for (uint i = 0; i < sw.count(); ++i) { | 92 | for (uint i = 0; i < sw.count(); ++i) { |
93 | QString keymap_map; | 93 | QString keymap_map; |
94 | if (sw[i][0] != '/') { | 94 | if (sw[i][0] != '/') { |
95 | 95 | ||
96 | keymap_map = map_dir.absPath() + "/" + sw[i]; | 96 | keymap_map = map_dir.absPath() + "/" + sw[i]; |
97 | } else { | 97 | } else { |
98 | 98 | ||
99 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) | 99 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) |
100 | && i != sw.count()-1) || !QFile::exists(sw[i])) { | 100 | && i != sw.count()-1) || !QFile::exists(sw[i])) { |
101 | continue; | 101 | continue; |
102 | } | 102 | } |
103 | keymap_map = sw[i]; | 103 | keymap_map = sw[i]; |
104 | } | 104 | } |
105 | 105 | ||
106 | QFile map(keymap_map); | 106 | QFile map(keymap_map); |
107 | if (map.open(IO_ReadOnly)) { | 107 | if (map.open(IO_ReadOnly)) { |
108 | QString line; | 108 | QString line; |
109 | 109 | ||
110 | map.readLine(line, 1024); | 110 | map.readLine(line, 1024); |
111 | while (!map.atEnd()) { | 111 | while (!map.atEnd()) { |
112 | 112 | ||
113 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { | 113 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { |
114 | 114 | ||
115 | if (i != sw.count()-1) { | 115 | if (i != sw.count()-1) { |
116 | if (keymap_map == current_map) { | 116 | if (keymap_map == current_map) { |
117 | lang = i; | 117 | lang = i; |
118 | } | 118 | } |
119 | sw_maps.append(keymap_map); | 119 | sw_maps.append(keymap_map); |
120 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 120 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
121 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); | 121 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); |
122 | } else { | 122 | } else { |
123 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); | 123 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); |
124 | } | 124 | } |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | map.readLine(line, 1024); | 127 | map.readLine(line, 1024); |
128 | } | 128 | } |
129 | map.close(); | 129 | map.close(); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | setText(current); | 133 | setText(current); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | int Multikey::position() | 137 | int Multikey::position() |
138 | { | 138 | { |
139 | return 10; | 139 | return 10; |
140 | } | 140 | } |
141 | 141 | ||
142 | EXPORT_OPIE_APPLET_v1( Multikey ) | 142 | EXPORT_OPIE_APPLET_v1( Multikey ) |
diff --git a/core/apps/taboapp/main.cpp b/core/apps/taboapp/main.cpp index e43f118..e999803 100644 --- a/core/apps/taboapp/main.cpp +++ b/core/apps/taboapp/main.cpp | |||
@@ -1,57 +1,57 @@ | |||
1 | /* OPIE */ | 1 | /* OPIE */ |
2 | #include <oappinterface.h> | 2 | #include <oappinterface.h> |
3 | #include <oappplugin.h> | 3 | #include <oappplugin.h> |
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | #include <opie2/otabwidget.h> | 5 | #include <opie2/otabwidget.h> |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | #include <qpe/qlibrary.h> | 7 | #include <qpe/qlibrary.h> |
8 | using namespace Opie::Core; | 8 | using namespace Opie::Core; |
9 | using namespace Opie::Ui; | 9 | using namespace Opie::Ui; |
10 | 10 | ||
11 | /* QT */ | 11 | /* QT */ |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | 13 | ||
14 | int main( int argc, char **argv ) | 14 | int main( int argc, char **argv ) |
15 | { | 15 | { |
16 | QPEApplication a( argc, argv ); | 16 | QPEApplication a( argc, argv ); |
17 | 17 | ||
18 | OTabWidget *tabwidget = new OTabWidget(0, "tab widget"); | 18 | OTabWidget *tabwidget = new OTabWidget(0, "tab widget"); |
19 | 19 | ||
20 | QString path = QPEApplication::qpeDir() + "/plugins/app"; | 20 | QString path = QPEApplication::qpeDir() + "plugins/app"; |
21 | QDir dir( path, "lib*.so" ); | 21 | QDir dir( path, "lib*.so" ); |
22 | 22 | ||
23 | QStringList list = dir.entryList(); | 23 | QStringList list = dir.entryList(); |
24 | QStringList::Iterator it; | 24 | QStringList::Iterator it; |
25 | 25 | ||
26 | QInterfacePtr<OAppInterface> iface; | 26 | QInterfacePtr<OAppInterface> iface; |
27 | for ( it = list.begin(); it != list.end(); ++it ) { | 27 | for ( it = list.begin(); it != list.end(); ++it ) { |
28 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 28 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
29 | 29 | ||
30 | odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; | 30 | odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; |
31 | if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 31 | if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
32 | odebug << "accepted: " << QString( path + "/" + *it ) << "" << oendl; | 32 | odebug << "accepted: " << QString( path + "/" + *it ) << "" << oendl; |
33 | 33 | ||
34 | QList<QWidget> list = iface->widgets(); | 34 | QList<QWidget> list = iface->widgets(); |
35 | QWidget *widget; | 35 | QWidget *widget; |
36 | for ( widget = list.first(); widget != 0; widget = list.next() ) | 36 | for ( widget = list.first(); widget != 0; widget = list.next() ) |
37 | tabwidget->addTab(widget, QString(*it), QString(*it)); | 37 | tabwidget->addTab(widget, QString(*it), QString(*it)); |
38 | 38 | ||
39 | QString lang = getenv( "LANG" ); | 39 | QString lang = getenv( "LANG" ); |
40 | if (lang.isNull()) | 40 | if (lang.isNull()) |
41 | lang = "en"; | 41 | lang = "en"; |
42 | QTranslator *trans = new QTranslator(qApp); | 42 | QTranslator *trans = new QTranslator(qApp); |
43 | QString type = (*it).left( (*it).find(".") ); | 43 | QString type = (*it).left( (*it).find(".") ); |
44 | if (type.left(3) == "lib") | 44 | if (type.left(3) == "lib") |
45 | type = type.mid(3); | 45 | type = type.mid(3); |
46 | type = type.right( type.find("lib") ); | 46 | type = type.right( type.find("lib") ); |
47 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 47 | QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm"; |
48 | if ( trans->load( tfn )) | 48 | if ( trans->load( tfn )) |
49 | qApp->installTranslator( trans ); | 49 | qApp->installTranslator( trans ); |
50 | else | 50 | else |
51 | delete trans; | 51 | delete trans; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | a.showMainDocumentWidget(tabwidget); | 55 | a.showMainDocumentWidget(tabwidget); |
56 | return a.exec(); | 56 | return a.exec(); |
57 | } | 57 | } |
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 586628b..24669ac 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -124,252 +124,252 @@ InputMethods::InputMethods( QWidget *parent ) : | |||
124 | 124 | ||
125 | 125 | ||
126 | imButton = new QWidgetStack( this ); // later a widget stack | 126 | imButton = new QWidgetStack( this ); // later a widget stack |
127 | imButton->setFocusPolicy(NoFocus); | 127 | imButton->setFocusPolicy(NoFocus); |
128 | if (parent->sizeHint().height() > 0) | 128 | if (parent->sizeHint().height() > 0) |
129 | imButton->setFixedHeight( parent->sizeHint().height() ); | 129 | imButton->setFixedHeight( parent->sizeHint().height() ); |
130 | hbox->addWidget(imButton); | 130 | hbox->addWidget(imButton); |
131 | 131 | ||
132 | imChoice = new QToolButton( this ); | 132 | imChoice = new QToolButton( this ); |
133 | imChoice->setFocusPolicy(NoFocus); | 133 | imChoice->setFocusPolicy(NoFocus); |
134 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 134 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
135 | if (parent->sizeHint().height() > 0) | 135 | if (parent->sizeHint().height() > 0) |
136 | imChoice->setFixedHeight( parent->sizeHint().height() ); | 136 | imChoice->setFixedHeight( parent->sizeHint().height() ); |
137 | imChoice->setFixedWidth( 13 ); | 137 | imChoice->setFixedWidth( 13 ); |
138 | imChoice->setAutoRaise( TRUE ); | 138 | imChoice->setAutoRaise( TRUE ); |
139 | hbox->addWidget( imChoice ); | 139 | hbox->addWidget( imChoice ); |
140 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); | 140 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); |
141 | 141 | ||
142 | loadInputMethods(); | 142 | loadInputMethods(); |
143 | 143 | ||
144 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); | 144 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); |
145 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 145 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
146 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); | 146 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); |
147 | } | 147 | } |
148 | 148 | ||
149 | InputMethods::~InputMethods() | 149 | InputMethods::~InputMethods() |
150 | { | 150 | { |
151 | Config cfg("qpe"); | 151 | Config cfg("qpe"); |
152 | cfg.setGroup("InputMethod"); | 152 | cfg.setGroup("InputMethod"); |
153 | if (imethod) | 153 | if (imethod) |
154 | cfg.writeEntry("im", imethod->name() ); | 154 | cfg.writeEntry("im", imethod->name() ); |
155 | if (mkeyboard) | 155 | if (mkeyboard) |
156 | cfg.writeEntry("current", mkeyboard->name() ); | 156 | cfg.writeEntry("current", mkeyboard->name() ); |
157 | 157 | ||
158 | unloadInputMethods(); | 158 | unloadInputMethods(); |
159 | } | 159 | } |
160 | 160 | ||
161 | void InputMethods::hideInputMethod() | 161 | void InputMethods::hideInputMethod() |
162 | { | 162 | { |
163 | kbdButton->setOn( FALSE ); | 163 | kbdButton->setOn( FALSE ); |
164 | } | 164 | } |
165 | 165 | ||
166 | void InputMethods::showInputMethod() | 166 | void InputMethods::showInputMethod() |
167 | { | 167 | { |
168 | kbdButton->setOn( TRUE ); | 168 | kbdButton->setOn( TRUE ); |
169 | } | 169 | } |
170 | 170 | ||
171 | void InputMethods::showInputMethod(const QString& name) | 171 | void InputMethods::showInputMethod(const QString& name) |
172 | { | 172 | { |
173 | int i = 0; | 173 | int i = 0; |
174 | QValueList<InputMethod>::Iterator it; | 174 | QValueList<InputMethod>::Iterator it; |
175 | InputMethod *im = 0; | 175 | InputMethod *im = 0; |
176 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 176 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
177 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); | 177 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); |
178 | if ( (*it).name() == name || lname == name ) { | 178 | if ( (*it).name() == name || lname == name ) { |
179 | im = &(*it); | 179 | im = &(*it); |
180 | break; | 180 | break; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | if ( im ) | 183 | if ( im ) |
184 | chooseKeyboard(im); | 184 | chooseKeyboard(im); |
185 | } | 185 | } |
186 | 186 | ||
187 | void InputMethods::resetStates() | 187 | void InputMethods::resetStates() |
188 | { | 188 | { |
189 | if ( mkeyboard && !mkeyboard->newIM ) | 189 | if ( mkeyboard && !mkeyboard->newIM ) |
190 | mkeyboard->interface->resetState(); | 190 | mkeyboard->interface->resetState(); |
191 | } | 191 | } |
192 | 192 | ||
193 | QRect InputMethods::inputRect() const | 193 | QRect InputMethods::inputRect() const |
194 | { | 194 | { |
195 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) | 195 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) |
196 | return QRect(); | 196 | return QRect(); |
197 | else | 197 | else |
198 | return mkeyboard->widget->geometry(); | 198 | return mkeyboard->widget->geometry(); |
199 | } | 199 | } |
200 | 200 | ||
201 | void InputMethods::unloadInputMethods() | 201 | void InputMethods::unloadInputMethods() |
202 | { | 202 | { |
203 | unloadMethod( inputMethodList ); | 203 | unloadMethod( inputMethodList ); |
204 | unloadMethod( inputModifierList ); | 204 | unloadMethod( inputModifierList ); |
205 | inputMethodList.clear(); | 205 | inputMethodList.clear(); |
206 | inputModifierList.clear(); | 206 | inputModifierList.clear(); |
207 | 207 | ||
208 | } | 208 | } |
209 | 209 | ||
210 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { | 210 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { |
211 | QValueList<InputMethod>::Iterator it; | 211 | QValueList<InputMethod>::Iterator it; |
212 | 212 | ||
213 | for (it = list.begin(); it != list.end(); ++it ) | 213 | for (it = list.begin(); it != list.end(); ++it ) |
214 | (*it).releaseInterface(); | 214 | (*it).releaseInterface(); |
215 | 215 | ||
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | QStringList InputMethods::plugins()const { | 219 | QStringList InputMethods::plugins()const { |
220 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 220 | QString path = QPEApplication::qpeDir() + "plugins/inputmethods"; |
221 | #ifdef Q_OS_MACX | 221 | #ifdef Q_OS_MACX |
222 | QDir dir( path, "lib*.dylib" ); | 222 | QDir dir( path, "lib*.dylib" ); |
223 | #else | 223 | #else |
224 | QDir dir( path, "lib*.so" ); | 224 | QDir dir( path, "lib*.so" ); |
225 | #endif /* Q_OS_MACX */ | 225 | #endif /* Q_OS_MACX */ |
226 | return dir.entryList(); | 226 | return dir.entryList(); |
227 | } | 227 | } |
228 | 228 | ||
229 | void InputMethods::installTranslator( const QString& type ) { | 229 | void InputMethods::installTranslator( const QString& type ) { |
230 | QStringList langs = Global::languageList(); | 230 | QStringList langs = Global::languageList(); |
231 | QStringList::ConstIterator lit; | 231 | QStringList::ConstIterator lit; |
232 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { | 232 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { |
233 | QString lang = *lit; | 233 | QString lang = *lit; |
234 | QTranslator * trans = new QTranslator(qApp); | 234 | QTranslator * trans = new QTranslator(qApp); |
235 | 235 | ||
236 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 236 | QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm"; |
237 | 237 | ||
238 | if ( trans->load( tfn )) | 238 | if ( trans->load( tfn )) |
239 | qApp->installTranslator( trans ); | 239 | qApp->installTranslator( trans ); |
240 | else | 240 | else |
241 | delete trans; | 241 | delete trans; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void InputMethods::setPreferedHandlers() { | 245 | void InputMethods::setPreferedHandlers() { |
246 | Config cfg("qpe"); | 246 | Config cfg("qpe"); |
247 | cfg.setGroup("InputMethod"); | 247 | cfg.setGroup("InputMethod"); |
248 | QString current = cfg.readEntry("current"); | 248 | QString current = cfg.readEntry("current"); |
249 | QString im = cfg.readEntry("im"); | 249 | QString im = cfg.readEntry("im"); |
250 | 250 | ||
251 | QValueList<InputMethod>::Iterator it; | 251 | QValueList<InputMethod>::Iterator it; |
252 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { | 252 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { |
253 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) | 253 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) |
254 | if ( (*it).name() == im ) { | 254 | if ( (*it).name() == im ) { |
255 | imethod = &(*it); break; | 255 | imethod = &(*it); break; |
256 | } | 256 | } |
257 | 257 | ||
258 | } | 258 | } |
259 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { | 259 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { |
260 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) | 260 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) |
261 | if ( (*it).name() == current ) { | 261 | if ( (*it).name() == current ) { |
262 | owarn << "preferred keyboard is " << current << "" << oendl; | 262 | owarn << "preferred keyboard is " << current << "" << oendl; |
263 | mkeyboard = &(*it); | 263 | mkeyboard = &(*it); |
264 | kbdButton->setPixmap( *mkeyboard->icon() ); | 264 | kbdButton->setPixmap( *mkeyboard->icon() ); |
265 | break; | 265 | break; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | } | 269 | } |
270 | 270 | ||
271 | void InputMethods::loadInputMethods() | 271 | void InputMethods::loadInputMethods() |
272 | { | 272 | { |
273 | #ifndef QT_NO_COMPONENT | 273 | #ifndef QT_NO_COMPONENT |
274 | hideInputMethod(); | 274 | hideInputMethod(); |
275 | mkeyboard = 0; | 275 | mkeyboard = 0; |
276 | 276 | ||
277 | unloadInputMethods(); | 277 | unloadInputMethods(); |
278 | 278 | ||
279 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 279 | QString path = QPEApplication::qpeDir() + "plugins/inputmethods"; |
280 | QStringList list = plugins(); | 280 | QStringList list = plugins(); |
281 | QStringList::Iterator it; | 281 | QStringList::Iterator it; |
282 | for ( it = list.begin(); it != list.end(); ++it ) { | 282 | for ( it = list.begin(); it != list.end(); ++it ) { |
283 | InputMethodInterface *iface = 0; | 283 | InputMethodInterface *iface = 0; |
284 | ExtInputMethodInterface *eface = 0; | 284 | ExtInputMethodInterface *eface = 0; |
285 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 285 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
286 | 286 | ||
287 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { | 287 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { |
288 | InputMethod input; | 288 | InputMethod input; |
289 | input.newIM = FALSE; | 289 | input.newIM = FALSE; |
290 | input.library = lib; | 290 | input.library = lib; |
291 | input.libName = *it; | 291 | input.libName = *it; |
292 | input.interface = iface; | 292 | input.interface = iface; |
293 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); | 293 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); |
294 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); | 294 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); |
295 | inputMethodList.append( input ); | 295 | inputMethodList.append( input ); |
296 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { | 296 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { |
297 | InputMethod input; | 297 | InputMethod input; |
298 | input.newIM = TRUE; | 298 | input.newIM = TRUE; |
299 | input.library = lib; | 299 | input.library = lib; |
300 | input.libName = *it; | 300 | input.libName = *it; |
301 | input.extInterface = eface; | 301 | input.extInterface = eface; |
302 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); | 302 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); |
303 | // may be either a simple, or advanced. | 303 | // may be either a simple, or advanced. |
304 | if (input.widget) { | 304 | if (input.widget) { |
305 | //odebug << "its a keyboard" << oendl; | 305 | //odebug << "its a keyboard" << oendl; |
306 | inputMethodList.append( input ); | 306 | inputMethodList.append( input ); |
307 | } else { | 307 | } else { |
308 | //odebug << "its a real im" << oendl; | 308 | //odebug << "its a real im" << oendl; |
309 | input.widget = input.extInterface->statusWidget( 0, 0 ); | 309 | input.widget = input.extInterface->statusWidget( 0, 0 ); |
310 | if (input.widget) { | 310 | if (input.widget) { |
311 | //odebug << "blah" << oendl; | 311 | //odebug << "blah" << oendl; |
312 | inputModifierList.append( input ); | 312 | inputModifierList.append( input ); |
313 | imButton->addWidget(input.widget, inputModifierList.count()); | 313 | imButton->addWidget(input.widget, inputModifierList.count()); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | }else{ | 316 | }else{ |
317 | delete lib; | 317 | delete lib; |
318 | lib = 0l; | 318 | lib = 0l; |
319 | } | 319 | } |
320 | installTranslator( (*it).left( (*it).find(".") ) ); | 320 | installTranslator( (*it).left( (*it).find(".") ) ); |
321 | } | 321 | } |
322 | qHeapSort( inputMethodList ); | 322 | qHeapSort( inputMethodList ); |
323 | #endif /* killed BUILT in cause they would not compile */ | 323 | #endif /* killed BUILT in cause they would not compile */ |
324 | 324 | ||
325 | QWSServer::setCurrentInputMethod( 0 ); | 325 | QWSServer::setCurrentInputMethod( 0 ); |
326 | 326 | ||
327 | /* set the prefered IM + handler */ | 327 | /* set the prefered IM + handler */ |
328 | setPreferedHandlers(); | 328 | setPreferedHandlers(); |
329 | if ( !inputModifierList.isEmpty() ) { | 329 | if ( !inputModifierList.isEmpty() ) { |
330 | if (!imethod) | 330 | if (!imethod) |
331 | imethod = &inputModifierList[0]; | 331 | imethod = &inputModifierList[0]; |
332 | imButton->raiseWidget(imethod->widget); | 332 | imButton->raiseWidget(imethod->widget); |
333 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 333 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
334 | } else { | 334 | } else { |
335 | imethod = 0; | 335 | imethod = 0; |
336 | } | 336 | } |
337 | 337 | ||
338 | // we need to update keyboards afterwards, as some of them may not be compatible with | 338 | // we need to update keyboards afterwards, as some of them may not be compatible with |
339 | // the current input method | 339 | // the current input method |
340 | updateKeyboards(imethod); | 340 | updateKeyboards(imethod); |
341 | 341 | ||
342 | if ( !inputModifierList.isEmpty() ) | 342 | if ( !inputModifierList.isEmpty() ) |
343 | imButton->show(); | 343 | imButton->show(); |
344 | else | 344 | else |
345 | imButton->hide(); | 345 | imButton->hide(); |
346 | 346 | ||
347 | if ( inputModifierList.count() > 1 ) | 347 | if ( inputModifierList.count() > 1 ) |
348 | imChoice->show(); | 348 | imChoice->show(); |
349 | else | 349 | else |
350 | imChoice->hide(); | 350 | imChoice->hide(); |
351 | } | 351 | } |
352 | 352 | ||
353 | void InputMethods::chooseKbd() | 353 | void InputMethods::chooseKbd() |
354 | { | 354 | { |
355 | QPopupMenu pop( this ); | 355 | QPopupMenu pop( this ); |
356 | pop.setFocusPolicy( NoFocus ); //don't reset IM | 356 | pop.setFocusPolicy( NoFocus ); //don't reset IM |
357 | 357 | ||
358 | QString imname; | 358 | QString imname; |
359 | if (imethod) | 359 | if (imethod) |
360 | imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); | 360 | imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); |
361 | 361 | ||
362 | int i = 0; | 362 | int i = 0; |
363 | int firstDepKbd = 0; | 363 | int firstDepKbd = 0; |
364 | 364 | ||
365 | QValueList<InputMethod>::Iterator it; | 365 | QValueList<InputMethod>::Iterator it; |
366 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 366 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
367 | // add empty new items, all old items. | 367 | // add empty new items, all old items. |
368 | if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { | 368 | if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { |
369 | pop.insertItem( (*it).name(), i, firstDepKbd); | 369 | pop.insertItem( (*it).name(), i, firstDepKbd); |
370 | if ( mkeyboard == &(*it) ) | 370 | if ( mkeyboard == &(*it) ) |
371 | pop.setItemChecked( i, TRUE ); | 371 | pop.setItemChecked( i, TRUE ); |
372 | 372 | ||
373 | firstDepKbd++; | 373 | firstDepKbd++; |
374 | } else if ( (*it).extInterface->compatible().contains(imname)) { | 374 | } else if ( (*it).extInterface->compatible().contains(imname)) { |
375 | // check if we need to insert a sep. | 375 | // check if we need to insert a sep. |
diff --git a/core/launcher/irserver.cpp b/core/launcher/irserver.cpp index 092eb0c..19cf904 100644 --- a/core/launcher/irserver.cpp +++ b/core/launcher/irserver.cpp | |||
@@ -1,76 +1,76 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "irserver.h" | 21 | #include "irserver.h" |
22 | #include "obexinterface.h" | 22 | #include "obexinterface.h" |
23 | 23 | ||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <qtopia/qlibrary.h> | 26 | #include <qtopia/qlibrary.h> |
27 | #include <qtopia/qpeapplication.h> | 27 | #include <qtopia/qpeapplication.h> |
28 | 28 | ||
29 | /* QT */ | 29 | /* QT */ |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | 31 | ||
32 | IrServer::IrServer( QObject *parent, const char *name ) | 32 | IrServer::IrServer( QObject *parent, const char *name ) |
33 | : QObject( parent, name ), obexIface(0) | 33 | : QObject( parent, name ), obexIface(0) |
34 | { | 34 | { |
35 | lib = 0; | 35 | lib = 0; |
36 | obexIface = 0; | 36 | obexIface = 0; |
37 | QString path = QPEApplication::qpeDir() + "/plugins/obex/"; | 37 | QString path = QPEApplication::qpeDir() + "plugins/obex/"; |
38 | #ifdef Q_OS_MACX | 38 | #ifdef Q_OS_MACX |
39 | QDir dir( path, "lib*.dylib" ); | 39 | QDir dir( path, "lib*.dylib" ); |
40 | #else | 40 | #else |
41 | QDir dir( path, "lib*.so" ); | 41 | QDir dir( path, "lib*.so" ); |
42 | #endif /* Q_OS_MACX */ | 42 | #endif /* Q_OS_MACX */ |
43 | QStringList list = dir.entryList(); | 43 | QStringList list = dir.entryList(); |
44 | QStringList::Iterator it; | 44 | QStringList::Iterator it; |
45 | for ( it = list.begin(); it != list.end(); ++it ) { | 45 | for ( it = list.begin(); it != list.end(); ++it ) { |
46 | QLibrary *trylib = new QLibrary( path + *it ); | 46 | QLibrary *trylib = new QLibrary( path + *it ); |
47 | //odebug << "trying lib " << (path + (*it)) << "" << oendl; | 47 | //odebug << "trying lib " << (path + (*it)) << "" << oendl; |
48 | if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&obexIface ) == QS_OK ) { | 48 | if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&obexIface ) == QS_OK ) { |
49 | lib = trylib; | 49 | lib = trylib; |
50 | //odebug << "found obex lib" << oendl; | 50 | //odebug << "found obex lib" << oendl; |
51 | QString lang = getenv( "LANG" ); | 51 | QString lang = getenv( "LANG" ); |
52 | QTranslator * trans = new QTranslator(qApp); | 52 | QTranslator * trans = new QTranslator(qApp); |
53 | QString type = (*it).left( (*it).find(".") ); | 53 | QString type = (*it).left( (*it).find(".") ); |
54 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 54 | QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm"; |
55 | //odebug << "tr fpr obex: " << tfn << "" << oendl; | 55 | //odebug << "tr fpr obex: " << tfn << "" << oendl; |
56 | if ( trans->load( tfn )) | 56 | if ( trans->load( tfn )) |
57 | qApp->installTranslator( trans ); | 57 | qApp->installTranslator( trans ); |
58 | else | 58 | else |
59 | delete trans; | 59 | delete trans; |
60 | 60 | ||
61 | break; | 61 | break; |
62 | } else { | 62 | } else { |
63 | delete lib; | 63 | delete lib; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | if ( !lib ) | 66 | if ( !lib ) |
67 | odebug << "could not load IR plugin" << oendl; | 67 | odebug << "could not load IR plugin" << oendl; |
68 | } | 68 | } |
69 | 69 | ||
70 | IrServer::~IrServer() | 70 | IrServer::~IrServer() |
71 | { | 71 | { |
72 | if ( obexIface ) | 72 | if ( obexIface ) |
73 | obexIface->release(); | 73 | obexIface->release(); |
74 | delete lib; | 74 | delete lib; |
75 | } | 75 | } |
76 | 76 | ||
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index f3a7651..66f665f 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp | |||
@@ -222,169 +222,169 @@ void StartMenu::createMenuEntries( QPopupMenu *menu, QDir dir, bool ltabs, bool | |||
222 | dirs.sort(); | 222 | dirs.sort(); |
223 | 223 | ||
224 | for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) { | 224 | for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) { |
225 | createDirEntry( menu, dir, *it, lot ); | 225 | createDirEntry( menu, dir, *it, lot ); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | bool StartMenu::loadMenu( QPopupMenu *menu ) | 230 | bool StartMenu::loadMenu( QPopupMenu *menu ) |
231 | { | 231 | { |
232 | Config cfg("StartMenu"); | 232 | Config cfg("StartMenu"); |
233 | cfg.setGroup("Menu"); | 233 | cfg.setGroup("Menu"); |
234 | 234 | ||
235 | bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE); | 235 | bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE); |
236 | bool lot = cfg.readBoolEntry("LauncherOther", TRUE); | 236 | bool lot = cfg.readBoolEntry("LauncherOther", TRUE); |
237 | useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); | 237 | useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); |
238 | bool sepfirst = !ltabs && !lot; | 238 | bool sepfirst = !ltabs && !lot; |
239 | 239 | ||
240 | currentItem = 0; | 240 | currentItem = 0; |
241 | launchMenu->clear(); | 241 | launchMenu->clear(); |
242 | 242 | ||
243 | appLnks.setAutoDelete( true ); | 243 | appLnks.setAutoDelete( true ); |
244 | tabNames.setAutoDelete( true ); | 244 | tabNames.setAutoDelete( true ); |
245 | appLnks.clear(); | 245 | appLnks.clear(); |
246 | tabNames.clear(); | 246 | tabNames.clear(); |
247 | appLnks.setAutoDelete( false ); | 247 | appLnks.setAutoDelete( false ); |
248 | tabNames.setAutoDelete( false ); | 248 | tabNames.setAutoDelete( false ); |
249 | 249 | ||
250 | QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name ); | 250 | QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name ); |
251 | createMenuEntries( menu, dir, ltabs, lot ); | 251 | createMenuEntries( menu, dir, ltabs, lot ); |
252 | 252 | ||
253 | if ( !menu->count() ) sepfirst = TRUE; | 253 | if ( !menu->count() ) sepfirst = TRUE; |
254 | 254 | ||
255 | launchMenu->setName( sepfirst ? "accessories" : "accessories_need_sep" ); // No tr | 255 | launchMenu->setName( sepfirst ? "accessories" : "accessories_need_sep" ); // No tr |
256 | 256 | ||
257 | return currentItem; | 257 | return currentItem; |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void StartMenu::launch() | 261 | void StartMenu::launch() |
262 | { | 262 | { |
263 | int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); | 263 | int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); |
264 | 264 | ||
265 | if ( launchMenu->isVisible() ) | 265 | if ( launchMenu->isVisible() ) |
266 | launchMenu->hide(); | 266 | launchMenu->hide(); |
267 | else | 267 | else |
268 | launchMenu->popup( QPoint( 1, y ) ); | 268 | launchMenu->popup( QPoint( 1, y ) ); |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | 272 | ||
273 | 273 | ||
274 | static int compareAppletPositions(const void *b, const void *a) | 274 | static int compareAppletPositions(const void *b, const void *a) |
275 | { | 275 | { |
276 | const MenuApplet* aa = *(const MenuApplet**)a; | 276 | const MenuApplet* aa = *(const MenuApplet**)a; |
277 | const MenuApplet* ab = *(const MenuApplet**)b; | 277 | const MenuApplet* ab = *(const MenuApplet**)b; |
278 | int d = aa->iface->position() - ab->iface->position(); | 278 | int d = aa->iface->position() - ab->iface->position(); |
279 | if ( d ) return d; | 279 | if ( d ) return d; |
280 | return QString::compare(aa->library->library(),ab->library->library()); | 280 | return QString::compare(aa->library->library(),ab->library->library()); |
281 | } | 281 | } |
282 | 282 | ||
283 | void StartMenu::clearApplets() | 283 | void StartMenu::clearApplets() |
284 | { | 284 | { |
285 | if ( launchMenu ) | 285 | if ( launchMenu ) |
286 | launchMenu-> hide(); | 286 | launchMenu-> hide(); |
287 | 287 | ||
288 | for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { | 288 | for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { |
289 | MenuApplet *applet = it.current(); | 289 | MenuApplet *applet = it.current(); |
290 | if ( launchMenu ) { | 290 | if ( launchMenu ) { |
291 | launchMenu->removeItem( applet-> id ); | 291 | launchMenu->removeItem( applet-> id ); |
292 | delete applet->popup; | 292 | delete applet->popup; |
293 | } | 293 | } |
294 | 294 | ||
295 | applet->iface->release(); | 295 | applet->iface->release(); |
296 | applet->library->unload(); | 296 | applet->library->unload(); |
297 | delete applet-> library; | 297 | delete applet-> library; |
298 | } | 298 | } |
299 | menuApplets.clear(); | 299 | menuApplets.clear(); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | 303 | ||
304 | 304 | ||
305 | void StartMenu::loadApplets() | 305 | void StartMenu::loadApplets() |
306 | { | 306 | { |
307 | Config cfg( "StartMenu" ); | 307 | Config cfg( "StartMenu" ); |
308 | cfg.setGroup( "Applets" ); | 308 | cfg.setGroup( "Applets" ); |
309 | 309 | ||
310 | // SafeMode causes too much problems, so we disable it for now -- | 310 | // SafeMode causes too much problems, so we disable it for now -- |
311 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 | 311 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 |
312 | // removed in the remerge PluginManager could handle it | 312 | // removed in the remerge PluginManager could handle it |
313 | // we don't currently use it -zecke | 313 | // we don't currently use it -zecke |
314 | 314 | ||
315 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 315 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
316 | 316 | ||
317 | QString lang = getenv( "LANG" ); | 317 | QString lang = getenv( "LANG" ); |
318 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 318 | QString path = QPEApplication::qpeDir() + "plugins/applets"; |
319 | QDir dir( path, "lib*.so" ); | 319 | QDir dir( path, "lib*.so" ); |
320 | QStringList list = dir.entryList(); | 320 | QStringList list = dir.entryList(); |
321 | QStringList::Iterator it; | 321 | QStringList::Iterator it; |
322 | int napplets = 0; | 322 | int napplets = 0; |
323 | MenuApplet* *xapplets = new MenuApplet*[list.count()]; | 323 | MenuApplet* *xapplets = new MenuApplet*[list.count()]; |
324 | for ( it = list.begin(); it != list.end(); ++it ) { | 324 | for ( it = list.begin(); it != list.end(); ++it ) { |
325 | if ( exclude.find( *it ) != exclude.end() ) | 325 | if ( exclude.find( *it ) != exclude.end() ) |
326 | continue; | 326 | continue; |
327 | MenuAppletInterface *iface = 0; | 327 | MenuAppletInterface *iface = 0; |
328 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 328 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
329 | if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 329 | if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
330 | MenuApplet *applet = new MenuApplet; | 330 | MenuApplet *applet = new MenuApplet; |
331 | xapplets[napplets++] = applet; | 331 | xapplets[napplets++] = applet; |
332 | applet->library = lib; | 332 | applet->library = lib; |
333 | applet->iface = iface; | 333 | applet->iface = iface; |
334 | 334 | ||
335 | QTranslator *trans = new QTranslator(qApp); | 335 | QTranslator *trans = new QTranslator(qApp); |
336 | QString type = (*it).left( (*it).find(".") ); | 336 | QString type = (*it).left( (*it).find(".") ); |
337 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 337 | QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm"; |
338 | if ( trans->load( tfn )) | 338 | if ( trans->load( tfn )) |
339 | qApp->installTranslator( trans ); | 339 | qApp->installTranslator( trans ); |
340 | else | 340 | else |
341 | delete trans; | 341 | delete trans; |
342 | } else { | 342 | } else { |
343 | exclude += *it; | 343 | exclude += *it; |
344 | delete lib; | 344 | delete lib; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 347 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
348 | qsort(xapplets, napplets, sizeof(menuApplets[0]), compareAppletPositions); | 348 | qsort(xapplets, napplets, sizeof(menuApplets[0]), compareAppletPositions); |
349 | 349 | ||
350 | 350 | ||
351 | while ( napplets-- ) { | 351 | while ( napplets-- ) { |
352 | MenuApplet *applet = xapplets[napplets]; | 352 | MenuApplet *applet = xapplets[napplets]; |
353 | applet->popup = applet->iface->popup( this ); | 353 | applet->popup = applet->iface->popup( this ); |
354 | 354 | ||
355 | // menuApplets got an id < -1 | 355 | // menuApplets got an id < -1 |
356 | menuApplets.insert( -( currentItem + 2 ), new MenuApplet( *applet ) ); | 356 | menuApplets.insert( -( currentItem + 2 ), new MenuApplet( *applet ) ); |
357 | currentItem++; | 357 | currentItem++; |
358 | } | 358 | } |
359 | delete [] xapplets; | 359 | delete [] xapplets; |
360 | 360 | ||
361 | addApplets( launchMenu ); | 361 | addApplets( launchMenu ); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | /* | 365 | /* |
366 | * Launcher calls loadMenu too often fix that | 366 | * Launcher calls loadMenu too often fix that |
367 | */ | 367 | */ |
368 | void StartMenu::addApplets(QPopupMenu* pop) { | 368 | void StartMenu::addApplets(QPopupMenu* pop) { |
369 | QIntDict<MenuApplet> dict; | 369 | QIntDict<MenuApplet> dict; |
370 | if( pop-> count ( )) | 370 | if( pop-> count ( )) |
371 | pop-> insertSeparator ( ); | 371 | pop-> insertSeparator ( ); |
372 | 372 | ||
373 | for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { | 373 | for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { |
374 | MenuApplet *applet = it.current(); | 374 | MenuApplet *applet = it.current(); |
375 | if ( applet->popup ) | 375 | if ( applet->popup ) |
376 | applet->id = pop->insertItem( applet->iface->icon(), | 376 | applet->id = pop->insertItem( applet->iface->icon(), |
377 | applet->iface->text(), applet->popup ); | 377 | applet->iface->text(), applet->popup ); |
378 | else | 378 | else |
379 | applet->id = pop->insertItem( applet->iface->icon(), | 379 | applet->id = pop->insertItem( applet->iface->icon(), |
380 | applet->iface->text() ); | 380 | applet->iface->text() ); |
381 | 381 | ||
382 | 382 | ||
383 | dict.insert( applet->id, new MenuApplet( *applet ) ); | 383 | dict.insert( applet->id, new MenuApplet( *applet ) ); |
384 | } | 384 | } |
385 | /* need to update the key */ | 385 | /* need to update the key */ |
386 | menuApplets.setAutoDelete( true ); | 386 | menuApplets.setAutoDelete( true ); |
387 | menuApplets.clear(); | 387 | menuApplets.clear(); |
388 | menuApplets.setAutoDelete( false ); | 388 | menuApplets.setAutoDelete( false ); |
389 | menuApplets = dict; | 389 | menuApplets = dict; |
390 | } | 390 | } |
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index 3c72d25..d0f1808 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp | |||
@@ -4,147 +4,147 @@ | |||
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "systray.h" | 21 | #include "systray.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | #include <qtopia/qpeapplication.h> | 25 | #include <qtopia/qpeapplication.h> |
26 | #include <qtopia/qlibrary.h> | 26 | #include <qtopia/qlibrary.h> |
27 | #include <qtopia/config.h> | 27 | #include <qtopia/config.h> |
28 | using namespace Opie::Core; | 28 | using namespace Opie::Core; |
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | 33 | ||
34 | /* STD */ | 34 | /* STD */ |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | 36 | ||
37 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) | 37 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) |
38 | { | 38 | { |
39 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 39 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
40 | loadApplets(); | 40 | loadApplets(); |
41 | } | 41 | } |
42 | 42 | ||
43 | SysTray::~SysTray() | 43 | SysTray::~SysTray() |
44 | { | 44 | { |
45 | clearApplets(); | 45 | clearApplets(); |
46 | } | 46 | } |
47 | 47 | ||
48 | static int compareAppletPositions(const void *a, const void *b) | 48 | static int compareAppletPositions(const void *a, const void *b) |
49 | { | 49 | { |
50 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; | 50 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; |
51 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; | 51 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; |
52 | int d = ab->iface->position() - aa->iface->position(); | 52 | int d = ab->iface->position() - aa->iface->position(); |
53 | if ( d ) return d; | 53 | if ( d ) return d; |
54 | return QString::compare(ab->name,aa->name); | 54 | return QString::compare(ab->name,aa->name); |
55 | } | 55 | } |
56 | 56 | ||
57 | void SysTray::loadApplets() | 57 | void SysTray::loadApplets() |
58 | { | 58 | { |
59 | hide(); | 59 | hide(); |
60 | clearApplets(); | 60 | clearApplets(); |
61 | addApplets(); | 61 | addApplets(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void SysTray::clearApplets() | 64 | void SysTray::clearApplets() |
65 | { | 65 | { |
66 | #ifndef QT_NO_COMPONENTS | 66 | #ifndef QT_NO_COMPONENTS |
67 | 67 | ||
68 | /* | 68 | /* |
69 | * Note on clearing. SOme applets delete their | 69 | * Note on clearing. SOme applets delete their |
70 | * applets themselves some don't do it | 70 | * applets themselves some don't do it |
71 | * and on restart this can crash. If we delete it | 71 | * and on restart this can crash. If we delete it |
72 | * here we might end up in a double deletion. We could | 72 | * here we might end up in a double deletion. We could |
73 | * use QGuardedPtr but that would be one QOBject | 73 | * use QGuardedPtr but that would be one QOBject |
74 | * for every applet more but only useful for restart | 74 | * for every applet more but only useful for restart |
75 | */ | 75 | */ |
76 | QValueList<TaskbarApplet>::Iterator mit; | 76 | QValueList<TaskbarApplet>::Iterator mit; |
77 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { | 77 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { |
78 | (*mit).iface->release(); | 78 | (*mit).iface->release(); |
79 | (*mit).library->unload(); | 79 | (*mit).library->unload(); |
80 | delete (*mit).library; | 80 | delete (*mit).library; |
81 | } | 81 | } |
82 | 82 | ||
83 | #endif | 83 | #endif |
84 | appletList.clear(); | 84 | appletList.clear(); |
85 | if ( layout ) | 85 | if ( layout ) |
86 | delete layout; | 86 | delete layout; |
87 | layout = new QHBoxLayout( this, 0, 1 ); | 87 | layout = new QHBoxLayout( this, 0, 1 ); |
88 | layout->setAutoAdd(TRUE); | 88 | layout->setAutoAdd(TRUE); |
89 | } | 89 | } |
90 | 90 | ||
91 | void SysTray::addApplets() | 91 | void SysTray::addApplets() |
92 | { | 92 | { |
93 | hide(); | 93 | hide(); |
94 | #ifndef QT_NO_COMPONENTS | 94 | #ifndef QT_NO_COMPONENTS |
95 | Config cfg( "Taskbar" ); | 95 | Config cfg( "Taskbar" ); |
96 | cfg.setGroup( "Applets" ); | 96 | cfg.setGroup( "Applets" ); |
97 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 97 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
98 | 98 | ||
99 | QString lang = getenv( "LANG" ); | 99 | QString lang = getenv( "LANG" ); |
100 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 100 | QString path = QPEApplication::qpeDir() + "plugins/applets"; |
101 | #ifdef Q_OS_MACX | 101 | #ifdef Q_OS_MACX |
102 | QDir dir( path, "lib*.dylib" ); | 102 | QDir dir( path, "lib*.dylib" ); |
103 | #else | 103 | #else |
104 | QDir dir( path, "lib*.so" ); | 104 | QDir dir( path, "lib*.so" ); |
105 | #endif /* Q_OS_MACX */ | 105 | #endif /* Q_OS_MACX */ |
106 | QStringList list = dir.entryList(); | 106 | QStringList list = dir.entryList(); |
107 | QStringList::Iterator it; | 107 | QStringList::Iterator it; |
108 | int napplets=0; | 108 | int napplets=0; |
109 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; | 109 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; |
110 | for ( it = list.begin(); it != list.end(); ++it ) { | 110 | for ( it = list.begin(); it != list.end(); ++it ) { |
111 | if ( exclude.find( *it ) != exclude.end() ) | 111 | if ( exclude.find( *it ) != exclude.end() ) |
112 | continue; | 112 | continue; |
113 | owarn << "Found Applet: " << (*it) << "" << oendl; | 113 | owarn << "Found Applet: " << (*it) << "" << oendl; |
114 | TaskbarAppletInterface *iface = 0; | 114 | TaskbarAppletInterface *iface = 0; |
115 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 115 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
116 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 116 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
117 | TaskbarApplet *applet = new TaskbarApplet; | 117 | TaskbarApplet *applet = new TaskbarApplet; |
118 | applets[napplets++] = applet; | 118 | applets[napplets++] = applet; |
119 | applet->library = lib; | 119 | applet->library = lib; |
120 | applet->iface = iface; | 120 | applet->iface = iface; |
121 | 121 | ||
122 | QTranslator *trans = new QTranslator(qApp); | 122 | QTranslator *trans = new QTranslator(qApp); |
123 | QString type = (*it).left( (*it).find(".") ); | 123 | QString type = (*it).left( (*it).find(".") ); |
124 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 124 | QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm"; |
125 | if ( trans->load( tfn )) | 125 | if ( trans->load( tfn )) |
126 | qApp->installTranslator( trans ); | 126 | qApp->installTranslator( trans ); |
127 | else | 127 | else |
128 | delete trans; | 128 | delete trans; |
129 | } else { | 129 | } else { |
130 | exclude += *it; | 130 | exclude += *it; |
131 | delete lib; | 131 | delete lib; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 134 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
135 | qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); | 135 | qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); |
136 | while (napplets--) { | 136 | while (napplets--) { |
137 | TaskbarApplet *applet = applets[napplets]; | 137 | TaskbarApplet *applet = applets[napplets]; |
138 | applet->applet = applet->iface->applet( this ); | 138 | applet->applet = applet->iface->applet( this ); |
139 | appletList.append(*applet); | 139 | appletList.append(*applet); |
140 | } | 140 | } |
141 | delete [] applets; | 141 | delete [] applets; |
142 | #else /* ## FIXME single app */ | 142 | #else /* ## FIXME single app */ |
143 | TaskbarApplet * const applet = new TaskbarApplet(); | 143 | TaskbarApplet * const applet = new TaskbarApplet(); |
144 | applet->iface = new ClockAppletImpl(); | 144 | applet->iface = new ClockAppletImpl(); |
145 | applet->applet = applet->iface->applet( this ); | 145 | applet->applet = applet->iface->applet( this ); |
146 | appletList.append( applet ); | 146 | appletList.append( applet ); |
147 | #endif | 147 | #endif |
148 | show(); | 148 | show(); |
149 | } | 149 | } |
150 | 150 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index b700cd1..8b0fbbc 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp | |||
@@ -46,152 +46,152 @@ MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | |||
46 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { | 46 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { |
47 | Config cfg( "OpiePlayer" ); | 47 | Config cfg( "OpiePlayer" ); |
48 | readConfig( cfg ); | 48 | readConfig( cfg ); |
49 | loadPlugins(); | 49 | loadPlugins(); |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
53 | MediaPlayerState::~MediaPlayerState() { | 53 | MediaPlayerState::~MediaPlayerState() { |
54 | Config cfg( "OpiePlayer" ); | 54 | Config cfg( "OpiePlayer" ); |
55 | writeConfig( cfg ); | 55 | writeConfig( cfg ); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | void MediaPlayerState::readConfig( Config& cfg ) { | 59 | void MediaPlayerState::readConfig( Config& cfg ) { |
60 | cfg.setGroup("Options"); | 60 | cfg.setGroup("Options"); |
61 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 61 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
62 | isScaled = cfg.readBoolEntry( "Scaling" ); | 62 | isScaled = cfg.readBoolEntry( "Scaling" ); |
63 | isLooping = cfg.readBoolEntry( "Looping" ); | 63 | isLooping = cfg.readBoolEntry( "Looping" ); |
64 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 64 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
65 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 65 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
66 | usePlaylist = TRUE; | 66 | usePlaylist = TRUE; |
67 | isPlaying = FALSE; | 67 | isPlaying = FALSE; |
68 | isPaused = FALSE; | 68 | isPaused = FALSE; |
69 | curPosition = 0; | 69 | curPosition = 0; |
70 | curLength = 0; | 70 | curLength = 0; |
71 | curView = 'l'; | 71 | curView = 'l'; |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 75 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
76 | cfg.setGroup("Options"); | 76 | cfg.setGroup("Options"); |
77 | cfg.writeEntry("FullScreen", isFullscreen ); | 77 | cfg.writeEntry("FullScreen", isFullscreen ); |
78 | cfg.writeEntry("Scaling", isScaled ); | 78 | cfg.writeEntry("Scaling", isScaled ); |
79 | cfg.writeEntry("Looping", isLooping ); | 79 | cfg.writeEntry("Looping", isLooping ); |
80 | cfg.writeEntry("Shuffle", isShuffled ); | 80 | cfg.writeEntry("Shuffle", isShuffled ); |
81 | cfg.writeEntry("UsePlayList", usePlaylist ); | 81 | cfg.writeEntry("UsePlayList", usePlaylist ); |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | struct MediaPlayerPlugin { | 85 | struct MediaPlayerPlugin { |
86 | #ifndef QT_NO_COMPONENT | 86 | #ifndef QT_NO_COMPONENT |
87 | QLibrary *library; | 87 | QLibrary *library; |
88 | #endif | 88 | #endif |
89 | MediaPlayerPluginInterface *iface; | 89 | MediaPlayerPluginInterface *iface; |
90 | MediaPlayerDecoder *decoder; | 90 | MediaPlayerDecoder *decoder; |
91 | MediaPlayerEncoder *encoder; | 91 | MediaPlayerEncoder *encoder; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | static QValueList<MediaPlayerPlugin> pluginList; | 95 | static QValueList<MediaPlayerPlugin> pluginList; |
96 | 96 | ||
97 | 97 | ||
98 | // Find the first decoder which supports this type of file | 98 | // Find the first decoder which supports this type of file |
99 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { | 99 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { |
100 | MediaPlayerDecoder *tmpDecoder = NULL; | 100 | MediaPlayerDecoder *tmpDecoder = NULL; |
101 | QValueList<MediaPlayerPlugin>::Iterator it; | 101 | QValueList<MediaPlayerPlugin>::Iterator it; |
102 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 102 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
103 | if ( (*it).decoder->isFileSupported( file ) ) { | 103 | if ( (*it).decoder->isFileSupported( file ) ) { |
104 | tmpDecoder = (*it).decoder; | 104 | tmpDecoder = (*it).decoder; |
105 | break; | 105 | break; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | if(file.left(4)=="http") | 108 | if(file.left(4)=="http") |
109 | isStreaming = TRUE; | 109 | isStreaming = TRUE; |
110 | else | 110 | else |
111 | isStreaming = FALSE; | 111 | isStreaming = FALSE; |
112 | return decoder = tmpDecoder; | 112 | return decoder = tmpDecoder; |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { | 116 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { |
117 | return decoder; | 117 | return decoder; |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | // ### hack to get true sample count | 121 | // ### hack to get true sample count |
122 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { | 122 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { |
123 | return libmpeg3decoder; | 123 | return libmpeg3decoder; |
124 | } | 124 | } |
125 | 125 | ||
126 | // ### hack to get true sample count | 126 | // ### hack to get true sample count |
127 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { | 127 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { |
128 | // return libwavdecoder; | 128 | // return libwavdecoder; |
129 | // } | 129 | // } |
130 | 130 | ||
131 | void MediaPlayerState::loadPlugins() { | 131 | void MediaPlayerState::loadPlugins() { |
132 | // odebug << "load plugins" << oendl; | 132 | // odebug << "load plugins" << oendl; |
133 | #ifndef QT_NO_COMPONENT | 133 | #ifndef QT_NO_COMPONENT |
134 | QValueList<MediaPlayerPlugin>::Iterator mit; | 134 | QValueList<MediaPlayerPlugin>::Iterator mit; |
135 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { | 135 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { |
136 | (*mit).iface->release(); | 136 | (*mit).iface->release(); |
137 | (*mit).library->unload(); | 137 | (*mit).library->unload(); |
138 | delete (*mit).library; | 138 | delete (*mit).library; |
139 | } | 139 | } |
140 | pluginList.clear(); | 140 | pluginList.clear(); |
141 | 141 | ||
142 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; | 142 | QString path = QPEApplication::qpeDir() + "plugins/codecs"; |
143 | QDir dir( path, "lib*.so" ); | 143 | QDir dir( path, "lib*.so" ); |
144 | QStringList list = dir.entryList(); | 144 | QStringList list = dir.entryList(); |
145 | QStringList::Iterator it; | 145 | QStringList::Iterator it; |
146 | for ( it = list.begin(); it != list.end(); ++it ) { | 146 | for ( it = list.begin(); it != list.end(); ++it ) { |
147 | MediaPlayerPluginInterface *iface = 0; | 147 | MediaPlayerPluginInterface *iface = 0; |
148 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 148 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
149 | // odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; | 149 | // odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; |
150 | 150 | ||
151 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { | 151 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { |
152 | 152 | ||
153 | // odebug << "loading: " << QString( path + "/" + *it ) << "" << oendl; | 153 | // odebug << "loading: " << QString( path + "/" + *it ) << "" << oendl; |
154 | 154 | ||
155 | MediaPlayerPlugin plugin; | 155 | MediaPlayerPlugin plugin; |
156 | plugin.library = lib; | 156 | plugin.library = lib; |
157 | plugin.iface = iface; | 157 | plugin.iface = iface; |
158 | plugin.decoder = plugin.iface->decoder(); | 158 | plugin.decoder = plugin.iface->decoder(); |
159 | plugin.encoder = plugin.iface->encoder(); | 159 | plugin.encoder = plugin.iface->encoder(); |
160 | pluginList.append( plugin ); | 160 | pluginList.append( plugin ); |
161 | 161 | ||
162 | // ### hack to get true sample count | 162 | // ### hack to get true sample count |
163 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) | 163 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) |
164 | libmpeg3decoder = plugin.decoder; | 164 | libmpeg3decoder = plugin.decoder; |
165 | 165 | ||
166 | } else { | 166 | } else { |
167 | delete lib; | 167 | delete lib; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | #else | 170 | #else |
171 | pluginList.clear(); | 171 | pluginList.clear(); |
172 | 172 | ||
173 | MediaPlayerPlugin plugin0; | 173 | MediaPlayerPlugin plugin0; |
174 | plugin0.iface = new LibMpeg3PluginImpl; | 174 | plugin0.iface = new LibMpeg3PluginImpl; |
175 | plugin0.decoder = plugin0.iface->decoder(); | 175 | plugin0.decoder = plugin0.iface->decoder(); |
176 | plugin0.encoder = plugin0.iface->encoder(); | 176 | plugin0.encoder = plugin0.iface->encoder(); |
177 | pluginList.append( plugin0 ); | 177 | pluginList.append( plugin0 ); |
178 | 178 | ||
179 | MediaPlayerPlugin plugin1; | 179 | MediaPlayerPlugin plugin1; |
180 | plugin1.iface = new LibMadPluginImpl; | 180 | plugin1.iface = new LibMadPluginImpl; |
181 | plugin1.decoder = plugin1.iface->decoder(); | 181 | plugin1.decoder = plugin1.iface->decoder(); |
182 | plugin1.encoder = plugin1.iface->encoder(); | 182 | plugin1.encoder = plugin1.iface->encoder(); |
183 | pluginList.append( plugin1 ); | 183 | pluginList.append( plugin1 ); |
184 | 184 | ||
185 | MediaPlayerPlugin plugin2; | 185 | MediaPlayerPlugin plugin2; |
186 | plugin2.iface = new WavPluginImpl; | 186 | plugin2.iface = new WavPluginImpl; |
187 | plugin2.decoder = plugin2.iface->decoder(); | 187 | plugin2.decoder = plugin2.iface->decoder(); |
188 | plugin2.encoder = plugin2.iface->encoder(); | 188 | plugin2.encoder = plugin2.iface->encoder(); |
189 | pluginList.append( plugin2 ); | 189 | pluginList.append( plugin2 ); |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | if ( pluginList.count() ) | 192 | if ( pluginList.count() ) |
193 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); | 193 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); |
194 | else | 194 | else |
195 | MediaPlayerDebug(( "No decoders found" )); | 195 | MediaPlayerDebug(( "No decoders found" )); |
196 | } | 196 | } |
197 | 197 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 46aeff2..db2bf1b 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1289,171 +1289,171 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1289 | case Key_Q: //add to playlist | 1289 | case Key_Q: //add to playlist |
1290 | addSelected(); | 1290 | addSelected(); |
1291 | break; | 1291 | break; |
1292 | case Key_R: //remove from playlist | 1292 | case Key_R: //remove from playlist |
1293 | removeSelected(); | 1293 | removeSelected(); |
1294 | break; | 1294 | break; |
1295 | // case Key_P: //play | 1295 | // case Key_P: //play |
1296 | // odebug << "Play" << oendl; | 1296 | // odebug << "Play" << oendl; |
1297 | // playSelected(); | 1297 | // playSelected(); |
1298 | // break; | 1298 | // break; |
1299 | case Key_Space: | 1299 | case Key_Space: |
1300 | // playSelected(); puh | 1300 | // playSelected(); puh |
1301 | break; | 1301 | break; |
1302 | case Key_1: | 1302 | case Key_1: |
1303 | tabWidget->setCurrentPage(0); | 1303 | tabWidget->setCurrentPage(0); |
1304 | break; | 1304 | break; |
1305 | case Key_2: | 1305 | case Key_2: |
1306 | tabWidget->setCurrentPage(1); | 1306 | tabWidget->setCurrentPage(1); |
1307 | break; | 1307 | break; |
1308 | case Key_3: | 1308 | case Key_3: |
1309 | tabWidget->setCurrentPage(2); | 1309 | tabWidget->setCurrentPage(2); |
1310 | break; | 1310 | break; |
1311 | case Key_4: | 1311 | case Key_4: |
1312 | tabWidget->setCurrentPage(3); | 1312 | tabWidget->setCurrentPage(3); |
1313 | break; | 1313 | break; |
1314 | case Key_Down: | 1314 | case Key_Down: |
1315 | if ( !d->selectedFiles->next() ) | 1315 | if ( !d->selectedFiles->next() ) |
1316 | d->selectedFiles->first(); | 1316 | d->selectedFiles->first(); |
1317 | 1317 | ||
1318 | break; | 1318 | break; |
1319 | case Key_Up: | 1319 | case Key_Up: |
1320 | if ( !d->selectedFiles->prev() ) | 1320 | if ( !d->selectedFiles->prev() ) |
1321 | // d->selectedFiles->last(); | 1321 | // d->selectedFiles->last(); |
1322 | 1322 | ||
1323 | break; | 1323 | break; |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1328 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1329 | { | 1329 | { |
1330 | // odebug << "Key press" << oendl; | 1330 | // odebug << "Key press" << oendl; |
1331 | // switch ( e->key() ) { | 1331 | // switch ( e->key() ) { |
1332 | // ////////////////////////////// Zaurus keys | 1332 | // ////////////////////////////// Zaurus keys |
1333 | // case Key_A: //add to playlist | 1333 | // case Key_A: //add to playlist |
1334 | // odebug << "Add" << oendl; | 1334 | // odebug << "Add" << oendl; |
1335 | // addSelected(); | 1335 | // addSelected(); |
1336 | // break; | 1336 | // break; |
1337 | // case Key_R: //remove from playlist | 1337 | // case Key_R: //remove from playlist |
1338 | // removeSelected(); | 1338 | // removeSelected(); |
1339 | // break; | 1339 | // break; |
1340 | // case Key_P: //play | 1340 | // case Key_P: //play |
1341 | // odebug << "Play" << oendl; | 1341 | // odebug << "Play" << oendl; |
1342 | // playSelected(); | 1342 | // playSelected(); |
1343 | // break; | 1343 | // break; |
1344 | // case Key_Space: | 1344 | // case Key_Space: |
1345 | // odebug << "Play" << oendl; | 1345 | // odebug << "Play" << oendl; |
1346 | // playSelected(); | 1346 | // playSelected(); |
1347 | // break; | 1347 | // break; |
1348 | // } | 1348 | // } |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | void PlayListWidget::doBlank() { | 1351 | void PlayListWidget::doBlank() { |
1352 | // odebug << "do blanking" << oendl; | 1352 | // odebug << "do blanking" << oendl; |
1353 | #ifdef QT_QWS_DEVFS | 1353 | #ifdef QT_QWS_DEVFS |
1354 | fd=open("/dev/fb/0",O_RDWR); | 1354 | fd=open("/dev/fb/0",O_RDWR); |
1355 | #else | 1355 | #else |
1356 | fd=open("/dev/fb0",O_RDWR); | 1356 | fd=open("/dev/fb0",O_RDWR); |
1357 | #endif | 1357 | #endif |
1358 | if (fd != -1) { | 1358 | if (fd != -1) { |
1359 | ioctl(fd,FBIOBLANK,1); | 1359 | ioctl(fd,FBIOBLANK,1); |
1360 | // close(fd); | 1360 | // close(fd); |
1361 | } | 1361 | } |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | void PlayListWidget::doUnblank() { | 1364 | void PlayListWidget::doUnblank() { |
1365 | // this crashes opieplayer with a segfault | 1365 | // this crashes opieplayer with a segfault |
1366 | // int fd; | 1366 | // int fd; |
1367 | // fd=open("/dev/fb0",O_RDWR); | 1367 | // fd=open("/dev/fb0",O_RDWR); |
1368 | // odebug << "do unblanking" << oendl; | 1368 | // odebug << "do unblanking" << oendl; |
1369 | if (fd != -1) { | 1369 | if (fd != -1) { |
1370 | ioctl(fd,FBIOBLANK,0); | 1370 | ioctl(fd,FBIOBLANK,0); |
1371 | close(fd); | 1371 | close(fd); |
1372 | } | 1372 | } |
1373 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1373 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1374 | h <<-3;// v[1]; // -3 Force on | 1374 | h <<-3;// v[1]; // -3 Force on |
1375 | } | 1375 | } |
1376 | 1376 | ||
1377 | void PlayListWidget::populateSkinsMenu() { | 1377 | void PlayListWidget::populateSkinsMenu() { |
1378 | int item = 0; | 1378 | int item = 0; |
1379 | defaultSkinIndex = 0; | 1379 | defaultSkinIndex = 0; |
1380 | QString skinName; | 1380 | QString skinName; |
1381 | Config cfg( "OpiePlayer" ); | 1381 | Config cfg( "OpiePlayer" ); |
1382 | cfg.setGroup("Options" ); | 1382 | cfg.setGroup("Options" ); |
1383 | QString skin = cfg.readEntry( "Skin", "default" ); | 1383 | QString skin = cfg.readEntry( "Skin", "default" ); |
1384 | 1384 | ||
1385 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1385 | QDir skinsDir( QPEApplication::qpeDir() + "pics/opieplayer2/skins" ); |
1386 | skinsDir.setFilter( QDir::Dirs ); | 1386 | skinsDir.setFilter( QDir::Dirs ); |
1387 | skinsDir.setSorting(QDir::Name ); | 1387 | skinsDir.setSorting(QDir::Name ); |
1388 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1388 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1389 | QFileInfoListIterator it( *skinslist ); | 1389 | QFileInfoListIterator it( *skinslist ); |
1390 | QFileInfo *fi; | 1390 | QFileInfo *fi; |
1391 | while ( ( fi = it.current() ) ) { | 1391 | while ( ( fi = it.current() ) ) { |
1392 | skinName = fi->fileName(); | 1392 | skinName = fi->fileName(); |
1393 | // odebug << fi->fileName() << oendl; | 1393 | // odebug << fi->fileName() << oendl; |
1394 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1394 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1395 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1395 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1396 | } | 1396 | } |
1397 | if( skinName == "default" ) { | 1397 | if( skinName == "default" ) { |
1398 | defaultSkinIndex = item; | 1398 | defaultSkinIndex = item; |
1399 | } | 1399 | } |
1400 | if( skinName == skin ) { | 1400 | if( skinName == skin ) { |
1401 | skinsMenu->setItemChecked( item, TRUE ); | 1401 | skinsMenu->setItemChecked( item, TRUE ); |
1402 | } | 1402 | } |
1403 | ++it; | 1403 | ++it; |
1404 | } | 1404 | } |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | void PlayListWidget::skinsMenuActivated( int item ) { | 1407 | void PlayListWidget::skinsMenuActivated( int item ) { |
1408 | for( int i = defaultSkinIndex; i > defaultSkinIndex - static_cast<int>(skinsMenu->count()); i-- ) { | 1408 | for( int i = defaultSkinIndex; i > defaultSkinIndex - static_cast<int>(skinsMenu->count()); i-- ) { |
1409 | skinsMenu->setItemChecked( i, FALSE ); | 1409 | skinsMenu->setItemChecked( i, FALSE ); |
1410 | } | 1410 | } |
1411 | skinsMenu->setItemChecked( item, TRUE ); | 1411 | skinsMenu->setItemChecked( item, TRUE ); |
1412 | 1412 | ||
1413 | Config cfg( "OpiePlayer" ); | 1413 | Config cfg( "OpiePlayer" ); |
1414 | cfg.setGroup("Options"); | 1414 | cfg.setGroup("Options"); |
1415 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1415 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1418 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1419 | // odebug << "qcop message "+msg << oendl; | 1419 | // odebug << "qcop message "+msg << oendl; |
1420 | QDataStream stream ( data, IO_ReadOnly ); | 1420 | QDataStream stream ( data, IO_ReadOnly ); |
1421 | if ( msg == "play()" ) { //plays current selection | 1421 | if ( msg == "play()" ) { //plays current selection |
1422 | btnPlay( true); | 1422 | btnPlay( true); |
1423 | } else if ( msg == "stop()" ) { | 1423 | } else if ( msg == "stop()" ) { |
1424 | mediaPlayerState->setPlaying( false); | 1424 | mediaPlayerState->setPlaying( false); |
1425 | } else if ( msg == "togglePause()" ) { | 1425 | } else if ( msg == "togglePause()" ) { |
1426 | mediaPlayerState->togglePaused(); | 1426 | mediaPlayerState->togglePaused(); |
1427 | } else if ( msg == "next()" ) { //select next in lis | 1427 | } else if ( msg == "next()" ) { //select next in lis |
1428 | mediaPlayerState->setNext(); | 1428 | mediaPlayerState->setNext(); |
1429 | } else if ( msg == "prev()" ) { //select previous in list | 1429 | } else if ( msg == "prev()" ) { //select previous in list |
1430 | mediaPlayerState->setPrev(); | 1430 | mediaPlayerState->setPrev(); |
1431 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1431 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1432 | mediaPlayerState->toggleLooping(); | 1432 | mediaPlayerState->toggleLooping(); |
1433 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1433 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1434 | mediaPlayerState->toggleShuffled(); | 1434 | mediaPlayerState->toggleShuffled(); |
1435 | } else if ( msg == "volUp()" ) { //volume more | 1435 | } else if ( msg == "volUp()" ) { //volume more |
1436 | // emit moreClicked(); | 1436 | // emit moreClicked(); |
1437 | // emit moreReleased(); | 1437 | // emit moreReleased(); |
1438 | } else if ( msg == "volDown()" ) { //volume less | 1438 | } else if ( msg == "volDown()" ) { //volume less |
1439 | // emit lessClicked(); | 1439 | // emit lessClicked(); |
1440 | // emit lessReleased(); | 1440 | // emit lessReleased(); |
1441 | } else if ( msg == "play(QString)" ) { //play this now | 1441 | } else if ( msg == "play(QString)" ) { //play this now |
1442 | QString file; | 1442 | QString file; |
1443 | stream >> file; | 1443 | stream >> file; |
1444 | setDocumentEx( (const QString &) file); | 1444 | setDocumentEx( (const QString &) file); |
1445 | } else if ( msg == "add(QString)" ) { //add to playlist | 1445 | } else if ( msg == "add(QString)" ) { //add to playlist |
1446 | QString file; | 1446 | QString file; |
1447 | stream >> file; | 1447 | stream >> file; |
1448 | QFileInfo fileInfo(file); | 1448 | QFileInfo fileInfo(file); |
1449 | DocLnk lnk; | 1449 | DocLnk lnk; |
1450 | lnk.setName( fileInfo.baseName() ); //sets name | 1450 | lnk.setName( fileInfo.baseName() ); //sets name |
1451 | lnk.setFile( file ); //sets file name | 1451 | lnk.setFile( file ); //sets file name |
1452 | addToSelection( lnk ); | 1452 | addToSelection( lnk ); |
1453 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1453 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1454 | QString file; | 1454 | QString file; |
1455 | stream >> file; | 1455 | stream >> file; |
1456 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop | 1456 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop |
1457 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); | 1457 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); |
1458 | } | 1458 | } |
1459 | } | 1459 | } |
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 2396ed5..c545511 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -5,193 +5,193 @@ | |||
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "videowidget.h" | 21 | #include "videowidget.h" |
22 | #include "mediaplayerstate.h" | 22 | #include "mediaplayerstate.h" |
23 | 23 | ||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/mediaplayerplugininterface.h> | 26 | #include <qpe/mediaplayerplugininterface.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <opie2/odebug.h> | 29 | #include <opie2/odebug.h> |
30 | 30 | ||
31 | /* QT */ | 31 | /* QT */ |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qslider.h> | 33 | #include <qslider.h> |
34 | 34 | ||
35 | 35 | ||
36 | #ifdef Q_WS_QWS | 36 | #ifdef Q_WS_QWS |
37 | # define USE_DIRECT_PAINTER | 37 | # define USE_DIRECT_PAINTER |
38 | # include <qdirectpainter_qws.h> | 38 | # include <qdirectpainter_qws.h> |
39 | # include <qgfxraster_qws.h> | 39 | # include <qgfxraster_qws.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | 42 | ||
43 | extern MediaPlayerState *mediaPlayerState; | 43 | extern MediaPlayerState *mediaPlayerState; |
44 | 44 | ||
45 | 45 | ||
46 | static const int xo = 2; // movable x offset | 46 | static const int xo = 2; // movable x offset |
47 | static const int yo = 0; // movable y offset | 47 | static const int yo = 0; // movable y offset |
48 | 48 | ||
49 | 49 | ||
50 | struct MediaButton { | 50 | struct MediaButton { |
51 | // int xPos, yPos; | 51 | // int xPos, yPos; |
52 | bool isToggle, isHeld, isDown; | 52 | bool isToggle, isHeld, isDown; |
53 | // int controlType; | 53 | // int controlType; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | 56 | ||
57 | // Layout information for the videoButtons (and if it is a toggle button or not) | 57 | // Layout information for the videoButtons (and if it is a toggle button or not) |
58 | MediaButton videoButtons[] = { | 58 | MediaButton videoButtons[] = { |
59 | { FALSE, FALSE, FALSE }, // stop | 59 | { FALSE, FALSE, FALSE }, // stop |
60 | { FALSE, FALSE, FALSE }, // play | 60 | { FALSE, FALSE, FALSE }, // play |
61 | { FALSE, FALSE, FALSE }, // previous | 61 | { FALSE, FALSE, FALSE }, // previous |
62 | { FALSE, FALSE, FALSE }, // next | 62 | { FALSE, FALSE, FALSE }, // next |
63 | { FALSE, FALSE, FALSE }, // volUp | 63 | { FALSE, FALSE, FALSE }, // volUp |
64 | { FALSE, FALSE, FALSE }, // volDown | 64 | { FALSE, FALSE, FALSE }, // volDown |
65 | { TRUE, FALSE, FALSE } // fullscreen | 65 | { TRUE, FALSE, FALSE } // fullscreen |
66 | }; | 66 | }; |
67 | 67 | ||
68 | //static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 68 | //static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
69 | 69 | ||
70 | const char *skinV_mask_file_names[7] = { | 70 | const char *skinV_mask_file_names[7] = { |
71 | "stop","play","back","fwd","up","down","full" | 71 | "stop","play","back","fwd","up","down","full" |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 74 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
75 | 75 | ||
76 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 76 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
77 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) | 77 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) |
78 | { | 78 | { |
79 | setCaption( tr("OpiePlayer") ); | 79 | setCaption( tr("OpiePlayer") ); |
80 | Config cfg("OpiePlayer"); | 80 | Config cfg("OpiePlayer"); |
81 | 81 | ||
82 | cfg.setGroup("Options"); | 82 | cfg.setGroup("Options"); |
83 | skin = cfg.readEntry("Skin","default"); | 83 | skin = cfg.readEntry("Skin","default"); |
84 | 84 | ||
85 | QString skinPath; | 85 | QString skinPath; |
86 | skinPath = "opieplayer2/skins/" + skin; | 86 | skinPath = "opieplayer2/skins/" + skin; |
87 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) | 87 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
88 | skinPath = "opieplayer2/skins/default"; | 88 | skinPath = "opieplayer2/skins/default"; |
89 | 89 | ||
90 | 90 | ||
91 | // QString skinPath = "opieplayer2/skins/" + skin; | 91 | // QString skinPath = "opieplayer2/skins/" + skin; |
92 | 92 | ||
93 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 93 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
94 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 94 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
95 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 95 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
96 | 96 | ||
97 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 97 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
98 | imgButtonMask->fill( 0 ); | 98 | imgButtonMask->fill( 0 ); |
99 | 99 | ||
100 | for ( int i = 0; i < 7; i++ ) { | 100 | for ( int i = 0; i < 7; i++ ) { |
101 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + | 101 | QString filename = QString( QPEApplication::qpeDir() + "pics/" + skinPath + |
102 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 102 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
103 | // odebug << "loading "+filename << oendl; | 103 | // odebug << "loading "+filename << oendl; |
104 | masks[i] = new QBitmap( filename ); | 104 | masks[i] = new QBitmap( filename ); |
105 | 105 | ||
106 | if ( !masks[i]->isNull() ) { | 106 | if ( !masks[i]->isNull() ) { |
107 | QImage imgMask = masks[i]->convertToImage(); | 107 | QImage imgMask = masks[i]->convertToImage(); |
108 | uchar **dest = imgButtonMask->jumpTable(); | 108 | uchar **dest = imgButtonMask->jumpTable(); |
109 | for ( int y = 0; y < imgUp->height(); y++ ) { | 109 | for ( int y = 0; y < imgUp->height(); y++ ) { |
110 | uchar *line = dest[y]; | 110 | uchar *line = dest[y]; |
111 | for ( int x = 0; x < imgUp->width(); x++ ) { | 111 | for ( int x = 0; x < imgUp->width(); x++ ) { |
112 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 112 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
113 | line[x] = i + 1; | 113 | line[x] = i + 1; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | for ( int i = 0; i < 7; i++ ) { | 118 | for ( int i = 0; i < 7; i++ ) { |
119 | buttonPixUp[i] = NULL; | 119 | buttonPixUp[i] = NULL; |
120 | buttonPixDown[i] = NULL; | 120 | buttonPixDown[i] = NULL; |
121 | } | 121 | } |
122 | 122 | ||
123 | QWidget *d = QApplication::desktop(); | 123 | QWidget *d = QApplication::desktop(); |
124 | int width = d->width(); | 124 | int width = d->width(); |
125 | int height = d->height(); | 125 | int height = d->height(); |
126 | 126 | ||
127 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { | 127 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { |
128 | QImage img; | 128 | QImage img; |
129 | img = pixBg->convertToImage(); | 129 | img = pixBg->convertToImage(); |
130 | pixBg->convertFromImage( img.smoothScale( width, height)); | 130 | pixBg->convertFromImage( img.smoothScale( width, height)); |
131 | } | 131 | } |
132 | 132 | ||
133 | setBackgroundPixmap( *pixBg ); | 133 | setBackgroundPixmap( *pixBg ); |
134 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 134 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
135 | slider = new QSlider( Qt::Horizontal, this ); | 135 | slider = new QSlider( Qt::Horizontal, this ); |
136 | slider->setMinValue( 0 ); | 136 | slider->setMinValue( 0 ); |
137 | slider->setMaxValue( 1 ); | 137 | slider->setMaxValue( 1 ); |
138 | 138 | ||
139 | slider->setBackgroundPixmap( *pixBg ); | 139 | slider->setBackgroundPixmap( *pixBg ); |
140 | slider->setFocusPolicy( QWidget::NoFocus ); | 140 | slider->setFocusPolicy( QWidget::NoFocus ); |
141 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 141 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
142 | 142 | ||
143 | connect(slider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); | 143 | connect(slider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); |
144 | connect(slider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); | 144 | connect(slider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); |
145 | 145 | ||
146 | connect(mediaPlayerState,SIGNAL(lengthChanged(long)),this,SLOT(setLength(long))); | 146 | connect(mediaPlayerState,SIGNAL(lengthChanged(long)),this,SLOT(setLength(long))); |
147 | connect(mediaPlayerState,SIGNAL(positionChanged(long)),this,SLOT(setPosition(long))); | 147 | connect(mediaPlayerState,SIGNAL(positionChanged(long)),this,SLOT(setPosition(long))); |
148 | connect(mediaPlayerState,SIGNAL(positionUpdated(long)),this,SLOT(setPosition(long))); | 148 | connect(mediaPlayerState,SIGNAL(positionUpdated(long)),this,SLOT(setPosition(long))); |
149 | connect(mediaPlayerState,SIGNAL(viewChanged(char)),this,SLOT(setView(char))); | 149 | connect(mediaPlayerState,SIGNAL(viewChanged(char)),this,SLOT(setView(char))); |
150 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 150 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
151 | connect(mediaPlayerState,SIGNAL(playingToggled(bool)),this,SLOT(setPlaying(bool))); | 151 | connect(mediaPlayerState,SIGNAL(playingToggled(bool)),this,SLOT(setPlaying(bool))); |
152 | 152 | ||
153 | // Intialise state | 153 | // Intialise state |
154 | setLength( mediaPlayerState->length() ); | 154 | setLength( mediaPlayerState->length() ); |
155 | setPosition( mediaPlayerState->position() ); | 155 | setPosition( mediaPlayerState->position() ); |
156 | setFullscreen( mediaPlayerState->fullscreen() ); | 156 | setFullscreen( mediaPlayerState->fullscreen() ); |
157 | // setPlaying( mediaPlayerState->playing() ); | 157 | // setPlaying( mediaPlayerState->playing() ); |
158 | // if(this->x() < 0 || this->y() < 0) | 158 | // if(this->x() < 0 || this->y() < 0) |
159 | // this->move(0,0); | 159 | // this->move(0,0); |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | VideoWidget::~VideoWidget() { | 163 | VideoWidget::~VideoWidget() { |
164 | 164 | ||
165 | for ( int i = 0; i < 7; i++ ) | 165 | for ( int i = 0; i < 7; i++ ) |
166 | { | 166 | { |
167 | delete buttonPixUp[i]; | 167 | delete buttonPixUp[i]; |
168 | delete buttonPixDown[i]; | 168 | delete buttonPixDown[i]; |
169 | } | 169 | } |
170 | 170 | ||
171 | delete pixBg; | 171 | delete pixBg; |
172 | delete imgUp; | 172 | delete imgUp; |
173 | delete imgDn; | 173 | delete imgDn; |
174 | delete imgButtonMask; | 174 | delete imgButtonMask; |
175 | for ( int i = 0; i < 7; i++ ) | 175 | for ( int i = 0; i < 7; i++ ) |
176 | { | 176 | { |
177 | delete masks[i]; | 177 | delete masks[i]; |
178 | } | 178 | } |
179 | 179 | ||
180 | // for ( int i = 0; i < 3; i++ ) | 180 | // for ( int i = 0; i < 3; i++ ) |
181 | // delete pixmaps[i]; | 181 | // delete pixmaps[i]; |
182 | // delete currentFrame; | 182 | // delete currentFrame; |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | static bool videoSliderBeingMoved = FALSE; | 186 | static bool videoSliderBeingMoved = FALSE; |
187 | 187 | ||
188 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 188 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
189 | QPixmap pix( img.width(), img.height() ); | 189 | QPixmap pix( img.width(), img.height() ); |
190 | QPainter p( &pix ); | 190 | QPainter p( &pix ); |
191 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 191 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
192 | p.drawImage( 0, 0, img ); | 192 | p.drawImage( 0, 0, img ); |
193 | return new QPixmap( pix ); | 193 | return new QPixmap( pix ); |
194 | } | 194 | } |
195 | 195 | ||
196 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 196 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
197 | QPixmap *pixmap = new QPixmap( pix ); | 197 | QPixmap *pixmap = new QPixmap( pix ); |
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp index f0a8ba2..0699d0a 100644 --- a/core/opie-login/main.cpp +++ b/core/opie-login/main.cpp | |||
@@ -87,193 +87,193 @@ int main ( int argc, char **argv ) | |||
87 | switch ( c ) { | 87 | switch ( c ) { |
88 | case 'a': | 88 | case 'a': |
89 | autolog = optarg; | 89 | autolog = optarg; |
90 | break; | 90 | break; |
91 | default: | 91 | default: |
92 | ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); | 92 | ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); |
93 | return 2; | 93 | return 2; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | //struct rlimit rl; | 97 | //struct rlimit rl; |
98 | //::getrlimit ( RLIMIT_NOFILE, &rl ); | 98 | //::getrlimit ( RLIMIT_NOFILE, &rl ); |
99 | 99 | ||
100 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) | 100 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) |
101 | // ::close ( i ); | 101 | // ::close ( i ); |
102 | 102 | ||
103 | ::setpgid ( 0, 0 ); | 103 | ::setpgid ( 0, 0 ); |
104 | ::setsid ( ); | 104 | ::setsid ( ); |
105 | 105 | ||
106 | ::signal ( SIGTERM, sigterm ); | 106 | ::signal ( SIGTERM, sigterm ); |
107 | ::signal ( SIGINT, sigterm ); | 107 | ::signal ( SIGINT, sigterm ); |
108 | 108 | ||
109 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); | 109 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); |
110 | ::atexit ( exit_closelog ); | 110 | ::atexit ( exit_closelog ); |
111 | 111 | ||
112 | while ( true ) { | 112 | while ( true ) { |
113 | pid_t child = ::fork ( ); | 113 | pid_t child = ::fork ( ); |
114 | 114 | ||
115 | if ( child < 0 ) { | 115 | if ( child < 0 ) { |
116 | ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); | 116 | ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | else if ( child > 0 ) { | 119 | else if ( child > 0 ) { |
120 | int status = 0; | 120 | int status = 0; |
121 | time_t started = ::time ( 0 ); | 121 | time_t started = ::time ( 0 ); |
122 | 122 | ||
123 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } | 123 | while ( ::waitpid ( child, &status, 0 ) < 0 ) { } |
124 | 124 | ||
125 | LoginApplication::logout ( ); | 125 | LoginApplication::logout ( ); |
126 | 126 | ||
127 | if (( ::time ( 0 ) - started ) < 3 ) { | 127 | if (( ::time ( 0 ) - started ) < 3 ) { |
128 | if ( autolog ) { | 128 | if ( autolog ) { |
129 | ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); | 129 | ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); |
130 | autolog = 0; | 130 | autolog = 0; |
131 | } | 131 | } |
132 | else { | 132 | else { |
133 | ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); | 133 | ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | } | 136 | } |
137 | int killedbysig = 0; | 137 | int killedbysig = 0; |
138 | userExited=0; | 138 | userExited=0; |
139 | if (WIFEXITED(status)!=0 ) { | 139 | if (WIFEXITED(status)!=0 ) { |
140 | if (WEXITSTATUS(status)==137) { | 140 | if (WEXITSTATUS(status)==137) { |
141 | userExited=1; | 141 | userExited=1; |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | if ( WIFSIGNALED( status )) { | 145 | if ( WIFSIGNALED( status )) { |
146 | switch ( WTERMSIG( status )) { | 146 | switch ( WTERMSIG( status )) { |
147 | case SIGTERM: | 147 | case SIGTERM: |
148 | case SIGINT : | 148 | case SIGINT : |
149 | case SIGKILL: | 149 | case SIGKILL: |
150 | break; | 150 | break; |
151 | 151 | ||
152 | default : | 152 | default : |
153 | killedbysig = WTERMSIG( status ); | 153 | killedbysig = WTERMSIG( status ); |
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | if ( killedbysig ) { // qpe was killed by an uncaught signal | 157 | if ( killedbysig ) { // qpe was killed by an uncaught signal |
158 | qApp = 0; | 158 | qApp = 0; |
159 | 159 | ||
160 | ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); | 160 | ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); |
161 | 161 | ||
162 | QWSServer::setDesktopBackground ( QImage ( )); | 162 | QWSServer::setDesktopBackground ( QImage ( )); |
163 | QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); | 163 | QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); |
164 | app-> setFont ( QFont ( "Helvetica", 10 )); | 164 | app-> setFont ( QFont ( "Helvetica", 10 )); |
165 | app-> setStyle ( new QPEStyle ( )); | 165 | app-> setStyle ( new QPEStyle ( )); |
166 | 166 | ||
167 | // const char *sig = ::strsignal ( killedbysig ); | 167 | // const char *sig = ::strsignal ( killedbysig ); |
168 | const char *sig = ::sys_siglist[killedbysig]; | 168 | const char *sig = ::sys_siglist[killedbysig]; |
169 | QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); | 169 | QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); |
170 | l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); | 170 | l-> setText ( LoginWindowImpl::tr( "Opie was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); |
171 | l-> setAlignment ( Qt::AlignCenter ); | 171 | l-> setAlignment ( Qt::AlignCenter ); |
172 | l-> move ( 0, 0 ); | 172 | l-> move ( 0, 0 ); |
173 | l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); | 173 | l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); |
174 | l-> show ( ); | 174 | l-> show ( ); |
175 | QTimer::singleShot ( 3000, app, SLOT( quit())); | 175 | QTimer::singleShot ( 3000, app, SLOT( quit())); |
176 | app-> exec ( ); | 176 | app-> exec ( ); |
177 | delete app; | 177 | delete app; |
178 | qApp = 0; | 178 | qApp = 0; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | else { | 181 | else { |
182 | if ( !autolog ) { | 182 | if ( !autolog ) { |
183 | QString confFile=QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 183 | QString confFile=QPEApplication::qpeDir() + "etc/opie-login.conf"; |
184 | Config cfg ( confFile, Config::File ); | 184 | Config cfg ( confFile, Config::File ); |
185 | cfg. setGroup ( "General" ); | 185 | cfg. setGroup ( "General" ); |
186 | QString user = cfg. readEntry ( "AutoLogin" ); | 186 | QString user = cfg. readEntry ( "AutoLogin" ); |
187 | 187 | ||
188 | if ( !user. isEmpty ( )) | 188 | if ( !user. isEmpty ( )) |
189 | autolog = ::strdup ( user. latin1 ( )); | 189 | autolog = ::strdup ( user. latin1 ( )); |
190 | } | 190 | } |
191 | 191 | ||
192 | if ( autolog && !userExited ) { | 192 | if ( autolog && !userExited ) { |
193 | 193 | ||
194 | QWSServer::setDesktopBackground( QImage() ); | 194 | QWSServer::setDesktopBackground( QImage() ); |
195 | ODevice::inst ( )-> setDisplayStatus ( true ); | 195 | ODevice::inst ( )-> setDisplayStatus ( true ); |
196 | ODevice::inst ( )-> setSoftSuspend ( false ); | 196 | ODevice::inst ( )-> setSoftSuspend ( false ); |
197 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); | 197 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); |
198 | LoginApplication::setLoginAs ( autolog ); | 198 | LoginApplication::setLoginAs ( autolog ); |
199 | 199 | ||
200 | 200 | ||
201 | if ( LoginApplication::changeIdentity ( )) | 201 | if ( LoginApplication::changeIdentity ( )) |
202 | ::exit ( LoginApplication::login ( )); | 202 | ::exit ( LoginApplication::login ( )); |
203 | else | 203 | else |
204 | ::exit ( 0 ); | 204 | ::exit ( 0 ); |
205 | } | 205 | } |
206 | else { | 206 | else { |
207 | ::exit ( login_main ( argc, argv, ppid )); | 207 | ::exit ( login_main ( argc, argv, ppid )); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | } | 210 | } |
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | 213 | ||
214 | void sigterm ( int /*sig*/ ) | 214 | void sigterm ( int /*sig*/ ) |
215 | { | 215 | { |
216 | ::exit ( 0 ); | 216 | ::exit ( 0 ); |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | void exit_closelog ( ) | 220 | void exit_closelog ( ) |
221 | { | 221 | { |
222 | ::closelog ( ); | 222 | ::closelog ( ); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | class LoginScreenSaver : public QWSScreenSaver | 226 | class LoginScreenSaver : public QWSScreenSaver |
227 | { | 227 | { |
228 | public: | 228 | public: |
229 | LoginScreenSaver ( ) | 229 | LoginScreenSaver ( ) |
230 | { | 230 | { |
231 | m_lcd_status = true; | 231 | m_lcd_status = true; |
232 | 232 | ||
233 | m_backlight_bright = -1; | 233 | m_backlight_bright = -1; |
234 | m_backlight_forcedoff = false; | 234 | m_backlight_forcedoff = false; |
235 | 235 | ||
236 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 236 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
237 | ODevice::inst ( )-> setDisplayStatus ( true ); | 237 | ODevice::inst ( )-> setDisplayStatus ( true ); |
238 | } | 238 | } |
239 | void restore() | 239 | void restore() |
240 | { | 240 | { |
241 | if ( !m_lcd_status ) // We must have turned it off | 241 | if ( !m_lcd_status ) // We must have turned it off |
242 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 242 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
243 | 243 | ||
244 | setBacklight ( -3 ); | 244 | setBacklight ( -3 ); |
245 | } | 245 | } |
246 | bool save( int level ) | 246 | bool save( int level ) |
247 | { | 247 | { |
248 | switch ( level ) { | 248 | switch ( level ) { |
249 | case 0: | 249 | case 0: |
250 | if ( backlight() > 1 ) | 250 | if ( backlight() > 1 ) |
251 | setBacklight( 1 ); // lowest non-off | 251 | setBacklight( 1 ); // lowest non-off |
252 | return true; | 252 | return true; |
253 | break; | 253 | break; |
254 | case 1: | 254 | case 1: |
255 | setBacklight( 0 ); // off | 255 | setBacklight( 0 ); // off |
256 | return true; | 256 | return true; |
257 | break; | 257 | break; |
258 | case 2: | 258 | case 2: |
259 | // We're going to suspend the whole machine | 259 | // We're going to suspend the whole machine |
260 | if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { | 260 | if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { |
261 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 261 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
262 | return true; | 262 | return true; |
263 | } | 263 | } |
264 | break; | 264 | break; |
265 | } | 265 | } |
266 | return false; | 266 | return false; |
267 | } | 267 | } |
268 | 268 | ||
269 | private: | 269 | private: |
270 | public: | 270 | public: |
271 | void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) | 271 | void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) |
272 | { | 272 | { |
273 | int v [4]; | 273 | int v [4]; |
274 | 274 | ||
275 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 275 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
276 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 276 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
277 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 277 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
278 | v [ 3 ] = 0; | 278 | v [ 3 ] = 0; |
279 | 279 | ||
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp index 2b64c47..55bf358 100644 --- a/core/settings/launcher/menusettings.cpp +++ b/core/settings/launcher/menusettings.cpp | |||
@@ -1,178 +1,178 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "menusettings.h" | 29 | #include "menusettings.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/qlibrary.h> | 32 | #include <qpe/qlibrary.h> |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/menuappletinterface.h> | 34 | #include <qpe/menuappletinterface.h> |
35 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qlistview.h> | 38 | #include <qlistview.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qheader.h> | 40 | #include <qheader.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qwhatsthis.h> | 43 | #include <qwhatsthis.h> |
44 | 44 | ||
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | 46 | ||
47 | 47 | ||
48 | MenuSettings::MenuSettings ( QWidget *parent, const char *name ) | 48 | MenuSettings::MenuSettings ( 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 in O-Menu:" ), this ); | 55 | QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), 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 | m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this ); | 64 | m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this ); |
65 | lay-> addWidget ( m_menutabs ); | 65 | lay-> addWidget ( m_menutabs ); |
66 | 66 | ||
67 | m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this ); | 67 | m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this ); |
68 | lay-> addWidget ( m_menusubpopup ); | 68 | lay-> addWidget ( m_menusubpopup ); |
69 | 69 | ||
70 | QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." )); | 70 | QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." )); |
71 | QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." )); | 71 | QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." )); |
72 | 72 | ||
73 | connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); | 73 | connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); |
74 | 74 | ||
75 | init ( ); | 75 | init ( ); |
76 | } | 76 | } |
77 | 77 | ||
78 | void MenuSettings::init ( ) | 78 | void MenuSettings::init ( ) |
79 | { | 79 | { |
80 | Config cfg ( "StartMenu" ); | 80 | Config cfg ( "StartMenu" ); |
81 | cfg. setGroup ( "Applets" ); | 81 | cfg. setGroup ( "Applets" ); |
82 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); | 82 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); |
83 | 83 | ||
84 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; | 84 | QString path = QPEApplication::qpeDir ( ) + "plugins/applets"; |
85 | #ifdef Q_OS_MACX | 85 | #ifdef Q_OS_MACX |
86 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); | 86 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); |
87 | #else | 87 | #else |
88 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); | 88 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); |
89 | #endif /* Q_OS_MACX */ | 89 | #endif /* Q_OS_MACX */ |
90 | 90 | ||
91 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { | 91 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { |
92 | QString name; | 92 | QString name; |
93 | QPixmap icon; | 93 | QPixmap icon; |
94 | MenuAppletInterface *iface = 0; | 94 | MenuAppletInterface *iface = 0; |
95 | 95 | ||
96 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 96 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
97 | lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); | 97 | lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); |
98 | if ( iface ) { | 98 | if ( iface ) { |
99 | QString lang = getenv( "LANG" ); | 99 | QString lang = getenv( "LANG" ); |
100 | QTranslator *trans = new QTranslator ( qApp ); | 100 | QTranslator *trans = new QTranslator ( qApp ); |
101 | QString type = (*it). left ((*it). find (".")); | 101 | QString type = (*it). left ((*it). find (".")); |
102 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; | 102 | QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm"; |
103 | if ( trans-> load ( tfn )) | 103 | if ( trans-> load ( tfn )) |
104 | qApp-> installTranslator ( trans ); | 104 | qApp-> installTranslator ( trans ); |
105 | else | 105 | else |
106 | delete trans; | 106 | delete trans; |
107 | name = iface-> name ( ); | 107 | name = iface-> name ( ); |
108 | icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); | 108 | icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); |
109 | iface-> release ( ); | 109 | iface-> release ( ); |
110 | lib-> unload ( ); | 110 | lib-> unload ( ); |
111 | 111 | ||
112 | QCheckListItem *item; | 112 | QCheckListItem *item; |
113 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); | 113 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); |
114 | if ( !icon. isNull ( )) | 114 | if ( !icon. isNull ( )) |
115 | item-> setPixmap ( 0, icon ); | 115 | item-> setPixmap ( 0, icon ); |
116 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); | 116 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); |
117 | m_applets [*it] = item; | 117 | m_applets [*it] = item; |
118 | } else { | 118 | } else { |
119 | delete lib; | 119 | delete lib; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | cfg. setGroup ( "Menu" ); | 123 | cfg. setGroup ( "Menu" ); |
124 | m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) ); | 124 | m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) ); |
125 | m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) ); | 125 | m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) ); |
126 | m_menusubpopup->setEnabled( m_menutabs->isChecked() ); | 126 | m_menusubpopup->setEnabled( m_menutabs->isChecked() ); |
127 | connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) ); | 127 | connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) ); |
128 | 128 | ||
129 | } | 129 | } |
130 | 130 | ||
131 | void MenuSettings::appletChanged() | 131 | void MenuSettings::appletChanged() |
132 | { | 132 | { |
133 | m_applets_changed = true; | 133 | m_applets_changed = true; |
134 | } | 134 | } |
135 | 135 | ||
136 | void MenuSettings::accept ( ) | 136 | void MenuSettings::accept ( ) |
137 | { | 137 | { |
138 | bool apps_changed = false; | 138 | bool apps_changed = false; |
139 | 139 | ||
140 | Config cfg ( "StartMenu" ); | 140 | Config cfg ( "StartMenu" ); |
141 | cfg. setGroup ( "Applets" ); | 141 | cfg. setGroup ( "Applets" ); |
142 | if ( m_applets_changed ) { | 142 | if ( m_applets_changed ) { |
143 | QStringList exclude; | 143 | QStringList exclude; |
144 | QMap <QString, QCheckListItem *>::Iterator it; | 144 | QMap <QString, QCheckListItem *>::Iterator it; |
145 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { | 145 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { |
146 | if ( !(*it)-> isOn ( )) | 146 | if ( !(*it)-> isOn ( )) |
147 | exclude << it. key ( ); | 147 | exclude << it. key ( ); |
148 | } | 148 | } |
149 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); | 149 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); |
150 | } | 150 | } |
151 | cfg. writeEntry ( "SafeMode", false ); | 151 | cfg. writeEntry ( "SafeMode", false ); |
152 | 152 | ||
153 | cfg. setGroup ( "Menu" ); | 153 | cfg. setGroup ( "Menu" ); |
154 | 154 | ||
155 | if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { | 155 | if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { |
156 | apps_changed = true; | 156 | apps_changed = true; |
157 | cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); | 157 | cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); |
158 | } | 158 | } |
159 | 159 | ||
160 | if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) { | 160 | if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) { |
161 | apps_changed = true; | 161 | apps_changed = true; |
162 | cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( )); | 162 | cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( )); |
163 | } | 163 | } |
164 | 164 | ||
165 | cfg. write ( ); | 165 | cfg. write ( ); |
166 | 166 | ||
167 | if ( m_applets_changed ) { | 167 | if ( m_applets_changed ) { |
168 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); | 168 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); |
169 | m_applets_changed = false; | 169 | m_applets_changed = false; |
170 | } | 170 | } |
171 | if ( apps_changed ) { | 171 | if ( apps_changed ) { |
172 | // currently use reloadApplets() since reloadApps is now used exclusive for server | 172 | // currently use reloadApplets() since reloadApps is now used exclusive for server |
173 | // to refresh the tabs. But what we want here is also a refresh of the startmenu entries | 173 | // to refresh the tabs. But what we want here is also a refresh of the startmenu entries |
174 | QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); | 174 | QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); |
175 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); | 175 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp index 8dd9e97..861ff3a 100644 --- a/core/settings/launcher/taskbarsettings.cpp +++ b/core/settings/launcher/taskbarsettings.cpp | |||
@@ -1,176 +1,176 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "taskbarsettings.h" | 29 | #include "taskbarsettings.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/qlibrary.h> | 33 | #include <qpe/qlibrary.h> |
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/taskbarappletinterface.h> | 35 | #include <qpe/taskbarappletinterface.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <opie2/odebug.h> | 37 | #include <opie2/odebug.h> |
38 | 38 | ||
39 | /* QT */ | 39 | /* QT */ |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #include <qheader.h> | 42 | #include <qheader.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qwhatsthis.h> | 45 | #include <qwhatsthis.h> |
46 | 46 | ||
47 | /* STD */ | 47 | /* STD */ |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | 50 | ||
51 | TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) | 51 | TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) |
52 | : QWidget ( parent, name ) | 52 | : QWidget ( parent, name ) |
53 | { | 53 | { |
54 | m_applets_changed = false; | 54 | m_applets_changed = false; |
55 | 55 | ||
56 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); | 56 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); |
57 | 57 | ||
58 | QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); | 58 | QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); |
59 | lay-> addWidget ( l ); | 59 | lay-> addWidget ( l ); |
60 | 60 | ||
61 | m_list = new QListView ( this ); | 61 | m_list = new QListView ( this ); |
62 | m_list-> addColumn ( "foobar" ); | 62 | m_list-> addColumn ( "foobar" ); |
63 | m_list-> header ( )-> hide ( ); | 63 | m_list-> header ( )-> hide ( ); |
64 | 64 | ||
65 | lay-> addWidget ( m_list ); | 65 | lay-> addWidget ( m_list ); |
66 | 66 | ||
67 | QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); | 67 | QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); |
68 | 68 | ||
69 | connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); | 69 | connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); |
70 | 70 | ||
71 | init ( ); | 71 | init ( ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void TaskbarSettings::init ( ) | 74 | void TaskbarSettings::init ( ) |
75 | { | 75 | { |
76 | Config cfg ( "Taskbar" ); | 76 | Config cfg ( "Taskbar" ); |
77 | cfg. setGroup ( "Applets" ); | 77 | cfg. setGroup ( "Applets" ); |
78 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); | 78 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); |
79 | 79 | ||
80 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; | 80 | QString path = QPEApplication::qpeDir ( ) + "plugins/applets"; |
81 | #ifdef Q_OS_MACX | 81 | #ifdef Q_OS_MACX |
82 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); | 82 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); |
83 | #else | 83 | #else |
84 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); | 84 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); |
85 | #endif /* Q_OS_MACX */ | 85 | #endif /* Q_OS_MACX */ |
86 | 86 | ||
87 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { | 87 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { |
88 | QString name; | 88 | QString name; |
89 | QPixmap icon; | 89 | QPixmap icon; |
90 | TaskbarNamedAppletInterface *iface = 0; | 90 | TaskbarNamedAppletInterface *iface = 0; |
91 | 91 | ||
92 | owarn << "Load applet: " << (*it) << "" << oendl; | 92 | owarn << "Load applet: " << (*it) << "" << oendl; |
93 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 93 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
94 | lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); | 94 | lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); |
95 | owarn << "<1>" << oendl; | 95 | owarn << "<1>" << oendl; |
96 | if ( iface ) { | 96 | if ( iface ) { |
97 | owarn << "<2>" << oendl; | 97 | owarn << "<2>" << oendl; |
98 | QString lang = getenv( "LANG" ); | 98 | QString lang = getenv( "LANG" ); |
99 | QTranslator *trans = new QTranslator ( qApp ); | 99 | QTranslator *trans = new QTranslator ( qApp ); |
100 | QString type = (*it). left ((*it). find (".")); | 100 | QString type = (*it). left ((*it). find (".")); |
101 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; | 101 | QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm"; |
102 | if ( trans-> load ( tfn )) | 102 | if ( trans-> load ( tfn )) |
103 | qApp-> installTranslator ( trans ); | 103 | qApp-> installTranslator ( trans ); |
104 | else | 104 | else |
105 | delete trans; | 105 | delete trans; |
106 | name = iface-> name ( ); | 106 | name = iface-> name ( ); |
107 | icon = iface-> icon ( ); | 107 | icon = iface-> icon ( ); |
108 | iface-> release ( ); | 108 | iface-> release ( ); |
109 | } | 109 | } |
110 | owarn << "<3>" << oendl; | 110 | owarn << "<3>" << oendl; |
111 | if ( !iface ) { | 111 | if ( !iface ) { |
112 | owarn << "<4>" << oendl; | 112 | owarn << "<4>" << oendl; |
113 | lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); | 113 | lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); |
114 | 114 | ||
115 | if ( iface ) { | 115 | if ( iface ) { |
116 | owarn << "<5>" << oendl; | 116 | owarn << "<5>" << oendl; |
117 | name = (*it). mid ( 3 ); | 117 | name = (*it). mid ( 3 ); |
118 | owarn << "Found applet: " << name << "" << oendl; | 118 | owarn << "Found applet: " << name << "" << oendl; |
119 | #ifdef Q_OS_MACX | 119 | #ifdef Q_OS_MACX |
120 | int sep = name. find( ".dylib" ); | 120 | int sep = name. find( ".dylib" ); |
121 | #else | 121 | #else |
122 | int sep = name. find( ".so" ); | 122 | int sep = name. find( ".so" ); |
123 | #endif /* Q_OS_MACX */ | 123 | #endif /* Q_OS_MACX */ |
124 | if ( sep > 0 ) | 124 | if ( sep > 0 ) |
125 | name. truncate ( sep ); | 125 | name. truncate ( sep ); |
126 | sep = name. find ( "applet" ); | 126 | sep = name. find ( "applet" ); |
127 | if ( sep == (int) name.length ( ) - 6 ) | 127 | if ( sep == (int) name.length ( ) - 6 ) |
128 | name. truncate ( sep ); | 128 | name. truncate ( sep ); |
129 | name[0] = name[0]. upper ( ); | 129 | name[0] = name[0]. upper ( ); |
130 | iface-> release ( ); | 130 | iface-> release ( ); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | owarn << "<6>" << oendl; | 133 | owarn << "<6>" << oendl; |
134 | 134 | ||
135 | if ( iface ) { | 135 | if ( iface ) { |
136 | owarn << "<7>" << oendl; | 136 | owarn << "<7>" << oendl; |
137 | QCheckListItem *item; | 137 | QCheckListItem *item; |
138 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); | 138 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); |
139 | if ( !icon. isNull ( )) | 139 | if ( !icon. isNull ( )) |
140 | item-> setPixmap ( 0, icon ); | 140 | item-> setPixmap ( 0, icon ); |
141 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); | 141 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); |
142 | m_applets [*it] = item; | 142 | m_applets [*it] = item; |
143 | } | 143 | } |
144 | lib-> unload ( ); | 144 | lib-> unload ( ); |
145 | delete lib; | 145 | delete lib; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | void TaskbarSettings::appletChanged() | 149 | void TaskbarSettings::appletChanged() |
150 | { | 150 | { |
151 | m_applets_changed = true; | 151 | m_applets_changed = true; |
152 | } | 152 | } |
153 | 153 | ||
154 | void TaskbarSettings::accept ( ) | 154 | void TaskbarSettings::accept ( ) |
155 | { | 155 | { |
156 | Config cfg ( "Taskbar" ); | 156 | Config cfg ( "Taskbar" ); |
157 | cfg. setGroup ( "Applets" ); | 157 | cfg. setGroup ( "Applets" ); |
158 | 158 | ||
159 | if ( m_applets_changed ) { | 159 | if ( m_applets_changed ) { |
160 | QStringList exclude; | 160 | QStringList exclude; |
161 | QMap <QString, QCheckListItem *>::Iterator it; | 161 | QMap <QString, QCheckListItem *>::Iterator it; |
162 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { | 162 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { |
163 | if ( !(*it)-> isOn ( )) | 163 | if ( !(*it)-> isOn ( )) |
164 | exclude << it. key ( ); | 164 | exclude << it. key ( ); |
165 | } | 165 | } |
166 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); | 166 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); |
167 | } | 167 | } |
168 | cfg. writeEntry ( "SafeMode", false ); | 168 | cfg. writeEntry ( "SafeMode", false ); |
169 | cfg. write ( ); | 169 | cfg. write ( ); |
170 | 170 | ||
171 | if ( m_applets_changed ) { | 171 | if ( m_applets_changed ) { |
172 | QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); | 172 | QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); |
173 | m_applets_changed = false; | 173 | m_applets_changed = false; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
diff --git a/core/settings/security/multiauthconfig.cpp b/core/settings/security/multiauthconfig.cpp index e545e17..45d691b 100644 --- a/core/settings/security/multiauthconfig.cpp +++ b/core/settings/security/multiauthconfig.cpp | |||
@@ -61,193 +61,193 @@ class ToolButton : public QToolButton { | |||
61 | : QWidget(parent, name), m_onStart(0), m_onResume(0), m_noProtectConfig(0), m_explanScreens(0), m_nbSuccessMin(0), m_tryButton(0) | 61 | : QWidget(parent, name), m_onStart(0), m_onResume(0), m_noProtectConfig(0), m_explanScreens(0), m_nbSuccessMin(0), m_tryButton(0) |
62 | { | 62 | { |
63 | // keep track of the MultiauthConfig parent in one of our attributes | 63 | // keep track of the MultiauthConfig parent in one of our attributes |
64 | m_parentConfig = parentConfig; | 64 | m_parentConfig = parentConfig; |
65 | QVBoxLayout *vb = new QVBoxLayout(this); | 65 | QVBoxLayout *vb = new QVBoxLayout(this); |
66 | vb->setSpacing(11); | 66 | vb->setSpacing(11); |
67 | vb->setMargin(11); | 67 | vb->setMargin(11); |
68 | vb->setAlignment( Qt::AlignTop ); | 68 | vb->setAlignment( Qt::AlignTop ); |
69 | 69 | ||
70 | QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box"); | 70 | QGroupBox *lockBox = new QGroupBox(0, Qt::Vertical, tr("When to lock Opie"), this, "lock box"); |
71 | vb->addWidget(lockBox); | 71 | vb->addWidget(lockBox); |
72 | QGridLayout *boxLayout = new QGridLayout( lockBox->layout() ); | 72 | QGridLayout *boxLayout = new QGridLayout( lockBox->layout() ); |
73 | m_onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start"); | 73 | m_onStart = new QCheckBox( tr( "on Opie start" ), lockBox, "lock on opie start"); |
74 | m_onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume"); | 74 | m_onResume = new QCheckBox( tr( "on Opie resume" ), lockBox, "lock on opie resume"); |
75 | boxLayout->addWidget(m_onStart, 0, 0); | 75 | boxLayout->addWidget(m_onStart, 0, 0); |
76 | boxLayout->addWidget(m_onResume, 0, 1); | 76 | boxLayout->addWidget(m_onResume, 0, 1); |
77 | 77 | ||
78 | QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box"); | 78 | QGroupBox *nbBox = new QGroupBox(0, Qt::Vertical, tr("Multiple plugins authentication"), this, "nb box"); |
79 | vb->addWidget(nbBox); | 79 | vb->addWidget(nbBox); |
80 | QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() ); | 80 | QGridLayout *nbBoxLayout = new QGridLayout( nbBox->layout() ); |
81 | m_nbSuccessMin = new QSpinBox(nbBox); | 81 | m_nbSuccessMin = new QSpinBox(nbBox); |
82 | QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox); | 82 | QLabel *lNbSuccessMin = new QLabel( tr( "Required successes" ), nbBox); |
83 | nbBoxLayout->addWidget(m_nbSuccessMin, 0, 0); | 83 | nbBoxLayout->addWidget(m_nbSuccessMin, 0, 0); |
84 | nbBoxLayout->addWidget(lNbSuccessMin, 0, 1); | 84 | nbBoxLayout->addWidget(lNbSuccessMin, 0, 1); |
85 | m_nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor | 85 | m_nbSuccessMin->setMinValue(1); // the max value is defined in MultiauthConfig constructor |
86 | 86 | ||
87 | QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Options"), this, "dev box"); | 87 | QGroupBox *devBox = new QGroupBox(0, Qt::Vertical, tr("Options"), this, "dev box"); |
88 | vb->addWidget(devBox); | 88 | vb->addWidget(devBox); |
89 | QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() ); | 89 | QGridLayout *devBoxLayout = new QGridLayout( devBox->layout() ); |
90 | m_noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config"); | 90 | m_noProtectConfig = new QCheckBox( tr("Don't protect this config screen"), devBox, "don't protect config"); |
91 | m_explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens"); | 91 | m_explanScreens = new QCheckBox( tr("Show explanatory screens"), devBox, "Show explan. screens"); |
92 | devBoxLayout->addWidget(m_noProtectConfig, 0, 0); | 92 | devBoxLayout->addWidget(m_noProtectConfig, 0, 0); |
93 | devBoxLayout->addWidget(m_explanScreens, 1, 0); | 93 | devBoxLayout->addWidget(m_explanScreens, 1, 0); |
94 | 94 | ||
95 | QVGroupBox *tryBox = new QVGroupBox(tr("Testing"), this, "try box"); | 95 | QVGroupBox *tryBox = new QVGroupBox(tr("Testing"), this, "try box"); |
96 | vb->addWidget(tryBox); | 96 | vb->addWidget(tryBox); |
97 | m_tryButton = new QPushButton( tr("Test the authentication now"), tryBox, "try button"); | 97 | m_tryButton = new QPushButton( tr("Test the authentication now"), tryBox, "try button"); |
98 | connect( m_tryButton, SIGNAL(clicked()), this, SLOT(tryAuth()) ); | 98 | connect( m_tryButton, SIGNAL(clicked()), this, SLOT(tryAuth()) ); |
99 | 99 | ||
100 | } | 100 | } |
101 | 101 | ||
102 | /// nothing to do | 102 | /// nothing to do |
103 | MultiauthGeneralConfig::~MultiauthGeneralConfig() | 103 | MultiauthGeneralConfig::~MultiauthGeneralConfig() |
104 | {} | 104 | {} |
105 | 105 | ||
106 | /// launches the authentication process, as configured, with the option to bypass it | 106 | /// launches the authentication process, as configured, with the option to bypass it |
107 | void MultiauthGeneralConfig::tryAuth() | 107 | void MultiauthGeneralConfig::tryAuth() |
108 | { | 108 | { |
109 | QMessageBox confirmSave( | 109 | QMessageBox confirmSave( |
110 | tr("Attention"), | 110 | tr("Attention"), |
111 | "<p>" + tr("You must save your current settings before trying to authenticate. Press OK to accept and launch a simulated authentication process.") + "</p><p><em>" + | 111 | "<p>" + tr("You must save your current settings before trying to authenticate. Press OK to accept and launch a simulated authentication process.") + "</p><p><em>" + |
112 | tr("If you don't like the result of this test, don't forget to change your settings before you exit the configuration application!") + "</em></p>", | 112 | tr("If you don't like the result of this test, don't forget to change your settings before you exit the configuration application!") + "</em></p>", |
113 | QMessageBox::Warning, | 113 | QMessageBox::Warning, |
114 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, | 114 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, |
115 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 115 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
116 | confirmSave.setButtonText(QMessageBox::Cancel, tr("Cancel")); | 116 | confirmSave.setButtonText(QMessageBox::Cancel, tr("Cancel")); |
117 | confirmSave.setButtonText(QMessageBox::Yes, tr("OK")); | 117 | confirmSave.setButtonText(QMessageBox::Yes, tr("OK")); |
118 | 118 | ||
119 | if ( confirmSave.exec() == QMessageBox::Yes) | 119 | if ( confirmSave.exec() == QMessageBox::Yes) |
120 | { | 120 | { |
121 | owarn << "writing config as user accepted" << oendl; | 121 | owarn << "writing config as user accepted" << oendl; |
122 | m_parentConfig->writeConfigs(); | 122 | m_parentConfig->writeConfigs(); |
123 | owarn << "testing authentication" << oendl; | 123 | owarn << "testing authentication" << oendl; |
124 | // launch the authentication in testing mode | 124 | // launch the authentication in testing mode |
125 | Opie::Security::MultiauthPassword::authenticate(Opie::Security::TestNow); | 125 | Opie::Security::MultiauthPassword::authenticate(Opie::Security::TestNow); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | /// Builds and displays the Opie multi-authentication configuration dialog | 130 | /// Builds and displays the Opie multi-authentication configuration dialog |
131 | static void test_and_start() { | 131 | static void test_and_start() { |
132 | Config pcfg("Security"); | 132 | Config pcfg("Security"); |
133 | pcfg.setGroup( "Misc" ); | 133 | pcfg.setGroup( "Misc" ); |
134 | bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true); | 134 | bool protectConfigDialog = ! pcfg.readBoolEntry("noProtectConfig", true); |
135 | 135 | ||
136 | if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) { | 136 | if (protectConfigDialog && Opie::Security::Internal::runPlugins() != 0) { |
137 | owarn << "authentication failed, not showing opie-security" << oendl; | 137 | owarn << "authentication failed, not showing opie-security" << oendl; |
138 | exit( -1 ); | 138 | exit( -1 ); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | 143 | ||
144 | MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0) | 144 | MultiauthConfig::MultiauthConfig(QWidget* par, const char* w = "MultiauthConfig dialog", WFlags f = 0) |
145 | : QDialog(par, w, TRUE, f), | 145 | : QDialog(par, w, TRUE, f), |
146 | m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0), | 146 | m_mainTW(0), m_pluginListView(0), m_pluginListWidget(0), |
147 | m_generalConfig(0), m_loginWidget(0), m_syncWidget(0), | 147 | m_generalConfig(0), m_loginWidget(0), m_syncWidget(0), |
148 | m_nbSuccessReq(0), m_plugins_changed(false) | 148 | m_nbSuccessReq(0), m_plugins_changed(false) |
149 | { | 149 | { |
150 | /* Initializes the global configuration window | 150 | /* Initializes the global configuration window |
151 | */ | 151 | */ |
152 | test_and_start(); | 152 | test_and_start(); |
153 | 153 | ||
154 | /* Checks (and memorizes) if any authentication plugins are | 154 | /* Checks (and memorizes) if any authentication plugins are |
155 | * installed on the system | 155 | * installed on the system |
156 | */ | 156 | */ |
157 | QString path = QPEApplication::qpeDir() + "/plugins/security"; | 157 | QString path = QPEApplication::qpeDir() + "plugins/security"; |
158 | QDir dir( path, "lib*.so" ); | 158 | QDir dir( path, "lib*.so" ); |
159 | QStringList list = dir.entryList(); | 159 | QStringList list = dir.entryList(); |
160 | 160 | ||
161 | m_pluginsInstalled = ! list.isEmpty(); | 161 | m_pluginsInstalled = ! list.isEmpty(); |
162 | if (m_pluginsInstalled == false) | 162 | if (m_pluginsInstalled == false) |
163 | owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl; | 163 | owarn << "no authentication plugins installed! Talking about it in the last tab..." << oendl; |
164 | 164 | ||
165 | setCaption( tr( "Security configuration" ) ); | 165 | setCaption( tr( "Security configuration" ) ); |
166 | QVBoxLayout *layout = new QVBoxLayout( this ); | 166 | QVBoxLayout *layout = new QVBoxLayout( this ); |
167 | m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" ); | 167 | m_mainTW = new Opie::Ui::OTabWidget( this, "main tab widget" ); |
168 | layout->addWidget(m_mainTW); | 168 | layout->addWidget(m_mainTW); |
169 | 169 | ||
170 | if (m_pluginsInstalled) | 170 | if (m_pluginsInstalled) |
171 | { | 171 | { |
172 | m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget"); | 172 | m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget"); |
173 | QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); | 173 | QVBoxLayout * pluginListLayout = new QVBoxLayout(m_pluginListWidget); |
174 | pluginListLayout->setSpacing(6); | 174 | pluginListLayout->setSpacing(6); |
175 | pluginListLayout->setMargin(11); | 175 | pluginListLayout->setMargin(11); |
176 | QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget ); | 176 | QLabel * pluginListTitle = new QLabel( tr( "Load which plugins in what order:" ), m_pluginListWidget ); |
177 | pluginListLayout->addWidget(pluginListTitle); | 177 | pluginListLayout->addWidget(pluginListTitle); |
178 | QHBox * pluginListHB = new QHBox(m_pluginListWidget); | 178 | QHBox * pluginListHB = new QHBox(m_pluginListWidget); |
179 | pluginListLayout->addWidget(pluginListHB); | 179 | pluginListLayout->addWidget(pluginListHB); |
180 | 180 | ||
181 | m_pluginListView = new QListView(pluginListHB); | 181 | m_pluginListView = new QListView(pluginListHB); |
182 | m_pluginListView->addColumn("PluginList"); | 182 | m_pluginListView->addColumn("PluginList"); |
183 | m_pluginListView->header()->hide(); | 183 | m_pluginListView->header()->hide(); |
184 | m_pluginListView->setSorting(-1); | 184 | m_pluginListView->setSorting(-1); |
185 | QWhatsThis::add(m_pluginListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the order they will appear in" )); | 185 | QWhatsThis::add(m_pluginListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the order they will appear in" )); |
186 | 186 | ||
187 | QVBox * pluginListVB = new QVBox(pluginListHB); | 187 | QVBox * pluginListVB = new QVBox(pluginListHB); |
188 | new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); | 188 | new ToolButton( pluginListVB, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); |
189 | new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); | 189 | new ToolButton( pluginListVB, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); |
190 | m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) ); | 190 | m_mainTW->addTab( m_pluginListWidget, "pass", tr( "plugins" ) ); |
191 | 191 | ||
192 | connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) ); | 192 | connect ( m_pluginListView , SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( pluginsChanged ( ) ) ); |
193 | 193 | ||
194 | // general Opie multi-authentication configuration tab | 194 | // general Opie multi-authentication configuration tab |
195 | m_generalConfig = new MultiauthGeneralConfig(this, m_mainTW); | 195 | m_generalConfig = new MultiauthGeneralConfig(this, m_mainTW); |
196 | m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") ); | 196 | m_mainTW->addTab(m_generalConfig, "SettingsIcon", tr( "Authentication") ); |
197 | 197 | ||
198 | } | 198 | } |
199 | // login settings page | 199 | // login settings page |
200 | m_loginWidget = new LoginBase(m_mainTW, "login config widget"); | 200 | m_loginWidget = new LoginBase(m_mainTW, "login config widget"); |
201 | m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") ); | 201 | m_mainTW->addTab(m_loginWidget, "security/users", tr( "Login") ); |
202 | 202 | ||
203 | // sync settings page | 203 | // sync settings page |
204 | m_syncWidget = new SyncBase( m_mainTW, "sync config widget" ); | 204 | m_syncWidget = new SyncBase( m_mainTW, "sync config widget" ); |
205 | m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") ); | 205 | m_mainTW->addTab(m_syncWidget, "security/sync", tr( "Sync") ); |
206 | 206 | ||
207 | // read the "Security" Config file and update our UI | 207 | // read the "Security" Config file and update our UI |
208 | readConfig(); | 208 | readConfig(); |
209 | 209 | ||
210 | 210 | ||
211 | if (m_pluginsInstalled) | 211 | if (m_pluginsInstalled) |
212 | { | 212 | { |
213 | /* loads plugins configuration widgets in mainTW tabs and in pluginListView | 213 | /* loads plugins configuration widgets in mainTW tabs and in pluginListView |
214 | */ | 214 | */ |
215 | 215 | ||
216 | loadPlugins(); | 216 | loadPlugins(); |
217 | 217 | ||
218 | for ( int i = pluginList.count() - 1; i >= 0; i-- ) { | 218 | for ( int i = pluginList.count() - 1; i >= 0; i-- ) { |
219 | MultiauthPlugin plugin = pluginList[i]; | 219 | MultiauthPlugin plugin = pluginList[i]; |
220 | 220 | ||
221 | // load the config widgets in the tabs | 221 | // load the config widgets in the tabs |
222 | // (configWidget will return 0l if there is no configuration GUI) | 222 | // (configWidget will return 0l if there is no configuration GUI) |
223 | MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW); | 223 | MultiauthConfigWidget* widget = plugin.pluginObject->configWidget(m_mainTW); |
224 | if ( widget != 0l ) { | 224 | if ( widget != 0l ) { |
225 | odebug << "plugin " << plugin.name << " has a configuration widget" << oendl; | 225 | odebug << "plugin " << plugin.name << " has a configuration widget" << oendl; |
226 | configWidgetList.append(widget); | 226 | configWidgetList.append(widget); |
227 | m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(), | 227 | m_mainTW->addTab( widget, plugin.pluginObject->pixmapNameConfig(), |
228 | plugin.pluginObject->pluginName() ); | 228 | plugin.pluginObject->pluginName() ); |
229 | } | 229 | } |
230 | // set the order/activate tab | 230 | // set the order/activate tab |
231 | QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() ); | 231 | QPixmap icon = Resource::loadPixmap( plugin.pluginObject->pixmapNameWidget() ); |
232 | QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); | 232 | QCheckListItem * item = new QCheckListItem(m_pluginListView, plugin.pluginObject->pluginName(), QCheckListItem::CheckBox ); |
233 | if ( !icon.isNull() ) { | 233 | if ( !icon.isNull() ) { |
234 | item->setPixmap( 0, icon ); | 234 | item->setPixmap( 0, icon ); |
235 | } | 235 | } |
236 | if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { | 236 | if ( m_excludePlugins.find( plugin.name ) == m_excludePlugins.end() ) { |
237 | item->setOn( TRUE ); | 237 | item->setOn( TRUE ); |
238 | } | 238 | } |
239 | m_plugins[plugin.name] = item; | 239 | m_plugins[plugin.name] = item; |
240 | } | 240 | } |
241 | 241 | ||
242 | // set the first tab as default. | 242 | // set the first tab as default. |
243 | m_mainTW->setCurrentTab(m_pluginListWidget); | 243 | m_mainTW->setCurrentTab(m_pluginListWidget); |
244 | 244 | ||
245 | // put the number of plugins as the max number of req. auth. | 245 | // put the number of plugins as the max number of req. auth. |
246 | m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() ); | 246 | m_generalConfig->m_nbSuccessMin->setMaxValue( pluginList.count() ); |
247 | } | 247 | } |
248 | else | 248 | else |
249 | { | 249 | { |
250 | /* we don't have any installed plugin there. Let's tell | 250 | /* we don't have any installed plugin there. Let's tell |
251 | * that to the user in a third tab, using the m_pluginListWidget widget | 251 | * that to the user in a third tab, using the m_pluginListWidget widget |
252 | */ | 252 | */ |
253 | m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); | 253 | m_pluginListWidget = new QWidget(m_mainTW, "plugin list widget (no plugins warning)"); |
@@ -281,328 +281,328 @@ void MultiauthConfig::writeConfigs() { | |||
281 | for ( confWidget = configWidgetList.first(); confWidget != 0; | 281 | for ( confWidget = configWidgetList.first(); confWidget != 0; |
282 | confWidget = configWidgetList.next() ) | 282 | confWidget = configWidgetList.next() ) |
283 | confWidget->writeConfig(); | 283 | confWidget->writeConfig(); |
284 | } | 284 | } |
285 | 285 | ||
286 | /// on QDialog::accept, we save all the configurations and exit the QDialog normally | 286 | /// on QDialog::accept, we save all the configurations and exit the QDialog normally |
287 | void MultiauthConfig::accept() { | 287 | void MultiauthConfig::accept() { |
288 | writeConfigs(); | 288 | writeConfigs(); |
289 | QDialog::accept(); | 289 | QDialog::accept(); |
290 | } | 290 | } |
291 | 291 | ||
292 | void MultiauthConfig::done( int r ) { | 292 | void MultiauthConfig::done( int r ) { |
293 | QDialog::done( r ); | 293 | QDialog::done( r ); |
294 | close(); | 294 | close(); |
295 | } | 295 | } |
296 | 296 | ||
297 | /// moves up the selected plugin | 297 | /// moves up the selected plugin |
298 | void MultiauthConfig::moveSelectedUp() | 298 | void MultiauthConfig::moveSelectedUp() |
299 | { | 299 | { |
300 | QListViewItem *item = m_pluginListView->selectedItem(); | 300 | QListViewItem *item = m_pluginListView->selectedItem(); |
301 | if ( item && item->itemAbove() ) { | 301 | if ( item && item->itemAbove() ) { |
302 | item->itemAbove()->moveItem( item ); | 302 | item->itemAbove()->moveItem( item ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | /// moves down the selected plugin | 306 | /// moves down the selected plugin |
307 | void MultiauthConfig::moveSelectedDown() | 307 | void MultiauthConfig::moveSelectedDown() |
308 | { | 308 | { |
309 | QListViewItem *item = m_pluginListView->selectedItem(); | 309 | QListViewItem *item = m_pluginListView->selectedItem(); |
310 | if ( item && item->itemBelow() ) { | 310 | if ( item && item->itemBelow() ) { |
311 | item->moveItem( item->itemBelow() ); | 311 | item->moveItem( item->itemBelow() ); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | /// reads the <code>Security.conf</code> Config file, and updates parts of the user interface | 315 | /// reads the <code>Security.conf</code> Config file, and updates parts of the user interface |
316 | void MultiauthConfig::readConfig() | 316 | void MultiauthConfig::readConfig() |
317 | { | 317 | { |
318 | // pointer, so we release this Config when we want | 318 | // pointer, so we release this Config when we want |
319 | Config* pcfg = new Config("Security"); | 319 | Config* pcfg = new Config("Security"); |
320 | 320 | ||
321 | if (m_pluginsInstalled) | 321 | if (m_pluginsInstalled) |
322 | { | 322 | { |
323 | pcfg->setGroup( "Misc" ); | 323 | pcfg->setGroup( "Misc" ); |
324 | m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); | 324 | m_generalConfig->m_onStart->setChecked( pcfg->readBoolEntry( "onStart", false ) ); |
325 | m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); | 325 | m_generalConfig->m_onResume->setChecked( pcfg->readBoolEntry( "onResume", false ) ); |
326 | m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); | 326 | m_generalConfig->m_nbSuccessMin->setValue( pcfg->readNumEntry( "nbSuccessMin", 1 ) ); |
327 | m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); | 327 | m_generalConfig->m_noProtectConfig->setChecked( pcfg->readBoolEntry( "noProtectConfig", true) ); |
328 | m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); | 328 | m_generalConfig->m_explanScreens->setChecked( pcfg->readBoolEntry( "explanScreens", true ) ); |
329 | 329 | ||
330 | pcfg->setGroup( "Plugins" ); | 330 | pcfg->setGroup( "Plugins" ); |
331 | m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); | 331 | m_excludePlugins = pcfg->readListEntry( "ExcludePlugins", ',' ); |
332 | m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); | 332 | m_allPlugins = pcfg->readListEntry( "AllPlugins", ',' ); |
333 | } | 333 | } |
334 | 334 | ||
335 | /* Login and Sync stuff */ | 335 | /* Login and Sync stuff */ |
336 | pcfg->setGroup("Sync"); | 336 | pcfg->setGroup("Sync"); |
337 | int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 | 337 | int auth_peer = pcfg->readNumEntry("auth_peer",0xc0a88100);//new default 192.168.129.0/24 |
338 | int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24); | 338 | int auth_peer_bits = pcfg->readNumEntry("auth_peer_bits",24); |
339 | 339 | ||
340 | pcfg->setGroup("SyncMode"); | 340 | pcfg->setGroup("SyncMode"); |
341 | int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp | 341 | int mode = pcfg->readNumEntry("Mode",2); // Default to Sharp |
342 | switch( mode ) { | 342 | switch( mode ) { |
343 | case 0x01: | 343 | case 0x01: |
344 | m_syncWidget->syncModeCombo->setCurrentItem( 0 ); | 344 | m_syncWidget->syncModeCombo->setCurrentItem( 0 ); |
345 | break; | 345 | break; |
346 | case 0x02: | 346 | case 0x02: |
347 | default: | 347 | default: |
348 | m_syncWidget->syncModeCombo->setCurrentItem( 1 ); | 348 | m_syncWidget->syncModeCombo->setCurrentItem( 1 ); |
349 | break; | 349 | break; |
350 | case 0x04: | 350 | case 0x04: |
351 | m_syncWidget->syncModeCombo->setCurrentItem( 2 ); | 351 | m_syncWidget->syncModeCombo->setCurrentItem( 2 ); |
352 | break; | 352 | break; |
353 | } | 353 | } |
354 | /* | 354 | /* |
355 | cfg.setGroup("Remote"); | 355 | cfg.setGroup("Remote"); |
356 | if ( telnetAvailable() ) | 356 | if ( telnetAvailable() ) |
357 | telnet->setChecked(cfg.readEntry("allow_telnet")); | 357 | telnet->setChecked(cfg.readEntry("allow_telnet")); |
358 | else | 358 | else |
359 | telnet->hide(); | 359 | telnet->hide(); |
360 | 360 | ||
361 | if ( sshAvailable() ) | 361 | if ( sshAvailable() ) |
362 | ssh->setChecked(cfg.readEntry("allow_ssh")); | 362 | ssh->setChecked(cfg.readEntry("allow_ssh")); |
363 | else | 363 | else |
364 | ssh->hide(); | 364 | ssh->hide(); |
365 | */ | 365 | */ |
366 | 366 | ||
367 | // release the Config handler | 367 | // release the Config handler |
368 | delete pcfg; | 368 | delete pcfg; |
369 | // indeed, selectNet will open the config file... | 369 | // indeed, selectNet will open the config file... |
370 | selectNet(auth_peer,auth_peer_bits,TRUE); | 370 | selectNet(auth_peer,auth_peer_bits,TRUE); |
371 | 371 | ||
372 | connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), | 372 | connect( m_syncWidget->syncnet, SIGNAL(textChanged(const QString&)), |
373 | this, SLOT(setSyncNet(const QString&))); | 373 | this, SLOT(setSyncNet(const QString&))); |
374 | 374 | ||
375 | 375 | ||
376 | 376 | ||
377 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 377 | QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; |
378 | Config loginCfg(configFile,Config::File); | 378 | Config loginCfg(configFile,Config::File); |
379 | 379 | ||
380 | loginCfg.setGroup("General"); | 380 | loginCfg.setGroup("General"); |
381 | autoLoginName=loginCfg.readEntry("AutoLogin",""); | 381 | autoLoginName=loginCfg.readEntry("AutoLogin",""); |
382 | 382 | ||
383 | if (autoLoginName.stripWhiteSpace().isEmpty()) { | 383 | if (autoLoginName.stripWhiteSpace().isEmpty()) { |
384 | autoLogin=false; | 384 | autoLogin=false; |
385 | } else { | 385 | } else { |
386 | autoLogin=true; | 386 | autoLogin=true; |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); | 390 | connect(m_loginWidget->autologinToggle, SIGNAL(toggled(bool)), this, SLOT(toggleAutoLogin(bool))); |
391 | connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); | 391 | connect(m_loginWidget->userlist, SIGNAL(activated(int)), this, SLOT(changeLoginName(int))); |
392 | connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); | 392 | connect(m_syncWidget->restoredefaults,SIGNAL(clicked()), this, SLOT(restoreDefaults())); |
393 | connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); | 393 | connect(m_syncWidget->deleteentry,SIGNAL(clicked()), this, SLOT(deleteListEntry())); |
394 | 394 | ||
395 | loadUsers(); | 395 | loadUsers(); |
396 | updateGUI(); | 396 | updateGUI(); |
397 | 397 | ||
398 | } | 398 | } |
399 | 399 | ||
400 | void MultiauthConfig::writeConfig() | 400 | void MultiauthConfig::writeConfig() |
401 | { | 401 | { |
402 | Config* pcfg = new Config("Security"); | 402 | Config* pcfg = new Config("Security"); |
403 | 403 | ||
404 | if (m_pluginsInstalled) | 404 | if (m_pluginsInstalled) |
405 | { | 405 | { |
406 | pcfg->setGroup( "Plugins" ); | 406 | pcfg->setGroup( "Plugins" ); |
407 | QStringList exclude; | 407 | QStringList exclude; |
408 | QStringList include; | 408 | QStringList include; |
409 | QStringList allPlugins; | 409 | QStringList allPlugins; |
410 | 410 | ||
411 | QListViewItemIterator list_it( m_pluginListView ); | 411 | QListViewItemIterator list_it( m_pluginListView ); |
412 | 412 | ||
413 | // this makes sure the names get saved in the order selected | 413 | // this makes sure the names get saved in the order selected |
414 | for ( ; list_it.current(); ++list_it ) { | 414 | for ( ; list_it.current(); ++list_it ) { |
415 | QMap <QString, QCheckListItem *>::Iterator it; | 415 | QMap <QString, QCheckListItem *>::Iterator it; |
416 | for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { | 416 | for ( it = m_plugins.begin(); it != m_plugins. end (); ++it ) { |
417 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { | 417 | if ( list_it.current() == (*it) && !(*it)-> isOn () ) { |
418 | exclude << it.key(); | 418 | exclude << it.key(); |
419 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ | 419 | } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ |
420 | include << it.key(); | 420 | include << it.key(); |
421 | } | 421 | } |
422 | if ( list_it.current() == (*it) ) { | 422 | if ( list_it.current() == (*it) ) { |
423 | allPlugins << it.key(); | 423 | allPlugins << it.key(); |
424 | } | 424 | } |
425 | } | 425 | } |
426 | } | 426 | } |
427 | pcfg->writeEntry( "ExcludePlugins", exclude, ',' ); | 427 | pcfg->writeEntry( "ExcludePlugins", exclude, ',' ); |
428 | pcfg->writeEntry( "IncludePlugins", include, ',' ); | 428 | pcfg->writeEntry( "IncludePlugins", include, ',' ); |
429 | pcfg->writeEntry( "AllPlugins", allPlugins, ',' ); | 429 | pcfg->writeEntry( "AllPlugins", allPlugins, ',' ); |
430 | 430 | ||
431 | pcfg->setGroup( "Misc" ); | 431 | pcfg->setGroup( "Misc" ); |
432 | pcfg->writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); | 432 | pcfg->writeEntry( "onStart", m_generalConfig->m_onStart->isChecked() ); |
433 | pcfg->writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); | 433 | pcfg->writeEntry( "onResume", m_generalConfig->m_onResume->isChecked() ); |
434 | pcfg->writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); | 434 | pcfg->writeEntry( "nbSuccessMin", m_generalConfig->m_nbSuccessMin->text() ); |
435 | pcfg->writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); | 435 | pcfg->writeEntry( "noProtectConfig", m_generalConfig->m_noProtectConfig->isChecked() ); |
436 | pcfg->writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); | 436 | pcfg->writeEntry( "explanScreens", m_generalConfig->m_explanScreens->isChecked() ); |
437 | } | 437 | } |
438 | 438 | ||
439 | /* Login and Sync stuff */ | 439 | /* Login and Sync stuff */ |
440 | 440 | ||
441 | pcfg->setGroup("Sync"); | 441 | pcfg->setGroup("Sync"); |
442 | int auth_peer=0; | 442 | int auth_peer=0; |
443 | int auth_peer_bits; | 443 | int auth_peer_bits; |
444 | QString sn = m_syncWidget->syncnet->currentText(); | 444 | QString sn = m_syncWidget->syncnet->currentText(); |
445 | parseNet(sn,auth_peer,auth_peer_bits); | 445 | parseNet(sn,auth_peer,auth_peer_bits); |
446 | 446 | ||
447 | //this is the *selected* (active) net range | 447 | //this is the *selected* (active) net range |
448 | pcfg->writeEntry("auth_peer",auth_peer); | 448 | pcfg->writeEntry("auth_peer",auth_peer); |
449 | pcfg->writeEntry("auth_peer_bits",auth_peer_bits); | 449 | pcfg->writeEntry("auth_peer_bits",auth_peer_bits); |
450 | 450 | ||
451 | //write back all other net ranges in *cleartext* | 451 | //write back all other net ranges in *cleartext* |
452 | for (int i=0; i<10; i++) { | 452 | for (int i=0; i<10; i++) { |
453 | QString target; | 453 | QString target; |
454 | target.sprintf("net%d", i); | 454 | target.sprintf("net%d", i); |
455 | if ( i < m_syncWidget->syncnet->count() ) | 455 | if ( i < m_syncWidget->syncnet->count() ) |
456 | pcfg->writeEntry(target, m_syncWidget->syncnet->text(i)); | 456 | pcfg->writeEntry(target, m_syncWidget->syncnet->text(i)); |
457 | else // no more entry in the syncnet list -> we clear the line | 457 | else // no more entry in the syncnet list -> we clear the line |
458 | pcfg->writeEntry(target, ""); | 458 | pcfg->writeEntry(target, ""); |
459 | } | 459 | } |
460 | 460 | ||
461 | #ifdef ODP | 461 | #ifdef ODP |
462 | #error "Use 0,1,2 and use Launcher" | 462 | #error "Use 0,1,2 and use Launcher" |
463 | #endif | 463 | #endif |
464 | /* keep the old code so we don't use currentItem directly */ | 464 | /* keep the old code so we don't use currentItem directly */ |
465 | int value = 0x02; | 465 | int value = 0x02; |
466 | switch( m_syncWidget->syncModeCombo->currentItem() ) { | 466 | switch( m_syncWidget->syncModeCombo->currentItem() ) { |
467 | case 0: | 467 | case 0: |
468 | value = 0x01; | 468 | value = 0x01; |
469 | break; | 469 | break; |
470 | case 1: | 470 | case 1: |
471 | value = 0x02; | 471 | value = 0x02; |
472 | break; | 472 | break; |
473 | case 2: | 473 | case 2: |
474 | value = 0x04; | 474 | value = 0x04; |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | pcfg->setGroup("SyncMode"); | 477 | pcfg->setGroup("SyncMode"); |
478 | pcfg->writeEntry( "Mode", value ); | 478 | pcfg->writeEntry( "Mode", value ); |
479 | 479 | ||
480 | /* | 480 | /* |
481 | pcfg->setGroup("Remote"); | 481 | pcfg->setGroup("Remote"); |
482 | if ( telnetAvailable() ) | 482 | if ( telnetAvailable() ) |
483 | pcfg->writeEntry("allow_telnet",telnet->isChecked()); | 483 | pcfg->writeEntry("allow_telnet",telnet->isChecked()); |
484 | if ( sshAvailable() ) | 484 | if ( sshAvailable() ) |
485 | pcfg->writeEntry("allow_ssh",ssh->isChecked()); | 485 | pcfg->writeEntry("allow_ssh",ssh->isChecked()); |
486 | // ### write ssh/telnet sys config files | 486 | // ### write ssh/telnet sys config files |
487 | */ | 487 | */ |
488 | 488 | ||
489 | //release the Config handler | 489 | //release the Config handler |
490 | delete pcfg; | 490 | delete pcfg; |
491 | 491 | ||
492 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 492 | QString configFile = QPEApplication::qpeDir() + "etc/opie-login.conf"; |
493 | Config loginCfg(configFile,Config::File); | 493 | Config loginCfg(configFile,Config::File); |
494 | loginCfg.setGroup("General"); | 494 | loginCfg.setGroup("General"); |
495 | 495 | ||
496 | if (autoLogin) { | 496 | if (autoLogin) { |
497 | loginCfg.writeEntry("AutoLogin",autoLoginName); | 497 | loginCfg.writeEntry("AutoLogin",autoLoginName); |
498 | } else { | 498 | } else { |
499 | loginCfg.removeEntry("AutoLogin"); | 499 | loginCfg.removeEntry("AutoLogin"); |
500 | } | 500 | } |
501 | 501 | ||
502 | } | 502 | } |
503 | 503 | ||
504 | /// slot used to record the fact plugins order has been modified | 504 | /// slot used to record the fact plugins order has been modified |
505 | void MultiauthConfig::pluginsChanged() { | 505 | void MultiauthConfig::pluginsChanged() { |
506 | m_plugins_changed = true; | 506 | m_plugins_changed = true; |
507 | } | 507 | } |
508 | 508 | ||
509 | /// loads each multiauth plugin | 509 | /// loads each multiauth plugin |
510 | void MultiauthConfig::loadPlugins() { | 510 | void MultiauthConfig::loadPlugins() { |
511 | 511 | ||
512 | QString path = QPEApplication::qpeDir() + "/plugins/security"; | 512 | QString path = QPEApplication::qpeDir() + "plugins/security"; |
513 | QDir dir( path, "lib*.so" ); | 513 | QDir dir( path, "lib*.so" ); |
514 | 514 | ||
515 | QStringList list = dir.entryList(); | 515 | QStringList list = dir.entryList(); |
516 | QStringList::Iterator it; | 516 | QStringList::Iterator it; |
517 | 517 | ||
518 | // temporary list used to sort plugins | 518 | // temporary list used to sort plugins |
519 | QMap<QString, MultiauthPlugin> sortList; | 519 | QMap<QString, MultiauthPlugin> sortList; |
520 | 520 | ||
521 | for ( it = list.begin(); it != list.end(); ++it ) { | 521 | for ( it = list.begin(); it != list.end(); ++it ) { |
522 | QInterfacePtr<MultiauthPluginInterface> iface; | 522 | QInterfacePtr<MultiauthPluginInterface> iface; |
523 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 523 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
524 | QString libPath(path + "/" + *it); | 524 | QString libPath(path + "/" + *it); |
525 | 525 | ||
526 | if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 526 | if ( lib->queryInterface( IID_MultiauthPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
527 | MultiauthPlugin plugin; | 527 | MultiauthPlugin plugin; |
528 | plugin.library = lib; | 528 | plugin.library = lib; |
529 | plugin.iface = iface; | 529 | plugin.iface = iface; |
530 | plugin.name = QString(*it); | 530 | plugin.name = QString(*it); |
531 | 531 | ||
532 | // find out if plugins should be launched | 532 | // find out if plugins should be launched |
533 | if ( m_excludePlugins.grep( *it ).isEmpty() ) { | 533 | if ( m_excludePlugins.grep( *it ).isEmpty() ) { |
534 | plugin.active = true; | 534 | plugin.active = true; |
535 | } else { | 535 | } else { |
536 | plugin.active = false; | 536 | plugin.active = false; |
537 | } | 537 | } |
538 | 538 | ||
539 | plugin.pluginObject = plugin.iface->plugin(); | 539 | plugin.pluginObject = plugin.iface->plugin(); |
540 | 540 | ||
541 | // "prebuffer" it in one more list, to get the sorting done | 541 | // "prebuffer" it in one more list, to get the sorting done |
542 | sortList.insert( plugin.name, plugin ); | 542 | sortList.insert( plugin.name, plugin ); |
543 | 543 | ||
544 | // on first start the list is off course empty | 544 | // on first start the list is off course empty |
545 | if ( m_allPlugins.isEmpty() ) { | 545 | if ( m_allPlugins.isEmpty() ) { |
546 | pluginList.append( plugin ); | 546 | pluginList.append( plugin ); |
547 | } | 547 | } |
548 | // if plugin is not yet in the list, add it to the layout too | 548 | // if plugin is not yet in the list, add it to the layout too |
549 | else if ( !m_allPlugins.contains( plugin.name ) ) { | 549 | else if ( !m_allPlugins.contains( plugin.name ) ) { |
550 | pluginList.append( plugin ); | 550 | pluginList.append( plugin ); |
551 | } | 551 | } |
552 | 552 | ||
553 | } else { | 553 | } else { |
554 | delete lib; | 554 | delete lib; |
555 | } | 555 | } |
556 | 556 | ||
557 | } // end for | 557 | } // end for |
558 | 558 | ||
559 | // put m_allPlugins tempPlugin objects into pluginList | 559 | // put m_allPlugins tempPlugin objects into pluginList |
560 | if ( !m_allPlugins.isEmpty() ) { | 560 | if ( !m_allPlugins.isEmpty() ) { |
561 | MultiauthPlugin tempPlugin; | 561 | MultiauthPlugin tempPlugin; |
562 | QStringList::Iterator stringit; | 562 | QStringList::Iterator stringit; |
563 | for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) { | 563 | for( stringit = m_allPlugins.begin(); stringit != m_allPlugins.end(); ++stringit ) { |
564 | tempPlugin = ( sortList.find( *stringit ) ).data(); | 564 | tempPlugin = ( sortList.find( *stringit ) ).data(); |
565 | if ( !( (tempPlugin.name).isEmpty() ) ) { | 565 | if ( !( (tempPlugin.name).isEmpty() ) ) { |
566 | pluginList.append( tempPlugin ); | 566 | pluginList.append( tempPlugin ); |
567 | } | 567 | } |
568 | } | 568 | } |
569 | } | 569 | } |
570 | 570 | ||
571 | } | 571 | } |
572 | 572 | ||
573 | void MultiauthConfig::deleteListEntry() | 573 | void MultiauthConfig::deleteListEntry() |
574 | { | 574 | { |
575 | m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem()); | 575 | m_syncWidget->syncnet->removeItem(m_syncWidget->syncnet->currentItem()); |
576 | } | 576 | } |
577 | 577 | ||
578 | void MultiauthConfig::restoreDefaults() | 578 | void MultiauthConfig::restoreDefaults() |
579 | { | 579 | { |
580 | QMessageBox unrecbox( | 580 | QMessageBox unrecbox( |
581 | tr("Attention"), | 581 | tr("Attention"), |
582 | "<p>" + tr("All user-defined net ranges will be lost.") + "</p>", | 582 | "<p>" + tr("All user-defined net ranges will be lost.") + "</p>", |
583 | QMessageBox::Warning, | 583 | QMessageBox::Warning, |
584 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, | 584 | QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, |
585 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 585 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
586 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); | 586 | unrecbox.setButtonText(QMessageBox::Cancel, tr("Cancel")); |
587 | unrecbox.setButtonText(QMessageBox::Yes, tr("OK")); | 587 | unrecbox.setButtonText(QMessageBox::Yes, tr("OK")); |
588 | 588 | ||
589 | if ( unrecbox.exec() == QMessageBox::Yes) | 589 | if ( unrecbox.exec() == QMessageBox::Yes) |
590 | { | 590 | { |
591 | m_syncWidget->syncnet->clear(); | 591 | m_syncWidget->syncnet->clear(); |
592 | insertDefaultRanges(); | 592 | insertDefaultRanges(); |
593 | } | 593 | } |
594 | m_syncWidget->syncModeCombo->setCurrentItem( 2 ); | 594 | m_syncWidget->syncModeCombo->setCurrentItem( 2 ); |
595 | } | 595 | } |
596 | 596 | ||
597 | void MultiauthConfig::insertDefaultRanges() | 597 | void MultiauthConfig::insertDefaultRanges() |
598 | { | 598 | { |
599 | m_syncWidget->syncnet->insertItem( "192.168.129.0/24" ); | 599 | m_syncWidget->syncnet->insertItem( "192.168.129.0/24" ); |
600 | m_syncWidget->syncnet->insertItem( "192.168.1.0/24" ); | 600 | m_syncWidget->syncnet->insertItem( "192.168.1.0/24" ); |
601 | m_syncWidget->syncnet->insertItem( "192.168.0.0/16" ); | 601 | m_syncWidget->syncnet->insertItem( "192.168.0.0/16" ); |
602 | m_syncWidget->syncnet->insertItem( "172.16.0.0/12" ); | 602 | m_syncWidget->syncnet->insertItem( "172.16.0.0/12" ); |
603 | m_syncWidget->syncnet->insertItem( "10.0.0.0/8" ); | 603 | m_syncWidget->syncnet->insertItem( "10.0.0.0/8" ); |
604 | m_syncWidget->syncnet->insertItem( "1.0.0.0/8" ); | 604 | m_syncWidget->syncnet->insertItem( "1.0.0.0/8" ); |
605 | m_syncWidget->syncnet->insertItem( tr( "Any" ) ); | 605 | m_syncWidget->syncnet->insertItem( tr( "Any" ) ); |
606 | m_syncWidget->syncnet->insertItem( tr( "None" ) ); | 606 | m_syncWidget->syncnet->insertItem( tr( "None" ) ); |
607 | } | 607 | } |
608 | 608 | ||
diff --git a/core/tools/quicklauncher/dropins.h b/core/tools/quicklauncher/dropins.h index a9664f8..df364ce 100644 --- a/core/tools/quicklauncher/dropins.h +++ b/core/tools/quicklauncher/dropins.h | |||
@@ -1,71 +1,71 @@ | |||
1 | /* OPIE */ | 1 | /* OPIE */ |
2 | #include <opie2/owait.h> | 2 | #include <opie2/owait.h> |
3 | using namespace Opie::Ui; | 3 | using namespace Opie::Ui; |
4 | 4 | ||
5 | #include <qtopia/qcom.h> | 5 | #include <qtopia/qcom.h> |
6 | #include <qtopia/qlibrary.h> | 6 | #include <qtopia/qlibrary.h> |
7 | #include <qtopia/qpeapplication.h> | 7 | #include <qtopia/qpeapplication.h> |
8 | #include <qtopia/applicationinterface.h> | 8 | #include <qtopia/applicationinterface.h> |
9 | #include <qtopia/resource.h> | 9 | #include <qtopia/resource.h> |
10 | 10 | ||
11 | /* QT */ | 11 | /* QT */ |
12 | #include <qmetaobject.h> | 12 | #include <qmetaobject.h> |
13 | #include <qmap.h> | 13 | #include <qmap.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | 15 | ||
16 | namespace QuickPrivate { | 16 | namespace QuickPrivate { |
17 | 17 | ||
18 | struct PluginLoader { | 18 | struct PluginLoader { |
19 | PluginLoader( const char* ) { | 19 | PluginLoader( const char* ) { |
20 | } | 20 | } |
21 | 21 | ||
22 | QRESULT queryInterface( const QString& app, const QUuid&, QUnknownInterface** ); | 22 | QRESULT queryInterface( const QString& app, const QUuid&, QUnknownInterface** ); |
23 | void releaseInterface( QUnknownInterface* ); | 23 | void releaseInterface( QUnknownInterface* ); |
24 | QMap<QUnknownInterface*, QLibrary*> libs; | 24 | QMap<QUnknownInterface*, QLibrary*> libs; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * We can skip installing a Translator here because Opies QPEApplication | 28 | * We can skip installing a Translator here because Opies QPEApplication |
29 | * will do that in initApp for us as well | 29 | * will do that in initApp for us as well |
30 | */ | 30 | */ |
31 | QRESULT PluginLoader::queryInterface( const QString& libFile, const QUuid& uuid, QUnknownInterface** iface ) { | 31 | QRESULT PluginLoader::queryInterface( const QString& libFile, const QUuid& uuid, QUnknownInterface** iface ) { |
32 | QRESULT res = QS_FALSE; | 32 | QRESULT res = QS_FALSE; |
33 | *iface = 0; | 33 | *iface = 0; |
34 | 34 | ||
35 | // This code is very platform specific.. We should find better | 35 | // This code is very platform specific.. We should find better |
36 | // solutions to handle names.. Maybe one central function would be | 36 | // solutions to handle names.. Maybe one central function would be |
37 | // better than checking this ".so" stuff all around in the sources.. | 37 | // better than checking this ".so" stuff all around in the sources.. |
38 | // (eilers) | 38 | // (eilers) |
39 | 39 | ||
40 | // Below lines from TT then mine again | 40 | // Below lines from TT then mine again |
41 | QString name = libFile; | 41 | QString name = libFile; |
42 | if ( libFile.findRev(".so") == (int)libFile.length()-3 ) { | 42 | if ( libFile.findRev(".so") == (int)libFile.length()-3 ) { |
43 | name = libFile.left( libFile.length()-3 ); | 43 | name = libFile.left( libFile.length()-3 ); |
44 | if ( name.find( "lib" ) == 0 ) | 44 | if ( name.find( "lib" ) == 0 ) |
45 | name = name.mid( 3 ); | 45 | name = name.mid( 3 ); |
46 | } | 46 | } |
47 | #ifdef Q_OS_MACX | 47 | #ifdef Q_OS_MACX |
48 | QString path = QPEApplication::qpeDir() + "/plugins/application/lib"+name+".dylib"; | 48 | QString path = QPEApplication::qpeDir() + "plugins/application/lib"+name+".dylib"; |
49 | #else | 49 | #else |
50 | QString path = QPEApplication::qpeDir() + "/plugins/application/lib"+name+".so"; | 50 | QString path = QPEApplication::qpeDir() + "plugins/application/lib"+name+".so"; |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | QLibrary *lib = new QLibrary( path ); | 53 | QLibrary *lib = new QLibrary( path ); |
54 | if ( lib->queryInterface( uuid, iface ) == QS_OK && iface ) { | 54 | if ( lib->queryInterface( uuid, iface ) == QS_OK && iface ) { |
55 | libs.insert( *iface, lib ); | 55 | libs.insert( *iface, lib ); |
56 | res = QS_OK; | 56 | res = QS_OK; |
57 | } | 57 | } |
58 | 58 | ||
59 | return res; | 59 | return res; |
60 | } | 60 | } |
61 | 61 | ||
62 | void PluginLoader::releaseInterface( QUnknownInterface* iface ) { | 62 | void PluginLoader::releaseInterface( QUnknownInterface* iface ) { |
63 | if ( libs.contains( iface ) ) { | 63 | if ( libs.contains( iface ) ) { |
64 | iface->release(); | 64 | iface->release(); |
65 | delete libs[iface]; | 65 | delete libs[iface]; |
66 | libs.remove( iface ); // we only handle pointers so even if the object is not valid the address-space is | 66 | libs.remove( iface ); // we only handle pointers so even if the object is not valid the address-space is |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index 1fba9bc..fe5051d 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -1,347 +1,347 @@ | |||
1 | /* | 1 | /* |
2 | * TODO | 2 | * TODO |
3 | * make a font selection thing (size too) | 3 | * make a font selection thing (size too) |
4 | * make a keymap editor | 4 | * make a keymap editor |
5 | * make keys translucent | 5 | * make keys translucent |
6 | * make vertical keys possible | 6 | * make vertical keys possible |
7 | * | 7 | * |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/resource.h> | 13 | #include <qpe/resource.h> |
14 | 14 | ||
15 | #include <qlayout.h> | 15 | #include <qlayout.h> |
16 | #include <qwidget.h> | 16 | #include <qwidget.h> |
17 | #include <qdialog.h> | 17 | #include <qdialog.h> |
18 | #include <qtabwidget.h> | 18 | #include <qtabwidget.h> |
19 | #include <qvbox.h> | 19 | #include <qvbox.h> |
20 | #include <qgrid.h> | 20 | #include <qgrid.h> |
21 | #include <qgroupbox.h> | 21 | #include <qgroupbox.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
24 | #include <qsizepolicy.h> | 24 | #include <qsizepolicy.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <opie2/ofiledialog.h> | 29 | #include <opie2/ofiledialog.h> |
30 | #include <opie2/qcolordialog.h> | 30 | #include <opie2/qcolordialog.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfileinfo.h> | 32 | #include <qfileinfo.h> |
33 | #include "configdlg.h" | 33 | #include "configdlg.h" |
34 | #include "keyboard.h" | 34 | #include "keyboard.h" |
35 | 35 | ||
36 | using namespace Opie; | 36 | using namespace Opie; |
37 | using namespace Opie::Ui; | 37 | using namespace Opie::Ui; |
38 | // ConfigDlg::ConfigDlg() {{{1 | 38 | // ConfigDlg::ConfigDlg() {{{1 |
39 | ConfigDlg::ConfigDlg () : QDialog () | 39 | ConfigDlg::ConfigDlg () : QDialog () |
40 | { | 40 | { |
41 | setCaption( tr("Multikey Configuration") ); | 41 | setCaption( tr("Multikey Configuration") ); |
42 | Config config ("multikey"); | 42 | Config config ("multikey"); |
43 | config.setGroup("keymaps"); | 43 | config.setGroup("keymaps"); |
44 | QString current_map = config.readEntry("current", 0); | 44 | QString current_map = config.readEntry("current", 0); |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * 'general config' tab | 47 | * 'general config' tab |
48 | */ | 48 | */ |
49 | 49 | ||
50 | QVBoxLayout *base_lay = new QVBoxLayout(this); | 50 | QVBoxLayout *base_lay = new QVBoxLayout(this); |
51 | 51 | ||
52 | QTabWidget *tabs = new QTabWidget(this, "tabs"); | 52 | QTabWidget *tabs = new QTabWidget(this, "tabs"); |
53 | 53 | ||
54 | QWidget *gen_box = new QWidget(tabs, "gen_tab"); | 54 | QWidget *gen_box = new QWidget(tabs, "gen_tab"); |
55 | QVBoxLayout *gen_lay = new QVBoxLayout(gen_box); | 55 | QVBoxLayout *gen_lay = new QVBoxLayout(gen_box); |
56 | gen_lay->setMargin(3); | 56 | gen_lay->setMargin(3); |
57 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); | 57 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
58 | 58 | ||
59 | QHBox *hbox1 = new QHBox(map_group); | 59 | QHBox *hbox1 = new QHBox(map_group); |
60 | keymaps = new QListBox(hbox1); | 60 | keymaps = new QListBox(hbox1); |
61 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 61 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
62 | QVBox *vbox1 = new QVBox(hbox1); | 62 | QVBox *vbox1 = new QVBox(hbox1); |
63 | 63 | ||
64 | QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); | 64 | QToolButton *tb1 = new QToolButton(vbox1, tr("Move Up")); |
65 | tb1->setPixmap(Resource::loadPixmap("up")); | 65 | tb1->setPixmap(Resource::loadPixmap("up")); |
66 | tb1->setAutoRaise(TRUE); | 66 | tb1->setAutoRaise(TRUE); |
67 | tb1->setFocusPolicy(QWidget::NoFocus); | 67 | tb1->setFocusPolicy(QWidget::NoFocus); |
68 | tb1->setToggleButton(FALSE); | 68 | tb1->setToggleButton(FALSE); |
69 | connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); | 69 | connect(tb1, SIGNAL(clicked()), this, SLOT(moveSelectedUp())); |
70 | 70 | ||
71 | QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); | 71 | QToolButton *tb2 = new QToolButton(vbox1, tr("Move Down")); |
72 | tb2->setPixmap(Resource::loadPixmap("down")); | 72 | tb2->setPixmap(Resource::loadPixmap("down")); |
73 | tb2->setAutoRaise(TRUE); | 73 | tb2->setAutoRaise(TRUE); |
74 | tb2->setFocusPolicy(QWidget::NoFocus); | 74 | tb2->setFocusPolicy(QWidget::NoFocus); |
75 | tb2->setToggleButton(FALSE); | 75 | tb2->setToggleButton(FALSE); |
76 | connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); | 76 | connect(tb2, SIGNAL(clicked()), this, SLOT(moveSelectedDown())); |
77 | 77 | ||
78 | QString cur(tr("Current Language")); | 78 | QString cur(tr("Current Language")); |
79 | keymaps->insertItem(cur); | 79 | keymaps->insertItem(cur); |
80 | keymaps->setSelected(0, true); | 80 | keymaps->setSelected(0, true); |
81 | 81 | ||
82 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 82 | QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap"); |
83 | default_maps = map_dir.entryList(); // so i can access it in other places | 83 | default_maps = map_dir.entryList(); // so i can access it in other places |
84 | custom_maps = config.readListEntry("maps", QChar('|')); | 84 | custom_maps = config.readListEntry("maps", QChar('|')); |
85 | sw_maps = ConfigDlg::loadSw(); | 85 | sw_maps = ConfigDlg::loadSw(); |
86 | 86 | ||
87 | QStringList sw_copy(sw_maps); | 87 | QStringList sw_copy(sw_maps); |
88 | for (uint i = 0; i < sw_copy.count(); i++) { | 88 | for (uint i = 0; i < sw_copy.count(); i++) { |
89 | 89 | ||
90 | QString keymap_map; | 90 | QString keymap_map; |
91 | if (sw_copy[i][0] != '/') { /* share/multikey */ | 91 | if (sw_copy[i][0] != '/') { /* share/multikey */ |
92 | 92 | ||
93 | keymap_map = map_dir.absPath() + "/" + sw_copy[i]; | 93 | keymap_map = map_dir.absPath() + "/" + sw_copy[i]; |
94 | } else { | 94 | } else { |
95 | 95 | ||
96 | if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) | 96 | if (map_dir.exists(QFileInfo(sw_copy[i]).fileName(), false) |
97 | || !QFile::exists(sw_copy[i])) { | 97 | || !QFile::exists(sw_copy[i])) { |
98 | 98 | ||
99 | custom_maps.remove(sw_copy[i]); | 99 | custom_maps.remove(sw_copy[i]); |
100 | sw_maps.remove(sw_copy[i]); | 100 | sw_maps.remove(sw_copy[i]); |
101 | 101 | ||
102 | // remove it from the list too | 102 | // remove it from the list too |
103 | config.writeEntry("maps", custom_maps.join("|")); | 103 | config.writeEntry("maps", custom_maps.join("|")); |
104 | 104 | ||
105 | continue; | 105 | continue; |
106 | } | 106 | } |
107 | keymap_map = sw_copy[i]; | 107 | keymap_map = sw_copy[i]; |
108 | } | 108 | } |
109 | 109 | ||
110 | QFile map(keymap_map); | 110 | QFile map(keymap_map); |
111 | if (map.open(IO_ReadOnly)) { | 111 | if (map.open(IO_ReadOnly)) { |
112 | 112 | ||
113 | QString line; bool found = 0; | 113 | QString line; bool found = 0; |
114 | 114 | ||
115 | map.readLine(line, 1024); | 115 | map.readLine(line, 1024); |
116 | while (!map.atEnd()) { | 116 | while (!map.atEnd()) { |
117 | 117 | ||
118 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { | 118 | if (line.find(QRegExp("^title\\s*=\\s*")) != -1) { |
119 | 119 | ||
120 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 120 | keymaps->insertItem(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
121 | found = 1; | 121 | found = 1; |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | map.readLine(line, 1024); | 124 | map.readLine(line, 1024); |
125 | } | 125 | } |
126 | if (!found) | 126 | if (!found) |
127 | keymaps->insertItem(keymap_map); | 127 | keymaps->insertItem(keymap_map); |
128 | 128 | ||
129 | map.close(); | 129 | map.close(); |
130 | } | 130 | } |
131 | 131 | ||
132 | if (keymap_map == current_map) { | 132 | if (keymap_map == current_map) { |
133 | keymaps->setSelected(i + 1, true); | 133 | keymaps->setSelected(i + 1, true); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | // have to "+1" because the "current language" listItem... remember? | 137 | // have to "+1" because the "current language" listItem... remember? |
138 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); | 138 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
139 | 139 | ||
140 | QGrid *add_remove_grid = new QGrid(2, map_group); | 140 | QGrid *add_remove_grid = new QGrid(2, map_group); |
141 | add_remove_grid->setMargin(3); | 141 | add_remove_grid->setMargin(3); |
142 | add_remove_grid->setSpacing(3); | 142 | add_remove_grid->setSpacing(3); |
143 | 143 | ||
144 | add_button = new QPushButton(tr("Add"), add_remove_grid); | 144 | add_button = new QPushButton(tr("Add"), add_remove_grid); |
145 | add_button->setFlat(TRUE); | 145 | add_button->setFlat(TRUE); |
146 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); | 146 | connect(add_button, SIGNAL(clicked()), SLOT(addMap())); |
147 | 147 | ||
148 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | 148 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); |
149 | remove_button->setFlat(TRUE); | 149 | remove_button->setFlat(TRUE); |
150 | if (keymaps->currentItem() == 0 || default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end()) | 150 | if (keymaps->currentItem() == 0 || default_maps.find(QFileInfo(current_map).fileName()) != default_maps.end()) |
151 | remove_button->setDisabled(true); | 151 | remove_button->setDisabled(true); |
152 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); | 152 | connect(remove_button, SIGNAL(clicked()), SLOT(removeMap())); |
153 | 153 | ||
154 | gen_lay->addWidget(map_group); | 154 | gen_lay->addWidget(map_group); |
155 | 155 | ||
156 | // make a box that will contain the buttons on the bottom | 156 | // make a box that will contain the buttons on the bottom |
157 | QGrid *other_grid = new QGrid(2, gen_box); | 157 | QGrid *other_grid = new QGrid(2, gen_box); |
158 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); | 158 | pick_button = new QCheckBox(tr("Pickboard"), other_grid); |
159 | 159 | ||
160 | config.setGroup ("general"); | 160 | config.setGroup ("general"); |
161 | bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed | 161 | bool pick_open = config.readBoolEntry ("usePickboard", FALSE); // default closed |
162 | if (pick_open) { | 162 | if (pick_open) { |
163 | 163 | ||
164 | pick_button->setChecked(true); | 164 | pick_button->setChecked(true); |
165 | } | 165 | } |
166 | 166 | ||
167 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); | 167 | repeat_button = new QCheckBox(tr("Key Repeat"), other_grid); |
168 | bool repeat_on = config.readBoolEntry ("useRepeat", TRUE); | 168 | bool repeat_on = config.readBoolEntry ("useRepeat", TRUE); |
169 | 169 | ||
170 | if (repeat_on) { | 170 | if (repeat_on) { |
171 | 171 | ||
172 | repeat_button->setChecked(true); | 172 | repeat_button->setChecked(true); |
173 | } | 173 | } |
174 | 174 | ||
175 | gen_lay->addWidget(other_grid); | 175 | gen_lay->addWidget(other_grid); |
176 | tabs->addTab(gen_box, tr("General Settings")); | 176 | tabs->addTab(gen_box, tr("General Settings")); |
177 | 177 | ||
178 | /* | 178 | /* |
179 | * 'color' tab | 179 | * 'color' tab |
180 | */ | 180 | */ |
181 | 181 | ||
182 | QWidget *color_box = new QWidget(tabs, "color_tab"); | 182 | QWidget *color_box = new QWidget(tabs, "color_tab"); |
183 | 183 | ||
184 | QGridLayout *color_lay = new QGridLayout(color_box); | 184 | QGridLayout *color_lay = new QGridLayout(color_box); |
185 | QGrid *color_grid = new QGrid(2, color_box); | 185 | QGrid *color_grid = new QGrid(2, color_box); |
186 | color_lay->setAlignment(Qt::AlignTop); | 186 | color_lay->setAlignment(Qt::AlignTop); |
187 | color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 187 | color_grid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
188 | color_grid->layout()->setAlignment(Qt::AlignTop); | 188 | color_grid->layout()->setAlignment(Qt::AlignTop); |
189 | color_grid->setMargin(3); | 189 | color_grid->setMargin(3); |
190 | color_grid->setSpacing(3); | 190 | color_grid->setSpacing(3); |
191 | 191 | ||
192 | QLabel *label; | 192 | QLabel *label; |
193 | QStringList color; | 193 | QStringList color; |
194 | config.setGroup("colors"); | 194 | config.setGroup("colors"); |
195 | 195 | ||
196 | label = new QLabel(tr("Key Color"), color_grid); | 196 | label = new QLabel(tr("Key Color"), color_grid); |
197 | keycolor_button = new QPushButton(color_grid); | 197 | keycolor_button = new QPushButton(color_grid); |
198 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); | 198 | connect(keycolor_button, SIGNAL(clicked()), SLOT(keyColorClicked())); |
199 | keycolor_button->setFlat(TRUE); | 199 | keycolor_button->setFlat(TRUE); |
200 | color = config.readListEntry("keycolor", QChar(',')); | 200 | color = config.readListEntry("keycolor", QChar(',')); |
201 | /* | 201 | /* |
202 | * hopefully not required | 202 | * hopefully not required |
203 | 203 | ||
204 | if (color.isEmpty()) { | 204 | if (color.isEmpty()) { |
205 | color = QStringList::split(",", "240,240,240"); | 205 | color = QStringList::split(",", "240,240,240"); |
206 | config.writeEntry("keycolor", color.join(",")); | 206 | config.writeEntry("keycolor", color.join(",")); |
207 | 207 | ||
208 | } | 208 | } |
209 | */ | 209 | */ |
210 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); | 210 | keycolor_button->setPalette(QPalette(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()))); |
211 | 211 | ||
212 | 212 | ||
213 | label = new QLabel(tr("Key Pressed Color"), color_grid); | 213 | label = new QLabel(tr("Key Pressed Color"), color_grid); |
214 | keycolor_pressed_button = new QPushButton(color_grid); | 214 | keycolor_pressed_button = new QPushButton(color_grid); |
215 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); | 215 | connect(keycolor_pressed_button, SIGNAL(clicked()), SLOT(keyColorPressedClicked())); |
216 | keycolor_pressed_button->setFlat(TRUE); | 216 | keycolor_pressed_button->setFlat(TRUE); |
217 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 217 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
218 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 218 | keycolor_pressed_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
219 | 219 | ||
220 | label = new QLabel(tr("Line Color"), color_grid); | 220 | label = new QLabel(tr("Line Color"), color_grid); |
221 | keycolor_lines_button = new QPushButton(color_grid); | 221 | keycolor_lines_button = new QPushButton(color_grid); |
222 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); | 222 | connect(keycolor_lines_button, SIGNAL(clicked()), SLOT(keyColorLinesClicked())); |
223 | keycolor_lines_button->setFlat(TRUE); | 223 | keycolor_lines_button->setFlat(TRUE); |
224 | color = config.readListEntry("keycolor_lines", QChar(',')); | 224 | color = config.readListEntry("keycolor_lines", QChar(',')); |
225 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 225 | keycolor_lines_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
226 | 226 | ||
227 | 227 | ||
228 | label = new QLabel(tr("Text Color"), color_grid); | 228 | label = new QLabel(tr("Text Color"), color_grid); |
229 | textcolor_button = new QPushButton(color_grid); | 229 | textcolor_button = new QPushButton(color_grid); |
230 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); | 230 | connect(textcolor_button, SIGNAL(clicked()), SLOT(textColorClicked())); |
231 | textcolor_button->setFlat(TRUE); | 231 | textcolor_button->setFlat(TRUE); |
232 | color = config.readListEntry("textcolor", QChar(',')); | 232 | color = config.readListEntry("textcolor", QChar(',')); |
233 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); | 233 | textcolor_button->setPalette(QPalette((QColor(color[0].toInt(), color[1].toInt(), color[2].toInt())))); |
234 | 234 | ||
235 | label = new QLabel("", color_grid); // a spacer so the above buttons dont expand | 235 | label = new QLabel("", color_grid); // a spacer so the above buttons dont expand |
236 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 236 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
237 | /* FIXME: hacked spacer height */ | 237 | /* FIXME: hacked spacer height */ |
238 | QSpacerItem *spacer = new QSpacerItem(0, 300, QSizePolicy::Expanding, QSizePolicy::Maximum); | 238 | QSpacerItem *spacer = new QSpacerItem(0, 300, QSizePolicy::Expanding, QSizePolicy::Maximum); |
239 | 239 | ||
240 | color_lay->addWidget(color_grid, 0, 0); | 240 | color_lay->addWidget(color_grid, 0, 0); |
241 | color_lay->addItem(spacer); | 241 | color_lay->addItem(spacer); |
242 | 242 | ||
243 | tabs->addTab(color_box, tr("Colors")); | 243 | tabs->addTab(color_box, tr("Colors")); |
244 | base_lay->addWidget(tabs); | 244 | base_lay->addWidget(tabs); |
245 | } | 245 | } |
246 | 246 | ||
247 | QStringList ConfigDlg::loadSw() | 247 | QStringList ConfigDlg::loadSw() |
248 | { | 248 | { |
249 | Config *config = new Config("multikey"); | 249 | Config *config = new Config("multikey"); |
250 | config->setGroup("keymaps"); | 250 | config->setGroup("keymaps"); |
251 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey", "*.keymap"); | 251 | QDir map_dir(QPEApplication::qpeDir() + "share/multikey", "*.keymap"); |
252 | QStringList d_maps = map_dir.entryList(); // so i can access it in other places | 252 | QStringList d_maps = map_dir.entryList(); // so i can access it in other places |
253 | QStringList c_maps = config->readListEntry("maps", QChar('|')); | 253 | QStringList c_maps = config->readListEntry("maps", QChar('|')); |
254 | QStringList s_maps = config->readListEntry("sw", QChar('|')); | 254 | QStringList s_maps = config->readListEntry("sw", QChar('|')); |
255 | delete config; | 255 | delete config; |
256 | 256 | ||
257 | if (!s_maps.count()) | 257 | if (!s_maps.count()) |
258 | { | 258 | { |
259 | s_maps = d_maps+c_maps; | 259 | s_maps = d_maps+c_maps; |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | /* Clear non existents entries */ | 263 | /* Clear non existents entries */ |
264 | QStringList s_copy(s_maps); | 264 | QStringList s_copy(s_maps); |
265 | for (uint i = 0; i < s_copy.count(); ++i) { | 265 | for (uint i = 0; i < s_copy.count(); ++i) { |
266 | if (d_maps.find(s_copy[i]) == d_maps.end() | 266 | if (d_maps.find(s_copy[i]) == d_maps.end() |
267 | && c_maps.find(s_copy[i]) == c_maps.end()) { | 267 | && c_maps.find(s_copy[i]) == c_maps.end()) { |
268 | s_maps.remove(s_copy[i]); | 268 | s_maps.remove(s_copy[i]); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | /* Update sw_maps from default_maps */ | 271 | /* Update sw_maps from default_maps */ |
272 | for (uint i = 0; i < d_maps.count(); ++i) { | 272 | for (uint i = 0; i < d_maps.count(); ++i) { |
273 | if (s_maps.find(d_maps[i]) == s_maps.end()) { | 273 | if (s_maps.find(d_maps[i]) == s_maps.end()) { |
274 | s_maps.append(d_maps[i]); | 274 | s_maps.append(d_maps[i]); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | /* Update sw_maps from custom_maps */ | 277 | /* Update sw_maps from custom_maps */ |
278 | for (uint i = 0; i < c_maps.count(); ++i) { | 278 | for (uint i = 0; i < c_maps.count(); ++i) { |
279 | if (s_maps.find(c_maps[i]) == s_maps.end()) { | 279 | if (s_maps.find(c_maps[i]) == s_maps.end()) { |
280 | s_maps.append(c_maps[i]); | 280 | s_maps.append(c_maps[i]); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | return s_maps; | 285 | return s_maps; |
286 | } | 286 | } |
287 | 287 | ||
288 | void ConfigDlg::accept() | 288 | void ConfigDlg::accept() |
289 | { | 289 | { |
290 | /* Writing all stuffs to config */ | 290 | /* Writing all stuffs to config */ |
291 | Config *config = new Config("multikey"); | 291 | Config *config = new Config("multikey"); |
292 | config->setGroup("general"); | 292 | config->setGroup("general"); |
293 | config->writeEntry("usePickboard", pick_button->isChecked()); // default closed | 293 | config->writeEntry("usePickboard", pick_button->isChecked()); // default closed |
294 | config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed | 294 | config->writeEntry("useRepeat", repeat_button->isChecked()); // default closed |
295 | 295 | ||
296 | config->setGroup("keymaps"); | 296 | config->setGroup("keymaps"); |
297 | config->writeEntry("sw", sw_maps, QChar('|')); | 297 | config->writeEntry("sw", sw_maps, QChar('|')); |
298 | config->writeEntry("maps", custom_maps, QChar('|')); | 298 | config->writeEntry("maps", custom_maps, QChar('|')); |
299 | delete config; | 299 | delete config; |
300 | 300 | ||
301 | int index = keymaps->currentItem(); | 301 | int index = keymaps->currentItem(); |
302 | if (index == 0) { | 302 | if (index == 0) { |
303 | 303 | ||
304 | remove_button->setDisabled(true); | 304 | remove_button->setDisabled(true); |
305 | emit setMapToDefault(); | 305 | emit setMapToDefault(); |
306 | } | 306 | } |
307 | else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) { | 307 | else if (default_maps.find(sw_maps[index-1]) != default_maps.end()) { |
308 | 308 | ||
309 | remove_button->setDisabled(true); | 309 | remove_button->setDisabled(true); |
310 | emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); | 310 | emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + sw_maps[index - 1]); |
311 | 311 | ||
312 | } else { | 312 | } else { |
313 | 313 | ||
314 | remove_button->setEnabled(true); | 314 | remove_button->setEnabled(true); |
315 | emit setMapToFile(sw_maps[index - 1]); | 315 | emit setMapToFile(sw_maps[index - 1]); |
316 | } | 316 | } |
317 | 317 | ||
318 | emit pickboardToggled(pick_button->isChecked()); | 318 | emit pickboardToggled(pick_button->isChecked()); |
319 | emit repeatToggled(repeat_button->isChecked()); | 319 | emit repeatToggled(repeat_button->isChecked()); |
320 | emit reloadSw(); | 320 | emit reloadSw(); |
321 | 321 | ||
322 | QDialog::accept(); | 322 | QDialog::accept(); |
323 | emit configDlgClosed(); | 323 | emit configDlgClosed(); |
324 | } | 324 | } |
325 | 325 | ||
326 | void ConfigDlg::moveSelectedUp() | 326 | void ConfigDlg::moveSelectedUp() |
327 | { | 327 | { |
328 | int i = keymaps->currentItem(); | 328 | int i = keymaps->currentItem(); |
329 | /* Ignore Current Language */ | 329 | /* Ignore Current Language */ |
330 | if (i > 1) { | 330 | if (i > 1) { |
331 | QString t = sw_maps[i-1]; | 331 | QString t = sw_maps[i-1]; |
332 | sw_maps[i-1] = sw_maps[i-2]; | 332 | sw_maps[i-1] = sw_maps[i-2]; |
333 | sw_maps[i-2] = t; | 333 | sw_maps[i-2] = t; |
334 | 334 | ||
335 | QString item = keymaps->currentText(); | 335 | QString item = keymaps->currentText(); |
336 | keymaps->removeItem(i); | 336 | keymaps->removeItem(i); |
337 | keymaps->insertItem(item, i-1); | 337 | keymaps->insertItem(item, i-1); |
338 | keymaps->setCurrentItem(i-1); | 338 | keymaps->setCurrentItem(i-1); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void ConfigDlg::moveSelectedDown() | 342 | void ConfigDlg::moveSelectedDown() |
343 | { | 343 | { |
344 | int i = keymaps->currentItem(); | 344 | int i = keymaps->currentItem(); |
345 | /* Ignore Current Language */ | 345 | /* Ignore Current Language */ |
346 | if (i > 0 && i < (int)keymaps->count() - 1) { | 346 | if (i > 0 && i < (int)keymaps->count() - 1) { |
347 | QString t = sw_maps[i-1]; | 347 | QString t = sw_maps[i-1]; |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 7ddfd3e..f8cafd5 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1284,198 +1284,198 @@ ushort Keyboard::parseKoreanInput (ushort c) { | |||
1284 | return combineKoreanChars(schar, mchar, 0); | 1284 | return combineKoreanChars(schar, mchar, 0); |
1285 | 1285 | ||
1286 | } | 1286 | } |
1287 | else { | 1287 | else { |
1288 | schar = 0; mchar = 0; echar = 0; | 1288 | schar = 0; mchar = 0; echar = 0; |
1289 | return c; | 1289 | return c; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | } | 1292 | } |
1293 | else /*if (c == ' ')*/ return c; | 1293 | else /*if (c == ' ')*/ return c; |
1294 | 1294 | ||
1295 | 1295 | ||
1296 | // and now... finally delete previous char, and return new char | 1296 | // and now... finally delete previous char, and return new char |
1297 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1297 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1298 | 1298 | ||
1299 | 1299 | ||
1300 | return combineKoreanChars( schar, mchar, echar); | 1300 | return combineKoreanChars( schar, mchar, echar); |
1301 | 1301 | ||
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 1304 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
1305 | 1305 | ||
1306 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 1306 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
1307 | 1307 | ||
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | ushort Keyboard::constoe(const ushort c) { | 1310 | ushort Keyboard::constoe(const ushort c) { |
1311 | 1311 | ||
1312 | // converts schars to echars if possible | 1312 | // converts schars to echars if possible |
1313 | 1313 | ||
1314 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 1314 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
1315 | 1315 | ||
1316 | switch (c) { | 1316 | switch (c) { |
1317 | case 0x1100: return 0x11a8; | 1317 | case 0x1100: return 0x11a8; |
1318 | case 0x1101: return 0x11a9; | 1318 | case 0x1101: return 0x11a9; |
1319 | case 0x1102: return 0x11ab; | 1319 | case 0x1102: return 0x11ab; |
1320 | case 0x1103: return 0x11ae; | 1320 | case 0x1103: return 0x11ae; |
1321 | case 0x1105: return 0x11af; | 1321 | case 0x1105: return 0x11af; |
1322 | case 0x1106: return 0x11b7; | 1322 | case 0x1106: return 0x11b7; |
1323 | case 0x1107: return 0x11b8; | 1323 | case 0x1107: return 0x11b8; |
1324 | case 0x1109: return 0x11ba; | 1324 | case 0x1109: return 0x11ba; |
1325 | case 0x110a: return 0x11bb; | 1325 | case 0x110a: return 0x11bb; |
1326 | case 0x110b: return 0x11bc; | 1326 | case 0x110b: return 0x11bc; |
1327 | case 0x110c: return 0x11bd; | 1327 | case 0x110c: return 0x11bd; |
1328 | case 0x110e: return 0x11be; | 1328 | case 0x110e: return 0x11be; |
1329 | case 0x110f: return 0x11bf; | 1329 | case 0x110f: return 0x11bf; |
1330 | case 0x1110: return 0x11c0; | 1330 | case 0x1110: return 0x11c0; |
1331 | case 0x1111: return 0x11c1; | 1331 | case 0x1111: return 0x11c1; |
1332 | case 0x1112: return 0x11c2; | 1332 | case 0x1112: return 0x11c2; |
1333 | default: return 0; | 1333 | default: return 0; |
1334 | 1334 | ||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | } else { //echar to schar | 1337 | } else { //echar to schar |
1338 | 1338 | ||
1339 | switch (c) { | 1339 | switch (c) { |
1340 | case 0x11a8: return 0x1100; | 1340 | case 0x11a8: return 0x1100; |
1341 | case 0x11a9: return 0x1101; | 1341 | case 0x11a9: return 0x1101; |
1342 | case 0x11ab: return 0x1102; | 1342 | case 0x11ab: return 0x1102; |
1343 | case 0x11ae: return 0x1103; | 1343 | case 0x11ae: return 0x1103; |
1344 | case 0x11af: return 0x1105; | 1344 | case 0x11af: return 0x1105; |
1345 | case 0x11b7: return 0x1106; | 1345 | case 0x11b7: return 0x1106; |
1346 | case 0x11b8: return 0x1107; | 1346 | case 0x11b8: return 0x1107; |
1347 | case 0x11ba: return 0x1109; | 1347 | case 0x11ba: return 0x1109; |
1348 | case 0x11bb: return 0x110a; | 1348 | case 0x11bb: return 0x110a; |
1349 | case 0x11bc: return 0x110b; | 1349 | case 0x11bc: return 0x110b; |
1350 | case 0x11bd: return 0x110c; | 1350 | case 0x11bd: return 0x110c; |
1351 | case 0x11be: return 0x110e; | 1351 | case 0x11be: return 0x110e; |
1352 | case 0x11bf: return 0x110f; | 1352 | case 0x11bf: return 0x110f; |
1353 | case 0x11c0: return 0x1110; | 1353 | case 0x11c0: return 0x1110; |
1354 | case 0x11c1: return 0x1111; | 1354 | case 0x11c1: return 0x1111; |
1355 | case 0x11c2: return 0x1112; | 1355 | case 0x11c2: return 0x1112; |
1356 | default: return 0; | 1356 | default: return 0; |
1357 | 1357 | ||
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | 1363 | ||
1364 | // Keys::Keys {{{1 | 1364 | // Keys::Keys {{{1 |
1365 | 1365 | ||
1366 | Keys::Keys() { | 1366 | Keys::Keys() { |
1367 | 1367 | ||
1368 | Config *config = new Config ("multikey"); | 1368 | Config *config = new Config ("multikey"); |
1369 | config->setGroup( "keymaps" ); | 1369 | config->setGroup( "keymaps" ); |
1370 | QString map = config->readEntry( "current" ); | 1370 | QString map = config->readEntry( "current" ); |
1371 | delete config; | 1371 | delete config; |
1372 | 1372 | ||
1373 | if (map.isNull() || !(QFile(map).exists())) { | 1373 | if (map.isNull() || !(QFile(map).exists())) { |
1374 | 1374 | ||
1375 | Config *config = new Config("locale"); | 1375 | Config *config = new Config("locale"); |
1376 | config->setGroup( "Language" ); | 1376 | config->setGroup( "Language" ); |
1377 | QString l = config->readEntry( "Language" , "en" ); | 1377 | QString l = config->readEntry( "Language" , "en" ); |
1378 | delete config; | 1378 | delete config; |
1379 | 1379 | ||
1380 | map = QPEApplication::qpeDir() + "/share/multikey/" | 1380 | map = QPEApplication::qpeDir() + "share/multikey/" |
1381 | + l + ".keymap"; | 1381 | + l + ".keymap"; |
1382 | 1382 | ||
1383 | } | 1383 | } |
1384 | if (map.isNull() || !(QFile(map).exists())) { | 1384 | if (map.isNull() || !(QFile(map).exists())) { |
1385 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; | 1385 | map = QPEApplication::qpeDir() + "share/multikey/en.keymap"; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | setKeysFromFile(map); | 1388 | setKeysFromFile(map); |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | Keys::Keys(const char * filename) { | 1391 | Keys::Keys(const char * filename) { |
1392 | 1392 | ||
1393 | setKeysFromFile(filename); | 1393 | setKeysFromFile(filename); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | // Keys::setKeysFromFile {{{2 | 1396 | // Keys::setKeysFromFile {{{2 |
1397 | void Keys::setKeysFromFile(const char * filename) { | 1397 | void Keys::setKeysFromFile(const char * filename) { |
1398 | 1398 | ||
1399 | QFile f(filename); | 1399 | QFile f(filename); |
1400 | 1400 | ||
1401 | if (f.open(IO_ReadOnly)) { | 1401 | if (f.open(IO_ReadOnly)) { |
1402 | 1402 | ||
1403 | QTextStream t(&f); | 1403 | QTextStream t(&f); |
1404 | int row; | 1404 | int row; |
1405 | int qcode; | 1405 | int qcode; |
1406 | ushort unicode; | 1406 | ushort unicode; |
1407 | int width; | 1407 | int width; |
1408 | QString buf; | 1408 | QString buf; |
1409 | QString comment; | 1409 | QString comment; |
1410 | char * xpm[256]; //couldnt be larger than that... could it? | 1410 | char * xpm[256]; //couldnt be larger than that... could it? |
1411 | QImage *xpm2pix = 0; | 1411 | QImage *xpm2pix = 0; |
1412 | 1412 | ||
1413 | buf = t.readLine(); | 1413 | buf = t.readLine(); |
1414 | while (buf) { | 1414 | while (buf) { |
1415 | 1415 | ||
1416 | // get rid of comments | 1416 | // get rid of comments |
1417 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); | 1417 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); |
1418 | 1418 | ||
1419 | // key definition | 1419 | // key definition |
1420 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 1420 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
1421 | // no $1 type referencing!!! this implementation of regexp sucks | 1421 | // no $1 type referencing!!! this implementation of regexp sucks |
1422 | 1422 | ||
1423 | // dont know of any sscanf() type funcs in Qt lib | 1423 | // dont know of any sscanf() type funcs in Qt lib |
1424 | QTextStream tmp (buf, IO_ReadOnly); | 1424 | QTextStream tmp (buf, IO_ReadOnly); |
1425 | tmp >> row >> qcode >> unicode >> width >> comment; | 1425 | tmp >> row >> qcode >> unicode >> width >> comment; |
1426 | 1426 | ||
1427 | buf = t.readLine(); | 1427 | buf = t.readLine(); |
1428 | int xpmLineCount = 0; | 1428 | int xpmLineCount = 0; |
1429 | xpm2pix = 0; | 1429 | xpm2pix = 0; |
1430 | 1430 | ||
1431 | // erase blank space | 1431 | // erase blank space |
1432 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 1432 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
1433 | 1433 | ||
1434 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 1434 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
1435 | 1435 | ||
1436 | QString xpmBuf = buf.stripWhiteSpace(); | 1436 | QString xpmBuf = buf.stripWhiteSpace(); |
1437 | 1437 | ||
1438 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 1438 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
1439 | 1439 | ||
1440 | int j = 0; | 1440 | int j = 0; |
1441 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 1441 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
1442 | if (xpmBuf[i].latin1() != '"') { | 1442 | if (xpmBuf[i].latin1() != '"') { |
1443 | 1443 | ||
1444 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 1444 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
1445 | j++; | 1445 | j++; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | } | 1448 | } |
1449 | // have to close that facker up | 1449 | // have to close that facker up |
1450 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 1450 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
1451 | 1451 | ||
1452 | xpmLineCount++; | 1452 | xpmLineCount++; |
1453 | buf = t.readLine(); | 1453 | buf = t.readLine(); |
1454 | } | 1454 | } |
1455 | if (xpmLineCount) { | 1455 | if (xpmLineCount) { |
1456 | 1456 | ||
1457 | xpm2pix = new QImage((const char **)xpm); | 1457 | xpm2pix = new QImage((const char **)xpm); |
1458 | for (int i = 0; i < xpmLineCount; i++) | 1458 | for (int i = 0; i < xpmLineCount; i++) |
1459 | 1459 | ||
1460 | delete [] (xpm[i]); | 1460 | delete [] (xpm[i]); |
1461 | 1461 | ||
1462 | } | 1462 | } |
1463 | setKey(row, qcode, unicode, width, xpm2pix); | 1463 | setKey(row, qcode, unicode, width, xpm2pix); |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | // shift map | 1466 | // shift map |
1467 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1467 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1468 | 1468 | ||
1469 | QTextStream tmp (buf, IO_ReadOnly); | 1469 | QTextStream tmp (buf, IO_ReadOnly); |
1470 | ushort lower, shift; | 1470 | ushort lower, shift; |
1471 | tmp >> lower >> shift; | 1471 | tmp >> lower >> shift; |
1472 | 1472 | ||
1473 | shiftMap.insert(lower, shift); | 1473 | shiftMap.insert(lower, shift); |
1474 | 1474 | ||
1475 | buf = t.readLine(); | 1475 | buf = t.readLine(); |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | // meta key map | 1478 | // meta key map |
1479 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1479 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1480 | 1480 | ||
1481 | QTextStream tmp (buf, IO_ReadOnly); | 1481 | QTextStream tmp (buf, IO_ReadOnly); |
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp index 2a6e369..d33eac6 100644 --- a/libopie2/opiecore/opluginloader.cpp +++ b/libopie2/opiecore/opluginloader.cpp | |||
@@ -380,358 +380,358 @@ OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const { | |||
380 | OPluginItem::List lst; | 380 | OPluginItem::List lst; |
381 | for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) | 381 | for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) |
382 | lst += plugins( *it, sorted, false ); | 382 | lst += plugins( *it, sorted, false ); |
383 | 383 | ||
384 | if ( sorted ) | 384 | if ( sorted ) |
385 | qHeapSort( lst ); | 385 | qHeapSort( lst ); |
386 | return lst; | 386 | return lst; |
387 | } | 387 | } |
388 | 388 | ||
389 | /** | 389 | /** |
390 | * \brief Return only the enabled plugins | 390 | * \brief Return only the enabled plugins |
391 | * Return only activated plugins. | 391 | * Return only activated plugins. |
392 | * | 392 | * |
393 | * @param sorted If the list should be sorted | 393 | * @param sorted If the list should be sorted |
394 | */ | 394 | */ |
395 | OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const { | 395 | OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const { |
396 | OPluginItem::List lst; | 396 | OPluginItem::List lst; |
397 | for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) | 397 | for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it ) |
398 | lst += plugins( *it, sorted, true ); | 398 | lst += plugins( *it, sorted, true ); |
399 | 399 | ||
400 | if ( sorted ) | 400 | if ( sorted ) |
401 | qHeapSort( lst ); | 401 | qHeapSort( lst ); |
402 | return lst; | 402 | return lst; |
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | /** | 406 | /** |
407 | * \brief Load a OPluginItem for the specified interface | 407 | * \brief Load a OPluginItem for the specified interface |
408 | * This will open the resource of the OPluginItem::path() and then will query | 408 | * This will open the resource of the OPluginItem::path() and then will query |
409 | * if the Interface specified in the uuid is available and then will manage the | 409 | * if the Interface specified in the uuid is available and then will manage the |
410 | * resource and Interface. | 410 | * resource and Interface. |
411 | * | 411 | * |
412 | * @param item The OPluginItem that should be loaded | 412 | * @param item The OPluginItem that should be loaded |
413 | * @param uuid The Interface to query for | 413 | * @param uuid The Interface to query for |
414 | * | 414 | * |
415 | * @return Either 0 in case of failure or the Plugin as QUnknownInterface* | 415 | * @return Either 0 in case of failure or the Plugin as QUnknownInterface* |
416 | */ | 416 | */ |
417 | QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) { | 417 | QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) { |
418 | /* | 418 | /* |
419 | * Check if there could be a library | 419 | * Check if there could be a library |
420 | */ | 420 | */ |
421 | QString pa = item.path(); | 421 | QString pa = item.path(); |
422 | if ( pa.isEmpty() ) | 422 | if ( pa.isEmpty() ) |
423 | return 0l; | 423 | return 0l; |
424 | 424 | ||
425 | /* | 425 | /* |
426 | * See if we get a library | 426 | * See if we get a library |
427 | * return if we've none | 427 | * return if we've none |
428 | */ | 428 | */ |
429 | setSafeMode( pa, true ); | 429 | setSafeMode( pa, true ); |
430 | QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa ); | 430 | QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa ); |
431 | if ( !lib ) { | 431 | if ( !lib ) { |
432 | setSafeMode(); | 432 | setSafeMode(); |
433 | return 0l; | 433 | return 0l; |
434 | } | 434 | } |
435 | 435 | ||
436 | /** | 436 | /** |
437 | * try to load the plugin and just in case initialize the pointer to a pointer again | 437 | * try to load the plugin and just in case initialize the pointer to a pointer again |
438 | */ | 438 | */ |
439 | QUnknownInterface* iface=0; | 439 | QUnknownInterface* iface=0; |
440 | if ( lib->queryInterface( uuid, &iface ) == QS_OK ) { | 440 | if ( lib->queryInterface( uuid, &iface ) == QS_OK ) { |
441 | installTranslators( item.name() ); | 441 | installTranslators( item.name() ); |
442 | m_library.insert( iface, lib ); | 442 | m_library.insert( iface, lib ); |
443 | }else | 443 | }else |
444 | iface = 0; | 444 | iface = 0; |
445 | 445 | ||
446 | setSafeMode(); | 446 | setSafeMode(); |
447 | 447 | ||
448 | return iface; | 448 | return iface; |
449 | } | 449 | } |
450 | 450 | ||
451 | /** | 451 | /** |
452 | * @internal and reads in the safe mode | 452 | * @internal and reads in the safe mode |
453 | */ | 453 | */ |
454 | void OGenericPluginLoader::readConfig() { | 454 | void OGenericPluginLoader::readConfig() { |
455 | 455 | ||
456 | 456 | ||
457 | /* read the config for SafeMode */ | 457 | /* read the config for SafeMode */ |
458 | OConfig conf( m_dir + "-odpplugins" ); | 458 | OConfig conf( m_dir + "-odpplugins" ); |
459 | conf.setGroup( "General" ); | 459 | conf.setGroup( "General" ); |
460 | m_isSafeMode = conf.readBoolEntry( "SafeMode", false ); | 460 | m_isSafeMode = conf.readBoolEntry( "SafeMode", false ); |
461 | } | 461 | } |
462 | 462 | ||
463 | /** | 463 | /** |
464 | * @internal Enter or leave SafeMode | 464 | * @internal Enter or leave SafeMode |
465 | */ | 465 | */ |
466 | void OGenericPluginLoader::setSafeMode(const QString& str, bool b) { | 466 | void OGenericPluginLoader::setSafeMode(const QString& str, bool b) { |
467 | OConfig conf( m_dir + "-odpplugins" ); | 467 | OConfig conf( m_dir + "-odpplugins" ); |
468 | conf.setGroup( "General" ); | 468 | conf.setGroup( "General" ); |
469 | conf.writeEntry( "SafeMode", b ); | 469 | conf.writeEntry( "SafeMode", b ); |
470 | conf.writeEntry( "CrashedPlugin", str ); | 470 | conf.writeEntry( "CrashedPlugin", str ); |
471 | } | 471 | } |
472 | 472 | ||
473 | /** | 473 | /** |
474 | * @internal | 474 | * @internal |
475 | * | 475 | * |
476 | * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype | 476 | * Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"plugins/"+mytype |
477 | * is used as plugin dir | 477 | * is used as plugin dir |
478 | */ | 478 | */ |
479 | void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) { | 479 | void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) { |
480 | m_plugDirs = lst; | 480 | m_plugDirs = lst; |
481 | } | 481 | } |
482 | 482 | ||
483 | /** | 483 | /** |
484 | * | 484 | * |
485 | * @internal | 485 | * @internal |
486 | * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs | 486 | * Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs |
487 | */ | 487 | */ |
488 | void OGenericPluginLoader::setPluginDir( const QString& str) { | 488 | void OGenericPluginLoader::setPluginDir( const QString& str) { |
489 | m_plugDirs.clear(); | 489 | m_plugDirs.clear(); |
490 | m_plugDirs.append( str ); | 490 | m_plugDirs.append( str ); |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | /** | 494 | /** |
495 | * @internal | 495 | * @internal |
496 | */ | 496 | */ |
497 | bool OGenericPluginLoader::isSorted()const{ | 497 | bool OGenericPluginLoader::isSorted()const{ |
498 | return m_isSorted; | 498 | return m_isSorted; |
499 | } | 499 | } |
500 | 500 | ||
501 | /* | 501 | /* |
502 | * make libfoo.so.1.0.0 -> foo on UNIX | 502 | * make libfoo.so.1.0.0 -> foo on UNIX |
503 | * make libfoo.dylib -> foo on MAC OS X Unix | 503 | * make libfoo.dylib -> foo on MAC OS X Unix |
504 | * windows is obviously missing | 504 | * windows is obviously missing |
505 | */ | 505 | */ |
506 | /** | 506 | /** |
507 | * @internal | 507 | * @internal |
508 | */ | 508 | */ |
509 | QString OGenericPluginLoader::unlibify( const QString& str ) { | 509 | QString OGenericPluginLoader::unlibify( const QString& str ) { |
510 | QString st = str.mid( str.find( "lib" )+3 ); | 510 | QString st = str.mid( str.find( "lib" )+3 ); |
511 | #ifdef Q_OS_MACX | 511 | #ifdef Q_OS_MACX |
512 | return st.left( st.findRev( ".dylib" ) ); | 512 | return st.left( st.findRev( ".dylib" ) ); |
513 | #else | 513 | #else |
514 | return st.left( st.findRev( ".so" ) ); | 514 | return st.left( st.findRev( ".so" ) ); |
515 | #endif | 515 | #endif |
516 | } | 516 | } |
517 | 517 | ||
518 | /** | 518 | /** |
519 | * @internal | 519 | * @internal |
520 | * | 520 | * |
521 | * \brief method to return available plugins. Internal and for reeimplementations | 521 | * \brief method to return available plugins. Internal and for reeimplementations |
522 | * | 522 | * |
523 | *Return a List of Plugins for a dir and add positions and remove disabled. | 523 | *Return a List of Plugins for a dir and add positions and remove disabled. |
524 | * If a plugin is on the excluded list assign position -2 | 524 | * If a plugin is on the excluded list assign position -2 |
525 | * | 525 | * |
526 | * @param _dir The dir to look in | 526 | * @param _dir The dir to look in |
527 | * @param sorted Should positions be read? | 527 | * @param sorted Should positions be read? |
528 | * @param disabled Remove excluded from the list | 528 | * @param disabled Remove excluded from the list |
529 | */ | 529 | */ |
530 | OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const { | 530 | OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const { |
531 | #ifdef Q_OS_MACX | 531 | #ifdef Q_OS_MACX |
532 | QDir dir( _dir, "lib*.dylib" ); | 532 | QDir dir( _dir, "lib*.dylib" ); |
533 | #else | 533 | #else |
534 | QDir dir( _dir, "lib*.so" ); | 534 | QDir dir( _dir, "lib*.so" ); |
535 | #endif | 535 | #endif |
536 | 536 | ||
537 | 537 | ||
538 | OPluginItem::List lst; | 538 | OPluginItem::List lst; |
539 | 539 | ||
540 | /* | 540 | /* |
541 | * get excluded list and then iterate over them | 541 | * get excluded list and then iterate over them |
542 | * Excluded list contains the name | 542 | * Excluded list contains the name |
543 | * Position is a list with 'name.pos.name.pos.name.pos' | 543 | * Position is a list with 'name.pos.name.pos.name.pos' |
544 | * | 544 | * |
545 | * For the look up we will create two QMap<QString,pos> | 545 | * For the look up we will create two QMap<QString,pos> |
546 | */ | 546 | */ |
547 | QMap<QString, int> positionMap; | 547 | QMap<QString, int> positionMap; |
548 | QMap<QString, int> excludedMap; | 548 | QMap<QString, int> excludedMap; |
549 | 549 | ||
550 | 550 | ||
551 | OConfig cfg( m_dir+"-odpplugins" ); | 551 | OConfig cfg( m_dir+"-odpplugins" ); |
552 | cfg.setGroup( _dir ); | 552 | cfg.setGroup( _dir ); |
553 | 553 | ||
554 | 554 | ||
555 | QStringList excludes = cfg.readListEntry( "Excluded", ',' ); | 555 | QStringList excludes = cfg.readListEntry( "Excluded", ',' ); |
556 | for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) | 556 | for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it ) |
557 | excludedMap.insert( *it, -2 ); | 557 | excludedMap.insert( *it, -2 ); |
558 | 558 | ||
559 | if ( sorted ) { | 559 | if ( sorted ) { |
560 | QStringList pos = cfg.readListEntry( "Positions", '.' ); | 560 | QStringList pos = cfg.readListEntry( "Positions", '.' ); |
561 | QStringList::Iterator it = pos.begin(); | 561 | QStringList::Iterator it = pos.begin(); |
562 | QString tmp; int i; | 562 | QString tmp; int i; |
563 | while ( it != pos.end() ) { | 563 | while ( it != pos.end() ) { |
564 | tmp = *it++; i = (*it++).toInt(); | 564 | tmp = *it++; i = (*it++).toInt(); |
565 | positionMap.insert( tmp, i ); | 565 | positionMap.insert( tmp, i ); |
566 | } | 566 | } |
567 | 567 | ||
568 | } | 568 | } |
569 | 569 | ||
570 | 570 | ||
571 | 571 | ||
572 | 572 | ||
573 | QStringList list = dir.entryList(); | 573 | QStringList list = dir.entryList(); |
574 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 574 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
575 | QString str = unlibify( *it ); | 575 | QString str = unlibify( *it ); |
576 | OPluginItem item( str, _dir + "/" + *it ); | 576 | OPluginItem item( str, _dir + "/" + *it ); |
577 | 577 | ||
578 | bool ex = excludedMap.contains( str ); | 578 | bool ex = excludedMap.contains( str ); |
579 | /* | 579 | /* |
580 | * if disabled but we should show all mark it as disabled | 580 | * if disabled but we should show all mark it as disabled |
581 | * else continue because we don't want to add the item | 581 | * else continue because we don't want to add the item |
582 | * else if sorted we assign the right position | 582 | * else if sorted we assign the right position |
583 | */ | 583 | */ |
584 | if ( ex && !disabled) | 584 | if ( ex && !disabled) |
585 | item.setEnabled( false ); | 585 | item.setEnabled( false ); |
586 | else if ( ex && disabled ) | 586 | else if ( ex && disabled ) |
587 | continue; | 587 | continue; |
588 | else if ( sorted ) | 588 | else if ( sorted ) |
589 | item.setPosition( positionMap[str] ); | 589 | item.setPosition( positionMap[str] ); |
590 | 590 | ||
591 | 591 | ||
592 | lst.append( item ); | 592 | lst.append( item ); |
593 | } | 593 | } |
594 | 594 | ||
595 | return lst; | 595 | return lst; |
596 | } | 596 | } |
597 | 597 | ||
598 | /** | 598 | /** |
599 | * @internal generate a list of languages from $LANG | 599 | * @internal generate a list of languages from $LANG |
600 | */ | 600 | */ |
601 | QStringList OGenericPluginLoader::languageList() { | 601 | QStringList OGenericPluginLoader::languageList() { |
602 | if ( m_languages.isEmpty() ) { | 602 | if ( m_languages.isEmpty() ) { |
603 | /* | 603 | /* |
604 | * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be | 604 | * be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be |
605 | * to our list of languages. | 605 | * to our list of languages. |
606 | * Also for de_DE@euro we will add de_DE@eurp, de_DE, de | 606 | * Also for de_DE@euro we will add de_DE@eurp, de_DE, de |
607 | * to our list of languages | 607 | * to our list of languages |
608 | */ | 608 | */ |
609 | QString str = ::getenv( "LANG" ); | 609 | QString str = ::getenv( "LANG" ); |
610 | m_languages += str; | 610 | m_languages += str; |
611 | int pos = str.find( '@' ); | 611 | int pos = str.find( '@' ); |
612 | if( pos > 0 ) | 612 | if( pos > 0 ) |
613 | m_languages += str.left( pos ); | 613 | m_languages += str.left( pos ); |
614 | 614 | ||
615 | 615 | ||
616 | pos = str.find( '.' ); | 616 | pos = str.find( '.' ); |
617 | if ( pos > 0 ) | 617 | if ( pos > 0 ) |
618 | m_languages += str.left( pos ); | 618 | m_languages += str.left( pos ); |
619 | 619 | ||
620 | int n_pos = str.find( '_' ); | 620 | int n_pos = str.find( '_' ); |
621 | if ( n_pos > 0 ) | 621 | if ( n_pos > 0 ) |
622 | m_languages += str.left( n_pos ); | 622 | m_languages += str.left( n_pos ); |
623 | 623 | ||
624 | } | 624 | } |
625 | return m_languages; | 625 | return m_languages; |
626 | } | 626 | } |
627 | 627 | ||
628 | /** | 628 | /** |
629 | * @internal | 629 | * @internal |
630 | * Tries to install languages using the languageList for the type | 630 | * Tries to install languages using the languageList for the type |
631 | */ | 631 | */ |
632 | void OGenericPluginLoader::installTranslators(const QString& type) { | 632 | void OGenericPluginLoader::installTranslators(const QString& type) { |
633 | QStringList lst = languageList(); | 633 | QStringList lst = languageList(); |
634 | 634 | ||
635 | /* | 635 | /* |
636 | * for each language and maybe later for each language dir... | 636 | * for each language and maybe later for each language dir... |
637 | * try to load a Translator | 637 | * try to load a Translator |
638 | */ | 638 | */ |
639 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 639 | for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
640 | QTranslator* trans = new QTranslator( qApp ); | 640 | QTranslator* trans = new QTranslator( qApp ); |
641 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/lib" + type + ".qm" ; | 641 | QString tfn = QPEApplication::qpeDir()+"i18n/" + *it + "/lib" + type + ".qm" ; |
642 | 642 | ||
643 | /* | 643 | /* |
644 | * If loaded then install else clean up and don't leak | 644 | * If loaded then install else clean up and don't leak |
645 | */ | 645 | */ |
646 | if ( trans->load( tfn ) ) | 646 | if ( trans->load( tfn ) ) |
647 | qApp->installTranslator( trans ); | 647 | qApp->installTranslator( trans ); |
648 | else | 648 | else |
649 | delete trans; | 649 | delete trans; |
650 | } | 650 | } |
651 | } | 651 | } |
652 | 652 | ||
653 | /** | 653 | /** |
654 | * \brief Simple c'tor. | 654 | * \brief Simple c'tor. |
655 | * | 655 | * |
656 | * Simple C'tor same as the one of the base class. Additional this | 656 | * Simple C'tor same as the one of the base class. Additional this |
657 | * class can cast for you if you nee it. | 657 | * class can cast for you if you nee it. |
658 | * | 658 | * |
659 | * | 659 | * |
660 | * @param name The name of your plugin class | 660 | * @param name The name of your plugin class |
661 | * @param sorted If plugins are sorted | 661 | * @param sorted If plugins are sorted |
662 | * | 662 | * |
663 | * @see OGenericPluginLoader | 663 | * @see OGenericPluginLoader |
664 | */ | 664 | */ |
665 | OPluginLoader::OPluginLoader( const QString& name, bool sorted ) | 665 | OPluginLoader::OPluginLoader( const QString& name, bool sorted ) |
666 | : OGenericPluginLoader( name, sorted ) | 666 | : OGenericPluginLoader( name, sorted ) |
667 | { | 667 | { |
668 | } | 668 | } |
669 | 669 | ||
670 | /** | 670 | /** |
671 | * d'tor | 671 | * d'tor |
672 | * @see OGenericPluginLoader::~OGenericPluginLoader | 672 | * @see OGenericPluginLoader::~OGenericPluginLoader |
673 | */ | 673 | */ |
674 | OPluginLoader::~OPluginLoader() { | 674 | OPluginLoader::~OPluginLoader() { |
675 | } | 675 | } |
676 | 676 | ||
677 | /** | 677 | /** |
678 | * \brief C'Tor using a OGenericPluginLoader | 678 | * \brief C'Tor using a OGenericPluginLoader |
679 | * The C'tor. Pass your OGenericPluginLoader to manage | 679 | * The C'tor. Pass your OGenericPluginLoader to manage |
680 | * OGenericPluginLoader::allAvailable plugins. | 680 | * OGenericPluginLoader::allAvailable plugins. |
681 | * | 681 | * |
682 | * | 682 | * |
683 | * @param loader A Pointer to your OGenericPluginLoader | 683 | * @param loader A Pointer to your OGenericPluginLoader |
684 | */ | 684 | */ |
685 | OPluginManager::OPluginManager( OGenericPluginLoader* loader) | 685 | OPluginManager::OPluginManager( OGenericPluginLoader* loader) |
686 | : m_loader( loader ), m_isSorted( false ) | 686 | : m_loader( loader ), m_isSorted( false ) |
687 | { | 687 | { |
688 | } | 688 | } |
689 | 689 | ||
690 | /** | 690 | /** |
691 | * \brief Overloaded c'tor using a List of Plugins and a type name | 691 | * \brief Overloaded c'tor using a List of Plugins and a type name |
692 | * Overloaded Constructor to work with a 'Type' of plugins | 692 | * Overloaded Constructor to work with a 'Type' of plugins |
693 | * and a correspending list of those. In this case calling load | 693 | * and a correspending list of those. In this case calling load |
694 | * is a no operation. | 694 | * is a no operation. |
695 | * | 695 | * |
696 | * @param name The name of your plugin ('today','inputmethods','applets') | 696 | * @param name The name of your plugin ('today','inputmethods','applets') |
697 | * @param lst A List with plugins of your type to manage | 697 | * @param lst A List with plugins of your type to manage |
698 | * @param isSorted If the List should be treated sorted | 698 | * @param isSorted If the List should be treated sorted |
699 | */ | 699 | */ |
700 | OPluginManager::OPluginManager( const QString& name, const OPluginItem::List& lst, bool isSorted) | 700 | OPluginManager::OPluginManager( const QString& name, const OPluginItem::List& lst, bool isSorted) |
701 | : m_loader( 0l ), m_cfgName( name ), m_plugins( lst ), m_isSorted( isSorted ) | 701 | : m_loader( 0l ), m_cfgName( name ), m_plugins( lst ), m_isSorted( isSorted ) |
702 | { | 702 | { |
703 | } | 703 | } |
704 | 704 | ||
705 | /** | 705 | /** |
706 | * \brief A simple d'tor | 706 | * \brief A simple d'tor |
707 | */ | 707 | */ |
708 | OPluginManager::~OPluginManager() { | 708 | OPluginManager::~OPluginManager() { |
709 | } | 709 | } |
710 | 710 | ||
711 | /** | 711 | /** |
712 | * \brief Return the OPluginItem where loading is likely to have crashed on. | 712 | * \brief Return the OPluginItem where loading is likely to have crashed on. |
713 | 713 | ||
714 | * Return the Item that made the OGenericPluginLoader crash | 714 | * Return the Item that made the OGenericPluginLoader crash |
715 | * the returned OPluginItem could be empty if no crash occured | 715 | * the returned OPluginItem could be empty if no crash occured |
716 | * which should apply most of the time. It could also be empty if the crashed | 716 | * which should apply most of the time. It could also be empty if the crashed |
717 | * plugin is not in the current list of available/managed plugins | 717 | * plugin is not in the current list of available/managed plugins |
718 | * | 718 | * |
719 | * @see OPluginItem::isEmpty | 719 | * @see OPluginItem::isEmpty |
720 | * @return OPluginItem that crashed the loader | 720 | * @return OPluginItem that crashed the loader |
721 | */ | 721 | */ |
722 | OPluginItem OPluginManager::crashedPlugin()const { | 722 | OPluginItem OPluginManager::crashedPlugin()const { |
723 | return m_crashed; | 723 | return m_crashed; |
724 | } | 724 | } |
725 | 725 | ||
726 | /** | 726 | /** |
727 | * \brief Return a list of plugins that are managed by this OPluginManager | 727 | * \brief Return a list of plugins that are managed by this OPluginManager |
728 | * | 728 | * |
729 | * Return the list of managed plugins. This could either result | 729 | * Return the list of managed plugins. This could either result |
730 | * from passing a OGenericPluginLoader and calling load or by | 730 | * from passing a OGenericPluginLoader and calling load or by |
731 | * giving name and a list of plugins. | 731 | * giving name and a list of plugins. |
732 | */ | 732 | */ |
733 | OPluginItem::List OPluginManager::managedPlugins()const { | 733 | OPluginItem::List OPluginManager::managedPlugins()const { |
734 | return m_plugins; | 734 | return m_plugins; |
735 | } | 735 | } |
736 | 736 | ||
737 | /** | 737 | /** |
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp index 32bae0a..7e185a2 100644 --- a/libopie2/opienet/omanufacturerdb.cpp +++ b/libopie2/opienet/omanufacturerdb.cpp | |||
@@ -1,143 +1,143 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "omanufacturerdb.h" | 29 | #include "omanufacturerdb.h" |
30 | 30 | ||
31 | #define OPIE_IMPROVE_GUI_LATENCY 1 | 31 | #define OPIE_IMPROVE_GUI_LATENCY 1 |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 36 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | /* QT */ | 42 | /* QT */ |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | #include <qfile.h> | 44 | #include <qfile.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | using namespace Opie::Core; | 47 | using namespace Opie::Core; |
48 | namespace Opie { | 48 | namespace Opie { |
49 | namespace Net { | 49 | namespace Net { |
50 | 50 | ||
51 | OManufacturerDB* OManufacturerDB::_instance = 0; | 51 | OManufacturerDB* OManufacturerDB::_instance = 0; |
52 | 52 | ||
53 | OManufacturerDB* OManufacturerDB::instance() | 53 | OManufacturerDB* OManufacturerDB::instance() |
54 | { | 54 | { |
55 | if ( !OManufacturerDB::_instance ) | 55 | if ( !OManufacturerDB::_instance ) |
56 | { | 56 | { |
57 | odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; | 57 | odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; |
58 | _instance = new OManufacturerDB(); | 58 | _instance = new OManufacturerDB(); |
59 | } | 59 | } |
60 | return _instance; | 60 | return _instance; |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | OManufacturerDB::OManufacturerDB() | 64 | OManufacturerDB::OManufacturerDB() |
65 | { | 65 | { |
66 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 66 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
67 | Global::statusMessage( "Reading Manufacturers..." ); | 67 | Global::statusMessage( "Reading Manufacturers..." ); |
68 | #endif | 68 | #endif |
69 | QString filename( "/etc/manufacturers" ); | 69 | QString filename( "/etc/manufacturers" ); |
70 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 70 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
71 | if ( !QFile::exists( filename ) ) | 71 | if ( !QFile::exists( filename ) ) |
72 | { | 72 | { |
73 | filename = QPEApplication::qpeDir()+"/etc/manufacturers"; | 73 | filename = QPEApplication::qpeDir()+"etc/manufacturers"; |
74 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 74 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
75 | if ( !QFile::exists( filename ) ) | 75 | if ( !QFile::exists( filename ) ) |
76 | { | 76 | { |
77 | filename = "/usr/share/wellenreiter/manufacturers"; | 77 | filename = "/usr/share/wellenreiter/manufacturers"; |
78 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 78 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | QFile file( filename ); | 82 | QFile file( filename ); |
83 | bool hasFile = file.open( IO_ReadOnly ); | 83 | bool hasFile = file.open( IO_ReadOnly ); |
84 | if (!hasFile) | 84 | if (!hasFile) |
85 | { | 85 | { |
86 | owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; | 86 | owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; |
87 | } | 87 | } |
88 | else | 88 | else |
89 | { | 89 | { |
90 | odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; | 90 | odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; |
91 | QTextStream s( &file ); | 91 | QTextStream s( &file ); |
92 | QString addr; | 92 | QString addr; |
93 | QString manu; | 93 | QString manu; |
94 | QString extManu; | 94 | QString extManu; |
95 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 95 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
96 | int counter = 0; | 96 | int counter = 0; |
97 | #endif | 97 | #endif |
98 | while (!s.atEnd()) | 98 | while (!s.atEnd()) |
99 | { | 99 | { |
100 | s >> addr; | 100 | s >> addr; |
101 | s >> manu; | 101 | s >> manu; |
102 | s >> extManu; | 102 | s >> extManu; |
103 | 103 | ||
104 | manufacturers.insert( addr, manu ); | 104 | manufacturers.insert( addr, manu ); |
105 | manufacturersExt.insert( addr, extManu ); | 105 | manufacturersExt.insert( addr, extManu ); |
106 | // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; | 106 | // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; |
107 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 107 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
108 | counter++; | 108 | counter++; |
109 | if ( counter == 50 ) | 109 | if ( counter == 50 ) |
110 | { | 110 | { |
111 | qApp->processEvents(); | 111 | qApp->processEvents(); |
112 | counter = 0; | 112 | counter = 0; |
113 | } | 113 | } |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | odebug << "OManufacturerDB: manufacturer list completed." << oendl; | 116 | odebug << "OManufacturerDB: manufacturer list completed." << oendl; |
117 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 117 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
118 | Global::statusMessage( "Manufacturers Complete..." ); | 118 | Global::statusMessage( "Manufacturers Complete..." ); |
119 | #endif | 119 | #endif |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | OManufacturerDB::~OManufacturerDB() | 124 | OManufacturerDB::~OManufacturerDB() |
125 | { | 125 | { |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const | 129 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const |
130 | { | 130 | { |
131 | return manufacturers[macaddr.upper().left(8)]; | 131 | return manufacturers[macaddr.upper().left(8)]; |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const | 135 | const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const |
136 | { | 136 | { |
137 | QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); | 137 | QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); |
138 | return it == manufacturersExt.end() ? lookup( macaddr ) : *it; | 138 | return it == manufacturersExt.end() ? lookup( macaddr ) : *it; |
139 | } | 139 | } |
140 | 140 | ||
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
diff --git a/libopie2/opiesecurity/multiauthcommon.cpp b/libopie2/opiesecurity/multiauthcommon.cpp index 9de62d2..e563193 100644 --- a/libopie2/opiesecurity/multiauthcommon.cpp +++ b/libopie2/opiesecurity/multiauthcommon.cpp | |||
@@ -1,188 +1,188 @@ | |||
1 | #include "multiauthplugininterface.h" | 1 | #include "multiauthplugininterface.h" |
2 | #include "multiauthcommon.h" | 2 | #include "multiauthcommon.h" |
3 | 3 | ||
4 | /* Opie */ | 4 | /* Opie */ |
5 | #include <opie2/odebug.h> | 5 | #include <opie2/odebug.h> |
6 | #include <opie2/oapplication.h> | 6 | #include <opie2/oapplication.h> |
7 | 7 | ||
8 | /* Qt */ | 8 | /* Qt */ |
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | #include <qpe/qlibrary.h> | 10 | #include <qpe/qlibrary.h> |
11 | #include <qpe/qcom.h> | 11 | #include <qpe/qcom.h> |
12 | #include <qtextview.h> | 12 | #include <qtextview.h> |
13 | #include <qdir.h> | 13 | #include <qdir.h> |
14 | 14 | ||
15 | /* UNIX */ | 15 | /* UNIX */ |
16 | #include <unistd.h> | 16 | #include <unistd.h> |
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | 18 | ||
19 | namespace Opie { | 19 | namespace Opie { |
20 | namespace Security { | 20 | namespace Security { |
21 | 21 | ||
22 | SecOwnerDlg::SecOwnerDlg( QWidget *parent, const char * name, Contact c, | 22 | SecOwnerDlg::SecOwnerDlg( QWidget *parent, const char * name, Contact c, |
23 | bool modal, bool fullscreen = FALSE ) | 23 | bool modal, bool fullscreen = FALSE ) |
24 | : QDialog( parent, name, modal, | 24 | : QDialog( parent, name, modal, |
25 | fullscreen ? | 25 | fullscreen ? |
26 | WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 ) | 26 | WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop : 0 ) |
27 | { | 27 | { |
28 | if ( fullscreen ) { | 28 | if ( fullscreen ) { |
29 | QRect desk = qApp->desktop()->geometry(); | 29 | QRect desk = qApp->desktop()->geometry(); |
30 | setGeometry( 0, 0, desk.width(), desk.height() ); | 30 | setGeometry( 0, 0, desk.width(), desk.height() ); |
31 | } | 31 | } |
32 | // set up contents. | 32 | // set up contents. |
33 | QString text("<H3>" + tr("Please contact the owner (directions follow), or try again clicking of this screen (and waiting for the penalty time) if you are the legitimate owner") + "</H3>"); | 33 | QString text("<H3>" + tr("Please contact the owner (directions follow), or try again clicking of this screen (and waiting for the penalty time) if you are the legitimate owner") + "</H3>"); |
34 | text += c.toRichText(); | 34 | text += c.toRichText(); |
35 | tv = new QTextView(this); | 35 | tv = new QTextView(this); |
36 | tv->setText(text); | 36 | tv->setText(text); |
37 | 37 | ||
38 | tv->viewport()->installEventFilter(this); | 38 | tv->viewport()->installEventFilter(this); |
39 | } | 39 | } |
40 | 40 | ||
41 | void SecOwnerDlg::resizeEvent( QResizeEvent * ) | 41 | void SecOwnerDlg::resizeEvent( QResizeEvent * ) |
42 | { | 42 | { |
43 | tv->resize( size() ); | 43 | tv->resize( size() ); |
44 | } | 44 | } |
45 | 45 | ||
46 | bool SecOwnerDlg::eventFilter(QObject *o, QEvent *e) | 46 | bool SecOwnerDlg::eventFilter(QObject *o, QEvent *e) |
47 | { | 47 | { |
48 | if (e->type() == QEvent::KeyPress || e->type() == QEvent::MouseButtonPress ) { | 48 | if (e->type() == QEvent::KeyPress || e->type() == QEvent::MouseButtonPress ) { |
49 | accept(); | 49 | accept(); |
50 | return TRUE; | 50 | return TRUE; |
51 | } | 51 | } |
52 | return QWidget::eventFilter(o, e); | 52 | return QWidget::eventFilter(o, e); |
53 | } | 53 | } |
54 | 54 | ||
55 | void SecOwnerDlg::mousePressEvent( QMouseEvent * ) { accept(); } | 55 | void SecOwnerDlg::mousePressEvent( QMouseEvent * ) { accept(); } |
56 | 56 | ||
57 | 57 | ||
58 | namespace Internal { | 58 | namespace Internal { |
59 | /// run plugins until we reach nbSuccessMin successes | 59 | /// run plugins until we reach nbSuccessMin successes |
60 | int runPlugins() { | 60 | int runPlugins() { |
61 | 61 | ||
62 | SecOwnerDlg *oi = 0; | 62 | SecOwnerDlg *oi = 0; |
63 | // see if there is contact information. | 63 | // see if there is contact information. |
64 | QString vfilename = Global::applicationFileName("addressbook", | 64 | QString vfilename = Global::applicationFileName("addressbook", |
65 | "businesscard.vcf"); | 65 | "businesscard.vcf"); |
66 | if (QFile::exists(vfilename)) { | 66 | if (QFile::exists(vfilename)) { |
67 | Contact c; | 67 | Contact c; |
68 | c = Contact::readVCard( vfilename )[0]; | 68 | c = Contact::readVCard( vfilename )[0]; |
69 | 69 | ||
70 | oi = new SecOwnerDlg(0, 0, c, TRUE, TRUE); | 70 | oi = new SecOwnerDlg(0, 0, c, TRUE, TRUE); |
71 | } | 71 | } |
72 | 72 | ||
73 | Config config("Security"); | 73 | Config config("Security"); |
74 | config.setGroup("Plugins"); | 74 | config.setGroup("Plugins"); |
75 | QStringList plugins = config.readListEntry("IncludePlugins", ','); | 75 | QStringList plugins = config.readListEntry("IncludePlugins", ','); |
76 | /* if there are no configured plugins, we simply return 0 to | 76 | /* if there are no configured plugins, we simply return 0 to |
77 | * let the user in: | 77 | * let the user in: |
78 | */ | 78 | */ |
79 | if (plugins.isEmpty() == true) { | 79 | if (plugins.isEmpty() == true) { |
80 | owarn << "No authentication plugin has been configured yet!" << oendl; | 80 | owarn << "No authentication plugin has been configured yet!" << oendl; |
81 | odebug << "Letting the user in..." << oendl; | 81 | odebug << "Letting the user in..." << oendl; |
82 | if(oi) delete oi; | 82 | if(oi) delete oi; |
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
85 | config.setGroup("Misc"); | 85 | config.setGroup("Misc"); |
86 | int nbSuccessMin = config.readNumEntry("nbSuccessMin", 1); | 86 | int nbSuccessMin = config.readNumEntry("nbSuccessMin", 1); |
87 | int nbSuccess = 0; | 87 | int nbSuccess = 0; |
88 | 88 | ||
89 | /* tries to launch successively each plugin in $OPIEDIR/plugins/security | 89 | /* tries to launch successively each plugin in $OPIEDIR/plugins/security |
90 | * directory which file name is in Security.conf / [Misc] / IncludePlugins | 90 | * directory which file name is in Security.conf / [Misc] / IncludePlugins |
91 | */ | 91 | */ |
92 | QString path = QPEApplication::qpeDir() + "/plugins/security"; | 92 | QString path = QPEApplication::qpeDir() + "plugins/security"; |
93 | QStringList::Iterator libIt; | 93 | QStringList::Iterator libIt; |
94 | 94 | ||
95 | for ( libIt = plugins.begin(); libIt != plugins.end(); ++libIt ) { | 95 | for ( libIt = plugins.begin(); libIt != plugins.end(); ++libIt ) { |
96 | QInterfacePtr<MultiauthPluginInterface> iface; | 96 | QInterfacePtr<MultiauthPluginInterface> iface; |
97 | QLibrary *lib = new QLibrary( path + "/" + *libIt ); | 97 | QLibrary *lib = new QLibrary( path + "/" + *libIt ); |
98 | 98 | ||
99 | if ( lib->queryInterface( | 99 | if ( lib->queryInterface( |
100 | IID_MultiauthPluginInterface, | 100 | IID_MultiauthPluginInterface, |
101 | (QUnknownInterface**)&iface ) == QS_OK ) | 101 | (QUnknownInterface**)&iface ) == QS_OK ) |
102 | { | 102 | { |
103 | // the plugin is a true Multiauth plugin | 103 | // the plugin is a true Multiauth plugin |
104 | odebug << "Accepted plugin: " << QString( path + "/" + *libIt ) << oendl; | 104 | odebug << "Accepted plugin: " << QString( path + "/" + *libIt ) << oendl; |
105 | odebug << "Plugin name: " << iface->plugin()->pluginName() << oendl; | 105 | odebug << "Plugin name: " << iface->plugin()->pluginName() << oendl; |
106 | 106 | ||
107 | int resultCode; | 107 | int resultCode; |
108 | int tries = 0; | 108 | int tries = 0; |
109 | 109 | ||
110 | // perform authentication | 110 | // perform authentication |
111 | resultCode = iface->plugin()->authenticate(); | 111 | resultCode = iface->plugin()->authenticate(); |
112 | 112 | ||
113 | // display the result in command line | 113 | // display the result in command line |
114 | QString resultMessage; | 114 | QString resultMessage; |
115 | switch (resultCode) | 115 | switch (resultCode) |
116 | { | 116 | { |
117 | case MultiauthPluginObject::Success: | 117 | case MultiauthPluginObject::Success: |
118 | resultMessage = "Success!"; | 118 | resultMessage = "Success!"; |
119 | nbSuccess++; | 119 | nbSuccess++; |
120 | break; | 120 | break; |
121 | case MultiauthPluginObject::Failure: | 121 | case MultiauthPluginObject::Failure: |
122 | resultMessage = "Failure..."; | 122 | resultMessage = "Failure..."; |
123 | break; | 123 | break; |
124 | case MultiauthPluginObject::Skip: | 124 | case MultiauthPluginObject::Skip: |
125 | resultMessage = "Skip"; | 125 | resultMessage = "Skip"; |
126 | break; | 126 | break; |
127 | } | 127 | } |
128 | odebug << "Plugin result: " << resultMessage << oendl; | 128 | odebug << "Plugin result: " << resultMessage << oendl; |
129 | 129 | ||
130 | // if failure, wait, reperform, wait, reperform... until right | 130 | // if failure, wait, reperform, wait, reperform... until right |
131 | while (resultCode == MultiauthPluginObject::Failure) | 131 | while (resultCode == MultiauthPluginObject::Failure) |
132 | { | 132 | { |
133 | tries++; | 133 | tries++; |
134 | owarn << "This plugin has failed " << tries << " times already" << oendl; | 134 | owarn << "This plugin has failed " << tries << " times already" << oendl; |
135 | 135 | ||
136 | // displays owner information, if any | 136 | // displays owner information, if any |
137 | if (oi) | 137 | if (oi) |
138 | { | 138 | { |
139 | oi->exec(); | 139 | oi->exec(); |
140 | odebug << "Contact information displayed" << oendl; | 140 | odebug << "Contact information displayed" << oendl; |
141 | } | 141 | } |
142 | 142 | ||
143 | /// \todo parametrize the time penalty according to \em mode (exponential, | 143 | /// \todo parametrize the time penalty according to \em mode (exponential, |
144 | /// linear or fixed) and \em basetime (time penalty for the first failure) | 144 | /// linear or fixed) and \em basetime (time penalty for the first failure) |
145 | sleep(2 * tries); | 145 | sleep(2 * tries); |
146 | 146 | ||
147 | if (oi) | 147 | if (oi) |
148 | { | 148 | { |
149 | oi->hide(); | 149 | oi->hide(); |
150 | /** \todo fix the focus here: should go back to the current plugin widget | 150 | /** \todo fix the focus here: should go back to the current plugin widget |
151 | * but it doesn't, so we have to tap once on the widget before e.g. buttons | 151 | * but it doesn't, so we have to tap once on the widget before e.g. buttons |
152 | * are active again | 152 | * are active again |
153 | */ | 153 | */ |
154 | odebug << "Contact information hidden" << oendl; | 154 | odebug << "Contact information hidden" << oendl; |
155 | } | 155 | } |
156 | 156 | ||
157 | // perform authentication | 157 | // perform authentication |
158 | resultCode = iface->plugin()->authenticate(); | 158 | resultCode = iface->plugin()->authenticate(); |
159 | 159 | ||
160 | // display the result in command line | 160 | // display the result in command line |
161 | switch (resultCode) | 161 | switch (resultCode) |
162 | { | 162 | { |
163 | case MultiauthPluginObject::Success: | 163 | case MultiauthPluginObject::Success: |
164 | resultMessage = "Success!"; | 164 | resultMessage = "Success!"; |
165 | nbSuccess++; | 165 | nbSuccess++; |
166 | break; | 166 | break; |
167 | case MultiauthPluginObject::Failure: | 167 | case MultiauthPluginObject::Failure: |
168 | resultMessage = "Failure..."; | 168 | resultMessage = "Failure..."; |
169 | break; | 169 | break; |
170 | case MultiauthPluginObject::Skip: | 170 | case MultiauthPluginObject::Skip: |
171 | resultMessage = "Skip"; | 171 | resultMessage = "Skip"; |
172 | break; | 172 | break; |
173 | } | 173 | } |
174 | odebug << "Plugin result: " << resultMessage << oendl; | 174 | odebug << "Plugin result: " << resultMessage << oendl; |
175 | } | 175 | } |
176 | delete lib; | 176 | delete lib; |
177 | 177 | ||
178 | if (resultCode == MultiauthPluginObject::Success && nbSuccess == nbSuccessMin) | 178 | if (resultCode == MultiauthPluginObject::Success && nbSuccess == nbSuccessMin) |
179 | { | 179 | { |
180 | if(oi) delete oi; | 180 | if(oi) delete oi; |
181 | // we have reached the required number of successes, we can exit the plugin loop | 181 | // we have reached the required number of successes, we can exit the plugin loop |
182 | return 0; | 182 | return 0; |
183 | } | 183 | } |
184 | } else { | 184 | } else { |
185 | owarn << "Could not recognize plugin " << QString( path + "/" + *libIt ) << oendl; | 185 | owarn << "Could not recognize plugin " << QString( path + "/" + *libIt ) << oendl; |
186 | delete lib; | 186 | delete lib; |
187 | } // end if plugin recognized | 187 | } // end if plugin recognized |
188 | } //end for | 188 | } //end for |
diff --git a/library/fontdatabase.cpp b/library/fontdatabase.cpp index d94e338..7934a09 100644 --- a/library/fontdatabase.cpp +++ b/library/fontdatabase.cpp | |||
@@ -74,178 +74,178 @@ QValueList<FontFactory> *FontDatabase::factoryList = 0; | |||
74 | Constructs a FontDatabase object. | 74 | Constructs a FontDatabase object. |
75 | */ | 75 | */ |
76 | FontDatabase::FontDatabase() | 76 | FontDatabase::FontDatabase() |
77 | #ifndef QT_NO_FONTDATABASE | 77 | #ifndef QT_NO_FONTDATABASE |
78 | : QFontDatabase() | 78 | : QFontDatabase() |
79 | #endif | 79 | #endif |
80 | { | 80 | { |
81 | if ( !factoryList ) | 81 | if ( !factoryList ) |
82 | loadRenderers(); | 82 | loadRenderers(); |
83 | } | 83 | } |
84 | 84 | ||
85 | /*! | 85 | /*! |
86 | Returns a list of names of all the available font families. | 86 | Returns a list of names of all the available font families. |
87 | */ | 87 | */ |
88 | QStringList FontDatabase::families() const | 88 | QStringList FontDatabase::families() const |
89 | { | 89 | { |
90 | #ifndef QT_NO_FONTDATABASE | 90 | #ifndef QT_NO_FONTDATABASE |
91 | return QFontDatabase::families(); | 91 | return QFontDatabase::families(); |
92 | #else | 92 | #else |
93 | 93 | ||
94 | #ifndef QWS | 94 | #ifndef QWS |
95 | QStringList list; | 95 | QStringList list; |
96 | return list; | 96 | return list; |
97 | #else | 97 | #else |
98 | QStringList list; | 98 | QStringList list; |
99 | QDict<void> familyDict; | 99 | QDict<void> familyDict; |
100 | QDiskFont *qdf; | 100 | QDiskFont *qdf; |
101 | for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0; | 101 | for ( qdf=qt_fontmanager->diskfonts.first(); qdf!=0; |
102 | qdf=qt_fontmanager->diskfonts.next()) { | 102 | qdf=qt_fontmanager->diskfonts.next()) { |
103 | QString familyname = qdf->name; | 103 | QString familyname = qdf->name; |
104 | if ( !familyDict.find( familyname ) ) { | 104 | if ( !familyDict.find( familyname ) ) { |
105 | familyDict.insert( familyname, (void *)1 ); | 105 | familyDict.insert( familyname, (void *)1 ); |
106 | list.append( familyname ); | 106 | list.append( familyname ); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | QDir dir(fontDir(),"*.qpf"); | 110 | QDir dir(fontDir(),"*.qpf"); |
111 | for (int i=0; i<(int)dir.count(); i++) { | 111 | for (int i=0; i<(int)dir.count(); i++) { |
112 | QString familyname = fontFamily(dir[i]); | 112 | QString familyname = fontFamily(dir[i]); |
113 | if ( !familyDict.find( familyname ) ) { | 113 | if ( !familyDict.find( familyname ) ) { |
114 | familyDict.insert( familyname, (void *)1 ); | 114 | familyDict.insert( familyname, (void *)1 ); |
115 | list.append( familyname ); | 115 | list.append( familyname ); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | return list; | 119 | return list; |
120 | #endif | 120 | #endif |
121 | #endif | 121 | #endif |
122 | } | 122 | } |
123 | 123 | ||
124 | #ifdef QT_NO_FONTDATABASE | 124 | #ifdef QT_NO_FONTDATABASE |
125 | /*! | 125 | /*! |
126 | Returns a list of standard fontsizes. | 126 | Returns a list of standard fontsizes. |
127 | */ | 127 | */ |
128 | QValueList<int> FontDatabase::standardSizes() | 128 | QValueList<int> FontDatabase::standardSizes() |
129 | { | 129 | { |
130 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, | 130 | static int s[]={ 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, |
131 | 36, 48, 72, 0 }; | 131 | 36, 48, 72, 0 }; |
132 | static bool first = TRUE; | 132 | static bool first = TRUE; |
133 | static QValueList<int> sList; | 133 | static QValueList<int> sList; |
134 | if ( first ) { | 134 | if ( first ) { |
135 | first = FALSE; | 135 | first = FALSE; |
136 | int i = 0; | 136 | int i = 0; |
137 | while( s[i] ) | 137 | while( s[i] ) |
138 | sList.append( s[i++] ); | 138 | sList.append( s[i++] ); |
139 | } | 139 | } |
140 | return sList; | 140 | return sList; |
141 | } | 141 | } |
142 | 142 | ||
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | /*! | 145 | /*! |
146 | Load any font renderer plugins that are available and make the fonts | 146 | Load any font renderer plugins that are available and make the fonts |
147 | that the plugins can read available. | 147 | that the plugins can read available. |
148 | */ | 148 | */ |
149 | void FontDatabase::loadRenderers() | 149 | void FontDatabase::loadRenderers() |
150 | { | 150 | { |
151 | #ifndef QWS | 151 | #ifndef QWS |
152 | return; | 152 | return; |
153 | #else | 153 | #else |
154 | 154 | ||
155 | #ifndef QT_NO_COMPONENT | 155 | #ifndef QT_NO_COMPONENT |
156 | if ( !factoryList ) | 156 | if ( !factoryList ) |
157 | factoryList = new QValueList<FontFactory>; | 157 | factoryList = new QValueList<FontFactory>; |
158 | 158 | ||
159 | QValueList<FontFactory>::Iterator mit; | 159 | QValueList<FontFactory>::Iterator mit; |
160 | for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { | 160 | for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) { |
161 | qt_fontmanager->factories.setAutoDelete( false ); | 161 | qt_fontmanager->factories.setAutoDelete( false ); |
162 | qt_fontmanager->factories.removeRef( (*mit).factory ); | 162 | qt_fontmanager->factories.removeRef( (*mit).factory ); |
163 | qt_fontmanager->factories.setAutoDelete( true ); | 163 | qt_fontmanager->factories.setAutoDelete( true ); |
164 | (*mit).interface->release(); | 164 | (*mit).interface->release(); |
165 | (*mit).library->unload(); | 165 | (*mit).library->unload(); |
166 | delete (*mit).library; | 166 | delete (*mit).library; |
167 | } | 167 | } |
168 | factoryList->clear(); | 168 | factoryList->clear(); |
169 | 169 | ||
170 | QString path = QPEApplication::qpeDir() + "/plugins/fontfactories"; | 170 | QString path = QPEApplication::qpeDir() + "plugins/fontfactories"; |
171 | #ifdef Q_OS_MACX | 171 | #ifdef Q_OS_MACX |
172 | QDir dir( path, "lib*.dylib" ); | 172 | QDir dir( path, "lib*.dylib" ); |
173 | #else | 173 | #else |
174 | QDir dir( path, "lib*.so" ); | 174 | QDir dir( path, "lib*.so" ); |
175 | #endif | 175 | #endif |
176 | 176 | ||
177 | if ( !dir.exists()) | 177 | if ( !dir.exists()) |
178 | return; | 178 | return; |
179 | 179 | ||
180 | QStringList list = dir.entryList(); | 180 | QStringList list = dir.entryList(); |
181 | QStringList::Iterator it; | 181 | QStringList::Iterator it; |
182 | for ( it = list.begin(); it != list.end(); ++it ) { | 182 | for ( it = list.begin(); it != list.end(); ++it ) { |
183 | FontFactoryInterface *iface = 0; | 183 | FontFactoryInterface *iface = 0; |
184 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 184 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
185 | if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { | 185 | if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) { |
186 | FontFactory factory; | 186 | FontFactory factory; |
187 | factory.library = lib; | 187 | factory.library = lib; |
188 | factory.interface = iface; | 188 | factory.interface = iface; |
189 | factory.factory = factory.interface->fontFactory(); | 189 | factory.factory = factory.interface->fontFactory(); |
190 | factoryList->append( factory ); | 190 | factoryList->append( factory ); |
191 | qt_fontmanager->factories.append( factory.factory ); | 191 | qt_fontmanager->factories.append( factory.factory ); |
192 | readFonts( factory.factory ); | 192 | readFonts( factory.factory ); |
193 | } else { | 193 | } else { |
194 | delete lib; | 194 | delete lib; |
195 | } | 195 | } |
196 | } | 196 | } |
197 | #endif | 197 | #endif |
198 | #endif | 198 | #endif |
199 | } | 199 | } |
200 | 200 | ||
201 | /*! | 201 | /*! |
202 | \internal | 202 | \internal |
203 | */ | 203 | */ |
204 | void FontDatabase::readFonts( QFontFactory *factory ) | 204 | void FontDatabase::readFonts( QFontFactory *factory ) |
205 | { | 205 | { |
206 | #ifndef QWS | 206 | #ifndef QWS |
207 | return; | 207 | return; |
208 | #else | 208 | #else |
209 | // Load in font definition file | 209 | // Load in font definition file |
210 | QString fn = fontDir() + "fontdir"; | 210 | QString fn = fontDir() + "fontdir"; |
211 | FILE* fontdef=fopen(fn.local8Bit(),"r"); | 211 | FILE* fontdef=fopen(fn.local8Bit(),"r"); |
212 | if(!fontdef) { | 212 | if(!fontdef) { |
213 | QCString temp=fn.local8Bit(); | 213 | QCString temp=fn.local8Bit(); |
214 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", | 214 | qWarning("Cannot find font definition file %s - is $QTDIR set correctly?", |
215 | temp.data()); | 215 | temp.data()); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | char buf[200]=""; | 218 | char buf[200]=""; |
219 | char name[200]=""; | 219 | char name[200]=""; |
220 | char render[200]=""; | 220 | char render[200]=""; |
221 | char file[200]=""; | 221 | char file[200]=""; |
222 | char flags[200]=""; | 222 | char flags[200]=""; |
223 | char isitalic[10]=""; | 223 | char isitalic[10]=""; |
224 | fgets(buf,200,fontdef); | 224 | fgets(buf,200,fontdef); |
225 | while(!feof(fontdef)) { | 225 | while(!feof(fontdef)) { |
226 | if ( buf[0] != '#' ) { | 226 | if ( buf[0] != '#' ) { |
227 | int weight=50; | 227 | int weight=50; |
228 | int size=0; | 228 | int size=0; |
229 | flags[0]=0; | 229 | flags[0]=0; |
230 | sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags); | 230 | sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags); |
231 | QString filename; | 231 | QString filename; |
232 | if ( file[0] != '/' ) | 232 | if ( file[0] != '/' ) |
233 | filename = fontDir(); | 233 | filename = fontDir(); |
234 | filename += file; | 234 | filename += file; |
235 | if ( QFile::exists(filename) ) { | 235 | if ( QFile::exists(filename) ) { |
236 | if( factory->name() == render ) { | 236 | if( factory->name() == render ) { |
237 | QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', | 237 | QDiskFont * qdf=new QDiskFont(factory,name,isitalic[0]=='y', |
238 | weight,size,flags,filename); | 238 | weight,size,flags,filename); |
239 | qt_fontmanager->diskfonts.append(qdf); | 239 | qt_fontmanager->diskfonts.append(qdf); |
240 | #if QT_VERSION >= 232 | 240 | #if QT_VERSION >= 232 |
241 | QFontDatabase::qwsAddDiskFont( qdf ); | 241 | QFontDatabase::qwsAddDiskFont( qdf ); |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | } | 244 | } |
245 | } | 245 | } |
246 | fgets(buf,200,fontdef); | 246 | fgets(buf,200,fontdef); |
247 | } | 247 | } |
248 | fclose(fontdef); | 248 | fclose(fontdef); |
249 | #endif | 249 | #endif |
250 | } | 250 | } |
251 | 251 | ||
diff --git a/library/network.cpp b/library/network.cpp index f2a673c..0bbbec1 100644 --- a/library/network.cpp +++ b/library/network.cpp | |||
@@ -326,123 +326,123 @@ private: | |||
326 | 326 | ||
327 | private: | 327 | private: |
328 | QStringList available; | 328 | QStringList available; |
329 | QString current; | 329 | QString current; |
330 | bool up; | 330 | bool up; |
331 | int wait; | 331 | int wait; |
332 | }; | 332 | }; |
333 | 333 | ||
334 | static NetworkServer* ns=0; | 334 | static NetworkServer* ns=0; |
335 | 335 | ||
336 | /*! | 336 | /*! |
337 | \internal | 337 | \internal |
338 | */ | 338 | */ |
339 | QString Network::serviceName(const QString& service) | 339 | QString Network::serviceName(const QString& service) |
340 | { | 340 | { |
341 | Config cfg(service, Config::File); | 341 | Config cfg(service, Config::File); |
342 | cfg.setGroup("Info"); | 342 | cfg.setGroup("Info"); |
343 | return cfg.readEntry("Name"); | 343 | return cfg.readEntry("Name"); |
344 | } | 344 | } |
345 | 345 | ||
346 | /*! | 346 | /*! |
347 | \internal | 347 | \internal |
348 | */ | 348 | */ |
349 | QString Network::serviceType(const QString& service) | 349 | QString Network::serviceType(const QString& service) |
350 | { | 350 | { |
351 | Config cfg(service, Config::File); | 351 | Config cfg(service, Config::File); |
352 | cfg.setGroup("Info"); | 352 | cfg.setGroup("Info"); |
353 | return cfg.readEntry("Type"); | 353 | return cfg.readEntry("Type"); |
354 | } | 354 | } |
355 | 355 | ||
356 | /*! | 356 | /*! |
357 | \internal | 357 | \internal |
358 | */ | 358 | */ |
359 | bool Network::serviceNeedsPassword(const QString& service) | 359 | bool Network::serviceNeedsPassword(const QString& service) |
360 | { | 360 | { |
361 | Config cfg(service,Config::File); | 361 | Config cfg(service,Config::File); |
362 | cfg.setGroup("Info"); | 362 | cfg.setGroup("Info"); |
363 | QString type = cfg.readEntry("Type"); | 363 | QString type = cfg.readEntry("Type"); |
364 | NetworkInterface* plugin = Network::loadPlugin(type); | 364 | NetworkInterface* plugin = Network::loadPlugin(type); |
365 | cfg.setGroup("Properties"); | 365 | cfg.setGroup("Properties"); |
366 | return plugin ? plugin->needPassword(cfg) : FALSE; | 366 | return plugin ? plugin->needPassword(cfg) : FALSE; |
367 | } | 367 | } |
368 | 368 | ||
369 | /*! | 369 | /*! |
370 | \internal | 370 | \internal |
371 | */ | 371 | */ |
372 | bool Network::networkOnline() | 372 | bool Network::networkOnline() |
373 | { | 373 | { |
374 | return ns && ns->networkOnline(); | 374 | return ns && ns->networkOnline(); |
375 | } | 375 | } |
376 | 376 | ||
377 | /*! | 377 | /*! |
378 | \internal | 378 | \internal |
379 | */ | 379 | */ |
380 | void Network::createServer(QObject* parent) | 380 | void Network::createServer(QObject* parent) |
381 | { | 381 | { |
382 | ns = new NetworkServer(parent); | 382 | ns = new NetworkServer(parent); |
383 | } | 383 | } |
384 | 384 | ||
385 | /*! | 385 | /*! |
386 | \internal | 386 | \internal |
387 | */ | 387 | */ |
388 | int Network::addStateWidgets(QWidget* parent) | 388 | int Network::addStateWidgets(QWidget* parent) |
389 | { | 389 | { |
390 | int n=0; | 390 | int n=0; |
391 | QStringList l = Network::choices(); | 391 | QStringList l = Network::choices(); |
392 | QVBoxLayout* vb = new QVBoxLayout(parent); | 392 | QVBoxLayout* vb = new QVBoxLayout(parent); |
393 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { | 393 | for (QStringList::ConstIterator it=l.begin(); it!=l.end(); ++it) { |
394 | Config cfg(*it,Config::File); | 394 | Config cfg(*it,Config::File); |
395 | cfg.setGroup("Info"); | 395 | cfg.setGroup("Info"); |
396 | QString type = cfg.readEntry("Type"); | 396 | QString type = cfg.readEntry("Type"); |
397 | NetworkInterface* plugin = Network::loadPlugin(type); | 397 | NetworkInterface* plugin = Network::loadPlugin(type); |
398 | cfg.setGroup("Properties"); | 398 | cfg.setGroup("Properties"); |
399 | if ( plugin ) { | 399 | if ( plugin ) { |
400 | QWidget* w; | 400 | QWidget* w; |
401 | if ( (w=plugin->addStateWidget(parent,cfg)) ) { | 401 | if ( (w=plugin->addStateWidget(parent,cfg)) ) { |
402 | n++; | 402 | n++; |
403 | vb->addWidget(w); | 403 | vb->addWidget(w); |
404 | } | 404 | } |
405 | } | 405 | } |
406 | } | 406 | } |
407 | return n; | 407 | return n; |
408 | } | 408 | } |
409 | 409 | ||
410 | static QDict<NetworkInterface> *ifaces; | 410 | static QDict<NetworkInterface> *ifaces; |
411 | 411 | ||
412 | /*! | 412 | /*! |
413 | \internal | 413 | \internal |
414 | */ | 414 | */ |
415 | NetworkInterface* Network::loadPlugin(const QString& type) | 415 | NetworkInterface* Network::loadPlugin(const QString& type) |
416 | { | 416 | { |
417 | #ifndef QT_NO_COMPONENT | 417 | #ifndef QT_NO_COMPONENT |
418 | if ( !ifaces ) ifaces = new QDict<NetworkInterface>; | 418 | if ( !ifaces ) ifaces = new QDict<NetworkInterface>; |
419 | NetworkInterface *iface = ifaces->find(type); | 419 | NetworkInterface *iface = ifaces->find(type); |
420 | if ( !iface ) { | 420 | if ( !iface ) { |
421 | #ifdef Q_OS_MACX | 421 | #ifdef Q_OS_MACX |
422 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".dylib"; | 422 | QString libfile = QPEApplication::qpeDir() + "plugins/network/lib" + type + ".dylib"; |
423 | #else | 423 | #else |
424 | QString libfile = QPEApplication::qpeDir() + "/plugins/network/lib" + type + ".so"; | 424 | QString libfile = QPEApplication::qpeDir() + "plugins/network/lib" + type + ".so"; |
425 | #endif | 425 | #endif |
426 | QLibrary lib(libfile); | 426 | QLibrary lib(libfile); |
427 | if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) | 427 | if ( !lib.queryInterface( IID_Network, (QUnknownInterface**)&iface ) == QS_OK ) |
428 | return 0; | 428 | return 0; |
429 | ifaces->insert(type,iface); | 429 | ifaces->insert(type,iface); |
430 | QStringList langs = Global::languageList(); | 430 | QStringList langs = Global::languageList(); |
431 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 431 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
432 | QString lang = *it; | 432 | QString lang = *it; |
433 | QTranslator * trans = new QTranslator(qApp); | 433 | QTranslator * trans = new QTranslator(qApp); |
434 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/lib"+type+".qm"; | 434 | QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/lib"+type+".qm"; |
435 | if ( trans->load( tfn )) | 435 | if ( trans->load( tfn )) |
436 | qApp->installTranslator( trans ); | 436 | qApp->installTranslator( trans ); |
437 | else | 437 | else |
438 | delete trans; | 438 | delete trans; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | return iface; | 441 | return iface; |
442 | #else | 442 | #else |
443 | return 0; | 443 | return 0; |
444 | #endif | 444 | #endif |
445 | } | 445 | } |
446 | 446 | ||
447 | #include "network.moc" | 447 | #include "network.moc" |
448 | #endif// QT_NO_COP | 448 | #endif// QT_NO_COP |
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index 7842ebd..8b02de6 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -443,193 +443,193 @@ void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowD | |||
443 | p->drawImage(x+1, y+1, *img); | 443 | p->drawImage(x+1, y+1, *img); |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const | 447 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const |
448 | { | 448 | { |
449 | int th = metric(TitleHeight,wd); | 449 | int th = metric(TitleHeight,wd); |
450 | QRect rect( wd->rect ); | 450 | QRect rect( wd->rect ); |
451 | QRect r(rect.left() - metric(LeftBorder,wd), | 451 | QRect r(rect.left() - metric(LeftBorder,wd), |
452 | rect.top() - th - metric(TopBorder,wd), | 452 | rect.top() - th - metric(TopBorder,wd), |
453 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), | 453 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), |
454 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); | 454 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); |
455 | return QRegion(r) - rect; | 455 | return QRegion(r) - rect; |
456 | } | 456 | } |
457 | 457 | ||
458 | class DefaultWindowDecoration : public WindowDecorationInterface | 458 | class DefaultWindowDecoration : public WindowDecorationInterface |
459 | { | 459 | { |
460 | public: | 460 | public: |
461 | DefaultWindowDecoration(){} | 461 | DefaultWindowDecoration(){} |
462 | QString name() const { | 462 | QString name() const { |
463 | return qApp->translate("WindowDecoration", "Default", | 463 | return qApp->translate("WindowDecoration", "Default", |
464 | "List box text for default window decoration"); | 464 | "List box text for default window decoration"); |
465 | } | 465 | } |
466 | QPixmap icon() const { | 466 | QPixmap icon() const { |
467 | return QPixmap(); | 467 | return QPixmap(); |
468 | } | 468 | } |
469 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 469 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
470 | *iface = 0; | 470 | *iface = 0; |
471 | if ( uuid == IID_QUnknown ) | 471 | if ( uuid == IID_QUnknown ) |
472 | *iface = this; | 472 | *iface = this; |
473 | else if ( uuid == IID_WindowDecoration ) | 473 | else if ( uuid == IID_WindowDecoration ) |
474 | *iface = this; | 474 | *iface = this; |
475 | else | 475 | else |
476 | return QS_FALSE; | 476 | return QS_FALSE; |
477 | 477 | ||
478 | if ( *iface ) | 478 | if ( *iface ) |
479 | (*iface)->addRef(); | 479 | (*iface)->addRef(); |
480 | return QS_OK; | 480 | return QS_OK; |
481 | } | 481 | } |
482 | Q_REFCOUNT | 482 | Q_REFCOUNT |
483 | 483 | ||
484 | }; | 484 | }; |
485 | 485 | ||
486 | static WindowDecorationInterface *wdiface = 0; | 486 | static WindowDecorationInterface *wdiface = 0; |
487 | static QLibrary* wdlib = 0; | 487 | static QLibrary* wdlib = 0; |
488 | static QString libname; | 488 | static QString libname; |
489 | 489 | ||
490 | //=========================================================================== | 490 | //=========================================================================== |
491 | bool QPEDecoration::helpExists() const | 491 | bool QPEDecoration::helpExists() const |
492 | { | 492 | { |
493 | if ( helpFile.isNull() ) { | 493 | if ( helpFile.isNull() ) { |
494 | QStringList helpPath = Global::helpPath(); | 494 | QStringList helpPath = Global::helpPath(); |
495 | QString hf = QString(qApp->argv()[0]) + ".html"; | 495 | QString hf = QString(qApp->argv()[0]) + ".html"; |
496 | bool he = FALSE; | 496 | bool he = FALSE; |
497 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) | 497 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) |
498 | he = QFile::exists( *it + "/" + hf ); | 498 | he = QFile::exists( *it + "/" + hf ); |
499 | ((QPEDecoration*)this)->helpFile = hf; | 499 | ((QPEDecoration*)this)->helpFile = hf; |
500 | ((QPEDecoration*)this)->helpexists = he; | 500 | ((QPEDecoration*)this)->helpexists = he; |
501 | return he; | 501 | return he; |
502 | } | 502 | } |
503 | return helpexists; | 503 | return helpexists; |
504 | } | 504 | } |
505 | 505 | ||
506 | QPEDecoration::QPEDecoration() | 506 | QPEDecoration::QPEDecoration() |
507 | : QWSDefaultDecoration() | 507 | : QWSDefaultDecoration() |
508 | { | 508 | { |
509 | if ( wdlib ) { | 509 | if ( wdlib ) { |
510 | delete wdlib; | 510 | delete wdlib; |
511 | wdlib = 0; | 511 | wdlib = 0; |
512 | } else { | 512 | } else { |
513 | delete wdiface; | 513 | delete wdiface; |
514 | } | 514 | } |
515 | wdiface = new DefaultWindowDecoration; | 515 | wdiface = new DefaultWindowDecoration; |
516 | 516 | ||
517 | helpexists = FALSE; // We don't know (flagged by helpFile being null) | 517 | helpexists = FALSE; // We don't know (flagged by helpFile being null) |
518 | qpeManager = new QPEManager( this ); | 518 | qpeManager = new QPEManager( this ); |
519 | imageOk = Resource::loadImage( "OKButton" ); | 519 | imageOk = Resource::loadImage( "OKButton" ); |
520 | imageClose = Resource::loadImage( "CloseButton" ); | 520 | imageClose = Resource::loadImage( "CloseButton" ); |
521 | imageHelp = Resource::loadImage( "HelpButton" ); | 521 | imageHelp = Resource::loadImage( "HelpButton" ); |
522 | } | 522 | } |
523 | 523 | ||
524 | QPEDecoration::QPEDecoration( const QString &plugin ) | 524 | QPEDecoration::QPEDecoration( const QString &plugin ) |
525 | : QWSDefaultDecoration() | 525 | : QWSDefaultDecoration() |
526 | { | 526 | { |
527 | libname = plugin; | 527 | libname = plugin; |
528 | 528 | ||
529 | if ( wdlib ) { | 529 | if ( wdlib ) { |
530 | wdiface->release(); | 530 | wdiface->release(); |
531 | wdlib->unload(); | 531 | wdlib->unload(); |
532 | delete wdlib; | 532 | delete wdlib; |
533 | wdlib = 0; | 533 | wdlib = 0; |
534 | } else { | 534 | } else { |
535 | delete wdiface; | 535 | delete wdiface; |
536 | } | 536 | } |
537 | 537 | ||
538 | WindowDecorationInterface *iface = 0; | 538 | WindowDecorationInterface *iface = 0; |
539 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | 539 | QString path = QPEApplication::qpeDir() + "plugins/decorations/"; |
540 | 540 | ||
541 | #ifdef Q_OS_MACX | 541 | #ifdef Q_OS_MACX |
542 | if ( plugin.find( ".dylib" ) > 0 ) { | 542 | if ( plugin.find( ".dylib" ) > 0 ) { |
543 | #else | 543 | #else |
544 | if ( plugin.find( ".so" ) > 0 ) { | 544 | if ( plugin.find( ".so" ) > 0 ) { |
545 | #endif | 545 | #endif |
546 | // full library name supplied | 546 | // full library name supplied |
547 | path += plugin; | 547 | path += plugin; |
548 | } else { | 548 | } else { |
549 | #ifdef Q_OS_MACX | 549 | #ifdef Q_OS_MACX |
550 | path += "lib" + plugin.lower() + ".dylib"; // compatibility | 550 | path += "lib" + plugin.lower() + ".dylib"; // compatibility |
551 | #else | 551 | #else |
552 | path += "lib" + plugin.lower() + ".so"; // compatibility | 552 | path += "lib" + plugin.lower() + ".so"; // compatibility |
553 | #endif | 553 | #endif |
554 | } | 554 | } |
555 | 555 | ||
556 | QLibrary *lib = new QLibrary( path ); | 556 | QLibrary *lib = new QLibrary( path ); |
557 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 557 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
558 | wdiface = iface; | 558 | wdiface = iface; |
559 | wdlib = lib; | 559 | wdlib = lib; |
560 | } else { | 560 | } else { |
561 | delete lib; | 561 | delete lib; |
562 | wdiface = new DefaultWindowDecoration; | 562 | wdiface = new DefaultWindowDecoration; |
563 | } | 563 | } |
564 | 564 | ||
565 | 565 | ||
566 | 566 | ||
567 | helpexists = FALSE; // We don't know (flagged by helpFile being null) | 567 | helpexists = FALSE; // We don't know (flagged by helpFile being null) |
568 | qpeManager = new QPEManager( this ); | 568 | qpeManager = new QPEManager( this ); |
569 | } | 569 | } |
570 | 570 | ||
571 | QPEDecoration::~QPEDecoration() | 571 | QPEDecoration::~QPEDecoration() |
572 | { | 572 | { |
573 | delete qpeManager; | 573 | delete qpeManager; |
574 | } | 574 | } |
575 | 575 | ||
576 | const char **QPEDecoration::menuPixmap() | 576 | const char **QPEDecoration::menuPixmap() |
577 | { | 577 | { |
578 | return (const char **)0; | 578 | return (const char **)0; |
579 | } | 579 | } |
580 | 580 | ||
581 | const char **QPEDecoration::closePixmap() | 581 | const char **QPEDecoration::closePixmap() |
582 | { | 582 | { |
583 | return (const char **)qpe_close_xpm; | 583 | return (const char **)qpe_close_xpm; |
584 | } | 584 | } |
585 | 585 | ||
586 | const char **QPEDecoration::minimizePixmap() | 586 | const char **QPEDecoration::minimizePixmap() |
587 | { | 587 | { |
588 | return (const char **)qpe_accept_xpm; | 588 | return (const char **)qpe_accept_xpm; |
589 | } | 589 | } |
590 | 590 | ||
591 | const char **QPEDecoration::maximizePixmap() | 591 | const char **QPEDecoration::maximizePixmap() |
592 | { | 592 | { |
593 | return (const char **)0; | 593 | return (const char **)0; |
594 | } | 594 | } |
595 | 595 | ||
596 | const char **QPEDecoration::normalizePixmap() | 596 | const char **QPEDecoration::normalizePixmap() |
597 | { | 597 | { |
598 | return (const char **)0; | 598 | return (const char **)0; |
599 | } | 599 | } |
600 | 600 | ||
601 | int QPEDecoration::getTitleHeight( const QWidget *w ) | 601 | int QPEDecoration::getTitleHeight( const QWidget *w ) |
602 | { | 602 | { |
603 | WindowDecorationInterface::WindowData wd; | 603 | WindowDecorationInterface::WindowData wd; |
604 | windowData( w, wd ); | 604 | windowData( w, wd ); |
605 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 605 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
606 | } | 606 | } |
607 | 607 | ||
608 | /* | 608 | /* |
609 | If rect is empty, no frame is added. (a hack, really) | 609 | If rect is empty, no frame is added. (a hack, really) |
610 | */ | 610 | */ |
611 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) | 611 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) |
612 | { | 612 | { |
613 | qpeManager->updateActive(); | 613 | qpeManager->updateActive(); |
614 | 614 | ||
615 | WindowDecorationInterface::WindowData wd; | 615 | WindowDecorationInterface::WindowData wd; |
616 | windowData( widget, wd ); | 616 | windowData( widget, wd ); |
617 | wd.rect = rect; | 617 | wd.rect = rect; |
618 | 618 | ||
619 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 619 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
620 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); | 620 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); |
621 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); | 621 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); |
622 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); | 622 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); |
623 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); | 623 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); |
624 | 624 | ||
625 | QRegion region; | 625 | QRegion region; |
626 | 626 | ||
627 | switch ((int)type) { | 627 | switch ((int)type) { |
628 | case Menu: | 628 | case Menu: |
629 | break; | 629 | break; |
630 | case Maximize: | 630 | case Maximize: |
631 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { | 631 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { |
632 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); | 632 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); |
633 | int left = rect.right() - maximizeWidth - closeWidth; | 633 | int left = rect.right() - maximizeWidth - closeWidth; |
634 | if ( ((DecorHackWidget *)widget)->needsOk() ) | 634 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
635 | left -= okWidth; | 635 | left -= okWidth; |
diff --git a/libslcompat/slmisc.h b/libslcompat/slmisc.h index 20ba988..442b098 100644 --- a/libslcompat/slmisc.h +++ b/libslcompat/slmisc.h | |||
@@ -1,125 +1,125 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 SHARP CORPORATION All rights reserved. | 2 | * Copyright (C) 2002 SHARP CORPORATION All rights reserved. |
3 | */ | 3 | */ |
4 | #ifndef _SLMISC_H_INCLUDED | 4 | #ifndef _SLMISC_H_INCLUDED |
5 | #define _SLMISC_H_INCLUDED | 5 | #define _SLMISC_H_INCLUDED |
6 | 6 | ||
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
9 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | 11 | ||
12 | 12 | ||
13 | #define _SLPOWER | 13 | #define _SLPOWER |
14 | 14 | ||
15 | class QPopupMenu; | 15 | class QPopupMenu; |
16 | class QListView; | 16 | class QListView; |
17 | #if !defined(_SLPOWER) | 17 | #if !defined(_SLPOWER) |
18 | class PowerStatus; | 18 | class PowerStatus; |
19 | #else | 19 | #else |
20 | class SlPowerStatus; | 20 | class SlPowerStatus; |
21 | #endif | 21 | #endif |
22 | class Config; | 22 | class Config; |
23 | 23 | ||
24 | typedef ulong SlResolutionScale; | 24 | typedef ulong SlResolutionScale; |
25 | 25 | ||
26 | class SlMisc { | 26 | class SlMisc { |
27 | public: | 27 | public: |
28 | static bool isExecutable(const QString &c) { | 28 | static bool isExecutable(const QString &c) { |
29 | QFileInfo exec(QPEApplication::qpeDir() + "/bin/" + c); | 29 | QFileInfo exec(QPEApplication::qpeDir() + "bin/" + c); |
30 | return exec.isExecutable(); | 30 | return exec.isExecutable(); |
31 | }; | 31 | }; |
32 | static ulong availableMemory(); | 32 | static ulong availableMemory(); |
33 | static bool invalidFileName(QString &fName); | 33 | static bool invalidFileName(QString &fName); |
34 | static QString getValidFileName(const QString &baseName); | 34 | static QString getValidFileName(const QString &baseName); |
35 | static QString getCanonicalPath(const QString &fName); | 35 | static QString getCanonicalPath(const QString &fName); |
36 | static void enableAutoPowerOff(bool isOn); | 36 | static void enableAutoPowerOff(bool isOn); |
37 | static void enableAutoPowerOff(bool isOn,bool DimAlso,bool ScreenSaverAlso=FALSE); | 37 | static void enableAutoPowerOff(bool isOn,bool DimAlso,bool ScreenSaverAlso=FALSE); |
38 | static void enableLockApplication(bool); | 38 | static void enableLockApplication(bool); |
39 | static bool isTheSmbShareFileHasWriteEntry(const QString &shareFName); | 39 | static bool isTheSmbShareFileHasWriteEntry(const QString &shareFName); |
40 | static bool isTheSmbShareFileNowCopy(const QString &shareFName); | 40 | static bool isTheSmbShareFileNowCopy(const QString &shareFName); |
41 | static bool checkTheSmbShareFileMode(const QString &shareFName, | 41 | static bool checkTheSmbShareFileMode(const QString &shareFName, |
42 | char modeMask, char checkMode, bool equality); | 42 | char modeMask, char checkMode, bool equality); |
43 | static bool isTheFileLockedBySmbd(const QString &fName); | 43 | static bool isTheFileLockedBySmbd(const QString &fName); |
44 | static bool isSambaForked(); | 44 | static bool isSambaForked(); |
45 | static void startSamba(); | 45 | static void startSamba(); |
46 | static void stopSamba(); | 46 | static void stopSamba(); |
47 | enum ListType { Pid, CmdLine, Both }; | 47 | enum ListType { Pid, CmdLine, Both }; |
48 | static QStringList procList (const QRegExp& re, uint max = 0, enum ListType type = Pid); | 48 | static QStringList procList (const QRegExp& re, uint max = 0, enum ListType type = Pid); |
49 | static void dumpMemInfo(bool isShowHeap); | 49 | static void dumpMemInfo(bool isShowHeap); |
50 | static bool canCreateTheFile(const QString&); | 50 | static bool canCreateTheFile(const QString&); |
51 | static QString getLanguage(); | 51 | static QString getLanguage(); |
52 | static QSize getMaximizedWidgetInfo(); | 52 | static QSize getMaximizedWidgetInfo(); |
53 | static QSize SlMisc::getScrollbarMetrics(); | 53 | static QSize SlMisc::getScrollbarMetrics(); |
54 | static int getDpi(); | 54 | static int getDpi(); |
55 | static SlResolutionScale getResolutionScale(); | 55 | static SlResolutionScale getResolutionScale(); |
56 | static int getMaximizedWidgetContentsWidth(); | 56 | static int getMaximizedWidgetContentsWidth(); |
57 | static bool isLandscape(); | 57 | static bool isLandscape(); |
58 | static void requestCloseFile(const QString&); | 58 | static void requestCloseFile(const QString&); |
59 | static void requestOpenFile(const QString&); | 59 | static void requestOpenFile(const QString&); |
60 | 60 | ||
61 | static void insertStandardFontMenu(QPopupMenu *pm); | 61 | static void insertStandardFontMenu(QPopupMenu *pm); |
62 | static void insertAllFontMenu(QPopupMenu *pm); | 62 | static void insertAllFontMenu(QPopupMenu *pm); |
63 | static int getLogicalSizeFromMenuId(int id); | 63 | static int getLogicalSizeFromMenuId(int id); |
64 | static void setFontSizeItemChecked(QPopupMenu *pm,int logicalSize); | 64 | static void setFontSizeItemChecked(QPopupMenu *pm,int logicalSize); |
65 | static int getFontPointSize(int logicalSize); | 65 | static int getFontPointSize(int logicalSize); |
66 | static void toggleFontSize(QPopupMenu *pm,int &logicalSize,bool isLarge=true); | 66 | static void toggleFontSize(QPopupMenu *pm,int &logicalSize,bool isLarge=true); |
67 | static void toggleAllFontSize(QPopupMenu *pm,int *fontSize,bool isLarge=true); | 67 | static void toggleAllFontSize(QPopupMenu *pm,int *fontSize,bool isLarge=true); |
68 | 68 | ||
69 | static void SlFontArrange (QWidget* widget); | 69 | static void SlFontArrange (QWidget* widget); |
70 | static void SlLayoutSpaceArrange (QObject* object); | 70 | static void SlLayoutSpaceArrange (QObject* object); |
71 | 71 | ||
72 | static bool checkBatteryError(const QString &module_name, bool force); | 72 | static bool checkBatteryError(const QString &module_name, bool force); |
73 | static bool checkBatteryErrorWithoutDialog(const QString &module_name, bool force); | 73 | static bool checkBatteryErrorWithoutDialog(const QString &module_name, bool force); |
74 | 74 | ||
75 | 75 | ||
76 | enum InputDeviceType { | 76 | enum InputDeviceType { |
77 | BuiltinKeyboard = 1, | 77 | BuiltinKeyboard = 1, |
78 | SoftwareKeyboard = 2 | 78 | SoftwareKeyboard = 2 |
79 | }; | 79 | }; |
80 | static InputDeviceType defaultInputDevice(); | 80 | static InputDeviceType defaultInputDevice(); |
81 | 81 | ||
82 | 82 | ||
83 | typedef struct SlListColumnInfo { | 83 | typedef struct SlListColumnInfo { |
84 | enum Type { | 84 | enum Type { |
85 | Fixed = 0, | 85 | Fixed = 0, |
86 | StringLen, | 86 | StringLen, |
87 | Scale, | 87 | Scale, |
88 | FixedDpiAware | 88 | FixedDpiAware |
89 | }; | 89 | }; |
90 | Type type; | 90 | Type type; |
91 | QString str; | 91 | QString str; |
92 | int val; | 92 | int val; |
93 | }; | 93 | }; |
94 | typedef QValueList<SlListColumnInfo> SlListColumnInfos; | 94 | typedef QValueList<SlListColumnInfo> SlListColumnInfos; |
95 | 95 | ||
96 | static void setListColumnsWidth(QWidget *w,SlListColumnInfos &infos, | 96 | static void setListColumnsWidth(QWidget *w,SlListColumnInfos &infos, |
97 | Config &config); | 97 | Config &config); |
98 | static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, | 98 | static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, |
99 | Config &config); | 99 | Config &config); |
100 | static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, | 100 | static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, |
101 | Config &config,bool isLandscape); | 101 | Config &config,bool isLandscape); |
102 | static void rotateListColumnsWidth(QWidget *w,SlListColumnInfos &infos, | 102 | static void rotateListColumnsWidth(QWidget *w,SlListColumnInfos &infos, |
103 | Config &config); | 103 | Config &config); |
104 | static void setListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL); | 104 | static void setListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL); |
105 | static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL); | 105 | static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL); |
106 | static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, bool isLandscape, Config *config=NULL); | 106 | static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, bool isLandscape, Config *config=NULL); |
107 | static void rotateListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL); | 107 | static void rotateListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL); |
108 | static void temporaryMessageBox(const QString &caption, const QString &text, int msec=10000, QMessageBox::Icon icon=QMessageBox::NoIcon, int button0=0, int button1=0, int button2=0, QWidget *parent=0, const char *name=0, QWidget::WFlags f=QWidget::WStyle_DialogBorder); | 108 | static void temporaryMessageBox(const QString &caption, const QString &text, int msec=10000, QMessageBox::Icon icon=QMessageBox::NoIcon, int button0=0, int button1=0, int button2=0, QWidget *parent=0, const char *name=0, QWidget::WFlags f=QWidget::WStyle_DialogBorder); |
109 | 109 | ||
110 | static QString defaultWallPaper(); | 110 | static QString defaultWallPaper(); |
111 | typedef enum AppCommand { | 111 | typedef enum AppCommand { |
112 | NoneCommand = 0, | 112 | NoneCommand = 0, |
113 | NewCommand, | 113 | NewCommand, |
114 | ModifyCommand, | 114 | ModifyCommand, |
115 | DeleteCommand, | 115 | DeleteCommand, |
116 | ZoomInCommand, | 116 | ZoomInCommand, |
117 | ZoomOutCommand, | 117 | ZoomOutCommand, |
118 | CutCommand = 50, | 118 | CutCommand = 50, |
119 | CopyCommand, | 119 | CopyCommand, |
120 | PasteCommand | 120 | PasteCommand |
121 | }; | 121 | }; |
122 | static AppCommand appCommandFromKey(const QKeyEvent &e); | 122 | static AppCommand appCommandFromKey(const QKeyEvent &e); |
123 | 123 | ||
124 | typedef enum RequiredSize { | 124 | typedef enum RequiredSize { |
125 | SmallSize = 0, | 125 | SmallSize = 0, |
diff --git a/noncore/applets/zkbapplet/applet/zkbwidget.cpp b/noncore/applets/zkbapplet/applet/zkbwidget.cpp index 8499500..13729ea 100644 --- a/noncore/applets/zkbapplet/applet/zkbwidget.cpp +++ b/noncore/applets/zkbapplet/applet/zkbwidget.cpp | |||
@@ -1,140 +1,140 @@ | |||
1 | #include <opie2/otaskbarapplet.h> | 1 | #include <opie2/otaskbarapplet.h> |
2 | #include <opie2/okeyfilter.h> | 2 | #include <opie2/okeyfilter.h> |
3 | #include <qpe/qcopenvelope_qws.h> | 3 | #include <qpe/qcopenvelope_qws.h> |
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | #include <qpe/qpeapplication.h> | 5 | #include <qpe/qpeapplication.h> |
6 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | #include "zkbwidget.h" | 9 | #include "zkbwidget.h" |
10 | #include "zkbcfg.h" | 10 | #include "zkbcfg.h" |
11 | 11 | ||
12 | using namespace Opie::Ui; | 12 | using namespace Opie::Ui; |
13 | 13 | ||
14 | ZkbWidget::ZkbWidget(QWidget* parent) | 14 | ZkbWidget::ZkbWidget(QWidget* parent) |
15 | :QLabel(parent),keymap(0),disabled(Resource::loadPixmap("zkb-disabled")) { | 15 | :QLabel(parent),keymap(0),disabled(Resource::loadPixmap("zkb-disabled")) { |
16 | 16 | ||
17 | labels = new QPopupMenu(); | 17 | labels = new QPopupMenu(); |
18 | connect(labels, SIGNAL(activated(int)), this, | 18 | connect(labels, SIGNAL(activated(int)), this, |
19 | SLOT(labelChanged(int))); | 19 | SLOT(labelChanged(int))); |
20 | 20 | ||
21 | loadKeymap(); | 21 | loadKeymap(); |
22 | 22 | ||
23 | channel = new QCopChannel("QPE/zkb", this); | 23 | channel = new QCopChannel("QPE/zkb", this); |
24 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), | 24 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), |
25 | this, SLOT(signalReceived(const QCString&,const QByteArray&))); | 25 | this, SLOT(signalReceived(const QCString&,const QByteArray&))); |
26 | setFixedWidth ( AppLnk::smallIconSize() ); | 26 | setFixedWidth ( AppLnk::smallIconSize() ); |
27 | setFixedHeight ( AppLnk::smallIconSize() ); | 27 | setFixedHeight ( AppLnk::smallIconSize() ); |
28 | } | 28 | } |
29 | 29 | ||
30 | ZkbWidget::~ZkbWidget() | 30 | ZkbWidget::~ZkbWidget() |
31 | { | 31 | { |
32 | if (keymap != 0) { | 32 | if (keymap != 0) { |
33 | delete keymap; | 33 | delete keymap; |
34 | keymap = 0; | 34 | keymap = 0; |
35 | } | 35 | } |
36 | } | 36 | } |
37 | 37 | ||
38 | int ZkbWidget::position() | 38 | int ZkbWidget::position() |
39 | { | 39 | { |
40 | return 8; | 40 | return 8; |
41 | } | 41 | } |
42 | 42 | ||
43 | bool ZkbWidget::loadKeymap() { | 43 | bool ZkbWidget::loadKeymap() { |
44 | ZkbConfig c(QPEApplication::qpeDir()+"/share/zkb"); | 44 | ZkbConfig c(QPEApplication::qpeDir()+"share/zkb"); |
45 | QFontMetrics fm(font()); | 45 | QFontMetrics fm(font()); |
46 | 46 | ||
47 | if (keymap != 0) { | 47 | if (keymap != 0) { |
48 | delete keymap; | 48 | delete keymap; |
49 | keymap = 0; | 49 | keymap = 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | Keymap* km = new Keymap(); | 52 | Keymap* km = new Keymap(); |
53 | 53 | ||
54 | if (!c.load("zkb.xml", *km, "")) { | 54 | if (!c.load("zkb.xml", *km, "")) { |
55 | delete km; | 55 | delete km; |
56 | setPixmap(disabled); | 56 | setPixmap(disabled); |
57 | return false; | 57 | return false; |
58 | } | 58 | } |
59 | 59 | ||
60 | connect(km, SIGNAL(stateChanged(const QString&)), | 60 | connect(km, SIGNAL(stateChanged(const QString&)), |
61 | this, SLOT(stateChanged(const QString&))); | 61 | this, SLOT(stateChanged(const QString&))); |
62 | 62 | ||
63 | Opie::Core::OKeyFilter::inst()->addHandler(km); | 63 | Opie::Core::OKeyFilter::inst()->addHandler(km); |
64 | 64 | ||
65 | Keymap* oldkm = keymap; | 65 | Keymap* oldkm = keymap; |
66 | keymap = km; | 66 | keymap = km; |
67 | 67 | ||
68 | if (oldkm != 0) { | 68 | if (oldkm != 0) { |
69 | delete oldkm; | 69 | delete oldkm; |
70 | } | 70 | } |
71 | 71 | ||
72 | QString ltext = keymap->getCurrentLabel(); | 72 | QString ltext = keymap->getCurrentLabel(); |
73 | if (ltext.length()==0) ltext = "??"; | 73 | if (ltext.length()==0) ltext = "??"; |
74 | setText(ltext); | 74 | setText(ltext); |
75 | 75 | ||
76 | labels->clear(); | 76 | labels->clear(); |
77 | QStringList l = keymap->listLabels(); | 77 | QStringList l = keymap->listLabels(); |
78 | labels->insertItem(disabled, 0, 0); | 78 | labels->insertItem(disabled, 0, 0); |
79 | int n = 1; | 79 | int n = 1; |
80 | w = 0; | 80 | w = 0; |
81 | for(QStringList::Iterator it = l.begin(); it != l.end(); | 81 | for(QStringList::Iterator it = l.begin(); it != l.end(); |
82 | ++it, n++) { | 82 | ++it, n++) { |
83 | 83 | ||
84 | // printf("label: %s\n", (const char*) (*it).utf8()); | 84 | // printf("label: %s\n", (const char*) (*it).utf8()); |
85 | 85 | ||
86 | labels->insertItem(*it, n, n); | 86 | labels->insertItem(*it, n, n); |
87 | int lw = fm.width(*it); | 87 | int lw = fm.width(*it); |
88 | if (lw > w) { | 88 | if (lw > w) { |
89 | w = lw; | 89 | w = lw; |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | if (w == 0) { | 93 | if (w == 0) { |
94 | hide(); | 94 | hide(); |
95 | } else { | 95 | } else { |
96 | show(); | 96 | show(); |
97 | } | 97 | } |
98 | return true; | 98 | return true; |
99 | } | 99 | } |
100 | 100 | ||
101 | QSize ZkbWidget::sizeHint() const { | 101 | QSize ZkbWidget::sizeHint() const { |
102 | return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize()); | 102 | return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize()); |
103 | } | 103 | } |
104 | 104 | ||
105 | void ZkbWidget::stateChanged(const QString& s) { | 105 | void ZkbWidget::stateChanged(const QString& s) { |
106 | // odebug << "stateChanged: " << s.utf8() << "\n" << oendl; | 106 | // odebug << "stateChanged: " << s.utf8() << "\n" << oendl; |
107 | setText(s); | 107 | setText(s); |
108 | } | 108 | } |
109 | 109 | ||
110 | void ZkbWidget::labelChanged(int id) { | 110 | void ZkbWidget::labelChanged(int id) { |
111 | if (id == 0) { | 111 | if (id == 0) { |
112 | keymap->disable(); | 112 | keymap->disable(); |
113 | setPixmap(disabled); | 113 | setPixmap(disabled); |
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | 116 | ||
117 | keymap->enable(); | 117 | keymap->enable(); |
118 | 118 | ||
119 | QStringList l = keymap->listLabels(); | 119 | QStringList l = keymap->listLabels(); |
120 | QString lbl = l[id-1]; | 120 | QString lbl = l[id-1]; |
121 | 121 | ||
122 | // printf("labelChanged: %s\n", (const char*) lbl.utf8()); | 122 | // printf("labelChanged: %s\n", (const char*) lbl.utf8()); |
123 | State* state = keymap->getStateByLabel(lbl); | 123 | State* state = keymap->getStateByLabel(lbl); |
124 | if (state != 0) { | 124 | if (state != 0) { |
125 | keymap->setCurrentState(state); | 125 | keymap->setCurrentState(state); |
126 | setText(lbl); | 126 | setText(lbl); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { | 130 | void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { |
131 | QSize sh = labels->sizeHint(); | 131 | QSize sh = labels->sizeHint(); |
132 | QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); | 132 | QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); |
133 | labels->exec(p); | 133 | labels->exec(p); |
134 | } | 134 | } |
135 | 135 | ||
136 | void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { | 136 | void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { |
137 | QDataStream stream(data, IO_ReadOnly); | 137 | QDataStream stream(data, IO_ReadOnly); |
138 | 138 | ||
139 | if (msg == "enable()") { | 139 | if (msg == "enable()") { |
140 | keymap->enable(); | 140 | keymap->enable(); |
diff --git a/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp b/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp index 8d868d4..4190a9e 100644 --- a/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp +++ b/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp | |||
@@ -1,132 +1,132 @@ | |||
1 | 1 | ||
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
4 | #include <qpe/qcopenvelope_qws.h> | 4 | #include <qpe/qcopenvelope_qws.h> |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | #include "cfgdlg.h" | 6 | #include "cfgdlg.h" |
7 | 7 | ||
8 | CfgDlg::CfgDlg(QWidget* parent, CfgFile* cf, QApplication* app, bool mod): | 8 | CfgDlg::CfgDlg(QWidget* parent, CfgFile* cf, QApplication* app, bool mod): |
9 | QDialog(parent, "CfgDlg", mod), cfile(cf), application(app) { | 9 | QDialog(parent, "CfgDlg", mod), cfile(cf), application(app) { |
10 | 10 | ||
11 | setCaption(tr("keyz configurator")); | 11 | setCaption(tr("keyz configurator")); |
12 | 12 | ||
13 | QGridLayout* gl = new QGridLayout(this, 7, 5, 5, 5); | 13 | QGridLayout* gl = new QGridLayout(this, 7, 5, 5, 5); |
14 | 14 | ||
15 | QLabel* flabel = new QLabel("Available Keymaps", this); | 15 | QLabel* flabel = new QLabel("Available Keymaps", this); |
16 | files = new QListBox(this); | 16 | files = new QListBox(this); |
17 | QPushButton* addButton = new QPushButton(">>", this); //add->setText("Add"); | 17 | QPushButton* addButton = new QPushButton(">>", this); //add->setText("Add"); |
18 | connect(addButton, SIGNAL(clicked()), this, SLOT(add())); | 18 | connect(addButton, SIGNAL(clicked()), this, SLOT(add())); |
19 | QLabel* klabel = new QLabel("Selected Keymaps", this); | 19 | QLabel* klabel = new QLabel("Selected Keymaps", this); |
20 | keymaps = new QListBox(this); | 20 | keymaps = new QListBox(this); |
21 | connect(keymaps, SIGNAL(highlighted(const QString&)), this, SLOT(keymapHighlighted(const QString&))); | 21 | connect(keymaps, SIGNAL(highlighted(const QString&)), this, SLOT(keymapHighlighted(const QString&))); |
22 | QPushButton* delButton = new QPushButton("<<", this); //del->setText("Delete"); | 22 | QPushButton* delButton = new QPushButton("<<", this); //del->setText("Delete"); |
23 | connect(delButton, SIGNAL(clicked()), this, SLOT(del())); | 23 | connect(delButton, SIGNAL(clicked()), this, SLOT(del())); |
24 | QPushButton* slabelButton = new QPushButton("Set Label", this); //apply->setText("Apply"); | 24 | QPushButton* slabelButton = new QPushButton("Set Label", this); //apply->setText("Apply"); |
25 | connect(slabelButton, SIGNAL(clicked()), this, SLOT(setLabel())); | 25 | connect(slabelButton, SIGNAL(clicked()), this, SLOT(setLabel())); |
26 | QLabel* l = new QLabel("Label", this); | 26 | QLabel* l = new QLabel("Label", this); |
27 | label = new QLineEdit(this); | 27 | label = new QLineEdit(this); |
28 | QLabel* adlabel = new QLabel("Auto Repeat Delay (ms)", this); | 28 | QLabel* adlabel = new QLabel("Auto Repeat Delay (ms)", this); |
29 | QLabel* aplabel = new QLabel("Auto Repeat Period (ms)", this); | 29 | QLabel* aplabel = new QLabel("Auto Repeat Period (ms)", this); |
30 | ad = new QSpinBox(50, 5000, 5, this); | 30 | ad = new QSpinBox(50, 5000, 5, this); |
31 | ap = new QSpinBox(0, 5000, 5, this); | 31 | ap = new QSpinBox(0, 5000, 5, this); |
32 | 32 | ||
33 | //QLabel* adms = new QLabel("ms", this); | 33 | //QLabel* adms = new QLabel("ms", this); |
34 | //QLabel* apms = new QLabel("ms", this); | 34 | //QLabel* apms = new QLabel("ms", this); |
35 | 35 | ||
36 | //QCheckBox* enable = new QCheckBox("Enable", t); | 36 | //QCheckBox* enable = new QCheckBox("Enable", t); |
37 | 37 | ||
38 | gl->setColStretch(0, 1); | 38 | gl->setColStretch(0, 1); |
39 | gl->setColStretch(1, 1); | 39 | gl->setColStretch(1, 1); |
40 | gl->setColStretch(3, 1); | 40 | gl->setColStretch(3, 1); |
41 | gl->setColStretch(4, 1); | 41 | gl->setColStretch(4, 1); |
42 | gl->setRowStretch(3, 1); | 42 | gl->setRowStretch(3, 1); |
43 | gl->addMultiCellWidget(flabel, 0, 0, 0, 1); | 43 | gl->addMultiCellWidget(flabel, 0, 0, 0, 1); |
44 | gl->addMultiCellWidget(klabel, 0, 0, 3, 4); | 44 | gl->addMultiCellWidget(klabel, 0, 0, 3, 4); |
45 | gl->addMultiCellWidget(files, 1, 3, 0, 1); | 45 | gl->addMultiCellWidget(files, 1, 3, 0, 1); |
46 | gl->addMultiCellWidget(keymaps, 1, 3, 3, 4); | 46 | gl->addMultiCellWidget(keymaps, 1, 3, 3, 4); |
47 | gl->addWidget(addButton, 1, 2); | 47 | gl->addWidget(addButton, 1, 2); |
48 | gl->addWidget(delButton, 2, 2); | 48 | gl->addWidget(delButton, 2, 2); |
49 | 49 | ||
50 | gl->addWidget(l, 4, 0); | 50 | gl->addWidget(l, 4, 0); |
51 | gl->addWidget(label, 4, 1); | 51 | gl->addWidget(label, 4, 1); |
52 | gl->addMultiCellWidget(slabelButton, 4, 4, 3, 4); | 52 | gl->addMultiCellWidget(slabelButton, 4, 4, 3, 4); |
53 | 53 | ||
54 | gl->addMultiCellWidget(adlabel, 5, 5, 0, 2); | 54 | gl->addMultiCellWidget(adlabel, 5, 5, 0, 2); |
55 | gl->addMultiCellWidget(ad, 5, 5, 3, 4); | 55 | gl->addMultiCellWidget(ad, 5, 5, 3, 4); |
56 | //gl->addWidget(adms, 5, 3); | 56 | //gl->addWidget(adms, 5, 3); |
57 | 57 | ||
58 | gl->addMultiCellWidget(aplabel, 6, 6, 0, 2); | 58 | gl->addMultiCellWidget(aplabel, 6, 6, 0, 2); |
59 | gl->addMultiCellWidget(ap, 6, 6, 3, 4); | 59 | gl->addMultiCellWidget(ap, 6, 6, 3, 4); |
60 | 60 | ||
61 | //gl->addWidget(apms, 6, 3); | 61 | //gl->addWidget(apms, 6, 3); |
62 | 62 | ||
63 | QList<CfgEntry>& e = cfile->getEntries(); | 63 | QList<CfgEntry>& e = cfile->getEntries(); |
64 | 64 | ||
65 | for(uint i = 0; i < e.count(); i++) { | 65 | for(uint i = 0; i < e.count(); i++) { |
66 | CfgEntry* entry = e.at(i); | 66 | CfgEntry* entry = e.at(i); |
67 | keymaps->insertItem(entry->getFile()); | 67 | keymaps->insertItem(entry->getFile()); |
68 | m.insert(entry->getFile(), entry->getLabel()); | 68 | m.insert(entry->getFile(), entry->getLabel()); |
69 | } | 69 | } |
70 | 70 | ||
71 | QDir dir(QPEApplication::qpeDir()+"/share/zkb", "*.xml"); | 71 | QDir dir(QPEApplication::qpeDir()+"share/zkb", "*.xml"); |
72 | QStringList flist = dir.entryList(); | 72 | QStringList flist = dir.entryList(); |
73 | QStringList::Iterator sit; | 73 | QStringList::Iterator sit; |
74 | for(sit = flist.begin(); sit != flist.end(); ++sit) { | 74 | for(sit = flist.begin(); sit != flist.end(); ++sit) { |
75 | if (*sit != "common.xml" && *sit != "zkb.xml" && m.find(*sit) == m.end()) { | 75 | if (*sit != "common.xml" && *sit != "zkb.xml" && m.find(*sit) == m.end()) { |
76 | files->insertItem(*sit); | 76 | files->insertItem(*sit); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | ad->setValue(cfile->getAutorepeatDelay()); | 80 | ad->setValue(cfile->getAutorepeatDelay()); |
81 | ap->setValue(cfile->getAutorepeatPeriod()); | 81 | ap->setValue(cfile->getAutorepeatPeriod()); |
82 | 82 | ||
83 | //gl->addMultiCellWidget(enable, 7, 7, 0, 4); | 83 | //gl->addMultiCellWidget(enable, 7, 7, 0, 4); |
84 | } | 84 | } |
85 | 85 | ||
86 | CfgDlg::~CfgDlg() { | 86 | CfgDlg::~CfgDlg() { |
87 | } | 87 | } |
88 | 88 | ||
89 | void CfgDlg::add() { | 89 | void CfgDlg::add() { |
90 | if (!files->currentText().isEmpty()) { | 90 | if (!files->currentText().isEmpty()) { |
91 | QString t = files->currentText(); | 91 | QString t = files->currentText(); |
92 | files->removeItem(files->currentItem()); | 92 | files->removeItem(files->currentItem()); |
93 | keymaps->insertItem(t); | 93 | keymaps->insertItem(t); |
94 | cfile->replaceEntry(t, ""); | 94 | cfile->replaceEntry(t, ""); |
95 | m.replace(t, ""); | 95 | m.replace(t, ""); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | void CfgDlg::del() { | 99 | void CfgDlg::del() { |
100 | if (!keymaps->currentText().isEmpty()) { | 100 | if (!keymaps->currentText().isEmpty()) { |
101 | QString t = keymaps->currentText(); | 101 | QString t = keymaps->currentText(); |
102 | keymaps->removeItem(keymaps->currentItem()); | 102 | keymaps->removeItem(keymaps->currentItem()); |
103 | cfile->deleteEntry(t); | 103 | cfile->deleteEntry(t); |
104 | files->insertItem(t); | 104 | files->insertItem(t); |
105 | m.remove(files->currentText()); | 105 | m.remove(files->currentText()); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | void CfgDlg::setLabel() { | 109 | void CfgDlg::setLabel() { |
110 | if (!keymaps->currentText().isEmpty()) { | 110 | if (!keymaps->currentText().isEmpty()) { |
111 | cfile->replaceEntry(keymaps->currentText(), | 111 | cfile->replaceEntry(keymaps->currentText(), |
112 | label->text()); | 112 | label->text()); |
113 | m.replace(keymaps->currentText(), label->text()); | 113 | m.replace(keymaps->currentText(), label->text()); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | void CfgDlg::keymapHighlighted(const QString&text) { | 117 | void CfgDlg::keymapHighlighted(const QString&text) { |
118 | label->setText(*m.find(text)); | 118 | label->setText(*m.find(text)); |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | void CfgDlg::accept() { | 122 | void CfgDlg::accept() { |
123 | cfile->setAutorepeatDelay(ad->value()); | 123 | cfile->setAutorepeatDelay(ad->value()); |
124 | cfile->setAutorepeatPeriod(ap->value()); | 124 | cfile->setAutorepeatPeriod(ap->value()); |
125 | 125 | ||
126 | CfgParser p; | 126 | CfgParser p; |
127 | p.save(QPEApplication::qpeDir()+"/share/zkb/zkb.xml", *cfile); | 127 | p.save(QPEApplication::qpeDir()+"share/zkb/zkb.xml", *cfile); |
128 | QCopEnvelope("QPE/zkb", "reload()"); | 128 | QCopEnvelope("QPE/zkb", "reload()"); |
129 | 129 | ||
130 | QDialog::accept(); | 130 | QDialog::accept(); |
131 | } | 131 | } |
132 | 132 | ||
diff --git a/noncore/applets/zkbapplet/keyzcfg/main.cpp b/noncore/applets/zkbapplet/keyzcfg/main.cpp index 4615562..afd0f6a 100644 --- a/noncore/applets/zkbapplet/keyzcfg/main.cpp +++ b/noncore/applets/zkbapplet/keyzcfg/main.cpp | |||
@@ -1,22 +1,22 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | #include "cfgdlg.h" | 6 | #include "cfgdlg.h" |
7 | 7 | ||
8 | int main( int argc, char **argv ) { | 8 | int main( int argc, char **argv ) { |
9 | QPEApplication app(argc, argv); | 9 | QPEApplication app(argc, argv); |
10 | CfgFile cfile; | 10 | CfgFile cfile; |
11 | CfgParser cp; | 11 | CfgParser cp; |
12 | cp.load(QPEApplication::qpeDir()+"/share/zkb/zkb.xml", cfile); | 12 | cp.load(QPEApplication::qpeDir()+"share/zkb/zkb.xml", cfile); |
13 | 13 | ||
14 | 14 | ||
15 | CfgDlg c(0, &cfile, &app, true); | 15 | CfgDlg c(0, &cfile, &app, true); |
16 | 16 | ||
17 | 17 | ||
18 | app.showMainWidget(&c); | 18 | app.showMainWidget(&c); |
19 | int ret = QPEApplication::execDialog(&c); | 19 | int ret = QPEApplication::execDialog(&c); |
20 | 20 | ||
21 | return ret; | 21 | return ret; |
22 | } | 22 | } |
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp index 59fc242..b4958b3 100644 --- a/noncore/apps/opie-bartender/bartender.cpp +++ b/noncore/apps/opie-bartender/bartender.cpp | |||
@@ -20,193 +20,193 @@ | |||
20 | #include <opie2/odebug.h> | 20 | #include <opie2/odebug.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | using namespace Opie::Core; | 23 | using namespace Opie::Core; |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qlistbox.h> | 29 | #include <qlistbox.h> |
30 | #include <qmultilineedit.h> | 30 | #include <qmultilineedit.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qaction.h> | 33 | #include <qaction.h> |
34 | #include <qheader.h> | 34 | #include <qheader.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qtoolbar.h> | 37 | #include <qtoolbar.h> |
38 | #include <qmenubar.h> | 38 | #include <qmenubar.h> |
39 | 39 | ||
40 | /* STD */ | 40 | /* STD */ |
41 | #include <fcntl.h> | 41 | #include <fcntl.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #include <stdio.h> | 44 | #include <stdio.h> |
45 | #include <errno.h> | 45 | #include <errno.h> |
46 | 46 | ||
47 | Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) | 47 | Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) |
48 | : QMainWindow( parent, name, fl ) { | 48 | : QMainWindow( parent, name, fl ) { |
49 | if ( !name ) | 49 | if ( !name ) |
50 | setName( "Bartender" ); | 50 | setName( "Bartender" ); |
51 | QGridLayout *layout = new QGridLayout( this ); | 51 | QGridLayout *layout = new QGridLayout( this ); |
52 | layout->setSpacing( 2); | 52 | layout->setSpacing( 2); |
53 | layout->setMargin( 2); | 53 | layout->setMargin( 2); |
54 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 54 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
55 | 55 | ||
56 | setCaption( tr( "Bartender" ) ); | 56 | setCaption( tr( "Bartender" ) ); |
57 | 57 | ||
58 | ToolBar1 = new QToolBar( this, "ToolBar1" ); | 58 | ToolBar1 = new QToolBar( this, "ToolBar1" ); |
59 | ToolBar1->setFixedHeight(22); | 59 | ToolBar1->setFixedHeight(22); |
60 | layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); | 60 | layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); |
61 | 61 | ||
62 | QMenuBar *menuBar = new QMenuBar( ToolBar1 ); | 62 | QMenuBar *menuBar = new QMenuBar( ToolBar1 ); |
63 | QPopupMenu *fileMenu; | 63 | QPopupMenu *fileMenu; |
64 | fileMenu = new QPopupMenu( this); | 64 | fileMenu = new QPopupMenu( this); |
65 | menuBar->insertItem( tr("File"), fileMenu ); | 65 | menuBar->insertItem( tr("File"), fileMenu ); |
66 | 66 | ||
67 | fileMenu->insertItem(tr("New Drink")); | 67 | fileMenu->insertItem(tr("New Drink")); |
68 | fileMenu->insertItem(tr("Open Drink")); | 68 | fileMenu->insertItem(tr("Open Drink")); |
69 | fileMenu->insertItem(tr("Find by Drink Name")); | 69 | fileMenu->insertItem(tr("Find by Drink Name")); |
70 | fileMenu->insertItem(tr("Find by Alcohol")); | 70 | fileMenu->insertItem(tr("Find by Alcohol")); |
71 | 71 | ||
72 | QPopupMenu *editMenu; | 72 | QPopupMenu *editMenu; |
73 | editMenu = new QPopupMenu( this); | 73 | editMenu = new QPopupMenu( this); |
74 | menuBar->insertItem( tr("Edit"), editMenu ); | 74 | menuBar->insertItem( tr("Edit"), editMenu ); |
75 | editMenu->insertItem(tr("edit")); | 75 | editMenu->insertItem(tr("edit")); |
76 | 76 | ||
77 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); | 77 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); |
78 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); | 78 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); |
79 | 79 | ||
80 | 80 | ||
81 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); | 81 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); |
82 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 82 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
83 | a->addTo( ToolBar1 ); | 83 | a->addTo( ToolBar1 ); |
84 | 84 | ||
85 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); | 85 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); |
86 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); | 86 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); |
87 | a->addTo( ToolBar1 ); | 87 | a->addTo( ToolBar1 ); |
88 | 88 | ||
89 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); | 89 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); |
90 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); | 90 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); |
91 | a->addTo( ToolBar1 ); | 91 | a->addTo( ToolBar1 ); |
92 | 92 | ||
93 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); | 93 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); |
94 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); | 94 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); |
95 | a->addTo( ToolBar1 ); | 95 | a->addTo( ToolBar1 ); |
96 | 96 | ||
97 | QPushButton *t; | 97 | QPushButton *t; |
98 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); | 98 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); |
99 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); | 99 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); |
100 | 100 | ||
101 | DrinkView = new QListView( this, "DrinkView" ); | 101 | DrinkView = new QListView( this, "DrinkView" ); |
102 | DrinkView->addColumn( tr( "Name of Drink" ) ); | 102 | DrinkView->addColumn( tr( "Name of Drink" ) ); |
103 | // DrinkView->setRootIsDecorated( TRUE ); | 103 | // DrinkView->setRootIsDecorated( TRUE ); |
104 | DrinkView->header()->hide(); | 104 | DrinkView->header()->hide(); |
105 | 105 | ||
106 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); | 106 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); |
107 | 107 | ||
108 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); | 108 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); |
109 | connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 109 | connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
110 | this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); | 110 | this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); |
111 | 111 | ||
112 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); | 112 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); |
113 | if(QDir("db").exists()) { | 113 | if(QDir("db").exists()) { |
114 | dbFile.setName( "db/drinkdb.txt"); | 114 | dbFile.setName( "db/drinkdb.txt"); |
115 | } else | 115 | } else |
116 | dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); | 116 | dbFile.setName( QPEApplication::qpeDir()+"etc/bartender/drinkdb.txt"); |
117 | initDrinkDb(); | 117 | initDrinkDb(); |
118 | } | 118 | } |
119 | 119 | ||
120 | Bartender::~Bartender() { | 120 | Bartender::~Bartender() { |
121 | } | 121 | } |
122 | 122 | ||
123 | /* | 123 | /* |
124 | this happens right before exit */ | 124 | this happens right before exit */ |
125 | void Bartender::cleanUp() { | 125 | void Bartender::cleanUp() { |
126 | dbFile.close(); | 126 | dbFile.close(); |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | void Bartender::initDrinkDb() { | 130 | void Bartender::initDrinkDb() { |
131 | 131 | ||
132 | if(!dbFile.isOpen()) | 132 | if(!dbFile.isOpen()) |
133 | if ( !dbFile.open( IO_ReadOnly)) { | 133 | if ( !dbFile.open( IO_ReadOnly)) { |
134 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 134 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | fillList(); | 137 | fillList(); |
138 | } | 138 | } |
139 | 139 | ||
140 | void Bartender::fillList() { | 140 | void Bartender::fillList() { |
141 | dbFile.at(1); | 141 | dbFile.at(1); |
142 | DrinkView->clear(); | 142 | DrinkView->clear(); |
143 | int i=0; | 143 | int i=0; |
144 | QListViewItem * item ; | 144 | QListViewItem * item ; |
145 | QTextStream t( &dbFile); | 145 | QTextStream t( &dbFile); |
146 | QString s; | 146 | QString s; |
147 | while ( !t.eof()) { | 147 | while ( !t.eof()) { |
148 | s = t.readLine(); | 148 | s = t.readLine(); |
149 | if(s.find("#",0,TRUE) != -1) { | 149 | if(s.find("#",0,TRUE) != -1) { |
150 | // odebug << s.right(s.length()-2) << oendl; | 150 | // odebug << s.right(s.length()-2) << oendl; |
151 | item= new QListViewItem( DrinkView, 0 ); | 151 | item= new QListViewItem( DrinkView, 0 ); |
152 | item->setText( 0, s.right(s.length()-2)); | 152 | item->setText( 0, s.right(s.length()-2)); |
153 | i++; | 153 | i++; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | odebug << "there are currently " << i << " of drinks" << oendl; | 156 | odebug << "there are currently " << i << " of drinks" << oendl; |
157 | } | 157 | } |
158 | 158 | ||
159 | void Bartender::fileNew() { | 159 | void Bartender::fileNew() { |
160 | 160 | ||
161 | New_Drink *newDrinks; | 161 | New_Drink *newDrinks; |
162 | newDrinks = new New_Drink(this,"New Drink....", TRUE); | 162 | newDrinks = new New_Drink(this,"New Drink....", TRUE); |
163 | QString newName, newIng; | 163 | QString newName, newIng; |
164 | QPEApplication::execDialog( newDrinks ); | 164 | QPEApplication::execDialog( newDrinks ); |
165 | newName = newDrinks->LineEdit1->text(); | 165 | newName = newDrinks->LineEdit1->text(); |
166 | newIng= newDrinks->MultiLineEdit1->text(); | 166 | newIng= newDrinks->MultiLineEdit1->text(); |
167 | 167 | ||
168 | if(dbFile.isOpen()) | 168 | if(dbFile.isOpen()) |
169 | dbFile.close(); | 169 | dbFile.close(); |
170 | if ( !dbFile.open( IO_WriteOnly| IO_Append)) { | 170 | if ( !dbFile.open( IO_WriteOnly| IO_Append)) { |
171 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 171 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
172 | return; | 172 | return; |
173 | } | 173 | } |
174 | if(newDrinks ->result() == 1 ) { | 174 | if(newDrinks ->result() == 1 ) { |
175 | QString newDrink="\n# "+newName+"\n"; | 175 | QString newDrink="\n# "+newName+"\n"; |
176 | newDrink.append(newIng+"\n"); | 176 | newDrink.append(newIng+"\n"); |
177 | odebug << "writing "+newDrink << oendl; | 177 | odebug << "writing "+newDrink << oendl; |
178 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); | 178 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); |
179 | clearList(); | 179 | clearList(); |
180 | dbFile.close(); | 180 | dbFile.close(); |
181 | 181 | ||
182 | initDrinkDb(); | 182 | initDrinkDb(); |
183 | } | 183 | } |
184 | delete newDrinks; | 184 | delete newDrinks; |
185 | } | 185 | } |
186 | 186 | ||
187 | void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { | 187 | void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { |
188 | switch (mouse) { | 188 | switch (mouse) { |
189 | case 1: | 189 | case 1: |
190 | // showDrink(item); | 190 | // showDrink(item); |
191 | break; | 191 | break; |
192 | case 2: | 192 | case 2: |
193 | showDrink(item); | 193 | showDrink(item); |
194 | break; | 194 | break; |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | void Bartender::showDrink( QListViewItem *item) { | 198 | void Bartender::showDrink( QListViewItem *item) { |
199 | if(item==NULL) return; | 199 | if(item==NULL) return; |
200 | dbFile.at(0); | 200 | dbFile.at(0); |
201 | Show_Drink *showDrinks; | 201 | Show_Drink *showDrinks; |
202 | QString myDrink=item->text(0); | 202 | QString myDrink=item->text(0); |
203 | showDrinks = new Show_Drink(this, myDrink, TRUE); | 203 | showDrinks = new Show_Drink(this, myDrink, TRUE); |
204 | QTextStream t( &dbFile); | 204 | QTextStream t( &dbFile); |
205 | 205 | ||
206 | QString s, s2; | 206 | QString s, s2; |
207 | while ( !t.eof()) { | 207 | while ( !t.eof()) { |
208 | s = t.readLine(); | 208 | s = t.readLine(); |
209 | if(s.find( myDrink, 0, TRUE) != -1) { | 209 | if(s.find( myDrink, 0, TRUE) != -1) { |
210 | for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { | 210 | for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { |
211 | s2 = t.readLine(); | 211 | s2 = t.readLine(); |
212 | if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { | 212 | if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { |
diff --git a/noncore/apps/opie-console/fixit.cpp b/noncore/apps/opie-console/fixit.cpp index 3b0044a..f170074 100644 --- a/noncore/apps/opie-console/fixit.cpp +++ b/noncore/apps/opie-console/fixit.cpp | |||
@@ -1,94 +1,94 @@ | |||
1 | 1 | ||
2 | #include "fixit.h" | 2 | #include "fixit.h" |
3 | 3 | ||
4 | using namespace Opie::Core; | 4 | using namespace Opie::Core; |
5 | 5 | ||
6 | #ifdef FSCKED_DISTRI | 6 | #ifdef FSCKED_DISTRI |
7 | FixIt::FixIt() { | 7 | FixIt::FixIt() { |
8 | /* the new inittab */ | 8 | /* the new inittab */ |
9 | m_file = "#\n# /etc/inittab" | 9 | m_file = "#\n# /etc/inittab" |
10 | "#" | 10 | "#" |
11 | "" | 11 | "" |
12 | "# 0 - halt (Do NOT set initdefault to this)" | 12 | "# 0 - halt (Do NOT set initdefault to this)" |
13 | "# 1 - Single user mode" | 13 | "# 1 - Single user mode" |
14 | "# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)" | 14 | "# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)" |
15 | "# 3 - Full multiuser mode" | 15 | "# 3 - Full multiuser mode" |
16 | "# 4 - JavaVM(Intent) developer mode" | 16 | "# 4 - JavaVM(Intent) developer mode" |
17 | "# 5 - JavaVM(Intent)" | 17 | "# 5 - JavaVM(Intent)" |
18 | "# 6 - reboot (Do NOT set initdefault to this)" | 18 | "# 6 - reboot (Do NOT set initdefault to this)" |
19 | "#" | 19 | "#" |
20 | "id:5:initdefault:" | 20 | "id:5:initdefault:" |
21 | "" | 21 | "" |
22 | "# Specify things to do when starting" | 22 | "# Specify things to do when starting" |
23 | "si::sysinit:/etc/rc.d/rc.sysinit" | 23 | "si::sysinit:/etc/rc.d/rc.sysinit" |
24 | "" | 24 | "" |
25 | "l0:0:wait:/root/etc/rc.d/rc 0" | 25 | "l0:0:wait:/root/etc/rc.d/rc 0" |
26 | "l1:1:wait:/etc/rc.d/rc 1" | 26 | "l1:1:wait:/etc/rc.d/rc 1" |
27 | "l2:2:wait:/etc/rc.d/rc 2" | 27 | "l2:2:wait:/etc/rc.d/rc 2" |
28 | "l3:3:wait:/etc/rc.d/rc 3" | 28 | "l3:3:wait:/etc/rc.d/rc 3" |
29 | "l4:4:wait:/etc/rc.d/rc 4" | 29 | "l4:4:wait:/etc/rc.d/rc 4" |
30 | "l5:5:wait:/etc/rc.d/rc 5" | 30 | "l5:5:wait:/etc/rc.d/rc 5" |
31 | "l6:6:wait:/root/etc/rc.d/rc 6" | 31 | "l6:6:wait:/root/etc/rc.d/rc 6" |
32 | "" | 32 | "" |
33 | "# Specify things to do before rebooting" | 33 | "# Specify things to do before rebooting" |
34 | "um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" | 34 | "um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" |
35 | "sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" | 35 | "sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" |
36 | "" | 36 | "" |
37 | "# Specify program to run on ttyS0" | 37 | "# Specify program to run on ttyS0" |
38 | "s0:24:respawn:/sbin/getty 9600 ttyS0" | 38 | "s0:24:respawn:/sbin/getty 9600 ttyS0" |
39 | "#pd:5:respawn:/etc/sync/serialctl" | 39 | "#pd:5:respawn:/etc/sync/serialctl" |
40 | "" | 40 | "" |
41 | "# Specify program to run on tty1" | 41 | "# Specify program to run on tty1" |
42 | "1:2:respawn:/sbin/getty 9600 tty1" | 42 | "1:2:respawn:/sbin/getty 9600 tty1" |
43 | "ln:345:respawn:survive -l 6 /sbin/launch" | 43 | "ln:345:respawn:survive -l 6 /sbin/launch" |
44 | "#qt:5:respawn:/sbin/qt" | 44 | "#qt:5:respawn:/sbin/qt" |
45 | "" | 45 | "" |
46 | "# collie sp." | 46 | "# collie sp." |
47 | "sy::respawn:/sbin/shsync\n"; | 47 | "sy::respawn:/sbin/shsync\n"; |
48 | } | 48 | } |
49 | 49 | ||
50 | /* | 50 | /* |
51 | * the retail Zaurus is broken in many ways | 51 | * the retail Zaurus is broken in many ways |
52 | * one is that pppd is listening on our port... | 52 | * one is that pppd is listening on our port... |
53 | * we've to stop it from that and then do kill(SIGHUP,1); | 53 | * we've to stop it from that and then do kill(SIGHUP,1); |
54 | */ | 54 | */ |
55 | void FixIt::fixIt() { | 55 | void FixIt::fixIt() { |
56 | #ifndef EAST | 56 | #ifndef EAST |
57 | ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); | 57 | ::rename("/etc/inittab", QPEApplication::qpeDir() + "etc/inittab" ); |
58 | QFile file( "/etc/inittab" ); | 58 | QFile file( "/etc/inittab" ); |
59 | if ( file.open(IO_WriteOnly | IO_Raw ) ) { | 59 | if ( file.open(IO_WriteOnly | IO_Raw ) ) { |
60 | file.writeBlock(m_file,strlen(m_file) ); | 60 | file.writeBlock(m_file,strlen(m_file) ); |
61 | } | 61 | } |
62 | file.close(); | 62 | file.close(); |
63 | ::kill( SIGHUP, 1 ); | 63 | ::kill( SIGHUP, 1 ); |
64 | 64 | ||
65 | #else | 65 | #else |
66 | 66 | ||
67 | OProcess m_kill; | 67 | OProcess m_kill; |
68 | m_kill << QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_kill_0_1.sh"; | 68 | m_kill << QPEApplication::qpeDir() + "share/opie-console/sl6000_embedix_kill_0_1.sh"; |
69 | 69 | ||
70 | 70 | ||
71 | if ( !m_kill.start(OProcess::DontCare,OProcess::NoCommunication) ) { | 71 | if ( !m_kill.start(OProcess::DontCare,OProcess::NoCommunication) ) { |
72 | owarn << "could not execute kill script" << oendl; | 72 | owarn << "could not execute kill script" << oendl; |
73 | } else { | 73 | } else { |
74 | Global::statusMessage( QObject::tr("Fixing up Embedix")); | 74 | Global::statusMessage( QObject::tr("Fixing up Embedix")); |
75 | } | 75 | } |
76 | 76 | ||
77 | #endif | 77 | #endif |
78 | } | 78 | } |
79 | 79 | ||
80 | void FixIt::breakIt() { | 80 | void FixIt::breakIt() { |
81 | #ifdef EAST | 81 | #ifdef EAST |
82 | OProcess m_restart; | 82 | OProcess m_restart; |
83 | m_restart << QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_restart_0_1.sh"; | 83 | m_restart << QPEApplication::qpeDir() + "share/opie-console/sl6000_embedix_restart_0_1.sh"; |
84 | 84 | ||
85 | 85 | ||
86 | if ( !m_restart.start(OProcess::DontCare,OProcess::NoCommunication) ) { | 86 | if ( !m_restart.start(OProcess::DontCare,OProcess::NoCommunication) ) { |
87 | owarn << "could not execute restart script" << oendl; | 87 | owarn << "could not execute restart script" << oendl; |
88 | } | 88 | } |
89 | 89 | ||
90 | #endif | 90 | #endif |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | #endif | 94 | #endif |
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp index 020a116..3c096ed 100644 --- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp +++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp | |||
@@ -1,153 +1,153 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | // LibraryDialog.cpp - description | 2 | // LibraryDialog.cpp - description |
3 | // ------------------- | 3 | // ------------------- |
4 | // begin : Sat Aug 19 2000 | 4 | // begin : Sat Aug 19 2000 |
5 | // copyright : (C) 2000 - 2004 by llornkcor | 5 | // copyright : (C) 2000 - 2004 by llornkcor |
6 | // email : ljp@llornkcor.com | 6 | // email : ljp@llornkcor.com |
7 | // ***************************************************/ | 7 | // ***************************************************/ |
8 | // /*************************************************************************** | 8 | // /*************************************************************************** |
9 | // * This program is free software; you can redistribute it and/or modify * | 9 | // * This program is free software; you can redistribute it and/or modify * |
10 | // * it under the terms of the GNU General Public License as published by * | 10 | // * it under the terms of the GNU General Public License as published by * |
11 | // * the Free Software Foundation; either version 2 of the License, or * | 11 | // * the Free Software Foundation; either version 2 of the License, or * |
12 | // * (at your option) any later version. * | 12 | // * (at your option) any later version. * |
13 | // ***************************************************************************/ | 13 | // ***************************************************************************/ |
14 | //ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL | 14 | //ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL |
15 | 15 | ||
16 | #include "LibraryDialog.h" | 16 | #include "LibraryDialog.h" |
17 | #include "output.h" | 17 | #include "output.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qpedialog.h> | 22 | #include <qpe/qpedialog.h> |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | //#include <qlayout.h> | 28 | //#include <qlayout.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * The dialog will by default be modeless, unless you set 'modal' to | 36 | * The dialog will by default be modeless, unless you set 'modal' to |
37 | * TRUE to construct a modal dialog. */ | 37 | * TRUE to construct a modal dialog. */ |
38 | LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl ) | 38 | LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl ) |
39 | : QDialog( parent, name, true/* modal*/, fl ) | 39 | : QDialog( parent, name, true/* modal*/, fl ) |
40 | { | 40 | { |
41 | if ( !name ) | 41 | if ( !name ) |
42 | setName( "LibraryDialog" ); | 42 | setName( "LibraryDialog" ); |
43 | indexLoaded=false; | 43 | indexLoaded=false; |
44 | initDialog(); | 44 | initDialog(); |
45 | 45 | ||
46 | // this->setMaximumWidth(240); | 46 | // this->setMaximumWidth(240); |
47 | 47 | ||
48 | index = "GUTINDEX.ALL"; | 48 | index = "GUTINDEX.ALL"; |
49 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 49 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
50 | local_index = local_library + index; | 50 | local_index = local_library + index; |
51 | 51 | ||
52 | QString iniFile ; | 52 | QString iniFile ; |
53 | iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; | 53 | iniFile = QPEApplication::qpeDir()+"etc/gutenbrowser/gutenbrowserrc"; |
54 | 54 | ||
55 | new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; | 55 | new_index =QPEApplication::qpeDir()+"etc/gutenbrowser/PGWHOLE.TXT"; |
56 | 56 | ||
57 | old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; | 57 | old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
58 | // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; | 58 | // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; |
59 | 59 | ||
60 | // iniFile = local_library+"gutenbrowserrc"; | 60 | // iniFile = local_library+"gutenbrowserrc"; |
61 | // new_index = local_library + "PGWHOLE.TXT"; | 61 | // new_index = local_library + "PGWHOLE.TXT"; |
62 | // old_index = local_library + "GUTINDEX.ALL"; | 62 | // old_index = local_library + "GUTINDEX.ALL"; |
63 | 63 | ||
64 | Config config("Gutenbrowser"); | 64 | Config config("Gutenbrowser"); |
65 | 65 | ||
66 | config.setGroup( "HttpServer" ); | 66 | config.setGroup( "HttpServer" ); |
67 | proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); | 67 | proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); |
68 | 68 | ||
69 | config.setGroup( "FTPsite" ); | 69 | config.setGroup( "FTPsite" ); |
70 | ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); | 70 | ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); |
71 | odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; | 71 | odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; |
72 | // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); | 72 | // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); |
73 | // ftp_host=ftp_host.stripWhiteSpace(); | 73 | // ftp_host=ftp_host.stripWhiteSpace(); |
74 | ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); | 74 | ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); |
75 | 75 | ||
76 | i_binary = 0; | 76 | i_binary = 0; |
77 | 77 | ||
78 | config.setGroup("SortAuth"); | 78 | config.setGroup("SortAuth"); |
79 | if( config.readEntry("authSort", "FALSE") == "TRUE") | 79 | if( config.readEntry("authSort", "FALSE") == "TRUE") |
80 | authBox->setChecked(TRUE); | 80 | authBox->setChecked(TRUE); |
81 | 81 | ||
82 | config.setGroup("General"); | 82 | config.setGroup("General"); |
83 | downDir =config.readEntry( "DownloadDirectory",local_library); | 83 | downDir =config.readEntry( "DownloadDirectory",local_library); |
84 | odebug << "downDir is "+downDir << oendl; | 84 | odebug << "downDir is "+downDir << oendl; |
85 | newindexLib.setName( old_index); | 85 | newindexLib.setName( old_index); |
86 | indexLib.setName( old_index); | 86 | indexLib.setName( old_index); |
87 | 87 | ||
88 | new QPEDialogListener(this); | 88 | new QPEDialogListener(this); |
89 | QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); | 89 | QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | LibraryDialog::~LibraryDialog() | 93 | LibraryDialog::~LibraryDialog() |
94 | { | 94 | { |
95 | // delete QList_Item2; | 95 | // delete QList_Item2; |
96 | // delete QList_Item1; | 96 | // delete QList_Item1; |
97 | // delete QList_Item3; | 97 | // delete QList_Item3; |
98 | // delete QList_Item4; | 98 | // delete QList_Item4; |
99 | // delete QList_Item5; | 99 | // delete QList_Item5; |
100 | 100 | ||
101 | // saveConfig(); | 101 | // saveConfig(); |
102 | } | 102 | } |
103 | 103 | ||
104 | /*This groks using PGWHOLE.TXT */ | 104 | /*This groks using PGWHOLE.TXT */ |
105 | void LibraryDialog::Newlibrary() | 105 | void LibraryDialog::Newlibrary() |
106 | { | 106 | { |
107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files | 107 | #ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files |
108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; | 108 | //odebug << "Opening new library index " << newindexLib << "" << oendl; |
109 | if ( newindexLib.open( IO_ReadOnly) ) { | 109 | if ( newindexLib.open( IO_ReadOnly) ) { |
110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully | 110 | setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully |
111 | QTextStream indexStream( &newindexLib ); | 111 | QTextStream indexStream( &newindexLib ); |
112 | QString indexLine; | 112 | QString indexLine; |
113 | while ( !indexStream.atEnd() ) { // until end of file.. | 113 | while ( !indexStream.atEnd() ) { // until end of file.. |
114 | indexLine = indexStream.readLine(); | 114 | indexLine = indexStream.readLine(); |
115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { | 115 | if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { |
116 | year = indexLine.mid(4,4); | 116 | year = indexLine.mid(4,4); |
117 | year = year.stripWhiteSpace(); | 117 | year = year.stripWhiteSpace(); |
118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); | 118 | file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); |
119 | file = file.stripWhiteSpace(); | 119 | file = file.stripWhiteSpace(); |
120 | number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); | 120 | number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); |
121 | if( year.toInt() < 1984) | 121 | if( year.toInt() < 1984) |
122 | number = number.left( number.length() -1 ); | 122 | number = number.left( number.length() -1 ); |
123 | number = number.stripWhiteSpace(); | 123 | number = number.stripWhiteSpace(); |
124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); | 124 | title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); |
125 | title = title.stripWhiteSpace(); | 125 | title = title.stripWhiteSpace(); |
126 | 126 | ||
127 | getAuthor(); // groks author | 127 | getAuthor(); // groks author |
128 | author = author.stripWhiteSpace(); | 128 | author = author.stripWhiteSpace(); |
129 | if (authBox->isChecked()) { // this reverses the first name and last name of the author | 129 | if (authBox->isChecked()) { // this reverses the first name and last name of the author |
130 | // odebug << "Sorting last name first" << oendl; | 130 | // odebug << "Sorting last name first" << oendl; |
131 | QString lastName, firstName=""; | 131 | QString lastName, firstName=""; |
132 | int finder=author.findRev( ' ', -1, TRUE); | 132 | int finder=author.findRev( ' ', -1, TRUE); |
133 | lastName=author.right( author.length()-finder); | 133 | lastName=author.right( author.length()-finder); |
134 | firstName=author.left(finder); | 134 | firstName=author.left(finder); |
135 | lastName=lastName.stripWhiteSpace(); | 135 | lastName=lastName.stripWhiteSpace(); |
136 | firstName=firstName.stripWhiteSpace(); | 136 | firstName=firstName.stripWhiteSpace(); |
137 | 137 | ||
138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names | 138 | if( lastName.find( firstName, 0, true) == -1) // this avoids dup names |
139 | author=lastName+", "+firstName; | 139 | author=lastName+", "+firstName; |
140 | } | 140 | } |
141 | 141 | ||
142 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { | 142 | if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { |
143 | 143 | ||
144 | // fill string list or something to be able to resort the whole library | 144 | // fill string list or something to be able to resort the whole library |
145 | if( author.isEmpty() ) | 145 | if( author.isEmpty() ) |
146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); | 146 | QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); |
147 | else { | 147 | else { |
148 | 148 | ||
149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || | 149 | if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || |
150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) | 150 | (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) |
151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); | 151 | QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); |
152 | 152 | ||
153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || | 153 | else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || |
diff --git a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp index a9c7346..de9c72b 100644 --- a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp +++ b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp | |||
@@ -1,137 +1,137 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | ftpsitedlg.cpp - description | 2 | ftpsitedlg.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Tue Jul 25 2000 | 4 | begin : Tue Jul 25 2000 |
5 | copyright : (C) 2000 -2004 by llornkcor | 5 | copyright : (C) 2000 -2004 by llornkcor |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * This program is free software; you can redistribute it and/or modify * | 9 | * This program is free software; you can redistribute it and/or modify * |
10 | * it under the terms of the GNU General Public License as published by * | 10 | * it under the terms of the GNU General Public License as published by * |
11 | * the Free Software Foundation; either version 2 of the License, or * | 11 | * the Free Software Foundation; either version 2 of the License, or * |
12 | * (at your option) any later version. * | 12 | * (at your option) any later version. * |
13 | ***************************************************************************/ | 13 | ***************************************************************************/ |
14 | 14 | ||
15 | #include "optionsDialog.h" | 15 | #include "optionsDialog.h" |
16 | #include "gutenbrowser.h" | 16 | #include "gutenbrowser.h" |
17 | //#include "NetworkDialog.h" | 17 | //#include "NetworkDialog.h" |
18 | #include "output.h" | 18 | #include "output.h" |
19 | 19 | ||
20 | /* OPIE */ | 20 | /* OPIE */ |
21 | #include <opie2/odebug.h> | 21 | #include <opie2/odebug.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | 23 | ||
24 | /* QT */ | 24 | /* QT */ |
25 | #include <qprogressbar.h> | 25 | #include <qprogressbar.h> |
26 | #include <qurloperator.h> | 26 | #include <qurloperator.h> |
27 | #include <qlistbox.h> | 27 | #include <qlistbox.h> |
28 | 28 | ||
29 | /* STD */ | 29 | /* STD */ |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | 33 | ||
34 | // :)~ | 34 | // :)~ |
35 | void optionsDialog::ftpSiteDlg( ) | 35 | void optionsDialog::ftpSiteDlg( ) |
36 | { | 36 | { |
37 | //printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" ); | 37 | //printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" ); |
38 | // initDialog(); | 38 | // initDialog(); |
39 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 39 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
40 | // ListFile = local_library + "ftpList"; | 40 | // ListFile = local_library + "ftpList"; |
41 | ListFile = QPEApplication::qpeDir() + "/etc/gutenbrowser"; | 41 | ListFile = QPEApplication::qpeDir() + "etc/gutenbrowser"; |
42 | QDir dir(ListFile); | 42 | QDir dir(ListFile); |
43 | if( !dir.exists()) | 43 | if( !dir.exists()) |
44 | dir.mkdir(ListFile,true); | 44 | dir.mkdir(ListFile,true); |
45 | ListFile+="/ftpList"; | 45 | ListFile+="/ftpList"; |
46 | odebug << "opening "+ListFile << oendl; | 46 | odebug << "opening "+ListFile << oendl; |
47 | if ( QFile(ListFile).exists() ) { | 47 | if ( QFile(ListFile).exists() ) { |
48 | openSiteList(); | 48 | openSiteList(); |
49 | } else { | 49 | } else { |
50 | switch( QMessageBox::warning( this, "Gutenbrowser", | 50 | switch( QMessageBox::warning( this, "Gutenbrowser", |
51 | "Do you want to download \nan ftp site list?", | 51 | "Do you want to download \nan ftp site list?", |
52 | QMessageBox::Yes, QMessageBox::No)) { | 52 | QMessageBox::Yes, QMessageBox::No)) { |
53 | case QMessageBox::Yes: // yes | 53 | case QMessageBox::Yes: // yes |
54 | getSite(); | 54 | getSite(); |
55 | break; | 55 | break; |
56 | case QMessageBox::No: // No | 56 | case QMessageBox::No: // No |
57 | // exit | 57 | // exit |
58 | break; | 58 | break; |
59 | } | 59 | } |
60 | 60 | ||
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | /* | 65 | /* |
66 | // get ftp list from web- parse it. */ | 66 | // get ftp list from web- parse it. */ |
67 | void optionsDialog::getSite() | 67 | void optionsDialog::getSite() |
68 | { | 68 | { |
69 | QString file_name; | 69 | QString file_name; |
70 | QString ftp_listFileURL; | 70 | QString ftp_listFileURL; |
71 | QString outputFile; | 71 | QString outputFile; |
72 | // outputFile = local_library+ "list.html"; | 72 | // outputFile = local_library+ "list.html"; |
73 | outputFile = ListFile + "list.html"; | 73 | outputFile = ListFile + "list.html"; |
74 | QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html"; | 74 | QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html"; |
75 | //http://www.gutenberg.org/index.html"; | 75 | //http://www.gutenberg.org/index.html"; |
76 | // QString networkUrl= "http://llornkcor.com/index.shtml"; | 76 | // QString networkUrl= "http://llornkcor.com/index.shtml"; |
77 | // // "http://www.gutenberg.org/index.html" | 77 | // // "http://www.gutenberg.org/index.html" |
78 | // | 78 | // |
79 | //Qhttp stops working at times.... :( | 79 | //Qhttp stops working at times.... :( |
80 | // NetworkDialog *NetworkDlg; | 80 | // NetworkDialog *NetworkDlg; |
81 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); | 81 | // NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); |
82 | // if( NetworkDlg->exec() != 0 ) | 82 | // if( NetworkDlg->exec() != 0 ) |
83 | // { // use new, improved, *INSTANT* network-dialog-file-getterer | 83 | // { // use new, improved, *INSTANT* network-dialog-file-getterer |
84 | // odebug << "gitcha!" << oendl; | 84 | // odebug << "gitcha!" << oendl; |
85 | // } | 85 | // } |
86 | // delete NetworkDlg; | 86 | // delete NetworkDlg; |
87 | //#ifdef Q_WS_QWS | 87 | //#ifdef Q_WS_QWS |
88 | 88 | ||
89 | // TODO qprocess here | 89 | // TODO qprocess here |
90 | 90 | ||
91 | QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ; | 91 | QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ; |
92 | odebug << "Issuing the command "+cmd << oendl; | 92 | odebug << "Issuing the command "+cmd << oendl; |
93 | Output *outDlg; | 93 | Output *outDlg; |
94 | outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); | 94 | outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); |
95 | outDlg->showMaximized(); | 95 | outDlg->showMaximized(); |
96 | outDlg->show(); | 96 | outDlg->show(); |
97 | qApp->processEvents(); | 97 | qApp->processEvents(); |
98 | FILE *fp; | 98 | FILE *fp; |
99 | char line[130]; | 99 | char line[130]; |
100 | outDlg->OutputEdit->append( tr("Running wget") ); | 100 | outDlg->OutputEdit->append( tr("Running wget") ); |
101 | sleep(1); | 101 | sleep(1); |
102 | fp = popen( (const char *) cmd, "r"); | 102 | fp = popen( (const char *) cmd, "r"); |
103 | while ( fgets( line, sizeof line, fp)) { | 103 | while ( fgets( line, sizeof line, fp)) { |
104 | outDlg->OutputEdit->append(line); | 104 | outDlg->OutputEdit->append(line); |
105 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 105 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
106 | } | 106 | } |
107 | pclose(fp); | 107 | pclose(fp); |
108 | outDlg->close(); | 108 | outDlg->close(); |
109 | if(outDlg) | 109 | if(outDlg) |
110 | delete outDlg; | 110 | delete outDlg; |
111 | 111 | ||
112 | // outputFile=ListFile; | 112 | // outputFile=ListFile; |
113 | ftp_QListBox_1->clear(); | 113 | ftp_QListBox_1->clear(); |
114 | parseFtpList( outputFile); // got the html list, now parse it so we can use it | 114 | parseFtpList( outputFile); // got the html list, now parse it so we can use it |
115 | } | 115 | } |
116 | 116 | ||
117 | bool optionsDialog::parseFtpList( QString outputFile) | 117 | bool optionsDialog::parseFtpList( QString outputFile) |
118 | { | 118 | { |
119 | // parse ftplist html and extract just the machine names/directories | 119 | // parse ftplist html and extract just the machine names/directories |
120 | // TODO: add locations!! | 120 | // TODO: add locations!! |
121 | odebug << "parse ftplist "+outputFile << oendl; | 121 | odebug << "parse ftplist "+outputFile << oendl; |
122 | QString ftpList, s_location; | 122 | QString ftpList, s_location; |
123 | QFile f( outputFile ); | 123 | QFile f( outputFile ); |
124 | 124 | ||
125 | if( f.open( IO_ReadWrite )) { | 125 | if( f.open( IO_ReadWrite )) { |
126 | QTextStream t( &f); | 126 | QTextStream t( &f); |
127 | QString countryName; | 127 | QString countryName; |
128 | bool b_gotchTest=false; | 128 | bool b_gotchTest=false; |
129 | 129 | ||
130 | while ( !t.eof() ) { | 130 | while ( !t.eof() ) { |
131 | QString s = t.readLine(); | 131 | QString s = t.readLine(); |
132 | int start; | 132 | int start; |
133 | int end; | 133 | int end; |
134 | if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file | 134 | if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file |
135 | b_gotchTest = true; | 135 | b_gotchTest = true; |
136 | } | 136 | } |
137 | if( b_gotchTest) { | 137 | if( b_gotchTest) { |
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index 644fae8..fac21da 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | |||
@@ -49,198 +49,198 @@ | |||
49 | #include <qobjectlist.h> | 49 | #include <qobjectlist.h> |
50 | #include <qfontdialog.h> | 50 | #include <qfontdialog.h> |
51 | #include <qtextview.h> | 51 | #include <qtextview.h> |
52 | #include <qbrush.h> | 52 | #include <qbrush.h> |
53 | #include <qfile.h> | 53 | #include <qfile.h> |
54 | #include <qfontinfo.h> | 54 | #include <qfontinfo.h> |
55 | #include <qscrollview.h> | 55 | #include <qscrollview.h> |
56 | #include <qpoint.h> | 56 | #include <qpoint.h> |
57 | 57 | ||
58 | /* STD */ | 58 | /* STD */ |
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <unistd.h> | 61 | #include <unistd.h> |
62 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
63 | #include <fcntl.h> | 63 | #include <fcntl.h> |
64 | #include <errno.h> | 64 | #include <errno.h> |
65 | 65 | ||
66 | static const int nfontsizes = 9; | 66 | static const int nfontsizes = 9; |
67 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; | 67 | static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; |
68 | 68 | ||
69 | #ifdef NOQUICKLAUNCH | 69 | #ifdef NOQUICKLAUNCH |
70 | Gutenbrowser::Gutenbrowser() | 70 | Gutenbrowser::Gutenbrowser() |
71 | Gutenbrowser(); | 71 | Gutenbrowser(); |
72 | #else | 72 | #else |
73 | Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) | 73 | Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) |
74 | #endif | 74 | #endif |
75 | : QMainWindow() | 75 | : QMainWindow() |
76 | { | 76 | { |
77 | // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 77 | // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
78 | // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); | 78 | // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); |
79 | // e << ""; | 79 | // e << ""; |
80 | // QPEApplication::grabKeyboard(); | 80 | // QPEApplication::grabKeyboard(); |
81 | showMainList=TRUE; | 81 | showMainList=TRUE; |
82 | working=false; | 82 | working=false; |
83 | this->setUpdatesEnabled(TRUE); | 83 | this->setUpdatesEnabled(TRUE); |
84 | // #ifndef Q_WS_QWS | 84 | // #ifndef Q_WS_QWS |
85 | QString msg; | 85 | QString msg; |
86 | msg="You have now entered unto gutenbrowser,\n"; | 86 | msg="You have now entered unto gutenbrowser,\n"; |
87 | msg+="make your self at home, sit back, relax and read something great.\n"; | 87 | msg+="make your self at home, sit back, relax and read something great.\n"; |
88 | 88 | ||
89 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; | 89 | local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; |
90 | setCaption("Gutenbrowser");// Embedded " VERSION); | 90 | setCaption("Gutenbrowser");// Embedded " VERSION); |
91 | this->setUpdatesEnabled(TRUE); | 91 | this->setUpdatesEnabled(TRUE); |
92 | 92 | ||
93 | // bool firstTime=FALSE; | 93 | // bool firstTime=FALSE; |
94 | topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); | 94 | topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); |
95 | 95 | ||
96 | menu = new QHBoxLayout(-1,"menu"); | 96 | menu = new QHBoxLayout(-1,"menu"); |
97 | buttons2 = new QHBoxLayout(-1,"buttons2"); | 97 | buttons2 = new QHBoxLayout(-1,"buttons2"); |
98 | edits = new QHBoxLayout(-1,"edits"); | 98 | edits = new QHBoxLayout(-1,"edits"); |
99 | 99 | ||
100 | useSplitter=TRUE; | 100 | useSplitter=TRUE; |
101 | 101 | ||
102 | initConfig(); | 102 | initConfig(); |
103 | initMenuBar(); | 103 | initMenuBar(); |
104 | initButtonBar(); | 104 | initButtonBar(); |
105 | initStatusBar(); | 105 | initStatusBar(); |
106 | initView(); | 106 | initView(); |
107 | initSlots(); | 107 | initSlots(); |
108 | qDebug("init finished"); | 108 | qDebug("init finished"); |
109 | QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); | 109 | QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); |
110 | 110 | ||
111 | connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), | 111 | connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), |
112 | this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); | 112 | this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); |
113 | if( useIcons) | 113 | if( useIcons) |
114 | toggleButtonIcons( TRUE); | 114 | toggleButtonIcons( TRUE); |
115 | else | 115 | else |
116 | toggleButtonIcons( FALSE); | 116 | toggleButtonIcons( FALSE); |
117 | 117 | ||
118 | enableButtons(false); | 118 | enableButtons(false); |
119 | 119 | ||
120 | Config config("Gutenbrowser"); // populate menubuttonlist | 120 | Config config("Gutenbrowser"); // populate menubuttonlist |
121 | config.setGroup("General"); | 121 | config.setGroup("General"); |
122 | 122 | ||
123 | config.setGroup( "Files" ); | 123 | config.setGroup( "Files" ); |
124 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); | 124 | QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); |
125 | int i_numofFiles = s_numofFiles.toInt(); | 125 | int i_numofFiles = s_numofFiles.toInt(); |
126 | 126 | ||
127 | QString tempFileName; | 127 | QString tempFileName; |
128 | 128 | ||
129 | for (int i = 0; i <= i_numofFiles; i++) { | 129 | for (int i = 0; i <= i_numofFiles; i++) { |
130 | // tempFileName.setNum(i); | 130 | // tempFileName.setNum(i); |
131 | config.setGroup( "Files" ); | 131 | config.setGroup( "Files" ); |
132 | QString ramble = config.readEntry( QString::number(i), "" ); | 132 | QString ramble = config.readEntry( QString::number(i), "" ); |
133 | 133 | ||
134 | config.setGroup( "Titles" ); | 134 | config.setGroup( "Titles" ); |
135 | QString tempTitle = config.readEntry( ramble, ""); | 135 | QString tempTitle = config.readEntry( ramble, ""); |
136 | config.setGroup( tempTitle); | 136 | config.setGroup( tempTitle); |
137 | int index = config.readNumEntry( "LineNumber", -1 ); | 137 | int index = config.readNumEntry( "LineNumber", -1 ); |
138 | if( index != -1) { | 138 | if( index != -1) { |
139 | odebug << tempTitle << oendl; | 139 | odebug << tempTitle << oendl; |
140 | if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); | 140 | if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; | 144 | // QString gutenIndex= local_library + "GUTINDEX.ALL"; |
145 | QString gutenIndex = QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; | 145 | QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL"; |
146 | qDebug("gutenindex "+gutenIndex ); | 146 | qDebug("gutenindex "+gutenIndex ); |
147 | if( QFile( gutenIndex).exists() ) { | 147 | if( QFile( gutenIndex).exists() ) { |
148 | indexLib.setName( gutenIndex); | 148 | indexLib.setName( gutenIndex); |
149 | } else { | 149 | } else { |
150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; | 150 | QString localLibIndexFile = QPEApplication::qpeDir()+ "etc/gutenbrowser/PGWHOLE.TXT"; |
151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; | 151 | // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; |
152 | newindexLib.setName( localLibIndexFile); | 152 | newindexLib.setName( localLibIndexFile); |
153 | } | 153 | } |
154 | qDebug("attempting new library"); | 154 | qDebug("attempting new library"); |
155 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); | 155 | LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); |
156 | loadCheck = false; | 156 | loadCheck = false; |
157 | chdir(local_library); | 157 | chdir(local_library); |
158 | if(!showMainList) { | 158 | if(!showMainList) { |
159 | Lview->setFocus(); | 159 | Lview->setFocus(); |
160 | // if(firstTime) | 160 | // if(firstTime) |
161 | // Bookmark(); | 161 | // Bookmark(); |
162 | for (int i=1;i< qApp->argc();i++) { | 162 | for (int i=1;i< qApp->argc();i++) { |
163 | qDebug("Suppose we open somethin"); | 163 | qDebug("Suppose we open somethin"); |
164 | if(!load(qApp->argv()[i])) return; | 164 | if(!load(qApp->argv()[i])) return; |
165 | } | 165 | } |
166 | } else { | 166 | } else { |
167 | fillWithTitles(); | 167 | fillWithTitles(); |
168 | mainList->setFocus(); | 168 | mainList->setFocus(); |
169 | // mainList->setCurrentItem(0); | 169 | // mainList->setCurrentItem(0); |
170 | 170 | ||
171 | } | 171 | } |
172 | writeConfig(); | 172 | writeConfig(); |
173 | QTimer::singleShot( 250, this, SLOT(hideView()) ); | 173 | QTimer::singleShot( 250, this, SLOT(hideView()) ); |
174 | } //end init | 174 | } //end init |
175 | 175 | ||
176 | Gutenbrowser::~Gutenbrowser() { | 176 | Gutenbrowser::~Gutenbrowser() { |
177 | // QPEApplication::grabKeyboard(); | 177 | // QPEApplication::grabKeyboard(); |
178 | // QPEApplication::ungrabKeyboard(); | 178 | // QPEApplication::ungrabKeyboard(); |
179 | odebug << "Exit" << oendl; | 179 | odebug << "Exit" << oendl; |
180 | } | 180 | } |
181 | 181 | ||
182 | /* | 182 | /* |
183 | Google.com search */ | 183 | Google.com search */ |
184 | void Gutenbrowser::InfoBarClick() { | 184 | void Gutenbrowser::InfoBarClick() { |
185 | QString text; | 185 | QString text; |
186 | if( Lview->hasSelectedText()) { | 186 | if( Lview->hasSelectedText()) { |
187 | Lview->copy(); | 187 | Lview->copy(); |
188 | QClipboard *cb = QApplication::clipboard(); | 188 | QClipboard *cb = QApplication::clipboard(); |
189 | text = cb->text(); | 189 | text = cb->text(); |
190 | } else { | 190 | } else { |
191 | // text=title; | 191 | // text=title; |
192 | text=this->caption(); | 192 | text=this->caption(); |
193 | } | 193 | } |
194 | searchGoogle(text); | 194 | searchGoogle(text); |
195 | } | 195 | } |
196 | 196 | ||
197 | /* | 197 | /* |
198 | download http with wget or preferred browser */ | 198 | download http with wget or preferred browser */ |
199 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { | 199 | void Gutenbrowser::goGetit( const QString &url, bool showMsg) { |
200 | // int eexit=0; | 200 | // int eexit=0; |
201 | QString cmd; | 201 | QString cmd; |
202 | // config.read(); | 202 | // config.read(); |
203 | qApp->processEvents(); | 203 | qApp->processEvents(); |
204 | QString filename = QPEApplication::qpeDir(); | 204 | QString filename = QPEApplication::qpeDir(); |
205 | if(filename.right(1)!="/") | 205 | if(filename.right(1)!="/") |
206 | filename+="/etc/gutenbrowser/"; | 206 | filename+="/etc/gutenbrowser/"; |
207 | else | 207 | else |
208 | filename+="etc/gutenbrowser/"; | 208 | filename+="etc/gutenbrowser/"; |
209 | odebug << "filename "+filename << oendl; | 209 | odebug << "filename "+filename << oendl; |
210 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; | 210 | // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; |
211 | 211 | ||
212 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); | 212 | filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); |
213 | 213 | ||
214 | Config config("Gutenbrowser"); | 214 | Config config("Gutenbrowser"); |
215 | config.setGroup( "Browser" ); | 215 | config.setGroup( "Browser" ); |
216 | QString brow = config.readEntry("Preferred", "Opera"); | 216 | QString brow = config.readEntry("Preferred", "Opera"); |
217 | odebug << "Preferred browser is "+brow << oendl; | 217 | odebug << "Preferred browser is "+brow << oendl; |
218 | if(!showMsg) { //if we just get the gutenindex.all | 218 | if(!showMsg) { //if we just get the gutenindex.all |
219 | cmd="wget -O " + filename +" " + url+" 2>&1" ; | 219 | cmd="wget -O " + filename +" " + url+" 2>&1" ; |
220 | chdir(local_library); | 220 | chdir(local_library); |
221 | odebug << "Issuing the system command: " << cmd << "" << oendl; | 221 | odebug << "Issuing the system command: " << cmd << "" << oendl; |
222 | 222 | ||
223 | Output *outDlg; | 223 | Output *outDlg; |
224 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); | 224 | outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); |
225 | outDlg->showMaximized(); | 225 | outDlg->showMaximized(); |
226 | outDlg->show(); | 226 | outDlg->show(); |
227 | qApp->processEvents(); | 227 | qApp->processEvents(); |
228 | FILE *fp; | 228 | FILE *fp; |
229 | char line[130]; | 229 | char line[130]; |
230 | outDlg->OutputEdit->append( tr("Running wget") ); | 230 | outDlg->OutputEdit->append( tr("Running wget") ); |
231 | sleep(1); | 231 | sleep(1); |
232 | fp = popen( (const char *) cmd, "r"); | 232 | fp = popen( (const char *) cmd, "r"); |
233 | odebug << "Issuing the command\n"+cmd << oendl; | 233 | odebug << "Issuing the command\n"+cmd << oendl; |
234 | // system(cmd); | 234 | // system(cmd); |
235 | while ( fgets( line, sizeof line, fp)) { | 235 | while ( fgets( line, sizeof line, fp)) { |
236 | outDlg->OutputEdit->append(line); | 236 | outDlg->OutputEdit->append(line); |
237 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 237 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
238 | } | 238 | } |
239 | pclose(fp); | 239 | pclose(fp); |
240 | outDlg->close(); | 240 | outDlg->close(); |
241 | if(outDlg) | 241 | if(outDlg) |
242 | delete outDlg; | 242 | delete outDlg; |
243 | } else { | 243 | } else { |
244 | if( brow == "Konq") { | 244 | if( brow == "Konq") { |
245 | cmd = "konqueror "+url+" &"; | 245 | cmd = "konqueror "+url+" &"; |
246 | } | 246 | } |
diff --git a/noncore/apps/opie-gutenbrowser/helpme.cpp b/noncore/apps/opie-gutenbrowser/helpme.cpp index 53e0236..0e23114 100644 --- a/noncore/apps/opie-gutenbrowser/helpme.cpp +++ b/noncore/apps/opie-gutenbrowser/helpme.cpp | |||
@@ -1,127 +1,127 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | helpme.cpp - description | 2 | helpme.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Tue Jul 25 2000 | 4 | begin : Tue Jul 25 2000 |
5 | begin : Sat Dec 4 1999 | 5 | begin : Sat Dec 4 1999 |
6 | copyright : (C) 2000 -2004 by llornkcor | 6 | copyright : (C) 2000 -2004 by llornkcor |
7 | email : ljp@llornkcor.com | 7 | email : ljp@llornkcor.com |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "helpme.h" | 18 | #include "helpme.h" |
19 | #include "helpwindow.h" | 19 | #include "helpwindow.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qprogressdialog.h> | 27 | #include <qprogressdialog.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | 33 | ||
34 | HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name) | 34 | HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name) |
35 | { | 35 | { |
36 | local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/"; | 36 | local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/"; |
37 | setCaption(tr("Gutenbrowser About " VERSION)); | 37 | setCaption(tr("Gutenbrowser About " VERSION)); |
38 | 38 | ||
39 | QGridLayout *layout = new QGridLayout( this ); | 39 | QGridLayout *layout = new QGridLayout( this ); |
40 | layout->setSpacing( 4 ); | 40 | layout->setSpacing( 4 ); |
41 | layout->setMargin( 4 ); | 41 | layout->setMargin( 4 ); |
42 | 42 | ||
43 | Edit = new QMultiLineEdit(this, ""); | 43 | Edit = new QMultiLineEdit(this, ""); |
44 | Edit->setReadOnly(true); | 44 | Edit->setReadOnly(true); |
45 | Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org")); | 45 | Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org")); |
46 | Edit->append(tr("Much appreciation to Lee Burgess,")); | 46 | Edit->append(tr("Much appreciation to Lee Burgess,")); |
47 | Edit->append(tr("for the original idea and concept of gutenbook.\n")); | 47 | Edit->append(tr("for the original idea and concept of gutenbook.\n")); |
48 | Edit->append(tr("A list of current Gutenberg ftp sites is at http://promo.net/pg/index.html\n")); | 48 | Edit->append(tr("A list of current Gutenberg ftp sites is at http://promo.net/pg/index.html\n")); |
49 | Edit->append(tr("For bug reports, comments or questions about Gutenbrowser, email")); | 49 | Edit->append(tr("For bug reports, comments or questions about Gutenbrowser, email")); |
50 | Edit->append(tr("ljp@llornkcor.com\n")); | 50 | Edit->append(tr("ljp@llornkcor.com\n")); |
51 | Edit->append(tr("\nMade using Qt, Qt Embedded, and Qtopia, a cross platform development API\nhttp://www.trolltech.com\n\n")); | 51 | Edit->append(tr("\nMade using Qt, Qt Embedded, and Qtopia, a cross platform development API\nhttp://www.trolltech.com\n\n")); |
52 | Edit->append(tr("Arnold's Laws of Documentation:")); | 52 | Edit->append(tr("Arnold's Laws of Documentation:")); |
53 | Edit->append(tr("(1) If it should exist, it doesn't.")); | 53 | Edit->append(tr("(1) If it should exist, it doesn't.")); |
54 | Edit->append(tr("(2) If it does exist, it's out of date.")); | 54 | Edit->append(tr("(2) If it does exist, it's out of date.")); |
55 | Edit->append(tr("(3) Only documentation for")); | 55 | Edit->append(tr("(3) Only documentation for")); |
56 | Edit->append(tr("useless programs transcends the")); | 56 | Edit->append(tr("useless programs transcends the")); |
57 | Edit->append(tr("first two laws.\n")); | 57 | Edit->append(tr("first two laws.\n")); |
58 | Edit->append(tr("Everything is temporary, anyway....\n :o)")); | 58 | Edit->append(tr("Everything is temporary, anyway....\n :o)")); |
59 | Edit->setWordWrap(QMultiLineEdit::WidgetWidth); | 59 | Edit->setWordWrap(QMultiLineEdit::WidgetWidth); |
60 | QString pixDir; | 60 | QString pixDir; |
61 | pixDir=QPEApplication::qpeDir()+"/pics/"; | 61 | pixDir=QPEApplication::qpeDir()+"pics/"; |
62 | QPushButton *help; | 62 | QPushButton *help; |
63 | help = new QPushButton(this); | 63 | help = new QPushButton(this); |
64 | help->setPixmap( QPixmap( pixDir+"gutenbrowser/help.png")); | 64 | help->setPixmap( QPixmap( pixDir+"gutenbrowser/help.png")); |
65 | help->setText("Help"); | 65 | help->setText("Help"); |
66 | connect( help,SIGNAL(clicked()),this,SLOT( help() )); | 66 | connect( help,SIGNAL(clicked()),this,SLOT( help() )); |
67 | 67 | ||
68 | /* QPushButton *ok; | 68 | /* QPushButton *ok; |
69 | ok = new QPushButton(this); | 69 | ok = new QPushButton(this); |
70 | ok->setPixmap( QPixmap( pixDir+"/gutenbrowser/exit.png")); | 70 | ok->setPixmap( QPixmap( pixDir+"/gutenbrowser/exit.png")); |
71 | ok->setText("ok"); | 71 | ok->setText("ok"); |
72 | connect(ok,SIGNAL(clicked()),this,SLOT(accept() )); | 72 | connect(ok,SIGNAL(clicked()),this,SLOT(accept() )); |
73 | */ | 73 | */ |
74 | help->setFixedHeight(25); | 74 | help->setFixedHeight(25); |
75 | // ok->setFixedHeight(25); | 75 | // ok->setFixedHeight(25); |
76 | 76 | ||
77 | // layout->addMultiCellWidget( ok, 0, 0, 4, 4 ); | 77 | // layout->addMultiCellWidget( ok, 0, 0, 4, 4 ); |
78 | layout->addMultiCellWidget( help, 0, 0, 4, 4 ); | 78 | layout->addMultiCellWidget( help, 0, 0, 4, 4 ); |
79 | layout->addMultiCellWidget( Edit, 1, 1, 0, 4 ); | 79 | layout->addMultiCellWidget( Edit, 1, 1, 0, 4 ); |
80 | } | 80 | } |
81 | 81 | ||
82 | HelpMe::~HelpMe() | 82 | HelpMe::~HelpMe() |
83 | { | 83 | { |
84 | //delete Edit; | 84 | //delete Edit; |
85 | 85 | ||
86 | } | 86 | } |
87 | 87 | ||
88 | void HelpMe::goToURL() | 88 | void HelpMe::goToURL() |
89 | { | 89 | { |
90 | 90 | ||
91 | url = "http://www.llornkcor.com/"; | 91 | url = "http://www.llornkcor.com/"; |
92 | goGetit( url); | 92 | goGetit( url); |
93 | } | 93 | } |
94 | 94 | ||
95 | void HelpMe::goToURL2() | 95 | void HelpMe::goToURL2() |
96 | { | 96 | { |
97 | url = "http://www.gutenberg.org"; | 97 | url = "http://www.gutenberg.org"; |
98 | goGetit( url); | 98 | goGetit( url); |
99 | } | 99 | } |
100 | 100 | ||
101 | void HelpMe::goToURL3() | 101 | void HelpMe::goToURL3() |
102 | { | 102 | { |
103 | url = "http://www.gutenbook.org"; | 103 | url = "http://www.gutenbook.org"; |
104 | goGetit( url); | 104 | goGetit( url); |
105 | } | 105 | } |
106 | 106 | ||
107 | void HelpMe::goGetit( QString url) | 107 | void HelpMe::goGetit( QString url) |
108 | { | 108 | { |
109 | HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser"); | 109 | HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser"); |
110 | help->setCaption("Qt Example - Helpviewer"); | 110 | help->setCaption("Qt Example - Helpviewer"); |
111 | help->showMaximized(); | 111 | help->showMaximized(); |
112 | help->show(); | 112 | help->show(); |
113 | } | 113 | } |
114 | 114 | ||
115 | void HelpMe::help() | 115 | void HelpMe::help() |
116 | { | 116 | { |
117 | QString msg ; | 117 | QString msg ; |
118 | msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be | 118 | msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be |
119 | odebug << msg << oendl; | 119 | odebug << msg << oendl; |
120 | QString url = "file://"+msg; | 120 | QString url = "file://"+msg; |
121 | goGetit( url); | 121 | goGetit( url); |
122 | 122 | ||
123 | // QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" ); | 123 | // QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" ); |
124 | // e << msg; | 124 | // e << msg; |
125 | 125 | ||
126 | // goGetit( msg); | 126 | // goGetit( msg); |
127 | } | 127 | } |
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 6aa6392..1ae3b15 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -2683,656 +2683,656 @@ void ZSafe::addCategory() | |||
2683 | else | 2683 | else |
2684 | { | 2684 | { |
2685 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2685 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2686 | #ifdef Q_WS_WIN | 2686 | #ifdef Q_WS_WIN |
2687 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2687 | categoryDialog->setCaption ("Qt " + tr("Category")); |
2688 | #endif | 2688 | #endif |
2689 | dialog = categoryDialog; | 2689 | dialog = categoryDialog; |
2690 | connect( dialog->CategoryField, | 2690 | connect( dialog->CategoryField, |
2691 | SIGNAL( activated(const QString&)), | 2691 | SIGNAL( activated(const QString&)), |
2692 | this, SLOT( categoryFieldActivated(const QString&) ) ); | 2692 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
2693 | initIcons = true; | 2693 | initIcons = true; |
2694 | } | 2694 | } |
2695 | 2695 | ||
2696 | #ifdef DESKTOP | 2696 | #ifdef DESKTOP |
2697 | #ifndef Q_WS_WIN | 2697 | #ifndef Q_WS_WIN |
2698 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2698 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
2699 | #else | 2699 | #else |
2700 | // read all categories from the config file and store | 2700 | // read all categories from the config file and store |
2701 | // into a list | 2701 | // into a list |
2702 | QFile f (cfgFile); | 2702 | QFile f (cfgFile); |
2703 | QStringList list; | 2703 | QStringList list; |
2704 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2704 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2705 | QTextStream t( &f ); // use a text stream | 2705 | QTextStream t( &f ); // use a text stream |
2706 | QString s; | 2706 | QString s; |
2707 | int n = 1; | 2707 | int n = 1; |
2708 | while ( !t.eof() ) { // until end of file... | 2708 | while ( !t.eof() ) { // until end of file... |
2709 | s = t.readLine(); // line of text excluding '\n' | 2709 | s = t.readLine(); // line of text excluding '\n' |
2710 | list.append(s); | 2710 | list.append(s); |
2711 | } | 2711 | } |
2712 | f.close(); | 2712 | f.close(); |
2713 | } | 2713 | } |
2714 | #endif | 2714 | #endif |
2715 | #else | 2715 | #else |
2716 | // read all categories from the config file and store | 2716 | // read all categories from the config file and store |
2717 | // into a list | 2717 | // into a list |
2718 | QFile f (cfgFile); | 2718 | QFile f (cfgFile); |
2719 | QStringList list; | 2719 | QStringList list; |
2720 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2720 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2721 | QTextStream t( &f ); // use a text stream | 2721 | QTextStream t( &f ); // use a text stream |
2722 | QString s; | 2722 | QString s; |
2723 | while ( !t.eof() ) { // until end of file... | 2723 | while ( !t.eof() ) { // until end of file... |
2724 | s = t.readLine(); // line of text excluding '\n' | 2724 | s = t.readLine(); // line of text excluding '\n' |
2725 | list.append(s); | 2725 | list.append(s); |
2726 | } | 2726 | } |
2727 | f.close(); | 2727 | f.close(); |
2728 | } | 2728 | } |
2729 | #endif | 2729 | #endif |
2730 | QStringList::Iterator it = list.begin(); | 2730 | QStringList::Iterator it = list.begin(); |
2731 | QString categ; | 2731 | QString categ; |
2732 | QString firstCategory; | 2732 | QString firstCategory; |
2733 | dialog->CategoryField->clear(); // remove all items | 2733 | dialog->CategoryField->clear(); // remove all items |
2734 | while( it != list.end() ) | 2734 | while( it != list.end() ) |
2735 | { | 2735 | { |
2736 | QString *cat = new QString (*it); | 2736 | QString *cat = new QString (*it); |
2737 | if (cat->contains("-field1", FALSE)) | 2737 | if (cat->contains("-field1", FALSE)) |
2738 | { | 2738 | { |
2739 | #ifdef DESKTOP | 2739 | #ifdef DESKTOP |
2740 | #ifndef Q_WS_WIN | 2740 | #ifndef Q_WS_WIN |
2741 | categ = cat->section ("-field1", 0, 0); | 2741 | categ = cat->section ("-field1", 0, 0); |
2742 | #else | 2742 | #else |
2743 | int pos = cat->find ("-field1"); | 2743 | int pos = cat->find ("-field1"); |
2744 | categ = cat->left (pos); | 2744 | categ = cat->left (pos); |
2745 | #endif | 2745 | #endif |
2746 | #else | 2746 | #else |
2747 | int pos = cat->find ("-field1"); | 2747 | int pos = cat->find ("-field1"); |
2748 | cat->truncate(pos); | 2748 | cat->truncate(pos); |
2749 | categ = *cat; | 2749 | categ = *cat; |
2750 | #endif | 2750 | #endif |
2751 | if (!categ.isEmpty()) | 2751 | if (!categ.isEmpty()) |
2752 | { | 2752 | { |
2753 | dialog->CategoryField->insertItem (categ, -1); | 2753 | dialog->CategoryField->insertItem (categ, -1); |
2754 | if (firstCategory.isEmpty()) | 2754 | if (firstCategory.isEmpty()) |
2755 | firstCategory = categ; | 2755 | firstCategory = categ; |
2756 | } | 2756 | } |
2757 | } | 2757 | } |
2758 | ++it; | 2758 | ++it; |
2759 | } | 2759 | } |
2760 | 2760 | ||
2761 | 2761 | ||
2762 | if (firstCategory.isEmpty()) | 2762 | if (firstCategory.isEmpty()) |
2763 | setCategoryDialogFields(dialog); | 2763 | setCategoryDialogFields(dialog); |
2764 | else | 2764 | else |
2765 | setCategoryDialogFields(dialog, firstCategory); | 2765 | setCategoryDialogFields(dialog, firstCategory); |
2766 | 2766 | ||
2767 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); | 2767 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); |
2768 | 2768 | ||
2769 | if (initIcons) | 2769 | if (initIcons) |
2770 | { | 2770 | { |
2771 | Wait waitDialog(this, tr("Wait dialog")); | 2771 | Wait waitDialog(this, tr("Wait dialog")); |
2772 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2772 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2773 | waitDialog.show(); | 2773 | waitDialog.show(); |
2774 | qApp->processEvents(); | 2774 | qApp->processEvents(); |
2775 | 2775 | ||
2776 | #ifdef DESKTOP | 2776 | #ifdef DESKTOP |
2777 | QDir d(iconPath); | 2777 | QDir d(iconPath); |
2778 | #else | 2778 | #else |
2779 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2779 | QDir d(QPEApplication::qpeDir() + "pics/"); |
2780 | #endif | 2780 | #endif |
2781 | d.setFilter( QDir::Files); | 2781 | d.setFilter( QDir::Files); |
2782 | 2782 | ||
2783 | const QFileInfoList *list = d.entryInfoList(); | 2783 | const QFileInfoList *list = d.entryInfoList(); |
2784 | QFileInfoListIterator it( *list ); // create list iterator | 2784 | QFileInfoListIterator it( *list ); // create list iterator |
2785 | QFileInfo *fi; // pointer for traversing | 2785 | QFileInfo *fi; // pointer for traversing |
2786 | 2786 | ||
2787 | dialog->IconField->insertItem("predefined"); | 2787 | dialog->IconField->insertItem("predefined"); |
2788 | while ( (fi=it.current()) ) { // for each file... | 2788 | while ( (fi=it.current()) ) { // for each file... |
2789 | QString fileName = fi->fileName(); | 2789 | QString fileName = fi->fileName(); |
2790 | if(fileName.right(4) == ".png"){ | 2790 | if(fileName.right(4) == ".png"){ |
2791 | fileName = fileName.mid(0,fileName.length()-4); | 2791 | fileName = fileName.mid(0,fileName.length()-4); |
2792 | #ifdef DESKTOP | 2792 | #ifdef DESKTOP |
2793 | QPixmap imageOfFile; | 2793 | QPixmap imageOfFile; |
2794 | imageOfFile.load(iconPath + fi->fileName()); | 2794 | imageOfFile.load(iconPath + fi->fileName()); |
2795 | #else | 2795 | #else |
2796 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2796 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
2797 | #endif | 2797 | #endif |
2798 | QImage foo = imageOfFile.convertToImage(); | 2798 | QImage foo = imageOfFile.convertToImage(); |
2799 | foo = foo.smoothScale(16,16); | 2799 | foo = foo.smoothScale(16,16); |
2800 | imageOfFile.convertFromImage(foo); | 2800 | imageOfFile.convertFromImage(foo); |
2801 | dialog->IconField->insertItem(imageOfFile,fileName); | 2801 | dialog->IconField->insertItem(imageOfFile,fileName); |
2802 | } | 2802 | } |
2803 | ++it; | 2803 | ++it; |
2804 | } | 2804 | } |
2805 | waitDialog.hide(); | 2805 | waitDialog.hide(); |
2806 | } | 2806 | } |
2807 | 2807 | ||
2808 | #ifndef Q_WS_WIN | 2808 | #ifndef Q_WS_WIN |
2809 | dialog->show(); | 2809 | dialog->show(); |
2810 | #endif | 2810 | #endif |
2811 | #ifndef DESKTOP | 2811 | #ifndef DESKTOP |
2812 | // dialog->move (20, 100); | 2812 | // dialog->move (20, 100); |
2813 | #endif | 2813 | #endif |
2814 | DialogCode result = (DialogCode) dialog->exec(); | 2814 | DialogCode result = (DialogCode) dialog->exec(); |
2815 | #ifdef DESKTOP | 2815 | #ifdef DESKTOP |
2816 | result = Accepted; | 2816 | result = Accepted; |
2817 | #endif | 2817 | #endif |
2818 | 2818 | ||
2819 | QString category; | 2819 | QString category; |
2820 | QString icon; | 2820 | QString icon; |
2821 | QString fullIconPath; | 2821 | QString fullIconPath; |
2822 | QPixmap *pix; | 2822 | QPixmap *pix; |
2823 | if (result == Accepted) | 2823 | if (result == Accepted) |
2824 | { | 2824 | { |
2825 | modified = true; | 2825 | modified = true; |
2826 | category = dialog->CategoryField->currentText(); | 2826 | category = dialog->CategoryField->currentText(); |
2827 | icon = dialog->IconField->currentText()+".png"; | 2827 | icon = dialog->IconField->currentText()+".png"; |
2828 | 2828 | ||
2829 | #ifndef NO_OPIE | 2829 | #ifndef NO_OPIE |
2830 | owarn << category << oendl; | 2830 | owarn << category << oendl; |
2831 | #endif | 2831 | #endif |
2832 | 2832 | ||
2833 | QListViewItem *li = new ShadedListItem( 1, ListView ); | 2833 | QListViewItem *li = new ShadedListItem( 1, ListView ); |
2834 | Category *c1 = new Category(); | 2834 | Category *c1 = new Category(); |
2835 | c1->setCategoryName(category); | 2835 | c1->setCategoryName(category); |
2836 | 2836 | ||
2837 | // if (!icon.isEmpty() && !icon.isNull()) | 2837 | // if (!icon.isEmpty() && !icon.isNull()) |
2838 | if (icon != "predefined.png") | 2838 | if (icon != "predefined.png") |
2839 | { | 2839 | { |
2840 | // build the full path | 2840 | // build the full path |
2841 | fullIconPath = iconPath + icon; | 2841 | fullIconPath = iconPath + icon; |
2842 | pix = new QPixmap (fullIconPath); | 2842 | pix = new QPixmap (fullIconPath); |
2843 | // pix->resize(14, 14); | 2843 | // pix->resize(14, 14); |
2844 | if (!pix->isNull()) | 2844 | if (!pix->isNull()) |
2845 | { | 2845 | { |
2846 | // save the full pixmap name into the config file | 2846 | // save the full pixmap name into the config file |
2847 | // #ifndef Q_WS_WIN | 2847 | // #ifndef Q_WS_WIN |
2848 | conf->writeEntry(APP_KEY+category, icon); | 2848 | conf->writeEntry(APP_KEY+category, icon); |
2849 | // #endif | 2849 | // #endif |
2850 | saveConf(); | 2850 | saveConf(); |
2851 | QImage img = pix->convertToImage(); | 2851 | QImage img = pix->convertToImage(); |
2852 | pix->convertFromImage(img.smoothScale(14,14)); | 2852 | pix->convertFromImage(img.smoothScale(14,14)); |
2853 | c1->setIcon (*pix); | 2853 | c1->setIcon (*pix); |
2854 | c1->setIconName(icon); | 2854 | c1->setIconName(icon); |
2855 | } | 2855 | } |
2856 | else | 2856 | else |
2857 | { | 2857 | { |
2858 | QPixmap folder( ( const char** ) general_data ); | 2858 | QPixmap folder( ( const char** ) general_data ); |
2859 | c1->setIcon (folder); | 2859 | c1->setIcon (folder); |
2860 | } | 2860 | } |
2861 | } | 2861 | } |
2862 | else | 2862 | else |
2863 | { | 2863 | { |
2864 | c1->setIcon (*getPredefinedIcon(category)); | 2864 | c1->setIcon (*getPredefinedIcon(category)); |
2865 | } | 2865 | } |
2866 | 2866 | ||
2867 | c1->setListItem (li); | 2867 | c1->setListItem (li); |
2868 | c1->initListItem(); | 2868 | c1->initListItem(); |
2869 | categories.insert (c1->getCategoryName(), c1); | 2869 | categories.insert (c1->getCategoryName(), c1); |
2870 | 2870 | ||
2871 | saveCategoryDialogFields(dialog); | 2871 | saveCategoryDialogFields(dialog); |
2872 | } | 2872 | } |
2873 | else | 2873 | else |
2874 | { | 2874 | { |
2875 | // delete dialog; | 2875 | // delete dialog; |
2876 | dialog->hide(); | 2876 | dialog->hide(); |
2877 | return; | 2877 | return; |
2878 | } | 2878 | } |
2879 | 2879 | ||
2880 | } | 2880 | } |
2881 | 2881 | ||
2882 | } | 2882 | } |
2883 | 2883 | ||
2884 | void ZSafe::delCategory() | 2884 | void ZSafe::delCategory() |
2885 | { | 2885 | { |
2886 | if (!selectedItem) | 2886 | if (!selectedItem) |
2887 | return; | 2887 | return; |
2888 | if (isCategory(selectedItem)) | 2888 | if (isCategory(selectedItem)) |
2889 | { | 2889 | { |
2890 | switch( QMessageBox::information( this, tr("ZSafe"), | 2890 | switch( QMessageBox::information( this, tr("ZSafe"), |
2891 | tr("Do you want to delete?"), | 2891 | tr("Do you want to delete?"), |
2892 | tr("&Delete"), tr("D&on't Delete"), | 2892 | tr("&Delete"), tr("D&on't Delete"), |
2893 | 0 // Enter == button 0 | 2893 | 0 // Enter == button 0 |
2894 | ) ) { // Escape == button 2 | 2894 | ) ) { // Escape == button 2 |
2895 | case 0: // Delete clicked, Alt-S or Enter pressed. | 2895 | case 0: // Delete clicked, Alt-S or Enter pressed. |
2896 | // Delete from the category list | 2896 | // Delete from the category list |
2897 | modified = true; | 2897 | modified = true; |
2898 | categories.remove (selectedItem->text(0)); | 2898 | categories.remove (selectedItem->text(0)); |
2899 | // #ifndef Q_WS_WIN | 2899 | // #ifndef Q_WS_WIN |
2900 | conf->removeEntry (selectedItem->text(0)); | 2900 | conf->removeEntry (selectedItem->text(0)); |
2901 | // #endif | 2901 | // #endif |
2902 | saveConf(); | 2902 | saveConf(); |
2903 | 2903 | ||
2904 | // Delete the selected item and all subitems | 2904 | // Delete the selected item and all subitems |
2905 | // step through all subitems | 2905 | // step through all subitems |
2906 | QListViewItem *si; | 2906 | QListViewItem *si; |
2907 | for (si = selectedItem->firstChild(); | 2907 | for (si = selectedItem->firstChild(); |
2908 | si != NULL; ) | 2908 | si != NULL; ) |
2909 | { | 2909 | { |
2910 | QListViewItem *_si = si; | 2910 | QListViewItem *_si = si; |
2911 | si = si->nextSibling(); | 2911 | si = si->nextSibling(); |
2912 | selectedItem->takeItem(_si); // remove from view list | 2912 | selectedItem->takeItem(_si); // remove from view list |
2913 | if (_si) delete _si; | 2913 | if (_si) delete _si; |
2914 | } | 2914 | } |
2915 | ListView->takeItem(selectedItem); | 2915 | ListView->takeItem(selectedItem); |
2916 | delete selectedItem; | 2916 | delete selectedItem; |
2917 | 2917 | ||
2918 | selectedItem = NULL; | 2918 | selectedItem = NULL; |
2919 | break; | 2919 | break; |
2920 | case 1: // Don't delete | 2920 | case 1: // Don't delete |
2921 | break; | 2921 | break; |
2922 | } | 2922 | } |
2923 | 2923 | ||
2924 | } | 2924 | } |
2925 | } | 2925 | } |
2926 | 2926 | ||
2927 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | 2927 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) |
2928 | { | 2928 | { |
2929 | if (!dialog) | 2929 | if (!dialog) |
2930 | return; | 2930 | return; |
2931 | 2931 | ||
2932 | QString icon; | 2932 | QString icon; |
2933 | if (selectedItem) | 2933 | if (selectedItem) |
2934 | { | 2934 | { |
2935 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 2935 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
2936 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 2936 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
2937 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 2937 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
2938 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 2938 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
2939 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); | 2939 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); |
2940 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); | 2940 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); |
2941 | 2941 | ||
2942 | Category *cat= categories.find (selectedItem->text(0)); | 2942 | Category *cat= categories.find (selectedItem->text(0)); |
2943 | if (cat) | 2943 | if (cat) |
2944 | { | 2944 | { |
2945 | icon = cat->getIconName(); | 2945 | icon = cat->getIconName(); |
2946 | } | 2946 | } |
2947 | else | 2947 | else |
2948 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); | 2948 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); |
2949 | } | 2949 | } |
2950 | else | 2950 | else |
2951 | { | 2951 | { |
2952 | dialog->Field1->setText(tr("Name")); | 2952 | dialog->Field1->setText(tr("Name")); |
2953 | dialog->Field2->setText(tr("Username")); | 2953 | dialog->Field2->setText(tr("Username")); |
2954 | dialog->Field3->setText(tr("Password")); | 2954 | dialog->Field3->setText(tr("Password")); |
2955 | dialog->Field4->setText(tr("Comment")); | 2955 | dialog->Field4->setText(tr("Comment")); |
2956 | dialog->Field5->setText(tr("Field 4")); | 2956 | dialog->Field5->setText(tr("Field 4")); |
2957 | dialog->Field6->setText(tr("Field 5")); | 2957 | dialog->Field6->setText(tr("Field 5")); |
2958 | } | 2958 | } |
2959 | 2959 | ||
2960 | #ifdef DESKTOP | 2960 | #ifdef DESKTOP |
2961 | QDir d(iconPath); | 2961 | QDir d(iconPath); |
2962 | #else | 2962 | #else |
2963 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2963 | QDir d(QPEApplication::qpeDir() + "pics/"); |
2964 | #endif | 2964 | #endif |
2965 | d.setFilter( QDir::Files); | 2965 | d.setFilter( QDir::Files); |
2966 | 2966 | ||
2967 | const QFileInfoList *list = d.entryInfoList(); | 2967 | const QFileInfoList *list = d.entryInfoList(); |
2968 | int i=0; | 2968 | int i=0; |
2969 | QFileInfoListIterator it( *list ); // create list iterator | 2969 | QFileInfoListIterator it( *list ); // create list iterator |
2970 | QFileInfo *fi; // pointer for traversing | 2970 | QFileInfo *fi; // pointer for traversing |
2971 | if (icon.isEmpty() || icon.isNull()) | 2971 | if (icon.isEmpty() || icon.isNull()) |
2972 | { | 2972 | { |
2973 | dialog->IconField->setCurrentItem(0); | 2973 | dialog->IconField->setCurrentItem(0); |
2974 | } | 2974 | } |
2975 | else | 2975 | else |
2976 | { | 2976 | { |
2977 | while ( (fi=it.current()) ) | 2977 | while ( (fi=it.current()) ) |
2978 | { // for each file... | 2978 | { // for each file... |
2979 | QString fileName = fi->fileName(); | 2979 | QString fileName = fi->fileName(); |
2980 | if(fileName.right(4) == ".png") | 2980 | if(fileName.right(4) == ".png") |
2981 | { | 2981 | { |
2982 | fileName = fileName.mid(0,fileName.length()-4); | 2982 | fileName = fileName.mid(0,fileName.length()-4); |
2983 | 2983 | ||
2984 | if(fileName+".png"==icon) | 2984 | if(fileName+".png"==icon) |
2985 | { | 2985 | { |
2986 | dialog->IconField->setCurrentItem(i+1); | 2986 | dialog->IconField->setCurrentItem(i+1); |
2987 | break; | 2987 | break; |
2988 | } | 2988 | } |
2989 | ++i; | 2989 | ++i; |
2990 | } | 2990 | } |
2991 | ++it; | 2991 | ++it; |
2992 | } | 2992 | } |
2993 | } | 2993 | } |
2994 | } | 2994 | } |
2995 | 2995 | ||
2996 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | 2996 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) |
2997 | { | 2997 | { |
2998 | if (!dialog) | 2998 | if (!dialog) |
2999 | return; | 2999 | return; |
3000 | 3000 | ||
3001 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); | 3001 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); |
3002 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); | 3002 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); |
3003 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); | 3003 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); |
3004 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); | 3004 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); |
3005 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); | 3005 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); |
3006 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); | 3006 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); |
3007 | 3007 | ||
3008 | QString icon; | 3008 | QString icon; |
3009 | Category *cat= categories.find (category); | 3009 | Category *cat= categories.find (category); |
3010 | if (cat) | 3010 | if (cat) |
3011 | { | 3011 | { |
3012 | icon = cat->getIconName(); | 3012 | icon = cat->getIconName(); |
3013 | } | 3013 | } |
3014 | else | 3014 | else |
3015 | icon = conf->readEntry(APP_KEY+category); | 3015 | icon = conf->readEntry(APP_KEY+category); |
3016 | 3016 | ||
3017 | #ifdef DESKTOP | 3017 | #ifdef DESKTOP |
3018 | QDir d(iconPath); | 3018 | QDir d(iconPath); |
3019 | #else | 3019 | #else |
3020 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3020 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3021 | #endif | 3021 | #endif |
3022 | d.setFilter( QDir::Files); | 3022 | d.setFilter( QDir::Files); |
3023 | 3023 | ||
3024 | const QFileInfoList *list = d.entryInfoList(); | 3024 | const QFileInfoList *list = d.entryInfoList(); |
3025 | int i=0; | 3025 | int i=0; |
3026 | QFileInfoListIterator it( *list ); // create list iterator | 3026 | QFileInfoListIterator it( *list ); // create list iterator |
3027 | QFileInfo *fi; // pointer for traversing | 3027 | QFileInfo *fi; // pointer for traversing |
3028 | if (icon.isEmpty() || icon.isNull()) | 3028 | if (icon.isEmpty() || icon.isNull()) |
3029 | { | 3029 | { |
3030 | dialog->IconField->setCurrentItem(0); | 3030 | dialog->IconField->setCurrentItem(0); |
3031 | } | 3031 | } |
3032 | else | 3032 | else |
3033 | { | 3033 | { |
3034 | while ( (fi=it.current()) ) | 3034 | while ( (fi=it.current()) ) |
3035 | { // for each file... | 3035 | { // for each file... |
3036 | QString fileName = fi->fileName(); | 3036 | QString fileName = fi->fileName(); |
3037 | if(fileName.right(4) == ".png") | 3037 | if(fileName.right(4) == ".png") |
3038 | { | 3038 | { |
3039 | fileName = fileName.mid(0,fileName.length()-4); | 3039 | fileName = fileName.mid(0,fileName.length()-4); |
3040 | 3040 | ||
3041 | if(fileName+".png"==icon) | 3041 | if(fileName+".png"==icon) |
3042 | { | 3042 | { |
3043 | dialog->IconField->setCurrentItem(i+1); | 3043 | dialog->IconField->setCurrentItem(i+1); |
3044 | break; | 3044 | break; |
3045 | } | 3045 | } |
3046 | ++i; | 3046 | ++i; |
3047 | } | 3047 | } |
3048 | ++it; | 3048 | ++it; |
3049 | } | 3049 | } |
3050 | } | 3050 | } |
3051 | } | 3051 | } |
3052 | 3052 | ||
3053 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) | 3053 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) |
3054 | { | 3054 | { |
3055 | QString app_key = APP_KEY; | 3055 | QString app_key = APP_KEY; |
3056 | #ifndef DESKTOP | 3056 | #ifndef DESKTOP |
3057 | conf->setGroup ("fieldDefs"); | 3057 | conf->setGroup ("fieldDefs"); |
3058 | #else | 3058 | #else |
3059 | #ifndef Q_WS_WIN | 3059 | #ifndef Q_WS_WIN |
3060 | app_key += "/fieldDefs/"; | 3060 | app_key += "/fieldDefs/"; |
3061 | #endif | 3061 | #endif |
3062 | #endif | 3062 | #endif |
3063 | QString category = dialog->CategoryField->currentText(); | 3063 | QString category = dialog->CategoryField->currentText(); |
3064 | // #ifndef Q_WS_WIN | 3064 | // #ifndef Q_WS_WIN |
3065 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); | 3065 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); |
3066 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); | 3066 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); |
3067 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); | 3067 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); |
3068 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); | 3068 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); |
3069 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); | 3069 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); |
3070 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); | 3070 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); |
3071 | // #endif | 3071 | // #endif |
3072 | saveConf(); | 3072 | saveConf(); |
3073 | #ifndef DESKTOP | 3073 | #ifndef DESKTOP |
3074 | conf->setGroup ("zsafe"); | 3074 | conf->setGroup ("zsafe"); |
3075 | #endif | 3075 | #endif |
3076 | } | 3076 | } |
3077 | 3077 | ||
3078 | void ZSafe::editCategory() | 3078 | void ZSafe::editCategory() |
3079 | { | 3079 | { |
3080 | if (!selectedItem) | 3080 | if (!selectedItem) |
3081 | return; | 3081 | return; |
3082 | if (isCategory(selectedItem)) | 3082 | if (isCategory(selectedItem)) |
3083 | { | 3083 | { |
3084 | QString category = selectedItem->text(0); | 3084 | QString category = selectedItem->text(0); |
3085 | bool initIcons = false; | 3085 | bool initIcons = false; |
3086 | // open the 'Category' dialog | 3086 | // open the 'Category' dialog |
3087 | CategoryDialog *dialog; | 3087 | CategoryDialog *dialog; |
3088 | if (categoryDialog) | 3088 | if (categoryDialog) |
3089 | { | 3089 | { |
3090 | dialog = categoryDialog; | 3090 | dialog = categoryDialog; |
3091 | } | 3091 | } |
3092 | else | 3092 | else |
3093 | { | 3093 | { |
3094 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 3094 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
3095 | #ifdef Q_WS_WIN | 3095 | #ifdef Q_WS_WIN |
3096 | categoryDialog->setCaption ("Qt " + tr("Category")); | 3096 | categoryDialog->setCaption ("Qt " + tr("Category")); |
3097 | #endif | 3097 | #endif |
3098 | dialog = categoryDialog; | 3098 | dialog = categoryDialog; |
3099 | connect( dialog->CategoryField, | 3099 | connect( dialog->CategoryField, |
3100 | SIGNAL( activated(const QString&)), | 3100 | SIGNAL( activated(const QString&)), |
3101 | this, SLOT( categoryFieldActivated(const QString&) ) ); | 3101 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
3102 | initIcons = true; | 3102 | initIcons = true; |
3103 | } | 3103 | } |
3104 | setCategoryDialogFields(dialog); | 3104 | setCategoryDialogFields(dialog); |
3105 | 3105 | ||
3106 | #ifdef DESKTOP | 3106 | #ifdef DESKTOP |
3107 | #ifndef Q_WS_WIN | 3107 | #ifndef Q_WS_WIN |
3108 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 3108 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
3109 | #else | 3109 | #else |
3110 | // read all categories from the config file and store | 3110 | // read all categories from the config file and store |
3111 | // into a list | 3111 | // into a list |
3112 | QFile f (cfgFile); | 3112 | QFile f (cfgFile); |
3113 | QStringList list; | 3113 | QStringList list; |
3114 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 3114 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3115 | QTextStream t( &f ); // use a text stream | 3115 | QTextStream t( &f ); // use a text stream |
3116 | QString s; | 3116 | QString s; |
3117 | int n = 1; | 3117 | int n = 1; |
3118 | while ( !t.eof() ) { // until end of file... | 3118 | while ( !t.eof() ) { // until end of file... |
3119 | s = t.readLine(); // line of text excluding '\n' | 3119 | s = t.readLine(); // line of text excluding '\n' |
3120 | list.append(s); | 3120 | list.append(s); |
3121 | } | 3121 | } |
3122 | f.close(); | 3122 | f.close(); |
3123 | } | 3123 | } |
3124 | #endif | 3124 | #endif |
3125 | #else | 3125 | #else |
3126 | // read all categories from the config file and store | 3126 | // read all categories from the config file and store |
3127 | // into a list | 3127 | // into a list |
3128 | QFile f (cfgFile); | 3128 | QFile f (cfgFile); |
3129 | QStringList list; | 3129 | QStringList list; |
3130 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 3130 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3131 | QTextStream t( &f ); // use a text stream | 3131 | QTextStream t( &f ); // use a text stream |
3132 | QString s; | 3132 | QString s; |
3133 | while ( !t.eof() ) { // until end of file... | 3133 | while ( !t.eof() ) { // until end of file... |
3134 | s = t.readLine(); // line of text excluding '\n' | 3134 | s = t.readLine(); // line of text excluding '\n' |
3135 | list.append(s); | 3135 | list.append(s); |
3136 | } | 3136 | } |
3137 | f.close(); | 3137 | f.close(); |
3138 | } | 3138 | } |
3139 | #endif | 3139 | #endif |
3140 | QStringList::Iterator it = list.begin(); | 3140 | QStringList::Iterator it = list.begin(); |
3141 | QString categ; | 3141 | QString categ; |
3142 | dialog->CategoryField->clear(); // remove all items | 3142 | dialog->CategoryField->clear(); // remove all items |
3143 | int i=0; | 3143 | int i=0; |
3144 | bool foundCategory = false; | 3144 | bool foundCategory = false; |
3145 | while( it != list.end() ) | 3145 | while( it != list.end() ) |
3146 | { | 3146 | { |
3147 | QString *cat = new QString (*it); | 3147 | QString *cat = new QString (*it); |
3148 | if (cat->contains("-field1", FALSE)) | 3148 | if (cat->contains("-field1", FALSE)) |
3149 | { | 3149 | { |
3150 | #ifdef DESKTOP | 3150 | #ifdef DESKTOP |
3151 | #ifndef Q_WS_WIN | 3151 | #ifndef Q_WS_WIN |
3152 | categ = cat->section ("-field1", 0, 0); | 3152 | categ = cat->section ("-field1", 0, 0); |
3153 | #else | 3153 | #else |
3154 | int pos = cat->find ("-field1"); | 3154 | int pos = cat->find ("-field1"); |
3155 | categ = cat->left (pos); | 3155 | categ = cat->left (pos); |
3156 | #endif | 3156 | #endif |
3157 | #else | 3157 | #else |
3158 | int pos = cat->find ("-field1"); | 3158 | int pos = cat->find ("-field1"); |
3159 | cat->truncate(pos); | 3159 | cat->truncate(pos); |
3160 | categ = *cat; | 3160 | categ = *cat; |
3161 | #endif | 3161 | #endif |
3162 | if (!categ.isEmpty()) | 3162 | if (!categ.isEmpty()) |
3163 | { | 3163 | { |
3164 | dialog->CategoryField->insertItem (categ, i); | 3164 | dialog->CategoryField->insertItem (categ, i); |
3165 | if (category.compare(categ) == 0) | 3165 | if (category.compare(categ) == 0) |
3166 | { | 3166 | { |
3167 | dialog->CategoryField->setCurrentItem(i); | 3167 | dialog->CategoryField->setCurrentItem(i); |
3168 | foundCategory = true; | 3168 | foundCategory = true; |
3169 | } | 3169 | } |
3170 | i++; | 3170 | i++; |
3171 | } | 3171 | } |
3172 | } | 3172 | } |
3173 | ++it; | 3173 | ++it; |
3174 | } | 3174 | } |
3175 | if (!foundCategory) | 3175 | if (!foundCategory) |
3176 | { | 3176 | { |
3177 | dialog->CategoryField->insertItem (category, i); | 3177 | dialog->CategoryField->insertItem (category, i); |
3178 | dialog->CategoryField->setCurrentItem(i); | 3178 | dialog->CategoryField->setCurrentItem(i); |
3179 | } | 3179 | } |
3180 | 3180 | ||
3181 | QString icon; | 3181 | QString icon; |
3182 | Category *cat= categories.find (selectedItem->text(0)); | 3182 | Category *cat= categories.find (selectedItem->text(0)); |
3183 | if (cat) | 3183 | if (cat) |
3184 | { | 3184 | { |
3185 | icon = cat->getIconName(); | 3185 | icon = cat->getIconName(); |
3186 | } | 3186 | } |
3187 | 3187 | ||
3188 | if (initIcons) | 3188 | if (initIcons) |
3189 | { | 3189 | { |
3190 | 3190 | ||
3191 | Wait waitDialog(this, tr("Wait dialog")); | 3191 | Wait waitDialog(this, tr("Wait dialog")); |
3192 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 3192 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3193 | waitDialog.show(); | 3193 | waitDialog.show(); |
3194 | qApp->processEvents(); | 3194 | qApp->processEvents(); |
3195 | 3195 | ||
3196 | #ifdef DESKTOP | 3196 | #ifdef DESKTOP |
3197 | QDir d(iconPath); | 3197 | QDir d(iconPath); |
3198 | #else | 3198 | #else |
3199 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3199 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3200 | #endif | 3200 | #endif |
3201 | d.setFilter( QDir::Files); | 3201 | d.setFilter( QDir::Files); |
3202 | 3202 | ||
3203 | const QFileInfoList *list = d.entryInfoList(); | 3203 | const QFileInfoList *list = d.entryInfoList(); |
3204 | int i=0; | 3204 | int i=0; |
3205 | QFileInfoListIterator it( *list ); // create list iterator | 3205 | QFileInfoListIterator it( *list ); // create list iterator |
3206 | QFileInfo *fi; // pointer for traversing | 3206 | QFileInfo *fi; // pointer for traversing |
3207 | if (icon.isEmpty() || icon.isNull()) | 3207 | if (icon.isEmpty() || icon.isNull()) |
3208 | { | 3208 | { |
3209 | dialog->IconField->setCurrentItem(0); | 3209 | dialog->IconField->setCurrentItem(0); |
3210 | } | 3210 | } |
3211 | 3211 | ||
3212 | dialog->IconField->insertItem("predefined"); | 3212 | dialog->IconField->insertItem("predefined"); |
3213 | while ( (fi=it.current()) ) { // for each file... | 3213 | while ( (fi=it.current()) ) { // for each file... |
3214 | QString fileName = fi->fileName(); | 3214 | QString fileName = fi->fileName(); |
3215 | if(fileName.right(4) == ".png") | 3215 | if(fileName.right(4) == ".png") |
3216 | { | 3216 | { |
3217 | fileName = fileName.mid(0,fileName.length()-4); | 3217 | fileName = fileName.mid(0,fileName.length()-4); |
3218 | #ifdef DESKTOP | 3218 | #ifdef DESKTOP |
3219 | QPixmap imageOfFile; | 3219 | QPixmap imageOfFile; |
3220 | imageOfFile.load(iconPath + fi->fileName()); | 3220 | imageOfFile.load(iconPath + fi->fileName()); |
3221 | #else | 3221 | #else |
3222 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 3222 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
3223 | #endif | 3223 | #endif |
3224 | QImage foo = imageOfFile.convertToImage(); | 3224 | QImage foo = imageOfFile.convertToImage(); |
3225 | foo = foo.smoothScale(16,16); | 3225 | foo = foo.smoothScale(16,16); |
3226 | imageOfFile.convertFromImage(foo); | 3226 | imageOfFile.convertFromImage(foo); |
3227 | dialog->IconField->insertItem(imageOfFile,fileName); | 3227 | dialog->IconField->insertItem(imageOfFile,fileName); |
3228 | if(fileName+".png"==icon) | 3228 | if(fileName+".png"==icon) |
3229 | dialog->IconField->setCurrentItem(i+1); | 3229 | dialog->IconField->setCurrentItem(i+1); |
3230 | ++i; | 3230 | ++i; |
3231 | } | 3231 | } |
3232 | ++it; | 3232 | ++it; |
3233 | } | 3233 | } |
3234 | waitDialog.hide(); | 3234 | waitDialog.hide(); |
3235 | } | 3235 | } |
3236 | else | 3236 | else |
3237 | { | 3237 | { |
3238 | #ifdef DESKTOP | 3238 | #ifdef DESKTOP |
3239 | // QDir d(QDir::homeDirPath() + "/pics/"); | 3239 | // QDir d(QDir::homeDirPath() + "/pics/"); |
3240 | QDir d(iconPath); | 3240 | QDir d(iconPath); |
3241 | #else | 3241 | #else |
3242 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3242 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3243 | #endif | 3243 | #endif |
3244 | d.setFilter( QDir::Files); | 3244 | d.setFilter( QDir::Files); |
3245 | 3245 | ||
3246 | const QFileInfoList *list = d.entryInfoList(); | 3246 | const QFileInfoList *list = d.entryInfoList(); |
3247 | int i=0; | 3247 | int i=0; |
3248 | QFileInfoListIterator it( *list ); // create list iterator | 3248 | QFileInfoListIterator it( *list ); // create list iterator |
3249 | QFileInfo *fi; // pointer for traversing | 3249 | QFileInfo *fi; // pointer for traversing |
3250 | if (icon.isEmpty() || icon.isNull()) | 3250 | if (icon.isEmpty() || icon.isNull()) |
3251 | { | 3251 | { |
3252 | dialog->IconField->setCurrentItem(0); | 3252 | dialog->IconField->setCurrentItem(0); |
3253 | } | 3253 | } |
3254 | else | 3254 | else |
3255 | { | 3255 | { |
3256 | 3256 | ||
3257 | while ( (fi=it.current()) ) | 3257 | while ( (fi=it.current()) ) |
3258 | { // for each file... | 3258 | { // for each file... |
3259 | QString fileName = fi->fileName(); | 3259 | QString fileName = fi->fileName(); |
3260 | if(fileName.right(4) == ".png") | 3260 | if(fileName.right(4) == ".png") |
3261 | { | 3261 | { |
3262 | fileName = fileName.mid(0,fileName.length()-4); | 3262 | fileName = fileName.mid(0,fileName.length()-4); |
3263 | 3263 | ||
3264 | 3264 | ||
3265 | if(fileName+".png"==icon) | 3265 | if(fileName+".png"==icon) |
3266 | { | 3266 | { |
3267 | dialog->IconField->setCurrentItem(i+1); | 3267 | dialog->IconField->setCurrentItem(i+1); |
3268 | break; | 3268 | break; |
3269 | } | 3269 | } |
3270 | ++i; | 3270 | ++i; |
3271 | } | 3271 | } |
3272 | ++it; | 3272 | ++it; |
3273 | } | 3273 | } |
3274 | } | 3274 | } |
3275 | } | 3275 | } |
3276 | 3276 | ||
3277 | // dialog->show(); | 3277 | // dialog->show(); |
3278 | #ifndef DESKTOP | 3278 | #ifndef DESKTOP |
3279 | // dialog->move (20, 100); | 3279 | // dialog->move (20, 100); |
3280 | #endif | 3280 | #endif |
3281 | DialogCode result = (DialogCode) dialog->exec(); | 3281 | DialogCode result = (DialogCode) dialog->exec(); |
3282 | #ifdef DESKTOP | 3282 | #ifdef DESKTOP |
3283 | result = Accepted; | 3283 | result = Accepted; |
3284 | #endif | 3284 | #endif |
3285 | 3285 | ||
3286 | QString fullIconPath; | 3286 | QString fullIconPath; |
3287 | QPixmap *pix; | 3287 | QPixmap *pix; |
3288 | if (result == Accepted) | 3288 | if (result == Accepted) |
3289 | { | 3289 | { |
3290 | modified = true; | 3290 | modified = true; |
3291 | if (category != dialog->CategoryField->currentText()) | 3291 | if (category != dialog->CategoryField->currentText()) |
3292 | { | 3292 | { |
3293 | categories.remove (category); | 3293 | categories.remove (category); |
3294 | // #ifndef Q_WS_WIN | 3294 | // #ifndef Q_WS_WIN |
3295 | conf->removeEntry(category); | 3295 | conf->removeEntry(category); |
3296 | // #endif | 3296 | // #endif |
3297 | saveConf(); | 3297 | saveConf(); |
3298 | } | 3298 | } |
3299 | 3299 | ||
3300 | category = dialog->CategoryField->currentText(); | 3300 | category = dialog->CategoryField->currentText(); |
3301 | icon = dialog->IconField->currentText()+".png"; | 3301 | icon = dialog->IconField->currentText()+".png"; |
3302 | 3302 | ||
3303 | if (cat) | 3303 | if (cat) |
3304 | { | 3304 | { |
3305 | #ifndef NO_OPIE | 3305 | #ifndef NO_OPIE |
3306 | owarn << "Category found" << oendl; | 3306 | owarn << "Category found" << oendl; |
3307 | #else | 3307 | #else |
3308 | qWarning("Category found"); | 3308 | qWarning("Category found"); |
3309 | #endif | 3309 | #endif |
3310 | 3310 | ||
3311 | // if (!icon.isEmpty() && !icon.isNull()) | 3311 | // if (!icon.isEmpty() && !icon.isNull()) |
3312 | if (icon != "predefined.png") | 3312 | if (icon != "predefined.png") |
3313 | { | 3313 | { |
3314 | // build the full path | 3314 | // build the full path |
3315 | fullIconPath = iconPath + icon; | 3315 | fullIconPath = iconPath + icon; |
3316 | pix = new QPixmap (fullIconPath); | 3316 | pix = new QPixmap (fullIconPath); |
3317 | if (!pix->isNull()) | 3317 | if (!pix->isNull()) |
3318 | { | 3318 | { |
3319 | // save the full pixmap name into the config file | 3319 | // save the full pixmap name into the config file |
3320 | // #ifndef Q_WS_WIN | 3320 | // #ifndef Q_WS_WIN |
3321 | conf->writeEntry(APP_KEY+category, icon); | 3321 | conf->writeEntry(APP_KEY+category, icon); |
3322 | // #endif | 3322 | // #endif |
3323 | saveConf(); | 3323 | saveConf(); |
3324 | QImage img = pix->convertToImage(); | 3324 | QImage img = pix->convertToImage(); |
3325 | pix->convertFromImage(img.smoothScale(14,14)); | 3325 | pix->convertFromImage(img.smoothScale(14,14)); |
3326 | cat->setIconName (icon); | 3326 | cat->setIconName (icon); |
3327 | cat->setIcon (*pix); | 3327 | cat->setIcon (*pix); |
3328 | } | 3328 | } |
3329 | } | 3329 | } |
3330 | else | 3330 | else |
3331 | { | 3331 | { |
3332 | // #ifndef Q_WS_WIN | 3332 | // #ifndef Q_WS_WIN |
3333 | conf->removeEntry (category); | 3333 | conf->removeEntry (category); |
3334 | // #endif | 3334 | // #endif |
3335 | saveConf(); | 3335 | saveConf(); |
3336 | cat->setIcon (*getPredefinedIcon(category)); | 3336 | cat->setIcon (*getPredefinedIcon(category)); |
3337 | } | 3337 | } |
3338 | 3338 | ||
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp index bdb1c78..c286a36 100644 --- a/noncore/games/backgammon/backgammon.cpp +++ b/noncore/games/backgammon/backgammon.cpp | |||
@@ -1,156 +1,156 @@ | |||
1 | #include "backgammon.h" | 1 | #include "backgammon.h" |
2 | #include "aidialog.h" | 2 | #include "aidialog.h" |
3 | #include "filedialog.h" | 3 | #include "filedialog.h" |
4 | #include "playerdialog.h" | 4 | #include "playerdialog.h" |
5 | #include "rulesdialog.h" | 5 | #include "rulesdialog.h" |
6 | #include "themedialog.h" | 6 | #include "themedialog.h" |
7 | 7 | ||
8 | /* OPIE */ | 8 | /* OPIE */ |
9 | #include <opie2/odebug.h> | 9 | #include <opie2/odebug.h> |
10 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
11 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
12 | #include <qpe/resource.h> | 12 | #include <qpe/resource.h> |
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | 14 | ||
15 | /* QT */ | 15 | /* QT */ |
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qlayout.h> | 17 | #include <qlayout.h> |
18 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
19 | #include <qtimer.h> | 19 | #include <qtimer.h> |
20 | #include <qmenubar.h> | 20 | #include <qmenubar.h> |
21 | 21 | ||
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | 23 | ||
24 | 24 | ||
25 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | 25 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) |
26 | : QMainWindow(parent, name, fl) | 26 | : QMainWindow(parent, name, fl) |
27 | { | 27 | { |
28 | if (!name) setName("BackGammon"); | 28 | if (!name) setName("BackGammon"); |
29 | setCaption(tr( "Backgammon") ); | 29 | setCaption(tr( "Backgammon") ); |
30 | setIcon( Resource::loadPixmap( "backgammon" ) ); | 30 | setIcon( Resource::loadPixmap( "backgammon" ) ); |
31 | //general counter varaible | 31 | //general counter varaible |
32 | int a=0; | 32 | int a=0; |
33 | //the game engine | 33 | //the game engine |
34 | move=new MoveEngine(); | 34 | move=new MoveEngine(); |
35 | 35 | ||
36 | //load the default theme | 36 | //load the default theme |
37 | Config conf("backgammon"); | 37 | Config conf("backgammon"); |
38 | if(!conf.isValid()) | 38 | if(!conf.isValid()) |
39 | { | 39 | { |
40 | odebug << "config file does not exist" << oendl; | 40 | odebug << "config file does not exist" << oendl; |
41 | conf.setGroup("general"); | 41 | conf.setGroup("general"); |
42 | conf.writeEntry("theme","default"); | 42 | conf.writeEntry("theme","default"); |
43 | conf.setGroup("rules"); | 43 | conf.setGroup("rules"); |
44 | conf.writeEntry("move_with_pieces_out",false); | 44 | conf.writeEntry("move_with_pieces_out",false); |
45 | conf.writeEntry("nice_dice",false); | 45 | conf.writeEntry("nice_dice",false); |
46 | conf.setGroup("display"); | 46 | conf.setGroup("display"); |
47 | conf.writeEntry("small",false); | 47 | conf.writeEntry("small",false); |
48 | conf.writeEntry("warning",true); | 48 | conf.writeEntry("warning",true); |
49 | conf.setGroup("ai"); | 49 | conf.setGroup("ai"); |
50 | conf.writeEntry("rescue",6); | 50 | conf.writeEntry("rescue",6); |
51 | conf.writeEntry("eliminate",4); | 51 | conf.writeEntry("eliminate",4); |
52 | conf.writeEntry("expose",1); | 52 | conf.writeEntry("expose",1); |
53 | conf.writeEntry("protect",5); | 53 | conf.writeEntry("protect",5); |
54 | conf.writeEntry("safe",3); | 54 | conf.writeEntry("safe",3); |
55 | conf.writeEntry("empty",2); | 55 | conf.writeEntry("empty",2); |
56 | 56 | ||
57 | } | 57 | } |
58 | conf.setGroup("general"); | 58 | conf.setGroup("general"); |
59 | theme_name=conf.readEntry("theme","default"); | 59 | theme_name=conf.readEntry("theme","default"); |
60 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; | 60 | QString theme_file=QPEApplication::qpeDir()+"backgammon/"+theme_name+".theme"; |
61 | 61 | ||
62 | //the rules | 62 | //the rules |
63 | conf.setGroup("rules"); | 63 | conf.setGroup("rules"); |
64 | rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); | 64 | rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); |
65 | rules.generous_dice=conf.readBoolEntry("nice_dice",false); | 65 | rules.generous_dice=conf.readBoolEntry("nice_dice",false); |
66 | 66 | ||
67 | move->setRules(rules); | 67 | move->setRules(rules); |
68 | 68 | ||
69 | //get the AI settings | 69 | //get the AI settings |
70 | AISettings ai; | 70 | AISettings ai; |
71 | conf.setGroup("ai"); | 71 | conf.setGroup("ai"); |
72 | ai.rescue=conf.readNumEntry("rescue",6); | 72 | ai.rescue=conf.readNumEntry("rescue",6); |
73 | ai.eliminate=conf.readNumEntry("eliminate",4); | 73 | ai.eliminate=conf.readNumEntry("eliminate",4); |
74 | ai.expose=conf.readNumEntry("expose",1); | 74 | ai.expose=conf.readNumEntry("expose",1); |
75 | ai.protect=conf.readNumEntry("protect",5); | 75 | ai.protect=conf.readNumEntry("protect",5); |
76 | ai.safe=conf.readNumEntry("safe",3); | 76 | ai.safe=conf.readNumEntry("safe",3); |
77 | ai.empty=conf.readNumEntry("empty",2); | 77 | ai.empty=conf.readNumEntry("empty",2); |
78 | move->setAISettings(ai); | 78 | move->setAISettings(ai); |
79 | 79 | ||
80 | 80 | ||
81 | //get the theme component names | 81 | //get the theme component names |
82 | Config theme(theme_file,Config::File); | 82 | Config theme(theme_file,Config::File); |
83 | if(!theme.isValid()) | 83 | if(!theme.isValid()) |
84 | { | 84 | { |
85 | odebug << "theme file does not exist" << oendl; | 85 | odebug << "theme file does not exist" << oendl; |
86 | theme.setGroup("theme"); | 86 | theme.setGroup("theme"); |
87 | theme.writeEntry("board","casino_board_1"); | 87 | theme.writeEntry("board","casino_board_1"); |
88 | theme.writeEntry("pieces1","casino_pieces_blue"); | 88 | theme.writeEntry("pieces1","casino_pieces_blue"); |
89 | theme.writeEntry("pieces2","casino_pieces_white"); | 89 | theme.writeEntry("pieces2","casino_pieces_white"); |
90 | theme.writeEntry("dice1","casino_dice"); | 90 | theme.writeEntry("dice1","casino_dice"); |
91 | theme.writeEntry("dice2","casino_dice"); | 91 | theme.writeEntry("dice2","casino_dice"); |
92 | theme.writeEntry("table","casino_table_green"); | 92 | theme.writeEntry("table","casino_table_green"); |
93 | theme.writeEntry("odds","casino_odds"); | 93 | theme.writeEntry("odds","casino_odds"); |
94 | } | 94 | } |
95 | theme.setGroup("theme"); | 95 | theme.setGroup("theme"); |
96 | board_name=theme.readEntry("board","casino_board_1"); | 96 | board_name=theme.readEntry("board","casino_board_1"); |
97 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); | 97 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); |
98 | piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); | 98 | piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); |
99 | diceA_name=theme.readEntry("dice1","casino_dice"); | 99 | diceA_name=theme.readEntry("dice1","casino_dice"); |
100 | diceB_name=theme.readEntry("dice2","casino_dice"); | 100 | diceB_name=theme.readEntry("dice2","casino_dice"); |
101 | table_name=theme.readEntry("table","casino_table_green"); | 101 | table_name=theme.readEntry("table","casino_table_green"); |
102 | odds_name=theme.readEntry("odds","casino_odds"); | 102 | odds_name=theme.readEntry("odds","casino_odds"); |
103 | 103 | ||
104 | 104 | ||
105 | //the menu | 105 | //the menu |
106 | QMenuBar* menuBar = new QMenuBar(this); | 106 | QMenuBar* menuBar = new QMenuBar(this); |
107 | 107 | ||
108 | QPopupMenu* gamemenu= new QPopupMenu(this); | 108 | QPopupMenu* gamemenu= new QPopupMenu(this); |
109 | gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); | 109 | gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); |
110 | gamemenu->insertSeparator(); | 110 | gamemenu->insertSeparator(); |
111 | gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame())); | 111 | gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame())); |
112 | gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame())); | 112 | gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame())); |
113 | gamemenu->insertSeparator(); | 113 | gamemenu->insertSeparator(); |
114 | gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame())); | 114 | gamemenu->insertItem(tr( "Delete" ),this,SLOT(deletegame())); |
115 | menuBar->insertItem(tr( "Game" ),gamemenu); | 115 | menuBar->insertItem(tr( "Game" ),gamemenu); |
116 | 116 | ||
117 | QPopupMenu* thememenu= new QPopupMenu(this); | 117 | QPopupMenu* thememenu= new QPopupMenu(this); |
118 | thememenu->insertItem(tr( "New" ),this,SLOT(newtheme())); | 118 | thememenu->insertItem(tr( "New" ),this,SLOT(newtheme())); |
119 | thememenu->insertSeparator(); | 119 | thememenu->insertSeparator(); |
120 | thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme())); | 120 | thememenu->insertItem(tr( "Load"),this,SLOT(loadtheme())); |
121 | thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme())); | 121 | thememenu->insertItem(tr( "Save" ),this,SLOT(savetheme())); |
122 | thememenu->insertSeparator(); | 122 | thememenu->insertSeparator(); |
123 | thememenu->insertItem(tr( "Default"),this,SLOT(themedefault())); | 123 | thememenu->insertItem(tr( "Default"),this,SLOT(themedefault())); |
124 | thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme())); | 124 | thememenu->insertItem(tr( "Delete" ),this,SLOT(deletetheme())); |
125 | menuBar->insertItem(tr( "Theme" ),thememenu); | 125 | menuBar->insertItem(tr( "Theme" ),thememenu); |
126 | 126 | ||
127 | QPopupMenu* optionmenu=new QPopupMenu(this); | 127 | QPopupMenu* optionmenu=new QPopupMenu(this); |
128 | optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect())); | 128 | optionmenu->insertItem(tr( "Player" ),this,SLOT(playerselect())); |
129 | optionmenu->insertSeparator(); | 129 | optionmenu->insertSeparator(); |
130 | optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI())); | 130 | optionmenu->insertItem(tr( "AI" ),this,SLOT(modify_AI())); |
131 | optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules())); | 131 | optionmenu->insertItem(tr( "Rules" ),this,SLOT(setrules())); |
132 | menuBar->insertItem(tr( "Options"),optionmenu); | 132 | menuBar->insertItem(tr( "Options"),optionmenu); |
133 | 133 | ||
134 | QWidget* mainarea=new QWidget(this); | 134 | QWidget* mainarea=new QWidget(this); |
135 | setCentralWidget(mainarea); | 135 | setCentralWidget(mainarea); |
136 | //the main area | 136 | //the main area |
137 | QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom); | 137 | QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom); |
138 | area=new QCanvas(235,235); | 138 | area=new QCanvas(235,235); |
139 | boardview=new BackGammonView(area,mainarea); | 139 | boardview=new BackGammonView(area,mainarea); |
140 | boardview->setMaximumHeight(240); | 140 | boardview->setMaximumHeight(240); |
141 | layout->addWidget(boardview); | 141 | layout->addWidget(boardview); |
142 | connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int))); | 142 | connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int))); |
143 | //status bar | 143 | //status bar |
144 | message=new QLabel("<b>Backgammon</b>",mainarea); | 144 | message=new QLabel("<b>Backgammon</b>",mainarea); |
145 | message->setAlignment(AlignHCenter); | 145 | message->setAlignment(AlignHCenter); |
146 | layout->addWidget(message); | 146 | layout->addWidget(message); |
147 | 147 | ||
148 | //the marker | 148 | //the marker |
149 | marker_current=new QCanvasRectangle(area); | 149 | marker_current=new QCanvasRectangle(area); |
150 | marker_current->setBrush(QColor(0,0,255)); | 150 | marker_current->setBrush(QColor(0,0,255)); |
151 | marker_current->setSize(15,5); | 151 | marker_current->setSize(15,5); |
152 | marker_current->setZ(1); | 152 | marker_current->setZ(1); |
153 | 153 | ||
154 | for(a=0;a<4;a++) | 154 | for(a=0;a<4;a++) |
155 | { | 155 | { |
156 | marker_next[a]=new QCanvasRectangle(area); | 156 | marker_next[a]=new QCanvasRectangle(area); |
@@ -235,374 +235,374 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | |||
235 | if(a<6) | 235 | if(a<6) |
236 | { | 236 | { |
237 | QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); | 237 | QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); |
238 | oddsDice[a]=new CanvasImageItem(oddsbg,area); | 238 | oddsDice[a]=new CanvasImageItem(oddsbg,area); |
239 | oddsDice[a]->setX(110); | 239 | oddsDice[a]->setX(110); |
240 | oddsDice[a]->setY(210-2); | 240 | oddsDice[a]->setY(210-2); |
241 | oddsDice[a]->setZ(1); | 241 | oddsDice[a]->setZ(1); |
242 | oddsDice[a]->setSize(15,15); | 242 | oddsDice[a]->setSize(15,15); |
243 | oddsDice[a]->hide(); | 243 | oddsDice[a]->hide(); |
244 | } | 244 | } |
245 | */ | 245 | */ |
246 | } | 246 | } |
247 | //oddsDice[0]->show(); | 247 | //oddsDice[0]->show(); |
248 | 248 | ||
249 | //set the board | 249 | //set the board |
250 | QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); | 250 | QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); |
251 | board=new CanvasImageItem(boardbg,area); | 251 | board=new CanvasImageItem(boardbg,area); |
252 | board->setX(0); | 252 | board->setX(0); |
253 | board->setY(0); | 253 | board->setY(0); |
254 | board->setZ(0); | 254 | board->setZ(0); |
255 | board->setSize(235-2,200-2); | 255 | board->setSize(235-2,200-2); |
256 | board->show(); | 256 | board->show(); |
257 | 257 | ||
258 | //the table | 258 | //the table |
259 | QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); | 259 | QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); |
260 | table=new CanvasImageItem(tablebg,area); | 260 | table=new CanvasImageItem(tablebg,area); |
261 | table->setX(0); | 261 | table->setX(0); |
262 | table->setY(200-2); | 262 | table->setY(200-2); |
263 | table->setZ(0); | 263 | table->setZ(0); |
264 | table->setSize(235-2,20); | 264 | table->setSize(235-2,20); |
265 | table->show(); | 265 | table->show(); |
266 | 266 | ||
267 | //the no move marker | 267 | //the no move marker |
268 | QImage nomovebg(Resource::loadImage("backgammon/no_move")); | 268 | QImage nomovebg(Resource::loadImage("backgammon/no_move")); |
269 | nomove_marker=new CanvasImageItem(nomovebg,area); | 269 | nomove_marker=new CanvasImageItem(nomovebg,area); |
270 | nomove_marker->setX(0); | 270 | nomove_marker->setX(0); |
271 | nomove_marker->setY(200); | 271 | nomove_marker->setY(200); |
272 | nomove_marker->setZ(2); | 272 | nomove_marker->setZ(2); |
273 | nomove_marker->hide(); | 273 | nomove_marker->hide(); |
274 | 274 | ||
275 | //default human against computer | 275 | //default human against computer |
276 | player1_auto=false; | 276 | player1_auto=false; |
277 | player2_auto=true; | 277 | player2_auto=true; |
278 | //start new game | 278 | //start new game |
279 | newgame(); | 279 | newgame(); |
280 | } | 280 | } |
281 | 281 | ||
282 | BackGammon::~BackGammon() | 282 | BackGammon::~BackGammon() |
283 | { | 283 | { |
284 | //DESTRUCTOR | 284 | //DESTRUCTOR |
285 | } | 285 | } |
286 | 286 | ||
287 | void BackGammon::newgame() | 287 | void BackGammon::newgame() |
288 | { | 288 | { |
289 | gameFinished=false; | 289 | gameFinished=false; |
290 | QDateTime now=QDateTime::currentDateTime(); | 290 | QDateTime now=QDateTime::currentDateTime(); |
291 | game_name=now.date().toString()+"_"+now.time().toString(); | 291 | game_name=now.date().toString()+"_"+now.time().toString(); |
292 | move->reset(); | 292 | move->reset(); |
293 | draw(); | 293 | draw(); |
294 | diceA1_value=7; | 294 | diceA1_value=7; |
295 | diceA2_value=7; | 295 | diceA2_value=7; |
296 | diceA3_value=7; | 296 | diceA3_value=7; |
297 | diceA4_value=7; | 297 | diceA4_value=7; |
298 | diceB1_value=7; | 298 | diceB1_value=7; |
299 | diceB2_value=7; | 299 | diceB2_value=7; |
300 | diceB3_value=7; | 300 | diceB3_value=7; |
301 | diceB4_value=7; | 301 | diceB4_value=7; |
302 | showdice(); | 302 | showdice(); |
303 | player=2; | 303 | player=2; |
304 | dice1_played=true; | 304 | dice1_played=true; |
305 | dice2_played=true; | 305 | dice2_played=true; |
306 | dice3_played=true; | 306 | dice3_played=true; |
307 | dice4_played=true; | 307 | dice4_played=true; |
308 | dice_rolled=false; | 308 | dice_rolled=false; |
309 | setplayer(); | 309 | setplayer(); |
310 | area->update(); | 310 | area->update(); |
311 | } | 311 | } |
312 | 312 | ||
313 | void BackGammon::playerselect() | 313 | void BackGammon::playerselect() |
314 | { | 314 | { |
315 | PlayerDialog* playerdialog=new PlayerDialog(this); | 315 | PlayerDialog* playerdialog=new PlayerDialog(this); |
316 | playerdialog->setAuto1(player1_auto); | 316 | playerdialog->setAuto1(player1_auto); |
317 | playerdialog->setAuto2(player2_auto); | 317 | playerdialog->setAuto2(player2_auto); |
318 | if(!playerdialog->exec()) | 318 | if(!playerdialog->exec()) |
319 | return; | 319 | return; |
320 | player1_auto=playerdialog->getAuto1(); | 320 | player1_auto=playerdialog->getAuto1(); |
321 | player2_auto=playerdialog->getAuto2(); | 321 | player2_auto=playerdialog->getAuto2(); |
322 | } | 322 | } |
323 | 323 | ||
324 | void BackGammon::loadgame() | 324 | void BackGammon::loadgame() |
325 | { | 325 | { |
326 | FileDialog* file=new FileDialog(this,"Load Game",".game"); | 326 | FileDialog* file=new FileDialog(this,"Load Game",".game"); |
327 | if(!file->exec()) | 327 | if(!file->exec()) |
328 | return; | 328 | return; |
329 | 329 | ||
330 | game_name=file->filename(); | 330 | game_name=file->filename(); |
331 | QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; | 331 | QString game_file=QPEApplication::qpeDir()+"backgammon/"+game_name+".game"; |
332 | 332 | ||
333 | Config game(game_file,Config::File); | 333 | Config game(game_file,Config::File); |
334 | game.setGroup("dice"); | 334 | game.setGroup("dice"); |
335 | diceA1_value=game.readNumEntry("diceA1_value"); | 335 | diceA1_value=game.readNumEntry("diceA1_value"); |
336 | diceA2_value=game.readNumEntry("diceA2_value"); | 336 | diceA2_value=game.readNumEntry("diceA2_value"); |
337 | diceA3_value=game.readNumEntry("diceA3_value"); | 337 | diceA3_value=game.readNumEntry("diceA3_value"); |
338 | diceA4_value=game.readNumEntry("diceA4_value"); | 338 | diceA4_value=game.readNumEntry("diceA4_value"); |
339 | diceB1_value=game.readNumEntry("diceB1_value"); | 339 | diceB1_value=game.readNumEntry("diceB1_value"); |
340 | diceB2_value=game.readNumEntry("diceB2_value"); | 340 | diceB2_value=game.readNumEntry("diceB2_value"); |
341 | diceB3_value=game.readNumEntry("diceB3_value"); | 341 | diceB3_value=game.readNumEntry("diceB3_value"); |
342 | diceB4_value=game.readNumEntry("diceB4_value"); | 342 | diceB4_value=game.readNumEntry("diceB4_value"); |
343 | player=game.readNumEntry("player"); | 343 | player=game.readNumEntry("player"); |
344 | dice1_played=game.readBoolEntry("dice1_played"); | 344 | dice1_played=game.readBoolEntry("dice1_played"); |
345 | dice2_played=game.readBoolEntry("dice2_played"); | 345 | dice2_played=game.readBoolEntry("dice2_played"); |
346 | dice3_played=game.readBoolEntry("dice3_played"); | 346 | dice3_played=game.readBoolEntry("dice3_played"); |
347 | dice4_played=game.readBoolEntry("dice4_played"); | 347 | dice4_played=game.readBoolEntry("dice4_played"); |
348 | dice_rolled=game.readBoolEntry("dice_rolled"); | 348 | dice_rolled=game.readBoolEntry("dice_rolled"); |
349 | player1_auto=game.readBoolEntry("player1_auto"); | 349 | player1_auto=game.readBoolEntry("player1_auto"); |
350 | player2_auto=game.readBoolEntry("player2_auto"); | 350 | player2_auto=game.readBoolEntry("player2_auto"); |
351 | 351 | ||
352 | game.setGroup("pieces"); | 352 | game.setGroup("pieces"); |
353 | QString label; | 353 | QString label; |
354 | LoadSave load; | 354 | LoadSave load; |
355 | for(int a=0;a<28;a++) | 355 | for(int a=0;a<28;a++) |
356 | { | 356 | { |
357 | label.setNum(a); | 357 | label.setNum(a); |
358 | load.pop[a].total = game.readNumEntry(label,0); | 358 | load.pop[a].total = game.readNumEntry(label,0); |
359 | } | 359 | } |
360 | 360 | ||
361 | move->loadGame(load); | 361 | move->loadGame(load); |
362 | setplayer(); | 362 | setplayer(); |
363 | showdice(); | 363 | showdice(); |
364 | draw(); | 364 | draw(); |
365 | area->update(); | 365 | area->update(); |
366 | } | 366 | } |
367 | 367 | ||
368 | void BackGammon::savegame() | 368 | void BackGammon::savegame() |
369 | { | 369 | { |
370 | QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; | 370 | QString game_file=QPEApplication::qpeDir()+"backgammon/"+game_name+".game"; |
371 | 371 | ||
372 | Config game(game_file,Config::File); | 372 | Config game(game_file,Config::File); |
373 | game.setGroup("dice"); | 373 | game.setGroup("dice"); |
374 | game.writeEntry("diceA1_value",diceA1_value); | 374 | game.writeEntry("diceA1_value",diceA1_value); |
375 | game.writeEntry("diceA2_value",diceA2_value); | 375 | game.writeEntry("diceA2_value",diceA2_value); |
376 | game.writeEntry("diceA3_value",diceA3_value); | 376 | game.writeEntry("diceA3_value",diceA3_value); |
377 | game.writeEntry("diceA4_value",diceA4_value); | 377 | game.writeEntry("diceA4_value",diceA4_value); |
378 | game.writeEntry("diceB1_value",diceB1_value); | 378 | game.writeEntry("diceB1_value",diceB1_value); |
379 | game.writeEntry("diceB2_value",diceB3_value); | 379 | game.writeEntry("diceB2_value",diceB3_value); |
380 | game.writeEntry("diceB3_value",diceB4_value); | 380 | game.writeEntry("diceB3_value",diceB4_value); |
381 | game.writeEntry("diceB4_value",diceB4_value); | 381 | game.writeEntry("diceB4_value",diceB4_value); |
382 | game.writeEntry("player",player); | 382 | game.writeEntry("player",player); |
383 | game.writeEntry("dice1_played",dice1_played); | 383 | game.writeEntry("dice1_played",dice1_played); |
384 | game.writeEntry("dice2_played",dice2_played); | 384 | game.writeEntry("dice2_played",dice2_played); |
385 | game.writeEntry("dice3_played",dice3_played); | 385 | game.writeEntry("dice3_played",dice3_played); |
386 | game.writeEntry("dice4_played",dice4_played); | 386 | game.writeEntry("dice4_played",dice4_played); |
387 | game.writeEntry("dice_rolled",dice_rolled); | 387 | game.writeEntry("dice_rolled",dice_rolled); |
388 | game.writeEntry("player1_auto",player1_auto); | 388 | game.writeEntry("player1_auto",player1_auto); |
389 | game.writeEntry("player2_auto",player2_auto); | 389 | game.writeEntry("player2_auto",player2_auto); |
390 | 390 | ||
391 | game.setGroup("pieces"); | 391 | game.setGroup("pieces"); |
392 | QString label; | 392 | QString label; |
393 | LoadSave save=move->saveGame(); | 393 | LoadSave save=move->saveGame(); |
394 | for(int a=0;a<28;a++) | 394 | for(int a=0;a<28;a++) |
395 | { | 395 | { |
396 | label.setNum(a); | 396 | label.setNum(a); |
397 | game.writeEntry(label,save.pop[a].total); | 397 | game.writeEntry(label,save.pop[a].total); |
398 | } | 398 | } |
399 | QMessageBox::information(this,"Backgammon","Game saved","OK"); | 399 | QMessageBox::information(this,"Backgammon","Game saved","OK"); |
400 | } | 400 | } |
401 | 401 | ||
402 | void BackGammon::deletegame() | 402 | void BackGammon::deletegame() |
403 | { | 403 | { |
404 | FileDialog* file=new FileDialog(this,"Delete Game",".game"); | 404 | FileDialog* file=new FileDialog(this,"Delete Game",".game"); |
405 | if(!file->exec()) | 405 | if(!file->exec()) |
406 | return; | 406 | return; |
407 | 407 | ||
408 | game_name=file->filename(); | 408 | game_name=file->filename(); |
409 | QString game_file=QPEApplication::qpeDir()+"/backgammon/"+game_name+".game"; | 409 | QString game_file=QPEApplication::qpeDir()+"backgammon/"+game_name+".game"; |
410 | 410 | ||
411 | if(!QMessageBox::warning(this,"Backgammon","deleted game\n"+game_name+" ?","OK","Cancel")) | 411 | if(!QMessageBox::warning(this,"Backgammon","deleted game\n"+game_name+" ?","OK","Cancel")) |
412 | { | 412 | { |
413 | QFile(game_file).remove(); | 413 | QFile(game_file).remove(); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | void BackGammon::newtheme() | 418 | void BackGammon::newtheme() |
419 | { | 419 | { |
420 | ThemeDialog* theme=new ThemeDialog(this); | 420 | ThemeDialog* theme=new ThemeDialog(this); |
421 | 421 | ||
422 | ImageNames names; | 422 | ImageNames names; |
423 | names.theme=theme_name; | 423 | names.theme=theme_name; |
424 | names.board=board_name; | 424 | names.board=board_name; |
425 | names.pieces1=piecesA_name; | 425 | names.pieces1=piecesA_name; |
426 | names.pieces2=piecesB_name; | 426 | names.pieces2=piecesB_name; |
427 | names.dice1=diceA_name; | 427 | names.dice1=diceA_name; |
428 | names.dice2=diceB_name; | 428 | names.dice2=diceB_name; |
429 | names.odds=odds_name; | 429 | names.odds=odds_name; |
430 | names.table=table_name; | 430 | names.table=table_name; |
431 | 431 | ||
432 | theme->setCurrent(names); | 432 | theme->setCurrent(names); |
433 | if(!theme->exec()) | 433 | if(!theme->exec()) |
434 | return; | 434 | return; |
435 | 435 | ||
436 | names=theme->getNames(); | 436 | names=theme->getNames(); |
437 | theme_name=names.theme; | 437 | theme_name=names.theme; |
438 | board_name=names.board; | 438 | board_name=names.board; |
439 | piecesA_name=names.pieces1; | 439 | piecesA_name=names.pieces1; |
440 | piecesB_name=names.pieces2; | 440 | piecesB_name=names.pieces2; |
441 | diceA_name=names.dice1; | 441 | diceA_name=names.dice1; |
442 | diceB_name=names.dice2; | 442 | diceB_name=names.dice2; |
443 | odds_name=names.odds; | 443 | odds_name=names.odds; |
444 | table_name=names.table; | 444 | table_name=names.table; |
445 | 445 | ||
446 | applytheme(); | 446 | applytheme(); |
447 | } | 447 | } |
448 | 448 | ||
449 | void BackGammon::loadtheme() | 449 | void BackGammon::loadtheme() |
450 | { | 450 | { |
451 | FileDialog* file=new FileDialog(this,"Load Theme",".theme"); | 451 | FileDialog* file=new FileDialog(this,"Load Theme",".theme"); |
452 | if(!file->exec()) | 452 | if(!file->exec()) |
453 | return; | 453 | return; |
454 | 454 | ||
455 | theme_name=file->filename(); | 455 | theme_name=file->filename(); |
456 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; | 456 | QString theme_file=QPEApplication::qpeDir()+"backgammon/"+theme_name+".theme"; |
457 | 457 | ||
458 | Config theme(theme_file,Config::File); | 458 | Config theme(theme_file,Config::File); |
459 | theme.setGroup("theme"); | 459 | theme.setGroup("theme"); |
460 | board_name=theme.readEntry("board","board_1"); | 460 | board_name=theme.readEntry("board","board_1"); |
461 | piecesA_name=theme.readEntry("pieces1","pieces_1"); | 461 | piecesA_name=theme.readEntry("pieces1","pieces_1"); |
462 | piecesB_name=theme.readEntry("pieces2","pieces_2"); | 462 | piecesB_name=theme.readEntry("pieces2","pieces_2"); |
463 | diceA_name=theme.readEntry("dice1","dice_1"); | 463 | diceA_name=theme.readEntry("dice1","dice_1"); |
464 | diceB_name=theme.readEntry("dice2","dice_2"); | 464 | diceB_name=theme.readEntry("dice2","dice_2"); |
465 | table_name=theme.readEntry("table","table_1"); | 465 | table_name=theme.readEntry("table","table_1"); |
466 | odds_name=theme.readEntry("odds","odds_1"); | 466 | odds_name=theme.readEntry("odds","odds_1"); |
467 | 467 | ||
468 | applytheme(); | 468 | applytheme(); |
469 | 469 | ||
470 | } | 470 | } |
471 | 471 | ||
472 | void BackGammon::savetheme() | 472 | void BackGammon::savetheme() |
473 | { | 473 | { |
474 | if(theme_name=="default") | 474 | if(theme_name=="default") |
475 | { | 475 | { |
476 | QMessageBox::information(this,"Backgammon","Sorry\nCannot overwrite default.theme","OK"); | 476 | QMessageBox::information(this,"Backgammon","Sorry\nCannot overwrite default.theme","OK"); |
477 | return; | 477 | return; |
478 | } | 478 | } |
479 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; | 479 | QString theme_file=QPEApplication::qpeDir()+"backgammon/"+theme_name+".theme"; |
480 | if(QMessageBox::information(this,"Backgammon","Save Theme\n"+theme_name,"Yes","No")) | 480 | if(QMessageBox::information(this,"Backgammon","Save Theme\n"+theme_name,"Yes","No")) |
481 | return; | 481 | return; |
482 | 482 | ||
483 | Config theme(theme_file,Config::File); | 483 | Config theme(theme_file,Config::File); |
484 | theme.setGroup("theme"); | 484 | theme.setGroup("theme"); |
485 | theme.writeEntry("board",board_name); | 485 | theme.writeEntry("board",board_name); |
486 | theme.writeEntry("pieces1",piecesA_name); | 486 | theme.writeEntry("pieces1",piecesA_name); |
487 | theme.writeEntry("pieces2",piecesB_name); | 487 | theme.writeEntry("pieces2",piecesB_name); |
488 | theme.writeEntry("dice1",diceA_name); | 488 | theme.writeEntry("dice1",diceA_name); |
489 | theme.writeEntry("dice2",diceB_name); | 489 | theme.writeEntry("dice2",diceB_name); |
490 | theme.writeEntry("table",table_name); | 490 | theme.writeEntry("table",table_name); |
491 | theme.writeEntry("odds",odds_name); | 491 | theme.writeEntry("odds",odds_name); |
492 | 492 | ||
493 | } | 493 | } |
494 | 494 | ||
495 | void BackGammon::themedefault() | 495 | void BackGammon::themedefault() |
496 | { | 496 | { |
497 | if(QMessageBox::information(this,"Backgammon","Make Theme\n"+theme_name+"\nthe default theme","Yes","No")) | 497 | if(QMessageBox::information(this,"Backgammon","Make Theme\n"+theme_name+"\nthe default theme","Yes","No")) |
498 | return; | 498 | return; |
499 | 499 | ||
500 | Config conf("backgammon"); | 500 | Config conf("backgammon"); |
501 | conf.setGroup("general"); | 501 | conf.setGroup("general"); |
502 | conf.writeEntry("theme",theme_name); | 502 | conf.writeEntry("theme",theme_name); |
503 | } | 503 | } |
504 | 504 | ||
505 | void BackGammon::deletetheme() | 505 | void BackGammon::deletetheme() |
506 | { | 506 | { |
507 | FileDialog* file=new FileDialog(this,"Delete Theme",".theme"); | 507 | FileDialog* file=new FileDialog(this,"Delete Theme",".theme"); |
508 | if(!file->exec()) | 508 | if(!file->exec()) |
509 | return; | 509 | return; |
510 | 510 | ||
511 | theme_name=file->filename(); | 511 | theme_name=file->filename(); |
512 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; | 512 | QString theme_file=QPEApplication::qpeDir()+"backgammon/"+theme_name+".theme"; |
513 | 513 | ||
514 | if(!QMessageBox::warning(this,tr( "Backgammon" ),tr( "deleted theme %1?").arg(theme_name),tr( "OK" ),tr( "Cancel" ))) | 514 | if(!QMessageBox::warning(this,tr( "Backgammon" ),tr( "deleted theme %1?").arg(theme_name),tr( "OK" ),tr( "Cancel" ))) |
515 | { | 515 | { |
516 | QFile(theme_file).remove(); | 516 | QFile(theme_file).remove(); |
517 | } | 517 | } |
518 | } | 518 | } |
519 | 519 | ||
520 | void BackGammon::modify_AI() | 520 | void BackGammon::modify_AI() |
521 | { | 521 | { |
522 | AI_Dialog* ai_mod=new AI_Dialog(this,tr( "Load Theme" ),".theme"); | 522 | AI_Dialog* ai_mod=new AI_Dialog(this,tr( "Load Theme" ),".theme"); |
523 | ai_mod->setAISettings(move->getAISettings()); | 523 | ai_mod->setAISettings(move->getAISettings()); |
524 | if(!ai_mod->exec()) | 524 | if(!ai_mod->exec()) |
525 | return; | 525 | return; |
526 | 526 | ||
527 | //get the AI settings | 527 | //get the AI settings |
528 | AISettings ai=ai_mod->getAISettings(); | 528 | AISettings ai=ai_mod->getAISettings(); |
529 | move->setAISettings(ai); | 529 | move->setAISettings(ai); |
530 | //write new settings to conf file | 530 | //write new settings to conf file |
531 | Config conf("backgammon"); | 531 | Config conf("backgammon"); |
532 | conf.setGroup("ai"); | 532 | conf.setGroup("ai"); |
533 | conf.writeEntry("rescue",ai.rescue); | 533 | conf.writeEntry("rescue",ai.rescue); |
534 | conf.writeEntry("eliminate",ai.eliminate); | 534 | conf.writeEntry("eliminate",ai.eliminate); |
535 | conf.writeEntry("expose",ai.expose); | 535 | conf.writeEntry("expose",ai.expose); |
536 | conf.writeEntry("protect",ai.protect); | 536 | conf.writeEntry("protect",ai.protect); |
537 | conf.writeEntry("safe",ai.safe); | 537 | conf.writeEntry("safe",ai.safe); |
538 | conf.writeEntry("empty",ai.empty); | 538 | conf.writeEntry("empty",ai.empty); |
539 | } | 539 | } |
540 | 540 | ||
541 | void BackGammon::setrules() | 541 | void BackGammon::setrules() |
542 | { | 542 | { |
543 | RulesDialog* rulesdialog=new RulesDialog(this,tr( "Load Theme" ),".theme"); | 543 | RulesDialog* rulesdialog=new RulesDialog(this,tr( "Load Theme" ),".theme"); |
544 | rulesdialog->setRules(rules); | 544 | rulesdialog->setRules(rules); |
545 | if(!rulesdialog->exec()) | 545 | if(!rulesdialog->exec()) |
546 | return; | 546 | return; |
547 | rules=rulesdialog->getRules(); | 547 | rules=rulesdialog->getRules(); |
548 | Config conf("backgammon"); | 548 | Config conf("backgammon"); |
549 | conf.setGroup("rules"); | 549 | conf.setGroup("rules"); |
550 | conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out); | 550 | conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out); |
551 | conf.writeEntry("nice_dice",rules.generous_dice); | 551 | conf.writeEntry("nice_dice",rules.generous_dice); |
552 | move->setRules(rules); | 552 | move->setRules(rules); |
553 | } | 553 | } |
554 | 554 | ||
555 | 555 | ||
556 | void BackGammon::draw() | 556 | void BackGammon::draw() |
557 | { | 557 | { |
558 | Pieces pieces; | 558 | Pieces pieces; |
559 | move->position(pieces); | 559 | move->position(pieces); |
560 | for(int a=0;a<15;a++) | 560 | for(int a=0;a<15;a++) |
561 | { | 561 | { |
562 | if(!pieces.player1[a].side) | 562 | if(!pieces.player1[a].side) |
563 | { | 563 | { |
564 | p1[a]->setX(pieces.player1[a].x); | 564 | p1[a]->setX(pieces.player1[a].x); |
565 | p1[a]->setY(pieces.player1[a].y); | 565 | p1[a]->setY(pieces.player1[a].y); |
566 | p1[a]->setZ(pieces.player1[a].z); | 566 | p1[a]->setZ(pieces.player1[a].z); |
567 | p1[a]->show(); | 567 | p1[a]->show(); |
568 | p1_side[a]->hide(); | 568 | p1_side[a]->hide(); |
569 | } | 569 | } |
570 | else | 570 | else |
571 | { | 571 | { |
572 | p1_side[a]->setX(pieces.player1[a].x); | 572 | p1_side[a]->setX(pieces.player1[a].x); |
573 | p1_side[a]->setY(pieces.player1[a].y); | 573 | p1_side[a]->setY(pieces.player1[a].y); |
574 | p1_side[a]->setZ(pieces.player1[a].z); | 574 | p1_side[a]->setZ(pieces.player1[a].z); |
575 | p1_side[a]->show(); | 575 | p1_side[a]->show(); |
576 | p1[a]->hide(); | 576 | p1[a]->hide(); |
577 | } | 577 | } |
578 | 578 | ||
579 | if(!pieces.player2[a].side) | 579 | if(!pieces.player2[a].side) |
580 | { | 580 | { |
581 | p2[a]->setX(pieces.player2[a].x); | 581 | p2[a]->setX(pieces.player2[a].x); |
582 | p2[a]->setY(pieces.player2[a].y); | 582 | p2[a]->setY(pieces.player2[a].y); |
583 | p2[a]->setZ(pieces.player2[a].z); | 583 | p2[a]->setZ(pieces.player2[a].z); |
584 | p2[a]->show(); | 584 | p2[a]->show(); |
585 | p2_side[a]->hide(); | 585 | p2_side[a]->hide(); |
586 | } | 586 | } |
587 | else | 587 | else |
588 | { | 588 | { |
589 | p2_side[a]->setX(pieces.player2[a].x); | 589 | p2_side[a]->setX(pieces.player2[a].x); |
590 | p2_side[a]->setY(pieces.player2[a].y); | 590 | p2_side[a]->setY(pieces.player2[a].y); |
591 | p2_side[a]->setZ(pieces.player2[a].z); | 591 | p2_side[a]->setZ(pieces.player2[a].z); |
592 | p2_side[a]->show(); | 592 | p2_side[a]->show(); |
593 | p2[a]->hide(); | 593 | p2[a]->hide(); |
594 | } | 594 | } |
595 | } | 595 | } |
596 | } | 596 | } |
597 | 597 | ||
598 | void BackGammon::mouse(int x,int y) | 598 | void BackGammon::mouse(int x,int y) |
599 | { | 599 | { |
600 | if(gameFinished) | 600 | if(gameFinished) |
601 | { | 601 | { |
602 | newgame(); | 602 | newgame(); |
603 | return; | 603 | return; |
604 | } | 604 | } |
605 | if(y<=200) //move pieces | 605 | if(y<=200) //move pieces |
606 | { | 606 | { |
607 | if((player==1 && player1_auto) || (player==2 && player2_auto)) | 607 | if((player==1 && player1_auto) || (player==2 && player2_auto)) |
608 | return; | 608 | return; |
diff --git a/noncore/games/backgammon/filedialog.cpp b/noncore/games/backgammon/filedialog.cpp index e0a2914..f185188 100644 --- a/noncore/games/backgammon/filedialog.cpp +++ b/noncore/games/backgammon/filedialog.cpp | |||
@@ -1,61 +1,61 @@ | |||
1 | #include "filedialog.h" | 1 | #include "filedialog.h" |
2 | 2 | ||
3 | #include <qdir.h> | 3 | #include <qdir.h> |
4 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
5 | 5 | ||
6 | FileDialog::FileDialog(QWidget* parent,QString header,QString extension,const char* name,bool modal,WFlags f) | 6 | FileDialog::FileDialog(QWidget* parent,QString header,QString extension,const char* name,bool modal,WFlags f) |
7 | :QDialog(parent,name,modal,f) | 7 | :QDialog(parent,name,modal,f) |
8 | { | 8 | { |
9 | setCaption(header); | 9 | setCaption(header); |
10 | ext=extension; | 10 | ext=extension; |
11 | dirselector=new QListView(this); | 11 | dirselector=new QListView(this); |
12 | dirselector->setGeometry(1,10,235,200); | 12 | dirselector->setGeometry(1,10,235,200); |
13 | dirselector->addColumn("Files"); | 13 | dirselector->addColumn("Files"); |
14 | connect(dirselector,SIGNAL(clicked(QListViewItem*)),this,SLOT(selectorclicked(QListViewItem*))); | 14 | connect(dirselector,SIGNAL(clicked(QListViewItem*)),this,SLOT(selectorclicked(QListViewItem*))); |
15 | 15 | ||
16 | getCurrentDir(); | 16 | getCurrentDir(); |
17 | 17 | ||
18 | file_name="user"; | 18 | file_name="user"; |
19 | fileinput=new QLineEdit(file_name,this); | 19 | fileinput=new QLineEdit(file_name,this); |
20 | fileinput->setGeometry(1,220,235,20); | 20 | fileinput->setGeometry(1,220,235,20); |
21 | 21 | ||
22 | QPEApplication::showDialog( this ); | 22 | QPEApplication::showDialog( this ); |
23 | } | 23 | } |
24 | 24 | ||
25 | FileDialog::~FileDialog() | 25 | FileDialog::~FileDialog() |
26 | {} | 26 | {} |
27 | 27 | ||
28 | 28 | ||
29 | void FileDialog::selectorclicked(QListViewItem* entry) | 29 | void FileDialog::selectorclicked(QListViewItem* entry) |
30 | { | 30 | { |
31 | if(entry==NULL) | 31 | if(entry==NULL) |
32 | return; | 32 | return; |
33 | file_name=entry->text(0); | 33 | file_name=entry->text(0); |
34 | fileinput->setText(file_name); | 34 | fileinput->setText(file_name); |
35 | } | 35 | } |
36 | 36 | ||
37 | void FileDialog::getCurrentDir() | 37 | void FileDialog::getCurrentDir() |
38 | { | 38 | { |
39 | dirselector->clear(); | 39 | dirselector->clear(); |
40 | QDir dir(QPEApplication::qpeDir()+"/backgammon"); | 40 | QDir dir(QPEApplication::qpeDir()+"backgammon"); |
41 | dir.setFilter(QDir::Files); | 41 | dir.setFilter(QDir::Files); |
42 | QFileInfoListIterator it(*(dir.entryInfoList())); | 42 | QFileInfoListIterator it(*(dir.entryInfoList())); |
43 | QFileInfo* fi; | 43 | QFileInfo* fi; |
44 | 44 | ||
45 | int ext_length=ext.length(); | 45 | int ext_length=ext.length(); |
46 | while((fi=it.current())) // go through all file and subdirs | 46 | while((fi=it.current())) // go through all file and subdirs |
47 | { | 47 | { |
48 | QString file=fi->fileName(); | 48 | QString file=fi->fileName(); |
49 | if(file.right(ext_length)==ext && file) | 49 | if(file.right(ext_length)==ext && file) |
50 | { | 50 | { |
51 | file=file.left(file.length()-ext_length); | 51 | file=file.left(file.length()-ext_length); |
52 | new QListViewItem(dirselector,file); | 52 | new QListViewItem(dirselector,file); |
53 | } | 53 | } |
54 | ++it; | 54 | ++it; |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | QString FileDialog::filename() | 58 | QString FileDialog::filename() |
59 | { | 59 | { |
60 | return file_name; | 60 | return file_name; |
61 | } | 61 | } |
diff --git a/noncore/games/backgammon/themedialog.cpp b/noncore/games/backgammon/themedialog.cpp index afd6a1b..9bdb6a9 100644 --- a/noncore/games/backgammon/themedialog.cpp +++ b/noncore/games/backgammon/themedialog.cpp | |||
@@ -50,112 +50,112 @@ ThemeDialog::ThemeDialog(QWidget* parent,const char* name,bool modal,WFlags f) | |||
50 | boxodds->setGeometry(40,200,195,20); | 50 | boxodds->setGeometry(40,200,195,20); |
51 | fillBox("odds",boxodds); | 51 | fillBox("odds",boxodds); |
52 | boxodds->setEnabled(false); | 52 | boxodds->setEnabled(false); |
53 | 53 | ||
54 | QLabel* labeltable=new QLabel("table",this); | 54 | QLabel* labeltable=new QLabel("table",this); |
55 | labeltable->setGeometry(0,225,40,20); | 55 | labeltable->setGeometry(0,225,40,20); |
56 | boxtable=new QComboBox(this); | 56 | boxtable=new QComboBox(this); |
57 | boxtable->setGeometry(40,225,195,20); | 57 | boxtable->setGeometry(40,225,195,20); |
58 | fillBox("table",boxtable); | 58 | fillBox("table",boxtable); |
59 | 59 | ||
60 | QPEApplication::showDialog( this ); | 60 | QPEApplication::showDialog( this ); |
61 | } | 61 | } |
62 | 62 | ||
63 | ThemeDialog::~ThemeDialog() | 63 | ThemeDialog::~ThemeDialog() |
64 | {} | 64 | {} |
65 | 65 | ||
66 | 66 | ||
67 | ImageNames ThemeDialog::getNames() | 67 | ImageNames ThemeDialog::getNames() |
68 | { | 68 | { |
69 | ImageNames names; | 69 | ImageNames names; |
70 | names.theme=lineName->text(); | 70 | names.theme=lineName->text(); |
71 | names.board=boxboard->currentText(); | 71 | names.board=boxboard->currentText(); |
72 | names.pieces1=boxpiecesA->currentText(); | 72 | names.pieces1=boxpiecesA->currentText(); |
73 | names.pieces2=boxpiecesB->currentText(); | 73 | names.pieces2=boxpiecesB->currentText(); |
74 | names.dice1=boxdiceA->currentText(); | 74 | names.dice1=boxdiceA->currentText(); |
75 | names.dice2=boxdiceB->currentText(); | 75 | names.dice2=boxdiceB->currentText(); |
76 | names.odds=boxodds->currentText(); | 76 | names.odds=boxodds->currentText(); |
77 | names.table=boxtable->currentText(); | 77 | names.table=boxtable->currentText(); |
78 | return names; | 78 | return names; |
79 | } | 79 | } |
80 | 80 | ||
81 | void ThemeDialog::setCurrent(const ImageNames& current) | 81 | void ThemeDialog::setCurrent(const ImageNames& current) |
82 | { | 82 | { |
83 | int a=0; | 83 | int a=0; |
84 | lineName->setText(current.theme); | 84 | lineName->setText(current.theme); |
85 | for(a=0;a<boxboard->count();a++) | 85 | for(a=0;a<boxboard->count();a++) |
86 | { | 86 | { |
87 | if(boxboard->text(a)==current.board) | 87 | if(boxboard->text(a)==current.board) |
88 | { | 88 | { |
89 | boxboard->setCurrentItem(a); | 89 | boxboard->setCurrentItem(a); |
90 | break; | 90 | break; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | for(a=0;a<boxpiecesA->count();a++) | 93 | for(a=0;a<boxpiecesA->count();a++) |
94 | { | 94 | { |
95 | if(boxpiecesA->text(a)==current.pieces1) | 95 | if(boxpiecesA->text(a)==current.pieces1) |
96 | { | 96 | { |
97 | boxpiecesA->setCurrentItem(a); | 97 | boxpiecesA->setCurrentItem(a); |
98 | break; | 98 | break; |
99 | } | 99 | } |
100 | } | 100 | } |
101 | for(a=0;a<boxpiecesB->count();a++) | 101 | for(a=0;a<boxpiecesB->count();a++) |
102 | { | 102 | { |
103 | if(boxpiecesB->text(a)==current.pieces2) | 103 | if(boxpiecesB->text(a)==current.pieces2) |
104 | { | 104 | { |
105 | boxpiecesB->setCurrentItem(a); | 105 | boxpiecesB->setCurrentItem(a); |
106 | break; | 106 | break; |
107 | } | 107 | } |
108 | } | 108 | } |
109 | for(a=0;a<boxdiceA->count();a++) | 109 | for(a=0;a<boxdiceA->count();a++) |
110 | { | 110 | { |
111 | if(boxdiceA->text(a)==current.dice1) | 111 | if(boxdiceA->text(a)==current.dice1) |
112 | { | 112 | { |
113 | boxdiceA->setCurrentItem(a); | 113 | boxdiceA->setCurrentItem(a); |
114 | break; | 114 | break; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | for(a=0;a<boxdiceB->count();a++) | 117 | for(a=0;a<boxdiceB->count();a++) |
118 | { | 118 | { |
119 | if(boxdiceB->text(a)==current.dice2) | 119 | if(boxdiceB->text(a)==current.dice2) |
120 | { | 120 | { |
121 | boxdiceB->setCurrentItem(a); | 121 | boxdiceB->setCurrentItem(a); |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | for(a=0;a<boxodds->count();a++) | 125 | for(a=0;a<boxodds->count();a++) |
126 | { | 126 | { |
127 | if(boxodds->text(a)==current.odds) | 127 | if(boxodds->text(a)==current.odds) |
128 | { | 128 | { |
129 | boxodds->setCurrentItem(a); | 129 | boxodds->setCurrentItem(a); |
130 | break; | 130 | break; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | for(a=0;a<boxtable->count();a++) | 133 | for(a=0;a<boxtable->count();a++) |
134 | { | 134 | { |
135 | if(boxtable->text(a)==current.table) | 135 | if(boxtable->text(a)==current.table) |
136 | { | 136 | { |
137 | boxtable->setCurrentItem(a); | 137 | boxtable->setCurrentItem(a); |
138 | break; | 138 | break; |
139 | } | 139 | } |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | void ThemeDialog::fillBox(QString dirname,QComboBox* thebox) | 143 | void ThemeDialog::fillBox(QString dirname,QComboBox* thebox) |
144 | { | 144 | { |
145 | thebox->clear(); | 145 | thebox->clear(); |
146 | QDir dir(QPEApplication::qpeDir()+"/pics/backgammon/"+dirname); | 146 | QDir dir(QPEApplication::qpeDir()+"pics/backgammon/"+dirname); |
147 | dir.setFilter(QDir::Dirs | QDir::Files); | 147 | dir.setFilter(QDir::Dirs | QDir::Files); |
148 | QFileInfoListIterator it(*(dir.entryInfoList())); | 148 | QFileInfoListIterator it(*(dir.entryInfoList())); |
149 | QFileInfo* fi; | 149 | QFileInfo* fi; |
150 | 150 | ||
151 | while((fi=it.current())) // go through all file and subdirs | 151 | while((fi=it.current())) // go through all file and subdirs |
152 | { | 152 | { |
153 | QString file=fi->fileName(); | 153 | QString file=fi->fileName(); |
154 | if(file.right(4)==".png") | 154 | if(file.right(4)==".png") |
155 | { | 155 | { |
156 | thebox->insertItem(file.left(file.find(".png"))); | 156 | thebox->insertItem(file.left(file.find(".png"))); |
157 | } | 157 | } |
158 | ++it; | 158 | ++it; |
159 | } | 159 | } |
160 | delete fi; | 160 | delete fi; |
161 | } | 161 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index dc2c496..2e9553f 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -856,193 +856,193 @@ void PlayListWidget::writem3u() { | |||
856 | lnk.setName( name); //sets file name | 856 | lnk.setName( name); //sets file name |
857 | 857 | ||
858 | // odebug << filename << oendl; | 858 | // odebug << filename << oendl; |
859 | Config config( "OpiePlayer" ); | 859 | Config config( "OpiePlayer" ); |
860 | config.setGroup( "PlayList" ); | 860 | config.setGroup( "PlayList" ); |
861 | 861 | ||
862 | config.writeEntry("CurrentPlaylist",filename); | 862 | config.writeEntry("CurrentPlaylist",filename); |
863 | currentPlayList=filename; | 863 | currentPlayList=filename; |
864 | 864 | ||
865 | if(!lnk.writeLink()) { | 865 | if(!lnk.writeLink()) { |
866 | odebug << "Writing doclink did not work" << oendl; | 866 | odebug << "Writing doclink did not work" << oendl; |
867 | } | 867 | } |
868 | 868 | ||
869 | setCaption(tr("OpiePlayer: ") + name); | 869 | setCaption(tr("OpiePlayer: ") + name); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 874 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
875 | switch ( e->key() ) { | 875 | switch ( e->key() ) { |
876 | ////////////////////////////// Zaurus keys | 876 | ////////////////////////////// Zaurus keys |
877 | case Key_F9: //activity | 877 | case Key_F9: //activity |
878 | // if(audioUI->isHidden()) | 878 | // if(audioUI->isHidden()) |
879 | // audioUI->showMaximized(); | 879 | // audioUI->showMaximized(); |
880 | break; | 880 | break; |
881 | case Key_F10: //contacts | 881 | case Key_F10: //contacts |
882 | // if( videoUI->isHidden()) | 882 | // if( videoUI->isHidden()) |
883 | // videoUI->showMaximized(); | 883 | // videoUI->showMaximized(); |
884 | break; | 884 | break; |
885 | case Key_F11: //menu | 885 | case Key_F11: //menu |
886 | break; | 886 | break; |
887 | case Key_F12: //home | 887 | case Key_F12: //home |
888 | // doBlank(); | 888 | // doBlank(); |
889 | break; | 889 | break; |
890 | case Key_F13: //mail | 890 | case Key_F13: //mail |
891 | // doUnblank(); | 891 | // doUnblank(); |
892 | break; | 892 | break; |
893 | case Key_Q: //add to playlist | 893 | case Key_Q: //add to playlist |
894 | addSelected(); | 894 | addSelected(); |
895 | break; | 895 | break; |
896 | case Key_R: //remove from playlist | 896 | case Key_R: //remove from playlist |
897 | removeSelected(); | 897 | removeSelected(); |
898 | break; | 898 | break; |
899 | // case Key_P: //play | 899 | // case Key_P: //play |
900 | // odebug << "Play" << oendl; | 900 | // odebug << "Play" << oendl; |
901 | // playSelected(); | 901 | // playSelected(); |
902 | // break; | 902 | // break; |
903 | case Key_Space: | 903 | case Key_Space: |
904 | // playSelected(); puh | 904 | // playSelected(); puh |
905 | break; | 905 | break; |
906 | case Key_1: | 906 | case Key_1: |
907 | tabWidget->setCurrentPage( 0 ); | 907 | tabWidget->setCurrentPage( 0 ); |
908 | break; | 908 | break; |
909 | case Key_2: | 909 | case Key_2: |
910 | tabWidget->setCurrentPage( 1 ); | 910 | tabWidget->setCurrentPage( 1 ); |
911 | break; | 911 | break; |
912 | case Key_3: | 912 | case Key_3: |
913 | tabWidget->setCurrentPage( 2 ); | 913 | tabWidget->setCurrentPage( 2 ); |
914 | break; | 914 | break; |
915 | case Key_4: | 915 | case Key_4: |
916 | tabWidget->setCurrentPage( 3 ); | 916 | tabWidget->setCurrentPage( 3 ); |
917 | break; | 917 | break; |
918 | case Key_Down: | 918 | case Key_Down: |
919 | if ( !d->selectedFiles->next() ) | 919 | if ( !d->selectedFiles->next() ) |
920 | d->selectedFiles->first(); | 920 | d->selectedFiles->first(); |
921 | break; | 921 | break; |
922 | case Key_Up: | 922 | case Key_Up: |
923 | if ( !d->selectedFiles->prev() ) | 923 | if ( !d->selectedFiles->prev() ) |
924 | // d->selectedFiles->last(); | 924 | // d->selectedFiles->last(); |
925 | break; | 925 | break; |
926 | } | 926 | } |
927 | } | 927 | } |
928 | 928 | ||
929 | void PlayListWidget::pmViewActivated(int index) { | 929 | void PlayListWidget::pmViewActivated(int index) { |
930 | // odebug << "" << index << "" << oendl; | 930 | // odebug << "" << index << "" << oendl; |
931 | switch(index) { | 931 | switch(index) { |
932 | case -16: | 932 | case -16: |
933 | { | 933 | { |
934 | mediaPlayerState->toggleFullscreen(); | 934 | mediaPlayerState->toggleFullscreen(); |
935 | bool b=mediaPlayerState->isFullscreen(); | 935 | bool b=mediaPlayerState->isFullscreen(); |
936 | pmView->setItemChecked( index, b); | 936 | pmView->setItemChecked( index, b); |
937 | Config cfg( "OpiePlayer" ); | 937 | Config cfg( "OpiePlayer" ); |
938 | cfg.writeEntry( "FullScreen", b ); | 938 | cfg.writeEntry( "FullScreen", b ); |
939 | } | 939 | } |
940 | break; | 940 | break; |
941 | }; | 941 | }; |
942 | } | 942 | } |
943 | 943 | ||
944 | void PlayListWidget::populateSkinsMenu() { | 944 | void PlayListWidget::populateSkinsMenu() { |
945 | int item = 0; | 945 | int item = 0; |
946 | defaultSkinIndex = 0; | 946 | defaultSkinIndex = 0; |
947 | QString skinName; | 947 | QString skinName; |
948 | Config cfg( "OpiePlayer" ); | 948 | Config cfg( "OpiePlayer" ); |
949 | cfg.setGroup("Options" ); | 949 | cfg.setGroup("Options" ); |
950 | QString skin = cfg.readEntry( "Skin", "default" ); | 950 | QString skin = cfg.readEntry( "Skin", "default" ); |
951 | 951 | ||
952 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 952 | QDir skinsDir( QPEApplication::qpeDir() + "pics/opieplayer2/skins" ); |
953 | skinsDir.setFilter( QDir::Dirs ); | 953 | skinsDir.setFilter( QDir::Dirs ); |
954 | skinsDir.setSorting(QDir::Name ); | 954 | skinsDir.setSorting(QDir::Name ); |
955 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 955 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
956 | QFileInfoListIterator it( *skinslist ); | 956 | QFileInfoListIterator it( *skinslist ); |
957 | QFileInfo *fi; | 957 | QFileInfo *fi; |
958 | while ( ( fi = it.current() ) ) { | 958 | while ( ( fi = it.current() ) ) { |
959 | skinName = fi->fileName(); | 959 | skinName = fi->fileName(); |
960 | // odebug << fi->fileName() << oendl; | 960 | // odebug << fi->fileName() << oendl; |
961 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 961 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
962 | item = skinsMenu->insertItem( fi->fileName() ) ; | 962 | item = skinsMenu->insertItem( fi->fileName() ) ; |
963 | } | 963 | } |
964 | if( skinName == "default" ) { | 964 | if( skinName == "default" ) { |
965 | defaultSkinIndex = item; | 965 | defaultSkinIndex = item; |
966 | } | 966 | } |
967 | if( skinName == skin ) { | 967 | if( skinName == skin ) { |
968 | skinsMenu->setItemChecked( item, TRUE ); | 968 | skinsMenu->setItemChecked( item, TRUE ); |
969 | } | 969 | } |
970 | ++it; | 970 | ++it; |
971 | } | 971 | } |
972 | } | 972 | } |
973 | 973 | ||
974 | void PlayListWidget::skinsMenuActivated( int item ) { | 974 | void PlayListWidget::skinsMenuActivated( int item ) { |
975 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 975 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
976 | skinsMenu->setItemChecked( i, FALSE ); | 976 | skinsMenu->setItemChecked( i, FALSE ); |
977 | } | 977 | } |
978 | skinsMenu->setItemChecked( item, TRUE ); | 978 | skinsMenu->setItemChecked( item, TRUE ); |
979 | 979 | ||
980 | { | 980 | { |
981 | Config cfg( "OpiePlayer" ); | 981 | Config cfg( "OpiePlayer" ); |
982 | cfg.setGroup("Options"); | 982 | cfg.setGroup("Options"); |
983 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 983 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
984 | } | 984 | } |
985 | 985 | ||
986 | emit skinSelected(); | 986 | emit skinSelected(); |
987 | } | 987 | } |
988 | 988 | ||
989 | PlayListWidget::TabType PlayListWidget::currentTab() const | 989 | PlayListWidget::TabType PlayListWidget::currentTab() const |
990 | { | 990 | { |
991 | static const TabType indexToTabType[ TabTypeCount ] = | 991 | static const TabType indexToTabType[ TabTypeCount ] = |
992 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 992 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
993 | 993 | ||
994 | int index = tabWidget->currentPageIndex(); | 994 | int index = tabWidget->currentPageIndex(); |
995 | assert( index < TabTypeCount && index >= 0 ); | 995 | assert( index < TabTypeCount && index >= 0 ); |
996 | 996 | ||
997 | return indexToTabType[ index ]; | 997 | return indexToTabType[ index ]; |
998 | } | 998 | } |
999 | 999 | ||
1000 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 1000 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
1001 | { | 1001 | { |
1002 | if ( currentTab() == CurrentPlayList ) { | 1002 | if ( currentTab() == CurrentPlayList ) { |
1003 | const DocLnk *lnk = current(); | 1003 | const DocLnk *lnk = current(); |
1004 | return Entry( lnk->name(), lnk->file() ); | 1004 | return Entry( lnk->name(), lnk->file() ); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | return Entry( currentFileListPathName() ); | 1007 | return Entry( currentFileListPathName() ); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | QString PlayListWidget::currentFileListPathName() const { | 1010 | QString PlayListWidget::currentFileListPathName() const { |
1011 | return currentFileListView->currentItem()->text( 3 ); | 1011 | return currentFileListView->currentItem()->text( 3 ); |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | 1014 | ||
1015 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1015 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1016 | QDataStream stream ( data, IO_ReadOnly ); | 1016 | QDataStream stream ( data, IO_ReadOnly ); |
1017 | if ( msg == "play()" ) { //plays current selection | 1017 | if ( msg == "play()" ) { //plays current selection |
1018 | btnPlay( true); | 1018 | btnPlay( true); |
1019 | } else if ( msg == "stop()" ) { | 1019 | } else if ( msg == "stop()" ) { |
1020 | mediaPlayerState->setPlaying( false); | 1020 | mediaPlayerState->setPlaying( false); |
1021 | } else if ( msg == "togglePause()" ) { | 1021 | } else if ( msg == "togglePause()" ) { |
1022 | mediaPlayerState->togglePaused(); | 1022 | mediaPlayerState->togglePaused(); |
1023 | } else if ( msg == "next()" ) { //select next in list | 1023 | } else if ( msg == "next()" ) { //select next in list |
1024 | mediaPlayerState->setNext(); | 1024 | mediaPlayerState->setNext(); |
1025 | } else if ( msg == "prev()" ) { //select previous in list | 1025 | } else if ( msg == "prev()" ) { //select previous in list |
1026 | mediaPlayerState->setPrev(); | 1026 | mediaPlayerState->setPrev(); |
1027 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1027 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1028 | mediaPlayerState->toggleLooping(); | 1028 | mediaPlayerState->toggleLooping(); |
1029 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1029 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1030 | mediaPlayerState->toggleShuffled(); | 1030 | mediaPlayerState->toggleShuffled(); |
1031 | } else if ( msg == "volUp()" ) { //volume more | 1031 | } else if ( msg == "volUp()" ) { //volume more |
1032 | // emit moreClicked(); | 1032 | // emit moreClicked(); |
1033 | // emit moreReleased(); | 1033 | // emit moreReleased(); |
1034 | } else if ( msg == "volDown()" ) { //volume less | 1034 | } else if ( msg == "volDown()" ) { //volume less |
1035 | // emit lessClicked(); | 1035 | // emit lessClicked(); |
1036 | // emit lessReleased(); | 1036 | // emit lessReleased(); |
1037 | } else if ( msg == "play(QString)" ) { //play this now | 1037 | } else if ( msg == "play(QString)" ) { //play this now |
1038 | QString file; | 1038 | QString file; |
1039 | stream >> file; | 1039 | stream >> file; |
1040 | setDocument( (const QString &) file); | 1040 | setDocument( (const QString &) file); |
1041 | } else if ( msg == "add(QString)" ) { //add to playlist | 1041 | } else if ( msg == "add(QString)" ) { //add to playlist |
1042 | QString file; | 1042 | QString file; |
1043 | stream >> file; | 1043 | stream >> file; |
1044 | QFileInfo fileInfo(file); | 1044 | QFileInfo fileInfo(file); |
1045 | DocLnk lnk; | 1045 | DocLnk lnk; |
1046 | lnk.setName( fileInfo.baseName() ); //sets name | 1046 | lnk.setName( fileInfo.baseName() ); //sets name |
1047 | lnk.setFile( file ); //sets file name | 1047 | lnk.setFile( file ); //sets file name |
1048 | addToSelection( lnk ); | 1048 | addToSelection( lnk ); |
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp index 81d6717..14750ac 100644 --- a/noncore/settings/language/language.cpp +++ b/noncore/settings/language/language.cpp | |||
@@ -1,156 +1,156 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "settings.h" | 21 | #include "settings.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/fontmanager.h> | 24 | #include <qpe/fontmanager.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/qpedialog.h> | 27 | #include <qpe/qpedialog.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 29 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qradiobutton.h> | 35 | #include <qradiobutton.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qslider.h> | 37 | #include <qslider.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | #include <qdatastream.h> | 40 | #include <qdatastream.h> |
41 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
42 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
43 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
44 | #include <qlistbox.h> | 44 | #include <qlistbox.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #if QT_VERSION >= 300 | 46 | #if QT_VERSION >= 300 |
47 | #include <qstylefactory.h> | 47 | #include <qstylefactory.h> |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | 51 | ||
52 | 52 | ||
53 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) | 53 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) |
54 | : LanguageSettingsBase( parent, name, TRUE, fl ) | 54 | : LanguageSettingsBase( parent, name, TRUE, fl ) |
55 | { | 55 | { |
56 | if ( FontManager::hasUnicodeFont() ) | 56 | if ( FontManager::hasUnicodeFont() ) |
57 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); | 57 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); |
58 | 58 | ||
59 | 59 | ||
60 | QString tfn = QPEApplication::qpeDir() + "/i18n/"; | 60 | QString tfn = QPEApplication::qpeDir() + "i18n/"; |
61 | QDir langDir = tfn; | 61 | QDir langDir = tfn; |
62 | QStringList list = langDir.entryList("*", QDir::Dirs ); | 62 | QStringList list = langDir.entryList("*", QDir::Dirs ); |
63 | 63 | ||
64 | QStringList::Iterator it; | 64 | QStringList::Iterator it; |
65 | 65 | ||
66 | for ( it = list.begin(); it != list.end(); ++it ) { | 66 | for ( it = list.begin(); it != list.end(); ++it ) { |
67 | QString name = (*it); | 67 | QString name = (*it); |
68 | QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); | 68 | QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); |
69 | if ( desktopFile.exists() ) { | 69 | if ( desktopFile.exists() ) { |
70 | langAvail.append(name); | 70 | langAvail.append(name); |
71 | Config conf( desktopFile.filePath(), Config::File ); | 71 | Config conf( desktopFile.filePath(), Config::File ); |
72 | QString langName = conf.readEntry( "Name" ); | 72 | QString langName = conf.readEntry( "Name" ); |
73 | QString ownName = conf.readEntryDirect( "Name[" + name + "]" ); | 73 | QString ownName = conf.readEntryDirect( "Name[" + name + "]" ); |
74 | if ( ownName.isEmpty() ) | 74 | if ( ownName.isEmpty() ) |
75 | ownName = conf.readEntryDirect( "Name" ); | 75 | ownName = conf.readEntryDirect( "Name" ); |
76 | if ( !ownName.isEmpty() && ownName != langName ) | 76 | if ( !ownName.isEmpty() && ownName != langName ) |
77 | langName = langName + " [" + ownName + "]"; | 77 | langName = langName + " [" + ownName + "]"; |
78 | languages->insertItem( langName ); | 78 | languages->insertItem( langName ); |
79 | 79 | ||
80 | } | 80 | } |
81 | } | 81 | } |
82 | if ( langAvail. find ( "en" ) == -1 ) { | 82 | if ( langAvail. find ( "en" ) == -1 ) { |
83 | langAvail. prepend ( "" ); // no tr | 83 | langAvail. prepend ( "" ); // no tr |
84 | languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 ); | 84 | languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 ); |
85 | } | 85 | } |
86 | 86 | ||
87 | dl = new QPEDialogListener(this); | 87 | dl = new QPEDialogListener(this); |
88 | reset(); | 88 | reset(); |
89 | } | 89 | } |
90 | 90 | ||
91 | LanguageSettings::~LanguageSettings() | 91 | LanguageSettings::~LanguageSettings() |
92 | {} | 92 | {} |
93 | 93 | ||
94 | void LanguageSettings::accept() | 94 | void LanguageSettings::accept() |
95 | { | 95 | { |
96 | Config c( "qpe" ); | 96 | Config c( "qpe" ); |
97 | c.setGroup( "Startup" ); | 97 | c.setGroup( "Startup" ); |
98 | if ( ( c.readNumEntry( "FirstUse", 42 ) == 0 ) && | 98 | if ( ( c.readNumEntry( "FirstUse", 42 ) == 0 ) && |
99 | ( QMessageBox::warning( this, tr("Language"), tr("<qt>Attention, all windows will be closed by changing the language\n" | 99 | ( QMessageBox::warning( this, tr("Language"), tr("<qt>Attention, all windows will be closed by changing the language\n" |
100 | "without saving the Data.<br><br>Go on?</qt>"), 1, 2) ) | 100 | "without saving the Data.<br><br>Go on?</qt>"), 1, 2) ) |
101 | == QMessageBox::Cancel ) | 101 | == QMessageBox::Cancel ) |
102 | return; | 102 | return; |
103 | applyLanguage(); | 103 | applyLanguage(); |
104 | QDialog::accept(); | 104 | QDialog::accept(); |
105 | } | 105 | } |
106 | 106 | ||
107 | void LanguageSettings::applyLanguage() | 107 | void LanguageSettings::applyLanguage() |
108 | { | 108 | { |
109 | setLanguage ( langAvail. at ( languages-> currentItem ( ))); | 109 | setLanguage ( langAvail. at ( languages-> currentItem ( ))); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void LanguageSettings::reject() | 113 | void LanguageSettings::reject() |
114 | { | 114 | { |
115 | reset(); | 115 | reset(); |
116 | QDialog::reject(); | 116 | QDialog::reject(); |
117 | } | 117 | } |
118 | 118 | ||
119 | void LanguageSettings::reset() | 119 | void LanguageSettings::reset() |
120 | { | 120 | { |
121 | QString l = getenv("LANG"); | 121 | QString l = getenv("LANG"); |
122 | Config config("locale"); | 122 | Config config("locale"); |
123 | config.setGroup("Language"); | 123 | config.setGroup("Language"); |
124 | l = config.readEntry( "Language", l ); | 124 | l = config.readEntry( "Language", l ); |
125 | actualLanguage = l; | 125 | actualLanguage = l; |
126 | if (l.isEmpty()) | 126 | if (l.isEmpty()) |
127 | l = "en"; | 127 | l = "en"; |
128 | 128 | ||
129 | int n = langAvail.find( l ); | 129 | int n = langAvail.find( l ); |
130 | languages->setCurrentItem( n ); | 130 | languages->setCurrentItem( n ); |
131 | } | 131 | } |
132 | 132 | ||
133 | QString LanguageSettings::actualLanguage; | 133 | QString LanguageSettings::actualLanguage; |
134 | 134 | ||
135 | void LanguageSettings::setLanguage(const QString& lang) | 135 | void LanguageSettings::setLanguage(const QString& lang) |
136 | { | 136 | { |
137 | if ( lang != actualLanguage ) { | 137 | if ( lang != actualLanguage ) { |
138 | Config config("locale"); | 138 | Config config("locale"); |
139 | config.setGroup( "Language" ); | 139 | config.setGroup( "Language" ); |
140 | if ( lang. isEmpty ( )) | 140 | if ( lang. isEmpty ( )) |
141 | config. removeEntry ( "Language" ); | 141 | config. removeEntry ( "Language" ); |
142 | else | 142 | else |
143 | config.writeEntry( "Language", lang ); | 143 | config.writeEntry( "Language", lang ); |
144 | config.write(); | 144 | config.write(); |
145 | 145 | ||
146 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 146 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
147 | 147 | ||
148 | QCopEnvelope e("QPE/System", "language(QString)"); | 148 | QCopEnvelope e("QPE/System", "language(QString)"); |
149 | e << lang; | 149 | e << lang; |
150 | #endif | 150 | #endif |
151 | 151 | ||
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | void LanguageSettings::done(int r) | 155 | void LanguageSettings::done(int r) |
156 | { | 156 | { |
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp index fb7d7c9..5f23aea 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | |||
@@ -195,193 +195,193 @@ void MainWindowImp::getAllInterfaces() | |||
195 | { | 195 | { |
196 | if((loc = line.find(":")) != -1) | 196 | if((loc = line.find(":")) != -1) |
197 | { | 197 | { |
198 | ifaces += line.left(loc); | 198 | ifaces += line.left(loc); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) | 203 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) |
204 | { | 204 | { |
205 | int flags = 0; | 205 | int flags = 0; |
206 | if ( m_handledIfaces.contains( (*it) ) ) | 206 | if ( m_handledIfaces.contains( (*it) ) ) |
207 | { | 207 | { |
208 | odebug << " " << (*it).latin1() << " is handled by a module" << oendl; | 208 | odebug << " " << (*it).latin1() << " is handled by a module" << oendl; |
209 | continue; | 209 | continue; |
210 | } | 210 | } |
211 | // int family; | 211 | // int family; |
212 | i = NULL; | 212 | i = NULL; |
213 | 213 | ||
214 | strcpy(ifr.ifr_name, (*it).latin1()); | 214 | strcpy(ifr.ifr_name, (*it).latin1()); |
215 | 215 | ||
216 | struct ifreq ifcopy; | 216 | struct ifreq ifcopy; |
217 | ifcopy = ifr; | 217 | ifcopy = ifr; |
218 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 218 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
219 | flags = ifcopy.ifr_flags; | 219 | flags = ifcopy.ifr_flags; |
220 | i = new Interface(this, ifr.ifr_name, false); | 220 | i = new Interface(this, ifr.ifr_name, false); |
221 | i->setAttached(true); | 221 | i->setAttached(true); |
222 | if ((flags & IFF_UP) == IFF_UP) | 222 | if ((flags & IFF_UP) == IFF_UP) |
223 | i->setStatus(true); | 223 | i->setStatus(true); |
224 | else | 224 | else |
225 | i->setStatus(false); | 225 | i->setStatus(false); |
226 | 226 | ||
227 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 227 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
228 | i->setHardwareName("Ethernet"); | 228 | i->setHardwareName("Ethernet"); |
229 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 229 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
230 | i->setHardwareName("Point to Point"); | 230 | i->setHardwareName("Point to Point"); |
231 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 231 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
232 | i->setHardwareName("Multicast"); | 232 | i->setHardwareName("Multicast"); |
233 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 233 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
234 | i->setHardwareName("Loopback"); | 234 | i->setHardwareName("Loopback"); |
235 | else | 235 | else |
236 | i->setHardwareName("Unknown"); | 236 | i->setHardwareName("Unknown"); |
237 | 237 | ||
238 | owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; | 238 | owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; |
239 | interfaceNames.insert(i->getInterfaceName(), i); | 239 | interfaceNames.insert(i->getInterfaceName(), i); |
240 | updateInterface(i); | 240 | updateInterface(i); |
241 | connect(i, SIGNAL(updateInterface(Interface*)), | 241 | connect(i, SIGNAL(updateInterface(Interface*)), |
242 | this, SLOT(updateInterface(Interface*))); | 242 | this, SLOT(updateInterface(Interface*))); |
243 | } | 243 | } |
244 | // now lets ask the plugins too ;) | 244 | // now lets ask the plugins too ;) |
245 | QMap<Module*, QLibrary*>::Iterator it; | 245 | QMap<Module*, QLibrary*>::Iterator it; |
246 | QList<Interface> ilist; | 246 | QList<Interface> ilist; |
247 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 247 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
248 | { | 248 | { |
249 | if(it.key()) | 249 | if(it.key()) |
250 | { | 250 | { |
251 | ilist = it.key()->getInterfaces(); | 251 | ilist = it.key()->getInterfaces(); |
252 | for( i = ilist.first(); i != 0; i = ilist.next() ) | 252 | for( i = ilist.first(); i != 0; i = ilist.next() ) |
253 | { | 253 | { |
254 | owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; | 254 | owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; |
255 | interfaceNames.insert(i->getInterfaceName(), i); | 255 | interfaceNames.insert(i->getInterfaceName(), i); |
256 | updateInterface(i); | 256 | updateInterface(i); |
257 | connect(i, SIGNAL(updateInterface(Interface*)), | 257 | connect(i, SIGNAL(updateInterface(Interface*)), |
258 | this, SLOT(updateInterface(Interface*))); | 258 | this, SLOT(updateInterface(Interface*))); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | /** | 264 | /** |
265 | * Load all modules that are found in the path | 265 | * Load all modules that are found in the path |
266 | * @param path a directory that is scaned for any plugins that can be loaded | 266 | * @param path a directory that is scaned for any plugins that can be loaded |
267 | * and attempts to load them | 267 | * and attempts to load them |
268 | */ | 268 | */ |
269 | void MainWindowImp::loadModules(const QString &path) | 269 | void MainWindowImp::loadModules(const QString &path) |
270 | { | 270 | { |
271 | #ifdef DEBUG | 271 | #ifdef DEBUG |
272 | odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; | 272 | odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; |
273 | #endif | 273 | #endif |
274 | QDir d(path); | 274 | QDir d(path); |
275 | if(!d.exists()) | 275 | if(!d.exists()) |
276 | return; | 276 | return; |
277 | 277 | ||
278 | QString lang = ::getenv("LANG"); | 278 | QString lang = ::getenv("LANG"); |
279 | // Don't want sym links | 279 | // Don't want sym links |
280 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 280 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
281 | const QFileInfoList *list = d.entryInfoList(); | 281 | const QFileInfoList *list = d.entryInfoList(); |
282 | QFileInfoListIterator it( *list ); | 282 | QFileInfoListIterator it( *list ); |
283 | QFileInfo *fi; | 283 | QFileInfo *fi; |
284 | while ( (fi=it.current()) ) | 284 | while ( (fi=it.current()) ) |
285 | { | 285 | { |
286 | if(fi->fileName().contains(".so")) | 286 | if(fi->fileName().contains(".so")) |
287 | { | 287 | { |
288 | /* if loaded install translation */ | 288 | /* if loaded install translation */ |
289 | if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ | 289 | if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ |
290 | QTranslator *trans = new QTranslator(qApp); | 290 | QTranslator *trans = new QTranslator(qApp); |
291 | QString fn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; | 291 | QString fn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; |
292 | if( trans->load( fn ) ) | 292 | if( trans->load( fn ) ) |
293 | qApp->installTranslator( trans ); | 293 | qApp->installTranslator( trans ); |
294 | else | 294 | else |
295 | delete trans; | 295 | delete trans; |
296 | } | 296 | } |
297 | odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; | 297 | odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; |
298 | } | 298 | } |
299 | ++it; | 299 | ++it; |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | /** | 303 | /** |
304 | * Attempt to load a function and resolve a function. | 304 | * Attempt to load a function and resolve a function. |
305 | * @param pluginFileName - the name of the file in which to attempt to load | 305 | * @param pluginFileName - the name of the file in which to attempt to load |
306 | * @param resolveString - function pointer to resolve | 306 | * @param resolveString - function pointer to resolve |
307 | * @return pointer to the function with name resolveString or NULL | 307 | * @return pointer to the function with name resolveString or NULL |
308 | */ | 308 | */ |
309 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) | 309 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) |
310 | { | 310 | { |
311 | #ifdef DEBUG | 311 | #ifdef DEBUG |
312 | odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; | 312 | odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; |
313 | #endif | 313 | #endif |
314 | QLibrary *lib = new QLibrary(pluginFileName); | 314 | QLibrary *lib = new QLibrary(pluginFileName); |
315 | void *functionPointer = lib->resolve(resolveString); | 315 | void *functionPointer = lib->resolve(resolveString); |
316 | if( !functionPointer ) | 316 | if( !functionPointer ) |
317 | { | 317 | { |
318 | #ifdef DEBUG | 318 | #ifdef DEBUG |
319 | odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; | 319 | odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; |
320 | #endif | 320 | #endif |
321 | delete lib; | 321 | delete lib; |
322 | return 0; | 322 | return 0; |
323 | } | 323 | } |
324 | // Try to get an object. | 324 | // Try to get an object. |
325 | Module *object = ((Module* (*)()) functionPointer)(); | 325 | Module *object = ((Module* (*)()) functionPointer)(); |
326 | if(object == 0) | 326 | if(object == 0) |
327 | { | 327 | { |
328 | #ifdef DEBUG | 328 | #ifdef DEBUG |
329 | odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; | 329 | odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; |
330 | #endif | 330 | #endif |
331 | delete lib; | 331 | delete lib; |
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | m_handledIfaces += object->handledInterfaceNames(); | 335 | m_handledIfaces += object->handledInterfaceNames(); |
336 | // Store for deletion later | 336 | // Store for deletion later |
337 | libraries.insert(object, lib); | 337 | libraries.insert(object, lib); |
338 | return object; | 338 | return object; |
339 | } | 339 | } |
340 | 340 | ||
341 | /** | 341 | /** |
342 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 342 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
343 | * load the plugin and append it to the list | 343 | * load the plugin and append it to the list |
344 | */ | 344 | */ |
345 | void MainWindowImp::addClicked() | 345 | void MainWindowImp::addClicked() |
346 | { | 346 | { |
347 | QMap<Module*, QLibrary*>::Iterator it; | 347 | QMap<Module*, QLibrary*>::Iterator it; |
348 | QMap<QString, QString> list; | 348 | QMap<QString, QString> list; |
349 | QMap<QString, Module*> newInterfaceOwners; | 349 | QMap<QString, Module*> newInterfaceOwners; |
350 | 350 | ||
351 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 351 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
352 | { | 352 | { |
353 | if(it.key()) | 353 | if(it.key()) |
354 | { | 354 | { |
355 | (it.key())->possibleNewInterfaces(list); | 355 | (it.key())->possibleNewInterfaces(list); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | // See if the list has anything that we can add. | 358 | // See if the list has anything that we can add. |
359 | if(list.count() == 0) | 359 | if(list.count() == 0) |
360 | { | 360 | { |
361 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 361 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 364 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
365 | addNewConnection.addConnections(list); | 365 | addNewConnection.addConnections(list); |
366 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) | 366 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) |
367 | { | 367 | { |
368 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 368 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
369 | if(!item) | 369 | if(!item) |
370 | return; | 370 | return; |
371 | 371 | ||
372 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 372 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
373 | { | 373 | { |
374 | if(it.key()) | 374 | if(it.key()) |
375 | { | 375 | { |
376 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 376 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
377 | if(i) | 377 | if(i) |
378 | { | 378 | { |
379 | odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl; | 379 | odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl; |
380 | interfaceNames.insert(i->getInterfaceName(), i); | 380 | interfaceNames.insert(i->getInterfaceName(), i); |
381 | updateInterface(i); | 381 | updateInterface(i); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 793fcb1..060185a 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -49,193 +49,193 @@ using namespace Opie::Ui; | |||
49 | #include <time.h> | 49 | #include <time.h> |
50 | #include <stdio.h> | 50 | #include <stdio.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <math.h> | 52 | #include <math.h> |
53 | #if defined (__GNUC__) && (__GNUC__ < 3) | 53 | #if defined (__GNUC__) && (__GNUC__ < 3) |
54 | #define round qRound | 54 | #define round qRound |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | extern "C" | 57 | extern "C" |
58 | { | 58 | { |
59 | void BenchFFT( void ); | 59 | void BenchFFT( void ); |
60 | double dhry_main( int ); | 60 | double dhry_main( int ); |
61 | } | 61 | } |
62 | 62 | ||
63 | #define DHRYSTONE_RUNS 20000000 | 63 | #define DHRYSTONE_RUNS 20000000 |
64 | #define TEST_DURATION 3 | 64 | #define TEST_DURATION 3 |
65 | 65 | ||
66 | //=========================================================================== | 66 | //=========================================================================== |
67 | 67 | ||
68 | class BenchmarkPaintWidget : public QWidget | 68 | class BenchmarkPaintWidget : public QWidget |
69 | { | 69 | { |
70 | public: | 70 | public: |
71 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 71 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
72 | { | 72 | { |
73 | resize( QApplication::desktop()->size() ); | 73 | resize( QApplication::desktop()->size() ); |
74 | show(); | 74 | show(); |
75 | p.begin( this ); | 75 | p.begin( this ); |
76 | }; | 76 | }; |
77 | 77 | ||
78 | ~BenchmarkPaintWidget() | 78 | ~BenchmarkPaintWidget() |
79 | { | 79 | { |
80 | p.end(); | 80 | p.end(); |
81 | hide(); | 81 | hide(); |
82 | }; | 82 | }; |
83 | 83 | ||
84 | QPainter p; | 84 | QPainter p; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | //=========================================================================== | 87 | //=========================================================================== |
88 | 88 | ||
89 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 89 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
90 | : QWidget( parent, name, wFlags ) | 90 | : QWidget( parent, name, wFlags ) |
91 | { | 91 | { |
92 | 92 | ||
93 | setMinimumSize( 200, 150 ); | 93 | setMinimumSize( 200, 150 ); |
94 | 94 | ||
95 | QVBoxLayout* vb = new QVBoxLayout( this ); | 95 | QVBoxLayout* vb = new QVBoxLayout( this ); |
96 | vb->setSpacing( 4 ); | 96 | vb->setSpacing( 4 ); |
97 | vb->setMargin( 4 ); | 97 | vb->setMargin( 4 ); |
98 | 98 | ||
99 | tests = new OListView( this ); | 99 | tests = new OListView( this ); |
100 | QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests " | 100 | QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests " |
101 | "have been performed, and comparison values for one selected device. " | 101 | "have been performed, and comparison values for one selected device. " |
102 | "Use the checkboxes to define which tests you want to perform." ) ); | 102 | "Use the checkboxes to define which tests you want to perform." ) ); |
103 | tests->setMargin( 0 ); | 103 | tests->setMargin( 0 ); |
104 | tests->addColumn( tr( "Tests" ) ); | 104 | tests->addColumn( tr( "Tests" ) ); |
105 | tests->addColumn( tr( "Results" ) ); | 105 | tests->addColumn( tr( "Results" ) ); |
106 | tests->addColumn( tr( "Comparison" ) ); | 106 | tests->addColumn( tr( "Comparison" ) ); |
107 | tests->setShowSortIndicator( true ); | 107 | tests->setShowSortIndicator( true ); |
108 | 108 | ||
109 | test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox ); | 109 | test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox ); |
110 | test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox ); | 110 | test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox ); |
111 | test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox ); | 111 | test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox ); |
112 | test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox ); | 112 | test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox ); |
113 | test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox ); | 113 | test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox ); |
114 | #ifndef QT_QWS_RAMSES | 114 | #ifndef QT_QWS_RAMSES |
115 | test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox ); | 115 | test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox ); |
116 | test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox ); | 116 | test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox ); |
117 | #endif | 117 | #endif |
118 | test_alu->setText( 1, "n/a" ); | 118 | test_alu->setText( 1, "n/a" ); |
119 | test_fpu->setText( 1, "n/a" ); | 119 | test_fpu->setText( 1, "n/a" ); |
120 | test_txt->setText( 1, "n/a" ); | 120 | test_txt->setText( 1, "n/a" ); |
121 | test_gfx->setText( 1, "n/a" ); | 121 | test_gfx->setText( 1, "n/a" ); |
122 | test_ram->setText( 1, "n/a" ); | 122 | test_ram->setText( 1, "n/a" ); |
123 | #ifndef QT_QWS_RAMSES | 123 | #ifndef QT_QWS_RAMSES |
124 | test_sd->setText( 1, "n/a" ); | 124 | test_sd->setText( 1, "n/a" ); |
125 | test_cf->setText( 1, "n/a" ); | 125 | test_cf->setText( 1, "n/a" ); |
126 | #endif | 126 | #endif |
127 | test_alu->setText( 2, "n/a" ); | 127 | test_alu->setText( 2, "n/a" ); |
128 | test_fpu->setText( 2, "n/a" ); | 128 | test_fpu->setText( 2, "n/a" ); |
129 | test_txt->setText( 2, "n/a" ); | 129 | test_txt->setText( 2, "n/a" ); |
130 | test_gfx->setText( 2, "n/a" ); | 130 | test_gfx->setText( 2, "n/a" ); |
131 | test_ram->setText( 2, "n/a" ); | 131 | test_ram->setText( 2, "n/a" ); |
132 | #ifndef QT_QWS_RAMSES | 132 | #ifndef QT_QWS_RAMSES |
133 | test_sd->setText( 2, "n/a" ); | 133 | test_sd->setText( 2, "n/a" ); |
134 | test_cf->setText( 2, "n/a" ); | 134 | test_cf->setText( 2, "n/a" ); |
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 137 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
138 | QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); | 138 | QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); |
139 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 139 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
140 | vb->addWidget( tests, 2 ); | 140 | vb->addWidget( tests, 2 ); |
141 | 141 | ||
142 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 142 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
143 | hb->addWidget( startButton, 2 ); | 143 | hb->addWidget( startButton, 2 ); |
144 | 144 | ||
145 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 145 | QFile f( QPEApplication::qpeDir() + "share/sysinfo/results" ); |
146 | if ( f.open( IO_ReadOnly ) ) | 146 | if ( f.open( IO_ReadOnly ) ) |
147 | { | 147 | { |
148 | machineCombo = new QComboBox( this ); | 148 | machineCombo = new QComboBox( this ); |
149 | QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); | 149 | QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); |
150 | 150 | ||
151 | QTextStream ts( &f ); | 151 | QTextStream ts( &f ); |
152 | while( !ts.eof() ) | 152 | while( !ts.eof() ) |
153 | { | 153 | { |
154 | QString machline = ts.readLine(); | 154 | QString machline = ts.readLine(); |
155 | odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; | 155 | odebug << "sysinfo: parsing benchmark results for '" << machline << "'" << oendl; |
156 | QString resline = ts.readLine(); | 156 | QString resline = ts.readLine(); |
157 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 157 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
158 | machineCombo->insertItem( machline ); | 158 | machineCombo->insertItem( machline ); |
159 | } | 159 | } |
160 | 160 | ||
161 | hb->addWidget( new QLabel( tr( "Compare:" ), this ) ); | 161 | hb->addWidget( new QLabel( tr( "Compare:" ), this ) ); |
162 | hb->addWidget( machineCombo, 2 ); | 162 | hb->addWidget( machineCombo, 2 ); |
163 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); | 163 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | BenchmarkInfo::~BenchmarkInfo() | 168 | BenchmarkInfo::~BenchmarkInfo() |
169 | {} | 169 | {} |
170 | 170 | ||
171 | 171 | ||
172 | void BenchmarkInfo::machineActivated( int index ) | 172 | void BenchmarkInfo::machineActivated( int index ) |
173 | { | 173 | { |
174 | QStringList* results = machines[ machineCombo->text( index ) ]; | 174 | QStringList* results = machines[ machineCombo->text( index ) ]; |
175 | if ( !results ) | 175 | if ( !results ) |
176 | { | 176 | { |
177 | odebug << "sysinfo: no results available." << oendl; | 177 | odebug << "sysinfo: no results available." << oendl; |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | QStringList::Iterator it = results->begin(); | 180 | QStringList::Iterator it = results->begin(); |
181 | test_alu->setText( 2, *(it++) ); | 181 | test_alu->setText( 2, *(it++) ); |
182 | test_fpu->setText( 2, *(it++) ); | 182 | test_fpu->setText( 2, *(it++) ); |
183 | test_txt->setText( 2, *(it++) ); | 183 | test_txt->setText( 2, *(it++) ); |
184 | test_gfx->setText( 2, *(it++) ); | 184 | test_gfx->setText( 2, *(it++) ); |
185 | test_ram->setText( 2, *(it++) ); | 185 | test_ram->setText( 2, *(it++) ); |
186 | #ifndef QT_QWS_RAMSES | 186 | #ifndef QT_QWS_RAMSES |
187 | test_sd->setText( 2, *(it++) ); | 187 | test_sd->setText( 2, *(it++) ); |
188 | test_cf->setText( 2, *(it++) ); | 188 | test_cf->setText( 2, *(it++) ); |
189 | #endif | 189 | #endif |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | void BenchmarkInfo::run() | 193 | void BenchmarkInfo::run() |
194 | { | 194 | { |
195 | startButton->setText( "> Don't touch! <" ); | 195 | startButton->setText( "> Don't touch! <" ); |
196 | qApp->processEvents(); | 196 | qApp->processEvents(); |
197 | QTime t; | 197 | QTime t; |
198 | 198 | ||
199 | if ( test_alu->isOn() ) | 199 | if ( test_alu->isOn() ) |
200 | { | 200 | { |
201 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 201 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
202 | test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) ); | 202 | test_alu->setText( 1, QString().sprintf( "%d dhrys", d ) ); |
203 | test_alu->setOn( false ); | 203 | test_alu->setOn( false ); |
204 | } | 204 | } |
205 | 205 | ||
206 | if ( test_fpu->isOn() ) | 206 | if ( test_fpu->isOn() ) |
207 | { | 207 | { |
208 | t.start(); | 208 | t.start(); |
209 | BenchFFT(); | 209 | BenchFFT(); |
210 | test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );; | 210 | test_fpu->setText( 1, QString().sprintf( "%.2f secs", t.elapsed() / 1000.0 ) );; |
211 | test_fpu->setOn( false ); | 211 | test_fpu->setOn( false ); |
212 | } | 212 | } |
213 | 213 | ||
214 | if ( test_txt->isOn() ) | 214 | if ( test_txt->isOn() ) |
215 | { | 215 | { |
216 | int value = textRendering( TEST_DURATION ); | 216 | int value = textRendering( TEST_DURATION ); |
217 | test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) ); | 217 | test_txt->setText( 1, QString().sprintf( "%d chars/sec", value / TEST_DURATION ) ); |
218 | test_txt->setOn( false ); | 218 | test_txt->setOn( false ); |
219 | } | 219 | } |
220 | 220 | ||
221 | if ( test_gfx->isOn() ) | 221 | if ( test_gfx->isOn() ) |
222 | { | 222 | { |
223 | int value = gfxRendering( TEST_DURATION ); | 223 | int value = gfxRendering( TEST_DURATION ); |
224 | test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests | 224 | test_gfx->setText( 1, QString().sprintf( "%.2f gops/sec", value / 4.0 / TEST_DURATION ) ); // 4 tests |
225 | test_gfx->setOn( false ); | 225 | test_gfx->setOn( false ); |
226 | } | 226 | } |
227 | 227 | ||
228 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 228 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
229 | { | 229 | { |
230 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 230 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
231 | } | 231 | } |
232 | 232 | ||
233 | #ifndef QT_QWS_RAMSES | 233 | #ifndef QT_QWS_RAMSES |
234 | if ( test_cf->isOn() ) | 234 | if ( test_cf->isOn() ) |
235 | { | 235 | { |
236 | OStorageInfo storage; | 236 | OStorageInfo storage; |
237 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 237 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
238 | } | 238 | } |
239 | 239 | ||
240 | if ( test_sd->isOn() ) | 240 | if ( test_sd->isOn() ) |
241 | { | 241 | { |
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp index 3eae424..85e5814 100644 --- a/noncore/settings/tabmanager/tabmanager.cpp +++ b/noncore/settings/tabmanager/tabmanager.cpp | |||
@@ -1,120 +1,120 @@ | |||
1 | #include "tabmanager.h" | 1 | #include "tabmanager.h" |
2 | #include "app.h" | 2 | #include "app.h" |
3 | #include "wait.h" | 3 | #include "wait.h" |
4 | #include "tabapplnk.h" | 4 | #include "tabapplnk.h" |
5 | 5 | ||
6 | #include <opie2/odebug.h> | 6 | #include <opie2/odebug.h> |
7 | 7 | ||
8 | #include <qpe/applnk.h> | 8 | #include <qpe/applnk.h> |
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qfile.h> | 10 | #include <qfile.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qlistview.h> | 12 | #include <qlistview.h> |
13 | #include <qheader.h> | 13 | #include <qheader.h> |
14 | #include <qcombobox.h> | 14 | #include <qcombobox.h> |
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qlabel.h> | 16 | #include <qlabel.h> |
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | #include <stdlib.h> | 18 | #include <stdlib.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | 22 | ||
23 | 23 | ||
24 | #define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" | 24 | #define HOME_APP_DIR QPEApplication::qpeDir()+"apps" |
25 | #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" | 25 | #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" |
26 | #define NEW_FOLDER "EmptyTab" | 26 | #define NEW_FOLDER "EmptyTab" |
27 | #define NEW_APPLICATION "NewApp" | 27 | #define NEW_APPLICATION "NewApp" |
28 | #define APPLICATION_EXTENSION ".desktop" | 28 | #define APPLICATION_EXTENSION ".desktop" |
29 | #define APPLICATION_EXTENSION_LENGTH 8 | 29 | #define APPLICATION_EXTENSION_LENGTH 8 |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Constructor. Sets up signals. Performs initial scan of applications | 32 | * Constructor. Sets up signals. Performs initial scan of applications |
33 | * and tabs | 33 | * and tabs |
34 | */ | 34 | */ |
35 | TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ | 35 | TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ |
36 | rescanFolder(HOME_APP_DIR); | 36 | rescanFolder(HOME_APP_DIR); |
37 | 37 | ||
38 | // Connect the signals and slots | 38 | // Connect the signals and slots |
39 | connect(tabList, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editItem(QListViewItem*))); | 39 | connect(tabList, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editItem(QListViewItem*))); |
40 | (tabList->header())->hide(); | 40 | (tabList->header())->hide(); |
41 | connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*))); | 41 | connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*))); |
42 | } | 42 | } |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * If anything in the tab's have been changed then update the system or alert | 45 | * If anything in the tab's have been changed then update the system or alert |
46 | * the user. | 46 | * the user. |
47 | */ | 47 | */ |
48 | TabManager::~TabManager(){ | 48 | TabManager::~TabManager(){ |
49 | if(changed){ | 49 | if(changed){ |
50 | // Prompt. | 50 | // Prompt. |
51 | //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); | 51 | //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); |
52 | //if (answer) | 52 | //if (answer) |
53 | // return; | 53 | // return; |
54 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 54 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
55 | QString link; //we'll just send an empty string | 55 | QString link; //we'll just send an empty string |
56 | e << link; | 56 | e << link; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Scans root directory for any tabs or applications. Will recursivly go down, | 61 | * Scans root directory for any tabs or applications. Will recursivly go down, |
62 | * but will not follow symlinks. | 62 | * but will not follow symlinks. |
63 | * @param directory - the directory to look in. | 63 | * @param directory - the directory to look in. |
64 | * @param parent - the parent to place any new tabs or apps into. If parent is | 64 | * @param parent - the parent to place any new tabs or apps into. If parent is |
65 | * NULL then the item is a tab and should be placed as a child of the window. | 65 | * NULL then the item is a tab and should be placed as a child of the window. |
66 | */ | 66 | */ |
67 | void TabManager::rescanFolder(QString directory, QListViewItem* parent){ | 67 | void TabManager::rescanFolder(QString directory, QListViewItem* parent){ |
68 | //odebug << QString("rescanFolder: ") + directory.latin1() << oendl; | 68 | //odebug << QString("rescanFolder: ") + directory.latin1() << oendl; |
69 | 69 | ||
70 | QDir d; | 70 | QDir d; |
71 | d.setPath(directory); | 71 | d.setPath(directory); |
72 | // Show hidden files for .directories | 72 | // Show hidden files for .directories |
73 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); | 73 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); |
74 | 74 | ||
75 | const QFileInfoList *list = d.entryInfoList(); | 75 | const QFileInfoList *list = d.entryInfoList(); |
76 | QFileInfoListIterator it( *list ); // create list iterator | 76 | QFileInfoListIterator it( *list ); // create list iterator |
77 | QFileInfo *fi; // pointer for traversing | 77 | QFileInfo *fi; // pointer for traversing |
78 | 78 | ||
79 | while ( (fi=it.current()) ) { // for each file... | 79 | while ( (fi=it.current()) ) { // for each file... |
80 | // If it is a dir and not .. or . then add it as a tab and go down. | 80 | // If it is a dir and not .. or . then add it as a tab and go down. |
81 | if(fi->isDir()){ | 81 | if(fi->isDir()){ |
82 | if(fi->fileName() != ".." && fi->fileName() != ".") { | 82 | if(fi->fileName() != ".." && fi->fileName() != ".") { |
83 | QListViewItem* newItem; | 83 | QListViewItem* newItem; |
84 | if(!parent) | 84 | if(!parent) |
85 | newItem = new QListViewItem(tabList, fi->fileName()); | 85 | newItem = new QListViewItem(tabList, fi->fileName()); |
86 | else | 86 | else |
87 | newItem = new QListViewItem(parent, fi->fileName()); | 87 | newItem = new QListViewItem(parent, fi->fileName()); |
88 | itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); | 88 | itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); |
89 | rescanFolder(directory + "/" + fi->fileName(), newItem); | 89 | rescanFolder(directory + "/" + fi->fileName(), newItem); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | else{ | 92 | else{ |
93 | // it is a file, if not a .directory add to parent. | 93 | // it is a file, if not a .directory add to parent. |
94 | 94 | ||
95 | // Change parents name and icon to reflect icon. | 95 | // Change parents name and icon to reflect icon. |
96 | if(fi->fileName() == ".directory"){ | 96 | if(fi->fileName() == ".directory"){ |
97 | AppLnk app(directory + "/" + fi->fileName()); | 97 | AppLnk app(directory + "/" + fi->fileName()); |
98 | if(parent){ | 98 | if(parent){ |
99 | parent->setPixmap(0,app.pixmap()); | 99 | parent->setPixmap(0,app.pixmap()); |
100 | parent->setText(0, app.name()); | 100 | parent->setText(0, app.name()); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | else{ | 103 | else{ |
104 | // Add any desktop files found. | 104 | // Add any desktop files found. |
105 | QListViewItem* newItem; | 105 | QListViewItem* newItem; |
106 | if(directory != HOME_APP_DIR){ | 106 | if(directory != HOME_APP_DIR){ |
107 | if(!parent) | 107 | if(!parent) |
108 | newItem = new QListViewItem(tabList, fi->fileName()); | 108 | newItem = new QListViewItem(tabList, fi->fileName()); |
109 | else | 109 | else |
110 | newItem = new QListViewItem(parent, fi->fileName()); | 110 | newItem = new QListViewItem(parent, fi->fileName()); |
111 | if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ | 111 | if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ |
112 | AppLnk app(directory + "/" + fi->fileName()); | 112 | AppLnk app(directory + "/" + fi->fileName()); |
113 | newItem->setPixmap(0,app.pixmap()); | 113 | newItem->setPixmap(0,app.pixmap()); |
114 | newItem->setText(0, app.name()); | 114 | newItem->setText(0, app.name()); |
115 | itemList.insert(newItem, directory + "/" + fi->fileName()); | 115 | itemList.insert(newItem, directory + "/" + fi->fileName()); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | ++it; // goto next list element | 120 | ++it; // goto next list element |
@@ -165,193 +165,193 @@ void TabManager::newApplication(){ | |||
165 | itemList.insert(newItem, homeLocation ); | 165 | itemList.insert(newItem, homeLocation ); |
166 | 166 | ||
167 | // We have changed something. | 167 | // We have changed something. |
168 | changed = true; | 168 | changed = true; |
169 | } | 169 | } |
170 | 170 | ||
171 | /** | 171 | /** |
172 | * Remove the item. | 172 | * Remove the item. |
173 | * Check if we can | 173 | * Check if we can |
174 | * Prompt user | 174 | * Prompt user |
175 | * Delete physical file (Dir, remove .dir, then dir. File, remove file) | 175 | * Delete physical file (Dir, remove .dir, then dir. File, remove file) |
176 | * Remove from installer if need too. | 176 | * Remove from installer if need too. |
177 | */ | 177 | */ |
178 | void TabManager::removeItem(){ | 178 | void TabManager::removeItem(){ |
179 | // Make sure we can delete | 179 | // Make sure we can delete |
180 | QListViewItem *item = tabList->currentItem(); | 180 | QListViewItem *item = tabList->currentItem(); |
181 | if(!item) | 181 | if(!item) |
182 | return; | 182 | return; |
183 | if(item->childCount() > 0){ | 183 | if(item->childCount() > 0){ |
184 | QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") ); | 184 | QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") ); |
185 | return; | 185 | return; |
186 | } | 186 | } |
187 | 187 | ||
188 | // Prompt. | 188 | // Prompt. |
189 | int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 ); | 189 | int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 ); |
190 | if (answer) | 190 | if (answer) |
191 | return; | 191 | return; |
192 | 192 | ||
193 | bool removeSuccessful = true; | 193 | bool removeSuccessful = true; |
194 | QString location = itemList[item]; | 194 | QString location = itemList[item]; |
195 | // Remove file (.directory in a Directory case) | 195 | // Remove file (.directory in a Directory case) |
196 | if(!QFile::remove(location)) | 196 | if(!QFile::remove(location)) |
197 | removeSuccessful = false; | 197 | removeSuccessful = false; |
198 | 198 | ||
199 | // Remove directory | 199 | // Remove directory |
200 | if(item->parent() == NULL){ | 200 | if(item->parent() == NULL){ |
201 | // Remove .directory file string | 201 | // Remove .directory file string |
202 | location = location.mid(0,location.length()-10); | 202 | location = location.mid(0,location.length()-10); |
203 | QDir dir; | 203 | QDir dir; |
204 | if(!dir.rmdir(location)) | 204 | if(!dir.rmdir(location)) |
205 | removeSuccessful = false; | 205 | removeSuccessful = false; |
206 | else | 206 | else |
207 | removeSuccessful = true; | 207 | removeSuccessful = true; |
208 | } | 208 | } |
209 | 209 | ||
210 | // If removing failed. | 210 | // If removing failed. |
211 | if(!removeSuccessful){ | 211 | if(!removeSuccessful){ |
212 | odebug << (QString("removeItem: ") + location).latin1() << oendl; | 212 | odebug << (QString("removeItem: ") + location).latin1() << oendl; |
213 | QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); | 213 | QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); |
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | 216 | ||
217 | // Remove from the installer so it wont fail. | 217 | // Remove from the installer so it wont fail. |
218 | // Don't need to do this sense the current install uses rm -f so no error | 218 | // Don't need to do this sense the current install uses rm -f so no error |
219 | 219 | ||
220 | // Remove from the gui list. | 220 | // Remove from the gui list. |
221 | itemList.remove(item); | 221 | itemList.remove(item); |
222 | if(item->parent()) | 222 | if(item->parent()) |
223 | item->parent()->takeItem(item); | 223 | item->parent()->takeItem(item); |
224 | delete item; | 224 | delete item; |
225 | 225 | ||
226 | // We have changed something. | 226 | // We have changed something. |
227 | changed = true; | 227 | changed = true; |
228 | } | 228 | } |
229 | 229 | ||
230 | /** | 230 | /** |
231 | * Helper function. Edits the current item. | 231 | * Helper function. Edits the current item. |
232 | * calls editItem with the currently selected item. | 232 | * calls editItem with the currently selected item. |
233 | */ | 233 | */ |
234 | void TabManager::editCurrentItem(){ | 234 | void TabManager::editCurrentItem(){ |
235 | editItem(tabList->currentItem()); | 235 | editItem(tabList->currentItem()); |
236 | } | 236 | } |
237 | 237 | ||
238 | /** | 238 | /** |
239 | * Edit the item that is passed in. | 239 | * Edit the item that is passed in. |
240 | * Show application dialog and if anything changed | 240 | * Show application dialog and if anything changed |
241 | * @param item the item to edit. | 241 | * @param item the item to edit. |
242 | */ | 242 | */ |
243 | void TabManager::editItem( QListViewItem * item){ | 243 | void TabManager::editItem( QListViewItem * item){ |
244 | if(!item) | 244 | if(!item) |
245 | return; | 245 | return; |
246 | 246 | ||
247 | TabAppLnk app(itemList[item]); | 247 | TabAppLnk app(itemList[item]); |
248 | if(!app.isValid()){ | 248 | if(!app.isValid()){ |
249 | odebug << QString("editItem: Not a valid applnk file: ") + itemList[item].latin1() << oendl; | 249 | odebug << QString("editItem: Not a valid applnk file: ") + itemList[item].latin1() << oendl; |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | 252 | ||
253 | // Fill with all of the icons | 253 | // Fill with all of the icons |
254 | if(!application){ | 254 | if(!application){ |
255 | Wait waitDialog(this, "Wait dialog"); | 255 | Wait waitDialog(this, "Wait dialog"); |
256 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 256 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
257 | waitDialog.show(); | 257 | waitDialog.show(); |
258 | qApp->processEvents(); | 258 | qApp->processEvents(); |
259 | application = new AppEdit(this, "Application edit", true); | 259 | application = new AppEdit(this, "Application edit", true); |
260 | 260 | ||
261 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 261 | QDir d(QPEApplication::qpeDir() + "pics/"); |
262 | d.setFilter( QDir::Files); | 262 | d.setFilter( QDir::Files); |
263 | 263 | ||
264 | const QFileInfoList *list = d.entryInfoList(); | 264 | const QFileInfoList *list = d.entryInfoList(); |
265 | QFileInfoListIterator it( *list ); // create list iterator | 265 | QFileInfoListIterator it( *list ); // create list iterator |
266 | QFileInfo *fi; // pointer for traversing | 266 | QFileInfo *fi; // pointer for traversing |
267 | 267 | ||
268 | while ( (fi=it.current()) ) { // for each file... | 268 | while ( (fi=it.current()) ) { // for each file... |
269 | QString fileName = fi->fileName(); | 269 | QString fileName = fi->fileName(); |
270 | if(fileName.right(4) == ".png"){ | 270 | if(fileName.right(4) == ".png"){ |
271 | fileName = fileName.mid(0,fileName.length()-4); | 271 | fileName = fileName.mid(0,fileName.length()-4); |
272 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 272 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
273 | QImage foo = imageOfFile.convertToImage(); | 273 | QImage foo = imageOfFile.convertToImage(); |
274 | foo = foo.smoothScale(16,16); | 274 | foo = foo.smoothScale(16,16); |
275 | imageOfFile.convertFromImage(foo); | 275 | imageOfFile.convertFromImage(foo); |
276 | application->iconLineEdit->insertItem(imageOfFile,fileName); | 276 | application->iconLineEdit->insertItem(imageOfFile,fileName); |
277 | } | 277 | } |
278 | //odebug << fi->fileName().latin1() << oendl; | 278 | //odebug << fi->fileName().latin1() << oendl; |
279 | ++it; | 279 | ++it; |
280 | } | 280 | } |
281 | waitDialog.hide(); | 281 | waitDialog.hide(); |
282 | } | 282 | } |
283 | int pixmap = -1; | 283 | int pixmap = -1; |
284 | QString pixmapText = app.pixmapString(); | 284 | QString pixmapText = app.pixmapString(); |
285 | QComboBox *f = application->iconLineEdit; | 285 | QComboBox *f = application->iconLineEdit; |
286 | for(int i = 0; i < application->iconLineEdit->count(); i++){ | 286 | for(int i = 0; i < application->iconLineEdit->count(); i++){ |
287 | if(f->text(i) == pixmapText){ | 287 | if(f->text(i) == pixmapText){ |
288 | pixmap = i; | 288 | pixmap = i; |
289 | break; | 289 | break; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | if(pixmap != -1) | 292 | if(pixmap != -1) |
293 | application->iconLineEdit->setCurrentItem(pixmap); | 293 | application->iconLineEdit->setCurrentItem(pixmap); |
294 | else if(pixmapText.isEmpty()){ | 294 | else if(pixmapText.isEmpty()){ |
295 | application->iconLineEdit->setCurrentItem(0); | 295 | application->iconLineEdit->setCurrentItem(0); |
296 | } | 296 | } |
297 | else{ | 297 | else{ |
298 | QPixmap imageOfFile(Resource::loadPixmap(pixmapText)); | 298 | QPixmap imageOfFile(Resource::loadPixmap(pixmapText)); |
299 | QImage foo = imageOfFile.convertToImage(); | 299 | QImage foo = imageOfFile.convertToImage(); |
300 | foo = foo.smoothScale(16,16); | 300 | foo = foo.smoothScale(16,16); |
301 | imageOfFile.convertFromImage(foo); | 301 | imageOfFile.convertFromImage(foo); |
302 | application->iconLineEdit->insertItem(imageOfFile,pixmapText,0); | 302 | application->iconLineEdit->insertItem(imageOfFile,pixmapText,0); |
303 | application->iconLineEdit->setCurrentItem(0); | 303 | application->iconLineEdit->setCurrentItem(0); |
304 | } | 304 | } |
305 | 305 | ||
306 | application->nameLineEdit->setText(app.name()); | 306 | application->nameLineEdit->setText(app.name()); |
307 | application->execLineEdit->setText(app.exec()); | 307 | application->execLineEdit->setText(app.exec()); |
308 | application->commentLineEdit->setText(app.comment()); | 308 | application->commentLineEdit->setText(app.comment()); |
309 | 309 | ||
310 | if(item->parent() == NULL){ | 310 | if(item->parent() == NULL){ |
311 | application->execLineEdit->setEnabled(false); | 311 | application->execLineEdit->setEnabled(false); |
312 | application->TextLabel3->setEnabled(false); | 312 | application->TextLabel3->setEnabled(false); |
313 | application->setCaption(tr("Tab")); | 313 | application->setCaption(tr("Tab")); |
314 | } | 314 | } |
315 | else{ | 315 | else{ |
316 | application->execLineEdit->setEnabled(true); | 316 | application->execLineEdit->setEnabled(true); |
317 | application->TextLabel3->setEnabled(true); | 317 | application->TextLabel3->setEnabled(true); |
318 | application->setCaption(tr("Application")); | 318 | application->setCaption(tr("Application")); |
319 | } | 319 | } |
320 | 320 | ||
321 | // Only do somthing if they hit OK | 321 | // Only do somthing if they hit OK |
322 | application->showMaximized(); | 322 | application->showMaximized(); |
323 | if(application->exec() == 0) | 323 | if(application->exec() == 0) |
324 | return; | 324 | return; |
325 | 325 | ||
326 | // If nothing has changed exit (hmmm why did they hit ok?) | 326 | // If nothing has changed exit (hmmm why did they hit ok?) |
327 | if(app.name() == application->nameLineEdit->text() && | 327 | if(app.name() == application->nameLineEdit->text() && |
328 | app.pixmapString() == application->iconLineEdit->currentText() && | 328 | app.pixmapString() == application->iconLineEdit->currentText() && |
329 | app.comment() == application->commentLineEdit->text() && | 329 | app.comment() == application->commentLineEdit->text() && |
330 | app.exec() == application->execLineEdit->text()) | 330 | app.exec() == application->execLineEdit->text()) |
331 | return; | 331 | return; |
332 | 332 | ||
333 | // Change the applnk file | 333 | // Change the applnk file |
334 | QString oldName = app.name(); | 334 | QString oldName = app.name(); |
335 | app.setName(application->nameLineEdit->text()); | 335 | app.setName(application->nameLineEdit->text()); |
336 | app.setIcon(application->iconLineEdit->currentText()); | 336 | app.setIcon(application->iconLineEdit->currentText()); |
337 | app.setComment(application->commentLineEdit->text()); | 337 | app.setComment(application->commentLineEdit->text()); |
338 | app.setExec(application->execLineEdit->text()); | 338 | app.setExec(application->execLineEdit->text()); |
339 | if(!app.writeLink()){ | 339 | if(!app.writeLink()){ |
340 | QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") ); | 340 | QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") ); |
341 | return; | 341 | return; |
342 | } | 342 | } |
343 | 343 | ||
344 | // Update the gui icon and name | 344 | // Update the gui icon and name |
345 | item->setText(0,app.name()); | 345 | item->setText(0,app.name()); |
346 | item->setPixmap(0,app.pixmap()); | 346 | item->setPixmap(0,app.pixmap()); |
347 | 347 | ||
348 | // We have changed something. | 348 | // We have changed something. |
349 | changed = true; | 349 | changed = true; |
350 | 350 | ||
351 | // If we were dealing with a new folder or new application change | 351 | // If we were dealing with a new folder or new application change |
352 | // the file names. Also change the item location in itemList | 352 | // the file names. Also change the item location in itemList |
353 | if(oldName == NEW_FOLDER){ | 353 | if(oldName == NEW_FOLDER){ |
354 | QDir r; | 354 | QDir r; |
355 | QString oldName = itemList[item]; | 355 | QString oldName = itemList[item]; |
356 | oldName = oldName.mid(0,oldName.length()-11); | 356 | oldName = oldName.mid(0,oldName.length()-11); |
357 | QString newName = oldName.mid(0,oldName.length()-9); | 357 | QString newName = oldName.mid(0,oldName.length()-9); |
diff --git a/noncore/styles/theme/othemebase.cpp b/noncore/styles/theme/othemebase.cpp index d2226e6..4275dd6 100644 --- a/noncore/styles/theme/othemebase.cpp +++ b/noncore/styles/theme/othemebase.cpp | |||
@@ -213,193 +213,193 @@ void OThemeBase::copyWidgetConfig( int sourceID, int destID, QString *pixnames, | |||
213 | pixmaps[ destID ] = NULL; | 213 | pixmaps[ destID ] = NULL; |
214 | images[ destID ] = NULL; | 214 | images[ destID ] = NULL; |
215 | if ( !pixnames[ destID ].isEmpty() ) { | 215 | if ( !pixnames[ destID ].isEmpty() ) { |
216 | if ( scaleHints[ sourceID ] == TileScale && blends[ sourceID ] == 0.0 ) { | 216 | if ( scaleHints[ sourceID ] == TileScale && blends[ sourceID ] == 0.0 ) { |
217 | pixmaps[ destID ] = pixmaps[ sourceID ]; | 217 | pixmaps[ destID ] = pixmaps[ sourceID ]; |
218 | duplicate[ destID ] = true; | 218 | duplicate[ destID ] = true; |
219 | } | 219 | } |
220 | if ( !duplicate[ destID ] ) { | 220 | if ( !duplicate[ destID ] ) { |
221 | pixmaps[ destID ] = loadPixmap( pixnames[ destID ] ); | 221 | pixmaps[ destID ] = loadPixmap( pixnames[ destID ] ); |
222 | if ( scaleHints[ destID ] == TileScale && blends[ destID ] == 0.0 ) | 222 | if ( scaleHints[ destID ] == TileScale && blends[ destID ] == 0.0 ) |
223 | images[ destID ] = NULL; | 223 | images[ destID ] = NULL; |
224 | else | 224 | else |
225 | images[ destID ] = loadImage( pixnames[ destID ] ); | 225 | images[ destID ] = loadImage( pixnames[ destID ] ); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | // border pixmap | 229 | // border pixmap |
230 | pbDuplicate[ destID ] = false; | 230 | pbDuplicate[ destID ] = false; |
231 | pbPixmaps[ destID ] = NULL; | 231 | pbPixmaps[ destID ] = NULL; |
232 | pbWidth[ destID ] = pbWidth[ sourceID ]; | 232 | pbWidth[ destID ] = pbWidth[ sourceID ]; |
233 | brdnames[ destID ] = brdnames[ sourceID ]; | 233 | brdnames[ destID ] = brdnames[ sourceID ]; |
234 | if ( !brdnames[ destID ].isEmpty() ) { | 234 | if ( !brdnames[ destID ].isEmpty() ) { |
235 | pbPixmaps[ destID ] = pbPixmaps[ sourceID ]; | 235 | pbPixmaps[ destID ] = pbPixmaps[ sourceID ]; |
236 | pbDuplicate[ destID ] = true; | 236 | pbDuplicate[ destID ] = true; |
237 | } | 237 | } |
238 | 238 | ||
239 | if ( sourceID == ActiveTab && destID == InactiveTab ) | 239 | if ( sourceID == ActiveTab && destID == InactiveTab ) |
240 | aTabLine = iTabLine; | 240 | aTabLine = iTabLine; |
241 | else if ( sourceID == InactiveTab && destID == ActiveTab ) | 241 | else if ( sourceID == InactiveTab && destID == ActiveTab ) |
242 | iTabLine = aTabLine; | 242 | iTabLine = aTabLine; |
243 | } | 243 | } |
244 | 244 | ||
245 | void OThemeBase::readConfig( Qt::GUIStyle /*style*/ ) | 245 | void OThemeBase::readConfig( Qt::GUIStyle /*style*/ ) |
246 | { | 246 | { |
247 | #define PREBLEND_ITEMS 12 | 247 | #define PREBLEND_ITEMS 12 |
248 | static WidgetType preBlend[] = {Slider, IndicatorOn, IndicatorOff, | 248 | static WidgetType preBlend[] = {Slider, IndicatorOn, IndicatorOff, |
249 | ExIndicatorOn, ExIndicatorOff, HScrollDeco, VScrollDeco, HScrollDecoDown, | 249 | ExIndicatorOn, ExIndicatorOff, HScrollDeco, VScrollDeco, HScrollDecoDown, |
250 | VScrollDecoDown, ComboDeco, ComboDecoDown, CheckMark}; | 250 | VScrollDecoDown, ComboDeco, ComboDecoDown, CheckMark}; |
251 | 251 | ||
252 | int i; | 252 | int i; |
253 | QString tmpStr; | 253 | QString tmpStr; |
254 | QString copyfrom[ WIDGETS ]; | 254 | QString copyfrom[ WIDGETS ]; |
255 | QString pixnames[ WIDGETS ]; // used for duplicate check | 255 | QString pixnames[ WIDGETS ]; // used for duplicate check |
256 | QString brdnames[ WIDGETS ]; | 256 | QString brdnames[ WIDGETS ]; |
257 | bool loaded[ WIDGETS ]; // used for preloading for CopyWidget | 257 | bool loaded[ WIDGETS ]; // used for preloading for CopyWidget |
258 | 258 | ||
259 | if ( configFileName.isEmpty() ) { | 259 | if ( configFileName.isEmpty() ) { |
260 | Config cfg ( "qpe" ); | 260 | Config cfg ( "qpe" ); |
261 | cfg. setGroup ( "Appearance" ); | 261 | cfg. setGroup ( "Appearance" ); |
262 | 262 | ||
263 | configFileName = cfg. readEntry ( "Theme", "default" ); | 263 | configFileName = cfg. readEntry ( "Theme", "default" ); |
264 | } | 264 | } |
265 | Config config( configFilePath + "/themes/" + configFileName + ".themerc" , Config::File ); | 265 | Config config( configFilePath + "/themes/" + configFileName + ".themerc" , Config::File ); |
266 | 266 | ||
267 | // Are we initalized? | 267 | // Are we initalized? |
268 | applyMiscResourceGroup( &config ); | 268 | applyMiscResourceGroup( &config ); |
269 | for ( i = 0; i < INHERIT_ITEMS; ++i ) { | 269 | for ( i = 0; i < INHERIT_ITEMS; ++i ) { |
270 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); | 270 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); |
271 | } | 271 | } |
272 | for ( ; i < INHERIT_ITEMS*2; ++i ) { | 272 | for ( ; i < INHERIT_ITEMS*2; ++i ) { |
273 | if ( config.hasGroup( QString( widgetEntries[ i ] ) ) ) { | 273 | if ( config.hasGroup( QString( widgetEntries[ i ] ) ) ) { |
274 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); | 274 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); |
275 | } | 275 | } |
276 | else { | 276 | else { |
277 | copyfrom [ i ] = widgetEntries[ i - INHERIT_ITEMS ]; | 277 | copyfrom [ i ] = widgetEntries[ i - INHERIT_ITEMS ]; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | for ( ; i < WIDGETS; ++i ) { | 280 | for ( ; i < WIDGETS; ++i ) { |
281 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); | 281 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); |
282 | } | 282 | } |
283 | 283 | ||
284 | // initalize defaults that may not be read | 284 | // initalize defaults that may not be read |
285 | for ( i = 0; i < WIDGETS; ++i ) | 285 | for ( i = 0; i < WIDGETS; ++i ) |
286 | loaded[ i ] = false; | 286 | loaded[ i ] = false; |
287 | btnXShift = btnYShift = focus3DOffset = 0; | 287 | btnXShift = btnYShift = focus3DOffset = 0; |
288 | aTabLine = iTabLine = true; | 288 | aTabLine = iTabLine = true; |
289 | roundedButton = roundedCombo = roundedSlider = focus3D = false; | 289 | roundedButton = roundedCombo = roundedSlider = focus3D = false; |
290 | splitterWidth = 10; | 290 | splitterWidth = 10; |
291 | 291 | ||
292 | for ( i = 0; i < WIDGETS; ++i ) { | 292 | for ( i = 0; i < WIDGETS; ++i ) { |
293 | readResourceGroup( i, copyfrom, pixnames, brdnames, loaded ); | 293 | readResourceGroup( i, copyfrom, pixnames, brdnames, loaded ); |
294 | } | 294 | } |
295 | 295 | ||
296 | // misc items | 296 | // misc items |
297 | readMiscResourceGroup(); | 297 | readMiscResourceGroup(); |
298 | 298 | ||
299 | // Handle preblend items | 299 | // Handle preblend items |
300 | for ( i = 0; i < PREBLEND_ITEMS; ++i ) { | 300 | for ( i = 0; i < PREBLEND_ITEMS; ++i ) { |
301 | if ( pixmaps[ preBlend[ i ] ] != NULL && blends[ preBlend[ i ] ] != 0.0 ) | 301 | if ( pixmaps[ preBlend[ i ] ] != NULL && blends[ preBlend[ i ] ] != 0.0 ) |
302 | blend( preBlend[ i ] ); | 302 | blend( preBlend[ i ] ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | OThemeBase::OThemeBase( const QString & configFile ) | 306 | OThemeBase::OThemeBase( const QString & configFile ) |
307 | : QWindowsStyle() | 307 | : QWindowsStyle() |
308 | { | 308 | { |
309 | configFilePath = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 309 | configFilePath = QPEApplication::qpeDir ( ) + "plugins/styles/"; |
310 | configFileName = configFile; | 310 | configFileName = configFile; |
311 | 311 | ||
312 | readConfig( Qt::WindowsStyle ); | 312 | readConfig( Qt::WindowsStyle ); |
313 | cache = new OThemeCache( cacheSize ); | 313 | cache = new OThemeCache( cacheSize ); |
314 | } | 314 | } |
315 | 315 | ||
316 | void OThemeBase::applyConfigFile( const QString &/*file*/ ) | 316 | void OThemeBase::applyConfigFile( const QString &/*file*/ ) |
317 | { | 317 | { |
318 | #if 0 | 318 | #if 0 |
319 | // handle std color scheme | 319 | // handle std color scheme |
320 | Config inConfig( file, Config::File ); | 320 | Config inConfig( file, Config::File ); |
321 | Config globalConfig ( "qpe" ); | 321 | Config globalConfig ( "qpe" ); |
322 | 322 | ||
323 | globalConfig. setGroup ( "Apperance" ); | 323 | globalConfig. setGroup ( "Apperance" ); |
324 | inConfig. setGroup( "General" ); | 324 | inConfig. setGroup( "General" ); |
325 | 325 | ||
326 | if ( inConfig.hasKey( "foreground" ) ) | 326 | if ( inConfig.hasKey( "foreground" ) ) |
327 | globalConfig.writeEntry( "Text", inConfig.readEntry( "foreground", " " ) ); | 327 | globalConfig.writeEntry( "Text", inConfig.readEntry( "foreground", " " ) ); |
328 | if ( inConfig.hasKey( "background" ) ) | 328 | if ( inConfig.hasKey( "background" ) ) |
329 | globalConfig.writeEntry( "Background", inConfig.readEntry( "background", " " ) ); | 329 | globalConfig.writeEntry( "Background", inConfig.readEntry( "background", " " ) ); |
330 | if ( inConfig.hasKey( "selectForeground" ) ) | 330 | if ( inConfig.hasKey( "selectForeground" ) ) |
331 | globalConfig.writeEntry( "HighlightedText", inConfig.readEntry( "selectForeground", " " ) ); | 331 | globalConfig.writeEntry( "HighlightedText", inConfig.readEntry( "selectForeground", " " ) ); |
332 | if ( inConfig.hasKey( "selectBackground" ) ) | 332 | if ( inConfig.hasKey( "selectBackground" ) ) |
333 | globalConfig.writeEntry( "Highlight", inConfig.readEntry( "selectBackground", " " ) ); | 333 | globalConfig.writeEntry( "Highlight", inConfig.readEntry( "selectBackground", " " ) ); |
334 | if ( inConfig.hasKey( "windowForeground" ) ) | 334 | if ( inConfig.hasKey( "windowForeground" ) ) |
335 | globalConfig.writeEntry( "Text", inConfig.readEntry( "windowForeground", " " ) ); | 335 | globalConfig.writeEntry( "Text", inConfig.readEntry( "windowForeground", " " ) ); |
336 | if ( inConfig.hasKey( "windowBackground" ) ) | 336 | if ( inConfig.hasKey( "windowBackground" ) ) |
337 | globalConfig.writeEntry( "Base", inConfig.readEntry( "windowBackground", " " ) ); | 337 | globalConfig.writeEntry( "Base", inConfig.readEntry( "windowBackground", " " ) ); |
338 | 338 | ||
339 | // Keep track of the current theme so that we can select the right one | 339 | // Keep track of the current theme so that we can select the right one |
340 | // in the KControl module. | 340 | // in the KControl module. |
341 | globalConfig.writeEntry ( "CurrentTheme", file ); | 341 | globalConfig.writeEntry ( "CurrentTheme", file ); |
342 | 342 | ||
343 | globalConfig.write(); | 343 | globalConfig.write(); |
344 | #endif | 344 | #endif |
345 | } | 345 | } |
346 | 346 | ||
347 | OThemeBase::~OThemeBase() | 347 | OThemeBase::~OThemeBase() |
348 | { | 348 | { |
349 | int i; | 349 | int i; |
350 | for ( i = 0; i < WIDGETS; ++i ) { | 350 | for ( i = 0; i < WIDGETS; ++i ) { |
351 | if ( !duplicate[ i ] ) { | 351 | if ( !duplicate[ i ] ) { |
352 | if ( images[ i ] ) | 352 | if ( images[ i ] ) |
353 | delete images[ i ]; | 353 | delete images[ i ]; |
354 | if ( pixmaps[ i ] ) | 354 | if ( pixmaps[ i ] ) |
355 | delete pixmaps[ i ]; | 355 | delete pixmaps[ i ]; |
356 | } | 356 | } |
357 | if ( !pbDuplicate[ i ] && pbPixmaps[ i ] ) | 357 | if ( !pbDuplicate[ i ] && pbPixmaps[ i ] ) |
358 | delete pbPixmaps[ i ]; | 358 | delete pbPixmaps[ i ]; |
359 | if ( colors[ i ] ) | 359 | if ( colors[ i ] ) |
360 | delete( colors[ i ] ); | 360 | delete( colors[ i ] ); |
361 | if ( grLowColors[ i ] ) | 361 | if ( grLowColors[ i ] ) |
362 | delete( grLowColors[ i ] ); | 362 | delete( grLowColors[ i ] ); |
363 | if ( grHighColors[ i ] ) | 363 | if ( grHighColors[ i ] ) |
364 | delete( grHighColors[ i ] ); | 364 | delete( grHighColors[ i ] ); |
365 | } | 365 | } |
366 | delete cache; | 366 | delete cache; |
367 | } | 367 | } |
368 | 368 | ||
369 | QImage* OThemeBase::loadImage( QString &name ) | 369 | QImage* OThemeBase::loadImage( QString &name ) |
370 | { | 370 | { |
371 | QImage * image = new QImage; | 371 | QImage * image = new QImage; |
372 | QString path = configFilePath + "/pixmaps/" + name; | 372 | QString path = configFilePath + "/pixmaps/" + name; |
373 | image->load( path ); | 373 | image->load( path ); |
374 | if ( !image->isNull() ) | 374 | if ( !image->isNull() ) |
375 | return ( image ); | 375 | return ( image ); |
376 | odebug << "OThemeBase: Unable to load image " << name.ascii ( ) << oendl; | 376 | odebug << "OThemeBase: Unable to load image " << name.ascii ( ) << oendl; |
377 | delete image; | 377 | delete image; |
378 | return ( NULL ); | 378 | return ( NULL ); |
379 | } | 379 | } |
380 | 380 | ||
381 | OThemePixmap* OThemeBase::loadPixmap( QString &name ) | 381 | OThemePixmap* OThemeBase::loadPixmap( QString &name ) |
382 | { | 382 | { |
383 | OThemePixmap * pixmap = new OThemePixmap( false ); | 383 | OThemePixmap * pixmap = new OThemePixmap( false ); |
384 | QString path = configFilePath + "/pixmaps/" + name; | 384 | QString path = configFilePath + "/pixmaps/" + name; |
385 | pixmap->load( path ); | 385 | pixmap->load( path ); |
386 | if ( !pixmap->isNull() ) | 386 | if ( !pixmap->isNull() ) |
387 | return pixmap; | 387 | return pixmap; |
388 | odebug << "OThemeBase: Unable to load pixmap " << name.ascii() << oendl; | 388 | odebug << "OThemeBase: Unable to load pixmap " << name.ascii() << oendl; |
389 | delete pixmap; | 389 | delete pixmap; |
390 | return ( NULL ); | 390 | return ( NULL ); |
391 | } | 391 | } |
392 | 392 | ||
393 | OThemePixmap* OThemeBase::scale( int w, int h, WidgetType widget ) | 393 | OThemePixmap* OThemeBase::scale( int w, int h, WidgetType widget ) |
394 | { | 394 | { |
395 | if ( scaleHints[ widget ] == FullScale ) { | 395 | if ( scaleHints[ widget ] == FullScale ) { |
396 | if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || | 396 | if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || |
397 | pixmaps[ widget ] ->height() != h ) { | 397 | pixmaps[ widget ] ->height() != h ) { |
398 | OThemePixmap * cachePix = cache->pixmap( w, h, widget ); | 398 | OThemePixmap * cachePix = cache->pixmap( w, h, widget ); |
399 | if ( cachePix ) { | 399 | if ( cachePix ) { |
400 | cachePix = new OThemePixmap( *cachePix ); | 400 | cachePix = new OThemePixmap( *cachePix ); |
401 | if ( pixmaps[ widget ] ) | 401 | if ( pixmaps[ widget ] ) |
402 | cache->insert( pixmaps[ widget ], OThemeCache::FullScale, | 402 | cache->insert( pixmaps[ widget ], OThemeCache::FullScale, |
403 | widget ); | 403 | widget ); |
404 | else | 404 | else |
405 | odebug << "We would have inserted a null pixmap!\n" << oendl; | 405 | odebug << "We would have inserted a null pixmap!\n" << oendl; |
diff --git a/noncore/styles/theme/themeset.cpp b/noncore/styles/theme/themeset.cpp index d4005bc..3205106 100644 --- a/noncore/styles/theme/themeset.cpp +++ b/noncore/styles/theme/themeset.cpp | |||
@@ -1,124 +1,124 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
23 | #include "themeset.h" | 23 | #include "themeset.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
27 | 27 | ||
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlistview.h> | 30 | #include <qlistview.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | 32 | ||
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | 34 | ||
35 | 35 | ||
36 | class MyConfig : public Config | 36 | class MyConfig : public Config |
37 | { | 37 | { |
38 | public: | 38 | public: |
39 | MyConfig ( const QString &f, Domain d ) : Config ( f, d ) | 39 | MyConfig ( const QString &f, Domain d ) : Config ( f, d ) |
40 | { } | 40 | { } |
41 | 41 | ||
42 | bool hasGroup ( const QString &gname ) const | 42 | bool hasGroup ( const QString &gname ) const |
43 | { | 43 | { |
44 | QMap< QString, ConfigGroup>::ConstIterator it = groups. find ( gname ); | 44 | QMap< QString, ConfigGroup>::ConstIterator it = groups. find ( gname ); |
45 | return ( it != groups.end() ); | 45 | return ( it != groups.end() ); |
46 | } | 46 | } |
47 | }; | 47 | }; |
48 | 48 | ||
49 | class MyItem : public QListViewItem | 49 | class MyItem : public QListViewItem |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | MyItem ( QListView *lv, QListViewItem *after, const QString &name, const QString &comm, const QString &theme ) : QListViewItem ( lv, after, name, comm ) | 52 | MyItem ( QListView *lv, QListViewItem *after, const QString &name, const QString &comm, const QString &theme ) : QListViewItem ( lv, after, name, comm ) |
53 | { | 53 | { |
54 | m_theme = theme; | 54 | m_theme = theme; |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | QString m_theme; | 58 | QString m_theme; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | 61 | ||
62 | ThemeSettings::ThemeSettings ( QWidget* parent, const char *name, WFlags fl ) | 62 | ThemeSettings::ThemeSettings ( QWidget* parent, const char *name, WFlags fl ) |
63 | : QWidget ( parent, name, fl ) | 63 | : QWidget ( parent, name, fl ) |
64 | { | 64 | { |
65 | setCaption ( tr( "Theme Style" ) ); | 65 | setCaption ( tr( "Theme Style" ) ); |
66 | 66 | ||
67 | Config config ( "qpe" ); | 67 | Config config ( "qpe" ); |
68 | config. setGroup ( "Appearance" ); | 68 | config. setGroup ( "Appearance" ); |
69 | 69 | ||
70 | QString active = config. readEntry ( "Theme", "default" ); | 70 | QString active = config. readEntry ( "Theme", "default" ); |
71 | 71 | ||
72 | QVBoxLayout *vbox = new QVBoxLayout ( this ); | 72 | QVBoxLayout *vbox = new QVBoxLayout ( this ); |
73 | vbox-> setSpacing ( 3 ); | 73 | vbox-> setSpacing ( 3 ); |
74 | vbox-> setMargin ( 6 ); | 74 | vbox-> setMargin ( 6 ); |
75 | 75 | ||
76 | vbox-> addWidget ( new QLabel ( tr( "Select the theme to be used" ), this )); | 76 | vbox-> addWidget ( new QLabel ( tr( "Select the theme to be used" ), this )); |
77 | 77 | ||
78 | m_list = new QListView ( this ); | 78 | m_list = new QListView ( this ); |
79 | m_list-> addColumn ( tr( "Name" )); | 79 | m_list-> addColumn ( tr( "Name" )); |
80 | m_list-> addColumn ( tr( "Description" )); | 80 | m_list-> addColumn ( tr( "Description" )); |
81 | m_list-> setSelectionMode ( QListView::Single ); | 81 | m_list-> setSelectionMode ( QListView::Single ); |
82 | m_list-> setAllColumnsShowFocus ( true ); | 82 | m_list-> setAllColumnsShowFocus ( true ); |
83 | m_list-> setSorting ( -1 ); | 83 | m_list-> setSorting ( -1 ); |
84 | vbox-> addWidget ( m_list, 10 ); | 84 | vbox-> addWidget ( m_list, 10 ); |
85 | 85 | ||
86 | QListViewItem *item = new MyItem ( m_list, 0, tr( "[No theme]" ), "", "" ); | 86 | QListViewItem *item = new MyItem ( m_list, 0, tr( "[No theme]" ), "", "" ); |
87 | m_list-> setSelected ( item, true ); | 87 | m_list-> setSelected ( item, true ); |
88 | 88 | ||
89 | QString path = QPEApplication::qpeDir() + "/plugins/styles/themes"; | 89 | QString path = QPEApplication::qpeDir() + "plugins/styles/themes"; |
90 | QStringList list = QDir ( path, "*.themerc" ). entryList ( ); | 90 | QStringList list = QDir ( path, "*.themerc" ). entryList ( ); |
91 | 91 | ||
92 | for ( QStringList::Iterator it = list. begin(); it != list. end ( ); ++it ) { | 92 | for ( QStringList::Iterator it = list. begin(); it != list. end ( ); ++it ) { |
93 | MyConfig cfg ( path + "/" + *it, Config::File ); | 93 | MyConfig cfg ( path + "/" + *it, Config::File ); |
94 | 94 | ||
95 | if ( cfg. hasGroup ( "Misc" )) { | 95 | if ( cfg. hasGroup ( "Misc" )) { |
96 | cfg. setGroup ( "Misc" ); | 96 | cfg. setGroup ( "Misc" ); |
97 | 97 | ||
98 | QString name = cfg. readEntry ( "Name" ); | 98 | QString name = cfg. readEntry ( "Name" ); |
99 | QString comm = cfg. readEntry ( "Comment" ); | 99 | QString comm = cfg. readEntry ( "Comment" ); |
100 | 100 | ||
101 | if ( !name. isEmpty ( )) { | 101 | if ( !name. isEmpty ( )) { |
102 | QString fname = (*it). left ((*it). length ( ) - 8 ); | 102 | QString fname = (*it). left ((*it). length ( ) - 8 ); |
103 | 103 | ||
104 | item = new MyItem ( m_list, item, name, comm, fname ); | 104 | item = new MyItem ( m_list, item, name, comm, fname ); |
105 | if ( active == fname ) { | 105 | if ( active == fname ) { |
106 | m_list-> setSelected ( item, true ); | 106 | m_list-> setSelected ( item, true ); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | } | 109 | } |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | bool ThemeSettings::writeConfig ( ) | 113 | bool ThemeSettings::writeConfig ( ) |
114 | { | 114 | { |
115 | Config config ( "qpe" ); | 115 | Config config ( "qpe" ); |
116 | config. setGroup ( "Appearance" ); | 116 | config. setGroup ( "Appearance" ); |
117 | 117 | ||
118 | MyItem *it = (MyItem *) m_list-> selectedItem ( ); | 118 | MyItem *it = (MyItem *) m_list-> selectedItem ( ); |
119 | config. writeEntry ( "Theme", it ? it-> m_theme : QString ( "" )); | 119 | config. writeEntry ( "Theme", it ? it-> m_theme : QString ( "" )); |
120 | config. write ( ); | 120 | config. write ( ); |
121 | 121 | ||
122 | return true; | 122 | return true; |
123 | } | 123 | } |
124 | 124 | ||
diff --git a/noncore/tools/calc2/calc.cpp b/noncore/tools/calc2/calc.cpp index 3dcdf6e..c7656bf 100644 --- a/noncore/tools/calc2/calc.cpp +++ b/noncore/tools/calc2/calc.cpp | |||
@@ -1,104 +1,104 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qvaluelist.h> | 21 | #include <qvaluelist.h> |
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #include <qdir.h> | 23 | #include <qdir.h> |
24 | #include <qwidgetstack.h> | 24 | #include <qwidgetstack.h> |
25 | 25 | ||
26 | #include "calc.h" | 26 | #include "calc.h" |
27 | #include "plugininterface.h" | 27 | #include "plugininterface.h" |
28 | 28 | ||
29 | calc::calc (QWidget * p, const char *n):QWidget (p, n) | 29 | calc::calc (QWidget * p, const char *n):QWidget (p, n) |
30 | { | 30 | { |
31 | setCaption (tr ("Calculator")); | 31 | setCaption (tr ("Calculator")); |
32 | 32 | ||
33 | // widgets | 33 | // widgets |
34 | LCD = new QLCDNumber (this); | 34 | LCD = new QLCDNumber (this); |
35 | LCD->setMaximumSize (QSize (240, 30)); | 35 | LCD->setMaximumSize (QSize (240, 30)); |
36 | LCD->setNumDigits(12); | 36 | LCD->setNumDigits(12); |
37 | LCD->setSegmentStyle(QLCDNumber::Filled); | 37 | LCD->setSegmentStyle(QLCDNumber::Filled); |
38 | pluginWidgetStack = new QWidgetStack (this); | 38 | pluginWidgetStack = new QWidgetStack (this); |
39 | 39 | ||
40 | // layout widgets | 40 | // layout widgets |
41 | calculatorLayout = new QVBoxLayout (this); | 41 | calculatorLayout = new QVBoxLayout (this); |
42 | calculatorLayout->addWidget (LCD); | 42 | calculatorLayout->addWidget (LCD); |
43 | calculatorLayout->addWidget (pluginWidgetStack); | 43 | calculatorLayout->addWidget (pluginWidgetStack); |
44 | 44 | ||
45 | // no formatting of display for now | 45 | // no formatting of display for now |
46 | connect (&engine, SIGNAL(display(double)), LCD, SLOT(display(double))); | 46 | connect (&engine, SIGNAL(display(double)), LCD, SLOT(display(double))); |
47 | connect (&engine, SIGNAL(display(const QString&)), LCD, SLOT(display(const QString&))); | 47 | connect (&engine, SIGNAL(display(const QString&)), LCD, SLOT(display(const QString&))); |
48 | connect (&engine, SIGNAL(setBinMode()), LCD, SLOT(setBinMode())); | 48 | connect (&engine, SIGNAL(setBinMode()), LCD, SLOT(setBinMode())); |
49 | connect (&engine, SIGNAL(setOctMode()), LCD, SLOT(setOctMode())); | 49 | connect (&engine, SIGNAL(setOctMode()), LCD, SLOT(setOctMode())); |
50 | connect (&engine, SIGNAL(setDecMode()), LCD, SLOT(setDecMode())); | 50 | connect (&engine, SIGNAL(setDecMode()), LCD, SLOT(setDecMode())); |
51 | connect (&engine, SIGNAL(setHexMode()), LCD, SLOT(setHexMode())); | 51 | connect (&engine, SIGNAL(setHexMode()), LCD, SLOT(setHexMode())); |
52 | 52 | ||
53 | #ifndef NO_PLUGINS | 53 | #ifndef NO_PLUGINS |
54 | // load plugins | 54 | // load plugins |
55 | QValueList < Plugin >::Iterator mit; | 55 | QValueList < Plugin >::Iterator mit; |
56 | for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) { | 56 | for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) { |
57 | (*mit).interface->release (); | 57 | (*mit).interface->release (); |
58 | (*mit).library->unload (); | 58 | (*mit).library->unload (); |
59 | delete (*mit).library; | 59 | delete (*mit).library; |
60 | } | 60 | } |
61 | pluginList.clear (); | 61 | pluginList.clear (); |
62 | 62 | ||
63 | QString path = QPEApplication::qpeDir() + "/plugins/calculator"; | 63 | QString path = QPEApplication::qpeDir() + "plugins/calculator"; |
64 | QDir dir (path, "lib*.so"); | 64 | QDir dir (path, "lib*.so"); |
65 | QStringList list = dir.entryList (); | 65 | QStringList list = dir.entryList (); |
66 | 66 | ||
67 | QStringList::Iterator it; | 67 | QStringList::Iterator it; |
68 | for (it = list.begin (); it != list.end (); ++it) { | 68 | for (it = list.begin (); it != list.end (); ++it) { |
69 | CalcInterface *iface = 0; | 69 | CalcInterface *iface = 0; |
70 | QLibrary *lib = new QLibrary (path + "/" + *it); | 70 | QLibrary *lib = new QLibrary (path + "/" + *it); |
71 | 71 | ||
72 | Plugin plugin; | 72 | Plugin plugin; |
73 | plugin.pluginWidget = 0; | 73 | plugin.pluginWidget = 0; |
74 | 74 | ||
75 | if (lib->queryInterface (IID_Calc, (QUnknownInterface **) & iface) == | 75 | if (lib->queryInterface (IID_Calc, (QUnknownInterface **) & iface) == |
76 | QS_OK) { | 76 | QS_OK) { |
77 | plugin.library = lib; | 77 | plugin.library = lib; |
78 | plugin.interface = iface; | 78 | plugin.interface = iface; |
79 | plugin.pluginWidget = plugin.interface->getPlugin(&engine,pluginWidgetStack); | 79 | plugin.pluginWidget = plugin.interface->getPlugin(&engine,pluginWidgetStack); |
80 | if (plugin.pluginWidget) | 80 | if (plugin.pluginWidget) |
81 | pluginWidgetStack->addWidget (plugin.pluginWidget, pluginList.count()); | 81 | pluginWidgetStack->addWidget (plugin.pluginWidget, pluginList.count()); |
82 | pluginList.append (plugin); | 82 | pluginList.append (plugin); |
83 | } else { | 83 | } else { |
84 | delete lib; | 84 | delete lib; |
85 | } | 85 | } |
86 | } | 86 | } |
87 | setMode (1); | 87 | setMode (1); |
88 | #else | 88 | #else |
89 | // load simple interface | 89 | // load simple interface |
90 | #endif | 90 | #endif |
91 | } | 91 | } |
92 | 92 | ||
93 | calc::~calc () | 93 | calc::~calc () |
94 | { | 94 | { |
95 | #ifndef NO_PLUGINS | 95 | #ifndef NO_PLUGINS |
96 | QValueList < Plugin >::Iterator mit; | 96 | QValueList < Plugin >::Iterator mit; |
97 | for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) { | 97 | for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) { |
98 | (*mit).interface->release (); | 98 | (*mit).interface->release (); |
99 | (*mit).library->unload (); | 99 | (*mit).library->unload (); |
100 | delete (*mit).library; | 100 | delete (*mit).library; |
101 | } | 101 | } |
102 | #endif | 102 | #endif |
103 | } | 103 | } |
104 | 104 | ||
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp index 3cb8faf..73e7ce4 100644 --- a/x11/libqpe-x11/qpe/qpeapplication.cpp +++ b/x11/libqpe-x11/qpe/qpeapplication.cpp | |||
@@ -47,214 +47,214 @@ const int XKeyRelease = KeyRelease; | |||
47 | #undef KeyRelease | 47 | #undef KeyRelease |
48 | 48 | ||
49 | namespace { | 49 | namespace { |
50 | struct QCopRec{ | 50 | struct QCopRec{ |
51 | QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar ) | 51 | QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar ) |
52 | : channel(ch), message(msg), data(ar) { | 52 | : channel(ch), message(msg), data(ar) { |
53 | 53 | ||
54 | } | 54 | } |
55 | QCString channel; | 55 | QCString channel; |
56 | QCString message; | 56 | QCString message; |
57 | QByteArray data; | 57 | QByteArray data; |
58 | }; | 58 | }; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | 61 | ||
62 | class QPEApplication::Private { | 62 | class QPEApplication::Private { |
63 | public: | 63 | public: |
64 | Private(); | 64 | Private(); |
65 | ~Private(); | 65 | ~Private(); |
66 | void enqueueQCop( const QCString& ch, const QCString& msg, | 66 | void enqueueQCop( const QCString& ch, const QCString& msg, |
67 | const QByteArray& ); | 67 | const QByteArray& ); |
68 | void sendQCopQ(); | 68 | void sendQCopQ(); |
69 | static void show_mx(QWidget* mw, bool nomaximize ); | 69 | static void show_mx(QWidget* mw, bool nomaximize ); |
70 | void show( QWidget* mw, bool nomax ); | 70 | void show( QWidget* mw, bool nomax ); |
71 | void loadTextCodecs(); | 71 | void loadTextCodecs(); |
72 | void loadImageCodecs(); | 72 | void loadImageCodecs(); |
73 | 73 | ||
74 | int kbgrabber; | 74 | int kbgrabber; |
75 | int presstimer; | 75 | int presstimer; |
76 | 76 | ||
77 | bool rightpressed : 1; | 77 | bool rightpressed : 1; |
78 | bool kbregrab : 1; | 78 | bool kbregrab : 1; |
79 | bool notbusysent : 1; | 79 | bool notbusysent : 1; |
80 | bool preloaded : 1; | 80 | bool preloaded : 1; |
81 | bool forceshow : 1; | 81 | bool forceshow : 1; |
82 | bool nomaximize : 1; | 82 | bool nomaximize : 1; |
83 | bool keep_running : 1; | 83 | bool keep_running : 1; |
84 | 84 | ||
85 | QWidget* presswidget; | 85 | QWidget* presswidget; |
86 | QPoint presspos; | 86 | QPoint presspos; |
87 | QWidget* qpe_main_widget; | 87 | QWidget* qpe_main_widget; |
88 | QString appName; | 88 | QString appName; |
89 | QString styleName; | 89 | QString styleName; |
90 | QString decorationName; | 90 | QString decorationName; |
91 | Atom wm_delete_window; | 91 | Atom wm_delete_window; |
92 | Atom wm_take_focus; | 92 | Atom wm_take_focus; |
93 | Atom wm_context_help; | 93 | Atom wm_context_help; |
94 | Atom wm_context_accept; | 94 | Atom wm_context_accept; |
95 | Atom wm_protocols; | 95 | Atom wm_protocols; |
96 | 96 | ||
97 | private: | 97 | private: |
98 | QList<QCopRec> qcopq; | 98 | QList<QCopRec> qcopq; |
99 | }; | 99 | }; |
100 | QPEApplication::Private::~Private() { | 100 | QPEApplication::Private::~Private() { |
101 | } | 101 | } |
102 | QPEApplication::Private::Private() | 102 | QPEApplication::Private::Private() |
103 | : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), | 103 | : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), |
104 | preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), | 104 | preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), |
105 | presswidget( 0 ), qpe_main_widget(0 ) { | 105 | presswidget( 0 ), qpe_main_widget(0 ) { |
106 | 106 | ||
107 | qcopq.setAutoDelete( TRUE ); | 107 | qcopq.setAutoDelete( TRUE ); |
108 | } | 108 | } |
109 | void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg, | 109 | void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg, |
110 | const QByteArray& ar ) { | 110 | const QByteArray& ar ) { |
111 | qcopq.append( new QCopRec(chan, msg, ar ) ); | 111 | qcopq.append( new QCopRec(chan, msg, ar ) ); |
112 | } | 112 | } |
113 | void QPEApplication::Private::sendQCopQ() { | 113 | void QPEApplication::Private::sendQCopQ() { |
114 | QCopRec* r; | 114 | QCopRec* r; |
115 | for ( r = qcopq.first(); r; r = qcopq.next() ) { | 115 | for ( r = qcopq.first(); r; r = qcopq.next() ) { |
116 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 116 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
117 | } | 117 | } |
118 | qcopq.clear(); | 118 | qcopq.clear(); |
119 | } | 119 | } |
120 | void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) { | 120 | void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) { |
121 | if (mw->layout() && mw->inherits("QDialog") ) { | 121 | if (mw->layout() && mw->inherits("QDialog") ) { |
122 | QPEApplication::showDialog( (QDialog*)mw, nomaximize ); | 122 | QPEApplication::showDialog( (QDialog*)mw, nomaximize ); |
123 | }else { | 123 | }else { |
124 | if (!nomaximize ) | 124 | if (!nomaximize ) |
125 | mw->showMaximized(); | 125 | mw->showMaximized(); |
126 | else | 126 | else |
127 | mw->show(); | 127 | mw->show(); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | void QPEApplication::Private::show( QWidget* mw, bool nomax ) { | 130 | void QPEApplication::Private::show( QWidget* mw, bool nomax ) { |
131 | nomaximize = nomax; | 131 | nomaximize = nomax; |
132 | qpe_main_widget = mw; | 132 | qpe_main_widget = mw; |
133 | 133 | ||
134 | sendQCopQ(); | 134 | sendQCopQ(); |
135 | 135 | ||
136 | if ( preloaded ) { | 136 | if ( preloaded ) { |
137 | if (forceshow ) | 137 | if (forceshow ) |
138 | show_mx(mw, nomax ); | 138 | show_mx(mw, nomax ); |
139 | }else if ( keep_running ) | 139 | }else if ( keep_running ) |
140 | show_mx( mw, nomax ); | 140 | show_mx( mw, nomax ); |
141 | } | 141 | } |
142 | void QPEApplication::Private::loadTextCodecs() { | 142 | void QPEApplication::Private::loadTextCodecs() { |
143 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 143 | QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; |
144 | QDir dir( path, "lib*.so" ); | 144 | QDir dir( path, "lib*.so" ); |
145 | QStringList list = dir.entryList(); | 145 | QStringList list = dir.entryList(); |
146 | QStringList::Iterator it; | 146 | QStringList::Iterator it; |
147 | for ( it = list.begin(); it != list.end(); ++it ) { | 147 | for ( it = list.begin(); it != list.end(); ++it ) { |
148 | TextCodecInterface *iface = 0; | 148 | TextCodecInterface *iface = 0; |
149 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 149 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
150 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 150 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
151 | QValueList<int> mibs = iface->mibEnums(); | 151 | QValueList<int> mibs = iface->mibEnums(); |
152 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 152 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
153 | (void)iface->createForMib(*i); | 153 | (void)iface->createForMib(*i); |
154 | // ### it exists now; need to remember if we can delete it | 154 | // ### it exists now; need to remember if we can delete it |
155 | } | 155 | } |
156 | } | 156 | } |
157 | else { | 157 | else { |
158 | lib->unload(); | 158 | lib->unload(); |
159 | delete lib; | 159 | delete lib; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
163 | void QPEApplication::Private::loadImageCodecs() { | 163 | void QPEApplication::Private::loadImageCodecs() { |
164 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 164 | QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; |
165 | QDir dir( path, "lib*.so" ); | 165 | QDir dir( path, "lib*.so" ); |
166 | QStringList list = dir.entryList(); | 166 | QStringList list = dir.entryList(); |
167 | QStringList::Iterator it; | 167 | QStringList::Iterator it; |
168 | for ( it = list.begin(); it != list.end(); ++it ) { | 168 | for ( it = list.begin(); it != list.end(); ++it ) { |
169 | ImageCodecInterface *iface = 0; | 169 | ImageCodecInterface *iface = 0; |
170 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 170 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
171 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 171 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
172 | QStringList formats = iface->keys(); | 172 | QStringList formats = iface->keys(); |
173 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 173 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
174 | (void)iface->installIOHandler(*i); | 174 | (void)iface->installIOHandler(*i); |
175 | // ### it exists now; need to remember if we can delete it | 175 | // ### it exists now; need to remember if we can delete it |
176 | } | 176 | } |
177 | } | 177 | } |
178 | else { | 178 | else { |
179 | lib->unload(); | 179 | lib->unload(); |
180 | delete lib; | 180 | delete lib; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | // The Help System hook | 185 | // The Help System hook |
186 | namespace { | 186 | namespace { |
187 | class ResourceMimeFactory : public QMimeSourceFactory | 187 | class ResourceMimeFactory : public QMimeSourceFactory |
188 | { | 188 | { |
189 | public: | 189 | public: |
190 | ResourceMimeFactory(); | 190 | ResourceMimeFactory(); |
191 | ~ResourceMimeFactory(); | 191 | ~ResourceMimeFactory(); |
192 | const QMimeSource* data( const QString& abs_name )const; | 192 | const QMimeSource* data( const QString& abs_name )const; |
193 | }; | 193 | }; |
194 | ResourceMimeFactory::ResourceMimeFactory() | 194 | ResourceMimeFactory::ResourceMimeFactory() |
195 | { | 195 | { |
196 | setFilePath( Global::helpPath() ); | 196 | setFilePath( Global::helpPath() ); |
197 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 197 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
198 | } | 198 | } |
199 | ResourceMimeFactory::~ResourceMimeFactory() { | 199 | ResourceMimeFactory::~ResourceMimeFactory() { |
200 | } | 200 | } |
201 | 201 | ||
202 | const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const | 202 | const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const |
203 | { | 203 | { |
204 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 204 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
205 | if ( !r ) { | 205 | if ( !r ) { |
206 | int sl = abs_name.length(); | 206 | int sl = abs_name.length(); |
207 | do { | 207 | do { |
208 | sl = abs_name.findRev( '/', sl - 1 ); | 208 | sl = abs_name.findRev( '/', sl - 1 ); |
209 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 209 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
210 | int dot = name.findRev( '.' ); | 210 | int dot = name.findRev( '.' ); |
211 | if ( dot >= 0 ) | 211 | if ( dot >= 0 ) |
212 | name = name.left( dot ); | 212 | name = name.left( dot ); |
213 | QImage img = Resource::loadImage( name ); | 213 | QImage img = Resource::loadImage( name ); |
214 | if ( !img.isNull() ) | 214 | if ( !img.isNull() ) |
215 | r = new QImageDrag( img ); | 215 | r = new QImageDrag( img ); |
216 | } | 216 | } |
217 | while ( !r && sl > 0 ); | 217 | while ( !r && sl > 0 ); |
218 | } | 218 | } |
219 | return r; | 219 | return r; |
220 | }; | 220 | }; |
221 | }; | 221 | }; |
222 | // QPEApplication | 222 | // QPEApplication |
223 | QPEApplication::~QPEApplication() { | 223 | QPEApplication::~QPEApplication() { |
224 | qWarning("~QPEApplication"); | 224 | qWarning("~QPEApplication"); |
225 | ungrabKeyboard(); | 225 | ungrabKeyboard(); |
226 | qWarning("UngrabKeyboard"); | 226 | qWarning("UngrabKeyboard"); |
227 | 227 | ||
228 | // delete m_sys; | 228 | // delete m_sys; |
229 | // delete m_pid; | 229 | // delete m_pid; |
230 | 230 | ||
231 | delete d; | 231 | delete d; |
232 | } | 232 | } |
233 | QPEApplication::QPEApplication(int &arg, char** argv, Type t) | 233 | QPEApplication::QPEApplication(int &arg, char** argv, Type t) |
234 | : QApplication( arg, argv, t ) { | 234 | : QApplication( arg, argv, t ) { |
235 | d = new Private; | 235 | d = new Private; |
236 | d->loadTextCodecs(); | 236 | d->loadTextCodecs(); |
237 | d->loadImageCodecs(); | 237 | d->loadImageCodecs(); |
238 | 238 | ||
239 | // Init X-Atom | 239 | // Init X-Atom |
240 | Atom *atoms[5]; | 240 | Atom *atoms[5]; |
241 | Atom atoms_re[5]; | 241 | Atom atoms_re[5]; |
242 | char* names[5]; | 242 | char* names[5]; |
243 | int n = 0; | 243 | int n = 0; |
244 | atoms[n] = &d->wm_delete_window; | 244 | atoms[n] = &d->wm_delete_window; |
245 | names[n++] = "WM_DELETE_WINDOW"; | 245 | names[n++] = "WM_DELETE_WINDOW"; |
246 | 246 | ||
247 | atoms[n] = &d->wm_take_focus; | 247 | atoms[n] = &d->wm_take_focus; |
248 | names[n++] = "WM_TAKE_FOCUS"; | 248 | names[n++] = "WM_TAKE_FOCUS"; |
249 | 249 | ||
250 | atoms[n] = &d->wm_context_help; | 250 | atoms[n] = &d->wm_context_help; |
251 | names[n++] = "_NET_WM_CONTEXT_HELP"; | 251 | names[n++] = "_NET_WM_CONTEXT_HELP"; |
252 | 252 | ||
253 | atoms[n] = &d->wm_context_accept; | 253 | atoms[n] = &d->wm_context_accept; |
254 | names[n++] = "_NET_WM_CONTEXT_ACCEPT"; | 254 | names[n++] = "_NET_WM_CONTEXT_ACCEPT"; |
255 | 255 | ||
256 | atoms[n] = &d->wm_protocols; | 256 | atoms[n] = &d->wm_protocols; |
257 | names[n++] = "WM_PROTOCOLS"; | 257 | names[n++] = "WM_PROTOCOLS"; |
258 | 258 | ||
259 | XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re); | 259 | XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re); |
260 | // now copy the values over to the properties | 260 | // now copy the values over to the properties |