Skip to content

Commit 589e616

Browse files
committed
[CORRECTIVE] Fix more dark mode colors
Fixes in expression editor, bus interface editor and delete item dialog
1 parent 305ddb7 commit 589e616

12 files changed

Lines changed: 136 additions & 25 deletions

File tree

Kactus2.pri

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ HEADERS += ./common/widgets/instanceWidgets/InstanceWidgets.h \
4949
./common/widgets/usageComboBox/usagecombobox.h \
5050
./common/widgets/accessComboBox/accesscombobox.h \
5151
./common/widgets/modWriteComboBox/modwritecombobox.h \
52+
./common/widgets/MandatoryComboBox/MandatoryComboBox.h \
5253
./common/widgets/readActionComboBox/readactioncombobox.h \
5354
./common/widgets/testConstraintComboBox/testconstraintcombobox.h \
5455
./common/widgets/viewSelector/viewselector.h \
@@ -963,6 +964,7 @@ SOURCES += ./editors/ComponentEditor/busInterfaces/general/MasterModeEditor.cpp
963964
./common/widgets/usageComboBox/usagecombobox.cpp \
964965
./common/widgets/accessComboBox/accesscombobox.cpp \
965966
./common/widgets/modWriteComboBox/modwritecombobox.cpp \
967+
./common/widgets/MandatoryComboBox/MandatoryComboBox.cpp \
966968
./common/widgets/readActionComboBox/readactioncombobox.cpp \
967969
./common/widgets/testConstraintComboBox/testconstraintcombobox.cpp \
968970
./common/widgets/viewSelector/viewselector.cpp \

Kactus2.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ CreateHelp
292292
<ClCompile Include="common\widgets\listManager\listeditor.cpp" />
293293
<ClCompile Include="common\widgets\listManager\listmanager.cpp" />
294294
<ClCompile Include="common\widgets\listManager\listmanagermodel.cpp" />
295+
<ClCompile Include="common\widgets\MandatoryComboBox\MandatoryComboBox.cpp" />
295296
<ClCompile Include="common\widgets\nameGroupBox\namegroupbox.cpp" />
296297
<ClCompile Include="common\widgets\ParameterGroupBox\parametergroupbox.cpp" />
297298
<ClCompile Include="common\widgets\segmentComboBox\SegmentComboBox.cpp" />
@@ -1320,6 +1321,7 @@ CreateHelp
13201321
<QtMoc Include="common\widgets\EnumCollectionEditor\InterfaceEnumEditor.h" />
13211322
<ClInclude Include="common\widgets\GroupBoxWithAlertSign\StyleOptionGroupBoxWithAlertSign.h" />
13221323
<QtMoc Include="common\widgets\instanceWidgets\InstanceWidgets.h" />
1324+
<QtMoc Include="common\widgets\MandatoryComboBox\MandatoryComboBox.h" />
13231325
<ClInclude Include="common\widgets\TreeItemSelector\TreeItem.h" />
13241326
<QtMoc Include="editors\AbstractionDefinitionEditor\AbsDefParameterReferenceCounter.h" />
13251327
<QtMoc Include="editors\AbstractionDefinitionEditor\AbsDefParameterReferenceTree.h" />

