diff --git a/src/Mod/Start/Gui/StartView.cpp b/src/Mod/Start/Gui/StartView.cpp index bcc51ba28a..fea28b0b7b 100644 --- a/src/Mod/Start/Gui/StartView.cpp +++ b/src/Mod/Start/Gui/StartView.cpp @@ -72,7 +72,7 @@ class NewFileButton: public QPushButton { public: - NewFileButton(const NewButton& newButton) + explicit NewFileButton(const NewButton& newButton) { auto hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/Mod/Start"); @@ -92,7 +92,9 @@ public: auto textLayout = gsl::owner(new QVBoxLayout); auto textLabelLine1 = gsl::owner(new QLabel(this)); textLabelLine1->setText(newButton.heading); - textLabelLine1->setStyleSheet(QLatin1String("font-weight: bold;")); + QFont font = textLabelLine1->font(); + font.setWeight(QFont::Bold); + textLabelLine1->setFont(font); auto textLabelLine2 = gsl::owner(new QLabel(this)); textLabelLine2->setText(newButton.description); textLabelLine2->setWordWrap(true); @@ -105,75 +107,7 @@ public: this->setMinimumHeight(newFileIconSize + cardSpacing); this->setMinimumWidth(newFileIconSize + cardLabelWith); - - updateStyle(); } - - void updateStyle() - { - QString style = QStringLiteral(""); - if (qApp->styleSheet().isEmpty()) { - style = fileCardStyle(); - } - setStyleSheet(style); // This will trigger a changeEvent - } - - void changeEvent(QEvent* event) override - { - if (!changeInProgress && event->type() == QEvent::StyleChange) { - changeInProgress = true; // Block recursive calls. - updateStyle(); - changeInProgress = false; - } - - QPushButton::changeEvent(event); - } - - - QString fileCardStyle() const - { - auto hGrp = App::GetApplication().GetParameterGroupByPath( - "User parameter:BaseApp/Preferences/Mod/Start"); - - auto getUserColor = [&hGrp](QColor color, const char* parameter) { - uint32_t packed = Base::Color::asPackedRGB(color); - packed = hGrp->GetUnsigned(parameter, packed); - color = Base::Color::fromPackedRGB(packed); - return color; - }; - - QColor background(221, 221, 221); // NOLINT - background = getUserColor(background, "FileCardBackgroundColor"); - - QColor hovered(98, 160, 234); // NOLINT - hovered = getUserColor(hovered, "FileCardBorderColor"); - - QColor pressed(38, 162, 105); // NOLINT - pressed = getUserColor(pressed, "FileCardSelectionColor"); - - return QStringLiteral("QPushButton {" - " background-color: rgb(%1, %2, %3);" - " border-radius: 8px;" - "}" - "QPushButton:hover {" - " border: 2px solid rgb(%4, %5, %6);" - "}" - "QPushButton:pressed {" - " border: 2px solid rgb(%7, %8, %9);" - "}") - .arg(background.red()) - .arg(background.green()) - .arg(background.blue()) - .arg(hovered.red()) - .arg(hovered.green()) - .arg(hovered.blue()) - .arg(pressed.red()) - .arg(pressed.green()) - .arg(pressed.blue()); - } - -private: - bool changeInProgress = false; }; } // namespace