Inform a user about options those require restart to take effect.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-03-12 11:56:47 +02:00
parent 368c3a871a
commit a68da11776
9 changed files with 65 additions and 17 deletions

View file

@ -33,7 +33,6 @@
#include <QDir> #include <QDir>
#include <QDirIterator> #include <QDirIterator>
#include <QMessageBox>
#include <QTimer> #include <QTimer>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -121,8 +120,9 @@ PreferencesConfigurationPage::~PreferencesConfigurationPage()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::Apply() QStringList PreferencesConfigurationPage::Apply()
{ {
QStringList preferences;
VSettings *settings = qApp->ValentinaSettings(); VSettings *settings = qApp->ValentinaSettings();
settings->SetAutosaveState(ui->autoSaveCheck->isChecked()); settings->SetAutosaveState(ui->autoSaveCheck->isChecked());
settings->SetAutosaveTime(ui->autoTime->value()); settings->SetAutosaveTime(ui->autoTime->value());
@ -153,9 +153,7 @@ void PreferencesConfigurationPage::Apply()
const QString unit = qvariant_cast<QString>(ui->unitCombo->currentData()); const QString unit = qvariant_cast<QString>(ui->unitCombo->currentData());
settings->SetUnit(unit); settings->SetUnit(unit);
m_unitChanged = false; m_unitChanged = false;
const QString text = tr("The Default unit has been updated and will be used as the default for the next " preferences.append(tr("default unit"));
"pattern you create.");
QMessageBox::information(this, QCoreApplication::applicationName(), text);
} }
if (m_labelLangChanged) if (m_labelLangChanged)
{ {
@ -163,6 +161,7 @@ void PreferencesConfigurationPage::Apply()
settings->SetLabelLanguage(locale); settings->SetLabelLanguage(locale);
m_labelLangChanged = false; m_labelLangChanged = false;
} }
return preferences;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -44,7 +44,7 @@ public:
explicit PreferencesConfigurationPage(QWidget *parent = nullptr); explicit PreferencesConfigurationPage(QWidget *parent = nullptr);
virtual ~PreferencesConfigurationPage(); virtual ~PreferencesConfigurationPage();
void Apply(); QStringList Apply();
protected: protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private: private:

View file

@ -55,7 +55,7 @@ PreferencesPathPage::~PreferencesPathPage()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesPathPage::Apply() QStringList PreferencesPathPage::Apply()
{ {
VSettings *settings = qApp->ValentinaSettings(); VSettings *settings = qApp->ValentinaSettings();
settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text()); settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text());
@ -64,6 +64,8 @@ void PreferencesPathPage::Apply()
settings->SetPathLayout(ui->pathTable->item(3, 1)->text()); settings->SetPathLayout(ui->pathTable->item(3, 1)->text());
settings->SetPathTemplate(ui->pathTable->item(4, 1)->text()); settings->SetPathTemplate(ui->pathTable->item(4, 1)->text());
settings->SetPathLabelTemplate(ui->pathTable->item(5, 1)->text()); settings->SetPathLabelTemplate(ui->pathTable->item(5, 1)->text());
return QStringList(); // No changes those require restart.
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -44,7 +44,7 @@ public:
explicit PreferencesPathPage(QWidget *parent = nullptr); explicit PreferencesPathPage(QWidget *parent = nullptr);
virtual ~PreferencesPathPage(); virtual ~PreferencesPathPage();
void Apply(); QStringList Apply();
private slots: private slots:
void DefaultPath(); void DefaultPath();

View file

