Work on backups.

This commit is contained in:
Martin Rotter 2014-10-09 18:20:54 +02:00
parent 0fbedb384c
commit 91789d8445
12 changed files with 52 additions and 14 deletions

View File

@ -120,6 +120,7 @@ class FeedsView : public QTreeView {
// Reloads counts for selected feeds. // Reloads counts for selected feeds.
void updateCountsOfSelectedFeeds(bool update_total_too); void updateCountsOfSelectedFeeds(bool update_total_too);
// Reloads counts of recycle bin.
void updateCountsOfRecycleBin(bool update_total_too); void updateCountsOfRecycleBin(bool update_total_too);
// Reloads counts for all feeds. // Reloads counts for all feeds.

View File

@ -110,7 +110,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
} }
else { else {
m_ui->m_txtPathsSettingsType->setText(tr("PARTIALLY portable")); 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())); m_ui->m_txtPathsSettingsFile->setText(QDir::toNativeSeparators(qApp->settings()->fileName()));

View File

@ -23,6 +23,8 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QPushButton> #include <QPushButton>
#include <QCheckBox> #include <QCheckBox>
#include <QFileDialog>
#include <QDateTime>
FormBackupDatabaseSettings::FormBackupDatabaseSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormBackupDatabaseSettings) { 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_checkBackupDatabase, SIGNAL(toggled(bool)), this, SLOT(checkOkButton()));
connect(m_ui->m_checkBackupSettings, 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(checkBackupNames(QString)));
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()));
checkOkButton(); selectFolder(qApp->documentsFolderPath());
m_ui->m_txtBackupName->lineEdit()->setText(QString(APP_LOW_NAME) + "_" + QDateTime::currentDateTime().toString("yyyyMMddHHmm")); m_ui->m_txtBackupName->lineEdit()->setText(QString(APP_LOW_NAME) + "_" + QDateTime::currentDateTime().toString("yyyyMMddHHmm"));
} }
@ -46,6 +49,20 @@ FormBackupDatabaseSettings::~FormBackupDatabaseSettings() {
delete m_ui; 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) { void FormBackupDatabaseSettings::checkBackupNames(const QString &name) {
if (name.simplified().isEmpty()) { if (name.simplified().isEmpty()) {
m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Error, tr("Backup name cannot be empty.")); m_ui->m_txtBackupName->setStatus(WidgetWithStatus::Error, tr("Backup name cannot be empty."));

View File

@ -37,6 +37,8 @@ class FormBackupDatabaseSettings : public QDialog {
private slots: private slots:
void performBackup();
void selectFolder(QString path = QString());
void checkBackupNames(const QString &name); void checkBackupNames(const QString &name);
void checkOkButton(); void checkOkButton();

View File

@ -164,7 +164,7 @@ void FormCategoryDetails::onNoIconSelected() {
void FormCategoryDetails::onLoadIconFromFile() { void FormCategoryDetails::onLoadIconFromFile() {
QFileDialog dialog(this, tr("Select icon file for the category"), 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.setFileMode(QFileDialog::ExistingFile);
dialog.setWindowIcon(qApp->icons()->fromTheme("image-generic")); dialog.setWindowIcon(qApp->icons()->fromTheme("image-generic"));
dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly); dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly);

View File

@ -178,7 +178,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"),
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.setFileMode(QFileDialog::ExistingFile);
dialog.setWindowIcon(qApp->icons()->fromTheme("image-generic")); dialog.setWindowIcon(qApp->icons()->fromTheme("image-generic"));
dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly); dialog.setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly);

View File

@ -105,7 +105,7 @@ void FormImportExport::selectExportFile() {
filter += filter_opml20; filter += filter_opml20;
QString selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"), 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. // Add more filters here.
filter += filter_opml20; 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_file.isEmpty()) {
if (selected_filter == filter_opml20) { if (selected_filter == filter_opml20) {

View File

@ -164,7 +164,7 @@ void FormSettings::onSkinSelected(QTreeWidgetItem *current,
void FormSettings::selectBrowserExecutable() { void FormSettings::selectBrowserExecutable() {
QString executable_file = QFileDialog::getOpenFileName(this, QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select web browser executable"), tr("Select web browser executable"),
QDir::homePath(), qApp->homeFolderPath(),
//: File filter for external browser selection dialog. //: File filter for external browser selection dialog.
tr("Executables (*.*)")); tr("Executables (*.*)"));

View File

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

View File

@ -118,7 +118,7 @@ class Application : public QtSingleApplication {
m_mainForm = main_form; m_mainForm = main_form;
} }
inline QString getTempDirectory() { inline QString tempFolderPath() {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
QString temp_directory = QStandardPaths::writableLocation(QStandardPaths::TempLocation); QString temp_directory = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
#else #else
@ -127,6 +127,24 @@ class Application : public QtSingleApplication {
return temp_directory; 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 // Access to application tray icon. Always use this in cooperation with
// SystemTrayIcon::isSystemTrayActivated(). // SystemTrayIcon::isSystemTrayActivated().
SystemTrayIcon *trayIcon(); SystemTrayIcon *trayIcon();

View File

@ -87,7 +87,7 @@ void DatabaseFactory::sqliteAssemblyDatabaseFilePath() {
QString(APP_DB_SQLITE_PATH); QString(APP_DB_SQLITE_PATH);
} }
else { else {
m_sqliteDatabaseFilePath = QDir::homePath() + QDir::separator() + m_sqliteDatabaseFilePath = qApp->homeFolderPath() + QDir::separator() +
QString(APP_LOW_H_NAME) + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() +
QString(APP_DB_SQLITE_PATH); QString(APP_DB_SQLITE_PATH);
} }

View File

@ -47,14 +47,13 @@ Settings *Settings::setupSettings(QObject *parent) {
// If settings file exists in executable file working directory // If settings file exists in executable file working directory
// (in subdirectory APP_CFG_PATH), then use it (portable settings). // (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 relative_path = QDir::separator() + QString(APP_CFG_PATH) + QDir::separator() + QString(APP_CFG_FILE);
QString app_path = qApp->applicationDirPath(); QString app_path = qApp->applicationDirPath();
QString app_path_file = app_path + relative_path; 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; QString home_path_file = home_path + relative_path;
bool portable_settings_available = QFileInfo(app_path).isWritable(); bool portable_settings_available = QFileInfo(app_path).isWritable();
bool non_portable_settings_exist = QFile::exists(home_path_file); bool non_portable_settings_exist = QFile::exists(home_path_file);