-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 1 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index 1e104a6..59a290b 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp @@ -128,132 +128,133 @@ ConfigDlg::ConfigDlg () : QTabWidget () */ QGrid *color_box = new QGrid(2, this); 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); 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); 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); button->setFlat((bool)1); label = new QLabel("", color_box); // a spacer so the above buttons dont expand label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); } void ConfigDlg::pickTog() { Config config ("multikey"); config.setGroup ("pickboard"); config.writeEntry ("open", pick_button->isChecked()); // default closed emit pickboardToggled(pick_button->isChecked()); } /* * 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, 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 keymaps->setSelected(keymaps->currentItem() - 1, true); // delete the next selected item cus you just moved it up keymaps->removeItem(keymaps->currentItem() + 1); custom_maps.remove(custom_maps[keymaps->currentItem() - default_maps.count()]); // write the changes Config config ("multikey"); config.setGroup("keymaps"); 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(',')); + config.write(); key_color_button->setBackgroundColor(newcolor); emit reloadKeyboard(); } diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 68918a6..8280297 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp @@ -423,257 +423,257 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*) clearHighlight(); } /* Keyboard::timerEvent {{{1 */ /* void Keyboard::timerEvent(QTimerEvent* e) { if ( e->timerId() == pressTid ) { killTimer(pressTid); pressTid = 0; if ( !pressed ) cout << "calling clearHighlight from timerEvent\n"; clearHighlight(); } } */ void Keyboard::repeat() { repeatTimer->start( 200 ); emit key( unicode, 0, modifiers, true, true ); } void Keyboard::clearHighlight() { if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { int tmpRow = pressedKeyRow; int tmpCol = pressedKeyCol; pressedKeyRow = -1; pressedKeyCol = -1; QPainter p(this); drawKeyboard(p, tmpRow, tmpCol); } } /* Keyboard::sizeHint {{{1 */ QSize Keyboard::sizeHint() const { QFontMetrics fm=fontMetrics(); int keyHeight = fm.lineSpacing() + 2; return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); } void Keyboard::resetState() { schar = mchar = echar = 0; picks->resetState(); } /* Keyboard::togglePickboard {{{1 */ void Keyboard::togglePickboard(bool on_off) { usePicks = on_off; if (usePicks) { picks->show(); //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send //adjustSize(); QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); } else { picks->hide(); picks->resetState(); //move(x(), y() + picks->height()); //adjustSize(); QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); } /* * this closes && opens the input method */ QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); } /* Keyboard::setMapTo ... {{{1 */ void Keyboard::setMapToDefault() { /* load current locale language map */ Config *config = new Config("locale"); config->setGroup( "Language" ); QString l = config->readEntry( "Language" , "en" ); delete config; QString key_map = QPEApplication::qpeDir() + "/share/multikey/" + l + ".keymap"; /* save change to multikey config file */ config = new Config("multikey"); config->setGroup ("keymaps"); config->writeEntry ("current", key_map); // default closed delete config; delete keys; keys = new Keys(key_map); // have to repaint the keyboard repaint(FALSE); } void Keyboard::setMapToFile(QString map) { /* save change to multikey config file */ Config *config = new Config("multikey"); config->setGroup ("keymaps"); config->writeEntry ("current", map); // default closed delete config; delete keys; if (QFile(map).exists()) keys = new Keys(map); else keys = new Keys(); repaint(FALSE); } -/* Keybaord::setColor {{{1 */ +/* Keybaord::reloadKeyboard {{{1 */ void Keyboard::reloadKeyboard() { // reload colors and redraw loadKeyboardColors(); repaint(); } void Keyboard::loadKeyboardColors() { Config config ("multikey"); config.setGroup("colors"); QStringList color; color = config.readListEntry("keycolor", QChar(',')); if (color.isEmpty()) { color = QStringList::split(",", "240,240,240"); config.writeEntry("keycolor", color.join(",")); } keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); color = config.readListEntry("keycolor_pressed", QChar(',')); if (color.isEmpty()) { color = QStringList::split(",", "171,183,198"); config.writeEntry("keycolor_pressed", color.join(",")); } keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); color = config.readListEntry("keycolor_lines", QChar(',')); if (color.isEmpty()) { color = QStringList::split(",", "138,148,160"); config.writeEntry("keycolor_lines", color.join(",")); } keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); color = config.readListEntry("textcolor", QChar(',')); if (color.isEmpty()) { color = QStringList::split(",", "43,54,68"); config.writeEntry("textcolor", color.join(",")); } textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); } /* korean input functions {{{1 * * TODO * one major problem with this implementation is that you can't move the * cursor after inputing korean chars, otherwise it will eat up and replace * the char before the cursor you move to. fix that * * make backspace delete one single char, not the whole thing if still * editing. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * how korean input works * * all following chars means unicode char value and are in hex * * ÃÊÀ½ = schar (start char) * ÁßÀ½ = mchar (middle char) * ³¡À½ = echar (end char) * * there are 19 schars. unicode position is at 1100 - 1112 * there are 21 mchars. unicode position is at 1161 - 1175 * there are 27 echars. unicode position is at 11a8 - 11c2 * * the map with everything combined is at ac00 - d7a3 * */ ushort Keyboard::parseKoreanInput (ushort c) { if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) || (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { schar = 0, mchar = 0, echar = 0; return c; } if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input if (schar == 0 || (schar != 0 && mchar == 0)) { schar = c; mchar = 0; echar = 0; return c; } else if (mchar != 0) { if (echar == 0) { if (!(echar = constoe(c))) { schar = c; mchar = 0; echar = 0; return c; } } else { // must figure out what the echar is if (echar == 0x11a8) { // ¤¡ if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ else { schar = c; mchar = 0; echar = 0; return c; } } else if (echar == 0x11ab) { // ¤¤ if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ else { schar = c; mchar = 0; echar = 0; return c; } } else if (echar == 0x11af) { // ¤© if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± |