Scene antialiasing.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-08 13:59:39 +03:00
parent fc3c8acc46
commit f28bbc6acd
4 changed files with 79 additions and 18 deletions

View File

@ -51,7 +51,21 @@ void ConfigurationPage::Apply()
QApplication::applicationName());
settings.setValue("configuration/autosave/state", autoSaveCheck->isChecked());
settings.setValue("configuration/autosave/time", autoTime->value());
QTimer *autoSaveTimer = qApp->getAutoSaveTimer();
SCASSERT(autoSaveTimer);
if (autoSaveCheck->isChecked())
{
autoSaveTimer->start(autoTime->value()*60000);
}
else
{
autoSaveTimer->stop();
}
settings.setValue("configuration/osSeparator", osOptionCheck->isChecked());
if (langChanged)
{
QString locale = qvariant_cast<QString>(langCombo->itemData(langCombo->currentIndex()));
@ -194,7 +208,12 @@ void PatternPage::Apply()
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
settings.setValue("pattern/user", userName->text());
//settings.setValue("pattern/graphicalOutput", graphOutputCheck->isChecked());
// Scene antialiasing
settings.setValue("pattern/graphicalOutput", graphOutputCheck->isChecked());
qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, graphOutputCheck->isChecked());
qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputCheck->isChecked());
settings.setValue("pattern/undone", undoneCount->value());
}
@ -228,15 +247,14 @@ QGroupBox *PatternPage::UserGroup()
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PatternPage::GraphOutputGroup()
{
// QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
// QApplication::applicationName());
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
QGroupBox *graphOutputGroup = new QGroupBox(tr("Graphical output"));
graphOutputCheck = new QCheckBox(tr("Use antialiasing"));
//bool graphOutputValue = settings.value("pattern/graphicalOutput", 1).toBool();
//graphOutputCheck->setChecked(graphOutputValue);
graphOutputCheck->setEnabled(false);
bool graphOutputValue = settings.value("pattern/graphicalOutput", 1).toBool();
graphOutputCheck->setChecked(graphOutputValue);
QHBoxLayout *graphLayout = new QHBoxLayout;
graphLayout->addWidget(graphOutputCheck);

View File

@ -83,6 +83,7 @@ MainWindow::MainWindow(QWidget *parent)
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
policy.setHorizontalStretch(12);
view->setSizePolicy(policy);
qApp->setSceneView(view);
helpLabel = new QLabel(QObject::tr("Create new pattern piece to start working."));
ui->statusBar->addWidget(helpLabel);
@ -1724,6 +1725,10 @@ void MainWindow::ReadSettings()
QSize size = settings.value("size", QSize(1000, 800)).toSize();
resize(size);
move(pos);
bool graphOutputValue = settings.value("pattern/graphicalOutput", 1).toBool();
view->setRenderHint(QPainter::Antialiasing, graphOutputValue);
view->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputValue);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1853,6 +1858,11 @@ void MainWindow::InitAutoSave()
delete autoSaveTimer;
autoSaveTimer = nullptr;
autoSaveTimer = new QTimer(this);
autoSaveTimer->setTimerType(Qt::VeryCoarseTimer);
connect(autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern);
autoSaveTimer->stop();
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
bool autoSave = settings.value("configuration/autosave/state", 1).toBool();
@ -1864,12 +1874,10 @@ void MainWindow::InitAutoSave()
{
autoTime = 5;
}
autoSaveTimer = new QTimer(this);
autoSaveTimer->setTimerType(Qt::VeryCoarseTimer);
connect(autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern);
autoSaveTimer->start(autoTime*60000);
}
qApp->setAutoSaveTimer(autoSaveTimer);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -51,7 +51,7 @@ VApplication::VApplication(int &argc, char **argv)
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap<QString, VTranslation>()),
guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()),
variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()),
postfixOperators(QMap<QString, VTranslation>()), undoStack(nullptr)
postfixOperators(QMap<QString, VTranslation>()), undoStack(nullptr), sceneView(nullptr), autoSaveTimer(nullptr)
{
undoStack = new QUndoStack(this);
@ -1937,10 +1937,3 @@ QString VApplication::FormulaToUser(const QString &formula)
return newFormula;
}
//---------------------------------------------------------------------------------------------------------------------
QUndoStack *VApplication::getUndoStack() const
{
return undoStack;
}

View File

@ -32,6 +32,7 @@
#include <QApplication>
#include <QUndoStack>
#include "../options.h"
#include "vmaingraphicsview.h"
#include "vtranslation.h"
class VApplication;
@ -83,6 +84,10 @@ public:
QString FormulaFromUser(const QString &formula);
QString FormulaToUser(const QString &formula);
QUndoStack *getUndoStack() const;
VMainGraphicsView *getSceneView() const;
void setSceneView(VMainGraphicsView *value);
QTimer *getAutoSaveTimer() const;
void setAutoSaveTimer(QTimer *value);
private:
Q_DISABLE_COPY(VApplication)
Valentina::Units _patternUnit;
@ -96,6 +101,8 @@ private:
QMap<QString, VTranslation> functions;
QMap<QString, VTranslation> postfixOperators;
QUndoStack *undoStack;
VMainGraphicsView *sceneView;
QTimer *autoSaveTimer;
void InitLineWidth();
void InitMeasurements();
void InitVariables();
@ -113,29 +120,64 @@ private:
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
};
//---------------------------------------------------------------------------------------------------------------------
inline Valentina::Units VApplication::patternUnit() const
{
return _patternUnit;
}
//---------------------------------------------------------------------------------------------------------------------
inline Pattern::Measurements VApplication::patternType() const
{
return _patternType;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VApplication::setPatternType(const Pattern::Measurements &patternType)
{
_patternType = patternType;
}
//---------------------------------------------------------------------------------------------------------------------
inline qreal VApplication::widthMainLine() const
{
return _widthMainLine;
}
//---------------------------------------------------------------------------------------------------------------------
inline qreal VApplication::widthHairLine() const
{
return _widthHairLine;
}
//---------------------------------------------------------------------------------------------------------------------
inline QUndoStack *VApplication::getUndoStack() const
{
return undoStack;
}
//---------------------------------------------------------------------------------------------------------------------
inline VMainGraphicsView *VApplication::getSceneView() const
{
return sceneView;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VApplication::setSceneView(VMainGraphicsView *value)
{
sceneView = value;
}
//---------------------------------------------------------------------------------------------------------------------
inline QTimer *VApplication::getAutoSaveTimer() const
{
return autoSaveTimer;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VApplication::setAutoSaveTimer(QTimer *value)
{
autoSaveTimer = value;
}
#endif // VAPPLICATION_H