Diffstat (limited to 'noncore/apps/opie-console/function_keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index 3da8d61..ce65052 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp @@ -46,32 +46,68 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) : */ if (keys.isEmpty()) loadDefaults(); } FunctionKeyboard::~FunctionKeyboard() {} void FunctionKeyboard::changeRows(int r) { numRows = r; - repaint(false); + + // have to do this so the whole thing gets redrawn + hide(); show(); } void FunctionKeyboard::changeCols(int c) { numCols = c; keyWidth = (double)width()/numCols; // have to reset this thing too repaint(false); } +void FunctionKeyboard::load (const Profile& prof) { + + keys.clear(); + + numRows = prof.readNumEntry("keb_rows", 2); + numCols = prof.readNumEntry("keb_cols", 10); + keyWidth = (double)width()/numCols; // have to reset this thing too + + /* load all the keys to the keyboard */ + for (ushort i = 0; i <= numRows - 1; i++) + for (ushort j = 0; j <= numCols - 1; j++) { + + QString h = "r" + QString::number(i) + "c" + QString::number(j); + QString values = prof.readEntry("keb_" + h); + + if (!values.isEmpty()) { + + QStringList l = QStringList::split(QChar('|'), values, TRUE); + keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); + + // load pixmap if used + if (!l[1].isEmpty()) { + + keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); + } + } + } + + if (keys.isEmpty()) loadDefaults(); + + hide(); + show(); + +} void FunctionKeyboard::paintEvent(QPaintEvent *e) { QPainter p(this); p.setClipRect(e->rect()); p.fillRect(0, 0, width(), height(), QColor(255,255,255)); p.setPen(QColor(0,0,0)); /* those decimals do count! becomes short if use plain int */ for (double i = 0; i <= width(); i += keyWidth) { @@ -264,24 +300,27 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); QVBoxLayout *root = new QVBoxLayout(this, 2); root->addWidget(kb); root->addWidget(dimentions); root->addWidget(editKey); } FunctionKeyboardConfig::~FunctionKeyboardConfig() { } void FunctionKeyboardConfig::load (const Profile& prof) { + kb->keys.clear(); + kb->loadDefaults(); + m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); /* load all the keys to the keyboard */ for (int i = 0; i <= m_rowBox->value() -1; i++) for (int j = 0; j <= m_colBox->value() -1; j++) { QString h = "r" + QString::number(i) + "c" + QString::number(j); QString values = prof.readEntry("keb_" + h); if (!values.isEmpty()) { @@ -311,26 +350,24 @@ void FunctionKeyboardConfig::save (Profile& prof) { + QString::number(k.qcode) + "|" + QString::number(k.unicode); prof.writeEntry("keb_" + it.key(), entry); } } void FunctionKeyboardConfig::slotChangeRows(int r) { kb->changeRows(r); - // have to do this so the whole thing gets redrawn - kb->hide(); kb->show(); } void FunctionKeyboardConfig::slotChangeCols(int c) { kb->changeCols(c); } void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { if (!pressed) return; selectedHandle = "r" + QString::number(r) + "c" + QString::number(c); selectedRow = r; |