From 548fbe586694755939e19e1b1b5f3c30a72cde51 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Tue, 30 May 2017 15:22:44 +0200 Subject: [PATCH] rename twitchaccount file to twitchuser to match class name --- .gitignore | 2 + accountmanager.h | 2 +- chatterino.pro | 10 +++- ircaccount.h | 1 + ircmanager.cpp | 2 +- ircmanager.h | 2 +- main.cpp | 48 ++++++++++++++++++++ twitch/{twitchaccount.cpp => twitchuser.cpp} | 2 +- twitch/{twitchaccount.h => twitchuser.h} | 0 widgets/settingsdialog.cpp | 2 +- 10 files changed, 64 insertions(+), 7 deletions(-) rename twitch/{twitchaccount.cpp => twitchuser.cpp} (95%) rename twitch/{twitchaccount.h => twitchuser.h} (100%) diff --git a/.gitignore b/.gitignore index e4aa6f639..dbf0a1fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ moc_*.cpp # Ignore binary file /chatterino + +settings.json diff --git a/accountmanager.h b/accountmanager.h index f7b0b3ab9..e97cdf74c 100644 --- a/accountmanager.h +++ b/accountmanager.h @@ -1,7 +1,7 @@ #ifndef ACCOUNTMANAGER_H #define ACCOUNTMANAGER_H -#include "twitch/twitchaccount.h" +#include "twitch/twitchuser.h" #include #include diff --git a/chatterino.pro b/chatterino.pro index 1d9104dbe..3e98092dc 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -84,7 +84,7 @@ SOURCES += main.cpp\ widgets/titlebar.cpp \ appdatapath.cpp \ accountmanager.cpp \ - twitch/twitchaccount.cpp \ + twitch/twitchuser.cpp \ ircaccount.cpp \ widgets/accountpopup.cpp @@ -142,7 +142,7 @@ HEADERS += \ widgets/titlebar.h \ appdatapath.h \ accountmanager.h \ - twitch/twitchaccount.h \ + twitch/twitchuser.h \ ircaccount.h \ widgets/accountpopup.h \ util/distancebetweenpoints.h @@ -159,6 +159,12 @@ win32 { INCLUDEPATH += C:\local\boost\ } +# Include settings library +SOURCES += lib/settings/src/settings/settingdata.cpp +SOURCES += lib/settings/src/settings/settingmanager.cpp +INCLUDEPATH += lib/settings/include/ +INCLUDEPATH += lib/settings/external/signals/include/ + # Optional dependency on windows sdk 7.1 win32:exists(C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\Windows.h) { LIBS += -L"C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib" \ diff --git a/ircaccount.h b/ircaccount.h index 9053a87fa..727bbe9cf 100644 --- a/ircaccount.h +++ b/ircaccount.h @@ -22,6 +22,7 @@ private: QString _realName; QString _password; }; + } // namespace chatterino #endif // IRCUSER_H diff --git a/ircmanager.cpp b/ircmanager.cpp index 87f93e475..e0a93645c 100644 --- a/ircmanager.cpp +++ b/ircmanager.cpp @@ -4,9 +4,9 @@ #include "channel.h" #include "channelmanager.h" #include "messages/messageparseargs.h" -#include "twitch/twitchaccount.h" #include "twitch/twitchmessagebuilder.h" #include "twitch/twitchparsemessage.h" +#include "twitch/twitchuser.h" #include #include diff --git a/ircmanager.h b/ircmanager.h index 4e5d6ad7e..23be08204 100644 --- a/ircmanager.h +++ b/ircmanager.h @@ -4,7 +4,7 @@ #define TWITCH_MAX_MESSAGELENGTH 500 #include "messages/message.h" -#include "twitch/twitchaccount.h" +#include "twitch/twitchuser.h" #include #include diff --git a/main.cpp b/main.cpp index c7847221d..e5950784b 100644 --- a/main.cpp +++ b/main.cpp @@ -15,14 +15,59 @@ #include #include #include +#include using namespace chatterino; using namespace chatterino::widgets; +namespace { + +inline bool initSettings(bool portable) +{ + QString settingsPath; + if (portable) { + settingsPath.append(QDir::currentPath()); + } else { + // Get settings path + settingsPath.append(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)); + if (settingsPath.isEmpty()) { + printf("Error finding writable location for settings\n"); + return false; + } + } + + if (!QDir().mkpath(settingsPath)) { + printf("Error creating directories for settings: %s\n", qPrintable(settingsPath)); + return false; + } + settingsPath.append("/settings.json"); + + pajlada::Settings::SettingManager::load(qPrintable(settingsPath)); + + return true; +} + +} // namespace + int main(int argc, char *argv[]) { QApplication a(argc, argv); + // Options + bool portable = false; + + for (int i = 1; i < argc; ++i) { + if (strcmp(argv[i], "portable") == 0) { + portable = true; + } + } + + // Initialize settings + if (!initSettings(portable)) { + printf("Error initializing settings\n"); + return 1; + } + chatterino::logging::init(); SettingsManager::getInstance().load(); Resources::load(); @@ -42,6 +87,9 @@ int main(int argc, char *argv[]) SettingsManager::getInstance().save(); + // Save settings + pajlada::Settings::SettingManager::save(); + WindowManager::getInstance().save(); return ret; diff --git a/twitch/twitchaccount.cpp b/twitch/twitchuser.cpp similarity index 95% rename from twitch/twitchaccount.cpp rename to twitch/twitchuser.cpp index 631eb1081..cb7ecda28 100644 --- a/twitch/twitchaccount.cpp +++ b/twitch/twitchuser.cpp @@ -1,4 +1,4 @@ -#include "twitchaccount.h" +#include "twitchuser.h" namespace chatterino { namespace twitch { diff --git a/twitch/twitchaccount.h b/twitch/twitchuser.h similarity index 100% rename from twitch/twitchaccount.h rename to twitch/twitchuser.h diff --git a/widgets/settingsdialog.cpp b/widgets/settingsdialog.cpp index 1c94c8944..0281a5171 100644 --- a/widgets/settingsdialog.cpp +++ b/widgets/settingsdialog.cpp @@ -1,6 +1,6 @@ #include "widgets/settingsdialog.h" #include "accountmanager.h" -#include "twitch/twitchaccount.h" +#include "twitch/twitchuser.h" #include "widgets/settingsdialogtab.h" #include "windowmanager.h"