diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0760262bb..eb757d1cd 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -354,6 +354,7 @@ set(APP_SOURCES
src/gui/formimportexport.cpp
src/gui/styleditemdelegatewithoutfocus.cpp
src/gui/formbackupdatabasesettings.cpp
+ src/gui/formrestoredatabasesettings.cpp
# DYNAMIC-SHORTCUTS sources.
src/dynamic-shortcuts/shortcutcatcher.cpp
@@ -440,6 +441,7 @@ set(APP_HEADERS
src/gui/messagessearchlineedit.h
src/gui/formimportexport.h
src/gui/formbackupdatabasesettings.h
+ src/gui/formrestoredatabasesettings.h
# DYNAMIC-SHORTCUTS headers.
src/dynamic-shortcuts/dynamicshortcutswidget.h
@@ -486,6 +488,7 @@ set(APP_FORMS
src/gui/toolbareditor.ui
src/gui/formimportexport.ui
src/gui/formbackupdatabasesettings.ui
+ src/gui/formrestoredatabasesettings.ui
)
# APP translations.
diff --git a/src/gui/formimportexport.ui b/src/gui/formimportexport.ui
index 599924082..46af7e659 100644
--- a/src/gui/formimportexport.ui
+++ b/src/gui/formimportexport.ui
@@ -146,22 +146,6 @@
-
- m_buttonBox
- accepted()
- FormImportExport
- accept()
-
-
- 248
- 254
-
-
- 157
- 274
-
-
-
m_buttonBox
rejected()
diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp
index 063736717..5f3f83d5a 100755
--- a/src/gui/formmain.cpp
+++ b/src/gui/formmain.cpp
@@ -36,6 +36,7 @@
#include "gui/formupdate.h"
#include "gui/formimportexport.h"
#include "gui/formbackupdatabasesettings.h"
+#include "gui/formrestoredatabasesettings.h"
#include
#include
@@ -405,7 +406,9 @@ void FormMain::backupDatabaseSettings() {
}
void FormMain::restoreDatabaseSettings() {
-
+ QPointer form = new FormRestoreDatabaseSettings(this);
+ form.data()->exec();
+ delete form.data();
}
void FormMain::changeEvent(QEvent *event) {
diff --git a/src/gui/formrestoredatabasesettings.cpp b/src/gui/formrestoredatabasesettings.cpp
new file mode 100644
index 000000000..e87d968b3
--- /dev/null
+++ b/src/gui/formrestoredatabasesettings.cpp
@@ -0,0 +1,106 @@
+// This file is part of RSS Guard.
+//
+// Copyright (C) 2011-2014 by Martin Rotter
+//
+// RSS Guard is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// RSS Guard is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with RSS Guard. If not, see .
+
+#include "gui/formrestoredatabasesettings.h"
+
+#include "miscellaneous/iconfactory.h"
+
+#include "QFileDialog"
+
+
+FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget *parent)
+ : QDialog(parent), m_ui(new Ui::FormRestoreDatabaseSettings) {
+ m_ui->setupUi(this);
+
+ setWindowIcon(qApp->icons()->fromTheme("document-import"));
+ setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint);
+
+ m_ui->m_lblResult->setStatus(WidgetWithStatus::Warning, tr("No operation executed yet."), tr("No operation executed yet."));
+
+ connect(m_ui->m_btnSelectFolder, SIGNAL(clicked()), this, SLOT(selectFolder()));
+ connect(m_ui->m_groupDatabase, 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()));
+
+ selectFolder(qApp->documentsFolderPath());
+}
+
+FormRestoreDatabaseSettings::~FormRestoreDatabaseSettings() {
+ delete m_ui;
+}
+
+void FormRestoreDatabaseSettings::performRestoration() {
+ // TODO: Pokračovat
+}
+
+void FormRestoreDatabaseSettings::checkOkButton() {
+ m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!m_ui->m_lblSelectFolder->label()->text().isEmpty() &&
+ ((m_ui->m_groupDatabase->isChecked() &&
+ m_ui->m_listDatabase->currentRow() >= 0) ||
+ (m_ui->m_groupSettings->isChecked() &&
+ m_ui->m_listSettings->currentRow() >= 0)));
+}
+
+void FormRestoreDatabaseSettings::selectFolder(QString folder) {
+ if (folder.isEmpty()) {
+ folder = QFileDialog::getExistingDirectory(this, tr("Select source folder"), m_ui->m_lblSelectFolder->label()->text());
+ }
+
+ if (!folder.isEmpty()) {
+ m_ui->m_lblSelectFolder->setStatus(WidgetWithStatus::Ok, QDir::toNativeSeparators(folder),
+ tr("Good source folder is specified."));
+ }
+ else {
+ return;
+ }
+
+ QDir selected_folder(folder);
+ QFileInfoList available_databases = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_DATABASE ,
+ QDir::Files | QDir::NoDotAndDotDot | QDir::Readable |
+ QDir::CaseSensitive | QDir::NoSymLinks,
+ QDir::Name);
+ QFileInfoList available_settings = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_SETTINGS ,
+ QDir::Files | QDir::NoDotAndDotDot | QDir::Readable |
+ QDir::CaseSensitive | QDir::NoSymLinks,
+ QDir::Name);
+
+ m_ui->m_listDatabase->clear();
+ m_ui->m_listSettings->clear();
+
+ foreach (const QFileInfo &database_file, available_databases) {
+ QListWidgetItem *database_item = new QListWidgetItem(database_file.fileName(), m_ui->m_listDatabase);
+ database_item->setData(Qt::UserRole, database_file.absoluteFilePath());
+ database_item->setToolTip(QDir::toNativeSeparators(database_file.absoluteFilePath()));
+ }
+
+ foreach (const QFileInfo &settings_file, available_settings) {
+ QListWidgetItem *settings_item = new QListWidgetItem(settings_file.fileName(), m_ui->m_listSettings);
+ settings_item->setData(Qt::UserRole, settings_file.absoluteFilePath());
+ settings_item->setToolTip(QDir::toNativeSeparators(settings_file.absoluteFilePath()));
+ }
+
+ if (!available_databases.isEmpty()) {
+ m_ui->m_listDatabase->setCurrentRow(0);
+ }
+
+ if (!available_settings.isEmpty()) {
+ m_ui->m_listSettings->setCurrentRow(0);
+ }
+
+ m_ui->m_groupDatabase->setChecked(!available_databases.isEmpty());
+ m_ui->m_groupSettings->setChecked(!available_settings.isEmpty());
+}
diff --git a/src/gui/formrestoredatabasesettings.h b/src/gui/formrestoredatabasesettings.h
new file mode 100644
index 000000000..b7f6048b3
--- /dev/null
+++ b/src/gui/formrestoredatabasesettings.h
@@ -0,0 +1,47 @@
+// This file is part of RSS Guard.
+//
+// Copyright (C) 2011-2014 by Martin Rotter
+//
+// RSS Guard is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// RSS Guard is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with RSS Guard. If not, see .
+
+#ifndef FORMRESTOREDATABASESETTINGS_H
+#define FORMRESTOREDATABASESETTINGS_H
+
+#include
+
+#include "ui_formrestoredatabasesettings.h"
+
+
+namespace Ui {
+ class FormRestoreDatabaseSettings;
+}
+
+class FormRestoreDatabaseSettings : public QDialog {
+ Q_OBJECT
+
+ public:
+ // Constructors and destructors.
+ explicit FormRestoreDatabaseSettings(QWidget *parent = 0);
+ virtual ~FormRestoreDatabaseSettings();
+
+ private slots:
+ void performRestoration();
+ void checkOkButton();
+ void selectFolder(QString folder = QString());
+
+ private:
+ Ui::FormRestoreDatabaseSettings *m_ui;
+};
+
+#endif // FORMRESTOREDATABASESETTINGS_H
diff --git a/src/gui/formrestoredatabasesettings.ui b/src/gui/formrestoredatabasesettings.ui
new file mode 100644
index 000000000..0a5c884d4
--- /dev/null
+++ b/src/gui/formrestoredatabasesettings.ui
@@ -0,0 +1,144 @@
+
+
+ FormRestoreDatabaseSettings
+
+
+
+ 0
+ 0
+ 509
+ 352
+
+
+
+ Restore database/settings
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 379
+ 26
+
+
+
+
+ -
+
+
+ Operation results
+
+
+
-
+
+
+ Qt::RightToLeft
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Close|QDialogButtonBox::Ok
+
+
+
+ -
+
+
+
+
+
+
-
+
+
+ &Select folder
+
+
+
+ -
+
+
+ Qt::RightToLeft
+
+
+
+
+
+
+ -
+
+
+ Restore database
+
+
+ true
+
+
+ false
+
+
+
-
+
+
+
+
+
+ -
+
+
+ Restore settings
+
+
+ true
+
+
+ false
+
+
+
-
+
+
+
+
+
+
+
+
+
+ LabelWithStatus
+ QWidget
+
+ 1
+
+
+
+
+
+ m_buttonBox
+ rejected()
+ FormRestoreDatabaseSettings
+ reject()
+
+
+ 254
+ 331
+
+
+ 254
+ 175
+
+
+
+
+
diff --git a/src/qtsingleapplication/qtlocalpeer.h b/src/qtsingleapplication/qtlocalpeer.h
index 1b533b1ab..8a1f2d169 100644
--- a/src/qtsingleapplication/qtlocalpeer.h
+++ b/src/qtsingleapplication/qtlocalpeer.h
@@ -64,7 +64,7 @@ Q_SIGNALS:
protected Q_SLOTS:
void receiveConnection();
-protected:
+public:
QString id;
QString socketName;
QLocalServer* server;