author | hash <hash> | 2002-10-24 17:56:48 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-24 17:56:48 (UTC) |
commit | 3773cd825129f1cc6fa7a4ecb4129634f5189984 (patch) (side-by-side diff) | |
tree | d10cc2c4e45e2b47eddcae5534f59ce8f90092b1 | |
parent | b01703c4b1de7006c88aa814ca00472b966b2464 (diff) | |
download | opie-3773cd825129f1cc6fa7a4ecb4129634f5189984.zip opie-3773cd825129f1cc6fa7a4ecb4129634f5189984.tar.gz opie-3773cd825129f1cc6fa7a4ecb4129634f5189984.tar.bz2 |
closing a session returns keyboard to default better now
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index ce65052..5f3b5ec 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp @@ -1,67 +1,70 @@ #include "function_keyboard.h" #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qsizepolicy.h> #include <qevent.h> #include <qwindowsystem_qws.h> #include <qapplication.h> #include <qlayout.h> #include <qspinbox.h> #include <qlistbox.h> #include <qlabel.h> #include <qcombobox.h> #include <qdir.h> +#define DEFAULT_ROWS 2 +#define DEFAULT_COLS 11 + /* FunctionKeyboard {{{1 */ FunctionKeyboard::FunctionKeyboard(QWidget *parent) : - QFrame(parent), numRows(2), numCols(11), + QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS), pressedRow(0), pressedCol(0) { setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); /* * all the saving/loading is now done in a profile. downside is that you cant modify * the keyboard for all profiles, but must do it on a profile-basis * Config conf("opie-console-keys"); conf.setGroup("keys"); for (uint r = 0; r < numRows; r++) for (uint c = 0; c < numCols; c++) { QString handle = "r" + QString::number(r) + "c" + QString::number(c); QStringList value_list = conf.readListEntry( handle, '|'); if (value_list.isEmpty()) continue; keys.insert( handle, FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) ); } //qWarning("loaded %d keys", keys.count()); */ if (keys.isEmpty()) loadDefaults(); } FunctionKeyboard::~FunctionKeyboard() {} void FunctionKeyboard::changeRows(int r) { numRows = r; // 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); } @@ -178,96 +181,100 @@ void FunctionKeyboard::paintKey(uint row, uint col) { } } void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { pressedRow = e->y() / keyHeight; pressedCol = (int) (e->x() / keyWidth); paintKey(pressedRow, pressedCol); // emit that sucker! FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; emit keyPressed(k, pressedRow, pressedCol, 1); } void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { if (pressedRow != -1 && pressedRow != -1) { int row = pressedRow; pressedRow = -1; int col = pressedCol; pressedCol = -1; paintKey(row, col); FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; emit keyPressed(k, row, col, 0); } } void FunctionKeyboard::resizeEvent(QResizeEvent*) { /* set he default font height/width */ QFontMetrics fm=fontMetrics(); keyHeight = fm.lineSpacing() + 2; keyWidth = (double)width()/numCols; } QSize FunctionKeyboard::sizeHint() const { return QSize(width(), keyHeight * numRows + 1); } void FunctionKeyboard::loadDefaults() { + numRows = DEFAULT_ROWS; + numCols = DEFAULT_COLS; + keyWidth = (double)width()/numCols; // have to reset this thing too + keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); keys.insert( "r0c9", FKey ("PU", 0, 4118, 0)); keys.insert( "r0c10", FKey ("PD", 0, 4119, 0)); keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); } /* FunctionKeyboardConfig {{{1 */ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) : ProfileDialogKeyWidget(name, parent, na), selectedRow(0), selectedCol(0) { qWarning("FunctionKeyboardConfig"); kb = new FunctionKeyboard(this); connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); QLabel *l = new QLabel("Rows", dimentions); m_rowBox = new QSpinBox(1, 15, 1, dimentions); connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); l = new QLabel("Columns", dimentions); m_colBox = new QSpinBox(1, 15, 1, dimentions); connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); |