diff options
Diffstat (limited to 'src/server/connectionframe/connectionframe.cpp')
-rw-r--r-- | src/server/connectionframe/connectionframe.cpp | 161 |
1 files changed, 73 insertions, 88 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index 3278e04..0a7b180 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -22,31 +22,31 @@ #include <cassert> static QString style_student( - "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ + "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ QGroupBox { background-color: #AAA; margin: 2px; border-radius: 4px}" ); static QString style_tutor( - "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ + "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ QGroupBox { background-color: #70C670; margin: 2px; border-radius: 4px}" ); static QString style_selectedStudent( - "QLabel{ background-color: #FFF; border-radius: 2px; color: black; } \ + "QLabel{ background-color: #FFF; border-radius: 2px; color: black; } \ QGroupBox { background-color: #ccebff; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}" ); static QString style_selectedTutor( - "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ + "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ QGroupBox { background-color: #99ff99; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}" ); static QString style_exam ( - "QLabel{ background-color: #919191; color: black; } \ + "QLabel{ background-color: #919191; color: black; } \ QGroupBox { background-color: #d35400; margin: 1px; border-radius: 4px}" ); static QString style_exam_selected ( - "QLabel{ background-color: #919191; color: black; } \ + "QLabel{ background-color: #919191; color: black; } \ QGroupBox { background-color: #cc743a; margin: 1px; border-radius: 4px}" ); static QString style_disconnected( - "QLabel{ background-color: #919191; color: black; } \ + "QLabel{ background-color: #919191; color: black; } \ QGroupBox { background-color: #7F7F7F; margin: 1px; border-radius: 4px}" ); @@ -59,13 +59,12 @@ static QIcon *term = NULL, *cam = NULL, *eye = NULL, *lock = NULL; * @param height */ ConnectionFrame::ConnectionFrame(QWidget *parent, int width, int height) : - QGroupBox(parent), _client(NULL), _timerId(0), _timerCounter(0), _isSelected(false), _isTutor(false) + QGroupBox(parent), _client(NULL), _timerId(0), _timerCounter(0), _isSelected(false), _isTutor(false) { //defines the ui-stuff // load icons first - if (term == NULL) - { + if (term == NULL) { term = new QIcon(":terminal"); cam = new QIcon(":cf_cam"); eye = new QIcon(":cf_eye"); @@ -74,50 +73,49 @@ ConnectionFrame::ConnectionFrame(QWidget *parent, int width, int height) : //this->setAttribute(Qt::WA_OpaquePaintEvent); - _mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); - _mainLayout->setSpacing(1); - _mainLayout->setMargin(3); - _mainLayout->setAlignment(Qt::AlignHCenter); - this->setStyleSheet(style_student); - - _iconLayout = new QBoxLayout(QBoxLayout::RightToLeft, NULL); - _iconLayout->setSpacing(1); - _iconLayout->setMargin(3); - - _lblUserName = new QLabel("Test", this); - _lblUserName->setAlignment(Qt::AlignHCenter); - - _lblHostName = new QLabel("PC", this); - _lblHostName->setAlignment(Qt::AlignHCenter); - - _lblExamMode = new QLabel(tr("EXAM-MODE"), this); - _lblExamMode->setAlignment(Qt::AlignHCenter); - _lblExamMode->setVisible(false); - - _icoCam = addIcon(cam); - _icoEye = addIcon(eye); - _icoLock = addIcon(lock); - - _iconLayout->addWidget(_icoCam); - _iconLayout->addWidget(_icoEye); - _iconLayout->addWidget(_icoLock); - _iconLayout->addStretch(); - - _mainLayout->addLayout(_iconLayout); - _mainLayout->addStretch(); - _mainLayout->addWidget(_lblExamMode); - _mainLayout->addStretch(); - _mainLayout->addWidget(_lblUserName); - _mainLayout->addWidget(_lblHostName); - this->setLayout(_mainLayout); - this->setSize(width, height); - this->updateAppearance(); + _mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); + _mainLayout->setSpacing(1); + _mainLayout->setMargin(3); + _mainLayout->setAlignment(Qt::AlignHCenter); + this->setStyleSheet(style_student); + + _iconLayout = new QBoxLayout(QBoxLayout::RightToLeft, NULL); + _iconLayout->setSpacing(1); + _iconLayout->setMargin(3); + + _lblUserName = new QLabel("Test", this); + _lblUserName->setAlignment(Qt::AlignHCenter); + + _lblHostName = new QLabel("PC", this); + _lblHostName->setAlignment(Qt::AlignHCenter); + + _lblExamMode = new QLabel(tr("EXAM-MODE"), this); + _lblExamMode->setAlignment(Qt::AlignHCenter); + _lblExamMode->setVisible(false); + + _icoCam = addIcon(cam); + _icoEye = addIcon(eye); + _icoLock = addIcon(lock); + + _iconLayout->addWidget(_icoCam); + _iconLayout->addWidget(_icoEye); + _iconLayout->addWidget(_icoLock); + _iconLayout->addStretch(); + + _mainLayout->addLayout(_iconLayout); + _mainLayout->addStretch(); + _mainLayout->addWidget(_lblExamMode); + _mainLayout->addStretch(); + _mainLayout->addWidget(_lblUserName); + _mainLayout->addWidget(_lblHostName); + this->setLayout(_mainLayout); + this->setSize(width, height); + this->updateAppearance(); } ConnectionFrame::~ConnectionFrame() { - if (_client != NULL) - { + if (_client != NULL) { _client->deleteLater(); } _iconLayout->deleteLater(); @@ -130,12 +128,12 @@ ConnectionFrame::~ConnectionFrame() */ QLabel* ConnectionFrame::addIcon(const QIcon* icon) { - QLabel *label = new QLabel(this); - label->setPixmap(icon->pixmap(24, 24, QIcon::Normal, QIcon::On)); - label->setAttribute(Qt::WA_TranslucentBackground); - label->hide(); - _icons.append(label); - return label; + QLabel *label = new QLabel(this); + label->setPixmap(icon->pixmap(24, 24, QIcon::Normal, QIcon::On)); + label->setAttribute(Qt::WA_TranslucentBackground); + label->hide(); + _icons.append(label); + return label; } /** @@ -196,16 +194,12 @@ void ConnectionFrame::showDefaultThumb() void ConnectionFrame::mouseReleaseEvent(QMouseEvent* event) { event->accept(); - if (event->button() == Qt::LeftButton) - { + if (event->button() == Qt::LeftButton) { QApplication::setOverrideCursor(QCursor(Qt::OpenHandCursor)); // Only recognize a move if the distance is larger than _startDragDistance - if ((this->pos() - _previousPosition).manhattanLength() > _startDragDistance ) - { + if ((this->pos() - _previousPosition).manhattanLength() > _startDragDistance ) { emit frameMoved(true, this); - } - else - { + } else { qDebug("Clicked"); move(_previousPosition); emit clicked(this); @@ -239,12 +233,9 @@ void ConnectionFrame::leaveEvent(QEvent* event) */ void ConnectionFrame::mousePressEvent(QMouseEvent *event) { - if (event->button() == Qt::RightButton) - { + if (event->button() == Qt::RightButton) { // Menu... - } - else - { + } else { _clickPoint = event->pos(); _previousPosition = this->pos(); QApplication::setOverrideCursor(QCursor(Qt::ClosedHandCursor)); @@ -263,7 +254,7 @@ void ConnectionFrame::mousePressEvent(QMouseEvent *event) void ConnectionFrame::mouseMoveEvent(QMouseEvent *event) { QApplication::setOverrideCursor(QCursor(Qt::ClosedHandCursor)); - move(mapToParent(event->pos()-_clickPoint)); + move(mapToParent(event->pos() - _clickPoint)); event->accept(); } @@ -286,7 +277,7 @@ void ConnectionFrame::paintEvent(QPaintEvent *event) QGroupBox::paintEvent(event); if (_remoteScreen.isNull()) { return; - } + } QPainter painter(this); painter.drawPixmap((this->width() - _remoteScreen.width()) / 2, 4, _remoteScreen); @@ -339,19 +330,18 @@ void ConnectionFrame::setTutor(bool b) */ void ConnectionFrame::updateAppearance() { - if (_client == NULL) - { + if (_client == NULL) { // Unconnected Frame if (_isSelected) { this->setStyleSheet(style_selectedStudent); - } else if (_isTutor) { - this->setStyleSheet(style_tutor); - }else { + } else if (_isTutor) { + this->setStyleSheet(style_tutor); + } else { this->setStyleSheet(style_disconnected); - } + } for (QList<QLabel*>::iterator it(_icons.begin()); it != _icons.end(); ++it) { (**it).hide(); - } + } return; } _icoCam->setVisible(_client->isActiveVncServer()); @@ -362,23 +352,19 @@ void ConnectionFrame::updateAppearance() _lblExamMode->setVisible(_client->isExamMode()); // Normal client, no special stuff active - if (_isSelected && _isTutor){ + if (_isSelected && _isTutor) { this->setStyleSheet(style_selectedTutor); - } - else if (_isTutor){ + } else if (_isTutor) { this->setStyleSheet(style_tutor); - } - else if (_client->isExamMode()) { + } else if (_client->isExamMode()) { if (_isSelected) { this->setStyleSheet(style_exam_selected); } else { this->setStyleSheet(style_exam); } - } - else if (_isSelected) { + } else if (_isSelected) { this->setStyleSheet(style_selectedStudent); - } - else { + } else { this->setStyleSheet(style_student); } } @@ -393,8 +379,7 @@ void ConnectionFrame::updateAppearance() */ void ConnectionFrame::onClientDisconnected() { - if (_timerId != 0) - { + if (_timerId != 0) { killTimer(_timerId); _timerId = 0; } |