diff options
Diffstat (limited to 'src/server/connectionframe/connectionframe.cpp')
-rw-r--r-- | src/server/connectionframe/connectionframe.cpp | 95 |
1 files changed, 53 insertions, 42 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index c2bba70..c6c20b8 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -16,46 +16,51 @@ #include "connectionframe.h" #include "../mainwindow/mainwindow.h" +#include "../../shared/util.h" #include "../net/client.h" -#include <QImage> -#include <cassert> -#include <cmath> -static QString style_student( - "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ - QGroupBox { background-color: #AAA; margin: 2px; border-radius: 4px}" +#include <QImage> +#include <QResizeEvent> +#include <QBoxLayout> +#include <QLabel> +#include <QApplication> +#include <QPainter> + +static const QString style_student( + "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;} \ - QGroupBox { background-color: #70C670; margin: 2px; border-radius: 4px}" +static const QString style_tutor( + "QLabel{ background-color: #FFF; border-radius: 2px; color: black;}" + " QGroupBox { background-color: #70C670; margin: 2px; border-radius: 4px}" ); -static QString style_attention( - "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ - QGroupBox { background-color: #C88; margin: 2px; border-radius: 4px}" +static const QString style_attention( + "QLabel{ background-color: #FFF; border-radius: 2px; color: black;}" + " QGroupBox { background-color: #C88; margin: 2px; border-radius: 4px}" ); -static QString style_selectedStudent( - "QLabel{ background-color: #FFF; border-radius: 2px; color: black; } \ - QGroupBox { background-color: #ccebff; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}" +static const QString style_selectedStudent( + "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;} \ - QGroupBox { background-color: #9f9; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}" +static const QString style_selectedTutor( + "QLabel{ background-color: #FFF; border-radius: 2px; color: black;}" + " QGroupBox { background-color: #9f9; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}" ); -static QString style_selectedAttention( - "QLabel{ background-color: #FFF; border-radius: 2px; color: black;} \ - QGroupBox { background-color: #E99; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}" +static const QString style_selectedAttention( + "QLabel{ background-color: #FFF; border-radius: 2px; color: black;}" + " QGroupBox { background-color: #E99; margin: 0px; border-radius: 4px; border: 4px solid #6C8CF0;}" ); -static QString style_exam ( - "QLabel{ background-color: #919191; color: black; } \ - QGroupBox { background-color: #d35400; margin: 1px; border-radius: 4px}" +static const QString style_exam ( + "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; } \ - QGroupBox { background-color: #cc743a; margin: 1px; border-radius: 4px}" +static const QString style_exam_selected ( + "QLabel{ background-color: #919191; color: black; }" + " QGroupBox { background-color: #cc743a; margin: 1px; border-radius: 4px}" ); -static QString style_disconnected( - "QLabel{ background-color: #919191; border-radius: 2px; color: black; } \ - QGroupBox { background-color: #7F7F7F; margin: 1px; border-radius: 4px}" +static const QString style_disconnected( + "QLabel{ background-color: #919191; border-radius: 2px; color: black; }" + " QGroupBox { background-color: #7F7F7F; margin: 1px; border-radius: 4px}" ); static QIcon *term = nullptr, *cam = nullptr, *eye = nullptr, *lock = nullptr; @@ -70,9 +75,10 @@ bool ConnectionFrame::paintDisabled = false; * @param width * @param height */ -ConnectionFrame::ConnectionFrame(MainWindow* main, QWidget *parent, bool fromRoomplan) : - QGroupBox(parent), _client(nullptr), _timerId(0), _timerCounter(0), _isSelected(false), _isTutor(false), - _isFromRoomplan(fromRoomplan), _mainWindow(main) +ConnectionFrame::ConnectionFrame(MainWindow* main, QWidget *parent, bool fromRoomplan) + : QGroupBox(parent) + , _isFromRoomplan(fromRoomplan) + , _mainWindow(main) { //defines the ui-stuff @@ -158,7 +164,7 @@ void ConnectionFrame::updateGeometry() */ QLabel* ConnectionFrame::addIcon(const QIcon* icon) { - QLabel *label = new QLabel(this); + auto *label = new QLabel(this); label->setPixmap(icon->pixmap(24, 24, QIcon::Normal, QIcon::On)); label->setAttribute(Qt::WA_TranslucentBackground); label->hide(); @@ -174,17 +180,17 @@ QLabel* ConnectionFrame::addIcon(const QIcon* icon) void ConnectionFrame::assignClient(Client* client) { assert(_client == nullptr); - connect( client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected()) ); - connect( client, SIGNAL(thumbUpdated(Client*, const QImage&)), this, SLOT(onThumbUpdated(Client*, const QImage&)) ); - connect( client, SIGNAL(vncServerStateChange(Client*)), this, SLOT(updateAppearance())); - connect( client, SIGNAL(vncClientStateChange(Client*)), this, SLOT(updateAppearance())); - connect( client, SIGNAL(stateChanged()), this, SLOT(updateAppearance())); _client = client; + connect(_client, &Client::disconnected, this, &ConnectionFrame::onClientDisconnected ); + connect(_client, &Client::thumbUpdated, this, &ConnectionFrame::onThumbUpdated ); + connect(_client, &Client::vncServerStateChange, this, &ConnectionFrame::updateAppearance); + connect(_client, &Client::vncClientStateChange, this, &ConnectionFrame::updateAppearance); + connect(_client, &Client::stateChanged, this, &ConnectionFrame::updateAppearance); _computerId = client->ip(); updateLabels(); showDefaultThumb(); if (_timerId == 0) - _timerId = startTimer(1000 + qrand() % 150); + _timerId = startTimer(slxrand() % 150 + 1000); this->updateAppearance(); _client->setTutor(_isTutor); } @@ -382,8 +388,8 @@ void ConnectionFrame::updateAppearance() } else { this->setStyleSheet(style_disconnected); } - for (QList<QLabel*>::iterator it(_icons.begin()); it != _icons.end(); ++it) { - (**it).hide(); + for (auto *_icon : _icons) { + _icon->hide(); } return; } @@ -448,3 +454,8 @@ void ConnectionFrame::onThumbUpdated(Client* client, const QImage& thumb) this->update(); } +void ConnectionFrame::resizeEvent(QResizeEvent *event) { + calcDesiredThumbSize(event->size()); + QGroupBox::resizeEvent(event); +} + |