From fd22d49eadf16cad851799bac95404f3322c3874 Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Thu, 16 Apr 2015 22:30:18 +0530 Subject: [PATCH] Refactoring: Move gzip/diff/awk path default values init on Windows into the Preferences class --- client/main.cpp | 12 ------------ client/preferences.cpp | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/client/main.cpp b/client/main.cpp index 94d3baf..65864f0 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -38,23 +38,11 @@ extern ProtocolWidgetFactory *OstProtocolWidgetFactory; QSettings *appSettings; QMainWindow *mainWindow; -#if defined(Q_OS_WIN32) -QString kGzipPathDefaultValue; -QString kDiffPathDefaultValue; -QString kAwkPathDefaultValue; -#endif - int main(int argc, char* argv[]) { QApplication app(argc, argv); int exitCode; -#if defined(Q_OS_WIN32) - kGzipPathDefaultValue = app.applicationDirPath() + "/gzip.exe"; - kDiffPathDefaultValue = app.applicationDirPath() + "/diff.exe"; - kAwkPathDefaultValue = app.applicationDirPath() + "/gawk.exe"; -#endif - app.setApplicationName("Ostinato"); app.setOrganizationName("Ostinato"); app.setProperty("version", version); diff --git a/client/preferences.cpp b/client/preferences.cpp index cbd9a58..06a18b1 100644 --- a/client/preferences.cpp +++ b/client/preferences.cpp @@ -25,6 +25,12 @@ along with this program. If not, see #include #include +#if defined(Q_OS_WIN32) +QString kGzipPathDefaultValue; +QString kDiffPathDefaultValue; +QString kAwkPathDefaultValue; +#endif + QString kUserDefaultValue; Preferences::Preferences() @@ -53,9 +59,14 @@ Preferences::~Preferences() void Preferences::initDefaults() { - Q_ASSERT(appSettings); - // Read username from the environment +#if defined(Q_OS_WIN32) + kGzipPathDefaultValue = QApplication::applicationDirPath() + "/gzip.exe"; + kDiffPathDefaultValue = QApplication::applicationDirPath() + "/diff.exe"; + kAwkPathDefaultValue = QApplication::applicationDirPath() + "/gawk.exe"; +#endif + + // Read default username from the environment #ifdef Q_OS_WIN32 kUserDefaultValue = QString(qgetenv("USERNAME").constData()); #else