author | hash <hash> | 2002-10-24 17:39:47 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-24 17:39:47 (UTC) |
commit | b01703c4b1de7006c88aa814ca00472b966b2464 (patch) (side-by-side diff) | |
tree | 9d0f4e708646ddbf1a0198f1ac2dd4b67e2c45fa /noncore/apps | |
parent | 1364899f2b250d1605e1a49cb7c65ce950c57fda (diff) | |
download | opie-b01703c4b1de7006c88aa814ca00472b966b2464.zip opie-b01703c4b1de7006c88aa814ca00472b966b2464.tar.gz opie-b01703c4b1de7006c88aa814ca00472b966b2464.tar.bz2 |
i think it loads according to the session properly now
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 43 | ||||
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 6 |
3 files changed, 48 insertions, 8 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 @@ -54,16 +54,52 @@ 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); @@ -272,8 +308,11 @@ 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 */ @@ -319,10 +358,8 @@ void FunctionKeyboardConfig::save (Profile& prof) { 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); diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h index 80d9f29..a60ff4b 100644 --- a/noncore/apps/opie-console/function_keyboard.h +++ b/noncore/apps/opie-console/function_keyboard.h @@ -44,9 +44,10 @@ public: void changeRows(int); void changeCols(int); - //Key getKey(int, int); + void load(const Profile &); + void loadDefaults(); void paintEvent(QPaintEvent *); void paintKey(uint, uint); void mousePressEvent(QMouseEvent*); @@ -57,12 +58,8 @@ public: signals: void keyPressed(FKey, ushort, ushort, bool); -private: - - void loadDefaults(); - private: // thie key for the map is the row/col diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index b177fa5..745efaf 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -406,8 +406,10 @@ void MainWindow::slotClose() { m_runScript->setEnabled( false ); m_fullscreen->setEnabled( false ); m_closewindow->setEnabled( false ); } + + m_kb->loadDefaults(); } /* * We will get the name @@ -455,8 +457,10 @@ void MainWindow::create( const Profile& prof ) { QWidget *w = currentSession()->widget(); if(w) w->setFocus(); + + m_kb->load(currentSession()->profile()); } void MainWindow::slotTransfer() { @@ -518,8 +522,10 @@ void MainWindow::slotSessionChanged( Session* ses ) { QWidget *w = m_curSession->widget(); if(w) w->setFocus(); + + m_kb->load(currentSession()->profile()); } } void MainWindow::slotFullscreen() { |