From e61097b8881bc7e72a5499816cb1199ea274a3ca Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Thu, 7 Oct 2010 22:54:10 +0200 Subject: Rework template meta-magic - No more implicit dependency on Boost.MPL - Better documentation for template magic - Move input handler policies to handler definitions where they belong - Separate out event descriptions from handlers --- src/gui/frame.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/frame.cpp b/src/gui/frame.cpp index 1b80c3d..12ce6b5 100644 --- a/src/gui/frame.cpp +++ b/src/gui/frame.cpp @@ -19,7 +19,6 @@ */ #include -#include #include "frame.h" #include #include @@ -434,19 +433,18 @@ void Frame::sendInputEvent(InputEvent const& evt) { QString str; eventToString(evt, str); - std::string evtStr = evt.toString(); PVSMsg msg(PVSCOMMAND, "INPUTEVENT", str); if(_remoteControlEnabled) { if(_remoteControlToAll) { - ConsoleLog writeLine(QString("sendInputEvent(%1) to one").arg(evtStr.c_str())); + ConsoleLog writeLine(QString("sendInputEvent(%1) to one").arg(evt.toString())); PVSConnectionManager::getManager()->getServer()->sendToAll(msg); } else { - ConsoleLog writeLine(QString("sendInputEvent(%1) to all").arg(evtStr.c_str())); + ConsoleLog writeLine(QString("sendInputEvent(%1) to all").arg(evt.toString())); _cFrame->getConnection()->sendMessage(msg); } } @@ -592,14 +590,14 @@ void Frame::showSpecialEventMenu() { qDebug("Trying to show menu..."); QMenu* menu = new QMenu(this); - QList specialEvents = privileged_handler_chain::describe(); - QList::iterator iter; + QList specialEvents = SpecialInputEventDescription::describeSpecialEvents(); + QListIterator iter(specialEvents); int i; - for(i = 0, iter = specialEvents.begin(); - iter != specialEvents.end(); - iter++, i++) + for(i = 0; + iter.hasNext(); + i++) { - QAction* act = menu->addAction((*iter).descriptionString); + QAction* act = menu->addAction(iter.next().description); act->setData(i); } QAction* selected = menu->exec(QCursor::pos()); -- cgit v1.2.3-55-g7522 From d75d1a3e507e6a4cc01367df4d7a77012819b95b Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Sun, 10 Oct 2010 22:09:29 +0200 Subject: Fix bug where pressing the closeUp-button sometimes results in no action. --- src/gui/frame.cpp | 29 +++++++++++- src/gui/frame.h | 3 ++ src/gui/mainWindow.cpp | 119 +++++++++++++++++++++++++++++-------------------- src/gui/mainWindow.h | 2 + 4 files changed, 102 insertions(+), 51 deletions(-) (limited to 'src/gui') diff --git a/src/gui/frame.cpp b/src/gui/frame.cpp index 12ce6b5..b9899d8 100644 --- a/src/gui/frame.cpp +++ b/src/gui/frame.cpp @@ -47,10 +47,12 @@ Frame::Frame(const QString & text, QWidget * parent) : _isLocked = false; _dozent = false; _uy = _ux = 0; + _isCloseUp = false; //QIcon icon; //icon.addFile(QString::fromUtf8(), QSize(), QIcon::Normal, QIcon::Off); button_closeUp = createToolButton(tr("View"), QIcon(":/restore"),SLOT(closeUp())); + button_closeUp->setCheckable(true); button_foto = createToolButton(tr("Foto"), QIcon(":/photos"),SLOT(foto())); button_lock = createToolButton(tr("Lock this client"), QIcon(":/lock"),SLOT(setLock())); //button_unlock = createToolButton(tr("Unlock this client"), QIcon(":/lock"),SLOT(setLock())); @@ -333,7 +335,11 @@ QImage Frame::getImageForFoto() void Frame::closeUp() { emit clicked(); - MainWindow::getWindow()->closeUp(); + + if(_isCloseUp) + MainWindow::getWindow()->unCloseUp(getConFrame()); + else + MainWindow::getWindow()->closeUp(getConFrame()); } void Frame::foto() @@ -377,6 +383,12 @@ void Frame::setDozent() } } +void Frame::setCloseUp(bool value) +{ + _isCloseUp = value; + button_closeUp->setChecked(value); +} + void Frame::remoteControlClicked() { if(_remoteControlEnabled) @@ -517,7 +529,20 @@ void Frame::keyPressEvent(QKeyEvent* event) { // The action of the keyboard may depend on the position of the pointer sendMouseMotionEvent(); - sendInputEvent(InputEvent::keyboardPress(event->key(), event->modifiers())); + + int key = event->key(); + + if(key >= ' ' && key < 0x100) + { + // the key is a Latin1 key. We need to find out the correct code to send. + QString text = event->text(); + if(text.length() == 1 && text.at(0).row() == 0) + { + // We found a Latin1 char and pray it is the correct case. + key = text.at(0).cell(); + } + } + sendInputEvent(InputEvent::keyboardPress(key, event->modifiers())); } } else diff --git a/src/gui/frame.h b/src/gui/frame.h index 8271670..4a3dd11 100644 --- a/src/gui/frame.h +++ b/src/gui/frame.h @@ -74,6 +74,8 @@ public Q_SLOTS: void setLock(); //void unlock(); void setDozent(); + void setCloseUp(bool value); + private Q_SLOTS: void remoteControlClicked(); void remoteControlAllClicked(); @@ -102,6 +104,7 @@ private: bool _isLocked; bool _dozent; int _ux, _uy; + bool _isCloseUp; // for remote control: QPoint _lastRecordedMousePosition; diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index 0f2fd0e..19b1021 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -98,7 +98,7 @@ MainWindow::MainWindow(QWidget *parent) : #ifdef MAINWINDOW_USE_TOUCHGUI //only used for the touchgui // define the slots we want to use - connect(ui->comboBox_touch1, SIGNAL(currentIndexChanged(int)), this, SLOT(combobox1(int))); // Combobox 1 verknüpfen mit IndexChangend Signal + connect(ui->comboBox_touch1, SIGNAL(currentIndexChanged(int)), this, SLOT(combobox1(int))); // Combobox 1 verkn��pfen mit IndexChangend Signal connect(ui->comboBox_touch1, SIGNAL(currentIndexChanged(int)), this, SLOT(setindexback())); connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(createProfile())); // profile button @@ -711,61 +711,82 @@ void MainWindow::closeUp() { std::list* selectedClients = MainWindow::getConnectionList()->getSelectedClients(); - if (!is_closeup) + + if(selectedClients->size() != 1) + // Cannot closeUp zero or more than one frames. + return; + + PVSClient* pvsClient = PVSConnectionManager::getManager()->getClientFromIp(selectedClients->front()); + + closeUp(pvsClient->getConnectionFrame(), pvsClient); +} + +void MainWindow::closeUp(ConnectionFrame* connFrame, PVSClient* pvsClient) +{ + std::list* selectedClients = + MainWindow::getConnectionList()->getSelectedClients(); + + if(selectedClients->size() != 1) + // Cannot closeUp zero or more than one frames. + return; + + if(!pvsClient) + pvsClient = connFrame->getConnection(); + + // Do we already have a closeUp Frame? + ConnectionFrame* closeupFrame = conWin->getCloseupFrame(); + + if(closeupFrame) { - if (selectedClients->size() == 1) - { - PVSClient * pvsClient = - PVSConnectionManager::getManager()->getClientFromIp( - selectedClients->front().toStdString().c_str()); - _framePosOnCloseUp = pvsClient->getConnectionFrame()->pos();//get the actualy position before run closeup - if (pvsClient->getVNCConnection()) - { - conWin->setCloseupFrame(pvsClient->getConnectionFrame()); - _updatefreq - = pvsClient->getConnectionFrame()->getFrame()->getVNCClientThread()->getUpdatefreq(); - pvsClient->getConnectionFrame()->getFrame()->getVNCClientThread()->setUpdatefreq( - 50); - pvsClient->getConnectionFrame()->move(5, 5); - pvsClient->getConnectionFrame()->setWindowFlags( - Qt::WindowStaysOnTopHint); - pvsClient->getConnectionFrame()->raise(); - pvsClient->getConnectionFrame()->paintCloseUp( - ui->widget->width(), ui->widget->height()); - - is_closeup = true; - conWin->setCloseupFrame(pvsClient->getConnectionFrame()); - } - } + // Is it the same as the sender one? + if(connFrame == closeupFrame) + // Then it already is close up. + return; else - { - QString - message = - QString( - tr( - "This operation can only be performed for one selected Client!")); - QMessageBox::information(this, "PVS", message); - } + // We need to un-closeUp the currently selected closeUp-Frame. + unCloseUp(closeupFrame); } - else if (conWin->getCloseupFrame()) + + _framePosOnCloseUp = connFrame->pos();//get the actualy position before run closeup + if (pvsClient->getVNCConnection()) { - /*PVSClient* pvsClient = - PVSConnectionManager::getManager()->getClientFromIp( - selectedClients->front().toStdString().c_str());*/ - conWin->getCloseupFrame()->setWindowFlags(Qt::Widget); - conWin->getCloseupFrame()->paintCloseUp( - conWin->getCloseupFrame()->getPrevWidth(), - conWin->getCloseupFrame()->getPrevHeight()); - conWin->getCloseupFrame()->move(_framePosOnCloseUp);//back to the position before the closeup - if (conWin->getCloseupFrame()->getConnection()->getVNCConnection()) - conWin->getCloseupFrame()->getFrame()->getVNCClientThread()->setUpdatefreq( - _updatefreq); - - is_closeup = false; - conWin->setCloseupFrame(NULL); + conWin->setCloseupFrame(connFrame); + _updatefreq = connFrame->getFrame()->getVNCClientThread()->getUpdatefreq(); + connFrame->getFrame()->getVNCClientThread()->setUpdatefreq( + 50); + connFrame->move(5, 5); + connFrame->setWindowFlags(Qt::WindowStaysOnTopHint); + connFrame->raise(); + connFrame->paintCloseUp(ui->widget->width(), ui->widget->height()); + + conWin->setCloseupFrame(connFrame); + + Frame* frame = connFrame->getFrame(); + if(frame) + frame->setCloseUp(true); } } +void MainWindow::unCloseUp(ConnectionFrame* connFrame) +{ + if(!connFrame) + return; + + connFrame->setWindowFlags(Qt::Widget); + connFrame->paintCloseUp( + connFrame->getPrevWidth(), + connFrame->getPrevHeight()); + connFrame->move(_framePosOnCloseUp);//back to the position before the closeup + if (connFrame->getConnection()->getVNCConnection()) + connFrame->getFrame()->getVNCClientThread()->setUpdatefreq(_updatefreq); + + Frame* frame = connFrame->getFrame(); + if(frame) + frame->setCloseUp(false); + + conWin->setCloseupFrame(NULL); +} + /* Perform some action if actionShowProcesses button was pressed * */ diff --git a/src/gui/mainWindow.h b/src/gui/mainWindow.h index 88756fd..c1f100e 100644 --- a/src/gui/mainWindow.h +++ b/src/gui/mainWindow.h @@ -172,6 +172,8 @@ public slots: void clientlisthide(); void projecttoolbar(); void unprojecttoolbar(); + void closeUp(ConnectionFrame* connFrame, PVSClient* client = 0); + void unCloseUp(ConnectionFrame* connFrame); void closeUp(); void foto(); void backgroundpicture(); -- cgit v1.2.3-55-g7522 From d81fa20f32d6285731248405d47fc34b8e612073 Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Tue, 12 Oct 2010 06:12:20 +0200 Subject: Fix control character handling bug. The code to deal with lowercase and uppercase versions of Latin1 characters was overly broad and sent ASCII Control Characters if Ctrl was pressed. --- src/gui/frame.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/frame.cpp b/src/gui/frame.cpp index b9899d8..12d49bc 100644 --- a/src/gui/frame.cpp +++ b/src/gui/frame.cpp @@ -538,8 +538,18 @@ void Frame::keyPressEvent(QKeyEvent* event) QString text = event->text(); if(text.length() == 1 && text.at(0).row() == 0) { - // We found a Latin1 char and pray it is the correct case. - key = text.at(0).cell(); + QChar c = text.at(0); + + // The next problem is that it may be a control character. + // This happens when Ctrl is pressed, so we only + // modify keys if they are lowercase or uppercase + // versions of the keycode. + + if(c.toLower().toLatin1() == key || c.toUpper().toLatin1() == key) + { + // We found a Latin1 char and pray it is the correct case. + key = c.cell(); + } } } sendInputEvent(InputEvent::keyboardPress(key, event->modifiers())); -- cgit v1.2.3-55-g7522 From 2561bfbe4f72bfb2093da2d93b1298caaa4f4497 Mon Sep 17 00:00:00 2001 From: Sebastien Braun Date: Wed, 13 Oct 2010 03:28:43 +0200 Subject: Fix key case comparison bug --- src/gui/frame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/frame.cpp b/src/gui/frame.cpp index 12d49bc..561f3ce 100644 --- a/src/gui/frame.cpp +++ b/src/gui/frame.cpp @@ -545,7 +545,7 @@ void Frame::keyPressEvent(QKeyEvent* event) // modify keys if they are lowercase or uppercase // versions of the keycode. - if(c.toLower().toLatin1() == key || c.toUpper().toLatin1() == key) + if(c.toLower().toLatin1() == (char)key || c.toUpper().toLatin1() == (char)key) { // We found a Latin1 char and pray it is the correct case. key = c.cell(); -- cgit v1.2.3-55-g7522