diff options
author | Sebastien Braun | 2010-10-10 22:09:29 +0200 |
---|---|---|
committer | Sebastien Braun | 2010-10-11 00:56:10 +0200 |
commit | d75d1a3e507e6a4cc01367df4d7a77012819b95b (patch) | |
tree | 56cadbc332d336c7689304991dcd347fc16230f4 | |
parent | Fix broken formatting of InputEvent::toString() (diff) | |
download | pvs-d75d1a3e507e6a4cc01367df4d7a77012819b95b.tar.gz pvs-d75d1a3e507e6a4cc01367df4d7a77012819b95b.tar.xz pvs-d75d1a3e507e6a4cc01367df4d7a77012819b95b.zip |
Fix bug where pressing the closeUp-button sometimes results in no action.
-rw-r--r-- | src/gui/frame.cpp | 29 | ||||
-rw-r--r-- | src/gui/frame.h | 3 | ||||
-rw-r--r-- | src/gui/mainWindow.cpp | 119 | ||||
-rw-r--r-- | src/gui/mainWindow.h | 2 |
4 files changed, 102 insertions, 51 deletions
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<QString>* 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<QString>* 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(); |