@ -113,13 +113,29 @@ PreferencesPatternPage::~PreferencesPatternPage()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::Apply() QStringList PreferencesPatternPage::Apply()
{ {
QStringList preferences;
VSettings *settings = qApp->ValentinaSettings(); VSettings *settings = qApp->ValentinaSettings();
// Scene antialiasing // Scene antialiasing
settings->SetGraphicalOutput(ui->graphOutputCheck->isChecked()); if (settings->GetGraphicalOutput() != ui->graphOutputCheck->isChecked())
settings->SetOpenGLRender(ui->checkBoxOpenGLRender->isChecked()); {
if (qApp->getSceneView()->IsOpenGLRender())
{
preferences.append(tr("antialiasing"));
}
settings->SetGraphicalOutput(ui->graphOutputCheck->isChecked());
}
if (settings->IsOpenGLRender() != ui->checkBoxOpenGLRender->isChecked())
{
preferences.append(tr("scene render"));
settings->SetOpenGLRender(ui->checkBoxOpenGLRender->isChecked());
}
settings->SetCurveApproximationScale(ui->doubleSpinBoxCurveApproximation->value()); settings->SetCurveApproximationScale(ui->doubleSpinBoxCurveApproximation->value());
settings->SetLineWidth(UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, Unit::Mm)); settings->SetLineWidth(UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, Unit::Mm));
qApp->getSceneView()->SetAntialiasing(ui->graphOutputCheck->isChecked()); qApp->getSceneView()->SetAntialiasing(ui->graphOutputCheck->isChecked());
@ -149,6 +165,8 @@ void PreferencesPatternPage::Apply()
settings->SetKnownMaterials(m_knownMaterials); settings->SetKnownMaterials(m_knownMaterials);
settings->SetRememberPatternMaterials(ui->checkBoxRemeberPatternMaterials->isChecked()); settings->SetRememberPatternMaterials(ui->checkBoxRemeberPatternMaterials->isChecked());
return preferences;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -47,7 +47,7 @@ public:
explicit PreferencesPatternPage(QWidget *parent = nullptr); explicit PreferencesPatternPage(QWidget *parent = nullptr);
virtual ~PreferencesPatternPage(); virtual ~PreferencesPatternPage();
void Apply(); QStringList Apply();
void InitDefaultSeamAllowance(); void InitDefaultSeamAllowance();
private slots: private slots:

View file

@ -33,6 +33,7 @@
#include "configpages/preferencespatternpage.h" #include "configpages/preferencespatternpage.h"
#include "configpages/preferencespathpage.h" #include "configpages/preferencespathpage.h"
#include <QMessageBox>
#include <QPushButton> #include <QPushButton>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -122,9 +123,19 @@ void DialogPreferences::PageChanged(QListWidgetItem *current, QListWidgetItem *p
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPreferences::Apply() void DialogPreferences::Apply()
{ {
m_configurePage->Apply(); QStringList preferences;
m_patternPage->Apply();
m_pathPage->Apply(); preferences += m_configurePage->Apply();
preferences += m_patternPage->Apply();
preferences += m_pathPage->Apply();
if (not preferences.isEmpty())
{
const QString text = tr("Followed %n option(s) require restart to take effect: %1.", "",
preferences.size()).arg(preferences.join(", "));
QMessageBox::information(this, QCoreApplication::applicationName(), text);
}
m_patternPage->InitDefaultSeamAllowance(); m_patternPage->InitDefaultSeamAllowance();

View file

@ -376,7 +376,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
setViewport(viewport); setViewport(viewport);
#else #else
setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer|QGL::SampleBuffers))); setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer|QGL::SampleBuffers)));
#endif #endif
} }
zoom = new GraphicsViewZoom(this); zoom = new GraphicsViewZoom(this);
@ -633,8 +633,24 @@ void VMainGraphicsView::SetAntialiasing(bool value)
{ {
setRenderHint(QPainter::Antialiasing, value); setRenderHint(QPainter::Antialiasing, value);
setRenderHint(QPainter::SmoothPixmapTransform, value); setRenderHint(QPainter::SmoothPixmapTransform, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VMainGraphicsView::IsOpenGLRender() const
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QOpenGLWidget *viewport = qobject_cast<QOpenGLWidget *>(this->viewport());
#else
QGLWidget *viewport = qobject_cast<QGLWidget *>(this->viewport());
#endif
if (viewport)
{
return true;
}
else
{
return false;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -132,6 +132,8 @@ public:
void SetAntialiasing(bool value); void SetAntialiasing(bool value);
bool IsOpenGLRender() const;
signals: signals:
/** /**
* @brief MouseRelease help catch mouse release event. * @brief MouseRelease help catch mouse release event.