Skip to content

Commit dea7631

Browse files
committed
ProjectBuildModel: white console (#110)
On some systems, black console looks bad. So, lets keep it "original theme" usually white. closes #110
1 parent bc5391a commit dea7631

3 files changed

Lines changed: 47 additions & 116 deletions

File tree

src/plugins/ProjectManager/BuildRunOutput.ui

Lines changed: 9 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -155,115 +155,6 @@
155155
</item>
156156
<item>
157157
<widget class="QTextBrowser" name="commandOuput">
158-
<property name="palette">
159-
<palette>
160-
<active>
161-
<colorrole role="WindowText">
162-
<brush brushstyle="SolidPattern">
163-
<color alpha="255">
164-
<red>255</red>
165-
<green>255</green>
166-
<blue>255</blue>
167-
</color>
168-
</brush>
169-
</colorrole>
170-
<colorrole role="Text">
171-
<brush brushstyle="SolidPattern">
172-
<color alpha="255">
173-
<red>119</red>
174-
<green>119</green>
175-
<blue>119</blue>
176-
</color>
177-
</brush>
178-
</colorrole>
179-
<colorrole role="Base">
180-
<brush brushstyle="SolidPattern">
181-
<color alpha="255">
182-
<red>0</red>
183-
<green>0</green>
184-
<blue>0</blue>
185-
</color>
186-
</brush>
187-
</colorrole>
188-
<colorrole role="Highlight">
189-
<brush brushstyle="SolidPattern">
190-
<color alpha="255">
191-
<red>119</red>
192-
<green>119</green>
193-
<blue>119</blue>
194-
</color>
195-
</brush>
196-
</colorrole>
197-
<colorrole role="HighlightedText">
198-
<brush brushstyle="SolidPattern">
199-
<color alpha="255">
200-
<red>0</red>
201-
<green>0</green>
202-
<blue>0</blue>
203-
</color>
204-
</brush>
205-
</colorrole>
206-
</active>
207-
<inactive>
208-
<colorrole role="WindowText">
209-
<brush brushstyle="SolidPattern">
210-
<color alpha="255">
211-
<red>255</red>
212-
<green>255</green>
213-
<blue>255</blue>
214-
</color>
215-
</brush>
216-
</colorrole>
217-
<colorrole role="Text">
218-
<brush brushstyle="SolidPattern">
219-
<color alpha="255">
220-
<red>119</red>
221-
<green>119</green>
222-
<blue>119</blue>
223-
</color>
224-
</brush>
225-
</colorrole>
226-
<colorrole role="Base">
227-
<brush brushstyle="SolidPattern">
228-
<color alpha="255">
229-
<red>0</red>
230-
<green>0</green>
231-
<blue>0</blue>
232-
</color>
233-
</brush>
234-
</colorrole>
235-
<colorrole role="Highlight">
236-
<brush brushstyle="SolidPattern">
237-
<color alpha="255">
238-
<red>119</red>
239-
<green>119</green>
240-
<blue>119</blue>
241-
</color>
242-
</brush>
243-
</colorrole>
244-
<colorrole role="HighlightedText">
245-
<brush brushstyle="SolidPattern">
246-
<color alpha="255">
247-
<red>0</red>
248-
<green>0</green>
249-
<blue>0</blue>
250-
</color>
251-
</brush>
252-
</colorrole>
253-
</inactive>
254-
<disabled>
255-
<colorrole role="HighlightedText">
256-
<brush brushstyle="SolidPattern">
257-
<color alpha="255">
258-
<red>0</red>
259-
<green>0</green>
260-
<blue>0</blue>
261-
</color>
262-
</brush>
263-
</colorrole>
264-
</disabled>
265-
</palette>
266-
</property>
267158
<property name="font">
268159
<font>
269160
<family>Monospace</family>
@@ -281,10 +172,17 @@
281172
<bool>true</bool>
282173
</property>
283174
<property name="html">
284-
<string notr="true">.</string>
175+
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
176+
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
177+
p, li { white-space: pre-wrap; }
178+
hr { height: 1px; border-width: 0; }
179+
li.unchecked::marker { content: &quot;\2610&quot;; }
180+
li.checked::marker { content: &quot;\2612&quot;; }
181+
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Monospace'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
182+
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
285183
</property>
286184
<property name="plainText">
287-
<string notr="true"/>
185+
<string notr="true">.</string>
288186
</property>
289187
<property name="textInteractionFlags">
290188
<set>Qt::TextInteractionFlag::LinksAccessibleByKeyboard|Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextBrowserInteraction|Qt::TextInteractionFlag::TextSelectableByKeyboard|Qt::TextInteractionFlag::TextSelectableByMouse</set>

src/plugins/ProjectManager/ProjectManagerPlg.cpp

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ static auto regenerateKits(const std::filesystem::path &directoryPath) -> void {
7575
KitDetector::platformUnix);
7676
}
7777