Kactus2.vcxproj.filters

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,12 @@
10191019
<Filter Include="Source Files\common\models">
10201020
<UniqueIdentifier>{967b596d-95ce-4a8c-a1d2-029b9792fffd}</UniqueIdentifier>
10211021
</Filter>
1022+
<Filter Include="Header Files\common\widgets\MandatoryComboBox">
1023+
<UniqueIdentifier>{0ad2fc3a-f385-41b2-8931-90a8f2c7cf80}</UniqueIdentifier>
1024+
</Filter>
1025+
<Filter Include="Source Files\common\widgets\MandatoryComboBox">
1026+
<UniqueIdentifier>{c80b2f13-600b-4d31-8867-c3dfe9008c98}</UniqueIdentifier>
1027+
</Filter>
10221028
</ItemGroup>
10231029
<ItemGroup>
10241030
<ClCompile Include="common\GenericEditProvider.cpp">
@@ -3451,6 +3457,9 @@
34513457
<ClCompile Include="common\KactusProxyStyle.cpp">
34523458
<Filter>Source Files\common</Filter>
34533459
</ClCompile>
3460+
<ClCompile Include="common\widgets\MandatoryComboBox\MandatoryComboBox.cpp">
3461+
<Filter>Source Files\common\widgets\MandatoryComboBox</Filter>
3462+
</ClCompile>
34543463
</ItemGroup>
34553464
<ItemGroup>
34563465
<CustomBuild Include="common\layouts\HCollisionLayout.inl">
@@ -6227,5 +6236,8 @@
62276236
<QtMoc Include="library\HierarchyModel.h">
62286237
<Filter>Header Files\library</Filter>
62296238
</QtMoc>
6239+
<QtMoc Include="common\widgets\MandatoryComboBox\MandatoryComboBox.h">
6240+
<Filter>Header Files\common\widgets\MandatoryComboBox</Filter>
6241+
</QtMoc>
62306242
</ItemGroup>
62316243
</Project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//-----------------------------------------------------------------------------
2+
// File: MandatoryComboBox.cpp
3+
//-----------------------------------------------------------------------------
4+
// Project: Kactus 2
5+
// Author: Anton Hagqvist
6+
// Date: 26.06.2026
7+
//
8+
// Description:
9+
// Combobox for mandatory items. Implements correct item colors for dark mode.
10+
//-----------------------------------------------------------------------------
11+
12+
#include "MandatoryComboBox.h"
13+
14+
#include <common/KactusUtils.h>
15+
#include <KactusAPI/include/KactusColors.h>
16+
17+
MandatoryComboBox::MandatoryComboBox(QWidget* parent) : QComboBox(parent)
18+
{
19+
setProperty("mandatoryField", true);
20+
isDarkMode_ = KactusUtils::darkThemeEnabled();
21+
}
22+
23+
void MandatoryComboBox::showPopup()
24+
{
25+
// Override color of text in combobox if dark mode is in use. Can't be set
26+
// in one style sheet, as it also affects the selected value shown when popup is closed.
27+
if (isDarkMode_)
28+
{
29+
auto textColorAsRGB = KactusUtils::colorToRgbString(KactusColors::REGULAR_TEXT);
30+
setStyleSheet("QComboBox { color: " % textColorAsRGB % "; selection-color: black; }");
31+
}
32+
QComboBox::showPopup();
33+
}
34+
35+
void MandatoryComboBox::hidePopup()
36+
{
37+
if (isDarkMode_)
38+
{
39+
setStyleSheet("QComboBox { color: black; }");
40+
}
41+
QComboBox::hidePopup();
42+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//-----------------------------------------------------------------------------
2+
// File: MandatoryComboBox.h
3+
//-----------------------------------------------------------------------------
4+
// Project: Kactus 2
5+
// Author: Anton Hagqvist
6+
// Date: 26.06.2026
7+
//
8+
// Description:
9+
// Combobox for mandatory items. Implements correct item colors for dark mode.
10+
//-----------------------------------------------------------------------------
11+
12+
#pragma once
13+
14+
#include <QComboBox>
15+
16+
class MandatoryComboBox : public QComboBox
17+
{
18+
Q_OBJECT
19+
public:
20+
explicit MandatoryComboBox(QWidget* parent = nullptr);
21+
virtual ~MandatoryComboBox() = default;
22+
23+
MandatoryComboBox(MandatoryComboBox const& other) = delete;
24+
MandatoryComboBox& operator=(MandatoryComboBox const& other) = delete;
25+
26+
//! Overridden functions for changing color of combobox items correctly when using dark mode
27+
virtual void showPopup() override;
28+
virtual void hidePopup() override;
29+
30+
private:
31+
32+
//! Flag indicating dark mode is in use
33+
bool isDarkMode_ = false;
34+
};

common/widgets/interfaceModeSelector/interfacemodeselector.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//-----------------------------------------------------------------------------
1919
InterfaceModeSelector::InterfaceModeSelector(Document::Revision docRevision, General::InterfaceMode mode,
2020
bool showMonitor, QWidget* parent):
21-
QComboBox(parent),
21+
MandatoryComboBox(parent),
2222
showMonitor_(showMonitor)
2323
{
2424
initialize(docRevision);
@@ -57,9 +57,6 @@ void InterfaceModeSelector::initialize(Document::Revision docRevision)
5757

5858
connect(this, SIGNAL(currentTextChanged(const QString&)),
5959
this, SLOT(setMode(const QString&)), Qt::UniqueConnection);
60-
61-
// the interface mode is mandatory by default
62-
setProperty("mandatoryField", true);
6360
}
6461

6562
//-----------------------------------------------------------------------------

common/widgets/interfaceModeSelector/interfacemodeselector.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
#ifndef INTERFACEMODESELECTOR_H
1313
#define INTERFACEMODESELECTOR_H
1414

15+
#include <common/widgets/MandatoryComboBox/MandatoryComboBox.h>
16+
1517
#include <IPXACTmodels/generaldeclarations.h>
1618

1719
#include <IPXACTmodels/common/Document.h>
1820

19-
#include <QComboBox>
2021
#include <QSharedPointer>
2122

2223
//-----------------------------------------------------------------------------
2324
//! The editor to select an interface mode for bus interface within a component.
2425
//-----------------------------------------------------------------------------
25-
class InterfaceModeSelector : public QComboBox
26+
class InterfaceModeSelector : public MandatoryComboBox
2627
{
2728
Q_OBJECT
2829

@@ -83,7 +84,6 @@ public slots:
8384

8485
private:
8586

86-
8787
//! Set up the editor.
8888
void initialize(Document::Revision docRevision);
8989

editors/ComponentEditor/busInterfaces/general/SystemModeEditor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ groupEditor_(this)
3838
setTitle(tr("Mirrored system"));
3939
}
4040

41-
groupEditor_.setProperty("mandatoryField", true);
42-
4341
connect(&groupEditor_, SIGNAL(currentTextChanged(QString const&)),
4442
this, SLOT(onGroupChange(QString const&)), Qt::UniqueConnection);
4543

editors/ComponentEditor/busInterfaces/general/SystemModeEditor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "ModeEditorBase.h"
1616

1717
#include <IPXACTmodels/Component/BusInterface.h>
18+
#include <common/widgets/MandatoryComboBox/MandatoryComboBox.h>
1819

1920
#include <QComboBox>
2021
#include <QSharedPointer>
@@ -100,7 +101,7 @@ private slots:
100101
LibraryInterface* libHandler_;
101102

102103
//! Select the group this interface belongs to.
103-
QComboBox groupEditor_;
104+
MandatoryComboBox groupEditor_;
104105
};
105106

