mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #741, allow to discard settings
(not saving, but continue closing)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
8b1bdbdcf8
commit
231bfea566
@@ -182,7 +182,7 @@ namespace BlackCore
|
||||
//! Automatically and always save settings
|
||||
void setSettingsAutoSave(bool autoSave);
|
||||
|
||||
//! All unsave settings
|
||||
//! All unsaved settings
|
||||
QStringList getAllUnsavedSettings() const;
|
||||
|
||||
//! Save all settings
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QStringListModel>
|
||||
#include <QModelIndexList>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
@@ -30,7 +32,11 @@ namespace BlackGui
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
this->initSettingsView();
|
||||
ui->bb_ApplicationCloseDialog->button(QDialogButtonBox::Save)->setDefault(true);
|
||||
|
||||
connect(this, &CApplicationCloseDialog::accepted, this, &CApplicationCloseDialog::ps_onAccepted);
|
||||
connect(this, &CApplicationCloseDialog::rejected, this, &CApplicationCloseDialog::ps_onRejected);
|
||||
connect(ui->bb_ApplicationCloseDialog, &QDialogButtonBox::clicked, this, &CApplicationCloseDialog::ps_buttonClicked);
|
||||
}
|
||||
|
||||
CApplicationCloseDialog::~CApplicationCloseDialog()
|
||||
@@ -38,7 +44,7 @@ namespace BlackGui
|
||||
|
||||
void CApplicationCloseDialog::ps_onAccepted()
|
||||
{
|
||||
QModelIndexList indexes = ui->lv_UnsavedSettings->selectionModel()->selectedIndexes();
|
||||
const QModelIndexList indexes = ui->lv_UnsavedSettings->selectionModel()->selectedIndexes();
|
||||
if (indexes.isEmpty()) { return; }
|
||||
const QList<int> rows = CGuiUtility::indexToUniqueRows(indexes);
|
||||
QStringList saveKeys;
|
||||
@@ -51,6 +57,20 @@ namespace BlackGui
|
||||
if (msg.isFailure()) { CLogMessage::preformatted(msg); }
|
||||
}
|
||||
|
||||
void CApplicationCloseDialog::ps_onRejected()
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
void CApplicationCloseDialog::ps_buttonClicked(QAbstractButton *button)
|
||||
{
|
||||
if (button == ui->bb_ApplicationCloseDialog->button(QDialogButtonBox::Discard))
|
||||
{
|
||||
ui->lv_UnsavedSettings->clearSelection();
|
||||
this->accept(); // fake accept with unselected items
|
||||
}
|
||||
}
|
||||
|
||||
void CApplicationCloseDialog::initSettingsView()
|
||||
{
|
||||
QStringList settings(CSettingsCache::instance()->getAllUnsavedKeys());
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
#include <QAbstractButton>
|
||||
|
||||
namespace Ui { class CApplicationCloseDialog; }
|
||||
namespace BlackGui
|
||||
@@ -38,6 +39,12 @@ namespace BlackGui
|
||||
//! Accepted
|
||||
void ps_onAccepted();
|
||||
|
||||
//! Rejected
|
||||
void ps_onRejected();
|
||||
|
||||
//! Button pressed
|
||||
void ps_buttonClicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CApplicationCloseDialog> ui;
|
||||
QStringList m_settingskeys;
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Abort|QDialogButtonBox::Discard|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user