Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-client-windows
Commits
6f4d4ee0
Commit
6f4d4ee0
authored
Feb 17, 2020
by
Ming Rui Zhang
Browse files
main: clean up and remove PROCESS_DPI_AWARE macro
Change-Id: Id06bff1bc5c2899224497008b18cd851a481bf10
parent
1ad2bda1
Changes
6
Hide whitespace changes
Inline
Side-by-side
jami-qt.pro
View file @
6f4d4ee0
...
...
@@ -17,7 +17,7 @@ win32-msvc {
QMAKE_LFLAGS
+=
/
ignore
:
4006
,
4049
,
4078
,
4098
/
FORCE
:
MULTIPLE
/
INCREMENTAL
:
NO
/
Debug
/
LTCG
/
NODEFAULTLIB
:
LIBCMT
#
preprocessor
defines
DEFINES
+=
UNICODE
PROCESS_DPI_AWARE
=
1
QT_NO_DEBUG
NDEBUG
DEFINES
+=
UNICODE
QT_NO_DEBUG
NDEBUG
#
dependencies
LRC
=
..
/
lrc
...
...
@@ -179,7 +179,8 @@ HEADERS += ./src/aboutdialog.h \
.
/
src
/
networkmanager
.
h
\
.
/
src
/
connectivitymonitor
.
h
\
.
/
src
/
userprofile
.
h
\
.
/
src
/
qmlclipboardadapter
.
h
.
/
src
/
qmlclipboardadapter
.
h
\
.
/
src
/
mainapplication
.
h
SOURCES
+=
.
/
src
/
aboutdialog
.
cpp
\
.
/
src
/
banneditemwidget
.
cpp
\
.
/
src
/
conversationsfilterwidget
.
cpp
\
...
...
@@ -246,7 +247,8 @@ SOURCES += ./src/aboutdialog.cpp \
.
/
src
/
recordwidget
.
cpp
\
.
/
src
/
networkmanager
.
cpp
\
.
/
src
/
connectivitymonitor
.
cpp
\
.
/
src
/
userprofile
.
cpp
.
/
src
/
userprofile
.
cpp
\
.
/
src
/
mainapplication
.
cpp
FORMS
+=
.
/
src
/
aboutdialog
.
ui
\
.
/
src
/
advancedsipsettingwidget
.
ui
\
.
/
src
/
callwidget
.
ui
\
...
...
src/main.cpp
View file @
6f4d4ee0
/***************************************************************************
* Copyright (C) 2015-20
19
by Savoir-faire Linux *
* Copyright (C) 2015-20
20
by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
...
...
@@ -17,286 +18,42 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include
"mainwindow.h"
#include
"accountmigrationdialog.h"
#include
"globalinstances.h"
#include
"networkmanager.h"
#include
"lrcinstance.h"
#include
"pixbufmanipulator.h"
#include
"mainapplication.h"
#include
"runguard.h"
#include
"utils.h"
#include
"splashscreen.h"
#include
"aboutdialog.h"
#include
"qmlclipboardadapter.h"
#include
<QApplication>
#include
<QFile>
#include
<QMessageBox>
#include
<QFontDatabase>
#include
<QLibraryInfo>
#include
<QTranslator>
#include
<thread>
#include
<ciso646>
#include
<locale.h>
#ifdef Q_OS_WIN
#include
<windows.h>
#endif
#if defined _MSC_VER && !COMPILE_ONLY
#include
<gnutls/gnutls.h>
#endif
void
consoleDebug
()
{
#ifdef Q_OS_WIN
AllocConsole
();
SetConsoleCP
(
CP_UTF8
);
freopen
(
"CONOUT$"
,
"w"
,
stdout
);
freopen
(
"CONOUT$"
,
"w"
,
stderr
);
COORD
coordInfo
;
coordInfo
.
X
=
130
;
coordInfo
.
Y
=
9000
;
SetConsoleScreenBufferSize
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
coordInfo
);
SetConsoleMode
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
ENABLE_QUICK_EDIT_MODE
|
ENABLE_EXTENDED_FLAGS
);
#endif
}
#ifdef _MSC_VER
void
vsConsoleDebug
()
{
// Print debug to output window if using VS
QObject
::
connect
(
&
LRCInstance
::
behaviorController
(),
&
lrc
::
api
::
BehaviorController
::
debugMessageReceived
,
[](
const
std
::
string
&
message
)
{
OutputDebugStringA
((
message
+
"
\n
"
).
c_str
());
});
}
#endif
void
fileDebug
(
QFile
&
debugFile
)
{
QObject
::
connect
(
&
LRCInstance
::
behaviorController
(),
&
lrc
::
api
::
BehaviorController
::
debugMessageReceived
,
[
&
debugFile
](
const
std
::
string
&
message
)
{
if
(
debugFile
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Append
))
{
auto
msg
=
(
message
+
"
\n
"
).
c_str
();
debugFile
.
write
(
msg
,
qstrlen
(
msg
));
debugFile
.
close
();
}
});
}
void
exitApp
(
RunGuard
&
guard
)
{
GlobalSystemTray
::
instance
().
hide
();
guard
.
release
();
}
#include
<QCryptographicHash>
#include
<QQmlEngine>
#include
<QQmlApplicationEngine>
int
main
(
int
argc
,
char
*
argv
[])
{
setlocale
(
LC_ALL
,
"en_US.utf8"
);
char
ARG_DISABLE_WEB_SECURITY
[]
=
"--disable-web-security"
;
int
newArgc
=
argc
+
1
+
1
;
char
**
newArgv
=
new
char
*
[
newArgc
];
for
(
int
i
=
0
;
i
<
argc
;
i
++
)
{
newArgv
[
i
]
=
argv
[
i
];
}
newArgv
[
argc
]
=
ARG_DISABLE_WEB_SECURITY
;
newArgv
[
argc
+
1
]
=
nullptr
;
#if defined(Q_OS_WIN) && (PROCESS_DPI_AWARE)
SetProcessDPIAware
();
#endif // Q_OS_WIN
#ifdef Q_OS_LINUX
if
(
!
getenv
(
"QT_QPA_PLATFORMTHEME"
))
setenv
(
"QT_QPA_PLATFORMTHEME"
,
"gtk3"
,
true
);
#endif
QApplication
a
(
newArgc
,
newArgv
);
QCoreApplication
::
setApplicationName
(
"Ring"
);
QCoreApplication
::
setOrganizationDomain
(
"jami.net"
);
MainApplication
::
applicationInitialization
();
// runguard to make sure that only one instance runs at a time
QCryptographicHash
appData
(
QCryptographicHash
::
Sha256
);
appData
.
addData
(
QApplication
::
applicationName
().
toUtf8
());
appData
.
addData
(
QApplication
::
organizationDomain
().
toUtf8
());
RunGuard
guard
(
appData
.
result
());
if
(
!
guard
.
tryToRun
())
{
// no need to exitApp since app is not set up
guard
.
release
();
return
0
;
}
for
(
auto
string
:
QCoreApplication
::
arguments
())
{
if
(
string
==
"-d"
||
string
==
"--debug"
)
{
consoleDebug
();
}
}
Utils
::
removeOldVersions
();
QApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
,
false
);
QGuiApplication
::
setAttribute
(
Qt
::
AA_UseHighDpiPixmaps
);
auto
startMinimized
=
false
;
QString
uri
=
""
;
auto
appDir
=
qApp
->
applicationDirPath
()
+
"/"
;
const
auto
locale_name
=
QLocale
::
system
().
name
();
const
auto
locale_lang
=
locale_name
.
split
(
'_'
)[
0
];
QTranslator
qtTranslator_lang
;
QTranslator
qtTranslator_name
;
if
(
locale_name
!=
locale_lang
)
{
if
(
qtTranslator_lang
.
load
(
"qt_"
+
locale_lang
,
QLibraryInfo
::
location
(
QLibraryInfo
::
TranslationsPath
)))
a
.
installTranslator
(
&
qtTranslator_lang
);
}
qtTranslator_name
.
load
(
"qt_"
+
locale_name
,
QLibraryInfo
::
location
(
QLibraryInfo
::
TranslationsPath
));
a
.
installTranslator
(
&
qtTranslator_name
);
QTranslator
lrcTranslator_lang
;
QTranslator
lrcTranslator_name
;
if
(
locale_name
!=
locale_lang
)
{
if
(
lrcTranslator_lang
.
load
(
appDir
+
"share/libringclient/translations/lrc_"
+
locale_lang
))
a
.
installTranslator
(
&
lrcTranslator_lang
);
}
if
(
lrcTranslator_name
.
load
(
appDir
+
"share/libringclient/translations/lrc_"
+
locale_name
))
a
.
installTranslator
(
&
lrcTranslator_name
);
QTranslator
mainTranslator_lang
;
QTranslator
mainTranslator_name
;
if
(
locale_name
!=
locale_lang
)
{
if
(
mainTranslator_lang
.
load
(
appDir
+
"share/ring/translations/ring_client_windows_"
+
locale_lang
))
a
.
installTranslator
(
&
mainTranslator_lang
);
}
if
(
mainTranslator_name
.
load
(
appDir
+
"share/ring/translations/ring_client_windows_"
+
locale_name
))
a
.
installTranslator
(
&
mainTranslator_name
);
QFont
font
;
font
.
setFamily
(
"Segoe UI"
);
a
.
setFont
(
font
);
#ifndef DEBUG_STYLESHEET
#ifdef Q_OS_LINUX
QFile
file
(
":/stylesheet.linux.css"
);
#else
QFile
file
(
":/stylesheet.css"
);
#endif
if
(
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
a
.
setStyleSheet
(
file
.
readAll
());
file
.
close
();
}
#endif
#if defined _MSC_VER && !COMPILE_ONLY
gnutls_global_init
();
#endif
GlobalInstances
::
setPixmapManipulator
(
std
::
make_unique
<
PixbufManipulator
>
());
SplashScreen
*
splash
=
new
SplashScreen
();
std
::
atomic_bool
isMigrating
(
false
);
LRCInstance
::
init
(
[
&
splash
,
&
a
,
&
isMigrating
]
{
splash
->
setupUI
(
QPixmap
(
":/images/logo-jami-standard-coul.png"
),
QString
(
"Jami - "
)
+
QObject
::
tr
(
"Migration needed"
),
QObject
::
tr
(
"Migration in progress... This may take a while."
),
QColor
(
232
,
232
,
232
)
);
splash
->
show
();
isMigrating
=
true
;
while
(
isMigrating
)
{
a
.
processEvents
();
}
},
[
&
splash
,
&
isMigrating
]
{
while
(
!
isMigrating
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
10
));
}
isMigrating
=
false
;
});
splash
->
hide
();
LRCInstance
::
subscribeToDebugReceived
();
LRCInstance
::
getAPI
().
holdConferences
=
false
;
QDir
logPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
));
// since logPath will be .../Ring, we use cdUp to remove it.
logPath
.
cdUp
();
QFile
debugFile
(
logPath
.
absolutePath
()
+
"/jami/jami.log"
);
for
(
auto
string
:
QCoreApplication
::
arguments
())
{
if
(
string
.
startsWith
(
"jami:"
))
{
uri
=
string
;
}
else
{
if
(
string
==
"-m"
||
string
==
"--minimized"
)
{
startMinimized
=
true
;
}
auto
dbgFile
=
string
==
"-f"
||
string
==
"--file"
;
auto
dbgConsole
=
string
==
"-c"
||
string
==
"--vsconsole"
;
if
(
dbgFile
||
dbgConsole
)
{
if
(
dbgFile
)
{
debugFile
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Truncate
);
debugFile
.
close
();
fileDebug
(
debugFile
);
}
#ifdef _MSC_VER
if
(
dbgConsole
)
{
vsConsoleDebug
();
}
#endif
}
}
}
auto
accountList
=
LRCInstance
::
accountModel
().
getAccountList
();
for
(
const
std
::
string
&
i
:
accountList
)
{
auto
accountStatus
=
LRCInstance
::
accountModel
().
getAccountInfo
(
i
).
status
;
if
(
accountStatus
==
lrc
::
api
::
account
::
Status
::
ERROR_NEED_MIGRATION
)
{
std
::
unique_ptr
<
AccountMigrationDialog
>
dialog
=
std
::
make_unique
<
AccountMigrationDialog
>
(
nullptr
,
i
);
int
status
=
dialog
->
exec
();
//migration failed
if
(
!
status
)
{
#ifdef Q_OS_WIN
FreeConsole
();
#endif
exitApp
(
guard
);
return
status
;
}
}
}
splash
->
finish
(
&
MainWindow
::
instance
());
splash
->
deleteLater
();
QFontDatabase
::
addApplicationFont
(
":/images/FontAwesome.otf"
);
char
ARG_DISABLE_WEB_SECURITY
[]
=
"--disable-web-security"
;
auto
newArgv
=
MainApplication
::
parseInputArgument
(
argc
,
argv
,
ARG_DISABLE_WEB_SECURITY
);
QSettings
settings
(
"jami.net"
,
"Jami"
);
if
(
not
startMinimized
)
{
MainWindow
::
instance
().
showWindow
();
}
else
{
MainWindow
::
instance
().
showMinimized
();
MainWindow
::
instance
().
hide
();
MainApplication
a
(
argc
,
newArgv
);
if
(
!
a
.
applicationSetup
())
{
guard
.
release
();
a
.
exitApp
();
return
0
;
}
QObject
::
connect
(
&
a
,
&
QApplication
::
aboutToQuit
,
[
&
guard
]
{
exitApp
(
guard
);
});
// for deployment and register types
qmlRegisterType
<
QmlClipboardAdapter
>
(
"MyQClipboard"
,
1
,
0
,
"QClipboard"
);
...
...
@@ -304,11 +61,9 @@ main(int argc, char* argv[])
engine
.
load
(
QUrl
(
QStringLiteral
(
"qrc:/src/KeyBoardShortcutTable.qml"
)));
engine
.
load
(
QUrl
(
QStringLiteral
(
"qrc:/src/UserProfileCard.qml"
)));
// exec the application
auto
ret
=
a
.
exec
();
#ifdef Q_OS_WIN
FreeConsole
();
#endif
guard
.
release
();
return
ret
;
}
src/mainapplication.cpp
0 → 100644
View file @
6f4d4ee0
/***************************************************************************
* Copyright (C) 2015-2020 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include
"mainapplication.h"
#include
"mainwindow.h"
#include
"accountmigrationdialog.h"
#include
"globalinstances.h"
#include
"lrcinstance.h"
#include
"pixbufmanipulator.h"
#include
"utils.h"
#include
<locale.h>
#ifdef Q_OS_WIN
#include
<windows.h>
#endif
#if defined _MSC_VER && !COMPILE_ONLY
#include
<gnutls/gnutls.h>
#endif
MainApplication
::
MainApplication
(
int
&
argc
,
char
**
argv
)
:
QApplication
(
argc
,
argv
)
{
QObject
::
connect
(
this
,
&
QApplication
::
aboutToQuit
,
[
this
]
{
exitApp
();
});
}
void
MainApplication
::
applicationInitialization
()
{
// some attributes are needed to be set before the creation of the sapplication
QApplication
::
setApplicationName
(
"Ring"
);
QApplication
::
setOrganizationDomain
(
"jami.net"
);
QApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
,
true
);
QApplication
::
setAttribute
(
Qt
::
AA_UseHighDpiPixmaps
);
}
void
MainApplication
::
consoleDebug
()
{
#ifdef Q_OS_WIN
AllocConsole
();
SetConsoleCP
(
CP_UTF8
);
freopen
(
"CONOUT$"
,
"w"
,
stdout
);
freopen
(
"CONOUT$"
,
"w"
,
stderr
);
COORD
coordInfo
;
coordInfo
.
X
=
130
;
coordInfo
.
Y
=
9000
;
SetConsoleScreenBufferSize
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
coordInfo
);
SetConsoleMode
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
ENABLE_QUICK_EDIT_MODE
|
ENABLE_EXTENDED_FLAGS
);
#endif
}
void
MainApplication
::
vsConsoleDebug
()
{
#ifdef _MSC_VER
// Print debug to output window if using VS
QObject
::
connect
(
&
LRCInstance
::
behaviorController
(),
&
lrc
::
api
::
BehaviorController
::
debugMessageReceived
,
[](
const
std
::
string
&
message
)
{
OutputDebugStringA
((
message
+
"
\n
"
).
c_str
());
});
#endif
}
void
MainApplication
::
fileDebug
(
QFile
*
debugFile
)
{
QObject
::
connect
(
&
LRCInstance
::
behaviorController
(),
&
lrc
::
api
::
BehaviorController
::
debugMessageReceived
,
[
debugFile
](
const
std
::
string
&
message
)
{
if
(
debugFile
->
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Append
))
{
auto
msg
=
(
message
+
"
\n
"
).
c_str
();
debugFile
->
write
(
msg
,
qstrlen
(
msg
));
debugFile
->
close
();
}
});
}
void
MainApplication
::
exitApp
()
{
GlobalSystemTray
::
instance
().
hide
();
#ifdef Q_OS_WIN
FreeConsole
();
#endif
}
char
**
MainApplication
::
parseInputArgument
(
int
&
argc
,
char
*
argv
[],
char
*
argToParse
)
{
// forcefully append argToParse
int
oldArgc
=
argc
;
argc
=
argc
+
1
+
1
;
char
**
newArgv
=
new
char
*
[
argc
];
for
(
int
i
=
0
;
i
<
oldArgc
;
i
++
)
{
newArgv
[
i
]
=
argv
[
i
];
}
newArgv
[
oldArgc
]
=
argToParse
;
newArgv
[
oldArgc
+
1
]
=
nullptr
;
return
newArgv
;
}
QString
MainApplication
::
getDebugFilePath
()
{
QDir
logPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
));
// since logPath will be .../Ring, we use cdUp to remove it.
logPath
.
cdUp
();
return
QString
(
logPath
.
absolutePath
()
+
"/jami/jami.log"
);
}
void
MainApplication
::
loadTranslations
()
{
auto
appDir
=
qApp
->
applicationDirPath
()
+
"/"
;
const
auto
locale_name
=
QLocale
::
system
().
name
();
const
auto
locale_lang
=
locale_name
.
split
(
'_'
)[
0
];
QTranslator
qtTranslator_lang
;
QTranslator
qtTranslator_name
;
if
(
locale_name
!=
locale_lang
)
{
if
(
qtTranslator_lang
.
load
(
"qt_"
+
locale_lang
,
QLibraryInfo
::
location
(
QLibraryInfo
::
TranslationsPath
)))
installTranslator
(
&
qtTranslator_lang
);
}
qtTranslator_name
.
load
(
"qt_"
+
locale_name
,
QLibraryInfo
::
location
(
QLibraryInfo
::
TranslationsPath
));
installTranslator
(
&
qtTranslator_name
);
QTranslator
lrcTranslator_lang
;
QTranslator
lrcTranslator_name
;
if
(
locale_name
!=
locale_lang
)
{
if
(
lrcTranslator_lang
.
load
(
appDir
+
"share/libringclient/translations/lrc_"
+
locale_lang
))
installTranslator
(
&
lrcTranslator_lang
);
}
if
(
lrcTranslator_name
.
load
(
appDir
+
"share/libringclient/translations/lrc_"
+
locale_name
))
installTranslator
(
&
lrcTranslator_name
);
QTranslator
mainTranslator_lang
;
QTranslator
mainTranslator_name
;
if
(
locale_name
!=
locale_lang
)
{
if
(
mainTranslator_lang
.
load
(
appDir
+
"share/ring/translations/ring_client_windows_"
+
locale_lang
))
installTranslator
(
&
mainTranslator_lang
);
}
if
(
mainTranslator_name
.
load
(
appDir
+
"share/ring/translations/ring_client_windows_"
+
locale_name
))
installTranslator
(
&
mainTranslator_name
);
}
void
MainApplication
::
initLrc
()
{
// init mainwindow and finish splash when mainwindow shows up
splash_
=
std
::
make_unique
<
SplashScreen
>
();
std
::
atomic_bool
isMigrating
(
false
);
LRCInstance
::
init
(
[
this
,
&
isMigrating
]
{
splash_
->
setupUI
(
QPixmap
(
":/images/logo-jami-standard-coul.png"
),
QString
(
"Jami - "
)
+
QObject
::
tr
(
"Migration needed"
),
QObject
::
tr
(
"Migration in progress... This may take a while."
),
QColor
(
232
,
232
,
232
)
);
splash_
->
show
();
isMigrating
=
true
;
while
(
isMigrating
)
{
this
->
processEvents
();
}
},
[
this
,
&
isMigrating
]
{
while
(
!
isMigrating
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
10
));
}
isMigrating
=
false
;
});
splash_
->
hide
();
LRCInstance
::
subscribeToDebugReceived
();
LRCInstance
::
getAPI
().
holdConferences
=
false
;
}
void
MainApplication
::
processInputArgument
(
bool
&
startMinimized
)
{
debugFile_
=
std
::
make_unique
<
QFile
>
(
getDebugFilePath
());
QString
uri
=
""
;
for
(
auto
string
:
QCoreApplication
::
arguments
())
{
if
(
string
.
startsWith
(
"jami:"
))
{
uri
=
string
;
}
else
{
if
(
string
==
"-m"
||
string
==
"--minimized"
)
{
startMinimized
=
true
;
}
auto
dbgFile
=
string
==
"-f"
||
string
==
"--file"
;
auto
dbgConsole
=
string
==
"-c"
||
string
==
"--vsconsole"
;
if
(
dbgFile
||
dbgConsole
)
{
if
(
dbgFile
)
{
debugFile_
->
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Truncate
);
debugFile_
->
close
();
fileDebug
(
debugFile_
.
get
());
}
#ifdef _MSC_VER
if
(
dbgConsole
)
{
vsConsoleDebug
();
}
#endif
}
}
}
}
void
MainApplication
::
setApplicationStyleSheet
()
{
#ifndef DEBUG_STYLESHEET
#ifdef Q_OS_LINUX
QFile
file
(
":/stylesheet.linux.css"
);
#else
QFile
file
(
":/stylesheet.css"
);
#endif
if
(
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
setStyleSheet
(
file
.
readAll
());
file
.
close
();
}
#endif
}
bool
MainApplication
::
startAccountMigration
()
{
auto
accountList
=
LRCInstance
::
accountModel
().
getAccountList
();
for
(
const
std
::
string
&
i
:
accountList
)
{
auto
accountStatus
=
LRCInstance
::
accountModel
().
getAccountInfo
(
i
).
status
;
if
(
accountStatus
==
lrc
::
api
::
account
::
Status
::
ERROR_NEED_MIGRATION
)
{
std
::
unique_ptr
<
AccountMigrationDialog
>
dialog
=
std
::
make_unique
<
AccountMigrationDialog
>
(
nullptr
,
i
);
int
status
=
dialog
->
exec
();
//migration failed
return
status
==
0
?
false
:
true
;
}
}
return
true
;
}
void
MainApplication
::
setApplicationFont
()
{
QFont
font
;
font
.
setFamily
(
"Segoe UI"
);
setFont
(
font
);