build: split user and data folder, moving user data to Application Support on Mac
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
#ifndef INCLUDES_DEFAULT_H
|
||||
#define INCLUDES_DEFAULT_H
|
||||
|
||||
static std::string appSettingsPath = "data/ApplicationSettings.xml";
|
||||
static std::string windowSettingsPath = "data/window_settings.ini";
|
||||
static std::string logPath = "data/log/";
|
||||
#include "utility/UserPaths.h"
|
||||
|
||||
void setup(int argc, char *argv[])
|
||||
{
|
||||
std::string userdir(std::getenv("HOME"));
|
||||
userdir.append("/.config/coati/");
|
||||
UserPaths::setUserDataPath(userdir);
|
||||
}
|
||||
|
||||
#endif // INCLUDES_DEFAULT_H
|
||||
@@ -4,10 +4,10 @@
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
static std::string appSettingsPath = "data/ApplicationSettings.xml";
|
||||
static std::string windowSettingsPath = "data/window_settings.ini";
|
||||
static std::string logPath = "data/log/";
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "utility/UserPaths.h"
|
||||
|
||||
void setup(int argc, char *argv[])
|
||||
{
|
||||
@@ -47,6 +47,22 @@ void setup(int argc, char *argv[])
|
||||
// printf("after change, libraryPaths=(%s)\n", QCoreApplication::libraryPaths().join(",").toUtf8().data());
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Makes the mac bundle copy the user files to the Application Support folder
|
||||
QString dataPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
|
||||
QDir dataDir(dataPath);
|
||||
if (!dataDir.exists())
|
||||
{
|
||||
dataDir.mkpath(dataPath);
|
||||
}
|
||||
|
||||
utility::copyNewFilesFromDirectory(QString::fromStdString(UserPaths::getUserDataPath()), dataPath);
|
||||
|
||||
UserPaths::setUserDataPath(dataPath.toStdString() + "/");
|
||||
// ----------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
#endif // INCLUDES_MAC_H
|
||||
|
||||
@@ -5,21 +5,15 @@
|
||||
|
||||
#include "vld.h"
|
||||
|
||||
// #define DEPLOY
|
||||
#include "utility/UserPaths.h"
|
||||
|
||||
#ifdef DEPLOY
|
||||
static std::string appSettingsPath = std::string(std::getenv("APPDATA")) + "/../local/Coati Software/Coati/ApplicationSettings.xml";
|
||||
static std::string windowSettingsPath = std::string(std::getenv("APPDATA")) + "/../local/Coati Software/Coati/window_settings.ini";
|
||||
static std::string logPath = std::string(std::getenv("APPDATA")) + "/../local/Coati Software/Coati/log/";
|
||||
#else
|
||||
static std::string appSettingsPath = "data/ApplicationSettings.xml";
|
||||
static std::string windowSettingsPath = "data/window_settings.ini";
|
||||
static std::string logPath = "data/log/";
|
||||
#endif
|
||||
// #define DEPLOY
|
||||
|
||||
void setup(int argc, char *argv[])
|
||||
{
|
||||
|
||||
#ifdef DEPLOY
|
||||
UserPaths::setUserDataPath(std::getenv("APPDATA")) + "/../local/Coati Software/Coati/");
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // INCLUDES_WINDOWS_H
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFontDatabase>
|
||||
#include <QPainter>
|
||||
@@ -150,4 +151,29 @@ namespace utility
|
||||
painter.drawImage(0, 0, colorImage);
|
||||
return QPixmap::fromImage(image);
|
||||
}
|
||||
|
||||
void copyNewFilesFromDirectory(QString src, QString dst)
|
||||
{
|
||||
QDir dir(src);
|
||||
if (!dir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||
{
|
||||
QString dst_path = dst + QDir::separator() + d;
|
||||
|
||||
dir.mkpath(dst_path);
|
||||
copyNewFilesFromDirectory(src + QDir::separator() + d, dst_path);
|
||||
}
|
||||
|
||||
foreach (QString f, dir.entryList(QDir::Files))
|
||||
{
|
||||
if (!QFile::exists(dst + QDir::separator() + f))
|
||||
{
|
||||
QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace utility
|
||||
std::string getStyleSheet(const std::string& path);
|
||||
|
||||
QPixmap colorizePixmap(const QPixmap& pixmap, QColor color);
|
||||
|
||||
void copyNewFilesFromDirectory(QString src, QString dst);
|
||||
}
|
||||
|
||||
# endif // UTILITY_QT_H
|
||||
|
||||
@@ -34,11 +34,10 @@
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/UserPaths.h"
|
||||
#include "version.h"
|
||||
#include "isTrial.h"
|
||||
|
||||
std::string QtMainWindow::m_windowSettingsPath = "data/window_settings.ini";
|
||||
|
||||
QtViewToggle::QtViewToggle(View* view, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_view(view)
|
||||
@@ -214,7 +213,7 @@ void QtMainWindow::hideView(View* view)
|
||||
|
||||
void QtMainWindow::loadLayout()
|
||||
{
|
||||
QSettings settings(m_windowSettingsPath.c_str(), QSettings::IniFormat);
|
||||
QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup("MainWindow");
|
||||
resize(settings.value("size", QSize(600, 400)).toSize());
|
||||
@@ -236,7 +235,7 @@ void QtMainWindow::loadLayout()
|
||||
|
||||
void QtMainWindow::saveLayout()
|
||||
{
|
||||
QSettings settings(m_windowSettingsPath.c_str(), QSettings::IniFormat);
|
||||
QSettings settings(UserPaths::getWindowSettingsPath().c_str(), QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup("MainWindow");
|
||||
settings.setValue("maximized", isMaximized());
|
||||
@@ -557,11 +556,6 @@ void QtMainWindow::updateRecentProjectMenu()
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::setWindowSettingsPath(const std::string& windowSettingsPath)
|
||||
{
|
||||
m_windowSettingsPath = windowSettingsPath;
|
||||
}
|
||||
|
||||
void QtMainWindow::toggleShowDockWidgetTitleBars()
|
||||
{
|
||||
setShowDockWidgetTitleBars(!m_showDockWidgetTitleBars);
|
||||
|
||||
@@ -130,8 +130,6 @@ public slots:
|
||||
|
||||
void updateRecentProjectMenu();
|
||||
|
||||
static void setWindowSettingsPath(const std::string& windowSettingsPath);
|
||||
|
||||
private slots:
|
||||
void toggleShowDockWidgetTitleBars();
|
||||
|
||||
@@ -172,8 +170,6 @@ private:
|
||||
|
||||
QShortcut* m_escapeShortcut;
|
||||
|
||||
static std::string m_windowSettingsPath;
|
||||
|
||||
QtThreadedFunctor<std::string, std::string, std::vector<std::string>, std::vector<std::string>> m_createNewProjectFunctor;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user