Make .cache/.local/.config folders uniform.

This commit is contained in:
Martin Rotter 2017-02-17 19:34:06 +01:00
parent c97e052a1f
commit 81f54e0d1c
11 changed files with 23 additions and 32 deletions

View file

@ -42,7 +42,7 @@ FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget *parent) : QDialo
connect(m_ui->m_txtBackupName->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkOkButton())); connect(m_ui->m_txtBackupName->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkOkButton()));
connect(m_ui->m_btnSelectFolder, SIGNAL(clicked()), this, SLOT(selectFolder())); connect(m_ui->m_btnSelectFolder, SIGNAL(clicked()), this, SLOT(selectFolder()));
selectFolder(qApp->documentsFolderPath()); selectFolder(qApp->getDocumentsFolderPath());
m_ui->m_txtBackupName->lineEdit()->setText(QString(APP_LOW_NAME) + QL1S("_") + QDateTime::currentDateTime().toString(QSL("yyyyMMddHHmm"))); m_ui->m_txtBackupName->lineEdit()->setText(QString(APP_LOW_NAME) + QL1S("_") + QDateTime::currentDateTime().toString(QSL("yyyyMMddHHmm")));
m_ui->m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet.")); m_ui->m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet."));

View file

@ -39,7 +39,7 @@ FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget *parent)
connect(m_ui->m_groupSettings, SIGNAL(toggled(bool)), this, SLOT(checkOkButton())); connect(m_ui->m_groupSettings, SIGNAL(toggled(bool)), this, SLOT(checkOkButton()));
connect(m_ui->m_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(performRestoration())); connect(m_ui->m_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(performRestoration()));
selectFolder(qApp->documentsFolderPath()); selectFolder(qApp->getDocumentsFolderPath());
} }
FormRestoreDatabaseSettings::~FormRestoreDatabaseSettings() { FormRestoreDatabaseSettings::~FormRestoreDatabaseSettings() {

View file

@ -122,7 +122,7 @@ void FormUpdate::updateProgress(qint64 bytes_received, qint64 bytes_total) {
void FormUpdate::saveUpdateFile(const QByteArray &file_contents) { void FormUpdate::saveUpdateFile(const QByteArray &file_contents) {
const QString url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;; const QString url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;;
const QString temp_directory = qApp->tempFolderPath(); const QString temp_directory = qApp->getTempFolderPath();
if (!temp_directory.isEmpty()) { if (!temp_directory.isEmpty()) {
const QString output_file_name = url_file.mid(url_file.lastIndexOf('/') + 1); const QString output_file_name = url_file.mid(url_file.lastIndexOf('/') + 1);

View file

@ -62,7 +62,7 @@ void SettingsBrowserMail::changeDefaultBrowserArguments(int index) {
void SettingsBrowserMail::selectBrowserExecutable() { void SettingsBrowserMail::selectBrowserExecutable() {
const QString executable_file = QFileDialog::getOpenFileName(this, const QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select web browser executable"), tr("Select web browser executable"),
qApp->homeFolderPath(), qApp->getHomeFolderPath(),
//: File filter for external browser selection dialog. //: File filter for external browser selection dialog.
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
tr("Executables (*)") tr("Executables (*)")
@ -110,7 +110,7 @@ void SettingsBrowserMail::changeDefaultEmailArguments(int index) {
void SettingsBrowserMail::selectEmailExecutable() { void SettingsBrowserMail::selectEmailExecutable() {
QString executable_file = QFileDialog::getOpenFileName(this, QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select e-mail executable"), tr("Select e-mail executable"),
qApp->homeFolderPath(), qApp->getHomeFolderPath(),
//: File filter for external e-mail selection dialog. //: File filter for external e-mail selection dialog.
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
tr("Executables (*)") tr("Executables (*)")

View file

@ -100,7 +100,11 @@ int main(int argc, char *argv[]) {
// These settings needs to be set before any QSettings object. // These settings needs to be set before any QSettings object.
Application::setApplicationName(APP_NAME); Application::setApplicationName(APP_NAME);
Application::setApplicationVersion(APP_VERSION); Application::setApplicationVersion(APP_VERSION);
#if !defined(Q_OS_LINUX)
Application::setOrganizationName(APP_AUTHOR); Application::setOrganizationName(APP_AUTHOR);
#endif
Application::setOrganizationDomain(APP_URL); Application::setOrganizationDomain(APP_URL);
Application::setWindowIcon(QIcon(APP_ICON_PATH)); Application::setWindowIcon(QIcon(APP_ICON_PATH));

View file

@ -188,31 +188,19 @@ void Application::setMainForm(FormMain *main_form) {
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
QString Application::getXdgConfigHomePath() { QString Application::getXdgConfigHomePath() {
// TODO: Return ".config" folder on Linux. return IOFactory::getSystemFolder(QStandardPaths::ConfigLocation);
// XDG_CONFIG_HOME
// Where user-specific configurations should be written (analogous to /etc).
// Should default to $HOME/.config.
const QString xdgConfigHome = qgetenv("XDG_CONFIG_HOME");
if (xdgConfigHome.isEmpty()) {
return qgetenv("HOME") + QDir::separator() + ".config";
}
else {
return xdgConfigHome;
}
} }
#endif #endif
QString Application::tempFolderPath() { QString Application::getTempFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::TempLocation); return IOFactory::getSystemFolder(QStandardPaths::TempLocation);
} }
QString Application::documentsFolderPath() { QString Application::getDocumentsFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::DocumentsLocation); return IOFactory::getSystemFolder(QStandardPaths::DocumentsLocation);
} }
QString Application::homeFolderPath() { QString Application::getHomeFolderPath() {
return IOFactory::getSystemFolder(QStandardPaths::HomeLocation); return IOFactory::getSystemFolder(QStandardPaths::HomeLocation);
} }

View file

@ -80,9 +80,9 @@ class Application : public QtSingleApplication {
QWidget *mainFormWidget(); QWidget *mainFormWidget();
SystemTrayIcon *trayIcon(); SystemTrayIcon *trayIcon();
QString tempFolderPath(); QString getTempFolderPath();
QString documentsFolderPath(); QString getDocumentsFolderPath();
QString homeFolderPath(); QString getHomeFolderPath();
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
QString getXdgConfigHomePath(); QString getXdgConfigHomePath();

View file

@ -322,17 +322,16 @@ QString Settings::getAppPathUserFolder() {
return qApp->applicationDirPath() + QDir::separator() + QSL("data"); return qApp->applicationDirPath() + QDir::separator() + QSL("data");
} }
QString Settings::getHomeUserFolder() { QString Settings::getHomeUserFolder() {
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
QString home_folder = qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QSL("data"); // Fallback folder.
QString home_folder = qApp->getHomeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QSL("data");
if (QDir().exists(home_folder)) { if (QDir().exists(home_folder)) {
return home_folder; return home_folder;
} }
else { else {
return qApp->getXdgConfigHomePath() + QDir::separator() + QString(APP_LOW_NAME); return qApp->getXdgConfigHomePath() + QDir::separator() + QString(APP_NAME);
} }
#else #else
return qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QSL("data"); return qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QSL("data");

View file

@ -187,7 +187,7 @@ void FormFeedDetails::onNoIconSelected() {
void FormFeedDetails::onLoadIconFromFile() { void FormFeedDetails::onLoadIconFromFile() {
QFileDialog dialog(this, tr("Select icon file for the feed"), QFileDialog dialog(this, tr("Select icon file for the feed"),
qApp->homeFolderPath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)")); qApp->getHomeFolderPath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)"));
dialog.setFileMode(QFileDialog::ExistingFile); dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setWindowIcon(qApp->icons()->fromTheme(QSL("image-x-generic"))); dialog.setWindowIcon(qApp->icons()->fromTheme(QSL("image-x-generic")));
dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly); dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly);

View file

@ -178,7 +178,7 @@ void FormStandardCategoryDetails::onNoIconSelected() {
void FormStandardCategoryDetails::onLoadIconFromFile() { void FormStandardCategoryDetails::onLoadIconFromFile() {
QFileDialog dialog(this, tr("Select icon file for the category"), QFileDialog dialog(this, tr("Select icon file for the category"),
qApp->homeFolderPath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)")); qApp->getHomeFolderPath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)"));
dialog.setFileMode(QFileDialog::ExistingFile); dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setWindowIcon(qApp->icons()->fromTheme(QSL("image-x-generic"))); dialog.setWindowIcon(qApp->icons()->fromTheme(QSL("image-x-generic")));
dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly); dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly);

View file

@ -163,7 +163,7 @@ void FormStandardImportExport::selectExportFile() {
filter += filter_txt_url_per_line; filter += filter_txt_url_per_line;
QString selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"), QString selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"),
qApp->homeFolderPath(), filter, &selected_filter); qApp->getHomeFolderPath(), filter, &selected_filter);
if (!selected_file.isEmpty()) { if (!selected_file.isEmpty()) {
if (selected_filter == filter_opml20) { if (selected_filter == filter_opml20) {
@ -199,7 +199,7 @@ void FormStandardImportExport::selectImportFile() {
filter += ";;"; filter += ";;";
filter += filter_txt_url_per_line; filter += filter_txt_url_per_line;
const QString selected_file = QFileDialog::getOpenFileName(this, tr("Select file for feeds import"), qApp->homeFolderPath(), const QString selected_file = QFileDialog::getOpenFileName(this, tr("Select file for feeds import"), qApp->getHomeFolderPath(),
filter, &selected_filter); filter, &selected_filter);
if (!selected_file.isEmpty()) { if (!selected_file.isEmpty()) {