Update filters when required after closing sources settings
This commit is contained in:
parent
6a59bd4201
commit
c2e855c9d8
|
@ -145,6 +145,11 @@ DialogSettings::~DialogSettings()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void DialogSettings::sourcesStatus(bool & modified, bool & internetUpdateRequired)
|
||||
{
|
||||
modified = ui->sources->sourcesModified(internetUpdateRequired);
|
||||
}
|
||||
|
||||
void DialogSettings::onOk()
|
||||
{
|
||||
done(QDialog::Accepted);
|
||||
|
|
|
@ -43,6 +43,7 @@ class DialogSettings : public QDialog {
|
|||
public:
|
||||
explicit DialogSettings(QWidget * parent);
|
||||
~DialogSettings() override;
|
||||
void sourcesStatus(bool & modified, bool & internetUpdateRequired);
|
||||
|
||||
public slots:
|
||||
void onRadioLeftPreviewToggled(bool);
|
||||
|
|
|
@ -474,6 +474,12 @@ QString MainWindow::screenGeometries()
|
|||
return geometries.join(QString());
|
||||
}
|
||||
|
||||
void MainWindow::updateFilters(bool internet)
|
||||
{
|
||||
ui->tbUpdateFilters->setEnabled(false);
|
||||
updateFiltersFromSources(0, internet);
|
||||
}
|
||||
|
||||
void MainWindow::onStartupFiltersUpdateFinished(int status)
|
||||
{
|
||||
bool ok = QObject::disconnect(Updater::getInstance(), &Updater::updateIsDone, this, &MainWindow::onStartupFiltersUpdateFinished);
|
||||
|
@ -986,8 +992,7 @@ void MainWindow::onPreviewZoomReset()
|
|||
|
||||
void MainWindow::onUpdateFiltersClicked()
|
||||
{
|
||||
ui->tbUpdateFilters->setEnabled(false);
|
||||
updateFiltersFromSources(0, ui->cbInternetUpdate->isChecked());
|
||||
updateFilters(ui->cbInternetUpdate->isChecked());
|
||||
}
|
||||
|
||||
void MainWindow::saveCurrentParameters()
|
||||
|
@ -1403,6 +1408,13 @@ void MainWindow::onSettingsClicked()
|
|||
}
|
||||
}
|
||||
showZoomWarningIfNeeded();
|
||||
// Sources modification may require an update
|
||||
bool sourcesModified = false;
|
||||
bool sourcesRequireInternetUpdate = false;
|
||||
dialog.sourcesStatus(sourcesModified, sourcesRequireInternetUpdate);
|
||||
if (sourcesModified) {
|
||||
updateFilters(sourcesRequireInternetUpdate && ui->cbInternetUpdate->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::confirmAbortProcessingOnCloseRequest()
|
||||
|
|
|
@ -142,6 +142,7 @@ private:
|
|||
void buildFiltersTree();
|
||||
void retrieveFilterAndParametersFromPluginParameters(QString & hash, QList<QString> & parameters);
|
||||
static QString screenGeometries();
|
||||
void updateFilters(bool internet);
|
||||
enum class ProcessingAction
|
||||
{
|
||||
NoAction,
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <QFileDialog>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QSet>
|
||||
#include <QToolTip>
|
||||
#include <algorithm>
|
||||
#include "GmicStdlib.h"
|
||||
|
@ -71,7 +72,7 @@ SourcesWidget::SourcesWidget(QWidget * parent) : QWidget(parent), ui(new Ui::Sou
|
|||
ui->list->currentItem()->setText(text);
|
||||
}
|
||||
});
|
||||
ui->list->addItems(Settings::filterSources());
|
||||
ui->list->addItems(_sourcesAtOpening = Settings::filterSources());
|
||||
|
||||
#ifdef _IS_WINDOWS_
|
||||
ui->labelVariables->setText(tr("Macros: $HOME %APPDATA% $VERSION"));
|
||||
|
@ -83,7 +84,7 @@ SourcesWidget::SourcesWidget(QWidget * parent) : QWidget(parent), ui(new Ui::Sou
|
|||
ui->cbOfficialFilters->addItem(tr("Enable without updates"), int(OfficialFilters::EnabledWithoutUpdates));
|
||||
ui->cbOfficialFilters->addItem(tr("Enable with updates (recommended)"), int(OfficialFilters::EnabledWithUpdates));
|
||||
|
||||
switch (Settings::officialFilterSource()) {
|
||||
switch (_officialFiltersAtOpening = Settings::officialFilterSource()) {
|
||||
case OfficialFilters::Disabled:
|
||||
ui->cbOfficialFilters->setCurrentIndex(0);
|
||||
break;
|
||||
|
@ -141,6 +142,36 @@ void SourcesWidget::saveSettings()
|
|||
Settings::setOfficialFilterSource((OfficialFilters)ui->cbOfficialFilters->currentData().toInt());
|
||||
}
|
||||
|
||||
bool SourcesWidget::sourcesModified(bool & internetUpdateRequired)
|
||||
{
|
||||
internetUpdateRequired = false;
|
||||
const QStringList currentSourceList = list();
|
||||
const OfficialFilters currentOfficialFilters = OfficialFilters(ui->cbOfficialFilters->currentData().toInt());
|
||||
if ((currentSourceList == _sourcesAtOpening) && (_officialFiltersAtOpening == currentOfficialFilters)) {
|
||||
return false;
|
||||
}
|
||||
QSet<QString> remoteSourcesBefore;
|
||||
for (const QString & source : _sourcesAtOpening) {
|
||||
if (source.startsWith("http://") || source.startsWith("https://")) {
|
||||
remoteSourcesBefore.insert(source);
|
||||
}
|
||||
}
|
||||
QSet<QString> remoteSourcesAfter;
|
||||
for (const QString & source : currentSourceList) {
|
||||
if (source.startsWith("http://") || source.startsWith("https://")) {
|
||||
remoteSourcesAfter.insert(source);
|
||||
}
|
||||
}
|
||||
if (!(remoteSourcesAfter - remoteSourcesBefore).isEmpty()) {
|
||||
internetUpdateRequired = true;
|
||||
}
|
||||
if ((currentOfficialFilters == OfficialFilters::EnabledWithUpdates) //
|
||||
&& (currentOfficialFilters != _officialFiltersAtOpening)) {
|
||||
internetUpdateRequired = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SourcesWidget::onOpenFile()
|
||||
{
|
||||
const QFileDialog::Options options = Settings::nativeFileDialogs() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog;
|
||||
|
@ -180,7 +211,6 @@ void SourcesWidget::setToDefault()
|
|||
void SourcesWidget::enableButtons()
|
||||
{
|
||||
int index = ui->list->currentRow();
|
||||
TSHOW(index);
|
||||
if (index == -1) {
|
||||
ui->tbUp->setEnabled(false);
|
||||
ui->tbDown->setEnabled(false);
|
||||
|
@ -199,8 +229,6 @@ void SourcesWidget::removeCurrentSource()
|
|||
{
|
||||
QListWidgetItem * item = ui->list->currentItem();
|
||||
int row = ui->list->currentRow();
|
||||
SHOW(item);
|
||||
SHOW(row);
|
||||
if (item) {
|
||||
ui->list->removeItemWidget(item);
|
||||
delete item;
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
QStringList list() const;
|
||||
static QStringList defaultList();
|
||||
void saveSettings();
|
||||
bool sourcesModified(bool & internetUpdateRequired);
|
||||
|
||||
private slots:
|
||||
void onOpenFile();
|
||||
|
@ -69,6 +70,8 @@ private slots:
|
|||
private:
|
||||
Ui::SourcesWidget * ui;
|
||||
QString _newItemText;
|
||||
QStringList _sourcesAtOpening;
|
||||
OfficialFilters _officialFiltersAtOpening;
|
||||
};
|
||||
|
||||
} // namespace GmicQt
|
||||
|
|
Loading…
Reference in New Issue