summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/configdlg.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/multikey/configdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp54
1 files changed, 46 insertions, 8 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index ac132d3..1e104a6 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -1,9 +1,10 @@
/*
* TODO
* make a font selection thing (size too)
+ * make a cursor thing
*
*
*
*/
#include <iostream.h>
@@ -21,17 +22,19 @@
#include <qcheckbox.h>
#include <qsizepolicy.h>
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qstringlist.h>
#include <opie/ofiledialog.h>
+#include <opie/colordialog.h>
#include <qdir.h>
#include <qfileinfo.h>
#include "configdlg.h"
#include "keyboard.h"
+// ConfigDlg::ConfigDlg() {{{1
ConfigDlg::ConfigDlg () : QTabWidget ()
{
setCaption( tr("Multikey Configuration") );
Config config ("multikey");
config.setGroup("keymaps");
QString current_map = config.readEntry("current", 0);
@@ -101,12 +104,14 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
add_button = new QPushButton(tr("Add"), add_remove_grid);
add_button->setFlat((bool)1);
connect(add_button, SIGNAL(clicked()), SLOT(addMap()));
remove_button = new QPushButton(tr("Remove"), add_remove_grid);
remove_button->setFlat((bool)1);
+ if ((int)map_dir.count() >= keymaps->currentItem())
+ remove_button->setDisabled(true);
connect(remove_button, SIGNAL(clicked()), SLOT(removeMap()));
pick_button = new QCheckBox(tr("Pickboard"), gen_box);
config.setGroup ("pickboard");
bool pick_open = config.readBoolEntry ("open", "0"); // default closed
@@ -126,18 +131,31 @@ ConfigDlg::ConfigDlg () : QTabWidget ()
color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
color_box->setMargin(3);
color_box->setSpacing(3);
addTab(color_box, tr("Colors"));
QLabel *label;
+ QStringList color;
label = new QLabel(tr("Key Color"), color_box);
- QPushButton *button = new QPushButton(color_box);
- button->setFlat((bool)1);
+ key_color_button = new QPushButton(color_box);
+ connect(key_color_button, SIGNAL(clicked()), SLOT(keyColorButtonClicked()));
+ key_color_button->setFlat((bool)1);
+
+ config.setGroup("colors");
+ color = config.readListEntry("keycolor", QChar(','));
+ if (color.isEmpty()) {
+ color = QStringList::split(",", "240,240,240");
+ config.writeEntry("keycolor", color.join(","));
+
+ }
+ key_color_button->setBackgroundColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
+
+
label = new QLabel(tr("Key Pressed Color"), color_box);
- button = new QPushButton(color_box);
+ QPushButton *button = new QPushButton(color_box);
button->setFlat((bool)1);
label = new QLabel(tr("Line Color"), color_box);
button = new QPushButton(color_box);
button->setFlat((bool)1);
label = new QLabel(tr("Text Color"), color_box);
button = new QPushButton(color_box);
@@ -161,50 +179,50 @@ void ConfigDlg::pickTog() {
* the index is kinda screwy, because in the config file, index 0 is just the
* first element in the QStringList, but here it's the "Current Language"
* listItem. therefor you have to minus one to the index before you access it.
*
*/
+// ConfigDlg::setMap {{{1
void ConfigDlg::setMap(int index) {
if (index == 0) {
remove_button->setDisabled(true);
-
emit setMapToDefault();
}
else if ((uint)index <= default_maps.count()) {
remove_button->setDisabled(true);
-
emit setMapToFile(keymaps->text(index));
} else {
remove_button->setEnabled(true);
-
emit setMapToFile(keymaps->text(index));
}
}
+// ConfigDlg::addMap() {{{1
void ConfigDlg::addMap() {
QString map = OFileDialog::getOpenFileName(1, QDir::home().absPath());
Config config ("multikey");
config.setGroup("keymaps");
QStringList maps = config.readListEntry("maps", QChar('|'));
maps.append(map);
keymaps->insertItem(map);
keymaps->setSelected(keymaps->count() - 1, true);
- config.writeEntry("maps", maps.join("|"));
+ config.writeEntry("maps", maps, QChar('|'));
config.writeEntry("current", map);
}
+// ConfigDlg::removeMap() {{{1
void ConfigDlg::removeMap() {
cout << "removing : " << custom_maps[keymaps->currentItem() - default_maps.count() - 1] << "\n";
cout << "currentItem : " << keymaps->currentItem() << "\n";
// move selection up one
@@ -214,8 +232,28 @@ void ConfigDlg::removeMap() {
custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]);
// write the changes
Config config ("multikey");
config.setGroup("keymaps");
- config.writeEntry("maps", custom_maps.join("|"));
+ config.writeEntry("maps", custom_maps, QChar('|'));
+}
+
+// ConfigDlg::color {{{1
+void ConfigDlg::keyColorButtonClicked() {
+
+ Config config ("multikey");
+ config.setGroup ("colors");
+
+ QStringList color = config.readListEntry("keycolor", QChar(','));
+
+ QColor newcolor = OColorDialog::getColor(QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()));
+
+ color[0].setNum(newcolor.red());
+ color[1].setNum(newcolor.green());
+ color[2].setNum(newcolor.blue());
+
+ config.writeEntry("keycolor", color, QChar(','));
+
+ key_color_button->setBackgroundColor(newcolor);
+ emit reloadKeyboard();
}