changed application data path from %appdata%/chatterino to

%appdata%/chatterino2
This commit is contained in:
fourtf 2017-04-13 18:51:46 +02:00
parent 138466035f
commit 11fed12be1
9 changed files with 221 additions and 183 deletions

30
appdatapath.cpp Normal file
View file

@ -0,0 +1,30 @@
#include "appdatapath.h"
#include <QDebug>
#include <QDir>
#include <QStandardPaths>
QString Path::appdataPath;
std::mutex Path::appdataPathMutex;
const QString &Path::getAppdataPath()
{
std::lock_guard<std::mutex> 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;
}

18
appdatapath.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef APPDATAPATH_H
#define APPDATAPATH_H
#include <QString>
#include <atomic>
#include <mutex>
class Path
{
public:
static const QString &getAppdataPath();
private:
static QString appdataPath;
static std::mutex appdataPathMutex;
};
#endif // APPDATAPATH_H

View file

@ -64,7 +64,8 @@ SOURCES += main.cpp\
twitch/twitchparsemessage.cpp \
widgets/fancybutton.cpp \
widgets/titlebar.cpp \
widgets/userpopupwidget.cpp
widgets/userpopupwidget.cpp \
appdatapath.cpp
HEADERS += \
asyncexec.h \
@ -121,7 +122,8 @@ HEADERS += \
twitch/twitchparsemessage.h \
widgets/fancybutton.h \
widgets/titlebar.h \
widgets/userpopupwidget.h
widgets/userpopupwidget.h \
appdatapath.h
PRECOMPILED_HEADER =

View file

@ -1,3 +1,5 @@
#include <QString>
#ifndef COMMON_H
#define COMMON_H

View file

@ -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 <QApplication>
#include <QClipboard>
#include <QDir>
#include <QStandardPaths>
#include <boost/signals2.hpp>
using namespace chatterino;
using namespace chatterino::widgets;
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
QApplication a(argc, argv);

View file

@ -1,4 +1,5 @@
#include "settingsmanager.h"
#include "appdatapath.h"
#include <QDebug>
#include <QDir>
@ -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;

View file

@ -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<std::reference_wrapper<BaseSetting>> _settingsItems;
bool _portable;
messages::Word::Type _wordTypeMask;
// methods

View file

@ -1,4 +1,5 @@
#include "windowmanager.h"
#include "appdatapath.h"
#include <QDebug>
#include <QStandardPaths>
@ -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;
}