mirror-chatterino2/src/main.cpp
Rasmus Karlsson 7df7da70cb A lot of changes
Remove unused constructor of messages::Message
Fixed LimitedQueueSnapshot _-prefixes
Changed LimitedQueueSnapshot's usage of int to std::size_t
ColorScheme is no longer a singleton
Created a "BaseWidget" class which is pretty much a QWidget except it
has a reference of ColorScheme since most widgets will need a reference
to the style they should use.
BaseWidget can be implemented either with a BaseWidget parent (which
will copy the ColorScheme reference from the parent) or with a
normal QWidget parent and an explicit ColorScheme reference.
Save main window geometry on close
Fix font changing in the Settings Dialog
Update settings library version
2017-06-26 19:53:31 +02:00

75 lines
1.6 KiB
C++

#include "application.hpp"
#include <QApplication>
#include <QDir>
#include <QStandardPaths>
#include <pajlada/settings/settingmanager.hpp>
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);
a.setAttribute(Qt::AA_EnableHighDpiScaling, true);
// 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;
}
int ret = 0;
{
// Initialize application
chatterino::Application app;
// Start the application
ret = app.run(a);
// Application will go out of scope here and deinitialize itself
}
// Save settings
pajlada::Settings::SettingManager::save();
return ret;
}