summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Braun2010-11-04 00:38:24 +0100
committerSebastien Braun2010-11-04 00:38:24 +0100
commit4fcc0efae9738bb28922da592fff78cfef50277b (patch)
treeb3855b36abe874606a802ec75fc573543d2d7b35 /src/gui
parent[PVSMGRTOUCH] resetall bug fixed (diff)
parentDocumentation fixes and code cleanup (diff)
downloadpvs-4fcc0efae9738bb28922da592fff78cfef50277b.tar.gz
pvs-4fcc0efae9738bb28922da592fff78cfef50277b.tar.xz
pvs-4fcc0efae9738bb28922da592fff78cfef50277b.zip
Merge input handling work to master
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/frame.cpp57
-rw-r--r--src/gui/frame.h3
-rw-r--r--src/gui/mainWindow.cpp119
-rw-r--r--src/gui/mainWindow.h2
4 files changed, 120 insertions, 61 deletions
diff --git a/src/gui/frame.cpp b/src/gui/frame.cpp
index 1b80c3d..561f3ce 100644
--- a/src/gui/frame.cpp
+++ b/src/gui/frame.cpp
@@ -19,7 +19,6 @@
*/
#include <src/input/inputEvent.h>
-#include <src/input/inputHandlerChain.h>
#include "frame.h"
#include <src/gui/mainWindow.h>
#include <iostream>
@@ -48,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()));
@@ -334,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()
@@ -378,6 +383,12 @@ void Frame::setDozent()
}
}
+void Frame::setCloseUp(bool value)
+{
+ _isCloseUp = value;
+ button_closeUp->setChecked(value);
+}
+
void Frame::remoteControlClicked()
{
if(_remoteControlEnabled)
@@ -434,19 +445,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);
}
}
@@ -519,7 +529,30 @@ 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)
+ {
+ 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() == (char)key || c.toUpper().toLatin1() == (char)key)
+ {
+ // We found a Latin1 char and pray it is the correct case.
+ key = c.cell();
+ }
+ }
+ }
+ sendInputEvent(InputEvent::keyboardPress(key, event->modifiers()));
}
}
else
@@ -592,14 +625,14 @@ void Frame::showSpecialEventMenu()
{
qDebug("Trying to show menu...");
QMenu* menu = new QMenu(this);
- QList<SpecialInputEventDescription> specialEvents = privileged_handler_chain::describe();
- QList<SpecialInputEventDescription>::iterator iter;
+ QList<SpecialInputEventDescription> specialEvents = SpecialInputEventDescription::describeSpecialEvents();
+ QListIterator<SpecialInputEventDescription> 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());
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 b6878e8..1376851 100644
--- a/src/gui/mainWindow.cpp
+++ b/src/gui/mainWindow.cpp
@@ -99,7 +99,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
@@ -715,61 +715,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 28f82f7..58787ed 100644
--- a/src/gui/mainWindow.h
+++ b/src/gui/mainWindow.h
@@ -178,6 +178,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();