From 11fed12be184970660040e91c8435d768216a49d Mon Sep 17 00:00:00 2001 From: fourtf Date: Thu, 13 Apr 2017 18:51:46 +0200 Subject: [PATCH] changed application data path from %appdata%/chatterino to %appdata%/chatterino2 --- appdatapath.cpp | 30 +++++ appdatapath.h | 18 +++ channel.cpp | 2 +- chatterino.pro | 322 ++++++++++++++++++++++---------------------- common.h | 2 + main.cpp | 6 +- settingsmanager.cpp | 16 +-- settingsmanager.h | 3 - windowmanager.cpp | 5 +- 9 files changed, 221 insertions(+), 183 deletions(-) create mode 100644 appdatapath.cpp create mode 100644 appdatapath.h diff --git a/appdatapath.cpp b/appdatapath.cpp new file mode 100644 index 000000000..801475413 --- /dev/null +++ b/appdatapath.cpp @@ -0,0 +1,30 @@ +#include "appdatapath.h" + +#include +#include +#include + +QString Path::appdataPath; +std::mutex Path::appdataPathMutex; + +const QString &Path::getAppdataPath() +{ + std::lock_guard lock(appdataPathMutex); + + if (appdataPath.isEmpty()) { +#ifdef PORTABLE + QString path = QCoreApplication::applicationDirPath(); +#else + QString path = + QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/Chatterino2/"; +#endif + + QDir(QDir::root()).mkdir(path); + + appdataPath = path; + } + + qDebug() << "memes: " << appdataPath; + + return appdataPath; +} diff --git a/appdatapath.h b/appdatapath.h new file mode 100644 index 000000000..5cac1f66a --- /dev/null +++ b/appdatapath.h @@ -0,0 +1,18 @@ +#ifndef APPDATAPATH_H +#define APPDATAPATH_H + +#include +#include +#include + +class Path +{ +public: + static const QString &getAppdataPath(); + +private: + static QString appdataPath; + static std::mutex appdataPathMutex; +}; + +#endif // APPDATAPATH_H diff --git a/channel.cpp b/channel.cpp index 965b61467..859c9725c 100644 --- a/channel.cpp +++ b/channel.cpp @@ -27,7 +27,7 @@ Channel::Channel(const QString &channel) , _subLink("https://www.twitch.tv/" + _name + "/subscribe?ref=in_chat_subscriber_link") , _channelLink("https://twitch.tv/" + _name) , _popoutPlayerLink("https://player.twitch.tv/?channel=" + _name) -//, _loggingChannel(logging::get(_name)) +// , _loggingChannel(logging::get(_name)) { reloadChannelEmotes(); } diff --git a/chatterino.pro b/chatterino.pro index 7334d331a..983b41fb7 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -1,160 +1,162 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2016-12-28T18:23:35 -# -#------------------------------------------------- - -QT += core gui network -CONFIG += communi -COMMUNI += core model util -CONFIG += c++14 - -include(lib/libcommuni/src/src.pri) - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = chatterino -TEMPLATE = app - -DEFINES += QT_DEPRECATED_WARNINGS -DEFINES += IRC_NAMESPACE=Communi - -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += main.cpp\ - channel.cpp \ - colorscheme.cpp \ - emojis.cpp \ - ircmanager.cpp \ - messages/lazyloadedimage.cpp \ - messages/link.cpp \ - messages/message.cpp \ - messages/word.cpp \ - messages/wordpart.cpp \ - resources.cpp \ - widgets/chatwidget.cpp \ - widgets/chatwidgetheader.cpp \ - widgets/chatwidgetheaderbutton.cpp \ - widgets/chatwidgetinput.cpp \ - widgets/chatwidgetview.cpp \ - widgets/mainwindow.cpp \ - widgets/notebook.cpp \ - widgets/notebookbutton.cpp \ - widgets/notebookpage.cpp \ - widgets/notebookpagedroppreview.cpp \ - widgets/notebooktab.cpp \ - widgets/scrollbar.cpp \ - widgets/scrollbarhighlight.cpp \ - widgets/settingsdialog.cpp \ - widgets/settingsdialogtab.cpp \ - widgets/textinputdialog.cpp \ - messages/messageref.cpp \ - logging/loggingmanager.cpp \ - logging/loggingchannel.cpp \ - windowmanager.cpp \ - channelmanager.cpp \ - fontmanager.cpp \ - settingsmanager.cpp \ - emotemanager.cpp \ - usermanager.cpp \ - twitch/twitchuser.cpp \ - messages/messagebuilder.cpp \ - twitch/twitchmessagebuilder.cpp \ - ircuser2.cpp \ - twitch/twitchparsemessage.cpp \ - widgets/fancybutton.cpp \ - widgets/titlebar.cpp \ - widgets/userpopupwidget.cpp - -HEADERS += \ - asyncexec.h \ - channel.h \ - colorscheme.h \ - common.h \ - concurrentmap.h \ - emojis.h \ - ircmanager.h \ - messages/lazyloadedimage.h \ - messages/link.h \ - messages/message.h \ - messages/word.h \ - messages/wordpart.h \ - resources.h \ - setting.h \ - twitch/emotevalue.h \ - widgets/chatwidget.h \ - widgets/chatwidgetheader.h \ - widgets/chatwidgetheaderbutton.h \ - widgets/chatwidgetinput.h \ - widgets/chatwidgetview.h \ - widgets/mainwindow.h \ - widgets/notebook.h \ - widgets/notebookbutton.h \ - widgets/notebookpage.h \ - widgets/notebookpagedroppreview.h \ - widgets/notebooktab.h \ - widgets/scrollbar.h \ - widgets/scrollbarhighlight.h \ - widgets/settingsdialog.h \ - widgets/settingsdialogtab.h \ - widgets/signallabel.h \ - widgets/textinputdialog.h \ - widgets/resizingtextedit.h \ - settingssnapshot.h \ - messages/limitedqueue.h \ - messages/limitedqueuesnapshot.h \ - messages/messageref.h \ - logging/loggingmanager.h \ - logging/loggingchannel.h \ - channelmanager.h \ - windowmanager.h \ - settingsmanager.h \ - fontmanager.h \ - emotemanager.h \ - util/urlfetch.h \ - usermanager.h \ - twitch/twitchuser.h \ - messages/messageparseargs.h \ - messages/messagebuilder.h \ - twitch/twitchmessagebuilder.h \ - ircuser2.h \ - twitch/twitchparsemessage.h \ - widgets/fancybutton.h \ - widgets/titlebar.h \ - widgets/userpopupwidget.h - -PRECOMPILED_HEADER = - -RESOURCES += \ - resources.qrc - -DISTFILES += - -# Include boost -win32 { - INCLUDEPATH += C:\local\boost\ -} - -# 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" \ - -ldwmapi \ - -lgdi32 - - SOURCES += platform/borderless/qwinwidget.cpp \ - platform/borderless/winnativewindow.cpp \ - platform/borderless/widget.cpp - - HEADERS += platform/borderless/qwinwidget.h \ - platform/borderless/winnativewindow.h \ - platform/borderless/widget.h - - DEFINES += "USEWINSDK" -} - -macx { - INCLUDEPATH += /usr/local/include -} - -FORMS += \ - forms/userpopup.ui +#------------------------------------------------- +# +# Project created by QtCreator 2016-12-28T18:23:35 +# +#------------------------------------------------- + +QT += core gui network +CONFIG += communi +COMMUNI += core model util +CONFIG += c++14 + +include(lib/libcommuni/src/src.pri) + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = chatterino +TEMPLATE = app + +DEFINES += QT_DEPRECATED_WARNINGS +DEFINES += IRC_NAMESPACE=Communi + +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += main.cpp\ + channel.cpp \ + colorscheme.cpp \ + emojis.cpp \ + ircmanager.cpp \ + messages/lazyloadedimage.cpp \ + messages/link.cpp \ + messages/message.cpp \ + messages/word.cpp \ + messages/wordpart.cpp \ + resources.cpp \ + widgets/chatwidget.cpp \ + widgets/chatwidgetheader.cpp \ + widgets/chatwidgetheaderbutton.cpp \ + widgets/chatwidgetinput.cpp \ + widgets/chatwidgetview.cpp \ + widgets/mainwindow.cpp \ + widgets/notebook.cpp \ + widgets/notebookbutton.cpp \ + widgets/notebookpage.cpp \ + widgets/notebookpagedroppreview.cpp \ + widgets/notebooktab.cpp \ + widgets/scrollbar.cpp \ + widgets/scrollbarhighlight.cpp \ + widgets/settingsdialog.cpp \ + widgets/settingsdialogtab.cpp \ + widgets/textinputdialog.cpp \ + messages/messageref.cpp \ + logging/loggingmanager.cpp \ + logging/loggingchannel.cpp \ + windowmanager.cpp \ + channelmanager.cpp \ + fontmanager.cpp \ + settingsmanager.cpp \ + emotemanager.cpp \ + usermanager.cpp \ + twitch/twitchuser.cpp \ + messages/messagebuilder.cpp \ + twitch/twitchmessagebuilder.cpp \ + ircuser2.cpp \ + twitch/twitchparsemessage.cpp \ + widgets/fancybutton.cpp \ + widgets/titlebar.cpp \ + widgets/userpopupwidget.cpp \ + appdatapath.cpp + +HEADERS += \ + asyncexec.h \ + channel.h \ + colorscheme.h \ + common.h \ + concurrentmap.h \ + emojis.h \ + ircmanager.h \ + messages/lazyloadedimage.h \ + messages/link.h \ + messages/message.h \ + messages/word.h \ + messages/wordpart.h \ + resources.h \ + setting.h \ + twitch/emotevalue.h \ + widgets/chatwidget.h \ + widgets/chatwidgetheader.h \ + widgets/chatwidgetheaderbutton.h \ + widgets/chatwidgetinput.h \ + widgets/chatwidgetview.h \ + widgets/mainwindow.h \ + widgets/notebook.h \ + widgets/notebookbutton.h \ + widgets/notebookpage.h \ + widgets/notebookpagedroppreview.h \ + widgets/notebooktab.h \ + widgets/scrollbar.h \ + widgets/scrollbarhighlight.h \ + widgets/settingsdialog.h \ + widgets/settingsdialogtab.h \ + widgets/signallabel.h \ + widgets/textinputdialog.h \ + widgets/resizingtextedit.h \ + settingssnapshot.h \ + messages/limitedqueue.h \ + messages/limitedqueuesnapshot.h \ + messages/messageref.h \ + logging/loggingmanager.h \ + logging/loggingchannel.h \ + channelmanager.h \ + windowmanager.h \ + settingsmanager.h \ + fontmanager.h \ + emotemanager.h \ + util/urlfetch.h \ + usermanager.h \ + twitch/twitchuser.h \ + messages/messageparseargs.h \ + messages/messagebuilder.h \ + twitch/twitchmessagebuilder.h \ + ircuser2.h \ + twitch/twitchparsemessage.h \ + widgets/fancybutton.h \ + widgets/titlebar.h \ + widgets/userpopupwidget.h \ + appdatapath.h + +PRECOMPILED_HEADER = + +RESOURCES += \ + resources.qrc + +DISTFILES += + +# Include boost +win32 { + INCLUDEPATH += C:\local\boost\ +} + +# 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" \ + -ldwmapi \ + -lgdi32 + + SOURCES += platform/borderless/qwinwidget.cpp \ + platform/borderless/winnativewindow.cpp \ + platform/borderless/widget.cpp + + HEADERS += platform/borderless/qwinwidget.h \ + platform/borderless/winnativewindow.h \ + platform/borderless/widget.h + + DEFINES += "USEWINSDK" +} + +macx { + INCLUDEPATH += /usr/local/include +} + +FORMS += \ + forms/userpopup.ui diff --git a/common.h b/common.h index 666cda037..c2911a848 100644 --- a/common.h +++ b/common.h @@ -1,3 +1,5 @@ +#include + #ifndef COMMON_H #define COMMON_H diff --git a/main.cpp b/main.cpp index 0f59faf2e..ba59cecf9 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include "channelmanager.h" #include "colorscheme.h" +#include "common.h" #include "emojis.h" #include "emotemanager.h" #include "ircmanager.h" @@ -11,13 +12,14 @@ #include #include +#include +#include #include using namespace chatterino; using namespace chatterino::widgets; -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { QApplication a(argc, argv); diff --git a/settingsmanager.cpp b/settingsmanager.cpp index 57e4e960b..6fdf8d038 100644 --- a/settingsmanager.cpp +++ b/settingsmanager.cpp @@ -1,4 +1,5 @@ #include "settingsmanager.h" +#include "appdatapath.h" #include #include @@ -11,10 +12,7 @@ namespace chatterino { SettingsManager SettingsManager::instance; SettingsManager::SettingsManager() - : _settings(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + - "/Chatterino/newsettings.ini", - QSettings::IniFormat) - , _portable(false) + : _settings(Path::getAppdataPath() + "settings.ini", QSettings::IniFormat) , _wordTypeMask(Word::Default) , theme(_settingsItems, "theme", "dark") , themeHue(_settingsItems, "themeHue", 0) @@ -87,16 +85,6 @@ bool SettingsManager::isIgnoredEmote(const QString &) return false; } -bool SettingsManager::getPortable() -{ - return _portable; -} - -void SettingsManager::setPortable(bool value) -{ - _portable = value; -} - QSettings &SettingsManager::getQSettings() { return _settings; diff --git a/settingsmanager.h b/settingsmanager.h index 541c82852..1b8e09c36 100644 --- a/settingsmanager.h +++ b/settingsmanager.h @@ -52,8 +52,6 @@ public: messages::Word::Type getWordTypeMask(); bool isIgnoredEmote(const QString &emote); - bool getPortable(); - void setPortable(bool value); QSettings &getQSettings(); SettingsSnapshot createSnapshot(); @@ -66,7 +64,6 @@ private: // variables QSettings _settings; std::vector> _settingsItems; - bool _portable; messages::Word::Type _wordTypeMask; // methods diff --git a/windowmanager.cpp b/windowmanager.cpp index eb3ac41b4..01c064df2 100644 --- a/windowmanager.cpp +++ b/windowmanager.cpp @@ -1,4 +1,5 @@ #include "windowmanager.h" +#include "appdatapath.h" #include #include @@ -9,9 +10,7 @@ namespace chatterino { static const std::string &getSettingsPath() { - static std::string path = - (QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/windows.json") - .toStdString(); + static std::string path = (Path::getAppdataPath() + "uilayout.json").toStdString(); return path; }