WSL/SLF GitLab Repository
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
inishell
Commits
2acf890f
Commit
2acf890f
authored
Feb 08, 2021
by
Michael Reisecker
Browse files
Minor structure changes
... to prepare having "valid" icon
parent
3f33f76c
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/gui_elements/Atomic.cc
View file @
2acf890f
...
...
@@ -58,8 +58,6 @@ Atomic::Atomic(QString section, QString key, QWidget *parent)
*/
void
Atomic
::
setDefaultPanelStyles
(
const
QString
&
in_value
)
{
setPanelStyle
(
FAULTY
,
false
);
//first we disable temporary styles
setPanelStyle
(
VALID
,
false
);
const
bool
is_default
=
(
QString
::
compare
(
in_value
,
this
->
property
(
"default_value"
).
toString
(),
Qt
::
CaseInsensitive
)
==
0
);
setPanelStyle
(
DEFAULT
,
is_default
&&
!
this
->
property
(
"default_value"
).
isNull
()
&&
!
in_value
.
isNull
());
...
...
@@ -197,11 +195,8 @@ void Atomic::setPanelStyle(const PanelStyle &style, const bool &set, QWidget *wi
case
DEFAULT
:
style_string
=
"shows_default"
;
break
;
case
FAULTY
:
style_string
=
"faulty"
;
break
;
case
VALID
:
style_string
=
"valid"
;
case
INVALID
:
style_string
=
"invalid"
;
}
widget_to_set
->
setProperty
(
style_string
.
toLocal8Bit
(),
set
?
"true"
:
"false"
);
this
->
style
()
->
unpolish
(
widget_to_set
);
//if a property is set dynamically, we might have to refresh
...
...
@@ -209,13 +204,12 @@ void Atomic::setPanelStyle(const PanelStyle &style, const bool &set, QWidget *wi
}
//https://wiki.qt.io/Technical_FAQ#How_can_my_stylesheet_account_for_custom_properties.3F
/**
* @brief S
witch between "faulty" and "valid" panel styl
es.
* @param[in]
on
True to set "
faulty
", false to
set
"valid".
* @brief S
tyle a panel to contain invalid valu
es.
* @param[in]
invalid
True to set "
invalid
", false to
disable (=
"valid"
)
.
*/
void
Atomic
::
set
V
alid
Panel
Style
(
const
bool
&
on
)
void
Atomic
::
set
Inv
alidStyle
(
const
bool
&
invalid
)
{
setPanelStyle
(
VALID
,
on
);
setPanelStyle
(
FAULTY
,
!
on
);
setPanelStyle
(
INVALID
,
invalid
);
}
/**
...
...
src/gui_elements/Atomic.h
View file @
2acf890f
...
...
@@ -46,8 +46,7 @@ class Atomic : public QWidget {
enum
PanelStyle
{
MANDATORY
,
DEFAULT
,
VALID
,
FAULTY
INVALID
};
Atomic
(
QString
section
,
QString
key
,
QWidget
*
parent
=
nullptr
);
virtual
void
setDefaultPanelStyles
(
const
QString
&
in_value
);
...
...
@@ -61,7 +60,7 @@ class Atomic : public QWidget {
void
setEmphasisWidget
(
QWidget
*
emphasis_widget
,
const
bool
&
set_object_name
=
true
);
QString
getId
()
const
noexcept
{
return
section_
+
Cst
::
sep
+
key_
;
}
void
setPanelStyle
(
const
PanelStyle
&
style
,
const
bool
&
set
=
true
,
QWidget
*
widget
=
nullptr
);
void
set
V
alid
Panel
Style
(
const
bool
&
on
);
void
set
Inv
alidStyle
(
const
bool
&
on
);
void
substituteKeys
(
QDomElement
&
parent_element
,
const
QString
&
replace
,
const
QString
&
replace_with
);
QSpacerItem
*
buildSpacer
();
...
...
src/gui_elements/Number.cc
View file @
2acf890f
...
...
@@ -167,8 +167,6 @@ Number::~Number()
*/
void
Number
::
setDefaultPanelStyles
(
const
QString
&
in_value
)
{
setPanelStyle
(
FAULTY
,
false
);
//first we disable temporary styles
setPanelStyle
(
VALID
,
false
);
bool
is_default
=
false
;
bool
success_inval
,
success_default
;
double
inval
=
in_value
.
toDouble
(
&
success_inval
);
...
...
@@ -307,7 +305,7 @@ void Number::setOptions(const QDomNode &options)
QString
bg_color
(
colors
::
getQColor
(
"app_bg"
).
name
()
);
//find font color to use for hidden spinbox text dependent on background color:
if
(
options
.
toElement
().
attribute
(
"optional"
).
toLower
()
==
"false"
)
if
(
!
qobject_cast
<
QLabel
*>
(
getEmphasisWidget
()))
//the entry widget is used for styling
if
(
!
qobject_cast
<
QLabel
*>
(
getEmphasisWidget
()))
//the entry widget is used for styling
bg_color
=
colors
::
getQColor
(
"mandatory"
).
name
();
number_element_
->
setStyleSheet
(
"* [empty=
\"
true
\"
] {color: "
+
bg_color
+
"}"
);
...
...
@@ -391,7 +389,7 @@ void Number::checkStrValue(const QString &str_check)
setDefaultPanelStyles
(
str_check
);
if
(
expr
::
checkExpression
(
str_check
,
evaluation_success
,
substitutions_
)
||
!
evaluation_success
)
set
V
alid
Panel
Style
(
evaluation_success
||
str_check
.
isEmpty
());
set
Inv
alidStyle
(
!
evaluation_success
&&
!
str_check
.
isEmpty
());
QTimer
::
singleShot
(
1
,
this
,
[
=
]{
setEmpty
(
false
);
});
setIniValue
(
str_check
);
//it is just a hint - save anyway
}
...
...
src/gui_elements/Textfield.cc
View file @
2acf890f
...
...
@@ -129,11 +129,12 @@ void Textfield::checkValue(const QString &text)
if
(
!
validation_regex_
.
isNull
())
{
//check against regex specified in XML
const
QRegularExpression
rex_xml
(
validation_regex_
);
const
QRegularExpressionMatch
xml_match
(
rex_xml
.
match
(
text
));
set
V
alid
Panel
Style
(
xml_match
.
captured
(
idx_full
)
=
=
text
&&
!
text
.
isEmpty
());
set
Inv
alidStyle
(
xml_match
.
captured
(
idx_full
)
!
=
text
&&
!
text
.
isEmpty
());
}
else
{
//check for (arithmetic) expressions
bool
evaluation_success
;
if
(
expr
::
checkExpression
(
text
,
evaluation_success
,
substitutions_
,
needs_prefix_for_evaluation_
))
setValidPanelStyle
(
evaluation_success
);
const
bool
is_expression
=
expr
::
checkExpression
(
text
,
evaluation_success
,
substitutions_
,
needs_prefix_for_evaluation_
);
setInvalidStyle
((
is_expression
&&
!
evaluation_success
)
&&
!
text
.
isEmpty
());
}
}
setIniValue
(
text
);
//checks are just a hint - set anyway
...
...
src/main/colors.cc
View file @
2acf890f
...
...
@@ -71,10 +71,8 @@ QColor getQColor(const QString &colorname)
name
=
"sl_red"
;
else
if
(
name
==
"default_values"
)
name
=
"sl_base00"
;
else
if
(
name
==
"
faulty
_values"
)
else
if
(
name
==
"
invalid
_values"
)
name
=
"sl_yellow"
;
else
if
(
name
==
"valid_values"
)
return
(
use_darkmode
)
?
QColor
(
"white"
)
:
QColor
();
else
if
(
name
==
"number"
)
name
=
"sl_cyan"
;
else
if
(
name
==
"groupborder"
)
...
...
src/main/main.cc
View file @
2acf890f
...
...
@@ -189,11 +189,10 @@ void setAppStylesheet(QApplication &app, const command_line_args &cmd_args)
* of our design elements trying to take into account current OS color scheme settings.
*/
app
.
setStyleSheet
(
" \
* [mandatory=
\"
true
\"
] {
background-color: "
+
colors
::
getQColor
(
"mandatory"
).
name
()
+
"
; color: "
+
colors
::
getQColor
(
"
normal
"
).
name
()
+
"} \
* [mandatory=
\"
true
\"
] {
font: bold
; color: "
+
colors
::
getQColor
(
"
mandatory
"
).
name
()
+
"} \
* [shows_default=
\"
true
\"
] {font-style: italic; color: "
+
colors
::
getQColor
(
"default_values"
).
name
()
+
"} \
* [faulty=
\"
true
\"
] {color: "
+
colors
::
getQColor
(
"faulty_values"
).
name
()
+
"} \
* [valid=
\"
true
\"
] {color: "
+
colors
::
getQColor
(
"valid_values"
).
name
()
+
"} \
* [highlight=
\"
true
\"
] {background-color: "
+
colors
::
getQColor
(
"sl_yellow"
).
name
()
+
"} \
* [invalid=
\"
true
\"
] {color:"
+
colors
::
getQColor
(
"invalid_values"
).
name
()
+
";} \
* [highlight=
\"
true
\"
] {background-color: "
+
colors
::
getQColor
(
"sl_yellow"
).
name
()
+
"} \
QTabWidget {padding: 0px; font-weight: bold; background-color: "
+
colors
::
getQColor
(
"app_bg"
).
name
()
+
"} \
QTabWidget:pane {background-color: "
+
colors
::
getQColor
(
"app_bg"
).
name
()
+
"} \
QScrollArea {background-color: "
+
colors
::
getQColor
(
"app_bg"
).
name
()
+
"} \
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment