summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp199
1 files changed, 101 insertions, 98 deletions
diff --git a/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp b/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp
index 6f24ea0..f4005bb 100644
--- a/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp
+++ b/noncore/applets/zkbapplet/keyzcfg/cfgdlg.cpp
@@ -1,132 +1,135 @@
1 1
2#include <qdir.h> 2#include <qdir.h>
3#include <qregexp.h>
3#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
4#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
5#include <unistd.h> 6#include <unistd.h>
6#include "cfgdlg.h" 7#include "cfgdlg.h"
7 8
8CfgDlg::CfgDlg(QWidget* parent, CfgFile* cf, QApplication* app, bool mod): 9CfgDlg::CfgDlg(QWidget* parent, CfgFile* cf, QApplication* app, bool mod):
9 QDialog(parent, "CfgDlg", mod), cfile(cf), application(app) { 10 QDialog(parent, "CfgDlg", mod), cfile(cf), application(app) {
10 11
11 setCaption(tr("keyz configurator")); 12 setCaption(tr("keyz configurator"));
12 13
13 QGridLayout* gl = new QGridLayout(this, 7, 5, 5, 5); 14 static QRegExp r("^common.*\\.xml$");
14 15 static QRegExp r2("^zkb\\.xml$");
15 QLabel* flabel = new QLabel("Available Keymaps", this); 16 QGridLayout* gl = new QGridLayout(this, 7, 5, 5, 5);
16 files = new QListBox(this); 17
17 QPushButton* addButton = new QPushButton(">>", this); //add->setText("Add"); 18 QLabel* flabel = new QLabel("Available Keymaps", this);
18 connect(addButton, SIGNAL(clicked()), this, SLOT(add())); 19 files = new QListBox(this);
19 QLabel* klabel = new QLabel("Selected Keymaps", this); 20 QPushButton* addButton = new QPushButton(">>", this); //add->setText("Add");
20 keymaps = new QListBox(this); 21 connect(addButton, SIGNAL(clicked()), this, SLOT(add()));
21 connect(keymaps, SIGNAL(highlighted(const QString&)), this, SLOT(keymapHighlighted(const QString&))); 22 QLabel* klabel = new QLabel("Selected Keymaps", this);
22 QPushButton* delButton = new QPushButton("<<", this); //del->setText("Delete"); 23 keymaps = new QListBox(this);
23 connect(delButton, SIGNAL(clicked()), this, SLOT(del())); 24 connect(keymaps, SIGNAL(highlighted(const QString&)), this, SLOT(keymapHighlighted(const QString&)));
24 QPushButton* slabelButton = new QPushButton("Set Label", this); //apply->setText("Apply"); 25 QPushButton* delButton = new QPushButton("<<", this); //del->setText("Delete");
25 connect(slabelButton, SIGNAL(clicked()), this, SLOT(setLabel())); 26 connect(delButton, SIGNAL(clicked()), this, SLOT(del()));
26 QLabel* l = new QLabel("Label", this); 27 QPushButton* slabelButton = new QPushButton("Set Label", this); //apply->setText("Apply");
27 label = new QLineEdit(this); 28 connect(slabelButton, SIGNAL(clicked()), this, SLOT(setLabel()));
28 QLabel* adlabel = new QLabel("Auto Repeat Delay (ms)", this); 29 QLabel* l = new QLabel("Label", this);
29 QLabel* aplabel = new QLabel("Auto Repeat Period (ms)", this); 30 label = new QLineEdit(this);
30 ad = new QSpinBox(50, 5000, 5, this); 31 QLabel* adlabel = new QLabel("Auto Repeat Delay (ms)", this);
31 ap = new QSpinBox(0, 5000, 5, this); 32 QLabel* aplabel = new QLabel("Auto Repeat Period (ms)", this);
32 33 ad = new QSpinBox(50, 5000, 5, this);
33 //QLabel* adms = new QLabel("ms", this); 34 ap = new QSpinBox(0, 5000, 5, this);
34 //QLabel* apms = new QLabel("ms", this); 35
35 36// QLabel* adms = new QLabel("ms", this);
36 //QCheckBox* enable = new QCheckBox("Enable", t); 37// QLabel* apms = new QLabel("ms", this);
37 38
38 gl->setColStretch(0, 1); 39// QCheckBox* enable = new QCheckBox("Enable", t);
39 gl->setColStretch(1, 1); 40
40 gl->setColStretch(3, 1); 41 gl->setColStretch(0, 1);
41 gl->setColStretch(4, 1); 42 gl->setColStretch(1, 1);
42 gl->setRowStretch(3, 1); 43 gl->setColStretch(3, 1);
43 gl->addMultiCellWidget(flabel, 0, 0, 0, 1); 44 gl->setColStretch(4, 1);
44 gl->addMultiCellWidget(klabel, 0, 0, 3, 4); 45 gl->setRowStretch(3, 1);
45 gl->addMultiCellWidget(files, 1, 3, 0, 1); 46 gl->addMultiCellWidget(flabel, 0, 0, 0, 1);
46 gl->addMultiCellWidget(keymaps, 1, 3, 3, 4); 47 gl->addMultiCellWidget(klabel, 0, 0, 3, 4);
47 gl->addWidget(addButton, 1, 2); 48 gl->addMultiCellWidget(files, 1, 3, 0, 1);
48 gl->addWidget(delButton, 2, 2); 49 gl->addMultiCellWidget(keymaps, 1, 3, 3, 4);
49 50 gl->addWidget(addButton, 1, 2);
50 gl->addWidget(l, 4, 0); 51 gl->addWidget(delButton, 2, 2);
51 gl->addWidget(label, 4, 1); 52
52 gl->addMultiCellWidget(slabelButton, 4, 4, 3, 4); 53 gl->addWidget(l, 4, 0);
53 54 gl->addWidget(label, 4, 1);
54 gl->addMultiCellWidget(adlabel, 5, 5, 0, 2); 55 gl->addMultiCellWidget(slabelButton, 4, 4, 3, 4);
55 gl->addMultiCellWidget(ad, 5, 5, 3, 4); 56
56 //gl->addWidget(adms, 5, 3); 57 gl->addMultiCellWidget(adlabel, 5, 5, 0, 2);
57 58 gl->addMultiCellWidget(ad, 5, 5, 3, 4);
58 gl->addMultiCellWidget(aplabel, 6, 6, 0, 2); 59// gl->addWidget(adms, 5, 3);
59 gl->addMultiCellWidget(ap, 6, 6, 3, 4); 60
60 61 gl->addMultiCellWidget(aplabel, 6, 6, 0, 2);
61 //gl->addWidget(apms, 6, 3); 62 gl->addMultiCellWidget(ap, 6, 6, 3, 4);
62 63
63 QList<CfgEntry>& e = cfile->getEntries(); 64// gl->addWidget(apms, 6, 3);
64 65
65 for(uint i = 0; i < e.count(); i++) { 66 QList<CfgEntry>& e = cfile->getEntries();
66 CfgEntry* entry = e.at(i); 67
67 keymaps->insertItem(entry->getFile()); 68 for(uint i = 0; i < e.count(); i++) {
68 m.insert(entry->getFile(), entry->getLabel()); 69 CfgEntry* entry = e.at(i);
69 } 70 keymaps->insertItem(entry->getFile());
70 71 m.insert(entry->getFile(), entry->getLabel());
71 QDir dir(QPEApplication::qpeDir()+"share/zkb", "*.xml"); 72 }
72 QStringList flist = dir.entryList(); 73
73 QStringList::Iterator sit; 74 QDir dir(QPEApplication::qpeDir()+"share/zkb", "*.xml");
74 for(sit = flist.begin(); sit != flist.end(); ++sit) { 75 QStringList flist = dir.entryList();
75 if (*sit != "common.xml" && *sit != "zkb.xml" && m.find(*sit) == m.end()) { 76 QStringList::Iterator sit;
76 files->insertItem(*sit); 77 for(sit = flist.begin(); sit != flist.end(); ++sit) {
77 } 78 if (r.match(*sit)==-1 && r2.match(*sit)==-1&& m.find(*sit) == m.end()) {
78 } 79 files->insertItem(*sit);
79 80 }
80 ad->setValue(cfile->getAutorepeatDelay()); 81 }
81 ap->setValue(cfile->getAutorepeatPeriod()); 82
82 83 ad->setValue(cfile->getAutorepeatDelay());
83 //gl->addMultiCellWidget(enable, 7, 7, 0, 4); 84 ap->setValue(cfile->getAutorepeatPeriod());
85
86// gl->addMultiCellWidget(enable, 7, 7, 0, 4);
84} 87}
85 88
86CfgDlg::~CfgDlg() { 89CfgDlg::~CfgDlg() {
87} 90}
88 91
89void CfgDlg::add() { 92void CfgDlg::add() {
90 if (!files->currentText().isEmpty()) { 93 if (!files->currentText().isEmpty()) {
91 QString t = files->currentText(); 94 QString t = files->currentText();
92 files->removeItem(files->currentItem()); 95 files->removeItem(files->currentItem());
93 keymaps->insertItem(t); 96 keymaps->insertItem(t);
94 cfile->replaceEntry(t, ""); 97 cfile->replaceEntry(t, "");
95 m.replace(t, ""); 98 m.replace(t, "");
96 } 99 }
97} 100}
98 101
99void CfgDlg::del() { 102void CfgDlg::del() {
100 if (!keymaps->currentText().isEmpty()) { 103 if (!keymaps->currentText().isEmpty()) {
101 QString t = keymaps->currentText(); 104 QString t = keymaps->currentText();
102 keymaps->removeItem(keymaps->currentItem()); 105 keymaps->removeItem(keymaps->currentItem());
103 cfile->deleteEntry(t); 106 cfile->deleteEntry(t);
104 files->insertItem(t); 107 files->insertItem(t);
105 m.remove(files->currentText()); 108 m.remove(files->currentText());
106 } 109 }
107} 110}
108 111
109void CfgDlg::setLabel() { 112void CfgDlg::setLabel() {
110 if (!keymaps->currentText().isEmpty()) { 113 if (!keymaps->currentText().isEmpty()) {
111 cfile->replaceEntry(keymaps->currentText(), 114 cfile->replaceEntry(keymaps->currentText(),
112 label->text()); 115 label->text());
113 m.replace(keymaps->currentText(), label->text()); 116 m.replace(keymaps->currentText(), label->text());
114 } 117 }
115} 118}
116 119
117void CfgDlg::keymapHighlighted(const QString&text) { 120void CfgDlg::keymapHighlighted(const QString&text) {
118 label->setText(*m.find(text)); 121 label->setText(*m.find(text));
119} 122}
120 123
121 124
122void CfgDlg::accept() { 125void CfgDlg::accept() {
123 cfile->setAutorepeatDelay(ad->value()); 126 cfile->setAutorepeatDelay(ad->value());
124 cfile->setAutorepeatPeriod(ap->value()); 127 cfile->setAutorepeatPeriod(ap->value());
125 128
126 CfgParser p; 129 CfgParser p;
127 p.save(Global::applicationFileName("zkb", "zkb.xml" ), *cfile); 130 p.save(Global::applicationFileName("zkb", "zkb.xml" ), *cfile);
128 QCopEnvelope("QPE/zkb", "reload()"); 131 QCopEnvelope("QPE/zkb", "reload()");
129 132
130 QDialog::accept(); 133 QDialog::accept();
131} 134}
132 135