Work on settings/db restoration.
This commit is contained in:
parent
11e74a0b6a
commit
c2e55d45a2
@ -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.
|
||||
|
@ -146,22 +146,6 @@
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>m_buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>FormImportExport</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "gui/formupdate.h"
|
||||
#include "gui/formimportexport.h"
|
||||
#include "gui/formbackupdatabasesettings.h"
|
||||
#include "gui/formrestoredatabasesettings.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QSessionManager>
|
||||
@ -405,7 +406,9 @@ void FormMain::backupDatabaseSettings() {
|
||||
}
|
||||
|
||||
void FormMain::restoreDatabaseSettings() {
|
||||
|
||||
QPointer<FormRestoreDatabaseSettings> form = new FormRestoreDatabaseSettings(this);
|
||||
form.data()->exec();
|
||||
delete form.data();
|
||||
}
|
||||
|
||||
void FormMain::changeEvent(QEvent *event) {
|
||||
|
106
src/gui/formrestoredatabasesettings.cpp
Normal file
106
src/gui/formrestoredatabasesettings.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
// This file is part of RSS Guard.
|
||||
//
|
||||
// Copyright (C) 2011-2014 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#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());
|
||||
}
|
47
src/gui/formrestoredatabasesettings.h
Normal file
47
src/gui/formrestoredatabasesettings.h
Normal file
@ -0,0 +1,47 @@
|
||||
// This file is part of RSS Guard.
|
||||
//
|
||||
// Copyright (C) 2011-2014 by Martin Rotter <rotter.martinos@gmail.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef FORMRESTOREDATABASESETTINGS_H
|
||||
#define FORMRESTOREDATABASESETTINGS_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#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
|
144
src/gui/formrestoredatabasesettings.ui
Normal file
144
src/gui/formrestoredatabasesettings.ui
Normal file
@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FormRestoreDatabaseSettings</class>
|
||||
<widget class="QDialog" name="FormRestoreDatabaseSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>509</width>
|
||||
<height>352</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Restore database/settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>379</width>
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Operation results</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="LabelWithStatus" name="m_lblResult" native="true">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="m_groupFile">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="m_btnSelectFolder">
|
||||
<property name="text">
|
||||
<string>&Select folder</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LabelWithStatus" name="m_lblSelectFolder" native="true">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="m_groupDatabase">
|
||||
<property name="title">
|
||||
<string>Restore database</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="m_listDatabase"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QGroupBox" name="m_groupSettings">
|
||||
<property name="title">
|
||||
<string>Restore settings</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QListWidget" name="m_listSettings"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LabelWithStatus</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>labelwithstatus.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>m_buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>FormRestoreDatabaseSettings</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>254</x>
|
||||
<y>331</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>254</x>
|
||||
<y>175</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -64,7 +64,7 @@ Q_SIGNALS:
|
||||
protected Q_SLOTS:
|
||||
void receiveConnection();
|
||||
|
||||
protected:
|
||||
public:
|
||||
QString id;
|
||||
QString socketName;
|
||||
QLocalServer* server;
|
||||
|
Loading…
x
Reference in New Issue
Block a user