Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
0dad2567
Commit
0dad2567
authored
7 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Reload theme without restart (#137)
parent
54cf3418
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/UserSettingsPage.h
+3
-2
3 additions, 2 deletions
include/UserSettingsPage.h
src/UserSettingsPage.cc
+41
-1
41 additions, 1 deletion
src/UserSettingsPage.cc
src/main.cc
+0
-25
0 additions, 25 deletions
src/main.cc
with
44 additions
and
28 deletions
include/UserSettingsPage.h
+
3
−
2
View file @
0dad2567
...
...
@@ -36,8 +36,9 @@ public:
void
save
();
void
load
();
void
setTheme
(
QString
theme
)
{
theme_
=
theme
;
}
void
setTray
(
bool
state
)
{
isTrayEnabled_
=
state
;
}
void
applyTheme
();
void
setTheme
(
QString
theme
);
void
setTray
(
bool
state
);
QString
theme
()
const
{
return
!
theme_
.
isEmpty
()
?
theme_
:
"light"
;
}
bool
isTrayEnabled
()
const
{
return
isTrayEnabled_
;
}
...
...
This diff is collapsed.
Click to expand it.
src/UserSettingsPage.cc
+
41
−
1
View file @
0dad2567
...
...
@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<QApplication>
#include
<QComboBox>
#include
<QDebug>
#include
<QLabel>
...
...
@@ -33,7 +34,46 @@ UserSettings::load()
{
QSettings
settings
;
isTrayEnabled_
=
settings
.
value
(
"user/window/tray"
,
true
).
toBool
();
theme_
=
settings
.
value
(
"user/theme"
,
"default"
).
toString
();
theme_
=
settings
.
value
(
"user/theme"
,
"light"
).
toString
();
applyTheme
();
}
void
UserSettings
::
setTheme
(
QString
theme
)
{
theme_
=
theme
;
save
();
applyTheme
();
}
void
UserSettings
::
setTray
(
bool
state
)
{
isTrayEnabled_
=
state
;
save
();
}
void
UserSettings
::
applyTheme
()
{
QFile
stylefile
;
QPalette
pal
;
if
(
theme
()
==
"light"
)
{
stylefile
.
setFileName
(
":/styles/styles/nheko.qss"
);
pal
.
setColor
(
QPalette
::
Link
,
QColor
(
"#333"
));
}
else
if
(
theme
()
==
"dark"
)
{
stylefile
.
setFileName
(
":/styles/styles/nheko-dark.qss"
);
pal
.
setColor
(
QPalette
::
Link
,
QColor
(
"#d7d9dc"
));
}
else
{
stylefile
.
setFileName
(
":/styles/styles/system.qss"
);
}
stylefile
.
open
(
QFile
::
ReadOnly
);
QString
stylesheet
=
QString
(
stylefile
.
readAll
());
QApplication
::
setPalette
(
pal
);
qobject_cast
<
QApplication
*>
(
QApplication
::
instance
())
->
setStyleSheet
(
stylesheet
);
}
void
...
...
This diff is collapsed.
Click to expand it.
src/main.cc
+
0
−
25
View file @
0dad2567
...
...
@@ -73,31 +73,6 @@ main(int argc, char *argv[])
QSettings
settings
;
QFile
stylefile
;
if
(
!
settings
.
contains
(
"user/theme"
))
settings
.
setValue
(
"user/theme"
,
"light"
);
const
auto
theme
=
settings
.
value
(
"user/theme"
,
"light"
).
toString
();
QPalette
pal
;
if
(
theme
==
"light"
)
{
stylefile
.
setFileName
(
":/styles/styles/nheko.qss"
);
pal
.
setColor
(
QPalette
::
Link
,
QColor
(
"#333"
));
}
else
if
(
theme
==
"dark"
)
{
stylefile
.
setFileName
(
":/styles/styles/nheko-dark.qss"
);
pal
.
setColor
(
QPalette
::
Link
,
QColor
(
"#d7d9dc"
));
}
else
{
stylefile
.
setFileName
(
":/styles/styles/system.qss"
);
}
app
.
setPalette
(
pal
);
stylefile
.
open
(
QFile
::
ReadOnly
);
QString
stylesheet
=
QString
(
stylefile
.
readAll
());
app
.
setStyleSheet
(
stylesheet
);
// Set the default if a value has not been set.
if
(
settings
.
value
(
"font/size"
).
toInt
()
==
0
)
settings
.
setValue
(
"font/size"
,
12
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment