diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 9ee013c6b..29e44d02a 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -120,6 +120,7 @@ class FeedsView : public QTreeView { // Reloads counts for selected feeds. void updateCountsOfSelectedFeeds(bool update_total_too); + // Reloads counts of recycle bin. void updateCountsOfRecycleBin(bool update_total_too); // Reloads counts for all feeds. diff --git a/src/gui/formabout.cpp b/src/gui/formabout.cpp index c6d174c7f..94cd3bcda 100755 --- a/src/gui/formabout.cpp +++ b/src/gui/formabout.cpp @@ -110,7 +110,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout) } else { m_ui->m_txtPathsSettingsType->setText(tr("PARTIALLY portable")); - m_ui->m_txtPathsDatabaseRoot->setText(QDir::toNativeSeparators(QDir::homePath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QString(APP_DB_SQLITE_PATH))); + m_ui->m_txtPathsDatabaseRoot->setText(QDir::toNativeSeparators(qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QString(APP_DB_SQLITE_PATH))); } m_ui->m_txtPathsSettingsFile->setText(QDir::toNativeSeparators(qApp->settings()->fileName())); diff --git a/src/gui/formbackupdatabasesettings.cpp b/src/gui/formbackupdatabasesettings.cpp index a7249d4cc..dac0be2c4 100644 --- a/src/gui/formbackupdatabasesettings.cpp +++ b/src/gui/formbackupdatabasesettings.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormBackupDatabaseSettings) { @@ -34,11 +36,12 @@ FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget *parent) : QDialo connect(m_ui->m_checkBackupDatabase, SIGNAL(toggled(bool)), this, SLOT(checkOkButton())); connect(m_ui->m_checkBackupSettings, SIGNAL(toggled(bool)), this, SLOT(checkOkButton())); + connect(m_ui->m_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(performBackup())); connect(m_ui->m_txtBackupName->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkBackupNames(QString))); connect(m_ui->m_txtBackupName->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(checkOkButton())); + connect(m_ui->m_btnSelectFolder, SIGNAL(clicked()), this, SLOT(selectFolder())); - checkOkButton(); - + selectFolder(qApp->documentsFolderPath()); m_ui->m_txtBackupName->lineEdit()->setText(QString(APP_LOW_NAME) + "_" + QDateTime::currentDateTime().toString("yyyyMMddHHmm")); } @@ -46,6 +49,20 @@ FormBackupDatabaseSettings::~FormBackupDatabaseSettings() { delete m_ui; } +void FormBackupDatabaseSettings::performBackup() { + +} + +void FormBackupDatabaseSettings::selectFolder(QString path) { + if (path.isEmpty()) { + path = QFileDialog::getExistingDirectory(this, tr("Select destionation folder"), m_ui->m_lblSelectFolder->label()->text()); + } + + if (!path.isEmpty()) { + m_ui->m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(path), tr("Good destination folder is specified.")); + } +} + void FormBackupDatabaseSettings::checkBackupNames(const QString &name) { if (name.simplified().isEmpty()) { m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Error, tr("Backup name cannot be empty.")); diff --git a/src/gui/formbackupdatabasesettings.h b/src/gui/formbackupdatabasesettings.h index a7e89ef17..cf0254a7b 100644 --- a/src/gui/formbackupdatabasesettings.h +++ b/src/gui/formbackupdatabasesettings.h @@ -37,6 +37,8 @@ class FormBackupDatabaseSettings : public QDialog { private slots: + void performBackup(); + void selectFolder(QString path = QString()); void checkBackupNames(const QString &name); void checkOkButton(); diff --git a/src/gui/formcategorydetails.cpp b/src/gui/formcategorydetails.cpp index bc772b15a..c3745da5d 100755 --- a/src/gui/formcategorydetails.cpp +++ b/src/gui/formcategorydetails.cpp @@ -164,7 +164,7 @@ void FormCategoryDetails::onNoIconSelected() { void FormCategoryDetails::onLoadIconFromFile() { QFileDialog dialog(this, tr("Select icon file for the category"), - QDir::homePath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)")); + qApp->homeFolderPath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)")); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setWindowIcon(qApp->icons()->fromTheme("image-generic")); dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly); diff --git a/src/gui/formfeeddetails.cpp b/src/gui/formfeeddetails.cpp index 08c95a5e6..7f54bbaab 100755 --- a/src/gui/formfeeddetails.cpp +++ b/src/gui/formfeeddetails.cpp @@ -178,7 +178,7 @@ void FormFeedDetails::onNoIconSelected() { void FormFeedDetails::onLoadIconFromFile() { QFileDialog dialog(this, tr("Select icon file for the feed"), - QDir::homePath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)")); + qApp->homeFolderPath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)")); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setWindowIcon(qApp->icons()->fromTheme("image-generic")); dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly); diff --git a/src/gui/formimportexport.cpp b/src/gui/formimportexport.cpp index e4f6ed3bf..e5fd49e4c 100644 --- a/src/gui/formimportexport.cpp +++ b/src/gui/formimportexport.cpp @@ -105,7 +105,7 @@ void FormImportExport::selectExportFile() { filter += filter_opml20; QString selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"), - QDir::homePath(), filter, &selected_filter); + qApp->homeFolderPath(), filter, &selected_filter); @@ -136,7 +136,8 @@ void FormImportExport::selectImportFile() { // Add more filters here. filter += filter_opml20; - QString selected_file = QFileDialog::getOpenFileName(this, tr("Select file for feeds import"), QDir::homePath(), filter, &selected_filter); + QString selected_file = QFileDialog::getOpenFileName(this, tr("Select file for feeds import"), qApp->homeFolderPath(), + filter, &selected_filter); if (!selected_file.isEmpty()) { if (selected_filter == filter_opml20) { diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index fb621996a..767e2a21f 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -164,7 +164,7 @@ void FormSettings::onSkinSelected(QTreeWidgetItem *current, void FormSettings::selectBrowserExecutable() { QString executable_file = QFileDialog::getOpenFileName(this, tr("Select web browser executable"), - QDir::homePath(), + qApp->homeFolderPath(), //: File filter for external browser selection dialog. tr("Executables (*.*)")); diff --git a/src/gui/formupdate.cpp b/src/gui/formupdate.cpp index 86abad591..45b940a9d 100755 --- a/src/gui/formupdate.cpp +++ b/src/gui/formupdate.cpp @@ -129,7 +129,7 @@ void FormUpdate::updateProgress(qint64 bytes_received, qint64 bytes_total) { void FormUpdate::saveUpdateFile(const QByteArray &file_contents) { QString url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;; - QString temp_directory = qApp->getTempDirectory(); + QString temp_directory = qApp->tempFolderPath(); if (!temp_directory.isEmpty()) { QString output_file_name = url_file.mid(url_file.lastIndexOf('/') + 1); diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h index 37b176c52..8a348d553 100755 --- a/src/miscellaneous/application.h +++ b/src/miscellaneous/application.h @@ -118,7 +118,7 @@ class Application : public QtSingleApplication { m_mainForm = main_form; } - inline QString getTempDirectory() { + inline QString tempFolderPath() { #if QT_VERSION >= 0x050000 QString temp_directory = QStandardPaths::writableLocation(QStandardPaths::TempLocation); #else @@ -127,6 +127,24 @@ class Application : public QtSingleApplication { return temp_directory; } + inline QString documentsFolderPath() { +#if QT_VERSION >= 0x050000 + QString doc_directory = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); +#else + QString doc_directory = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); +#endif + return doc_directory; + } + + inline QString homeFolderPath() { +#if QT_VERSION >= 0x050000 + QString home_path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); +#else + QString home_path = QDesktopServices::storageLocation(QDesktopServices::HomeLocation); +#endif + return home_path; + } + // Access to application tray icon. Always use this in cooperation with // SystemTrayIcon::isSystemTrayActivated(). SystemTrayIcon *trayIcon(); diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp index f993ff7ae..793f94380 100755 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -87,7 +87,7 @@ void DatabaseFactory::sqliteAssemblyDatabaseFilePath() { QString(APP_DB_SQLITE_PATH); } else { - m_sqliteDatabaseFilePath = QDir::homePath() + QDir::separator() + + m_sqliteDatabaseFilePath = qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QString(APP_DB_SQLITE_PATH); } diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index 97b5729ef..dea44e4a6 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -47,14 +47,13 @@ Settings *Settings::setupSettings(QObject *parent) { // If settings file exists in executable file working directory // (in subdirectory APP_CFG_PATH), then use it (portable settings). - // Otherwise use settings file stored in homePath(); + // Otherwise use settings file stored in home path. QString relative_path = QDir::separator() + QString(APP_CFG_PATH) + QDir::separator() + QString(APP_CFG_FILE); QString app_path = qApp->applicationDirPath(); QString app_path_file = app_path + relative_path; - QString home_path = QDir::homePath() + QDir::separator() + QString(APP_LOW_H_NAME); + QString home_path = qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME); QString home_path_file = home_path + relative_path; - bool portable_settings_available = QFileInfo(app_path).isWritable(); bool non_portable_settings_exist = QFile::exists(home_path_file);