Skip to content

Commit 2b67254

Browse files
committed
Simplifies conditionals in darkmode flag definition for win32
1 parent a844f82 commit 2b67254

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

main.cpp

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,36 +123,32 @@ static int myCvErrorCallback( int /*status*/, const char* /*func_name*/,
123123

124124
int main(int argc, char *argv[])
125125
{
126-
// DFTFringe doesn't have a good darkmode palette
127-
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
128-
// Following code adds the platform argument programmatically
129-
130-
// Create a new argv array with existing args plus platform args
131-
#ifdef Q_OS_WIN
132-
int newArgc = argc + 2;
126+
#ifdef _WIN32
127+
// DFTFringe doesn't have a good darkmode palette
128+
// one could call "DFTFringe.exe -platform windows:darkmode=1" to disable dark mode (except for app borders)
129+
// Following code adds the platform argument programmatically
130+
// Create a new argv array with existing args plus platform args
131+
int newArgc = argc + 2;
132+
std::vector<std::string> args;
133+
args.reserve(newArgc);
134+
// Copy existing arguments
135+
for (int i = 0; i < argc; ++i) {
136+
args.emplace_back(argv[i]);
137+
}
138+
// Add new arguments
139+
args.emplace_back("-platform");
140+
args.emplace_back("windows:darkmode=1");
141+
// Build non-const char* array
142+
std::vector<char*> newArgv;
143+
newArgv.reserve(newArgc);
144+
for (auto &arg : args) {
145+
newArgv.push_back(&arg[0]); // C++11 guarantees contiguous storage
146+
}
147+
// Allow secondary instances
148+
SingleApplication app( newArgc, newArgv.data(), true );
133149
#else
134-
int newArgc = argc;
150+
SingleApplication app( argc, argv, true );
135151
#endif
136-
std::vector<std::string> args;
137-
args.reserve(newArgc);
138-
// Copy existing arguments
139-
for (int i = 0; i < argc; ++i) {
140-
args.emplace_back(argv[i]);
141-
}
142-
// Add new arguments
143-
#ifdef Q_OS_WIN
144-
args.emplace_back("-platform");
145-
args.emplace_back("windows:darkmode=1");
146-
#endif
147-
// Build non-const char* array
148-
std::vector<char*> newArgv;
149-
newArgv.reserve(newArgc);
150-
for (auto &arg : args) {
151-
newArgv.push_back(&arg[0]); // C++11 guarantees contiguous storage
152-
}
153-
154-
// Allow secondary instances
155-
SingleApplication app( newArgc, newArgv.data(), true );
156152

157153
MessageReceiver msgReceiver;
158154

0 commit comments

Comments
 (0)