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

View File

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

View File

@ -55,7 +55,7 @@ PreferencesPathPage::~PreferencesPathPage()
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPathPage::Apply()
QStringList PreferencesPathPage::Apply()
{
VSettings *settings = qApp->ValentinaSettings();
settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text());
@ -64,6 +64,8 @@ void PreferencesPathPage::Apply()
settings->SetPathLayout(ui->pathTable->item(3, 1)->text());
settings->SetPathTemplate(ui->pathTable->item(4, 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);
virtual ~PreferencesPathPage();
void Apply();
QStringList Apply();
private slots:
void DefaultPath();

View File

@ -113,13 +113,29 @@ PreferencesPatternPage::~PreferencesPatternPage()
}
//---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::Apply()
QStringList PreferencesPatternPage::Apply()
{
QStringList preferences;
VSettings *settings = qApp->ValentinaSettings();
// Scene antialiasing
settings->SetGraphicalOutput(ui->graphOutputCheck->isChecked());
settings->SetOpenGLRender(ui->checkBoxOpenGLRender->isChecked());
if (settings->GetGraphicalOutput() != ui->graphOutputCheck->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->SetLineWidth(UnitConvertor(ui->doubleSpinBoxLineWidth->value(), m_oldLineUnit, Unit::Mm));
qApp->getSceneView()->SetAntialiasing(ui->graphOutputCheck->isChecked());
@ -149,6 +165,8 @@ void PreferencesPatternPage::Apply()
settings->SetKnownMaterials(m_knownMaterials);
settings->SetRememberPatternMaterials(ui->checkBoxRemeberPatternMaterials->isChecked());
return preferences;
}
//---------------------------------------------------------------------------------------------------------------------

View File

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

View File

@ -33,6 +33,7 @@
#include "configpages/preferencespatternpage.h"
#include "configpages/preferencespathpage.h"
#include <QMessageBox>
#include <QPushButton>
//---------------------------------------------------------------------------------------------------------------------
@ -122,9 +123,19 @@ void DialogPreferences::PageChanged(QListWidgetItem *current, QListWidgetItem *p
//---------------------------------------------------------------------------------------------------------------------
void DialogPreferences::Apply()
{
m_configurePage->Apply();
m_patternPage->Apply();
m_pathPage->Apply();
QStringList preferences;
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();

View File

@ -376,7 +376,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
setViewport(viewport);
#else
setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer|QGL::SampleBuffers)));
#endif
#endif
}
zoom = new GraphicsViewZoom(this);
@ -633,8 +633,24 @@ void VMainGraphicsView::SetAntialiasing(bool value)
{
setRenderHint(QPainter::Antialiasing, 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);
bool IsOpenGLRender() const;
signals:
/**
* @brief MouseRelease help catch mouse release event.