78-
static auto getCommandInterpreter(const QString &externalCommand)
79-
-> std::tuple<QString, QStringList> {
78+
static auto
79+
getCommandInterpreter(const QString &externalCommand) -> std::tuple<QString, QStringList> {
8080
QString interpreter;
8181
QStringList command;
8282

@@ -225,6 +225,14 @@ ProjectManagerPlugin::ProjectManagerPlugin() {
225225

226226
config.pluginName = tr("Project manager");
227227
config.description = tr("Add support for building using CMake/Cargo/Go");
228+
config.configItems.push_back(
229+
qmdiConfigItem::Builder()
230+
.setDisplayName(tr("Black console"))
231+
.setDescription(tr("Should the console background be black, or default"))
232+
.setKey(Config::BlackConsoleKey)
233+
.setType(qmdiConfigItem::Bool)
234+
.setDefaultValue(false)
235+
.build());
228236
config.configItems.push_back(
229237
qmdiConfigItem::Builder()
230238
.setDisplayName(tr("Save before running tasks (build, config etc)"))
@@ -331,20 +339,32 @@ void ProjectManagerPlugin::on_client_merged(qmdiHost *host) {
331339
issuesDock =
332340
manager->createNewPanel(Panels::South, "projectissues", tr("Issues"), projectIssues);
333341

334-
auto *w2 = new QWidget;
342+
auto w2 = new QWidget;
343+
auto font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
335344
outputPanel = new Ui::BuildRunOutput;
336345
outputPanel->setupUi(w2);
337346
outputDock = manager->createNewPanel(Panels::South, "buildoutput", tr("Output"), w2);
338347
outputPanel->commandOuput->setLineWrapMode(QTextEdit::LineWrapMode::NoWrap);
339348
outputPanel->commandOuput->viewport()->setCursor(Qt::CursorShape::IBeamCursor);
340349
outputPanel->commandOuput->setOpenExternalLinks(false);
341350
outputPanel->commandOuput->setOpenLinks(false);
342-
343-
auto font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
344351
outputPanel->commandOuput->setFont(font);
345352
outputPanel->commandOuput->setAcceptRichText(true);
346353
outputPanel->commandOuput->viewport()->setCursor(Qt::CursorShape::IBeamCursor);
347354
outputPanel->commandOuput->setLineWrapMode(QTextEdit::NoWrap);
355+
outputPanel->commandOuput->clear();
356+
357+
QTimer::singleShot(0, [this]() {
358+
// why in a timer? because at this step, if we set the palette, the widget
359+
// will get inserted "soon" and its palette will change anyway.
360+
if (getConfig().getBlackConsole()) {
361+
auto p = outputPanel->commandOuput->palette();
362+
p.setColor(QPalette::Base, Qt::black);
363+
p.setColor(QPalette::Text, QColor(192, 192, 192));
364+
outputPanel->commandOuput->setPalette(p);
365+
}
366+
});
367+
348368
connect(outputPanel->commandOuput, &QTextBrowser::anchorClicked, outputPanel->commandOuput,
349369
[this](const QUrl &link) {
350370
if (!link.isLocalFile()) {
@@ -617,6 +637,17 @@ void ProjectManagerPlugin::on_client_merged(qmdiHost *host) {
617637
});
618638
}
619639

640+
void ProjectManagerPlugin::configurationHasBeenModified() {
641+
IPlugin::configurationHasBeenModified();
642+
643+
auto p = outputDock->palette();
644+
if (getConfig().getBlackConsole()) {
645+
p.setColor(QPalette::Base, Qt::black);
646+
p.setColor(QPalette::Text, QColor(192, 192, 192));
647+
}
648+
outputPanel->commandOuput->setPalette(p);
649+
}
650+
620651
void ProjectManagerPlugin::loadConfig(QSettings &settings) {
621652
IPlugin::loadConfig(settings);
622653

src/plugins/ProjectManager/ProjectManagerPlg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ProjectManagerPlugin : public IPlugin {
4545

4646
struct Config {
4747
CONFIG_DEFINE(SaveBeforeTask, bool);
48+
CONFIG_DEFINE(BlackConsole, bool);
4849
CONFIG_DEFINE(ExtraPath, QStringList);
4950
CONFIG_DEFINE(OpenDirs, QStringList);
5051
CONFIG_DEFINE(SelectedDirectory, QString);
@@ -67,6 +68,7 @@ class ProjectManagerPlugin : public IPlugin {
6768

6869
virtual void showAbout() override;
6970
virtual void on_client_merged(qmdiHost *host) override;
71+
virtual void configurationHasBeenModified() override;
7072
virtual void loadConfig(QSettings &settings) override;
7173
virtual void saveConfig(QSettings &settings) override;
7274

0 commit comments

Comments
 (0)