106107
#endif // SYSTEM_MODE_EDITOR_H

editors/ComponentEditor/common/ExpressionEditor.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ void ExpressionEditor::setExpression(QString const& expression)
8282
insertWord(term, cursor);
8383

8484
QString operation = delimiter.match(expression, delimiterIndex).captured();
85-
cursor.insertText(operation, colorFormat(KactusColors::REGULAR_TEXT));
85+
86+
if (property("mandatoryField") == true)
87+
{
88+
cursor.insertText(operation, colorFormat(Qt::black));
89+
}
90+
else
91+
{
92+
cursor.insertText(operation, colorFormat(KactusColors::REGULAR_TEXT));
93+
}
8694

8795
delimiterIndex = wordEndIndex + operation.length();
8896
}
@@ -199,7 +207,14 @@ void ExpressionEditor::colorCurrentWordBlack()
199207
QTextCursor cursor = textCursor();
200208
cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
201209
cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
202-
cursor.setCharFormat(colorFormat(KactusColors::REGULAR_TEXT));
210+
if (property("mandatoryField") == true)
211+
{
212+
cursor.setCharFormat(colorFormat(Qt::black));
213+
}
214+
else
215+
{
216+
cursor.setCharFormat(colorFormat(KactusColors::REGULAR_TEXT));
217+
}
203218
}
204219

205220
//-----------------------------------------------------------------------------
@@ -248,7 +263,14 @@ void ExpressionEditor::handleParentKeyPressEvent(QKeyEvent* keyEvent)
248263
if (keyEvent->text().isEmpty() == false)
249264
{
250265
auto cursor = textCursor();
251-
cursor.setCharFormat(colorFormat(KactusColors::REGULAR_TEXT));
266+
if (property("mandatoryField") == true)
267+
{
268+
cursor.setCharFormat(colorFormat(Qt::black));
269+
}
270+
else
271+
{
272+
cursor.setCharFormat(colorFormat(KactusColors::REGULAR_TEXT));
273+
}
252274
setTextCursor(cursor);
253275
}
254276

0 commit comments

Comments
 (0)