Merge remote-tracking branch 'upstream/feature/manual-layout' into feature/manual-layout

This commit is contained in:
Ronan Le Tiec 2020-05-23 13:11:06 +02:00
commit e2cfe7d0cc
53 changed files with 888 additions and 720 deletions

View File

@ -47,6 +47,7 @@
- Setting scale factor for export and print. - Setting scale factor for export and print.
- New layout generator option: Prefer one sheet solution. - New layout generator option: Prefer one sheet solution.
- [smart-pattern/valentina#15] Organization of groups - groups categories - [smart-pattern/valentina#15] Organization of groups - groups categories
- Improve the property browser. Show full arc name.
# Version 0.6.2 (unreleased) # Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path. - [#903] Bug in tool Cut Spline path.

View File

@ -14,10 +14,10 @@ SOURCES += \
$$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vpuzzlegraphicspiece.cpp \
$$PWD/vpuzzlelayout.cpp \ $$PWD/vpuzzlelayout.cpp \
$$PWD/vpuzzlelayer.cpp \ $$PWD/vpuzzlelayer.cpp \
$$PWD/vpuzzlemaingraphicsscene.cpp \
$$PWD/vpuzzlemaingraphicsview.cpp \ $$PWD/vpuzzlemaingraphicsview.cpp \
$$PWD/vpuzzlemimedatapiece.cpp \ $$PWD/vpuzzlemimedatapiece.cpp \
$$PWD/vpuzzlepiece.cpp \ $$PWD/vpuzzlepiece.cpp \
$$PWD/vpuzzlesettings.cpp \
$$PWD/xml/layoutliterals.cpp \ $$PWD/xml/layoutliterals.cpp \
$$PWD/xml/vpuzzlelayoutfilewriter.cpp \ $$PWD/xml/vpuzzlelayoutfilewriter.cpp \
$$PWD/xml/vpuzzlelayoutfilereader.cpp \ $$PWD/xml/vpuzzlelayoutfilereader.cpp \
@ -39,10 +39,10 @@ HEADERS += \
$$PWD/vpuzzlegraphicspiece.h \ $$PWD/vpuzzlegraphicspiece.h \
$$PWD/vpuzzlelayout.h \ $$PWD/vpuzzlelayout.h \
$$PWD/vpuzzlelayer.h \ $$PWD/vpuzzlelayer.h \
$$PWD/vpuzzlemaingraphicsscene.h \
$$PWD/vpuzzlemaingraphicsview.h \ $$PWD/vpuzzlemaingraphicsview.h \
$$PWD/vpuzzlemimedatapiece.h \ $$PWD/vpuzzlemimedatapiece.h \
$$PWD/vpuzzlepiece.h \ $$PWD/vpuzzlepiece.h \
$$PWD/vpuzzlesettings.h \
$$PWD/xml/layoutliterals.h \ $$PWD/xml/layoutliterals.h \
$$PWD/xml/vpuzzlelayoutfilewriter.h \ $$PWD/xml/vpuzzlelayoutfilewriter.h \
$$PWD/xml/vpuzzlelayoutfilereader.h \ $$PWD/xml/vpuzzlelayoutfilereader.h \
@ -51,4 +51,5 @@ HEADERS += \
FORMS += \ FORMS += \
$$PWD/puzzlemainwindow.ui \ $$PWD/puzzlemainwindow.ui \
$$PWD/dialogs/dialogaboutpuzzle.ui $$PWD/dialogs/dialogaboutpuzzle.ui \
$$PWD/vpiececarrousel.ui

View File

@ -197,14 +197,14 @@ noRunPath{ # For enable run qmake with CONFIG+=noRunPath
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/vtools.lib #win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/vtools.lib
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/libvtools.a #else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vtools/$${DESTDIR}/libvtools.a
##VWidgets static library #VWidgets static library
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets
#INCLUDEPATH += $$PWD/../../libs/vwidgets INCLUDEPATH += $$PWD/../../libs/vwidgets
#DEPENDPATH += $$PWD/../../libs/vwidgets DEPENDPATH += $$PWD/../../libs/vwidgets
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a
## VFormat static library (depend on VPatternDB, IFC) ## VFormat static library (depend on VPatternDB, IFC)
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat #unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat
@ -277,13 +277,13 @@ else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser
INCLUDEPATH += $${PWD}/../../libs/qmuparser INCLUDEPATH += $${PWD}/../../libs/qmuparser
DEPENDPATH += $${PWD}/../../libs/qmuparser DEPENDPATH += $${PWD}/../../libs/qmuparser
## VPropertyExplorer library # VPropertyExplorer library
#win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
#else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
#else:unix: LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer else:unix: LIBS += -L$${OUT_PWD}/../../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
#INCLUDEPATH += $${PWD}/../../libs/vpropertyexplorer INCLUDEPATH += $${PWD}/../../libs/vpropertyexplorer
#DEPENDPATH += $${PWD}/../../libs/vpropertyexplorer DEPENDPATH += $${PWD}/../../libs/vpropertyexplorer
contains(DEFINES, APPIMAGE) { contains(DEFINES, APPIMAGE) {
unix:!macx: LIBS += -licudata -licui18n -licuuc unix:!macx: LIBS += -licudata -licui18n -licuuc

View File

@ -29,7 +29,7 @@
#define PUZZLEAPPLICATION_H #define PUZZLEAPPLICATION_H
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/vpuzzlesettings.h" #include "vpuzzlesettings.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "vpuzzlecommandline.h" #include "vpuzzlecommandline.h"

View File

@ -36,6 +36,7 @@
#include "puzzleapplication.h" #include "puzzleapplication.h"
#include "../vlayout/vrawlayout.h" #include "../vlayout/vrawlayout.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
#include "../vmisc/projectversion.h"
#include "../ifc/xml/vlayoutconverter.h" #include "../ifc/xml/vlayoutconverter.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
@ -75,6 +76,8 @@ PuzzleMainWindow::PuzzleMainWindow(const VPuzzleCommandLinePtr &cmd, QWidget *pa
SetPropertiesData(); SetPropertiesData();
ReadSettings();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -370,8 +373,10 @@ void PuzzleMainWindow::SetPropertyTabCurrentPieceData()
ui->checkBoxCurrentPieceMirrorPiece->setChecked(selectedPiece->GetPieceMirrored()); ui->checkBoxCurrentPieceMirrorPiece->setChecked(selectedPiece->GetPieceMirrored());
QPointF pos = selectedPiece->GetPosition(); QPointF pos = selectedPiece->GetPosition();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX, UnitConvertor(pos.x(), Unit::Px, m_layout->GetUnit())); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX,
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY, UnitConvertor(pos.y(), Unit::Px, m_layout->GetUnit())); UnitConvertor(pos.x(), Unit::Px, m_layout->GetUnit()));
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY,
UnitConvertor(pos.y(), Unit::Px, m_layout->GetUnit()));
qreal angle = selectedPiece->GetRotation(); qreal angle = selectedPiece->GetRotation();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceAngle, angle);
@ -469,7 +474,98 @@ void PuzzleMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value)
checkbox->blockSignals(false); checkbox->blockSignals(false);
} }
//---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::ReadSettings()
{
qCDebug(pWindow, "Reading settings.");
const VPuzzleSettings *settings = qApp->PuzzleSettings();
if (settings->status() == QSettings::NoError)
{
restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION);
ui->dockWidgetProperties->setVisible(settings->IsDockWidgetPropertiesActive());
ui->dockWidgetPropertiesContents->setVisible(settings->IsDockWidgetPropertiesContentsActive());
// Scene antialiasing
m_graphicsView->SetAntialiasing(settings->GetGraphicalOutput());
// Stack limit
// qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount());
}
else
{
qWarning() << tr("Cannot read settings from a malformed .INI file.");
}
}
//---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::WriteSettings()
{
VPuzzleSettings *settings = qApp->PuzzleSettings();
settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION));
settings->SetDockWidgetPropertiesActive(ui->dockWidgetProperties->isEnabled());
settings->SetDockWidgetPropertiesContentsActive(ui->dockWidgetPropertiesContents->isEnabled());
settings->sync();
if (settings->status() == QSettings::AccessError)
{
qWarning() << tr("Cannot save settings. Access denied.");
}
}
//---------------------------------------------------------------------------------------------------------------------
bool PuzzleMainWindow::MaybeSave()
{
// TODO: Implement maybe save check
// if (this->isWindowModified())
// {
// if (curFile.isEmpty() && ui->tableWidget->rowCount() == 0)
// {
// return true;// Don't ask if file was created without modifications.
// }
// QScopedPointer<QMessageBox> messageBox(new QMessageBox(tr("Unsaved changes"),
// tr("Measurements have been modified.\n"
// "Do you want to save your changes?"),
// QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
// QMessageBox::Cancel, this, Qt::Sheet));
// messageBox->setDefaultButton(QMessageBox::Yes);
// messageBox->setEscapeButton(QMessageBox::Cancel);
// messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() || mIsReadOnly ? tr("Save…") : tr("Save"));
// messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
// messageBox->setWindowModality(Qt::ApplicationModal);
// const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
// switch (ret)
// {
// case QMessageBox::Yes:
// if (mIsReadOnly)
// {
// return FileSaveAs();
// }
// else
// {
// return FileSave();
// }
// case QMessageBox::No:
// return true;
// case QMessageBox::Cancel:
// return false;
// default:
// break;
// }
// }
return true;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionNew_triggered() void PuzzleMainWindow::on_actionNew_triggered()
@ -486,6 +582,30 @@ void PuzzleMainWindow::on_actionNew_triggered()
} }
//---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::closeEvent(QCloseEvent *event)
{
#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1)
// Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344
static int numCalled = 0;
if (numCalled++ >= 1)
{
return;
}
#endif
if (MaybeSave())
{
WriteSettings();
event->accept();
deleteLater();
}
else
{
event->ignore();
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionOpen_triggered() void PuzzleMainWindow::on_actionOpen_triggered()
{ {
@ -796,8 +916,6 @@ void PuzzleMainWindow::on_checkBoxLayoutStickyEdges_toggled(bool checked)
// TODO update the QGraphicView // TODO update the QGraphicView
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_pushButtonLayoutExport_clicked() void PuzzleMainWindow::on_pushButtonLayoutExport_clicked()
{ {
@ -859,14 +977,10 @@ void PuzzleMainWindow::on_PieceCarrouselLocationChanged(Qt::DockWidgetArea area)
if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea) if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea)
{ {
m_pieceCarrousel->SetOrientation(Qt::Horizontal); m_pieceCarrousel->SetOrientation(Qt::Horizontal);
ui->dockWidgetPieceCarrousel->setMaximumHeight(208);
ui->dockWidgetPieceCarrousel->setMaximumWidth(10000);
} }
else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea) else if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea)
{ {
m_pieceCarrousel->SetOrientation(Qt::Vertical); m_pieceCarrousel->SetOrientation(Qt::Vertical);
ui->dockWidgetPieceCarrousel->setMaximumHeight(10000);
ui->dockWidgetPieceCarrousel->setMaximumWidth(160);
} }
} }
@ -883,14 +997,15 @@ void PuzzleMainWindow::on_PieceSelectionChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_PiecePositionChanged() void PuzzleMainWindow::on_PiecePositionChanged()
{ {
if(m_selectedPieces.count() == 1) if(m_selectedPieces.count() == 1)
{ {
VPuzzlePiece *piece = m_selectedPieces.first(); VPuzzlePiece *piece = m_selectedPieces.first();
QPointF pos = piece->GetPosition(); QPointF pos = piece->GetPosition();
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX, UnitConvertor(pos.x(), Unit::Px, m_layout->GetUnit())); SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionX,
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY, UnitConvertor(pos.y(), Unit::Px, m_layout->GetUnit())); UnitConvertor(pos.x(), Unit::Px, m_layout->GetUnit()));
SetDoubleSpinBoxValue(ui->doubleSpinBoxCurrentPieceBoxPositionY,
UnitConvertor(pos.y(), Unit::Px, m_layout->GetUnit()));
} }
} }

View File

