Skip to content

Commit b774160

Browse files
committedJun 14, 2021
Add default theme parameter to Application and use it in the tests to suppress the theme popup
1 parent 8efe4d6 commit b774160

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed
 

‎src/app/Application.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ QString userAgentSystem()
108108

109109
} // anon. namespace
110110

111-
Application::Application(int &argc, char **argv, bool haltOnParseError)
111+
Application::Application(
112+
int &argc,
113+
char **argv,
114+
bool haltOnParseError,
115+
const QString &defaultTheme)
112116
: QApplication(argc, argv)
113117
{
114118
Q_INIT_RESOURCE(resources);
@@ -153,7 +157,8 @@ Application::Application(int &argc, char **argv, bool haltOnParseError)
153157
mPathspec = parser.value("filter");
154158

155159
// Initialize theme.
156-
mTheme.reset(Theme::create(parser.value("theme")));
160+
QString theme = parser.value("theme");
161+
mTheme.reset(Theme::create(!theme.isEmpty() ? theme : defaultTheme));
157162
setStyle(mTheme->style());
158163
setStyleSheet(mTheme->styleSheet());
159164

‎src/app/Application.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ class Application : public QApplication
2323
Q_OBJECT
2424

2525
public:
26-
Application(int &argc, char **argv, bool haltOnParseError = false);
26+
Application(
27+
int &argc,
28+
char **argv,
29+
bool haltOnParseError = false,
30+
const QString &defaultTheme = QString());
2731

2832
void autoUpdate();
2933
bool restoreWindows();

‎test/Test.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@
1818
#define TEST_MAIN(TestClass) \
1919
int main(int argc, char *argv[]) \
2020
{ \
21-
std::vector<const char*> new_argv(argv, argv + argc); \
22-
new_argv.push_back("--theme Default"); \
23-
argc += 2; \
24-
argv = const_cast<char**>(new_argv.data()); \
25-
Application app(argc, argv); \
21+
Application app(argc, argv, false, "Default"); \
2622
TestClass test; \
2723
QTEST_SET_MAIN_SOURCE_PATH \
28-
return QTest::qExec(&test, {}); \
24+
return QTest::qExec(&test, app.arguments()); \
2925
}
3026

3127
class RepoView;

0 commit comments

Comments
 (0)
Please sign in to comment.