diff --git a/src/RunGui.cpp b/src/RunGui.cpp index f4a11b19..523a3c9f 100644 --- a/src/RunGui.cpp +++ b/src/RunGui.cpp @@ -8,7 +8,6 @@ #include #include "Application.hpp" -#include "common/Modes.hpp" #include "common/NetworkManager.hpp" #include "singletons/Paths.hpp" #include "singletons/Resources.hpp" diff --git a/src/main.cpp b/src/main.cpp index c2c4d9ab..990f6e83 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ #include "BrowserExtension.hpp" #include "RunGui.hpp" #include "common/Args.hpp" -#include "common/Modes.hpp" #include "singletons/Paths.hpp" #include "singletons/Settings.hpp" #include "util/IncognitoBrowser.hpp" @@ -29,35 +28,9 @@ int main(int argc, char **argv) else { initArgs(args); - Paths *paths{}; + Paths paths; + Settings settings(paths.settingsDirectory); - try - { - paths = new Paths; - } - catch (std::runtime_error &error) - { - QMessageBox box; - if (Modes::getInstance().isPortable) - { - box.setText( - error.what() + - QStringLiteral( - "\n\nInfo: Portable mode requires the application to " - "be in a writeable location. If you don't want " - "portable mode reinstall the application. " - "https://chatterino.com.")); - } - else - { - box.setText(error.what()); - } - box.exec(); - return 1; - } - - Settings settings(paths->settingsDirectory); - - runGui(a, *paths, settings); + runGui(a, paths, settings); } } diff --git a/src/singletons/Paths.cpp b/src/singletons/Paths.cpp index 83d7ab5a..ea8e2526 100644 --- a/src/singletons/Paths.cpp +++ b/src/singletons/Paths.cpp @@ -11,8 +11,6 @@ #include "common/Modes.hpp" #include "util/CombinePath.hpp" -using namespace std::literals; - namespace chatterino { Paths *Paths::instance = nullptr; @@ -24,7 +22,7 @@ Paths::Paths() this->initAppFilePathHash(); this->initCheckPortable(); - this->initRootDirectory(); + this->initAppDataDirectory(); this->initSubDirectories(); } @@ -78,7 +76,7 @@ void Paths::initCheckPortable() combinePath(QCoreApplication::applicationDirPath(), "portable")); } -void Paths::initRootDirectory() +void Paths::initAppDataDirectory() { assert(this->portable_.is_initialized()); @@ -97,8 +95,8 @@ void Paths::initRootDirectory() QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); if (path.isEmpty()) { - throw std::runtime_error("Could not create directory \""s + - path.toStdString() + "\""); + throw std::runtime_error( + "Error finding writable location for settings"); } // create directory Chatterino2 instead of chatterino on windows because the @@ -125,8 +123,8 @@ void Paths::initSubDirectories() if (!QDir().mkpath(path)) { - throw std::runtime_error("Could not create directory \""s + - path.toStdString() + "\""); + throw std::runtime_error( + "Error creating appdata path %appdata%/chatterino/" + name); } return path; diff --git a/src/singletons/Paths.hpp b/src/singletons/Paths.hpp index ea4cb6c2..1df1fc77 100644 --- a/src/singletons/Paths.hpp +++ b/src/singletons/Paths.hpp @@ -39,7 +39,7 @@ public: private: void initAppFilePathHash(); void initCheckPortable(); - void initRootDirectory(); + void initAppDataDirectory(); void initSubDirectories(); boost::optional portable_;