From 1d26b879c9b4d356f1bf48216192f5e156d5570f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 6 Sep 2018 13:37:34 +0200 Subject: [client] Fix style if checked button; add separator for buttons --- gui/client/toolbar.ui | 36 +++--------------------------------- src/client/addons/addons.cpp | 4 +--- src/client/toolbar/toolbar.cpp | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/gui/client/toolbar.ui b/gui/client/toolbar.ui index 121961e..9908dda 100644 --- a/gui/client/toolbar.ui +++ b/gui/client/toolbar.ui @@ -34,36 +34,12 @@ QPushButton:hover { QPushButton:pressed { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #dadbde, stop: 1 #f6f7fa); } +QPushButton:checked { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #cacbce, stop: 1 #e6e7ea); +} QPushButton::menu-indicator { image: url(:/darrow16.svg); } -/* QCheckBox */ -QCheckBox { -} -QCheckBox::indicator { - background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde); - border: 2px solid #8f8f91; - border-radius: 4px; - width: 16px; - height: 16px; -} -QCheckBox::indicator:unchecked { -} -QCheckBox::indicator:unchecked:hover { - border: 2px solid rgb(0, 170, 255); -} -QCheckBox::indicator:unchecked:pressed { - background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #dadbde, stop: 1 #f6f7fa); -} -QCheckBox::indicator:checked { - image: url(:/ok16.svg); -} -QCheckBox::indicator:checked:hover { - border: 2px solid rgb(0, 170, 255); -} -QCheckBox::indicator:checked:pressed { - background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #dadbde, stop: 1 #f6f7fa); -} @@ -229,9 +205,6 @@ QCheckBox::indicator:checked:pressed { 0 - - - @@ -249,9 +222,6 @@ QCheckBox::indicator:checked:pressed { true - - false - diff --git a/src/client/addons/addons.cpp b/src/client/addons/addons.cpp index 9f4a99f..43813ee 100644 --- a/src/client/addons/addons.cpp +++ b/src/client/addons/addons.cpp @@ -60,6 +60,7 @@ void AddonManager::loadFromPath(const QString &path, QList &button for (QFileInfo fileInfo : fileInfoList) { QString filePath = fileInfo.absoluteFilePath(); QSettings setting(filePath, QSettings::IniFormat); + setting.setIniCodec("UTF-8"); QString caption = setting.value("caption").toString(); // TODO: i18n QString exec = setting.value("exec").toString(); QString type = setting.value("type").toString(); @@ -195,12 +196,10 @@ static void setAddonVisible(Addon *addon, bool newValue) if (addon->button != nullptr) { QWidget *p = addon->button->parentWidget(); bool wasVisible = p != nullptr && addon->button->isVisibleTo(p); - qDebug() << "Visibility" << wasVisible << "->" << newValue; addon->button->setVisible(newValue); if (p != nullptr && wasVisible != newValue) { // Visibility changed -- adjust size of toolbar int size = (addon->button->width() + 2) * (newValue ? 1 : -1); - qDebug() << "Adding" << size; p->setFixedWidth(p->width() + size); } } else { @@ -212,7 +211,6 @@ static void handleAddonOutput(Addon* addon, QRegularExpressionMatchIterator &mat { while (matches.hasNext()) { auto m = matches.next(); - qDebug() << "Match:" << m.captured(0); auto key = m.captured(1); auto val = m.captured(2); bool newValue = toBool(val); diff --git a/src/client/toolbar/toolbar.cpp b/src/client/toolbar/toolbar.cpp index bec8586..d5e7d08 100644 --- a/src/client/toolbar/toolbar.cpp +++ b/src/client/toolbar/toolbar.cpp @@ -138,6 +138,13 @@ void Toolbar::init() connect(&_blinkTimer, SIGNAL(timeout()), this, SLOT(cameraBlink())); } +static QFrame* makeVerticalLine() { + QFrame *f = new QFrame(); + f->setFrameShape(QFrame::HLine); + f->setFrameShadow(QFrame::Sunken); + return f; +} + /** * This function should be called once from the main init() function which in * turn should only be called by the constructor. @@ -149,9 +156,13 @@ void Toolbar::initButtonsAndMenus() auto settings = clientApp->getSettings(); AddonManager::loadFromPath(settings->value("addonConfigDir", "/opt/openslx/pvs2/addons").toString(), buttons, menus); // Buttons - for (auto i : buttons) { - _ui->buttonContainer->addWidget(i); - i->setVisible(false); + if (!buttons.isEmpty()) { + _ui->buttonContainer->addWidget(makeVerticalLine()); + for (auto i : buttons) { + _ui->buttonContainer->addWidget(i); + i->setVisible(false); + } + _ui->buttonContainer->addWidget(makeVerticalLine()); } // Menu _menu = new QMenu(this); @@ -176,7 +187,6 @@ void Toolbar::initButtonsAndMenus() _ui->cmdMenu->setMenu(_menu); /* only add a "quit"-button when the configuration allows it. */ - bool allow = settings->value("allowClientQuit").toBool(); _acnQuit->setVisible(allow); -- cgit v1.2.3-55-g7522