summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2025-02-17 22:05:05 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2025-02-18 08:59:53 +0100
commit4a1a26e2a29f1c501cc61c23cb7ac556c1034b96 (patch)
tree2e92cd7c4079eaa98e91dc31068e1b3e2c5b3274
parentef38373275008740d1090fa1a1a59e1832ea40a9 (diff)
tdf#130857 qt weld: Implement QtInstanceLabel::set_label_type
This is e.g. used by Writer's "Table" -> "Insert Table" dialog (for which support will be declared in an upcoming commit) to show a warning when a large number is set for rows or columns. Implement similar to GtkInstanceLabel::set_label_type by setting specific font and background colors. Change-Id: I1e4c1863261cfd7f37f0bf80803fd97062c5604c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181806 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Jenkins
-rw-r--r--vcl/qt5/QtInstanceLabel.cxx31
1 files changed, 30 insertions, 1 deletions
diff --git a/vcl/qt5/QtInstanceLabel.cxx b/vcl/qt5/QtInstanceLabel.cxx
index ec6775ea6106..47f4dbfe4a68 100644
--- a/vcl/qt5/QtInstanceLabel.cxx
+++ b/vcl/qt5/QtInstanceLabel.cxx
@@ -48,7 +48,36 @@ void QtInstanceLabel::set_mnemonic_widget(Widget* pTarget)
void QtInstanceLabel::set_font(const vcl::Font&) { assert(false && "Not implemented yet"); }
-void QtInstanceLabel::set_label_type(weld::LabelType) { assert(false && "Not implemented yet"); }
+void QtInstanceLabel::set_label_type(weld::LabelType eType)
+{
+ SolarMutexGuard g;
+
+ GetQtInstance().RunInMainThread([&] {
+ switch (eType)
+ {
+ case weld::LabelType::Normal:
+ {
+ // reset to default QLabel colors
+ QLabel aLabel;
+ QPalette aPalette = aLabel.palette();
+ set_background(toColor(aPalette.color(getQWidget()->backgroundRole())));
+ setFontColor(toColor(aPalette.color(aLabel.backgroundRole())));
+ break;
+ }
+ case weld::LabelType::Warning:
+ set_background(Application::GetSettings().GetStyleSettings().GetWarningColor());
+ setFontColor(Application::GetSettings().GetStyleSettings().GetWarningTextColor());
+ break;
+ case weld::LabelType::Error:
+ set_background(Application::GetSettings().GetStyleSettings().GetErrorColor());
+ setFontColor(Application::GetSettings().GetStyleSettings().GetErrorTextColor());
+ break;
+ case weld::LabelType::Title:
+ setFontColor(Application::GetSettings().GetStyleSettings().GetLightColor());
+ break;
+ }
+ });
+}
void QtInstanceLabel::set_font_color(const Color& rColor) { setFontColor(rColor); }