From: Juergen Spitzmueller Date: Fri, 23 Dec 2022 08:14:03 +0000 (+0100) Subject: Fix UI of document color selection X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d90484de0a78d44d5119ce5bc78610571afcd3fc;p=features.git Fix UI of document color selection The coloring of push buttons does not work with all themes, so use a dedicated widget. Also, accelerators have been used multiple times. --- diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index 33f79a7a19..1effaa114d 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -86,9 +86,8 @@ #include -// a style sheet for buttons -// this is for example used for the background color setting button -static inline QString colorButtonStyleSheet(QColor const & bgColor) +// a style sheet for color frame widgets +static inline QString colorFrameStyleSheet(QColor const & bgColor) { if (bgColor.isValid()) { QString rc = QLatin1String("background-color:"); @@ -2260,10 +2259,10 @@ void GuiDocument::changeBackgroundColor() rgb2qcolor(set_backgroundcolor), asQWidget()); if (!newColor.isValid()) return; - // set the button color and text - colorModule->backgroundPB->setStyleSheet( - colorButtonStyleSheet(newColor)); - colorModule->backgroundPB->setText(qt_("&Change...")); + // set the color + colorModule->pageBackgroundCF->setVisible(true); + colorModule->pageBackgroundCF->setStyleSheet( + colorFrameStyleSheet(newColor)); // save color set_backgroundcolor = rgbFromHexName(fromqstr(newColor.name())); is_backgroundcolor = true; @@ -2273,10 +2272,9 @@ void GuiDocument::changeBackgroundColor() void GuiDocument::deleteBackgroundColor() { - // set the button color back to default by setting an empty StyleSheet - colorModule->backgroundPB->setStyleSheet(QLatin1String("")); - // change button text - colorModule->backgroundPB->setText(qt_("&Default...")); + // set the color back to default by setting an empty StyleSheet + colorModule->pageBackgroundCF->setStyleSheet(QLatin1String("")); + colorModule->pageBackgroundCF->setVisible(false); // save default color (white) set_backgroundcolor = rgbFromHexName("#ffffff"); is_backgroundcolor = false; @@ -2290,10 +2288,10 @@ void GuiDocument::changeFontColor() rgb2qcolor(set_fontcolor), asQWidget()); if (!newColor.isValid()) return; - // set the button color and text - colorModule->fontColorPB->setStyleSheet( - colorButtonStyleSheet(newColor)); - colorModule->fontColorPB->setText(qt_("&Change...")); + // set the color + colorModule->mainTextCF->setVisible(true); + colorModule->mainTextCF->setStyleSheet( + colorFrameStyleSheet(newColor)); // save color set_fontcolor = rgbFromHexName(fromqstr(newColor.name())); is_fontcolor = true; @@ -2304,9 +2302,8 @@ void GuiDocument::changeFontColor() void GuiDocument::deleteFontColor() { // set the button color back to default by setting an empty StyleSheet - colorModule->fontColorPB->setStyleSheet(QLatin1String("")); - // change button text - colorModule->fontColorPB->setText(qt_("&Default...")); + colorModule->mainTextCF->setStyleSheet(QLatin1String("")); + colorModule->mainTextCF->setVisible(false); // save default color (black) set_fontcolor = rgbFromHexName("#000000"); is_fontcolor = false; @@ -2320,9 +2317,9 @@ void GuiDocument::changeNoteFontColor() rgb2qcolor(set_notefontcolor), asQWidget()); if (!newColor.isValid()) return; - // set the button color - colorModule->noteFontColorPB->setStyleSheet( - colorButtonStyleSheet(newColor)); + // set the color + colorModule->noteFontCF->setStyleSheet( + colorFrameStyleSheet(newColor)); // save color set_notefontcolor = rgbFromHexName(fromqstr(newColor.name())); is_notefontcolor = true; @@ -2332,10 +2329,10 @@ void GuiDocument::changeNoteFontColor() void GuiDocument::deleteNoteFontColor() { - // set the button color back to pref + // set the color back to pref theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor); - colorModule->noteFontColorPB->setStyleSheet( - colorButtonStyleSheet(rgb2qcolor(set_notefontcolor))); + colorModule->noteFontCF->setStyleSheet( + colorFrameStyleSheet(rgb2qcolor(set_notefontcolor))); is_notefontcolor = false; change_adaptor(); } @@ -2347,9 +2344,9 @@ void GuiDocument::changeBoxBackgroundColor() rgb2qcolor(set_boxbgcolor), asQWidget()); if (!newColor.isValid()) return; - // set the button color - colorModule->boxBackgroundPB->setStyleSheet( - colorButtonStyleSheet(newColor)); + // set the color + colorModule->boxBackgroundCF->setStyleSheet( + colorFrameStyleSheet(newColor)); // save color set_boxbgcolor = rgbFromHexName(fromqstr(newColor.name())); is_boxbgcolor = true; @@ -2359,10 +2356,10 @@ void GuiDocument::changeBoxBackgroundColor() void GuiDocument::deleteBoxBackgroundColor() { - // set the button color back to pref + // set the color back to pref theApp()->getRgbColor(Color_shadedbg, set_boxbgcolor); - colorModule->boxBackgroundPB->setStyleSheet( - colorButtonStyleSheet(rgb2qcolor(set_boxbgcolor))); + colorModule->boxBackgroundCF->setStyleSheet( + colorFrameStyleSheet(rgb2qcolor(set_boxbgcolor))); is_boxbgcolor = false; change_adaptor(); } @@ -4099,26 +4096,30 @@ void GuiDocument::paramsToDialog() //color if (bp_.isfontcolor) { - colorModule->fontColorPB->setStyleSheet( - colorButtonStyleSheet(rgb2qcolor(bp_.fontcolor))); - } + colorModule->mainTextCF->setStyleSheet( + colorFrameStyleSheet(rgb2qcolor(bp_.fontcolor))); + colorModule->mainTextCF->setVisible(true); + } else + colorModule->mainTextCF->setVisible(false); set_fontcolor = bp_.fontcolor; is_fontcolor = bp_.isfontcolor; - colorModule->noteFontColorPB->setStyleSheet( - colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor))); + colorModule->noteFontCF->setStyleSheet( + colorFrameStyleSheet(rgb2qcolor(bp_.notefontcolor))); set_notefontcolor = bp_.notefontcolor; is_notefontcolor = bp_.isnotefontcolor; if (bp_.isbackgroundcolor) { - colorModule->backgroundPB->setStyleSheet( - colorButtonStyleSheet(rgb2qcolor(bp_.backgroundcolor))); - } + colorModule->pageBackgroundCF->setStyleSheet( + colorFrameStyleSheet(rgb2qcolor(bp_.backgroundcolor))); + colorModule->pageBackgroundCF->setVisible(true); + } else + colorModule->pageBackgroundCF->setVisible(false); set_backgroundcolor = bp_.backgroundcolor; is_backgroundcolor = bp_.isbackgroundcolor; - colorModule->boxBackgroundPB->setStyleSheet( - colorButtonStyleSheet(rgb2qcolor(bp_.boxbgcolor))); + colorModule->boxBackgroundCF->setStyleSheet( + colorFrameStyleSheet(rgb2qcolor(bp_.boxbgcolor))); set_boxbgcolor = bp_.boxbgcolor; is_boxbgcolor = bp_.isboxbgcolor; diff --git a/src/frontends/qt/ui/ColorUi.ui b/src/frontends/qt/ui/ColorUi.ui index 85eaf9c3cf..285cd7c44b 100644 --- a/src/frontends/qt/ui/ColorUi.ui +++ b/src/frontends/qt/ui/ColorUi.ui @@ -1,91 +1,83 @@ - + + ColorUi - - + + 0 0 - 426 - 261 + 519 + 274 - + Qt::DefaultContextMenu - + - + - + - + - - + + Font Colors - + true - + - - - - - Main text: - - - fontColorPB - - - - - - + + + + 16777215 16777215 - + Click to change the color - - Default... + + &Change... - - - + + + + Qt::Horizontal + + - 23 - 23 + 40 + 20 - - Revert the color to the default - - - R&eset - - - Qt::ToolButtonTextOnly + + + + + + Greyed-out notes: - - Qt::LeftArrow + + fontColorPB - + - + Qt::Horizontal - + 40 20 @@ -93,66 +85,119 @@ - - - - Greyed-out notes: + + + + Main text: - + fontColorPB - - - + + + 16777215 16777215 - + Click to change the color - - &Change... + + C&hange... - - - + + + 23 23 - + Revert the color to the default - + R&eset - + Qt::ToolButtonTextOnly - + Qt::LeftArrow - - - - Qt::Horizontal + + + + + 23 + 23 + + + + Revert the color to the default + + + &Reset + + + Qt::ToolButtonTextOnly - + + Qt::LeftArrow + + + + + + + + 0 + 0 + + + 40 - 20 + 0 - + + QFrame::Box + + + QFrame::Plain + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + QFrame::Box + + + QFrame::Plain + + @@ -160,70 +205,77 @@ - - + + Background Colors - + true - + - - - - - Page: + + + + + Shaded boxes: - + backgroundPB - - - + + + + Qt::Horizontal + + - 16777215 - 16777215 + 40 + 20 - - Click to change the color - - - Default... - - + - - - + + + 23 23 - + Revert the color to the default - - R&eset + + Rese&t - + Qt::ToolButtonTextOnly - + Qt::LeftArrow - + + + + Page: + + + backgroundPB + + + + - + Qt::Horizontal - + 40 20 @@ -231,66 +283,103 @@ - - - - Shaded boxes: - - - backgroundPB - - - - - - + + + 16777215 16777215 - + Click to change the color - - &Change... + + Ch&ange... - - - + + + 23 23 - + Revert the color to the default - - R&eset + + Re&set - + Qt::ToolButtonTextOnly - + Qt::LeftArrow - - - - Qt::Horizontal + + + + + 16777215 + 16777215 + + + + Click to change the color - + + Chan&ge... + + + + + + + + 0 + 0 + + + 40 - 20 + 0 - + + QFrame::Box + + + QFrame::Plain + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + QFrame::Box + + + QFrame::Plain + + @@ -299,10 +388,10 @@ - + Qt::Vertical - + 385 22 @@ -314,9 +403,9 @@ - + - qt_i18n.h + qt_i18n.h