mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-01-30 09:04:48 +01:00
Issue #34: Reset to Factory Settings option
This commit is contained in:
parent
98703cd483
commit
dead0dc519
@ -325,6 +325,7 @@ PDFProgramController::PDFProgramController(QObject* parent) :
|
||||
m_annotationManager(nullptr),
|
||||
m_formManager(nullptr),
|
||||
m_isBusy(false),
|
||||
m_isFactorySettingsBeingRestored(false),
|
||||
m_progress(nullptr)
|
||||
{
|
||||
|
||||
@ -494,6 +495,10 @@ void PDFProgramController::initialize(Features features,
|
||||
{
|
||||
connect(action, &QAction::triggered, this, &PDFProgramController::onActionOptionsTriggered);
|
||||
}
|
||||
if (QAction* action = m_actionManager->getAction(PDFActionManager::ResetToFactorySettings))
|
||||
{
|
||||
connect(action, &QAction::triggered, this, &PDFProgramController::resetSettings);
|
||||
}
|
||||
if (QAction* action = m_actionManager->getAction(PDFActionManager::CertificateManager))
|
||||
{
|
||||
connect(action, &QAction::triggered, this, &PDFProgramController::onActionCertificateManagerTriggered);
|
||||
@ -1059,6 +1064,11 @@ void PDFProgramController::saveDocument(const QString& fileName)
|
||||
}
|
||||
}
|
||||
|
||||
bool PDFProgramController::isFactorySettingsBeingRestored() const
|
||||
{
|
||||
return m_isFactorySettingsBeingRestored;
|
||||
}
|
||||
|
||||
bool PDFProgramController::getIsBusy() const
|
||||
{
|
||||
return m_isBusy;
|
||||
@ -1471,6 +1481,7 @@ void PDFProgramController::updateActionsAvailability()
|
||||
m_actionManager->setEnabled(PDFActionManager::Close, hasValidDocument);
|
||||
m_actionManager->setEnabled(PDFActionManager::Quit, !isBusy);
|
||||
m_actionManager->setEnabled(PDFActionManager::Options, !isBusy);
|
||||
m_actionManager->setEnabled(PDFActionManager::ResetToFactorySettings, !isBusy);
|
||||
m_actionManager->setEnabled(PDFActionManager::About, !isBusy);
|
||||
m_actionManager->setEnabled(PDFActionManager::FitPage, hasValidDocument);
|
||||
m_actionManager->setEnabled(PDFActionManager::FitWidth, hasValidDocument);
|
||||
@ -1882,6 +1893,8 @@ void PDFProgramController::loadPlugins()
|
||||
|
||||
void PDFProgramController::writeSettings()
|
||||
{
|
||||
Q_ASSERT(!m_isFactorySettingsBeingRestored);
|
||||
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
settings.setValue("geometry", m_mainWindow->saveGeometry());
|
||||
settings.setValue("windowState", m_mainWindow->saveState());
|
||||
@ -1916,6 +1929,26 @@ void PDFProgramController::writeSettings()
|
||||
m_certificateStore.saveDefaultUserCertificates();
|
||||
}
|
||||
|
||||
void PDFProgramController::resetSettings()
|
||||
{
|
||||
if (!canClose())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (QMessageBox::question(m_mainWindow, tr("Reset Ssettings"), tr("Do you wish to restore the default factory settings of the program? All settings changed by the user will be deleted. Application will be closed."), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
|
||||
{
|
||||
closeDocument();
|
||||
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
settings.clear();
|
||||
|
||||
QMessageBox::information(m_mainWindow, tr("Reset Settings"), tr("Default factory settings were restored. Application will be now closed."));
|
||||
m_isFactorySettingsBeingRestored = true;
|
||||
m_mainWindow->close();
|
||||
}
|
||||
}
|
||||
|
||||
void PDFProgramController::onActionOptionsTriggered()
|
||||
{
|
||||
PDFViewerSettingsDialog::OtherSettings otherSettings;
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
SaveAs,
|
||||
Properties,
|
||||
Options,
|
||||
ResetToFactorySettings,
|
||||
CertificateManager,
|
||||
GetSource,
|
||||
About,
|
||||
@ -272,6 +273,7 @@ public:
|
||||
pdf::PDFProgress* progress);
|
||||
void finishInitialization();
|
||||
void writeSettings();
|
||||
void resetSettings();
|
||||
|
||||
void performPrint();
|
||||
void performSave();
|
||||
@ -290,6 +292,8 @@ public:
|
||||
virtual QMainWindow* getMainWindow() const override;
|
||||
virtual VoiceSettings getVoiceSettings() const override;
|
||||
|
||||
bool isFactorySettingsBeingRestored() const;
|
||||
|
||||
signals:
|
||||
void queryPasswordRequest(QString* password, bool* ok);
|
||||
|
||||
@ -402,6 +406,7 @@ private:
|
||||
std::vector<pdf::PDFSignatureVerificationResult> m_signatures;
|
||||
|
||||
bool m_isBusy;
|
||||
bool m_isFactorySettingsBeingRestored;
|
||||
pdf::PDFProgress* m_progress;
|
||||
|
||||
QStringList m_enabledPlugins;
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "pdfwidgetutils.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QCloseEvent>
|
||||
@ -155,6 +154,7 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionShowTextLines, ui->actionShow_Text_Lines);
|
||||
m_actionManager->setAction(PDFActionManager::Properties, ui->actionProperties);
|
||||
m_actionManager->setAction(PDFActionManager::Options, ui->actionOptions);
|
||||
m_actionManager->setAction(PDFActionManager::ResetToFactorySettings, ui->actionResetToFactorySettings);
|
||||
m_actionManager->setAction(PDFActionManager::CertificateManager, ui->actionCertificateManager);
|
||||
m_actionManager->setAction(PDFActionManager::GetSource, ui->actionGetSource);
|
||||
m_actionManager->setAction(PDFActionManager::About, ui->actionAbout);
|
||||
@ -499,7 +499,11 @@ void PDFViewerMainWindow::closeEvent(QCloseEvent* event)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_programController->writeSettings();
|
||||
if (!m_programController->isFactorySettingsBeingRestored())
|
||||
{
|
||||
m_programController->writeSettings();
|
||||
}
|
||||
|
||||
m_programController->closeDocument();
|
||||
event->accept();
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>770</width>
|
||||
<height>21</height>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@ -103,6 +103,8 @@
|
||||
<addaction name="actionRendering_Errors"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionOptions"/>
|
||||
<addaction name="actionResetToFactorySettings"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCertificateManager"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
@ -343,6 +345,11 @@
|
||||
<string>Ctrl+K</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionResetToFactorySettings">
|
||||
<property name="text">
|
||||
<string>Reset to Factory Settings</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoom_In">
|
||||
<property name="icon">
|
||||
<iconset resource="pdf4qtviewer.qrc">
|
||||
|
@ -123,6 +123,7 @@ PDFViewerMainWindowLite::PDFViewerMainWindowLite(QWidget* parent) :
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionInvertColors, ui->actionInvertColors);
|
||||
m_actionManager->setAction(PDFActionManager::Properties, ui->actionProperties);
|
||||
m_actionManager->setAction(PDFActionManager::Options, ui->actionOptions);
|
||||
m_actionManager->setAction(PDFActionManager::ResetToFactorySettings, ui->actionResetToFactorySettings);
|
||||
m_actionManager->setAction(PDFActionManager::CertificateManager, ui->actionCertificateManager);
|
||||
m_actionManager->setAction(PDFActionManager::GetSource, ui->actionGetSource);
|
||||
m_actionManager->setAction(PDFActionManager::About, ui->actionAbout);
|
||||
@ -400,7 +401,11 @@ void PDFViewerMainWindowLite::closeEvent(QCloseEvent* event)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_programController->writeSettings();
|
||||
if (!m_programController->isFactorySettingsBeingRestored())
|
||||
{
|
||||
m_programController->writeSettings();
|
||||
}
|
||||
|
||||
m_programController->closeDocument();
|
||||
event->accept();
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>770</width>
|
||||
<height>21</height>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@ -97,6 +97,8 @@
|
||||
<addaction name="actionRendering_Errors"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionOptions"/>
|
||||
<addaction name="actionResetToFactorySettings"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCertificateManager"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
@ -263,6 +265,11 @@
|
||||
<string>Ctrl+K</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionResetToFactorySettings">
|
||||
<property name="text">
|
||||
<string>Reset to Factory Settings</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoom_In">
|
||||
<property name="icon">
|
||||
<iconset resource="pdf4qtviewer.qrc">
|
||||
|
Loading…
x
Reference in New Issue
Block a user