@ -84,6 +84,8 @@ public slots:
protected: protected:
enum { MaxRecentFiles = 5 }; enum { MaxRecentFiles = 5 };
virtual void closeEvent(QCloseEvent *event) override;
private: private:
Q_DISABLE_COPY(PuzzleMainWindow) Q_DISABLE_COPY(PuzzleMainWindow)
Ui::PuzzleMainWindow *ui; Ui::PuzzleMainWindow *ui;
@ -188,6 +190,11 @@ private:
*/ */
void SetCheckBoxValue(QCheckBox *checkbox, bool value); void SetCheckBoxValue(QCheckBox *checkbox, bool value);
void ReadSettings();
void WriteSettings();
bool MaybeSave();
private slots: private slots:
/** /**
* @brief on_actionOpen_triggered When the menu action File > Open is * @brief on_actionOpen_triggered When the menu action File > Open is

View File

@ -26,98 +26,57 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpiececarrousel.h" #include "vpiececarrousel.h"
#include "ui_vpiececarrousel.h"
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QMessageBox> #include <QMessageBox>
#include <QScrollBar> #include <QScrollBar>
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#include "vpuzzlelayer.h"
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QMenu>
#include <QPainter>
Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) : VPieceCarrousel::VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent) :
QWidget(parent), QWidget(parent),
m_layout(layout), ui(new Ui::VPieceCarrousel),
m_comboBoxLayer(new QComboBox(this)), m_layout(layout)
m_scrollArea(new QScrollArea(this)),
m_layersContainer(new QWidget(this)),
m_carrouselLayers(QList<VPieceCarrouselLayer *>())
{ {
Init(); ui->setupUi(this);
}
//---------------------------------------------------------------------------------------------------------------------
VPieceCarrousel::~VPieceCarrousel()
{
delete m_comboBoxLayer;
delete m_layersContainer;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::Init()
{
// ------ first we initialize the structure of the carrousel
// init the combo box // init the combo box
connect(m_comboBoxLayer, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxLayer, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&VPieceCarrousel::on_ActiveLayerChanged); &VPieceCarrousel::on_ActiveLayerChanged);
// init the layers container and corresponding scroll area ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
QWidget *layersContainerWrapper = new QWidget();
QVBoxLayout *layersContainerWrapperLayout = new QVBoxLayout();
layersContainerWrapperLayout->setMargin(0);
layersContainerWrapper->setLayout(layersContainerWrapperLayout);
QVBoxLayout *layersContainerLayout = new QVBoxLayout();
layersContainerLayout->setMargin(0);
m_layersContainer->setLayout(layersContainerLayout);
m_layersContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QSpacerItem *spacer = new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
layersContainerWrapperLayout->addWidget(m_layersContainer);
layersContainerWrapperLayout->addSpacerItem(spacer);
m_scrollArea->setWidgetResizable( true );
m_scrollArea->setWidget(layersContainerWrapper);
// init the layout of the piece carrousel
QVBoxLayout *mainLayout = new QVBoxLayout();
setLayout(mainLayout);
mainLayout->addWidget(m_comboBoxLayer);
mainLayout->addWidget(m_scrollArea);
// ------ then we fill the carrousel with the layout content // ------ then we fill the carrousel with the layout content
Refresh(); Refresh();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::Refresh() void VPieceCarrousel::Refresh()
{ {
// NOTE: alternative to clearing the carrousel and adding things again, we could make comparision // NOTE: alternative to clearing the carrousel and adding things again, we could make comparision
// --- clears the content of the carrousel // --- clears the content of the carrousel
Clear(); Clear();
// --- add the content saved in the layout to the carrousel. // --- add the content saved in the layout to the carrousel.
QList<VPuzzleLayer*> layers = m_layout->GetLayers(); // Do not rely on m_layout because we do not control it.
layers.prepend(m_layout->GetUnplacedPiecesLayer()); m_layers = m_layout->GetLayers();
m_layers.prepend(m_layout->GetUnplacedPiecesLayer());
for (auto layer : layers) for (auto layer : m_layers)
{ {
// add layer name to combo // add layer name to combo
m_comboBoxLayer->addItem(layer->GetName()); ui->comboBoxLayer->blockSignals(true);
ui->comboBoxLayer->addItem(layer->GetName());
// add new carrousel layer ui->comboBoxLayer->blockSignals(false);
VPieceCarrouselLayer *carrouselLayer = new VPieceCarrouselLayer(layer, this);
m_carrouselLayers.append(carrouselLayer);
m_layersContainer->layout()->addWidget(carrouselLayer);
} }
on_ActiveLayerChanged(0); on_ActiveLayerChanged(0);
@ -129,31 +88,9 @@ void VPieceCarrousel::Refresh()
void VPieceCarrousel::Clear() void VPieceCarrousel::Clear()
{ {
// remove the combobox entries // remove the combobox entries
int layerCount = m_comboBoxLayer->count(); ui->comboBoxLayer->clear();
for(int i=0;i<layerCount;i++)
{
m_comboBoxLayer->removeItem(0);
}
// remove the carrousel layers from the qlayout ui->listWidget->clear();
while(!m_layersContainer->layout()->isEmpty())
{
QLayoutItem* item = m_layersContainer->layout()->takeAt(0);
if(item != nullptr)
{
delete item;
}
}
// Removes and deletes the carrousel layers from the list
while (!m_carrouselLayers.isEmpty())
{
VPieceCarrouselLayer *carrouselLayer = m_carrouselLayers.takeLast();
if(carrouselLayer != nullptr)
{
delete carrouselLayer;
}
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -161,10 +98,21 @@ void VPieceCarrousel::on_ActiveLayerChanged(int index)
{ {
qCDebug(pCarrousel, "index changed %i", index); qCDebug(pCarrousel, "index changed %i", index);
int j=0; ui->listWidget->clear();
for (VPieceCarrouselLayer *carrouselLayer: m_carrouselLayers) {
carrouselLayer->setVisible(j == index); if (index >= 0 && index < m_layers.size())
j++; {
VPuzzleLayer *layer = m_layers.at(index);
if (layer)
{
QList<VPuzzlePiece*> pieces = layer->GetPieces();
for (auto piece : pieces)
{
new QListWidgetItem(piece->PieceIcon(QSize(120, 120)) , piece->GetName(), ui->listWidget);
}
}
} }
} }
@ -178,47 +126,26 @@ void VPieceCarrousel::SetOrientation(Qt::Orientation orientation)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPieceCarrousel::RefreshOrientation() void VPieceCarrousel::RefreshOrientation()
{ {
QBoxLayout::Direction direction = (m_orientation == Qt::Horizontal)?
QBoxLayout::LeftToRight
:
QBoxLayout::TopToBottom;
// Update the various qlayouts
QBoxLayout* mainScrollAreaLayout = qobject_cast<QBoxLayout*>(m_layersContainer->layout());
mainScrollAreaLayout->setDirection(direction);
QBoxLayout* layerContainerWrapper = qobject_cast<QBoxLayout*>(m_scrollArea->widget()->layout());
layerContainerWrapper->setDirection(direction);
for (VPieceCarrouselLayer *widget: m_carrouselLayers) {
QBoxLayout* layerLayout = qobject_cast<QBoxLayout*>(widget->layout());
layerLayout->setDirection(direction);
}
// then update the scrollarea min height / width and scrollbar behaviour // then update the scrollarea min height / width and scrollbar behaviour
if(m_orientation == Qt::Horizontal) if(m_orientation == Qt::Horizontal)
{ {
m_comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); ui->comboBoxLayer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// scroll bar policy of scroll area // scroll bar policy of scroll area
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); ui->listWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// FIXME: find a nicer way than putting directly the 120 height of the piece ui->listWidget->setFlow(QListView::TopToBottom);
m_scrollArea->setMinimumHeight(128 + m_scrollArea->horizontalScrollBar()->sizeHint().height()+2);
m_scrollArea->setMinimumWidth(0);
} }
else // Qt::Vertical else // Qt::Vertical
{ {
m_comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); ui->comboBoxLayer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
// scroll bar policy of scroll area // scroll bar policy of scroll area
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); ui->listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->listWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_scrollArea->setMinimumHeight(0); ui->listWidget->setFlow(QListView::LeftToRight);
m_scrollArea->setMinimumWidth(124 + m_scrollArea->verticalScrollBar()->sizeHint().width()+2);
// FIXME: find a nicer way than putting directly the 120 width of the piece
} }
} }

View File

@ -34,14 +34,18 @@
#include <QScrollArea> #include <QScrollArea>
#include "vpuzzlelayout.h" #include "vpuzzlelayout.h"
#include "vpuzzlepiece.h" #include "vpuzzlepiece.h"
#include "vpiececarrousellayer.h"
namespace Ui
{
class VPieceCarrousel;
}
class VPieceCarrousel : public QWidget class VPieceCarrousel : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr); explicit VPieceCarrousel(VPuzzleLayout *layout, QWidget *parent = nullptr);
virtual ~VPieceCarrousel(); virtual ~VPieceCarrousel() = default;
/** /**
* @brief SetOrientation Sets the orientation to the given value and refreshes * @brief SetOrientation Sets the orientation to the given value and refreshes
@ -56,11 +60,6 @@ public:
*/ */
void RefreshOrientation(); void RefreshOrientation();
/**
* @brief Inits the carroussel
*/
void Init();
/** /**
* @brief Refresh Refreshes the content of the carrousel * @brief Refresh Refreshes the content of the carrousel
*/ */
@ -78,14 +77,10 @@ public:
private: private:
Q_DISABLE_COPY(VPieceCarrousel) Q_DISABLE_COPY(VPieceCarrousel)
Ui::VPieceCarrousel *ui;
VPuzzleLayout *m_layout; VPuzzleLayout *m_layout;
QList<VPuzzleLayer*> m_layers{};
QComboBox *m_comboBoxLayer;
QScrollArea *m_scrollArea;
QWidget *m_layersContainer;
QList<VPieceCarrouselLayer*> m_carrouselLayers;
Qt::Orientation m_orientation{Qt::Vertical}; Qt::Orientation m_orientation{Qt::Vertical};

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VPieceCarrousel</class>
<widget class="QWidget" name="VPieceCarrousel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>583</width>
<height>557</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Carrousel</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QComboBox" name="comboBoxLayer">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
<property name="iconSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::TopToBottom</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="spacing">
<number>6</number>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -277,7 +277,7 @@ void VPieceCarrouselPiece::on_ActionPieceMovedToLayer()
{ {
QAction *act = qobject_cast<QAction *>(sender()); QAction *act = qobject_cast<QAction *>(sender());
QVariant v = act->data(); QVariant v = act->data();
VPuzzleLayer *layer = (VPuzzleLayer *) v.value<VPuzzleLayer *>(); VPuzzleLayer *layer = v.value<VPuzzleLayer *>();
if(layer != nullptr) if(layer != nullptr)
{ {
layer->GetLayout()->MovePieceToLayer(m_piece, layer); layer->GetLayout()->MovePieceToLayer(m_piece, layer);

View File

@ -37,7 +37,7 @@
class VPuzzleGraphicsLayout : public QGraphicsItem class VPuzzleGraphicsLayout : public QGraphicsItem
{ {
public: public:
VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsItem *parent = nullptr); explicit VPuzzleGraphicsLayout(VPuzzleLayout *layout, QGraphicsItem *parent = nullptr);
~VPuzzleGraphicsLayout(); ~VPuzzleGraphicsLayout();
QRectF boundingRect() const override; QRectF boundingRect() const override;

View File

@ -1,35 +0,0 @@
/************************************************************************
**
** @file vpuzzlemaingraphicsscene.cpp
** @author Ronan Le Tiec
** @date 3 5, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpuzzlemaingraphicsscene.h"
//---------------------------------------------------------------------------------------------------------------------
VPuzzleMainGraphicsScene::VPuzzleMainGraphicsScene(QObject *parent): QGraphicsScene(parent)
{
}

View File

@ -1,44 +0,0 @@
/************************************************************************
**
** @file vpuzzlemaingraphicsscene.cpp
** @author Ronan Le Tiec
** @date 3 5, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPUZZLEMAINGRAPHICSSCENE_H
#define VPUZZLEMAINGRAPHICSSCENE_H
#include <QGraphicsScene>
// TODO: When ready, extend from QGraphicsScene instead
class VPuzzleMainGraphicsScene : public QGraphicsScene
{
Q_OBJECT
public:
VPuzzleMainGraphicsScene(QObject *parent = nullptr);
};
#endif // VPUZZLEMAINGRAPHICSSCENE_H

View File

@ -34,6 +34,7 @@
#include "vpuzzlemimedatapiece.h" #include "vpuzzlemimedatapiece.h"
#include "vpuzzlelayer.h" #include "vpuzzlelayer.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include <QLoggingCategory> #include <QLoggingCategory>
@ -42,30 +43,22 @@ Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView")
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent) : VPuzzleMainGraphicsView::VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent) :
QGraphicsView(parent), VMainGraphicsView(parent),
m_layout(layout), m_layout(layout)
m_graphicsPieces(QList<VPuzzleGraphicsPiece*>())
{ {
m_scene = new VPuzzleMainGraphicsScene(this); m_scene = new VMainGraphicsScene(this);
setScene(m_scene); setScene(m_scene);
m_graphicsLayout = new VPuzzleGraphicsLayout(layout); m_graphicsLayout = new VPuzzleGraphicsLayout(layout);
m_graphicsLayout->setPos(0,0); m_graphicsLayout->setPos(0, 0);
m_scene->addItem(m_graphicsLayout); m_scene->addItem(m_graphicsLayout);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
setAcceptDrops(true); setAcceptDrops(true);
// add the connections // add the connections
connect(m_layout, &VPuzzleLayout::PieceMovedToLayer, this, &VPuzzleMainGraphicsView::on_PieceMovedToLayer); connect(m_layout, &VPuzzleLayout::PieceMovedToLayer, this, &VPuzzleMainGraphicsView::on_PieceMovedToLayer);
connect(m_scene, &VPuzzleMainGraphicsScene::selectionChanged, this, &VPuzzleMainGraphicsView::on_SceneSelectionChanged); connect(m_scene, &VMainGraphicsScene::selectionChanged, this,
} &VPuzzleMainGraphicsView::on_SceneSelectionChanged);
//---------------------------------------------------------------------------------------------------------------------
VPuzzleMainGraphicsView::~VPuzzleMainGraphicsView()
{
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -29,21 +29,19 @@
#ifndef VPUZZLEMAINGRAPHICSVIEW_H #ifndef VPUZZLEMAINGRAPHICSVIEW_H
#define VPUZZLEMAINGRAPHICSVIEW_H #define VPUZZLEMAINGRAPHICSVIEW_H
#include <QGraphicsView>
#include "vpuzzlegraphicslayout.h" #include "vpuzzlegraphicslayout.h"
#include "vpuzzlemaingraphicsscene.h"
#include "vpuzzlegraphicspiece.h" #include "vpuzzlegraphicspiece.h"
#include "../vwidgets/vmaingraphicsview.h"
class VMainGraphicsScene;
// TODO: when ready, extend the VMainGrapchisView instead class VPuzzleMainGraphicsView : public VMainGraphicsView
class VPuzzleMainGraphicsView : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent); VPuzzleMainGraphicsView(VPuzzleLayout *layout, QWidget *parent);
~VPuzzleMainGraphicsView(); ~VPuzzleMainGraphicsView() = default;
/** /**
* @brief RefreshLayout Refreshes the rectangles for the layout border and the margin * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin
@ -60,7 +58,8 @@ protected:
private slots: private slots:
/** /**
* @brief on_PieceMovedToLayer The slot is called when the given piece was moved from the given layer to the other given layer * @brief on_PieceMovedToLayer The slot is called when the given piece was moved from the given layer to the other
* given layer
* @param piece the piece that was moved * @param piece the piece that was moved
* @param layerBefore the layer before the move * @param layerBefore the layer before the move
* @param layerAfter the layer after the move * @param layerAfter the layer after the move
@ -75,12 +74,12 @@ private slots:
private: private:
Q_DISABLE_COPY(VPuzzleMainGraphicsView) Q_DISABLE_COPY(VPuzzleMainGraphicsView)
VPuzzleMainGraphicsScene *m_scene{nullptr}; VMainGraphicsScene *m_scene{nullptr};
VPuzzleGraphicsLayout *m_graphicsLayout{nullptr}; VPuzzleGraphicsLayout *m_graphicsLayout{nullptr};
VPuzzleLayout *m_layout{nullptr}; VPuzzleLayout *m_layout{nullptr};
QList<VPuzzleGraphicsPiece*> m_graphicsPieces; QList<VPuzzleGraphicsPiece*> m_graphicsPieces{};
}; };

View File

@ -32,7 +32,9 @@
#include "vpuzzlelayer.h" #include "vpuzzlelayer.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include <QIcon>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QPainter>
Q_LOGGING_CATEGORY(pPiece, "p.piece") Q_LOGGING_CATEGORY(pPiece, "p.piece")
@ -245,7 +247,6 @@ VPuzzleLayer* VPuzzlePiece::GetLayer()
return m_layer; return m_layer;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzlePiece::SetLayer(VPuzzleLayer* layer) void VPuzzlePiece::SetLayer(VPuzzleLayer* layer)
{ {
@ -254,3 +255,46 @@ void VPuzzlePiece::SetLayer(VPuzzleLayer* layer)
m_layer = layer; m_layer = layer;
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QIcon VPuzzlePiece::PieceIcon(const QSize &size) const
{
QVector<QPointF> points = GetSeamLine();
if(points.isEmpty())
{
points = GetCuttingLine();
}
QPolygonF shape(points);
shape << shape.first();
QRectF boundingRect = shape.boundingRect();
qreal canvasSize = qMax(boundingRect.height(), boundingRect.width());
QRectF canvas = QRectF(0, 0, canvasSize, canvasSize);
qreal dx = canvas.center().x() - boundingRect.center().x();
qreal dy = canvas.center().y() - boundingRect.center().y();
QPixmap pixmap(size);
pixmap.fill(QColor("white"));
QPainter painter;
painter.begin(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
int spacing = 2;
painter.translate(spacing, spacing);
qreal scaleFactorX = canvasSize * 100 / (size.width() - spacing*2) / 100;
qreal scaleFactorY = canvasSize * 100 / (size.height() - spacing*2) / 100;
painter.scale(1./scaleFactorX, 1./scaleFactorY);
painter.setPen(QPen(Qt::black, 0.8*qMax(scaleFactorX, scaleFactorY)));
painter.translate(dx, dy);
painter.drawPolygon(shape);
painter.end();
return QIcon(pixmap);
}

View File

@ -198,6 +198,8 @@ public:
*/ */
void SetLayer(VPuzzleLayer* layer); void SetLayer(VPuzzleLayer* layer);
QIcon PieceIcon(const QSize &size) const;
signals: signals:
/** /**
* @brief SelectionChanged emited when the selection of the piece was * @brief SelectionChanged emited when the selection of the piece was

View File

@ -0,0 +1,81 @@
/************************************************************************
**
** @file vpuzzlesettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpuzzlesettings.h"
namespace
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents")))
}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
: VCommonSettings(format, scope, organization, application, parent)
{}
//---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent)
{}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::IsDockWidgetPropertiesActive() const
{
return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::GetDefDockWidgetPropertiesActive()
{
return true;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleSettings::SetDockWidgetPropertiesActive(bool value)
{
setValue(*settingDockWidgetPropertiesActive, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::IsDockWidgetPropertiesContentsActive() const
{
return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::GetDefDockWidgetPropertiesContentsActive()
{
return true;
}
//---------------------------------------------------------------------------------------------------------------------
void VPuzzleSettings::SetDockWidgetPropertiesContentsActive(bool value)
{
setValue(*settingDockPropertiesContentsActive, value);
}

View File

@ -38,6 +38,15 @@ class VPuzzleSettings : public VCommonSettings
public: public:
VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
VPuzzleSettings(const QString &fileName, Format format, QObject *parent = nullptr);
bool IsDockWidgetPropertiesActive() const;
static bool GetDefDockWidgetPropertiesActive();
void SetDockWidgetPropertiesActive(bool value);
bool IsDockWidgetPropertiesContentsActive() const;
static bool GetDefDockWidgetPropertiesContentsActive();
void SetDockWidgetPropertiesContentsActive(bool value);
private: private:
Q_DISABLE_COPY(VPuzzleSettings) Q_DISABLE_COPY(VPuzzleSettings)

View File

@ -29,7 +29,7 @@
#include "tapepreferencesconfigurationpage.h" #include "tapepreferencesconfigurationpage.h"
#include "ui_tapepreferencesconfigurationpage.h" #include "ui_tapepreferencesconfigurationpage.h"
#include "../../mapplication.h" #include "../../mapplication.h"
#include "../vmisc/vtapesettings.h" #include "../../vtapesettings.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/pmsystems.h" #include "../vpatterndb/pmsystems.h"

View File

@ -29,7 +29,7 @@
#include "tapepreferencespathpage.h" #include "tapepreferencespathpage.h"
#include "ui_tapepreferencespathpage.h" #include "ui_tapepreferencespathpage.h"
#include "../../mapplication.h" #include "../../mapplication.h"
#include "../vmisc/vtapesettings.h" #include "../../vtapesettings.h"
#include <QDir> #include <QDir>
#include <QFileDialog> #include <QFileDialog>

View File

@ -30,7 +30,7 @@
#include "ui_dialognewmeasurements.h" #include "ui_dialognewmeasurements.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
#include "../vmisc/vtapesettings.h" #include "../vtapesettings.h"
#include "../mapplication.h" #include "../mapplication.h"
#include <QShowEvent> #include <QShowEvent>

View File

@ -31,7 +31,7 @@
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/vtapesettings.h" #include "vtapesettings.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "dialogs/dialogmdatabase.h" #include "dialogs/dialogmdatabase.h"
@ -101,8 +101,8 @@ private:
void Clean(); void Clean();
}; };
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
inline const VTranslateVars *MApplication::TrVars() inline const VTranslateVars *MApplication::TrVars()
{ {
return trVars; return trVars;

View File

@ -11,7 +11,8 @@ SOURCES += \
$$PWD/vlitepattern.cpp \ $$PWD/vlitepattern.cpp \
$$PWD/dialogs/dialogtapepreferences.cpp \ $$PWD/dialogs/dialogtapepreferences.cpp \
$$PWD/dialogs/configpages/tapepreferencesconfigurationpage.cpp \ $$PWD/dialogs/configpages/tapepreferencesconfigurationpage.cpp \
$$PWD/dialogs/configpages/tapepreferencespathpage.cpp $$PWD/dialogs/configpages/tapepreferencespathpage.cpp \
$$PWD/vtapesettings.cpp
*msvc*:SOURCES += $$PWD/stable.cpp *msvc*:SOURCES += $$PWD/stable.cpp
@ -26,7 +27,8 @@ HEADERS += \
$$PWD/vlitepattern.h \ $$PWD/vlitepattern.h \
$$PWD/dialogs/dialogtapepreferences.h \ $$PWD/dialogs/dialogtapepreferences.h \
$$PWD/dialogs/configpages/tapepreferencesconfigurationpage.h \ $$PWD/dialogs/configpages/tapepreferencesconfigurationpage.h \
$$PWD/dialogs/configpages/tapepreferencespathpage.h $$PWD/dialogs/configpages/tapepreferencespathpage.h \
$$PWD/vtapesettings.h
FORMS += \ FORMS += \
$$PWD/tmainwindow.ui \ $$PWD/tmainwindow.ui \

View File

@ -6,11 +6,13 @@ HEADERS += \
$$PWD/vformulaproperty.h \ $$PWD/vformulaproperty.h \
$$PWD/vformulapropertyeditor.h \ $$PWD/vformulapropertyeditor.h \
$$PWD/vtooloptionspropertybrowser.h \ $$PWD/vtooloptionspropertybrowser.h \
$$PWD/vcmdexport.h $$PWD/vcmdexport.h \
$$PWD/vvalentinasettings.h
SOURCES += \ SOURCES += \
$$PWD/vapplication.cpp \ $$PWD/vapplication.cpp \
$$PWD/vformulaproperty.cpp \ $$PWD/vformulaproperty.cpp \
$$PWD/vformulapropertyeditor.cpp \ $$PWD/vformulapropertyeditor.cpp \
$$PWD/vtooloptionspropertybrowser.cpp \ $$PWD/vtooloptionspropertybrowser.cpp \
$$PWD/vcmdexport.cpp $$PWD/vcmdexport.cpp \
$$PWD/vvalentinasettings.cpp

View File

@ -445,9 +445,10 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------
void VApplication::ActivateDarkMode() void VApplication::ActivateDarkMode()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
if (settings->GetDarkMode()) if (settings->GetDarkMode())
{ {
QFile f(QStringLiteral(":qdarkstyle/style.qss")); QFile f(QStringLiteral(":qdarkstyle/style.qss"));
@ -465,7 +466,6 @@ void VApplication::ActivateDarkMode()
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VApplication::TapeFilePath() const QString VApplication::TapeFilePath() const
{ {
@ -726,15 +726,15 @@ void VApplication::AboutToQuit()
*/ */
void VApplication::OpenSettings() void VApplication::OpenSettings()
{ {
settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), settings = new VValentinaSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this); QCoreApplication::applicationName(), this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSettings *VApplication::ValentinaSettings() VValentinaSettings *VApplication::ValentinaSettings()
{ {
SCASSERT(settings != nullptr) SCASSERT(settings != nullptr)
return qobject_cast<VSettings *>(settings); return qobject_cast<VValentinaSettings *>(settings);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vmaingraphicsview.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "vsettings.h" #include "vvalentinasettings.h"
#include "vcmdexport.h" #include "vcmdexport.h"
class VApplication;// use in define class VApplication;// use in define
@ -76,7 +76,7 @@ public:
virtual bool IsPedantic() const override; virtual bool IsPedantic() const override;
virtual void OpenSettings() override; virtual void OpenSettings() override;
VSettings *ValentinaSettings(); VValentinaSettings *ValentinaSettings();
protected: protected:
virtual void InitTrVars() override; virtual void InitTrVars() override;

View File

@ -32,7 +32,7 @@
#include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vdomdocument.h"
#include "../vformat/vmeasurements.h" #include "../vformat/vmeasurements.h"
#include "../vmisc/commandoptions.h" #include "../vmisc/commandoptions.h"
#include "../vmisc/vsettings.h" #include "vvalentinasettings.h"
#include "../vmisc/dialogs/dialogexporttocsv.h" #include "../vmisc/dialogs/dialogexporttocsv.h"
#include "../vlayout/vlayoutgenerator.h" #include "../vlayout/vlayoutgenerator.h"
#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/variables/vmeasurement.h"
@ -801,7 +801,7 @@ QStringList VCommandLine::OptionValues(const QString &option) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptNestingTime() const int VCommandLine::OptNestingTime() const
{ {
int time = VSettings::GetDefNestingTime(); int time = VValentinaSettings::GetDefNestingTime();
if (IsOptionSet(LONG_OPTION_NESTING_TIME)) if (IsOptionSet(LONG_OPTION_NESTING_TIME))
{ {
bool ok = false; bool ok = false;
@ -821,7 +821,7 @@ int VCommandLine::OptNestingTime() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::OptEfficiencyCoefficient() const qreal VCommandLine::OptEfficiencyCoefficient() const
{ {
qreal coefficient = VSettings::GetDefEfficiencyCoefficient(); qreal coefficient = VValentinaSettings::GetDefEfficiencyCoefficient();
if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT)) if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT))
{ {
bool ok = false; bool ok = false;

View File

@ -983,6 +983,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArc(VPE::VProperty *property)
SCASSERT(i != nullptr) SCASSERT(i != nullptr)
switch (PropertiesList().indexOf(id)) switch (PropertiesList().indexOf(id))
{ {
case 0: // AttrName
Q_UNREACHABLE();//The attribute is read only
break;
case 8: // AttrRadius case 8: // AttrRadius
i->SetFormulaRadius(value.value<VFormula>()); i->SetFormulaRadius(value.value<VFormula>());
break; break;
@ -1021,6 +1024,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArcWithLength(VPE::VProperty *pr
SCASSERT(i != nullptr) SCASSERT(i != nullptr)
switch (PropertiesList().indexOf(id)) switch (PropertiesList().indexOf(id))
{ {
case 0: // AttrName
Q_UNREACHABLE();//The attribute is read only
break;
case 8: // AttrRadius case 8: // AttrRadius
i->SetFormulaRadius(value.value<VFormula>()); i->SetFormulaRadius(value.value<VFormula>());
break; break;
@ -2019,6 +2025,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item)
i->ShowVisualization(true); i->ShowVisualization(true);
formView->setTitle(tr("Arc")); formView->setTitle(tr("Arc"));
AddPropertyObjectName(i, tr("Name:"), true);
AddPropertyParentPointName(i->CenterPointName(), tr("Center point:"), AttrCenter); AddPropertyParentPointName(i->CenterPointName(), tr("Center point:"), AttrCenter);
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius); AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius);
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1); AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);
@ -2035,6 +2042,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArcWithLength(QGraphicsItem *it
i->ShowVisualization(true); i->ShowVisualization(true);
formView->setTitle(tr("Arc with given length")); formView->setTitle(tr("Arc with given length"));
AddPropertyObjectName(i, tr("Name:"), true);
AddPropertyParentPointName(i->CenterPointName(), tr("Center point:"), AttrCenter); AddPropertyParentPointName(i->CenterPointName(), tr("Center point:"), AttrCenter);
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius); AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius);
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1); AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);

View File

@ -26,7 +26,7 @@
** **
*************************************************************************/ *************************************************************************/
#include "vsettings.h" #include "vvalentinasettings.h"
#include <QDir> #include <QDir>
#include <QLocale> #include <QLocale>
@ -47,26 +47,6 @@
Q_DECLARE_METATYPE(QMarginsF) Q_DECLARE_METATYPE(QMarginsF)
const int VSettings::defaultScrollingDuration = 300;
const int VSettings::scrollingDurationMin = 100;
const int VSettings::scrollingDurationMax = 1000;
const int VSettings::defaultScrollingUpdateInterval = 30;
const int VSettings::scrollingUpdateIntervalMin = 10;
const int VSettings::scrollingUpdateIntervalMax = 100;
const qreal VSettings::defaultSensorMouseScale = 2.0;
const qreal VSettings::sensorMouseScaleMin = 1.0;
const qreal VSettings::sensorMouseScaleMax = 10.0;
const qreal VSettings::defaultWheelMouseScale = 45.0;
const qreal VSettings::wheelMouseScaleMin = 1.0;
const qreal VSettings::wheelMouseScaleMax = 100.0;
const qreal VSettings::defaultScrollingAcceleration = 1.3;
const qreal VSettings::scrollingAccelerationMin = 1.0;
const qreal VSettings::scrollingAccelerationMax = 10.0;
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage,
@ -76,8 +56,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials")))
@ -107,13 +85,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1Str
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale,
(QLatin1String("scrolling/sensorMouseScale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive,
(QLatin1String("dockWidget/toolOptionsActive"))) (QLatin1String("dockWidget/toolOptionsActive")))
@ -122,17 +93,10 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize")))
// Reading settings file is very expensive, cache values to speed up getting a value
int scrollingDurationCached = -1;
int scrollingUpdateIntervalCached = -1;
qreal scrollingSensorMouseScaleCached = -1;
qreal scrollingWheelMouseScaleCached = -1;
qreal scrollingAccelerationCached = -1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application, VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent) QObject *parent)
:VCommonSettings(format, scope, organization, application, parent) :VCommonSettings(format, scope, organization, application, parent)
{ {
@ -140,63 +104,39 @@ VSettings::VSettings(Format format, Scope scope, const QString &organization, co
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSettings::VSettings(const QString &fileName, QSettings::Format format, QObject *parent) VValentinaSettings::VValentinaSettings(const QString &fileName, QSettings::Format format, QObject *parent)
:VCommonSettings(fileName, format, parent) :VCommonSettings(fileName, format, parent)
{ {
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF"); qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <class T> QString VValentinaSettings::GetLabelLanguage() const
inline T VSettings::ValueOrDef(const QString &setting, const T &defValue) const
{
const QVariant val = value(setting, QVariant::fromValue(defValue));
return val.canConvert<T>() ? val.value<T>() : defValue;
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline Cases VSettings::ValueOrDef<Cases>(const QString &setting, const Cases &defValue) const
{
const QVariant val = value(setting, QVariant::fromValue(static_cast<int>(defValue)));
const int g = val.canConvert<int>() ? val.value<int>() : static_cast<int>(defValue);
if (g < static_cast<int>(Cases::CaseThreeGroup) || g >= static_cast<int>(Cases::UnknownCase))
{
return defValue;
}
else
{
return static_cast<Cases>(g);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetLabelLanguage() const
{ {
return value(*settingConfigurationLabelLanguage, QLocale().bcp47Name()).toString(); return value(*settingConfigurationLabelLanguage, QLocale().bcp47Name()).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLabelLanguage(const QString &value) void VValentinaSettings::SetLabelLanguage(const QString &value)
{ {
setValue(*settingConfigurationLabelLanguage, value); setValue(*settingConfigurationLabelLanguage, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetDefPathLayout() QString VValentinaSettings::GetDefPathLayout()
{ {
return QDir::homePath() + QStringLiteral("/valentina/") + tr("layouts"); return QDir::homePath() + QStringLiteral("/valentina/") + tr("layouts");
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetPathLayout() const QString VValentinaSettings::GetPathLayout() const
{ {
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName()); QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
return settings.value(*settingPathsLayout, GetDefPathLayout()).toString(); return settings.value(*settingPathsLayout, GetDefPathLayout()).toString();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetPathLayout(const QString &value) void VValentinaSettings::SetPathLayout(const QString &value)
{ {
QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName()); QSettings settings(this->format(), this->scope(), this->organizationName(), this->applicationName());
settings.setValue(*settingPathsLayout, value); settings.setValue(*settingPathsLayout, value);
@ -204,358 +144,334 @@ void VSettings::SetPathLayout(const QString &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetGraphicalOutput() const qreal VValentinaSettings::GetLayoutPaperHeight() const
{ {
return value(*settingPatternGraphicalOutput, 1).toBool(); return ValueOrDef<qreal>(*this, *settingLayoutPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetGraphicalOutput(const bool &value) void VValentinaSettings::SetLayoutPaperHeight(qreal value)
{
setValue(*settingPatternGraphicalOutput, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsOpenGLRender() const
{
return value(*settingPatternUseOpenGLRender, 0).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetOpenGLRender(bool value)
{
setValue(*settingPatternUseOpenGLRender, value);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetLayoutPaperHeight() const
{
return ValueOrDef<qreal>(*settingLayoutPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px));
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutPaperHeight(qreal value)
{ {
setValue(*settingLayoutPaperHeight, value); setValue(*settingLayoutPaperHeight, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetLayoutPaperWidth() const qreal VValentinaSettings::GetLayoutPaperWidth() const
{ {
return ValueOrDef<qreal>(*settingLayoutPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px)); return ValueOrDef<qreal>(*this, *settingLayoutPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutPaperWidth(qreal value) void VValentinaSettings::SetLayoutPaperWidth(qreal value)
{ {
setValue(*settingLayoutPaperWidth, value); setValue(*settingLayoutPaperWidth, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetLayoutWidth() const qreal VValentinaSettings::GetLayoutWidth() const
{ {
return ValueOrDef<qreal>(*settingLayoutWidth, GetDefLayoutWidth()); return ValueOrDef<qreal>(*this, *settingLayoutWidth, GetDefLayoutWidth());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetDefLayoutWidth() qreal VValentinaSettings::GetDefLayoutWidth()
{ {
return UnitConvertor(2.5, Unit::Mm, Unit::Px); return UnitConvertor(2.5, Unit::Mm, Unit::Px);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutWidth(qreal value) void VValentinaSettings::SetLayoutWidth(qreal value)
{ {
setValue(*settingLayoutWidth, value); setValue(*settingLayoutWidth, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSettings::GetNestingTime() const int VValentinaSettings::GetNestingTime() const
{ {
return ValueOrDef<int>(*settingNestingTime, GetDefNestingTime()); return ValueOrDef<int>(*this, *settingNestingTime, GetDefNestingTime());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetNestingTime(int value) void VValentinaSettings::SetNestingTime(int value)
{ {
setValue(*settingNestingTime, value); setValue(*settingNestingTime, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetEfficiencyCoefficient() const qreal VValentinaSettings::GetEfficiencyCoefficient() const
{ {
return ValueOrDef<qreal>(*settingEfficiencyCoefficient, GetDefEfficiencyCoefficient()); return ValueOrDef<qreal>(*this, *settingEfficiencyCoefficient, GetDefEfficiencyCoefficient());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetEfficiencyCoefficient(qreal value) void VValentinaSettings::SetEfficiencyCoefficient(qreal value)
{ {
setValue(*settingEfficiencyCoefficient, value); setValue(*settingEfficiencyCoefficient, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMarginsF VSettings::GetFields(const QMarginsF &def) const QMarginsF VValentinaSettings::GetFields(const QMarginsF &def) const
{ {
return ValueOrDef<QMarginsF>(*settingFields, def); return ValueOrDef<QMarginsF>(*this, *settingFields, def);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetFields(const QMarginsF &value) void VValentinaSettings::SetFields(const QMarginsF &value)
{ {
setValue(*settingFields, QVariant::fromValue(value)); setValue(*settingFields, QVariant::fromValue(value));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Cases VSettings::GetLayoutGroup() const Cases VValentinaSettings::GetLayoutGroup() const
{ {
return ValueOrDef<Cases>(*settingLayoutSorting, GetDefLayoutGroup()); return ValueOrDef<Cases>(*this, *settingLayoutSorting, GetDefLayoutGroup());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Cases VSettings::GetDefLayoutGroup() Cases VValentinaSettings::GetDefLayoutGroup()
{ {
return Cases::CaseDesc; return Cases::CaseDesc;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutGroup(const Cases &value) void VValentinaSettings::SetLayoutGroup(const Cases &value)
{ {
setValue(*settingLayoutSorting, static_cast<int>(value)); setValue(*settingLayoutSorting, static_cast<int>(value));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutFollowGrainline() const bool VValentinaSettings::GetLayoutFollowGrainline() const
{ {
return value(*settingLayoutFollowGrainline, GetDefLayoutFollowGrainline()).toBool(); return value(*settingLayoutFollowGrainline, GetDefLayoutFollowGrainline()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutFollowGrainline() bool VValentinaSettings::GetDefLayoutFollowGrainline()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutFollowGrainline(bool value) void VValentinaSettings::SetLayoutFollowGrainline(bool value)
{ {
setValue(*settingLayoutFollowGrainline, value); setValue(*settingLayoutFollowGrainline, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutManualPriority() const bool VValentinaSettings::GetLayoutManualPriority() const
{ {
return value(*settingLayoutManualPriority, GetDefLayoutManualPriority()).toBool(); return value(*settingLayoutManualPriority, GetDefLayoutManualPriority()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutManualPriority() bool VValentinaSettings::GetDefLayoutManualPriority()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutManualPriority(bool value) void VValentinaSettings::SetLayoutManualPriority(bool value)
{ {
setValue(*settingLayoutManualPriority, value); setValue(*settingLayoutManualPriority, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutNestQuantity() const bool VValentinaSettings::GetLayoutNestQuantity() const
{ {
return value(*settingLayoutNestQuantity, GetDefLayoutNestQuantity()).toBool(); return value(*settingLayoutNestQuantity, GetDefLayoutNestQuantity()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutNestQuantity() bool VValentinaSettings::GetDefLayoutNestQuantity()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutNestQuantity(bool value) void VValentinaSettings::SetLayoutNestQuantity(bool value)
{ {
setValue(*settingLayoutNestQuantity, value); setValue(*settingLayoutNestQuantity, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutAutoCropLength() const bool VValentinaSettings::GetLayoutAutoCropLength() const
{ {
return value(*settingLayoutAutoCropLength, GetDefLayoutAutoCropLength()).toBool(); return value(*settingLayoutAutoCropLength, GetDefLayoutAutoCropLength()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutAutoCropLength() bool VValentinaSettings::GetDefLayoutAutoCropLength()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutAutoCropLength(bool value) void VValentinaSettings::SetLayoutAutoCropLength(bool value)
{ {
setValue(*settingLayoutAutoCropLength, value); setValue(*settingLayoutAutoCropLength, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutAutoCropWidth() const bool VValentinaSettings::GetLayoutAutoCropWidth() const
{ {
return value(*settingLayoutAutoCropWidth, GetDefLayoutAutoCropWidth()).toBool(); return value(*settingLayoutAutoCropWidth, GetDefLayoutAutoCropWidth()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutAutoCropWidth() bool VValentinaSettings::GetDefLayoutAutoCropWidth()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutAutoCropWidth(bool value) void VValentinaSettings::SetLayoutAutoCropWidth(bool value)
{ {
setValue(*settingLayoutAutoCropWidth, value); setValue(*settingLayoutAutoCropWidth, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutSaveLength() const bool VValentinaSettings::GetLayoutSaveLength() const
{ {
return value(*settingLayoutSaveLength, GetDefLayoutSaveLength()).toBool(); return value(*settingLayoutSaveLength, GetDefLayoutSaveLength()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutSaveLength() bool VValentinaSettings::GetDefLayoutSaveLength()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutSaveLength(bool value) void VValentinaSettings::SetLayoutSaveLength(bool value)
{ {
setValue(*settingLayoutSaveLength, value); setValue(*settingLayoutSaveLength, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutPreferOneSheetSolution() const bool VValentinaSettings::GetLayoutPreferOneSheetSolution() const
{ {
return value(*settingLayoutPreferOneSheetSolution, GetDefLayoutPreferOneSheetSolution()).toBool(); return value(*settingLayoutPreferOneSheetSolution, GetDefLayoutPreferOneSheetSolution()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutPreferOneSheetSolution() bool VValentinaSettings::GetDefLayoutPreferOneSheetSolution()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutPreferOneSheetSolution(bool value) void VValentinaSettings::SetLayoutPreferOneSheetSolution(bool value)
{ {
setValue(*settingLayoutPreferOneSheetSolution, value); setValue(*settingLayoutPreferOneSheetSolution, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutUnitePages() const bool VValentinaSettings::GetLayoutUnitePages() const
{ {
return value(*settingLayoutUnitePages, GetDefLayoutUnitePages()).toBool(); return value(*settingLayoutUnitePages, GetDefLayoutUnitePages()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutUnitePages() bool VValentinaSettings::GetDefLayoutUnitePages()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutUnitePages(bool value) void VValentinaSettings::SetLayoutUnitePages(bool value)
{ {
setValue(*settingLayoutUnitePages, value); setValue(*settingLayoutUnitePages, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetIgnoreAllFields() const bool VValentinaSettings::GetIgnoreAllFields() const
{ {
return value(*settingIgnoreFields, GetDefIgnoreAllFields()).toBool(); return value(*settingIgnoreFields, GetDefIgnoreAllFields()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefIgnoreAllFields() bool VValentinaSettings::GetDefIgnoreAllFields()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetIgnoreAllFields(bool value) void VValentinaSettings::SetIgnoreAllFields(bool value)
{ {
setValue(*settingIgnoreFields, value); setValue(*settingIgnoreFields, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetStripOptimization() const bool VValentinaSettings::GetStripOptimization() const
{ {
return value(*settingStripOptimization, GetDefStripOptimization()).toBool(); return value(*settingStripOptimization, GetDefStripOptimization()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefStripOptimization() bool VValentinaSettings::GetDefStripOptimization()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetStripOptimization(bool value) void VValentinaSettings::SetStripOptimization(bool value)
{ {
setValue(*settingStripOptimization, value); setValue(*settingStripOptimization, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint8 VSettings::GetMultiplier() const quint8 VValentinaSettings::GetMultiplier() const
{ {
return static_cast<quint8>(value(*settingMultiplier, GetDefMultiplier()).toUInt()); return static_cast<quint8>(value(*settingMultiplier, GetDefMultiplier()).toUInt());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint8 VSettings::GetDefMultiplier() quint8 VValentinaSettings::GetDefMultiplier()
{ {
return 1; return 1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetMultiplier(quint8 value) void VValentinaSettings::SetMultiplier(quint8 value)
{ {
setValue(*settingMultiplier, value); setValue(*settingMultiplier, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetTextAsPaths() const bool VValentinaSettings::GetTextAsPaths() const
{ {
return value(*settingTextAsPaths, GetDefTextAsPaths()).toBool(); return value(*settingTextAsPaths, GetDefTextAsPaths()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefTextAsPaths() bool VValentinaSettings::GetDefTextAsPaths()
{ {
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetTextAsPaths(bool value) void VValentinaSettings::SetTextAsPaths(bool value)
{ {
setValue(*settingTextAsPaths, value); setValue(*settingTextAsPaths, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VSettings::GetKnownMaterials() const QStringList VValentinaSettings::GetKnownMaterials() const
{ {
return value(*settingPatternKnownMaterials, QStringList()).toStringList(); return value(*settingPatternKnownMaterials, QStringList()).toStringList();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetKnownMaterials(const QStringList &list) void VValentinaSettings::SetKnownMaterials(const QStringList &list)
{ {
setValue(*settingPatternKnownMaterials, list); setValue(*settingPatternKnownMaterials, list);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsRememberPatternMaterials() const bool VValentinaSettings::IsRememberPatternMaterials() const
{ {
return value(*settingPatternRememberMaterials, true).toBool(); return value(*settingPatternRememberMaterials, true).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetRememberPatternMaterials(bool value) void VValentinaSettings::SetRememberPatternMaterials(bool value)
{ {
setValue(*settingPatternRememberMaterials, value); setValue(*settingPatternRememberMaterials, value);
} }
@ -569,10 +485,11 @@ void VSettings::SetRememberPatternMaterials(bool value)
* internaly as mm so there is conversion beeing made. * internaly as mm so there is conversion beeing made.
* @return tiled pdf margins * @return tiled pdf margins
*/ */
QMarginsF VSettings::GetTiledPDFMargins(const Unit &unit) const QMarginsF VValentinaSettings::GetTiledPDFMargins(const Unit &unit) const
{ {
// default value is 10mm. We save the margins in mm in the setting. // default value is 10mm. We save the margins in mm in the setting.
return UnitConvertor(ValueOrDef<QMarginsF>(*settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm, unit); return UnitConvertor(ValueOrDef<QMarginsF>(*this, *settingTiledPDFMargins, QMarginsF(10, 10, 10, 10)), Unit::Mm,
unit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -582,7 +499,7 @@ QMarginsF VSettings::GetTiledPDFMargins(const Unit &unit) const
* @param unit the unit in which are the value. Necessary because we save the values * @param unit the unit in which are the value. Necessary because we save the values
* internaly as mm so there is conversion beeing made. * internaly as mm so there is conversion beeing made.
*/ */
void VSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit) void VValentinaSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit)
{ {
setValue(*settingTiledPDFMargins, QVariant::fromValue(UnitConvertor(value, unit, Unit::Mm))); setValue(*settingTiledPDFMargins, QVariant::fromValue(UnitConvertor(value, unit, Unit::Mm)));
} }
@ -594,9 +511,9 @@ void VSettings::SetTiledPDFMargins(const QMarginsF &value, const Unit &unit)
* internaly as mm so there is conversion beeing made. * internaly as mm so there is conversion beeing made.
* @return tiled pdf paper height * @return tiled pdf paper height
*/ */
qreal VSettings::GetTiledPDFPaperHeight(const Unit &unit) const qreal VValentinaSettings::GetTiledPDFPaperHeight(const Unit &unit) const
{ {
return UnitConvertor(ValueOrDef<qreal>(*settingTiledPDFPaperHeight, 297 /*A4*/), Unit::Mm, unit); return UnitConvertor(ValueOrDef<qreal>(*this, *settingTiledPDFPaperHeight, 297 /*A4*/), Unit::Mm, unit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -605,7 +522,7 @@ qreal VSettings::GetTiledPDFPaperHeight(const Unit &unit) const
* @param value in mm * @param value in mm
* @param unit unit of the given value * @param unit unit of the given value
*/ */
void VSettings::SetTiledPDFPaperHeight(qreal value, const Unit &unit) void VValentinaSettings::SetTiledPDFPaperHeight(qreal value, const Unit &unit)
{ {
setValue(*settingTiledPDFPaperHeight, UnitConvertor(value, unit, Unit::Mm)); setValue(*settingTiledPDFPaperHeight, UnitConvertor(value, unit, Unit::Mm));
} }
@ -617,9 +534,9 @@ void VSettings::SetTiledPDFPaperHeight(qreal value, const Unit &unit)
* internaly as mm so there is conversion beeing made. * internaly as mm so there is conversion beeing made.
* @return tiled pdf paper width * @return tiled pdf paper width
*/ */
qreal VSettings::GetTiledPDFPaperWidth(const Unit &unit) const qreal VValentinaSettings::GetTiledPDFPaperWidth(const Unit &unit) const
{ {
return UnitConvertor(ValueOrDef<qreal>(*settingTiledPDFPaperWidth, 210 /*A4*/), Unit::Mm, unit); return UnitConvertor(ValueOrDef<qreal>(*this, *settingTiledPDFPaperWidth, 210 /*A4*/), Unit::Mm, unit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -628,13 +545,13 @@ qreal VSettings::GetTiledPDFPaperWidth(const Unit &unit) const
* @param unit unit of the given value * @param unit unit of the given value
* @param value in mm * @param value in mm
*/ */
void VSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit) void VValentinaSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit)
{ {
setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm)); setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PageOrientation VSettings::GetTiledPDFOrientation() const PageOrientation VValentinaSettings::GetTiledPDFOrientation() const
{ {
bool defaultValue = static_cast<bool>(PageOrientation::Portrait); bool defaultValue = static_cast<bool>(PageOrientation::Portrait);
bool result = value(*settingTiledPDFOrientation, defaultValue).toBool(); bool result = value(*settingTiledPDFOrientation, defaultValue).toBool();
@ -642,137 +559,69 @@ PageOrientation VSettings::GetTiledPDFOrientation() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetTiledPDFOrientation(PageOrientation value) void VValentinaSettings::SetTiledPDFOrientation(PageOrientation value)
{ {
setValue(*settingTiledPDFOrientation, static_cast<bool> (value)); setValue(*settingTiledPDFOrientation, static_cast<bool> (value));
} }
//---------------------------------------------------------------------------------------------------------------------
int VSettings::GetScrollingDuration() const
{
return GetCachedValue(scrollingDurationCached, *settingScrollingDuration, defaultScrollingDuration,
scrollingDurationMin, scrollingDurationMax);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetScrollingDuration(int duration) bool VValentinaSettings::IsDockWidgetGroupsActive() const
{
scrollingDurationCached = qBound(scrollingDurationMin, duration, scrollingDurationMax);
setValue(*settingScrollingDuration, scrollingDurationCached);
}
//---------------------------------------------------------------------------------------------------------------------
int VSettings::GetScrollingUpdateInterval() const
{
return GetCachedValue(scrollingUpdateIntervalCached, *settingScrollingUpdateInterval,
defaultScrollingUpdateInterval, scrollingUpdateIntervalMin, scrollingUpdateIntervalMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetScrollingUpdateInterval(int updateInterval)
{
scrollingUpdateIntervalCached = qBound(scrollingUpdateIntervalMin, updateInterval, scrollingUpdateIntervalMax);
setValue(*settingScrollingUpdateInterval, scrollingUpdateIntervalCached);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetSensorMouseScale() const
{
return GetCachedValue(scrollingSensorMouseScaleCached, *settingScrollingSensorMouseScale, defaultSensorMouseScale,
sensorMouseScaleMin, sensorMouseScaleMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetSensorMouseScale(qreal scale)
{
scrollingSensorMouseScaleCached = qBound(sensorMouseScaleMin, scale, sensorMouseScaleMax);
setValue(*settingScrollingSensorMouseScale, scrollingSensorMouseScaleCached);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetWheelMouseScale() const
{
return GetCachedValue(scrollingWheelMouseScaleCached, *settingScrollingWheelMouseScale, defaultWheelMouseScale,
wheelMouseScaleMin, wheelMouseScaleMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetWheelMouseScale(qreal scale)
{
scrollingWheelMouseScaleCached = qBound(wheelMouseScaleMin, scale, wheelMouseScaleMax);
setValue(*settingScrollingWheelMouseScale, scrollingWheelMouseScaleCached);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetScrollingAcceleration() const
{
return GetCachedValue(scrollingAccelerationCached, *settingScrollingAcceleration, defaultScrollingAcceleration,
scrollingAccelerationMin, scrollingAccelerationMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetScrollingAcceleration(qreal acceleration)
{
scrollingAccelerationCached = qBound(scrollingAccelerationMin, acceleration, scrollingAccelerationMax);
setValue(*settingScrollingAcceleration, scrollingAccelerationCached);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsDockWidgetGroupsActive() const
{ {
return value(*settingdockWidgetGroupsActive, GetDefDockWidgetGroupsActive()).toBool(); return value(*settingdockWidgetGroupsActive, GetDefDockWidgetGroupsActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefDockWidgetGroupsActive() bool VValentinaSettings::GetDefDockWidgetGroupsActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetDockWidgetGroupsActive(bool value) void VValentinaSettings::SetDockWidgetGroupsActive(bool value)
{ {
setValue(*settingdockWidgetGroupsActive, value); setValue(*settingdockWidgetGroupsActive, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsDockWidgetToolOptionsActive() const bool VValentinaSettings::IsDockWidgetToolOptionsActive() const
{ {
return value(*settingDockWidgetToolOptionsActive, GetDefDockWidgetToolOptionsActive()).toBool(); return value(*settingDockWidgetToolOptionsActive, GetDefDockWidgetToolOptionsActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefDockWidgetToolOptionsActive() bool VValentinaSettings::GetDefDockWidgetToolOptionsActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetDockWidgetToolOptionsActive(bool value) void VValentinaSettings::SetDockWidgetToolOptionsActive(bool value)
{ {
setValue(*settingDockWidgetToolOptionsActive, value); setValue(*settingDockWidgetToolOptionsActive, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::IsDockWidgetPatternMessagesActive() const bool VValentinaSettings::IsDockWidgetPatternMessagesActive() const
{ {
return value(*settingDockWidgetPatternMessagesActive, GetDefDockWidgetPatternMessagesActive()).toBool(); return value(*settingDockWidgetPatternMessagesActive, GetDefDockWidgetPatternMessagesActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefDockWidgetPatternMessagesActive() bool VValentinaSettings::GetDefDockWidgetPatternMessagesActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetDockWidgetPatternMessagesActive(bool value) void VValentinaSettings::SetDockWidgetPatternMessagesActive(bool value)
{ {
setValue(*settingDockWidgetPatternMessagesActive, value); setValue(*settingDockWidgetPatternMessagesActive, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSettings::GetPatternMessageFontSize(int fontSizeDef) const int VValentinaSettings::GetPatternMessageFontSize(int fontSizeDef) const
{ {
fontSizeDef = qBound(GetDefMinPatternMessageFontSize(), fontSizeDef, GetDefMaxPatternMessageFontSize()); fontSizeDef = qBound(GetDefMinPatternMessageFontSize(), fontSizeDef, GetDefMaxPatternMessageFontSize());
const int fontSize = value(*settingPatternMessagesFontSize, fontSizeDef).toInt(); const int fontSize = value(*settingPatternMessagesFontSize, fontSizeDef).toInt();
@ -780,56 +629,44 @@ int VSettings::GetPatternMessageFontSize(int fontSizeDef) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSettings::GetDefMinPatternMessageFontSize() int VValentinaSettings::GetDefMinPatternMessageFontSize()
{ {
return 5; return 5;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VSettings::GetDefMaxPatternMessageFontSize() int VValentinaSettings::GetDefMaxPatternMessageFontSize()
{ {
return 40; return 40;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetPatternMessageFontSize(int size) void VValentinaSettings::SetPatternMessageFontSize(int size)
{ {
setValue(*settingPatternMessagesFontSize, qBound(GetDefMinPatternMessageFontSize(), size, setValue(*settingPatternMessagesFontSize, qBound(GetDefMinPatternMessageFontSize(), size,
GetDefMaxPatternMessageFontSize())); GetDefMaxPatternMessageFontSize()));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetAutoRefreshPatternMessage() const bool VValentinaSettings::GetAutoRefreshPatternMessage() const
{ {
return value(*settingAutoRefreshPatternMessage, true).toBool(); return value(*settingAutoRefreshPatternMessage, true).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetAutoRefreshPatternMessage(bool value) void VValentinaSettings::SetAutoRefreshPatternMessage(bool value)
{ {
setValue(*settingAutoRefreshPatternMessage, value); setValue(*settingAutoRefreshPatternMessage, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QSize VSettings::GetWatermarkEditorSize() const QSize VValentinaSettings::GetWatermarkEditorSize() const
{ {
return value(*settingWatermarkEditorSize, QSize(0, 0)).toSize(); return value(*settingWatermarkEditorSize, QSize(0, 0)).toSize();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSettings::SetWatermarkEditorSize(const QSize &sz) void VValentinaSettings::SetWatermarkEditorSize(const QSize &sz)
{ {
setValue(*settingWatermarkEditorSize, sz); setValue(*settingWatermarkEditorSize, sz);
} }
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
T VSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const
{
if (cache < 0)
{
cache = qBound(valueMin, ValueOrDef(setting, defValue), valueMax);
}
return cache;
}

View File

@ -26,8 +26,8 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef VSETTINGS_H #ifndef VVALENTINASETTINGS_H
#define VSETTINGS_H #define VVALENTINASETTINGS_H
#include <QMetaObject> #include <QMetaObject>
#include <QObject> #include <QObject>
@ -39,13 +39,13 @@
#include "vcommonsettings.h" #include "vcommonsettings.h"
#include "../vlayout/vbank.h" #include "../vlayout/vbank.h"
class VSettings : public VCommonSettings class VValentinaSettings : public VCommonSettings
{ {
Q_OBJECT Q_OBJECT
public: public:
VSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
VSettings(const QString &fileName, Format format, QObject *parent = nullptr); VValentinaSettings(const QString &fileName, Format format, QObject *parent = nullptr);
QString GetLabelLanguage() const; QString GetLabelLanguage() const;
void SetLabelLanguage(const QString &value); void SetLabelLanguage(const QString &value);
@ -54,12 +54,6 @@ public:
QString GetPathLayout() const; QString GetPathLayout() const;
void SetPathLayout(const QString &value); void SetPathLayout(const QString &value);
bool GetGraphicalOutput() const;
void SetGraphicalOutput(const bool &value);
bool IsOpenGLRender() const;
void SetOpenGLRender(bool value);
// Layout settings // Layout settings
qreal GetLayoutPaperHeight() const; qreal GetLayoutPaperHeight() const;
void SetLayoutPaperHeight(qreal value); void SetLayoutPaperHeight(qreal value);
@ -153,36 +147,6 @@ public:
PageOrientation GetTiledPDFOrientation() const; PageOrientation GetTiledPDFOrientation() const;
void SetTiledPDFOrientation(PageOrientation value); void SetTiledPDFOrientation(PageOrientation value);
static const int defaultScrollingDuration;
static const int scrollingDurationMin;
static const int scrollingDurationMax;
int GetScrollingDuration() const;
void SetScrollingDuration(int duration);
static const int defaultScrollingUpdateInterval;
static const int scrollingUpdateIntervalMin;
static const int scrollingUpdateIntervalMax;
int GetScrollingUpdateInterval() const;
void SetScrollingUpdateInterval(int updateInterval);
static const qreal defaultSensorMouseScale;
static const qreal sensorMouseScaleMin;
static const qreal sensorMouseScaleMax;
qreal GetSensorMouseScale() const;
void SetSensorMouseScale(qreal scale);
static const qreal defaultWheelMouseScale;
static const qreal wheelMouseScaleMin;
static const qreal wheelMouseScaleMax;
qreal GetWheelMouseScale() const;
void SetWheelMouseScale(qreal scale);
static const qreal defaultScrollingAcceleration;
static const qreal scrollingAccelerationMin;
static const qreal scrollingAccelerationMax;
qreal GetScrollingAcceleration() const;
void SetScrollingAcceleration(qreal acceleration);
bool IsDockWidgetGroupsActive() const; bool IsDockWidgetGroupsActive() const;
static bool GetDefDockWidgetGroupsActive(); static bool GetDefDockWidgetGroupsActive();
void SetDockWidgetGroupsActive(bool value); void SetDockWidgetGroupsActive(bool value);
@ -207,13 +171,7 @@ public:
void SetWatermarkEditorSize(const QSize& sz); void SetWatermarkEditorSize(const QSize& sz);
private: private:
Q_DISABLE_COPY(VSettings) Q_DISABLE_COPY(VValentinaSettings)
template <typename T>
T GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const;
template <class T>
T ValueOrDef(const QString &setting, const T &defValue) const;
}; };
#endif // VSETTINGS_H #endif // VVALENTINASETTINGS_H

View File

@ -110,13 +110,13 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
//----------------------------- Pattern Editing //----------------------------- Pattern Editing
connect(ui->resetWarningsButton, &QPushButton::released, this, []() connect(ui->resetWarningsButton, &QPushButton::released, this, []()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetConfirmItemDelete(true); settings->SetConfirmItemDelete(true);
settings->SetConfirmFormatRewriting(true); settings->SetConfirmFormatRewriting(true);
}); });
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
ui->checkBoxFreeCurve->setChecked(settings->IsFreeCurveMode()); ui->checkBoxFreeCurve->setChecked(settings->IsFreeCurveMode());
ui->checkBoxZoomFitBestCurrentPP->setChecked(settings->IsDoubleClickZoomFitBestCurrentPP()); ui->checkBoxZoomFitBestCurrentPP->setChecked(settings->IsDoubleClickZoomFitBestCurrentPP());
@ -128,24 +128,24 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
ui->darkModeCheck->setChecked(settings->GetDarkMode()); ui->darkModeCheck->setChecked(settings->GetDarkMode());
// Tab Scrolling // Tab Scrolling
ui->spinBoxDuration->setMinimum(VSettings::scrollingDurationMin); ui->spinBoxDuration->setMinimum(VValentinaSettings::scrollingDurationMin);
ui->spinBoxDuration->setMaximum(VSettings::scrollingDurationMax); ui->spinBoxDuration->setMaximum(VValentinaSettings::scrollingDurationMax);
ui->spinBoxDuration->setValue(settings->GetScrollingDuration()); ui->spinBoxDuration->setValue(settings->GetScrollingDuration());
ui->spinBoxUpdateInterval->setMinimum(VSettings::scrollingUpdateIntervalMin); ui->spinBoxUpdateInterval->setMinimum(VValentinaSettings::scrollingUpdateIntervalMin);
ui->spinBoxUpdateInterval->setMaximum(VSettings::scrollingUpdateIntervalMax); ui->spinBoxUpdateInterval->setMaximum(VValentinaSettings::scrollingUpdateIntervalMax);
ui->spinBoxUpdateInterval->setValue(settings->GetScrollingUpdateInterval()); ui->spinBoxUpdateInterval->setValue(settings->GetScrollingUpdateInterval());
ui->doubleSpinBoxSensor->setMinimum(VSettings::sensorMouseScaleMin); ui->doubleSpinBoxSensor->setMinimum(VValentinaSettings::sensorMouseScaleMin);
ui->doubleSpinBoxSensor->setMaximum(VSettings::sensorMouseScaleMax); ui->doubleSpinBoxSensor->setMaximum(VValentinaSettings::sensorMouseScaleMax);
ui->doubleSpinBoxSensor->setValue(settings->GetSensorMouseScale()); ui->doubleSpinBoxSensor->setValue(settings->GetSensorMouseScale());
ui->doubleSpinBoxWheel->setMinimum(VSettings::wheelMouseScaleMin); ui->doubleSpinBoxWheel->setMinimum(VValentinaSettings::wheelMouseScaleMin);
ui->doubleSpinBoxWheel->setMaximum(VSettings::wheelMouseScaleMax); ui->doubleSpinBoxWheel->setMaximum(VValentinaSettings::wheelMouseScaleMax);
ui->doubleSpinBoxWheel->setValue(settings->GetWheelMouseScale()); ui->doubleSpinBoxWheel->setValue(settings->GetWheelMouseScale());
ui->doubleSpinBoxAcceleration->setMinimum(VSettings::scrollingAccelerationMin); ui->doubleSpinBoxAcceleration->setMinimum(VValentinaSettings::scrollingAccelerationMin);
ui->doubleSpinBoxAcceleration->setMaximum(VSettings::scrollingAccelerationMax); ui->doubleSpinBoxAcceleration->setMaximum(VValentinaSettings::scrollingAccelerationMax);
ui->doubleSpinBoxAcceleration->setValue(settings->GetScrollingAcceleration()); ui->doubleSpinBoxAcceleration->setValue(settings->GetScrollingAcceleration());
} }
@ -160,7 +160,7 @@ QStringList PreferencesConfigurationPage::Apply()
{ {
// Tab General // Tab General
QStringList preferences; QStringList preferences;
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetAutosaveState(ui->autoSaveCheck->isChecked()); settings->SetAutosaveState(ui->autoSaveCheck->isChecked());
settings->SetAutosaveTime(ui->autoTime->value()); settings->SetAutosaveTime(ui->autoTime->value());

View File

@ -28,7 +28,7 @@
#include "preferencespathpage.h" #include "preferencespathpage.h"
#include "ui_preferencespathpage.h" #include "ui_preferencespathpage.h"
#include "../vmisc/vsettings.h" #include "../../core/vvalentinasettings.h"
#include "../../core/vapplication.h" #include "../../core/vapplication.h"
#include <QDir> #include <QDir>
@ -65,7 +65,7 @@ PreferencesPathPage::~PreferencesPathPage()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList PreferencesPathPage::Apply() QStringList PreferencesPathPage::Apply()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text()); settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text());
settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text()); settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text());
settings->SetPathPattern(ui->pathTable->item(2, 1)->text()); settings->SetPathPattern(ui->pathTable->item(2, 1)->text());
@ -105,13 +105,13 @@ void PreferencesPathPage::DefaultPath()
path = VCommonSettings::GetDefPathMultisizeMeasurements(); path = VCommonSettings::GetDefPathMultisizeMeasurements();
break; break;
case 2: // pattern path case 2: // pattern path
path = VSettings::GetDefPathPattern(); path = VValentinaSettings::GetDefPathPattern();
break; break;
case 0: // individual measurements case 0: // individual measurements
path = VCommonSettings::GetDefPathIndividualMeasurements(); path = VCommonSettings::GetDefPathIndividualMeasurements();
break; break;
case 3: // layout path case 3: // layout path
path = VSettings::GetDefPathLayout(); path = VValentinaSettings::GetDefPathLayout();
break; break;
case 4: // templates case 4: // templates
path = VCommonSettings::GetDefPathTemplate(); path = VCommonSettings::GetDefPathTemplate();
@ -206,7 +206,7 @@ void PreferencesPathPage::InitTable()
ui->pathTable->setRowCount(7); ui->pathTable->setRowCount(7);
ui->pathTable->setColumnCount(2); ui->pathTable->setColumnCount(2);
const VSettings *settings = qApp->ValentinaSettings(); const VValentinaSettings *settings = qApp->ValentinaSettings();
{ {
ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements")));

View File

@ -63,7 +63,7 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
RetranslateUi(); RetranslateUi();
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput()); ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput());
ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender()); ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender());
@ -125,7 +125,7 @@ QStringList PreferencesPatternPage::Apply()
{ {
QStringList preferences; QStringList preferences;
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
// Scene antialiasing // Scene antialiasing
if (settings->GetGraphicalOutput() != ui->graphOutputCheck->isChecked()) if (settings->GetGraphicalOutput() != ui->graphOutputCheck->isChecked())
@ -200,7 +200,7 @@ void PreferencesPatternPage::changeEvent(QEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::EditDateTimeFormats() void PreferencesPatternPage::EditDateTimeFormats()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
QPushButton *button = qobject_cast<QPushButton *>(sender()); QPushButton *button = qobject_cast<QPushButton *>(sender());
if (button == ui->pushButtonEditDateFormats) if (button == ui->pushButtonEditDateFormats)
@ -230,7 +230,7 @@ void PreferencesPatternPage::ManageKnownMaterials()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesPatternPage::InitLabelDateTimeFormats() void PreferencesPatternPage::InitLabelDateTimeFormats()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
InitComboBoxFormats(ui->comboBoxDateFormats, InitComboBoxFormats(ui->comboBoxDateFormats,
VCommonSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(), VCommonSettings::PredefinedDateFormats() + settings->GetUserDefinedDateFormats(),

View File

@ -28,7 +28,7 @@
#include "dialogfinalmeasurements.h" #include "dialogfinalmeasurements.h"
#include "ui_dialogfinalmeasurements.h" #include "ui_dialogfinalmeasurements.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../qmuparser/qmutokenparser.h" #include "../qmuparser/qmutokenparser.h"

View File

@ -29,7 +29,7 @@
#include "dialogincrements.h" #include "dialogincrements.h"
#include "ui_dialogincrements.h" #include "ui_dialogincrements.h"
#include "../vwidgets/vwidgetpopup.h" #include "../vwidgets/vwidgetpopup.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../qmuparser/qmutokenparser.h" #include "../qmuparser/qmutokenparser.h"
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"

View File

@ -29,7 +29,7 @@
#include "dialoglayoutscale.h" #include "dialoglayoutscale.h"
#include "ui_dialoglayoutscale.h" #include "ui_dialoglayoutscale.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include <QPushButton> #include <QPushButton>
@ -180,7 +180,7 @@ void DialogLayoutScale::VerticalScaleChanged(double d)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::ReadSettings() void DialogLayoutScale::ReadSettings()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit(); const Unit unit = qApp->patternUnit();
// read Margins top, right, bottom, left // read Margins top, right, bottom, left
@ -200,7 +200,7 @@ void DialogLayoutScale::ReadSettings()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutScale::WriteSettings() const void DialogLayoutScale::WriteSettings() const
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit(); const Unit unit = qApp->patternUnit();
// write Margins top, right, bottom, left // write Margins top, right, bottom, left

View File

@ -30,7 +30,7 @@
#include "ui_dialoglayoutsettings.h" #include "ui_dialoglayoutsettings.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vdomdocument.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#include "../vlayout/vlayoutgenerator.h" #include "../vlayout/vlayoutgenerator.h"
@ -698,17 +698,17 @@ void DialogLayoutSettings::RestoreDefaults()
InitPrinter(); InitPrinter();
ui->comboBoxPrinter->blockSignals(false); ui->comboBoxPrinter->blockSignals(false);
SetLayoutWidth(VSettings::GetDefLayoutWidth()); SetLayoutWidth(VValentinaSettings::GetDefLayoutWidth());
SetGroup(VSettings::GetDefLayoutGroup()); SetGroup(VValentinaSettings::GetDefLayoutGroup());
SetFollowGrainline(VSettings::GetDefLayoutFollowGrainline()); SetFollowGrainline(VValentinaSettings::GetDefLayoutFollowGrainline());
SetManualPriority(VSettings::GetDefLayoutManualPriority()); SetManualPriority(VValentinaSettings::GetDefLayoutManualPriority());
SetFields(GetDefPrinterFields()); SetFields(GetDefPrinterFields());
SetIgnoreAllFields(VSettings::GetDefIgnoreAllFields()); SetIgnoreAllFields(VValentinaSettings::GetDefIgnoreAllFields());
SetMultiplier(VSettings::GetDefMultiplier()); SetMultiplier(VValentinaSettings::GetDefMultiplier());
SetNestingTime(VSettings::GetDefNestingTime()); SetNestingTime(VValentinaSettings::GetDefNestingTime());
SetEfficiencyCoefficient(VSettings::GetDefEfficiencyCoefficient()); SetEfficiencyCoefficient(VValentinaSettings::GetDefEfficiencyCoefficient());
SetNestQuantity(VSettings::GetDefLayoutNestQuantity()); SetNestQuantity(VValentinaSettings::GetDefLayoutNestQuantity());
SetPreferOneSheetSolution(VSettings::GetDefLayoutPreferOneSheetSolution()); SetPreferOneSheetSolution(VValentinaSettings::GetDefLayoutPreferOneSheetSolution());
CorrectMaxFileds(); CorrectMaxFileds();
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked()); IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
@ -1019,7 +1019,7 @@ void DialogLayoutSettings::MinimumLayoutSize()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::ReadSettings() void DialogLayoutSettings::ReadSettings()
{ {
const VSettings *settings = qApp->ValentinaSettings(); const VValentinaSettings *settings = qApp->ValentinaSettings();
SetLayoutWidth(settings->GetLayoutWidth()); SetLayoutWidth(settings->GetLayoutWidth());
SetNestingTime(settings->GetNestingTime()); SetNestingTime(settings->GetNestingTime());
SetEfficiencyCoefficient(settings->GetEfficiencyCoefficient()); SetEfficiencyCoefficient(settings->GetEfficiencyCoefficient());
@ -1051,7 +1051,7 @@ void DialogLayoutSettings::ReadSettings()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::WriteSettings() const void DialogLayoutSettings::WriteSettings() const
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetLayoutWidth(GetLayoutWidth()); settings->SetLayoutWidth(GetLayoutWidth());
settings->SetLayoutGroup(GetGroup()); settings->SetLayoutGroup(GetGroup());
settings->SetLayoutPaperHeight(GetPaperHeight()); settings->SetLayoutPaperHeight(GetPaperHeight());

View File

@ -29,7 +29,7 @@
#include "dialognewpattern.h" #include "dialognewpattern.h"
#include "ui_dialognewpattern.h" #include "ui_dialognewpattern.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include <QFileDialog> #include <QFileDialog>

View File

@ -81,7 +81,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
SCASSERT(doc != nullptr) SCASSERT(doc != nullptr)
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); settings->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
patternMaterials = doc->GetPatternMaterials(); patternMaterials = doc->GetPatternMaterials();
@ -951,7 +951,7 @@ void DialogPatternProperties::EditLabel()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::ManagePatternMaterials() void DialogPatternProperties::ManagePatternMaterials()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
DialogPatternMaterials editor(patternMaterials, settings->IsRememberPatternMaterials()); DialogPatternMaterials editor(patternMaterials, settings->IsRememberPatternMaterials());

View File

@ -29,7 +29,7 @@
#include "dialogsavelayout.h" #include "dialogsavelayout.h"
#include "ui_dialogsavelayout.h" #include "ui_dialogsavelayout.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include <QDir> #include <QDir>
@ -903,7 +903,7 @@ void DialogSaveLayout::RemoveFormatFromList(LayoutExportFormats format)
*/ */
void DialogSaveLayout::ReadSettings() void DialogSaveLayout::ReadSettings()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit(); const Unit unit = qApp->patternUnit();
// read Margins top, right, bottom, left // read Margins top, right, bottom, left
@ -957,7 +957,7 @@ void DialogSaveLayout::WriteSettings() const
return; return;
} }
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit(); const Unit unit = qApp->patternUnit();
// write Margins top, right, bottom, left // write Margins top, right, bottom, left

View File

@ -37,7 +37,7 @@
#include "version.h" #include "version.h"
#include "core/vapplication.h" #include "core/vapplication.h"
#include "../vmisc/customevents.h" #include "../vmisc/customevents.h"
#include "../vmisc/vsettings.h" #include "core/vvalentinasettings.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/qxtcsvmodel.h" #include "../vmisc/qxtcsvmodel.h"
#include "../vmisc/vmodifierkey.h" #include "../vmisc/vmodifierkey.h"
@ -301,7 +301,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, [this]() connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
QFont f = ui->plainTextEditPatternMessages->font(); QFont f = ui->plainTextEditPatternMessages->font();
if (f.pointSize() < settings->GetDefMaxPatternMessageFontSize()) if (f.pointSize() < settings->GetDefMaxPatternMessageFontSize())
{ {
@ -313,7 +313,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, [this]() connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
QFont f = ui->plainTextEditPatternMessages->font(); QFont f = ui->plainTextEditPatternMessages->font();
if (f.pointSize() > settings->GetDefMinPatternMessageFontSize()) if (f.pointSize() > settings->GetDefMinPatternMessageFontSize())
{ {
@ -2195,7 +2195,7 @@ void MainWindow::ToolBarTools()
ui->actionIncreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Plus)); ui->actionIncreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Plus));
connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]() connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetLabelFontSize(settings->GetLabelFontSize() + 1); settings->SetLabelFontSize(settings->GetLabelFontSize() + 1);
if (sceneDraw) if (sceneDraw)
{ {
@ -2211,7 +2211,7 @@ void MainWindow::ToolBarTools()
ui->actionDecreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Minus)); ui->actionDecreaseLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Minus));
connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]() connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetLabelFontSize(settings->GetLabelFontSize() - 1); settings->SetLabelFontSize(settings->GetLabelFontSize() - 1);
if (sceneDraw) if (sceneDraw)
{ {
@ -2227,7 +2227,7 @@ void MainWindow::ToolBarTools()
ui->actionOriginalLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_0)); ui->actionOriginalLabelFont->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_0));
connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]() connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]()
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetLabelFontSize(settings->GetDefLabelFontSize()); settings->SetLabelFontSize(settings->GetDefLabelFontSize());
if (sceneDraw) if (sceneDraw)
{ {
@ -4172,7 +4172,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
if (not qApp->GetPatternPath().isEmpty() && VApplication::IsGUIMode()) if (not qApp->GetPatternPath().isEmpty() && VApplication::IsGUIMode())
{ {
qCDebug(vMainWindow, "Updating recent file list."); qCDebug(vMainWindow, "Updating recent file list.");
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
QStringList files = settings->GetRecentFileList(); QStringList files = settings->GetRecentFileList();
files.removeAll(fileName); files.removeAll(fileName);
files.prepend(fileName); files.prepend(fileName);
@ -4201,7 +4201,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
void MainWindow::ReadSettings() void MainWindow::ReadSettings()
{ {
qCDebug(vMainWindow, "Reading settings."); qCDebug(vMainWindow, "Reading settings.");
const VSettings *settings = qApp->ValentinaSettings(); const VValentinaSettings *settings = qApp->ValentinaSettings();
if (settings->status() == QSettings::NoError) if (settings->status() == QSettings::NoError)
{ {
@ -4243,7 +4243,7 @@ void MainWindow::WriteSettings()
{ {
ActionDraw(true); ActionDraw(true);
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(APP_VERSION));

View File

@ -1820,7 +1820,7 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
} }
else else
{ {
VSettings *settings = qApp->ValentinaSettings(); VValentinaSettings *settings = qApp->ValentinaSettings();
pageMargin = QMarginsF(settings->GetTiledPDFMargins(Unit::Mm)); pageMargin = QMarginsF(settings->GetTiledPDFMargins(Unit::Mm));
orientation = settings->GetTiledPDFOrientation(); orientation = settings->GetTiledPDFOrientation();
} }

View File

@ -40,7 +40,7 @@
#include "../ifc/exception/vexceptionundo.h" #include "../ifc/exception/vexceptionundo.h"
#include "../ifc/xml/vpatternconverter.h" #include "../ifc/xml/vpatternconverter.h"
#include "../vmisc/customevents.h" #include "../vmisc/customevents.h"
#include "../vmisc/vsettings.h" #include "../core/vvalentinasettings.h"
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#include "../vmisc/projectversion.h" #include "../vmisc/projectversion.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"

View File

@ -37,7 +37,17 @@
#endif #endif
#define qApp (static_cast<TestVApplication*>(QCoreApplication::instance())) #define qApp (static_cast<TestVApplication*>(QCoreApplication::instance()))
class VTestSettings; class VTestSettings : public VCommonSettings
{
Q_OBJECT
public:
VTestSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr)
: VCommonSettings(format, scope, organization, application, parent)
{
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
}
};
class TestVApplication : public VAbstractApplication class TestVApplication : public VAbstractApplication
{ {
@ -50,7 +60,7 @@ public:
setApplicationName("ValentinaTest"); setApplicationName("ValentinaTest");
setOrganizationName(VER_COMPANYNAME_STR); setOrganizationName(VER_COMPANYNAME_STR);
OpenSettings(); TestVApplication::OpenSettings();
} }
virtual ~TestVApplication() Q_DECL_EQ_DEFAULT; virtual ~TestVApplication() Q_DECL_EQ_DEFAULT;
@ -62,7 +72,7 @@ public:
virtual void OpenSettings() override virtual void OpenSettings() override
{ {
settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), settings = new VTestSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this); QCoreApplication::applicationName(), this);
} }
@ -88,16 +98,4 @@ private:
VTranslateVars *m_trVars; VTranslateVars *m_trVars;
}; };
class VTestSettings : public VCommonSettings
{
Q_OBJECT
public:
VTestSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr)
: VCommonSettings(format, scope, organization, application, parent)
{
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
}
};
#endif // TESTVAPPLICATION_H #endif // TESTVAPPLICATION_H

View File

@ -45,7 +45,6 @@
#include "def.h" #include "def.h"
#include "vcommonsettings.h" #include "vcommonsettings.h"
#include "vlockguard.h" #include "vlockguard.h"
#include "vsettings.h"
class QUndoStack; class QUndoStack;
class VAbstractApplication;// use in define class VAbstractApplication;// use in define

View File

@ -47,6 +47,26 @@
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "../vpatterndb/pmsystems.h" #include "../vpatterndb/pmsystems.h"
const int VCommonSettings::defaultScrollingDuration = 300;
const int VCommonSettings::scrollingDurationMin = 100;
const int VCommonSettings::scrollingDurationMax = 1000;
const int VCommonSettings::defaultScrollingUpdateInterval = 30;
const int VCommonSettings::scrollingUpdateIntervalMin = 10;
const int VCommonSettings::scrollingUpdateIntervalMax = 100;
const qreal VCommonSettings::defaultSensorMouseScale = 2.0;
const qreal VCommonSettings::sensorMouseScaleMin = 1.0;
const qreal VCommonSettings::sensorMouseScaleMax = 10.0;
const qreal VCommonSettings::defaultWheelMouseScale = 45.0;
const qreal VCommonSettings::wheelMouseScaleMin = 1.0;
const qreal VCommonSettings::wheelMouseScaleMax = 100.0;
const qreal VCommonSettings::defaultScrollingAcceleration = 1.3;
const qreal VCommonSettings::scrollingAccelerationMin = 1.0;
const qreal VCommonSettings::scrollingAccelerationMax = 10.0;
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements")))
@ -81,6 +101,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList")))
@ -105,12 +127,24 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, (QLatin1St
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale,
(QLatin1String("scrolling/sensorMouseScale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration")))
// Reading settings file is very expensive, cache curve approximation to speed up getting value // Reading settings file is very expensive, cache curve approximation to speed up getting value
qreal curveApproximationCached = -1; qreal curveApproximationCached = -1;
Q_GLOBAL_STATIC(QString, localeCached) Q_GLOBAL_STATIC(QString, localeCached)
qreal lineWidthCached = 0; qreal lineWidthCached = 0;
int labelFontSizeCached = 0; int labelFontSizeCached = 0;
int pieceShowMainPath = -1; int pieceShowMainPath = -1;
int scrollingDurationCached = -1;
int scrollingUpdateIntervalCached = -1;
qreal scrollingSensorMouseScaleCached = -1;
qreal scrollingWheelMouseScaleCached = -1;
qreal scrollingAccelerationCached = -1;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats) QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
@ -1219,3 +1253,118 @@ qreal VCommonSettings::WidthHairLine() const
{ {
return WidthMainLine()/3.0; return WidthMainLine()/3.0;
} }
//---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetScrollingDuration() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingDurationCached, *settingScrollingDuration, defaultScrollingDuration,
scrollingDurationMin, scrollingDurationMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetScrollingDuration(int duration)
{
scrollingDurationCached = qBound(scrollingDurationMin, duration, scrollingDurationMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingDuration, scrollingDurationCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetScrollingUpdateInterval() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingUpdateIntervalCached, *settingScrollingUpdateInterval,
defaultScrollingUpdateInterval, scrollingUpdateIntervalMin, scrollingUpdateIntervalMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetScrollingUpdateInterval(int updateInterval)
{
scrollingUpdateIntervalCached = qBound(scrollingUpdateIntervalMin, updateInterval, scrollingUpdateIntervalMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingUpdateInterval, scrollingUpdateIntervalCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommonSettings::GetSensorMouseScale() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingSensorMouseScaleCached, *settingScrollingSensorMouseScale,
defaultSensorMouseScale, sensorMouseScaleMin, sensorMouseScaleMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetSensorMouseScale(qreal scale)
{
scrollingSensorMouseScaleCached = qBound(sensorMouseScaleMin, scale, sensorMouseScaleMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingSensorMouseScale, scrollingSensorMouseScaleCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommonSettings::GetWheelMouseScale() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingWheelMouseScaleCached, *settingScrollingWheelMouseScale,
defaultWheelMouseScale, wheelMouseScaleMin, wheelMouseScaleMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetWheelMouseScale(qreal scale)
{
scrollingWheelMouseScaleCached = qBound(wheelMouseScaleMin, scale, wheelMouseScaleMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingWheelMouseScale, scrollingWheelMouseScaleCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommonSettings::GetScrollingAcceleration() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return GetCachedValue(settings, scrollingAccelerationCached, *settingScrollingAcceleration,
defaultScrollingAcceleration, scrollingAccelerationMin, scrollingAccelerationMax);
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetScrollingAcceleration(qreal acceleration)
{
scrollingAccelerationCached = qBound(scrollingAccelerationMin, acceleration, scrollingAccelerationMax);
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingScrollingAcceleration, scrollingAccelerationCached);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::IsOpenGLRender() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return settings.value(*settingPatternUseOpenGLRender, 0).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetOpenGLRender(bool value)
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingPatternUseOpenGLRender, value);
settings.sync();
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetGraphicalOutput() const
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return settings.value(*settingPatternGraphicalOutput, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetGraphicalOutput(const bool &value)
{
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingPatternGraphicalOutput, value);
settings.sync();
}

View File

@ -38,6 +38,8 @@
#include <QStringList> #include <QStringList>
#include <QtGlobal> #include <QtGlobal>
#include "../vlayout/vbank.h"
class VCommonSettings : public QSettings class VCommonSettings : public QSettings
{ {
Q_OBJECT Q_OBJECT
@ -225,6 +227,52 @@ public:
void SetLineWidth(qreal width); void SetLineWidth(qreal width);
qreal WidthMainLine() const; qreal WidthMainLine() const;
qreal WidthHairLine() const; qreal WidthHairLine() const;
static const int defaultScrollingDuration;
static const int scrollingDurationMin;
static const int scrollingDurationMax;
int GetScrollingDuration() const;
void SetScrollingDuration(int duration);
static const int defaultScrollingUpdateInterval;
static const int scrollingUpdateIntervalMin;
static const int scrollingUpdateIntervalMax;
int GetScrollingUpdateInterval() const;
void SetScrollingUpdateInterval(int updateInterval);
static const qreal defaultSensorMouseScale;
static const qreal sensorMouseScaleMin;
static const qreal sensorMouseScaleMax;
qreal GetSensorMouseScale() const;
void SetSensorMouseScale(qreal scale);
static const qreal defaultWheelMouseScale;
static const qreal wheelMouseScaleMin;
static const qreal wheelMouseScaleMax;
qreal GetWheelMouseScale() const;
void SetWheelMouseScale(qreal scale);
static const qreal defaultScrollingAcceleration;
static const qreal scrollingAccelerationMin;
static const qreal scrollingAccelerationMax;
qreal GetScrollingAcceleration() const;
void SetScrollingAcceleration(qreal acceleration);
bool IsOpenGLRender() const;
void SetOpenGLRender(bool value);
bool GetGraphicalOutput() const;
void SetGraphicalOutput(const bool &value);
protected:
template <typename T>
static T GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin,
T valueMax);
template <class T>
static T ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue);
private: private:
Q_DISABLE_COPY(VCommonSettings) Q_DISABLE_COPY(VCommonSettings)
}; };
@ -247,4 +295,42 @@ inline qreal VCommonSettings::MaximalLineWidth()
return 5.0; // mm return 5.0; // mm
} }
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
T VCommonSettings::GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin,
T valueMax)
{
if (cache < 0)
{
cache = qBound(valueMin, ValueOrDef(settings, setting, defValue), valueMax);
}
return cache;
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline T VCommonSettings::ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue)
{
const QVariant val = settings.value(setting, QVariant::fromValue(defValue));
return val.canConvert<T>() ? val.value<T>() : defValue;
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline Cases VCommonSettings::ValueOrDef<Cases>(const QSettings &settings, const QString &setting,
const Cases &defValue)
{
const QVariant val = settings.value(setting, QVariant::fromValue(static_cast<int>(defValue)));
const int g = val.canConvert<int>() ? val.value<int>() : static_cast<int>(defValue);
if (g < static_cast<int>(Cases::CaseThreeGroup) || g >= static_cast<int>(Cases::UnknownCase))
{
return defValue;
}
else
{
return static_cast<Cases>(g);
}
}
#endif // VCOMMONSETTINGS_H #endif // VCOMMONSETTINGS_H

View File

@ -3,18 +3,15 @@
SOURCES += \ SOURCES += \
$$PWD/def.cpp \ $$PWD/def.cpp \
$$PWD/vsettings.cpp \
$$PWD/vabstractapplication.cpp \ $$PWD/vabstractapplication.cpp \
$$PWD/projectversion.cpp \ $$PWD/projectversion.cpp \
$$PWD/vcommonsettings.cpp \ $$PWD/vcommonsettings.cpp \
$$PWD/vtapesettings.cpp \
$$PWD/commandoptions.cpp \ $$PWD/commandoptions.cpp \
$$PWD/qxtcsvmodel.cpp \ $$PWD/qxtcsvmodel.cpp \
$$PWD/vtablesearch.cpp \ $$PWD/vtablesearch.cpp \
$$PWD/dialogs/dialogexporttocsv.cpp \ $$PWD/dialogs/dialogexporttocsv.cpp \
$$PWD/literals.cpp \ $$PWD/literals.cpp \
$$PWD/vmodifierkey.cpp \ $$PWD/vmodifierkey.cpp
$$PWD/vpuzzlesettings.cpp
*msvc*:SOURCES += $$PWD/stable.cpp *msvc*:SOURCES += $$PWD/stable.cpp
@ -29,11 +26,9 @@ HEADERS += \
$$PWD/stable.h \ $$PWD/stable.h \
$$PWD/def.h \ $$PWD/def.h \
$$PWD/vmath.h \ $$PWD/vmath.h \
$$PWD/vsettings.h \
$$PWD/vabstractapplication.h \ $$PWD/vabstractapplication.h \
$$PWD/projectversion.h \ $$PWD/projectversion.h \
$$PWD/vcommonsettings.h \ $$PWD/vcommonsettings.h \
$$PWD/vtapesettings.h \
$$PWD/debugbreak.h \ $$PWD/debugbreak.h \
$$PWD/vlockguard.h \ $$PWD/vlockguard.h \
$$PWD/vsysexits.h \ $$PWD/vsysexits.h \
@ -51,8 +46,7 @@ HEADERS += \
$$PWD/vdatastreamenum.h \ $$PWD/vdatastreamenum.h \
$$PWD/vmodifierkey.h \ $$PWD/vmodifierkey.h \
$$PWD/typedef.h \ $$PWD/typedef.h \
$$PWD/backport/qscopeguard.h \ $$PWD/backport/qscopeguard.h
$$PWD/vpuzzlesettings.h
contains(DEFINES, APPIMAGE) { contains(DEFINES, APPIMAGE) {
SOURCES += \ SOURCES += \

View File

@ -1,37 +0,0 @@
/************************************************************************
**
** @file vpuzzlesettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpuzzlesettings.h"
//---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
:VCommonSettings(format, scope, organization, application, parent)
{
}

View File

@ -56,7 +56,7 @@
#include "vsimplecurve.h" #include "vsimplecurve.h"
#include "vcontrolpointspline.h" #include "vcontrolpointspline.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/vsettings.h" #include "../vmisc/vcommonsettings.h"
#include "vabstractmainwindow.h" #include "vabstractmainwindow.h"
const qreal maxSceneSize = ((20.0 * 1000.0) / 25.4) * PrintDPI; // 20 meters in pixels const qreal maxSceneSize = ((20.0 * 1000.0) / 25.4) * PrintDPI; // 20 meters in pixels
@ -70,7 +70,7 @@ qreal ScrollingSteps(QWheelEvent* wheel_event)
const QPoint numPixels = wheel_event->pixelDelta(); const QPoint numPixels = wheel_event->pixelDelta();
const QPoint numDegrees = wheel_event->angleDelta() / 8; const QPoint numDegrees = wheel_event->angleDelta() / 8;
qreal numSteps = 0; qreal numSteps = 0;
VSettings *settings = qobject_cast<VSettings *>(qApp->Settings()); VCommonSettings *settings = qApp->Settings();
if (not numPixels.isNull()) if (not numPixels.isNull())
{ {
@ -105,7 +105,7 @@ qreal PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event)
scheduledScrollings += numSteps; scheduledScrollings += numSteps;
} }
scheduledScrollings *= qobject_cast<VSettings *>(qApp->Settings())->GetScrollingAcceleration(); scheduledScrollings *= qApp->Settings()->GetScrollingAcceleration();
return scheduledScrollings; return scheduledScrollings;
} }
@ -197,7 +197,7 @@ void GraphicsViewZoom::set_zoom_factor_base(double value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void GraphicsViewZoom::InitScrollingAnimation() void GraphicsViewZoom::InitScrollingAnimation()
{ {
VSettings *settings = qobject_cast<VSettings *>(qApp->Settings()); VCommonSettings *settings = qApp->Settings();
if (not verticalScrollAnim.isNull()) if (not verticalScrollAnim.isNull())
{ {
@ -427,7 +427,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
m_oldCursor(), m_oldCursor(),
m_currentCursor(Qt::ArrowCursor) m_currentCursor(Qt::ArrowCursor)
{ {
VSettings *settings = qobject_cast<VSettings *>(qApp->Settings()); VCommonSettings *settings = qApp->Settings();
if (settings && settings->IsOpenGLRender()) if (settings && settings->IsOpenGLRender())
{ {
QOpenGLWidget *viewport = new QOpenGLWidget(); QOpenGLWidget *viewport = new QOpenGLWidget();