summaryrefslogtreecommitdiff
path: root/noncore/applets
authorzecke <zecke>2004-12-20 22:17:40 (UTC)
committer zecke <zecke>2004-12-20 22:17:40 (UTC)
commitb15930cd03acafd9770bca26f3388817f1a4dcbf (patch) (unidiff)
tree7f86e31793c1bacb0882e7abb88a3847333f5c4a /noncore/applets
parenta50334dddaa542fd63726a639e852c30036f53a0 (diff)
downloadopie-b15930cd03acafd9770bca26f3388817f1a4dcbf.zip
opie-b15930cd03acafd9770bca26f3388817f1a4dcbf.tar.gz
opie-b15930cd03acafd9770bca26f3388817f1a4dcbf.tar.bz2
-Fix for 1483
"ZKB should keep user settings in $HOME/Settings instead of $OPIEDIR/share/zkb" Now by default it loads and saves to $HOME/Applications/zkb but falls back to $OPIEDIR/share/zkb to find the included files
Diffstat (limited to 'noncore/applets') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/zkbapplet/applet/zkbwidget.cpp18
-rw-r--r--noncore/applets/zkbapplet/applet/zkbwidget.h2
-rw-r--r--noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp2
-rw-r--r--noncore/applets/zkbapplet/keyzcfg/main.cpp4
-rw-r--r--noncore/applets/zkbapplet/keyzcfg/zkbcfg.cpp67
5 files changed, 47 insertions, 46 deletions
diff --git a/noncore/applets/zkbapplet/applet/zkbwidget.cpp b/noncore/applets/zkbapplet/applet/zkbwidget.cpp
index 13729ea..55c08b3 100644
--- a/noncore/applets/zkbapplet/applet/zkbwidget.cpp
+++ b/noncore/applets/zkbapplet/applet/zkbwidget.cpp
@@ -29,10 +29,8 @@ ZkbWidget::ZkbWidget(QWidget* parent)
29 29
30ZkbWidget::~ZkbWidget() 30ZkbWidget::~ZkbWidget()
31{ 31{
32 if (keymap != 0) { 32 delete keymap;
33 delete keymap; 33 keymap = 0;
34 keymap = 0;
35 }
36} 34}
37 35
38int ZkbWidget::position() 36int ZkbWidget::position()
@@ -41,13 +39,11 @@ int ZkbWidget::position()
41} 39}
42 40
43bool ZkbWidget::loadKeymap() { 41bool ZkbWidget::loadKeymap() {
44 ZkbConfig c(QPEApplication::qpeDir()+"share/zkb"); 42 ZkbConfig c(Global::applicationFileName("zkb", QString::null) );
45 QFontMetrics fm(font()); 43 QFontMetrics fm(font());
46 44
47 if (keymap != 0) { 45 delete keymap;
48 delete keymap; 46 keymap = 0;
49 keymap = 0;
50 }
51 47
52 Keymap* km = new Keymap(); 48 Keymap* km = new Keymap();
53 49
@@ -98,10 +94,6 @@ bool ZkbWidget::loadKeymap() {
98 return true; 94 return true;
99} 95}
100 96
101QSize ZkbWidget::sizeHint() const {
102 return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize());
103}
104
105void ZkbWidget::stateChanged(const QString& s) { 97void ZkbWidget::stateChanged(const QString& s) {
106// odebug << "stateChanged: " << s.utf8() << "\n" << oendl; 98// odebug << "stateChanged: " << s.utf8() << "\n" << oendl;
107 setText(s); 99 setText(s);
diff --git a/noncore/applets/zkbapplet/applet/zkbwidget.h b/noncore/applets/zkbapplet/applet/zkbwidget.h
index 9bce85a..13906c0 100644
--- a/noncore/applets/zkbapplet/applet/zkbwidget.h
+++ b/noncore/applets/zkbapplet/applet/zkbwidget.h
@@ -17,8 +17,6 @@ public:
17 ~ZkbWidget(); 17 ~ZkbWidget();
18 static int position(); 18 static int position();
19 19
20 QSize sizeHint() const;
21
22protected: 20protected:
23 QLabel* label; 21 QLabel* label;
24 Keymap* keymap; 22 Keymap* keymap;
diff --git a/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp b/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp
index 4190a9e..6f24ea0 100644
--- a/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp
+++ b/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp
@@ -124,7 +124,7 @@ void CfgDlg::accept() {
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(Global::applicationFileName("zkb", "zkb.xml" ), *cfile);
128 QCopEnvelope("QPE/zkb", "reload()"); 128 QCopEnvelope("QPE/zkb", "reload()");
129 129
130 QDialog::accept(); 130 QDialog::accept();
diff --git a/noncore/applets/zkbapplet/keyzcfg/main.cpp b/noncore/applets/zkbapplet/keyzcfg/main.cpp
index afd0f6a..d7926f0 100644
--- a/noncore/applets/zkbapplet/keyzcfg/main.cpp
+++ b/noncore/applets/zkbapplet/keyzcfg/main.cpp
@@ -1,5 +1,7 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qpe/global.h>
4
3#include <qlayout.h> 5#include <qlayout.h>
4#include <qmainwindow.h> 6#include <qmainwindow.h>
5 7
@@ -9,7 +11,7 @@ int main( int argc, char **argv ) {
9 QPEApplication app(argc, argv); 11 QPEApplication app(argc, argv);
10 CfgFile cfile; 12 CfgFile cfile;
11 CfgParser cp; 13 CfgParser cp;
12 cp.load(QPEApplication::qpeDir()+"share/zkb/zkb.xml", cfile); 14 cp.load(Global::applicationFileName("zkb", "zkb.xml"), cfile);
13 15
14 16
15 CfgDlg c(0, &cfile, &app, true); 17 CfgDlg c(0, &cfile, &app, true);
diff --git a/noncore/applets/zkbapplet/keyzcfg/zkbcfg.cpp b/noncore/applets/zkbapplet/keyzcfg/zkbcfg.cpp
index 24bd897..6f3b9bf 100644
--- a/noncore/applets/zkbapplet/keyzcfg/zkbcfg.cpp
+++ b/noncore/applets/zkbapplet/keyzcfg/zkbcfg.cpp
@@ -2,6 +2,7 @@
2 2
3/* OPIE */ 3/* OPIE */
4#include <opie2/odebug.h> 4#include <opie2/odebug.h>
5#include <opie2/oapplication.h>
5using namespace Opie::Core; 6using namespace Opie::Core;
6 7
7/* QT */ 8/* QT */
@@ -15,33 +16,41 @@ ZkbConfig::~ZkbConfig() {
15} 16}
16 17
17bool ZkbConfig::load(const QString& file, Keymap& keymap, const QString& prefix) { 18bool ZkbConfig::load(const QString& file, Keymap& keymap, const QString& prefix) {
18 bool ret; 19 bool ret;
19 QFile f(path+"/"+file); 20 QFile *f = new QFile(path+"/"+file);
20 QFileInfo fi(f); 21 QFileInfo fi(*f);
21 22
22 odebug << "start loading file=" << file.utf8() << "\n" << oendl; 23 /* Try */
23 if (includedFiles.find(fi.absFilePath()) != includedFiles.end()) { 24 if ( !fi.exists() && !path.contains( QPEApplication::qpeDir()) ) {
24 return false; 25 delete f;
25 } 26 f = new QFile( QPEApplication::qpeDir() + "share/zkb/" + file );
27 fi = QFileInfo( *f );
28 }
26 29
27 includedFiles.insert(fi.absFilePath(), 1); 30 odebug << "start loading file=" << file << "\n" << oendl;
28 QXmlInputSource is(f); 31 if (includedFiles.find(fi.absFilePath()) != includedFiles.end()) {
29 QXmlSimpleReader reader; 32 return false;
30 ZkbHandler h(*this, keymap, prefix); 33 }
31 34
32 reader.setContentHandler(&h); 35 includedFiles.insert(fi.absFilePath(), 1);
33 reader.setErrorHandler(this); 36 QXmlInputSource is(*f);
34 ret = reader.parse(is); 37 QXmlSimpleReader reader;
35 includedFiles.remove(fi.absFilePath()); 38 ZkbHandler h(*this, keymap, prefix);
36 39
37 odebug << "end loading file=" << file.utf8() << ": status=" << err.utf8() << oendl; 40 reader.setContentHandler(&h);
38 return ret; 41 reader.setErrorHandler(this);
42 ret = reader.parse(is);
43 includedFiles.remove(fi.absFilePath());
44
45 odebug << "end loading file=" << file << ": status=" << err << oendl;
46 delete f;
47 return ret;
39} 48}
40 49
41bool ZkbConfig::warning(const QXmlParseException& e) { 50bool ZkbConfig::warning(const QXmlParseException& e) {
42 QString tmp; 51 QString tmp;
43 52
44 tmp.sprintf("%d: warning: %s\n", e.lineNumber(), 53 tmp.sprintf("%d: warning: %s\n", e.lineNumber(),
45 (const char*) e.message().utf8()); 54 (const char*) e.message().utf8());
46 55
47 err += tmp; 56 err += tmp;
@@ -52,7 +61,7 @@ bool ZkbConfig::warning(const QXmlParseException& e) {
52bool ZkbConfig::error(const QXmlParseException& e) { 61bool ZkbConfig::error(const QXmlParseException& e) {
53 QString tmp; 62 QString tmp;
54 63
55 tmp.sprintf("%d: error: %s\n", e.lineNumber(), 64 tmp.sprintf("%d: error: %s\n", e.lineNumber(),
56 (const char*) e.message().utf8()); 65 (const char*) e.message().utf8());
57 66
58 err += tmp; 67 err += tmp;
@@ -63,7 +72,7 @@ bool ZkbConfig::error(const QXmlParseException& e) {
63bool ZkbConfig::fatalError(const QXmlParseException& e) { 72bool ZkbConfig::fatalError(const QXmlParseException& e) {
64 QString tmp; 73 QString tmp;
65 74
66 tmp.sprintf("%d: fatal error: %s\n", e.lineNumber(), 75 tmp.sprintf("%d: fatal error: %s\n", e.lineNumber(),
67 (const char*) e.message().utf8()); 76 (const char*) e.message().utf8());
68 77
69 err += tmp; 78 err += tmp;
@@ -76,7 +85,7 @@ QString ZkbConfig::errorString() {
76} 85}
77 86
78// Implementation of ZkbHandler 87// Implementation of ZkbHandler
79ZkbHandler::ZkbHandler(ZkbConfig& z, Keymap& k, const QString& p):zkc(z), keymap(k), 88ZkbHandler::ZkbHandler(ZkbConfig& z, Keymap& k, const QString& p):zkc(z), keymap(k),
80 prefix(p), ardelay(-1), arperiod(-1), currentState(0), currentAction(0) { 89 prefix(p), ardelay(-1), arperiod(-1), currentState(0), currentAction(0) {
81} 90}
82 91
@@ -90,7 +99,7 @@ bool ZkbHandler::startKeymapElement(int ard, int arp, const QString&) {
90 return true; 99 return true;
91} 100}
92 101
93bool ZkbHandler::startIncludeElement(const QString& file, 102bool ZkbHandler::startIncludeElement(const QString& file,
94 const QString& pref) { 103 const QString& pref) {
95 104
96 QString p = prefix; 105 QString p = prefix;
@@ -98,7 +107,7 @@ bool ZkbHandler::startIncludeElement(const QString& file,
98 if (!pref.isNull()) { 107 if (!pref.isNull()) {
99 p += pref + ":"; 108 p += pref + ":";
100 } 109 }
101 110
102 111
103 bool ret = zkc.load(file, keymap, p); 112 bool ret = zkc.load(file, keymap, p);
104 if (!ret) { 113 if (!ret) {
@@ -108,7 +117,7 @@ bool ZkbHandler::startIncludeElement(const QString& file,
108 return ret; 117 return ret;
109} 118}
110 119
111bool ZkbHandler::startLabelElement(const QString& label, 120bool ZkbHandler::startLabelElement(const QString& label,
112 const QString& state) { 121 const QString& state) {
113 122
114 if (!keymap.addLabel(label, prefix + state)) { 123 if (!keymap.addLabel(label, prefix + state)) {
@@ -119,20 +128,20 @@ bool ZkbHandler::startLabelElement(const QString& label,
119 return true; 128 return true;
120} 129}
121 130
122bool ZkbHandler::startStateElement(const QString& name, 131bool ZkbHandler::startStateElement(const QString& name,
123 const QString& parentName, bool dflt) { 132 const QString& parentName, bool dflt) {
124 133
125 currentStateName = prefix + name; 134 currentStateName = prefix + name;
126 currentState = keymap.getStateByName(currentStateName); 135 currentState = keymap.getStateByName(currentStateName);
127 136
128 //odebug << "state name=" << currentStateName.utf8() << "\n" << oendl; 137 //odebug << "state name=" << currentStateName.utf8() << "\n" << oendl;
129 138
130 State* parent = 0; 139 State* parent = 0;
131 if (!parentName.isEmpty()) { 140 if (!parentName.isEmpty()) {
132 QString pn = prefix + parentName; 141 QString pn = prefix + parentName;
133 parent = keymap.getStateByName(pn); 142 parent = keymap.getStateByName(pn);
134 if (parent == 0) { 143 if (parent == 0) {
135 err = currentStateName + 144 err = currentStateName +
136 ": undefined parent state: " + pn; 145 ": undefined parent state: " + pn;
137 return false; 146 return false;
138 } 147 }
@@ -167,7 +176,7 @@ bool ZkbHandler::startMapElement(int keycode, bool pressed) {
167 return true; 176 return true;
168} 177}
169 178
170bool ZkbHandler::startEventElement(int keycode, int unicode, int modifiers, 179bool ZkbHandler::startEventElement(int keycode, int unicode, int modifiers,
171 bool pressed, bool autorepeat) { 180 bool pressed, bool autorepeat) {
172 181
173 currentAction->setEvent(true); 182 currentAction->setEvent(true);
@@ -200,7 +209,7 @@ bool ZkbHandler::endKeymapElement() {
200 if (arperiod > 0) { 209 if (arperiod > 0) {
201 keymap.setAutorepeatPeriod(arperiod); 210 keymap.setAutorepeatPeriod(arperiod);
202 } 211 }
203 212
204 return true; 213 return true;
205} 214}
206 215