GUIApplication(...)
, ...
{
...
// setup common application data path
#ifdef Q_WS_WIN
QSettings registryCommon
("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
QSettings::NativeFormat);
mCommonApplicationDataFolder = registryCommon.value("Common AppData").toString();
mCommonApplicationDataFolder = mCommonApplicationDataFolder.replace("\\", "/");
#else
mCommonApplicationDataFolder
= QDir::homePath() + "/.config/";
#endif
if(!mCommonApplicationDataFolder.endsWith("/"))
mCommonApplicationDataFolder.append("/");
if(mVendor.isEmpty())
mCommonApplicationDataFolder.append(applicationName() + "/");
else
mCommonApplicationDataFolder.append(mVendor + "/" + applicationName() + "/");
mCommonSettings = new GUISettings(mCommonApplicationDataFolder + "Settings.ini", this);
// set translation file, mTransalator is Member
const QString languageFilePath
= applicationDirPath
() + "/data/" + language
();
showMessage(eInformation, languageFilePath + ".qm");
const QFile languageFile
(languageFilePath
+ ".qm");
if( languageFile.exists())
if(mTranslator.load(languageFilePath))
installTranslator(&mTranslator);
...
}
void GUIApplication::exec()
{
...
mMainWindow = new GUIMainWindow();
if( !applicationName().isEmpty() )
mMainWindow->setWindowTitle(applicationName() + " " + applicationVersion());
mMainWindow->show();
for( int i = 0; i < mMessageList.count(); i++)
showMessage(mMessageList.at(i).type, mMessageList.at(i).message, mMessageList.at(i).later);
mMessageList.clear();
}
void GUIApplication
::showMessage( MessageType iType,
const QString & iMessage,
bool iShowLater
) {
if( mMainWindow )
mMainWindow->showMessage( iType, iMessage, iShowLater );
else
{
MessageData data;
data.type = iType;
data.message = iMessage;
data.later = iShowLater;
mMessageList.append(data);
}
}
QString GUIApplication
::language() const {
return mCommonSettings->value("Language", "english").toString();
}
GUIApplication(...)
: QApplication(...)
, ...
{
...
// setup common application data path
#ifdef Q_WS_WIN
QSettings registryCommon("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", QSettings::NativeFormat);
mCommonApplicationDataFolder = registryCommon.value("Common AppData").toString();
mCommonApplicationDataFolder = mCommonApplicationDataFolder.replace("\\", "/");
#else
mCommonApplicationDataFolder = QDir::homePath() + "/.config/";
#endif
if(!mCommonApplicationDataFolder.endsWith("/"))
mCommonApplicationDataFolder.append("/");
if(mVendor.isEmpty())
mCommonApplicationDataFolder.append(applicationName() + "/");
else
mCommonApplicationDataFolder.append(mVendor + "/" + applicationName() + "/");
mCommonSettings = new GUISettings(mCommonApplicationDataFolder + "Settings.ini", this);
// set translation file, mTransalator is Member
const QString languageFilePath = applicationDirPath() + "/data/" + language();
showMessage(eInformation, languageFilePath + ".qm");
const QFile languageFile(languageFilePath + ".qm");
if( languageFile.exists())
if(mTranslator.load(languageFilePath))
installTranslator(&mTranslator);
...
}
void GUIApplication::exec()
{
...
mMainWindow = new GUIMainWindow();
if( !applicationName().isEmpty() )
mMainWindow->setWindowTitle(applicationName() + " " + applicationVersion());
mMainWindow->show();
for( int i = 0; i < mMessageList.count(); i++)
showMessage(mMessageList.at(i).type, mMessageList.at(i).message, mMessageList.at(i).later);
mMessageList.clear();
return QApplication::exec();
}
void GUIApplication::showMessage( MessageType iType, const QString & iMessage, bool iShowLater )
{
if( mMainWindow )
mMainWindow->showMessage( iType, iMessage, iShowLater );
else
{
MessageData data;
data.type = iType;
data.message = iMessage;
data.later = iShowLater;
mMessageList.append(data);
}
}
QString GUIApplication::language() const
{
return mCommonSettings->value("Language", "english").toString();
}
To copy to clipboard, switch view to plain text mode
Bookmarks