summaryrefslogtreecommitdiff
path: root/noncore
authorhash <hash>2002-10-24 17:39:47 (UTC)
committer hash <hash>2002-10-24 17:39:47 (UTC)
commitb01703c4b1de7006c88aa814ca00472b966b2464 (patch) (side-by-side diff)
tree9d0f4e708646ddbf1a0198f1ac2dd4b67e2c45fa /noncore
parent1364899f2b250d1605e1a49cb7c65ce950c57fda (diff)
downloadopie-b01703c4b1de7006c88aa814ca00472b966b2464.zip
opie-b01703c4b1de7006c88aa814ca00472b966b2464.tar.gz
opie-b01703c4b1de7006c88aa814ca00472b966b2464.tar.bz2
i think it loads according to the session properly now
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp43
-rw-r--r--noncore/apps/opie-console/function_keyboard.h7
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp6
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
@@ -34,56 +34,92 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
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;
- 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) {
p.drawLine((int)i, 0, (int)i, height());
}
// sometimes the last line doesnt get drawn
p.drawLine(width() -1, 0, width() -1, height());
for (int i = 0; i <= height(); i += keyHeight) {
p.drawLine(0, i, width(), i);
}
for (uint r = 0; r < numRows; r++) {
@@ -252,97 +288,98 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par
l = new QLabel("Q Keycode", editKey);
m_qvalues = new QComboBox(true, editKey);
m_qvalues->setInsertionPolicy(QComboBox::AtTop);
m_qvalues->setDuplicatesEnabled(false);
m_qvalues->insertItem("");
connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&)));
l = new QLabel("Unicode Value", editKey);
m_uniValues = new QComboBox(true, editKey);
m_uniValues->setInsertionPolicy(QComboBox::AtTop);
m_uniValues->setDuplicatesEnabled(false);
m_uniValues->insertItem("");
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()) {
QStringList l = QStringList::split(QChar('|'), values, TRUE);
kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
// load pixmap if used
if (!l[1].isEmpty()) {
kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
}
}
}
}
void FunctionKeyboardConfig::save (Profile& prof) {
prof.writeEntry("keb_rows", m_rowBox->value());
prof.writeEntry("keb_cols", m_colBox->value());
QMap<QString, FKey>::Iterator it;
for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
FKey k = it.data();
QString entry = k.label + "|"
+ k.pixFile + "|"
+ 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;
selectedCol = c;
if (k.pixFile.isEmpty()) {
m_labels->setEditable(true);
m_labels->setCurrentItem(0);
m_labels->changeItem(k.label, 0);
} else {
// any better way to select the pixmap?
m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile)));
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
@@ -24,65 +24,62 @@ struct FKey {
pix = new QPixmap ( Resource::loadPixmap("console/keys/" + f ) );
}
};
QString label;
QPixmap *pix;
QString pixFile;
ushort qcode;
ushort unicode;
};
class FunctionKeyboard : public QFrame {
Q_OBJECT
public:
FunctionKeyboard(QWidget *parent = 0);
~FunctionKeyboard();
friend class FunctionKeyboardConfig;
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*);
void mouseReleaseEvent(QMouseEvent*);
void resizeEvent(QResizeEvent*);
QSize sizeHint() const;
signals:
void keyPressed(FKey, ushort, ushort, bool);
-private:
-
- void loadDefaults();
-
private:
// thie key for the map is the row/col
QMap<QString, FKey> keys;
uint numRows;
int test;
uint numCols;
uint keyHeight;
double keyWidth; // decimal point matters!
int pressedRow, pressedCol;
QObject *parent;
};
class FunctionKeyboardConfig : public ProfileDialogKeyWidget {
Q_OBJECT
public:
FunctionKeyboardConfig(const QString& name, QWidget *wid, const char* name = 0l );
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
@@ -386,48 +386,50 @@ void MainWindow::slotConfigure() {
void MainWindow::slotClose() {
if (!currentSession() )
return;
Session* ses = currentSession();
qWarning("removing! currentSession %s", currentSession()->name().latin1() );
/* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
m_curSession = NULL;
tabWidget()->remove( /*currentSession()*/ses );
/*it's autodelete */
m_sessions.remove( ses );
qWarning("after remove!!");
if (!currentSession() ) {
m_connect->setEnabled( false );
m_disconnect->setEnabled( false );
m_terminate->setEnabled( false );
m_transfer->setEnabled( false );
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_runScript->setEnabled( false );
m_fullscreen->setEnabled( false );
m_closewindow->setEnabled( false );
}
+
+ m_kb->loadDefaults();
}
/*
* We will get the name
* Then the profile
* and then we will make a profile
*/
void MainWindow::slotProfile( int id) {
Profile prof = manager()->profile( m_sessionsPop->text( id) );
create( prof );
}
void MainWindow::create( const Profile& prof ) {
Session *ses = manager()->fromProfile( prof, tabWidget() );
if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
{
QMessageBox::warning(this,
QObject::tr("Session failed"),
QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
//if(ses) delete ses;
return;
}
m_sessions.append( ses );
@@ -435,48 +437,50 @@ void MainWindow::create( const Profile& prof ) {
tabWidget()->repaint();
m_curSession = ses;
// dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
m_terminate->setEnabled( true );
m_fullscreen->setEnabled( true );
m_closewindow->setEnabled( true );
m_transfer->setEnabled( false );
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_runScript->setEnabled( false );
// is io_layer wants direct connection, then autoconnect
//if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
if (prof.autoConnect()) {
slotConnect();
}
QWidget *w = currentSession()->widget();
if(w) w->setFocus();
+
+ m_kb->load(currentSession()->profile());
}
void MainWindow::slotTransfer()
{
if ( currentSession() ) {
TransferDialog dlg(currentSession()->widgetStack(), this);
dlg.showMaximized();
//currentSession()->widgetStack()->add(dlg);
dlg.exec();
}
}
void MainWindow::slotOpenKeb(bool state) {
if (state) m_keyBar->show();
else m_keyBar->hide();
}
void MainWindow::slotOpenButtons( bool state ) {
if ( state ) {
@@ -498,48 +502,50 @@ void MainWindow::slotSessionChanged( Session* ses ) {
m_disconnect->setEnabled( true );
m_recordScript->setEnabled( true );
m_saveScript->setEnabled( true );
m_runScript->setEnabled( true );
} else {
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_runScript->setEnabled( false );
}
if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
m_transfer->setEnabled( false );
} else {
m_transfer->setEnabled( true );
}
QWidget *w = m_curSession->widget();
if(w) w->setFocus();
+
+ m_kb->load(currentSession()->profile());
}
}
void MainWindow::slotFullscreen() {
if ( m_isFullscreen ) {
( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
( m_curSession->emulationHandler() )->cornerButton()->hide();
disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
} else {
savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
, QPoint(0,0), false );
( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
( m_curSession->widgetStack() )->setFocus();
( m_curSession->widgetStack() )->show();
( ( m_curSession->emulationHandler() )->cornerButton() )->show();