Add ability to apply settings without closing dialog
This commit is contained in:
parent
032895830c
commit
83232bfc76
@ -185,6 +185,12 @@ void Manager::translated(const TaskPtr &task)
|
|||||||
representer_->represent(task);
|
representer_->represent(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Manager::applySettings(const Settings &settings)
|
||||||
|
{
|
||||||
|
updateSettings(settings);
|
||||||
|
settings.save();
|
||||||
|
}
|
||||||
|
|
||||||
void Manager::fatalError(const QString &text)
|
void Manager::fatalError(const QString &text)
|
||||||
{
|
{
|
||||||
tray_->blockActions(false);
|
tray_->blockActions(false);
|
||||||
@ -216,7 +222,7 @@ void Manager::showLast()
|
|||||||
|
|
||||||
void Manager::settings()
|
void Manager::settings()
|
||||||
{
|
{
|
||||||
SettingsEditor editor(*updater_);
|
SettingsEditor editor(*this, *updater_);
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.load();
|
settings.load();
|
||||||
|
@ -16,6 +16,7 @@ public:
|
|||||||
void corrected(const TaskPtr &task);
|
void corrected(const TaskPtr &task);
|
||||||
void translated(const TaskPtr &task);
|
void translated(const TaskPtr &task);
|
||||||
|
|
||||||
|
void applySettings(const Settings &settings);
|
||||||
void fatalError(const QString &text);
|
void fatalError(const QString &text);
|
||||||
void capture();
|
void capture();
|
||||||
void repeatCapture();
|
void repeatCapture();
|
||||||
|
@ -93,7 +93,7 @@ void cleanupOutdated(QSettings& settings)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Settings::Settings()
|
void Settings::save() const
|
||||||
{
|
{
|
||||||
const auto baseDataPath =
|
const auto baseDataPath =
|
||||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
|
@ -21,9 +21,7 @@ enum class AutoUpdate { Disabled, Daily, Weekly, Monthly };
|
|||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Settings();
|
void save() const;
|
||||||
|
|
||||||
void save();
|
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
QString captureHotkey{"Ctrl+Alt+Z"};
|
QString captureHotkey{"Ctrl+Alt+Z"};
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "settingseditor.h"
|
#include "settingseditor.h"
|
||||||
|
#include "debug.h"
|
||||||
#include "languagecodes.h"
|
#include "languagecodes.h"
|
||||||
|
#include "manager.h"
|
||||||
#include "ui_settingseditor.h"
|
#include "ui_settingseditor.h"
|
||||||
#include "updates.h"
|
#include "updates.h"
|
||||||
#include "widgetstate.h"
|
#include "widgetstate.h"
|
||||||
@ -9,12 +11,16 @@
|
|||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
|
|
||||||
SettingsEditor::SettingsEditor(update::Loader &updater)
|
SettingsEditor::SettingsEditor(Manager &manager, update::Loader &updater)
|
||||||
: ui(new Ui::SettingsEditor)
|
: ui(new Ui::SettingsEditor)
|
||||||
|
, manager_(manager)
|
||||||
, updater_(updater)
|
, updater_(updater)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
connect(ui->buttonBox, &QDialogButtonBox::clicked, //
|
||||||
|
this, &SettingsEditor::handleButtonBoxClicked);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto model = new QStringListModel(this);
|
auto model = new QStringListModel(this);
|
||||||
model->setStringList({tr("General"), tr("Recognition"), tr("Correction"),
|
model->setStringList({tr("General"), tr("Recognition"), tr("Correction"),
|
||||||
@ -248,3 +254,22 @@ void SettingsEditor::adjustUpdatesView()
|
|||||||
updateTesseractLanguages();
|
updateTesseractLanguages();
|
||||||
updateTranslators();
|
updateTranslators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsEditor::handleButtonBoxClicked(QAbstractButton *button)
|
||||||
|
{
|
||||||
|
if (!button)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (button == ui->buttonBox->button(QDialogButtonBox::Ok)) {
|
||||||
|
accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (button == ui->buttonBox->button(QDialogButtonBox::Cancel)) {
|
||||||
|
reject();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (button == ui->buttonBox->button(QDialogButtonBox::Apply)) {
|
||||||
|
manager_.applySettings(settings());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -8,13 +8,14 @@ namespace Ui
|
|||||||
{
|
{
|
||||||
class SettingsEditor;
|
class SettingsEditor;
|
||||||
}
|
}
|
||||||
|
class QAbstractButton;
|
||||||
|
|
||||||
class SettingsEditor : public QDialog
|
class SettingsEditor : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SettingsEditor(update::Loader &updater);
|
SettingsEditor(Manager &manager, update::Loader &updater);
|
||||||
~SettingsEditor();
|
~SettingsEditor();
|
||||||
|
|
||||||
Settings settings() const;
|
Settings settings() const;
|
||||||
@ -26,8 +27,10 @@ private:
|
|||||||
void updateTranslators();
|
void updateTranslators();
|
||||||
void updateTranslationLanguages();
|
void updateTranslationLanguages();
|
||||||
void adjustUpdatesView();
|
void adjustUpdatesView();
|
||||||
|
void handleButtonBoxClicked(QAbstractButton *button);
|
||||||
|
|
||||||
Ui::SettingsEditor *ui;
|
Ui::SettingsEditor *ui;
|
||||||
|
Manager &manager_;
|
||||||
update::Loader &updater_;
|
update::Loader &updater_;
|
||||||
QStringList enabledTranslators_;
|
QStringList enabledTranslators_;
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -541,38 +541,5 @@
|
|||||||
<tabstop>proxySaveCheck</tabstop>
|
<tabstop>proxySaveCheck</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>SettingsEditor</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>256</x>
|
|
||||||
<y>447</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>SettingsEditor</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>324</x>
|
|
||||||
<y>447</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user