MCPcopy Create free account
hub / github.com/KDE/labplot / LabelWidget

Method LabelWidget

src/frontend/widgets/LabelWidget.cpp:93–224  ·  view source on GitHub ↗

! \class LabelWidget \brief Widget for editing the properties of a TextLabel object, mostly used in an appropriate dock widget. In order the properties of the label to be shown, \c loadConfig() has to be called with the corresponding KConfigGroup (settings for a label in *Plot, Axis etc. or for an independent label on the worksheet). \ingroup frontend */

Source from the content-addressed store, hash-verified

91 \ingroup frontend
92 */
93LabelWidget::LabelWidget(QWidget* parent)
94 : BaseDock(parent)
95 , m_dateTimeMenu(new QMenu(this)) {
96 ui.setupUi(this);
97 setBaseWidgets(ui.leName, ui.teComment);
98 setVisibilityWidgets(ui.chbVisible);
99
100 // set the minimum size of the text edit widget to one row of a QLabel
101 ui.teLabel->setMinimumHeight(ui.lName->height());
102
103 const KConfigGroup group = Settings::group(QStringLiteral("Settings_General"));
104 m_units = (BaseDock::Units)group.readEntry("Units", (int)BaseDock::Units::Metric);
105 if (m_units == BaseDock::Units::Imperial)
106 m_worksheetUnit = Worksheet::Unit::Inch;
107
108 QString suffix;
109 if (m_units == BaseDock::Units::Metric)
110 suffix = QLatin1String(" cm");
111 else
112 suffix = QLatin1String(" in");
113
114 ui.sbPositionX->setSuffix(suffix);
115 ui.sbPositionY->setSuffix(suffix);
116
117 m_dateTimeMenu->setSeparatorsCollapsible(false); // we don't want the first separator to be removed
118
119 // Icons
120 ui.tbFontBold->setIcon(QIcon::fromTheme(QStringLiteral("format-text-bold")));
121 ui.tbFontItalic->setIcon(QIcon::fromTheme(QStringLiteral("format-text-italic")));
122 ui.tbFontUnderline->setIcon(QIcon::fromTheme(QStringLiteral("format-text-underline")));
123 ui.tbFontStrikeOut->setIcon(QIcon::fromTheme(QStringLiteral("format-text-strikethrough")));
124 ui.tbFontSuperScript->setIcon(QIcon::fromTheme(QStringLiteral("format-text-superscript")));
125 ui.tbFontSubScript->setIcon(QIcon::fromTheme(QStringLiteral("format-text-subscript")));
126 ui.tbAlignLeft->setIcon(QIcon::fromTheme(QStringLiteral("format-justify-left")));
127 ui.tbAlignCenter->setIcon(QIcon::fromTheme(QStringLiteral("format-justify-center")));
128 ui.tbAlignRight->setIcon(QIcon::fromTheme(QStringLiteral("format-justify-right")));
129 ui.tbAlignJustify->setIcon(QIcon::fromTheme(QStringLiteral("format-justify-fill")));
130 ui.tbSymbols->setIcon(QIcon::fromTheme(QStringLiteral("labplot-format-text-symbol")));
131 ui.tbDateTime->setIcon(QIcon::fromTheme(QStringLiteral("chronometer")));
132
133 ui.kcbBackgroundColor->setAlphaChannelEnabled(true);
134 ui.kcbBackgroundColor->setColor(QColor(0, 0, 0, 0)); // transparent
135 ui.kcbFontColor->setAlphaChannelEnabled(true);
136 ui.kcbFontColor->setColor(QColor(255, 255, 255, 255)); // black
137
138#ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING
139 m_highlighter = new KSyntaxHighlighting::SyntaxHighlighter(ui.teLabel->document());
140 m_highlighter->setTheme(GuiTools::isDarkMode() ? m_repository.defaultTheme(KSyntaxHighlighting::Repository::DarkTheme)
141 : m_repository.defaultTheme(KSyntaxHighlighting::Repository::LightTheme));
142#endif
143
144 auto* gridLayout = qobject_cast<QGridLayout*>(layout());
145 borderLineWidget = new LineWidget(this);
146 gridLayout->addWidget(borderLineWidget, 31, 0, 1, 4);
147
148 m_messageWidget = new KMessageWidget(this);
149 m_messageWidget->setMessageType(KMessageWidget::Error);
150 m_messageWidget->setWordWrap(true);

Callers

nothing calls this directly

Calls 9

groupFunction · 0.85
heightMethod · 0.80
setSuffixMethod · 0.80
QColorClass · 0.50
setIconMethod · 0.45
setColorMethod · 0.45
setThemeMethod · 0.45
modelMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected