1919
2020#include " Application.h"
2121
22- #include " common/Common.h"
2322#include " idupdater.h"
2423#include " ScheduledUpdateTask.h"
2524
3837#include < userenv.h>
3938#include < wtsapi32.h>
4039
40+ using namespace Qt ::StringLiterals;
41+
4142int main ( int argc, char *argv[] )
4243{
4344 return Application ( argc, argv ).run ();
@@ -48,7 +49,7 @@ int main( int argc, char *argv[] )
4849Application::Application ( int &argc, char **argv )
4950: QtSingleApplication( argc, argv )
5051{
51- log.setFileName (QDir::tempPath () + QStringLiteral ( " /id-updater.log" ) );
52+ log.setFileName (QDir::tempPath () + u " /id-updater.log" _s );
5253 if ( log.exists () && log.open ( QFile::WriteOnly|QFile::Append ) )
5354 qInstallMessageHandler ( msgHandler );
5455
@@ -57,27 +58,28 @@ Application::Application( int &argc, char **argv )
5758 QTranslator *t = new QTranslator ( this );
5859 QString lang;
5960 auto languages = QLocale ().uiLanguages ().first ();
60- if (languages.contains (QLatin1String ( " et" ) , Qt::CaseInsensitive))
61- lang = QStringLiteral ( " et" ) ;
62- else if (languages.contains (QLatin1String ( " ru" ) , Qt::CaseInsensitive))
63- lang = QStringLiteral ( " ru" ) ;
61+ if (languages.contains (" et" _L1 , Qt::CaseInsensitive))
62+ lang = u " et" _s ;
63+ else if (languages.contains (" ru" _L1 , Qt::CaseInsensitive))
64+ lang = u " ru" _s ;
6465 else
65- lang = QStringLiteral ( " en" ) ;
66- void (qt->load (QStringLiteral ( " :/qtbase_%1.qm" ) .arg (lang)));
67- void (common->load (QStringLiteral ( " :/common_%1.qm" ) .arg (lang)));
68- void (t->load (QStringLiteral ( " :/idupdater_%1.qm" ) .arg (lang)));
66+ lang = u " en" _s ;
67+ void (qt->load (" :/qtbase_%1.qm" _L1 .arg (lang)));
68+ void (common->load (" :/common_%1.qm" _L1 .arg (lang)));
69+ void (t->load (" :/idupdater_%1.qm" _L1 .arg (lang)));
6970 installTranslator ( qt );
7071 installTranslator ( common );
7172 installTranslator ( t );
7273#ifdef NDEBUG
7374 setLibraryPaths ({ applicationDirPath () });
7475#endif
75- setWindowIcon (QIcon (QStringLiteral ( " :/appicon.png" ) ));
76- setApplicationName (QStringLiteral ( " id-updater" ) );
77- setApplicationVersion (QStringLiteral ( " %1.%2.%3.%4" )
76+ setWindowIcon (QIcon (u " :/appicon.png" _s ));
77+ setApplicationName (u " id-updater" _s );
78+ setApplicationVersion (u " %1.%2.%3.%4" _s
7879 .arg ( MAJOR_VER ).arg ( MINOR_VER ).arg ( RELEASE_VER ).arg ( BUILD_VER ) );
79- setOrganizationDomain (QStringLiteral (" ria.ee" ));
80- setOrganizationName (QStringLiteral (" RIA" ));
80+ setOrganizationDomain (u" ria.ee" _s);
81+ setOrganizationName (u" RIA" _s);
82+ setStyle (u" windowsvista" _s);
8183 QNetworkProxyFactory::setUseSystemConfiguration (true );
8284}
8385
@@ -90,15 +92,15 @@ Application::~Application()
9092int Application::confTask ( const QStringList &args ) const
9193{
9294 ScheduledUpdateTask task;
93- if (args.contains (QStringLiteral ( " -status" ) ))
95+ if (args.contains (" -status" _L1 ))
9496 return task.status ();
95- if (args.contains (QStringLiteral ( " -daily" ) ))
97+ if (args.contains (" -daily" _L1 ))
9698 return task.configure (ScheduledUpdateTask::DAILY);
97- if (args.contains (QStringLiteral ( " -weekly" ) ))
99+ if (args.contains (" -weekly" _L1 ))
98100 return task.configure (ScheduledUpdateTask::WEEKLY);
99- if (args.contains (QStringLiteral ( " -monthly" ) ))
101+ if (args.contains (" -monthly" _L1 ))
100102 return task.configure (ScheduledUpdateTask::MONTHLY);
101- if (args.contains (QStringLiteral ( " -remove" ) ))
103+ if (args.contains (" -remove" _L1 ))
102104 task.remove ();
103105 return true ;
104106}
@@ -107,7 +109,7 @@ bool Application::execute(const QStringList &arguments)
107109{
108110 // http://www.codeproject.com/KB/vista-security/interaction-in-vista.aspx
109111 qDebug () << " ProcessStarter begin" ;
110- QString command = QDir::toNativeSeparators (applicationFilePath ()) + " " + arguments.join (' ' );
112+ QString command = QDir::toNativeSeparators (applicationFilePath ()) + ' ' + arguments.join (' ' );
111113 qDebug () << " command:" << command;
112114
113115 PWTS_SESSION_INFOW sessionInfo = 0 ;
@@ -163,32 +165,32 @@ bool Application::execute(const QStringList &arguments)
163165
164166void Application::messageReceived ( const QString &str )
165167{
166- w->checkUpdates (str.contains (" -autoupdate" ), str.contains (" -autoclose" ));
168+ w->checkUpdates (str.contains (" -autoupdate" _L1 ), str.contains (" -autoclose" _L1 ));
167169}
168170
169171void Application::msgHandler ( QtMsgType type, const QMessageLogContext &, const QString &msg )
170172{
171- QFile *log = &qobject_cast<Application*>(qApp-> instance () )->log ;
172- log->write (QDateTime::currentDateTime ().toString (QStringLiteral ( " yyyy-MM-dd hh:mm:ss:zzz " ) ).toUtf8 ());
173+ QFile *log = &qobject_cast<Application*>(qApp)->log ;
174+ log->write (QDateTime::currentDateTime ().toString (u " yyyy-MM-dd hh:mm:ss:zzz " _s ).toUtf8 ());
173175 switch ( type )
174176 {
175- case QtDebugMsg: log->write (QStringLiteral ( " DBG: %1\n " ) .arg (msg).toUtf8 ()); break ;
176- case QtInfoMsg: log->write (QStringLiteral ( " INF: %1\n " ) .arg (msg).toUtf8 ()); break ;
177- case QtWarningMsg: log->write (QStringLiteral ( " WRN: %1\n " ) .arg (msg).toUtf8 ()); break ;
178- case QtCriticalMsg: log->write (QStringLiteral ( " CRI: %1\n " ) .arg ( msg).toUtf8 ()); break ;
179- case QtFatalMsg: log->write (QStringLiteral ( " FAT: %1\n " ) .arg (msg).toUtf8 ()); abort ();
177+ case QtDebugMsg: log->write (" DBG: %1\n " _L1 .arg (msg).toUtf8 ()); break ;
178+ case QtInfoMsg: log->write (" INF: %1\n " _L1 .arg (msg).toUtf8 ()); break ;
179+ case QtWarningMsg: log->write (" WRN: %1\n " _L1 .arg (msg).toUtf8 ()); break ;
180+ case QtCriticalMsg: log->write (" CRI: %1\n " _L1 .arg ( msg).toUtf8 ()); break ;
181+ case QtFatalMsg: log->write (" FAT: %1\n " _L1 .arg (msg).toUtf8 ()); abort ();
180182 }
181183}
182184
183185void Application::printHelp ()
184186{
185- QMessageBox::information (nullptr , QStringLiteral ( " ID Updater" ), QStringLiteral (
187+ QMessageBox::information (nullptr , u " ID Updater" _s,
186188 " <table><tr><td>-help</td><td>%1</td></tr>"
187189 " <tr><td>-autoupdate</td><td>%2</td></tr>"
188190 " <tr><td>-autoclose</td><td>%3</td></tr>"
189191 " <tr><td>-task</td><td>%4</td></tr>"
190192 " <tr><td colspan=\" 2\" >-daily|-monthly|-weekly|-remove</td></tr>"
191- " <tr><td colspan=\" 2\" >%6</td></tr></table>" ) .arg (
193+ " <tr><td colspan=\" 2\" >%6</td></tr></table>" _L1 .arg (
192194 tr (" this help" ),
193195 tr (" update automatically" ),
194196 tr (" close automatically when no updates are available" ),
@@ -201,36 +203,36 @@ int Application::run()
201203 QStringList args = arguments ();
202204 args.removeFirst ();
203205 qDebug () << " Starting updater with arguments" << args;
204- if ( args.contains (" -help" ) || args.contains (" -?" ) || args.contains (" /?" ) )
206+ if (args.contains (" -help" _L1 ) || args.contains (" -?" _L1 ) || args.contains (" /?" _L1) )
205207 {
206208 printHelp ();
207209 return 0 ;
208210 }
209- if ( args.contains (" -daily" ) || args.contains (" -weekly" ) || args.contains (" -monthly" ) || args.contains (" -remove" ) )
211+ if (args.contains (" -daily" _L1 ) || args.contains (" -weekly" _L1 ) || args.contains (" -monthly" _L1 ) || args.contains (" -remove" _L1) )
210212 {
211213 int result = confTask ( args );
212214 if ( !result )
213- QMessageBox::warning ( 0 , " ID Updater" ,
215+ QMessageBox::warning (nullptr , u " ID Updater" _s ,
214216 tr (" Failed to set schedule, check permissions. Try again with administrator permissions." ) );
215217 return !result;
216218 }
217219
218- if (args.contains (" -status" ))
220+ if (args.contains (" -status" _L1 ))
219221 return confTask ( args );
220222
221- if ( args.contains (" -task" ) )
223+ if ( args.contains (" -task" _L1 ) )
222224 {
223- args.removeAll ( " -task" );
224- args << " -autoclose" ;
225+ args.removeAll (" -task" _L1 );
226+ args. append ( u " -autoclose" _s) ;
225227 return !execute (args);
226228 }
227229
228230 if ( isRunning () )
229- return !sendMessage ( args.join ( " " ) );
231+ return !sendMessage (args.join (' ' ) );
230232 connect ( this , &QtSingleApplication::messageReceived, this , &Application::messageReceived );
231233
232234 w = new idupdater ( this );
233- w->checkUpdates (args.contains (" -autoupdate" ), args.contains (" -autoclose" ));
235+ w->checkUpdates (args.contains (" -autoupdate" _L1 ), args.contains (" -autoclose" _L1 ));
234236
235237 return exec ();
236238}
0 commit comments