Refactoring.
Code style.
This commit is contained in:
parent
807964e019
commit
bc1f47921f
|
@ -27,16 +27,16 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
#include "vpcarrousel.h"
|
#include "vpcarrousel.h"
|
||||||
#include "ui_vpcarrousel.h"
|
#include "ui_vpcarrousel.h"
|
||||||
#include <QVBoxLayout>
|
#include <QFontMetrics>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QFontMetrics>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
||||||
#include "../vmisc/backport/qoverload.h"
|
#include "../vmisc/backport/qoverload.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
||||||
#include "../layout/vpsheet.h"
|
|
||||||
#include "../layout/vplayout.h"
|
#include "../layout/vplayout.h"
|
||||||
|
#include "../layout/vpsheet.h"
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -51,8 +51,8 @@ Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") // NOLINT
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) :
|
VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent)
|
||||||
QWidget(parent),
|
: QWidget(parent),
|
||||||
ui(new Ui::VPCarrousel),
|
ui(new Ui::VPCarrousel),
|
||||||
m_layout(layout)
|
m_layout(layout)
|
||||||
{
|
{
|
||||||
|
@ -122,7 +122,7 @@ void VPCarrousel::Refresh()
|
||||||
|
|
||||||
ui->comboBoxPieceList->blockSignals(true);
|
ui->comboBoxPieceList->blockSignals(true);
|
||||||
|
|
||||||
for (const auto& sheet: qAsConst(m_pieceLists))
|
for (const auto &sheet : qAsConst(m_pieceLists))
|
||||||
{
|
{
|
||||||
ui->comboBoxPieceList->addItem(GetSheetName(sheet), sheet.sheetUuid);
|
ui->comboBoxPieceList->addItem(GetSheetName(sheet), sheet.sheetUuid);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ void VPCarrousel::RefreshSheetNames()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i < m_pieceLists.size(); ++i)
|
for (int i = 0; i < m_pieceLists.size(); ++i)
|
||||||
{
|
{
|
||||||
if (not m_pieceLists.at(i).unplaced)
|
if (not m_pieceLists.at(i).unplaced)
|
||||||
{
|
{
|
||||||
|
@ -257,7 +257,7 @@ void VPCarrousel::SetOrientation(Qt::Orientation orientation)
|
||||||
void VPCarrousel::RefreshOrientation()
|
void VPCarrousel::RefreshOrientation()
|
||||||
{
|
{
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
ui->comboBoxPieceList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
ui->comboBoxPieceList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
|
||||||
|
|
|
@ -27,17 +27,17 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vplayout.h"
|
#include "vplayout.h"
|
||||||
#include "vppiece.h"
|
#include "../ifc/exception/vexception.h"
|
||||||
#include "vpsheet.h"
|
|
||||||
#include "../vpapplication.h"
|
|
||||||
#include "../vptilefactory.h"
|
|
||||||
#include "../ifc/xml/vwatermarkconverter.h"
|
#include "../ifc/xml/vwatermarkconverter.h"
|
||||||
#include "../vformat/vwatermark.h"
|
#include "../vformat/vwatermark.h"
|
||||||
#include "../ifc/exception/vexception.h"
|
#include "../vpapplication.h"
|
||||||
|
#include "../vptilefactory.h"
|
||||||
|
#include "vppiece.h"
|
||||||
|
#include "vpsheet.h"
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QUndoStack>
|
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
|
#include <QUndoStack>
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
||||||
|
@ -48,10 +48,10 @@ Q_LOGGING_CATEGORY(pLayout, "p.layout") // NOLINT
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPLayout::VPLayout(QUndoStack *undoStack) :
|
VPLayout::VPLayout(QUndoStack *undoStack)
|
||||||
m_undoStack(undoStack)
|
: m_undoStack(undoStack)
|
||||||
{
|
{
|
||||||
SCASSERT(m_undoStack != nullptr)
|
SCASSERT(m_undoStack != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -60,6 +60,7 @@ VPLayout::~VPLayout()
|
||||||
delete m_tileFactory;
|
delete m_tileFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
||||||
{
|
{
|
||||||
SCASSERT(undoStack != nullptr)
|
SCASSERT(undoStack != nullptr)
|
||||||
|
@ -69,7 +70,7 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
||||||
|
|
||||||
// create a standard sheet
|
// create a standard sheet
|
||||||
VPSheetPtr sheet(new VPSheet(layout));
|
VPSheetPtr sheet(new VPSheet(layout));
|
||||||
sheet->SetName(tr("Sheet %1").arg(layout->GetAllSheets().size()+1));
|
sheet->SetName(tr("Sheet %1").arg(layout->GetAllSheets().size() + 1));
|
||||||
layout->AddSheet(sheet);
|
layout->AddSheet(sheet);
|
||||||
layout->SetFocusedSheet(sheet);
|
layout->SetFocusedSheet(sheet);
|
||||||
|
|
||||||
|
@ -79,8 +80,8 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
||||||
|
|
||||||
layout->LayoutSettings().SetShowTiles(settings->GetLayoutTileShowTiles());
|
layout->LayoutSettings().SetShowTiles(settings->GetLayoutTileShowTiles());
|
||||||
layout->LayoutSettings().SetShowWatermark(settings->GetLayoutTileShowWatermark());
|
layout->LayoutSettings().SetShowWatermark(settings->GetLayoutTileShowWatermark());
|
||||||
layout->LayoutSettings().SetTilesSize(QSizeF(settings->GetLayoutTilePaperWidth(),
|
layout->LayoutSettings().SetTilesSize(
|
||||||
settings->GetLayoutTilePaperHeight()));
|
QSizeF(settings->GetLayoutTilePaperWidth(), settings->GetLayoutTilePaperHeight()));
|
||||||
layout->LayoutSettings().SetIgnoreTilesMargins(settings->GetLayoutTileIgnoreMargins());
|
layout->LayoutSettings().SetIgnoreTilesMargins(settings->GetLayoutTileIgnoreMargins());
|
||||||
layout->LayoutSettings().SetTilesMargins(settings->GetLayoutTileMargins());
|
layout->LayoutSettings().SetTilesMargins(settings->GetLayoutTileMargins());
|
||||||
|
|
||||||
|
@ -151,7 +152,7 @@ void VPLayout::SetTileFactory(VPTileFactory *newTileFactory)
|
||||||
void VPLayout::RefreshScenePieces() const
|
void VPLayout::RefreshScenePieces() const
|
||||||
{
|
{
|
||||||
const QList<VPSheetPtr> sheets = GetSheets();
|
const QList<VPSheetPtr> sheets = GetSheets();
|
||||||
for (const auto& sheet : sheets)
|
for (const auto &sheet : sheets)
|
||||||
{
|
{
|
||||||
if (not sheet.isNull())
|
if (not sheet.isNull())
|
||||||
{
|
{
|
||||||
|
@ -204,15 +205,16 @@ auto VPLayout::IsSheetsUniform() const -> bool
|
||||||
|
|
||||||
QSizeF sheetSize = sheet->GetSheetSize().toSize();
|
QSizeF sheetSize = sheet->GetSheetSize().toSize();
|
||||||
|
|
||||||
return std::all_of(sheets.begin(), sheets.end(), [sheetSize](const VPSheetPtr &sheet)
|
return std::all_of(sheets.begin(), sheets.end(),
|
||||||
{
|
[sheetSize](const VPSheetPtr &sheet)
|
||||||
if (sheet.isNull())
|
{
|
||||||
{
|
if (sheet.isNull())
|
||||||
return false;
|
{
|
||||||
}
|
return false;
|
||||||
QSize size = sheet->GetSheetSize().toSize();
|
}
|
||||||
return size == sheetSize || size.transposed() == sheetSize;
|
QSize size = sheet->GetSheetSize().toSize();
|
||||||
});
|
return size == sheetSize || size.transposed() == sheetSize;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -227,7 +229,7 @@ auto VPLayout::GetPlacedPieces() const -> QList<VPPiecePtr>
|
||||||
QList<VPPiecePtr> pieces;
|
QList<VPPiecePtr> pieces;
|
||||||
pieces.reserve(m_pieces.size());
|
pieces.reserve(m_pieces.size());
|
||||||
|
|
||||||
for (const auto& piece : m_pieces)
|
for (const auto &piece : m_pieces)
|
||||||
{
|
{
|
||||||
if (not piece->isNull() && piece->Sheet() != VPSheetPtr() && piece->Sheet() != m_trashSheet)
|
if (not piece->isNull() && piece->Sheet() != VPSheetPtr() && piece->Sheet() != m_trashSheet)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +342,7 @@ auto VPLayout::PiecesForSheet(const VPSheetPtr &sheet) const -> QList<VPPiecePtr
|
||||||
QList<VPPiecePtr> list;
|
QList<VPPiecePtr> list;
|
||||||
list.reserve(m_pieces.size());
|
list.reserve(m_pieces.size());
|
||||||
|
|
||||||
for (const auto& piece : m_pieces)
|
for (const auto &piece : m_pieces)
|
||||||
{
|
{
|
||||||
if (not piece.isNull() && piece->Sheet() == sheet)
|
if (not piece.isNull() && piece->Sheet() == sheet)
|
||||||
{
|
{
|
||||||
|
@ -357,7 +359,7 @@ auto VPLayout::PiecesForSheet(const QUuid &uuid) const -> QList<VPPiecePtr>
|
||||||
QList<VPPiecePtr> list;
|
QList<VPPiecePtr> list;
|
||||||
list.reserve(m_pieces.size());
|
list.reserve(m_pieces.size());
|
||||||
|
|
||||||
for (const auto& piece : m_pieces)
|
for (const auto &piece : m_pieces)
|
||||||
{
|
{
|
||||||
if (not piece.isNull())
|
if (not piece.isNull())
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
#include "vplayoutsettings.h"
|
|
||||||
#include "layoutdef.h"
|
#include "layoutdef.h"
|
||||||
|
#include "vplayoutsettings.h"
|
||||||
|
|
||||||
class VPPiece;
|
class VPPiece;
|
||||||
class VPSheet;
|
class VPSheet;
|
||||||
|
@ -44,6 +44,7 @@ struct VWatermarkData;
|
||||||
class VPLayout : public QObject
|
class VPLayout : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~VPLayout() override;
|
~VPLayout() override;
|
||||||
|
|
||||||
|
|
|
@ -27,22 +27,21 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
#include "vpsheet.h"
|
#include "vpsheet.h"
|
||||||
|
|
||||||
#include "vplayout.h"
|
#include "../scene/vpgraphicspiece.h"
|
||||||
#include "vppiece.h"
|
#include "../scene/vpgraphicspiececontrols.h"
|
||||||
|
#include "../scene/vpgraphicssheet.h"
|
||||||
|
#include "../scene/vpgraphicstilegrid.h"
|
||||||
#include "../vpapplication.h"
|
#include "../vpapplication.h"
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
#include "../scene/vpgraphicssheet.h"
|
#include "vplayout.h"
|
||||||
#include "../scene/vpgraphicspiece.h"
|
#include "vppiece.h"
|
||||||
#include "../scene/vpgraphicstilegrid.h"
|
|
||||||
#include "../scene/vpgraphicspiececontrols.h"
|
|
||||||
#include "../scene/vpgraphicstilegrid.h"
|
|
||||||
|
|
||||||
// VPSheetSceneData
|
// VPSheetSceneData
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid)
|
VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid)
|
||||||
: m_layout(layout),
|
: m_layout(layout),
|
||||||
m_scene(new VMainGraphicsScene()),
|
m_scene(new VMainGraphicsScene()),
|
||||||
m_sheetUuid(sheetUuid)
|
m_sheetUuid(sheetUuid)
|
||||||
{
|
{
|
||||||
SCASSERT(not layout.isNull())
|
SCASSERT(not layout.isNull())
|
||||||
|
|
||||||
|
@ -60,10 +59,10 @@ VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheet
|
||||||
m_rotationOrigin->setVisible(false);
|
m_rotationOrigin->setVisible(false);
|
||||||
m_scene->addItem(m_rotationOrigin);
|
m_scene->addItem(m_rotationOrigin);
|
||||||
|
|
||||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::ShowOrigin,
|
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::ShowOrigin, m_rotationOrigin,
|
||||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_ShowOrigin);
|
&VPGraphicsTransformationOrigin::on_ShowOrigin);
|
||||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::TransformationOriginChanged,
|
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::TransformationOriginChanged, m_rotationOrigin,
|
||||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::SetTransformationOrigin);
|
&VPGraphicsTransformationOrigin::SetTransformationOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -95,7 +94,7 @@ void VPSheetSceneData::RefreshPieces()
|
||||||
m_graphicsPieces.clear();
|
m_graphicsPieces.clear();
|
||||||
|
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
if(layout.isNull())
|
if (layout.isNull())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +139,7 @@ void VPSheetSceneData::PrepareForExport()
|
||||||
VPSheetPtr sheet = layout->GetSheet(m_sheetUuid);
|
VPSheetPtr sheet = layout->GetSheet(m_sheetUuid);
|
||||||
m_slectedPiecesTmp = sheet->GetSelectedPieces();
|
m_slectedPiecesTmp = sheet->GetSelectedPieces();
|
||||||
|
|
||||||
for (const auto& piece : qAsConst(m_slectedPiecesTmp))
|
for (const auto &piece : qAsConst(m_slectedPiecesTmp))
|
||||||
{
|
{
|
||||||
if (not piece.isNull())
|
if (not piece.isNull())
|
||||||
{
|
{
|
||||||
|
@ -173,7 +172,7 @@ void VPSheetSceneData::CleanAfterExport()
|
||||||
layout->LayoutSettings().SetShowGrid(m_showGridTmp);
|
layout->LayoutSettings().SetShowGrid(m_showGridTmp);
|
||||||
layout->LayoutSettings().SetShowTiles(m_showTilesTmp);
|
layout->LayoutSettings().SetShowTiles(m_showTilesTmp);
|
||||||
|
|
||||||
for (const auto& piece : qAsConst(m_slectedPiecesTmp))
|
for (const auto &piece : qAsConst(m_slectedPiecesTmp))
|
||||||
{
|
{
|
||||||
if (not piece.isNull())
|
if (not piece.isNull())
|
||||||
{
|
{
|
||||||
|
@ -202,7 +201,7 @@ auto VPSheetSceneData::GraphicsPiecesAsItems() const -> QList<QGraphicsItem *>
|
||||||
QList<QGraphicsItem *> items;
|
QList<QGraphicsItem *> items;
|
||||||
items.reserve(m_graphicsPieces.size());
|
items.reserve(m_graphicsPieces.size());
|
||||||
|
|
||||||
for(auto *item : m_graphicsPieces)
|
for (auto *item : m_graphicsPieces)
|
||||||
{
|
{
|
||||||
items.append(item);
|
items.append(item);
|
||||||
}
|
}
|
||||||
|
@ -220,8 +219,8 @@ auto VPSheetSceneData::RotationControls() const -> VPGraphicsPieceControls *
|
||||||
auto VPSheetSceneData::ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *
|
auto VPSheetSceneData::ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *
|
||||||
{
|
{
|
||||||
auto _graphicsPiece =
|
auto _graphicsPiece =
|
||||||
std::find_if(m_graphicsPieces.begin(), m_graphicsPieces.end(),
|
std::find_if(m_graphicsPieces.begin(), m_graphicsPieces.end(),
|
||||||
[piece](VPGraphicsPiece *graphicPiece) { return graphicPiece->GetPiece() == piece; });
|
[piece](VPGraphicsPiece *graphicPiece) { return graphicPiece->GetPiece() == piece; });
|
||||||
|
|
||||||
if (_graphicsPiece != m_graphicsPieces.end())
|
if (_graphicsPiece != m_graphicsPieces.end())
|
||||||
{
|
{
|
||||||
|
@ -305,28 +304,25 @@ void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(layout.data(), &VPLayout::PieceTransformationChanged, piece,
|
QObject::connect(layout.data(), &VPLayout::PieceTransformationChanged, piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||||
&VPGraphicsPiece::on_RefreshPiece);
|
QObject::connect(layout.data(), &VPLayout::PieceZValueChanged, piece, &VPGraphicsPiece::PieceZValueChanged);
|
||||||
QObject::connect(layout.data(), &VPLayout::PieceZValueChanged, piece,
|
QObject::connect(layout.data(), &VPLayout::PieceSelectionChanged, m_rotationControls,
|
||||||
&VPGraphicsPiece::PieceZValueChanged);
|
&VPGraphicsPieceControls::on_UpdateControls);
|
||||||
QObject::connect(layout.data(), &VPLayout::PieceSelectionChanged,
|
QObject::connect(layout.data(), &VPLayout::PiecePositionValidityChanged, piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||||
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged, m_rotationControls,
|
||||||
QObject::connect(layout.data(), &VPLayout::PiecePositionValidityChanged,
|
&VPGraphicsPieceControls::on_UpdateControls);
|
||||||
piece, &VPGraphicsPiece::on_RefreshPiece);
|
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles, m_rotationControls,
|
||||||
QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged,
|
&VPGraphicsPieceControls::on_HideHandles);
|
||||||
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles, m_rotationOrigin,
|
||||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
&VPGraphicsTransformationOrigin::on_HideHandles);
|
||||||
m_rotationControls, &VPGraphicsPieceControls::on_HideHandles);
|
|
||||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
|
||||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_HideHandles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// VPSheet
|
// VPSheet
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPSheet::VPSheet(const VPLayoutPtr &layout, QObject *parent)
|
VPSheet::VPSheet(const VPLayoutPtr &layout, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_layout(layout),
|
m_layout(layout),
|
||||||
m_sceneData(new VPSheetSceneData(layout, Uuid()))
|
m_sceneData(new VPSheetSceneData(layout, Uuid()))
|
||||||
{
|
{
|
||||||
SCASSERT(not layout.isNull())
|
SCASSERT(not layout.isNull())
|
||||||
|
|
||||||
|
@ -371,7 +367,7 @@ auto VPSheet::GetSelectedPieces() const -> QList<VPPiecePtr>
|
||||||
QList<VPPiecePtr> selected;
|
QList<VPPiecePtr> selected;
|
||||||
selected.reserve(list.size());
|
selected.reserve(list.size());
|
||||||
|
|
||||||
for (const auto& piece : list)
|
for (const auto &piece : list)
|
||||||
{
|
{
|
||||||
if (not piece.isNull() && piece->IsSelected())
|
if (not piece.isNull() && piece->IsSelected())
|
||||||
{
|
{
|
||||||
|
@ -393,7 +389,7 @@ auto VPSheet::GetAsLayoutPieces() const -> QVector<VLayoutPiece>
|
||||||
QVector<VLayoutPiece> details;
|
QVector<VLayoutPiece> details;
|
||||||
details.reserve(pieces.size());
|
details.reserve(pieces.size());
|
||||||
|
|
||||||
for (const auto& piece : pieces)
|
for (const auto &piece : pieces)
|
||||||
{
|
{
|
||||||
if (not piece.isNull())
|
if (not piece.isNull())
|
||||||
{
|
{
|
||||||
|
@ -571,7 +567,6 @@ void VPSheet::ValidatePieceOutOfBound(const VPPiecePtr &piece) const
|
||||||
emit layout->PiecePositionValidityChanged(piece);
|
emit layout->PiecePositionValidityChanged(piece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -620,7 +615,7 @@ void VPSheet::RemoveUnusedLength()
|
||||||
|
|
||||||
QRectF piecesBoundingRect;
|
QRectF piecesBoundingRect;
|
||||||
|
|
||||||
for (const auto& piece : pieces)
|
for (const auto &piece : pieces)
|
||||||
{
|
{
|
||||||
if (not piece.isNull())
|
if (not piece.isNull())
|
||||||
{
|
{
|
||||||
|
@ -698,7 +693,7 @@ auto VPSheet::SceneData() const -> VPSheetSceneData *
|
||||||
void VPSheet::ClearSelection() const
|
void VPSheet::ClearSelection() const
|
||||||
{
|
{
|
||||||
QList<VPPiecePtr> selectedPieces = GetSelectedPieces();
|
QList<VPPiecePtr> selectedPieces = GetSelectedPieces();
|
||||||
for (const auto& piece : selectedPieces)
|
for (const auto &piece : selectedPieces)
|
||||||
{
|
{
|
||||||
if (piece->IsSelected())
|
if (piece->IsSelected())
|
||||||
{
|
{
|
||||||
|
@ -774,8 +769,7 @@ void VPSheet::SetSheetSize(const QSizeF &size)
|
||||||
void VPSheet::SetSheetSizeConverted(const QSizeF &size)
|
void VPSheet::SetSheetSizeConverted(const QSizeF &size)
|
||||||
{
|
{
|
||||||
Unit unit = SheetUnits();
|
Unit unit = SheetUnits();
|
||||||
m_size = QSizeF(UnitConvertor(size.width(), unit, Unit::Px),
|
m_size = QSizeF(UnitConvertor(size.width(), unit, Unit::Px), UnitConvertor(size.height(), unit, Unit::Px));
|
||||||
UnitConvertor(size.height(), unit, Unit::Px));
|
|
||||||
|
|
||||||
if (m_sceneData != nullptr)
|
if (m_sceneData != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -793,10 +787,8 @@ auto VPSheet::GetSheetSize() const -> QSizeF
|
||||||
auto VPSheet::GetSheetSizeConverted() const -> QSizeF
|
auto VPSheet::GetSheetSizeConverted() const -> QSizeF
|
||||||
{
|
{
|
||||||
Unit unit = SheetUnits();
|
Unit unit = SheetUnits();
|
||||||
QSizeF convertedSize = QSizeF(
|
QSizeF convertedSize =
|
||||||
UnitConvertor(m_size.width(), Unit::Px, unit),
|
QSizeF(UnitConvertor(m_size.width(), Unit::Px, unit), UnitConvertor(m_size.height(), Unit::Px, unit));
|
||||||
UnitConvertor(m_size.height(), Unit::Px, unit)
|
|
||||||
);
|
|
||||||
|
|
||||||
return convertedSize;
|
return convertedSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,9 +612,16 @@ void VApplication::BeginLogging()
|
||||||
void VApplication::ClearOldLogs()
|
void VApplication::ClearOldLogs()
|
||||||
{
|
{
|
||||||
const QString workingDirectory = QDir::currentPath(); // Save the app working directory
|
const QString workingDirectory = QDir::currentPath(); // Save the app working directory
|
||||||
QDir logsDir(LogDirPath());
|
const QString logDirPath = LogDirPath();
|
||||||
|
QDir logsDir(logDirPath);
|
||||||
|
|
||||||
|
if (!logsDir.exists())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
logsDir.setNameFilters(QStringList(QStringLiteral("*.log")));
|
logsDir.setNameFilters(QStringList(QStringLiteral("*.log")));
|
||||||
QDir::setCurrent(LogDirPath());
|
QDir::setCurrent(logDirPath);
|
||||||
|
|
||||||
// Restore working directory
|
// Restore working directory
|
||||||
auto restore = qScopeGuard([workingDirectory] { QDir::setCurrent(workingDirectory); });
|
auto restore = qScopeGuard([workingDirectory] { QDir::setCurrent(workingDirectory); });
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
#include <QSharedData>
|
#include <QSharedData>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "../qmuparser/qmutokenparser.h"
|
#include "../qmuparser/qmutokenparser.h"
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
|
|
@ -408,8 +408,6 @@ void VLayoutExporter::ExportToHPGL2(const QVector<VLayoutPiece> &details) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VLayoutExporter::SupportPDFConversion() -> bool
|
auto VLayoutExporter::SupportPDFConversion() -> bool
|
||||||
{
|
{
|
||||||
bool res = false;
|
|
||||||
|
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
|
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
|
||||||
// Seek pdftops in app bundle or near valentina.exe
|
// Seek pdftops in app bundle or near valentina.exe
|
||||||
|
@ -421,13 +419,11 @@ auto VLayoutExporter::SupportPDFConversion() -> bool
|
||||||
const int timeout = 15000;
|
const int timeout = 15000;
|
||||||
if (proc.waitForStarted(timeout) && (proc.waitForFinished(timeout) || proc.state() == QProcess::NotRunning))
|
if (proc.waitForStarted(timeout) && (proc.waitForFinished(timeout) || proc.state() == QProcess::NotRunning))
|
||||||
{
|
{
|
||||||
res = true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
qDebug() << *PDFTOPS << "error" << proc.error() << proc.errorString();
|
||||||
qDebug() << *PDFTOPS << "error" << proc.error() << proc.errorString();
|
return false;
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -29,13 +29,13 @@
|
||||||
#include "dialogexporttocsv.h"
|
#include "dialogexporttocsv.h"
|
||||||
#include "ui_dialogexporttocsv.h"
|
#include "ui_dialogexporttocsv.h"
|
||||||
|
|
||||||
#include "../vcommonsettings.h"
|
|
||||||
#include "../qxtcsvmodel.h"
|
#include "../qxtcsvmodel.h"
|
||||||
#include "../vabstractapplication.h"
|
#include "../vabstractapplication.h"
|
||||||
|
#include "../vcommonsettings.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
#include "../vtextcodec.h"
|
#include "../vtextcodec.h"
|
||||||
|
@ -49,10 +49,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(new Ui::DialogExportToCSV),
|
ui(new Ui::DialogExportToCSV),
|
||||||
isInitialized(false),
|
isInitialized(false),
|
||||||
m_fileName()
|
m_fileName()
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -71,32 +71,33 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
||||||
|
|
||||||
QPushButton *bDefaults = ui->buttonBox->button(QDialogButtonBox::RestoreDefaults);
|
QPushButton *bDefaults = ui->buttonBox->button(QDialogButtonBox::RestoreDefaults);
|
||||||
SCASSERT(bDefaults != nullptr)
|
SCASSERT(bDefaults != nullptr)
|
||||||
connect(bDefaults, &QPushButton::clicked, this, [this]()
|
connect(bDefaults, &QPushButton::clicked, this,
|
||||||
{
|
[this]()
|
||||||
ui->comboBoxCodec->blockSignals(true);
|
{
|
||||||
ui->checkBoxWithHeader->blockSignals(true);
|
ui->comboBoxCodec->blockSignals(true);
|
||||||
ui->buttonGroup->blockSignals(true);
|
ui->checkBoxWithHeader->blockSignals(true);
|
||||||
|
ui->buttonGroup->blockSignals(true);
|
||||||
|
|
||||||
ui->checkBoxWithHeader->setChecked(VAbstractApplication::VApp()->Settings()->GetDefCSVWithHeader());
|
ui->checkBoxWithHeader->setChecked(VAbstractApplication::VApp()->Settings()->GetDefCSVWithHeader());
|
||||||
ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(VCommonSettings::GetDefCSVCodec()));
|
ui->comboBoxCodec->setCurrentIndex(ui->comboBoxCodec->findData(VCommonSettings::GetDefCSVCodec()));
|
||||||
|
|
||||||
SetSeparator(VCommonSettings::GetDefCSVSeparator());
|
SetSeparator(VCommonSettings::GetDefCSVSeparator());
|
||||||
|
|
||||||
ui->comboBoxCodec->blockSignals(false);
|
ui->comboBoxCodec->blockSignals(false);
|
||||||
ui->checkBoxWithHeader->blockSignals(false);
|
ui->checkBoxWithHeader->blockSignals(false);
|
||||||
ui->buttonGroup->blockSignals(false);
|
ui->buttonGroup->blockSignals(false);
|
||||||
|
|
||||||
ShowPreview();
|
ShowPreview();
|
||||||
});
|
});
|
||||||
|
|
||||||
ui->groupBoxPreview->setVisible(false);
|
ui->groupBoxPreview->setVisible(false);
|
||||||
|
|
||||||
connect(ui->comboBoxCodec, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](){ShowPreview();});
|
connect(ui->comboBoxCodec, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() { ShowPreview(); });
|
||||||
connect(ui->checkBoxWithHeader, &QCheckBox::stateChanged, this, [this](){ShowPreview();});
|
connect(ui->checkBoxWithHeader, &QCheckBox::stateChanged, this, [this]() { ShowPreview(); });
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
connect(ui->buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, [this](){ShowPreview();});
|
connect(ui->buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, [this]() { ShowPreview(); });
|
||||||
#else
|
#else
|
||||||
connect(ui->buttonGroup, &QButtonGroup::idClicked, this, [this](){ShowPreview();});
|
connect(ui->buttonGroup, &QButtonGroup::idClicked, this, [this]() { ShowPreview(); });
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,8 +181,8 @@ void DialogExportToCSV::changeEvent(QEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogExportToCSV::showEvent(QShowEvent *event)
|
void DialogExportToCSV::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
QDialog::showEvent( event );
|
QDialog::showEvent(event);
|
||||||
if ( event->spontaneous() )
|
if (event->spontaneous())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +205,7 @@ void DialogExportToCSV::showEvent(QShowEvent *event)
|
||||||
setMinimumSize(size());
|
setMinimumSize(size());
|
||||||
}
|
}
|
||||||
|
|
||||||
isInitialized = true;//first show windows are held
|
isInitialized = true; // first show windows are held
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -229,7 +230,7 @@ void DialogExportToCSV::ShowPreview()
|
||||||
ui->tableWidget->horizontalHeader()->setVisible(IsWithHeader());
|
ui->tableWidget->horizontalHeader()->setVisible(IsWithHeader());
|
||||||
if (IsWithHeader())
|
if (IsWithHeader())
|
||||||
{
|
{
|
||||||
for(int column=0; column<columns; ++column)
|
for (int column = 0; column < columns; ++column)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *header = new QTableWidgetItem(csv.headerText(column));
|
QTableWidgetItem *header = new QTableWidgetItem(csv.headerText(column));
|
||||||
ui->tableWidget->setHorizontalHeaderItem(column, header);
|
ui->tableWidget->setHorizontalHeaderItem(column, header);
|
||||||
|
@ -237,9 +238,9 @@ void DialogExportToCSV::ShowPreview()
|
||||||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int row=0; row < rows; ++row)
|
for (int row = 0; row < rows; ++row)
|
||||||
{
|
{
|
||||||
for(int column=0; column<columns; ++column)
|
for (int column = 0; column < columns; ++column)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *item = new QTableWidgetItem(csv.text(row, column));
|
QTableWidgetItem *item = new QTableWidgetItem(csv.text(row, column));
|
||||||
item->setToolTip(csv.text(row, column));
|
item->setToolTip(csv.text(row, column));
|
||||||
|
@ -260,7 +261,7 @@ void DialogExportToCSV::ShowPreview()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogExportToCSV::SetSeparator(const QChar &separator)
|
void DialogExportToCSV::SetSeparator(const QChar &separator)
|
||||||
{
|
{
|
||||||
switch(separator.toLatin1())
|
switch (separator.toLatin1())
|
||||||
{
|
{
|
||||||
case '\t':
|
case '\t':
|
||||||
ui->radioButtonTab->setChecked(true);
|
ui->radioButtonTab->setChecked(true);
|
||||||
|
@ -294,7 +295,7 @@ auto DialogExportToCSV::MakeHelpCodecsList() -> QString
|
||||||
if (VTextCodec *codec = VTextCodec::codecForMib(list.at(i)))
|
if (VTextCodec *codec = VTextCodec::codecForMib(list.at(i)))
|
||||||
{
|
{
|
||||||
out += QStringLiteral("\t* ") + codec->name();
|
out += QStringLiteral("\t* ") + codec->name();
|
||||||
out += i < list.size()-1 ? QLatin1String(",\n") : QLatin1String(".\n");
|
out += i < list.size() - 1 ? QLatin1String(",\n") : QLatin1String(".\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||||
#include "../vmisc/defglobal.h"
|
#include "../defglobal.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum class VColorSheme
|
enum class VColorSheme
|
||||||
|
|
|
@ -32,37 +32,37 @@
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QFlags>
|
#include <QFlags>
|
||||||
|
#include <QGestureEvent>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMessageLogger>
|
#include <QMessageLogger>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QMimeDatabase>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QOpenGLWidget>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
#include <QScreen>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QThread>
|
||||||
#include <QTimeLine>
|
#include <QTimeLine>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QThread>
|
|
||||||
#include <QGestureEvent>
|
|
||||||
#include <QScreen>
|
|
||||||
#include <QOpenGLWidget>
|
|
||||||
#include <QMimeData>
|
|
||||||
#include <QMimeDatabase>
|
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
|
#include "../ifc/xml/utils.h"
|
||||||
|
#include "../vmisc/compatibility.h"
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "vmaingraphicsscene.h"
|
#include "../vmisc/literals.h"
|
||||||
#include "vsimplecurve.h"
|
|
||||||
#include "vcontrolpointspline.h"
|
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "../vmisc/literals.h"
|
|
||||||
#include "../vmisc/compatibility.h"
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "../ifc/xml/utils.h"
|
#include "vcontrolpointspline.h"
|
||||||
|
#include "vmaingraphicsscene.h"
|
||||||
|
#include "vsimplecurve.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -96,11 +96,11 @@ auto PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event) -> qr
|
||||||
|
|
||||||
if (qFuzzyIsNull(numSteps))
|
if (qFuzzyIsNull(numSteps))
|
||||||
{
|
{
|
||||||
return scheduledScrollings;//Just ignore
|
return scheduledScrollings; // Just ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::signbit(scheduledScrollings) != std::signbit(numSteps))
|
if (std::signbit(scheduledScrollings) != std::signbit(numSteps))
|
||||||
{ // if user moved the wheel in another direction, we reset previously scheduled scalings
|
{ // if user moved the wheel in another direction, we reset previously scheduled scalings
|
||||||
scheduledScrollings = numSteps;
|
scheduledScrollings = numSteps;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -109,7 +109,7 @@ auto PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event) -> qr
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduledScrollings *=
|
scheduledScrollings *=
|
||||||
qobject_cast<VCommonSettings *>(VAbstractApplication::VApp()->Settings())->GetScrollingAcceleration();
|
qobject_cast<VCommonSettings *>(VAbstractApplication::VApp()->Settings())->GetScrollingAcceleration();
|
||||||
|
|
||||||
return scheduledScrollings;
|
return scheduledScrollings;
|
||||||
}
|
}
|
||||||
|
@ -133,10 +133,10 @@ auto PrioritizeItems(const QList<QGraphicsItem *> &list) -> QList<QGraphicsItem
|
||||||
|
|
||||||
return prioritized + nonPrioritized;
|
return prioritized + nonPrioritized;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view)
|
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView *view)
|
||||||
: QObject(view),
|
: QObject(view),
|
||||||
_view(view),
|
_view(view),
|
||||||
_modifiers(Qt::ControlModifier),
|
_modifiers(Qt::ControlModifier),
|
||||||
|
@ -148,11 +148,11 @@ GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view)
|
||||||
horizontalScrollAnim(),
|
horizontalScrollAnim(),
|
||||||
_numScheduledHorizontalScrollings(0)
|
_numScheduledHorizontalScrollings(0)
|
||||||
{
|
{
|
||||||
_view->viewport()->installEventFilter(this);
|
_view->viewport()->installEventFilter(this);
|
||||||
_view->viewport()->grabGesture(Qt::PinchGesture);
|
_view->viewport()->grabGesture(Qt::PinchGesture);
|
||||||
_view->setMouseTracking(true);
|
_view->setMouseTracking(true);
|
||||||
|
|
||||||
InitScrollingAnimation();
|
InitScrollingAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -174,8 +174,8 @@ void GraphicsViewZoom::gentle_zoom(double factor)
|
||||||
FictiveSceneRect(_view->scene(), _view);
|
FictiveSceneRect(_view->scene(), _view);
|
||||||
}
|
}
|
||||||
_view->centerOn(target_scene_pos);
|
_view->centerOn(target_scene_pos);
|
||||||
QPointF delta_viewport_pos = target_viewport_pos - QPointF(_view->viewport()->width() / 2.0,
|
QPointF delta_viewport_pos =
|
||||||
_view->viewport()->height() / 2.0);
|
target_viewport_pos - QPointF(_view->viewport()->width() / 2.0, _view->viewport()->height() / 2.0);
|
||||||
QPointF viewport_center = _view->mapFromScene(target_scene_pos) - delta_viewport_pos;
|
QPointF viewport_center = _view->mapFromScene(target_scene_pos) - delta_viewport_pos;
|
||||||
_view->centerOn(_view->mapToScene(viewport_center.toPoint()));
|
_view->centerOn(_view->mapToScene(viewport_center.toPoint()));
|
||||||
// In the end we just set correct scene size
|
// In the end we just set correct scene size
|
||||||
|
@ -188,7 +188,7 @@ void GraphicsViewZoom::gentle_zoom(double factor)
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void GraphicsViewZoom::set_modifiers(Qt::KeyboardModifiers modifiers)
|
void GraphicsViewZoom::set_modifiers(Qt::KeyboardModifiers modifiers)
|
||||||
{
|
{
|
||||||
_modifiers = modifiers;
|
_modifiers = modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -273,7 +273,7 @@ auto GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) -> bool
|
||||||
* This data need for gentle_zoom().
|
* This data need for gentle_zoom().
|
||||||
* Almoust the same we do in method GraphicsViewZoom::animFinished.
|
* Almoust the same we do in method GraphicsViewZoom::animFinished.
|
||||||
*/
|
*/
|
||||||
QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
|
QMouseEvent *mouse_event = static_cast<QMouseEvent *>(event);
|
||||||
QPointF delta = target_viewport_pos - mouse_event->pos();
|
QPointF delta = target_viewport_pos - mouse_event->pos();
|
||||||
if (qAbs(delta.x()) > 5 || qAbs(delta.y()) > 5)
|
if (qAbs(delta.x()) > 5 || qAbs(delta.y()) > 5)
|
||||||
{
|
{
|
||||||
|
@ -331,25 +331,25 @@ void GraphicsViewZoom::FictiveSceneRect(QGraphicsScene *sc, QGraphicsView *view)
|
||||||
SCASSERT(sc != nullptr)
|
SCASSERT(sc != nullptr)
|
||||||
SCASSERT(view != nullptr)
|
SCASSERT(view != nullptr)
|
||||||
|
|
||||||
//Calculate view rect
|
// Calculate view rect
|
||||||
//to receive the currently visible area, map the widgets bounds to the scene
|
// to receive the currently visible area, map the widgets bounds to the scene
|
||||||
const QPointF a = view->mapToScene(0, 0 );
|
const QPointF a = view->mapToScene(0, 0);
|
||||||
const QPointF b = view->mapToScene(view->viewport()->width(), view->viewport()->height());
|
const QPointF b = view->mapToScene(view->viewport()->width(), view->viewport()->height());
|
||||||
QRectF viewRect = QRectF( a, b );
|
QRectF viewRect = QRectF(a, b);
|
||||||
|
|
||||||
//Scale view
|
// Scale view
|
||||||
QLineF topLeftRay(viewRect.center(), viewRect.topLeft());
|
QLineF topLeftRay(viewRect.center(), viewRect.topLeft());
|
||||||
topLeftRay.setLength(topLeftRay.length()*2);
|
topLeftRay.setLength(topLeftRay.length() * 2);
|
||||||
|
|
||||||
QLineF bottomRightRay(viewRect.center(), viewRect.bottomRight());
|
QLineF bottomRightRay(viewRect.center(), viewRect.bottomRight());
|
||||||
bottomRightRay.setLength(bottomRightRay.length()*2);
|
bottomRightRay.setLength(bottomRightRay.length() * 2);
|
||||||
|
|
||||||
viewRect = QRectF(topLeftRay.p2(), bottomRightRay.p2());
|
viewRect = QRectF(topLeftRay.p2(), bottomRightRay.p2());
|
||||||
|
|
||||||
//Calculate scene rect
|
// Calculate scene rect
|
||||||
const QRectF sceneRect = sc->sceneRect();
|
const QRectF sceneRect = sc->sceneRect();
|
||||||
|
|
||||||
//Unite two rects
|
// Unite two rects
|
||||||
const QRectF newRect = sceneRect.united(viewRect);
|
const QRectF newRect = sceneRect.united(viewRect);
|
||||||
|
|
||||||
sc->setSceneRect(newRect);
|
sc->setSceneRect(newRect);
|
||||||
|
@ -379,8 +379,8 @@ void GraphicsViewZoom::StartHorizontalScrollings(QWheelEvent *wheel_event)
|
||||||
{
|
{
|
||||||
if (not wheel_event->pixelDelta().isNull())
|
if (not wheel_event->pixelDelta().isNull())
|
||||||
{ // Native scrolling animation
|
{ // Native scrolling animation
|
||||||
_view->horizontalScrollBar()->setValue(qCeil(_view->horizontalScrollBar()->value() -
|
_view->horizontalScrollBar()->setValue(
|
||||||
ScrollingSteps(wheel_event)));
|
qCeil(_view->horizontalScrollBar()->value() - ScrollingSteps(wheel_event)));
|
||||||
animFinished();
|
animFinished();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -424,13 +424,13 @@ const unsigned long VMainGraphicsView::scrollDelay = 160;
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VMainGraphicsView::VMainGraphicsView(QWidget *parent)
|
VMainGraphicsView::VMainGraphicsView(QWidget *parent)
|
||||||
: QGraphicsView(parent),
|
: QGraphicsView(parent),
|
||||||
zoom(nullptr),
|
zoom(nullptr),
|
||||||
showToolOptions(true),
|
showToolOptions(true),
|
||||||
isAllowRubberBand(true),
|
isAllowRubberBand(true),
|
||||||
m_ptStartPos(),
|
m_ptStartPos(),
|
||||||
m_oldCursor(),
|
m_oldCursor(),
|
||||||
m_currentCursor(Qt::ArrowCursor)
|
m_currentCursor(Qt::ArrowCursor)
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
|
||||||
this->setInteractive(true);
|
this->setInteractive(true);
|
||||||
SetAntialiasing(true);
|
SetAntialiasing(true);
|
||||||
|
|
||||||
connect(zoom, &GraphicsViewZoom::zoomed, this, [this](){emit ScaleChanged(transform().m11());});
|
connect(zoom, &GraphicsViewZoom::zoomed, this, [this]() { emit ScaleChanged(transform().m11()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -488,7 +488,7 @@ void VMainGraphicsView::ZoomOut()
|
||||||
// See issue #532: Unexpected error occurs when zoom out image.
|
// See issue #532: Unexpected error occurs when zoom out image.
|
||||||
if (this->transform().m11() >= MinScale())
|
if (this->transform().m11() >= MinScale())
|
||||||
{
|
{
|
||||||
scale(1.0/1.1, 1.0/1.1);
|
scale(1.0 / 1.1, 1.0 / 1.1);
|
||||||
VMainGraphicsView::NewSceneRect(this->scene(), this);
|
VMainGraphicsView::NewSceneRect(this->scene(), this);
|
||||||
emit ScaleChanged(transform().m11());
|
emit ScaleChanged(transform().m11());
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *event)
|
||||||
auto *scene = qobject_cast<VMainGraphicsScene *>(this->scene());
|
auto *scene = qobject_cast<VMainGraphicsScene *>(this->scene());
|
||||||
const QList<QGraphicsItem *> list = items(event->pos());
|
const QList<QGraphicsItem *> list = items(event->pos());
|
||||||
if (list.isEmpty() || (scene && scene->IsNonInteractive()))
|
if (list.isEmpty() || (scene && scene->IsNonInteractive()))
|
||||||
{// Only when the user clicks on the scene background or non interactive scene
|
{ // Only when the user clicks on the scene background or non interactive scene
|
||||||
m_ptStartPos = event->pos();
|
m_ptStartPos = event->pos();
|
||||||
m_oldCursor = viewport()->cursor();
|
m_oldCursor = viewport()->cursor();
|
||||||
QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag);
|
QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag);
|
||||||
|
@ -602,10 +602,9 @@ void VMainGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QCursor cur = viewport()->cursor();
|
QCursor cur = viewport()->cursor();
|
||||||
// No way to restore bitmap from shape and we really don't need this for now.
|
// No way to restore bitmap from shape and we really don't need this for now.
|
||||||
if (m_currentCursor != Qt::BitmapCursor
|
if (m_currentCursor != Qt::BitmapCursor && cur.shape() == Qt::BitmapCursor &&
|
||||||
&& cur.shape() == Qt::BitmapCursor
|
cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowOpenHand).cacheKey() &&
|
||||||
&& cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowOpenHand).cacheKey()
|
cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowCloseHand).cacheKey())
|
||||||
&& cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowCloseHand).cacheKey())
|
|
||||||
{
|
{
|
||||||
viewport()->setCursor(m_currentCursor);
|
viewport()->setCursor(m_currentCursor);
|
||||||
}
|
}
|
||||||
|
@ -633,8 +632,8 @@ void VMainGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
||||||
*/
|
*/
|
||||||
void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
|
void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
QGraphicsView::mouseReleaseEvent ( event ); // First because need to hide a rubber band
|
QGraphicsView::mouseReleaseEvent(event); // First because need to hide a rubber band
|
||||||
QGraphicsView::setDragMode( QGraphicsView::NoDrag );
|
QGraphicsView::setDragMode(QGraphicsView::NoDrag);
|
||||||
if (event->button() == Qt::MiddleButton)
|
if (event->button() == Qt::MiddleButton)
|
||||||
{
|
{
|
||||||
viewport()->setCursor(m_oldCursor);
|
viewport()->setCursor(m_oldCursor);
|
||||||
|
@ -649,7 +648,7 @@ void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
void VMainGraphicsView::mouseDoubleClickEvent(QMouseEvent *event)
|
void VMainGraphicsView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton &&
|
if (event->button() == Qt::LeftButton &&
|
||||||
VAbstractApplication::VApp()->Settings()->IsDoubleClickZoomFitBestCurrentPP())
|
VAbstractApplication::VApp()->Settings()->IsDoubleClickZoomFitBestCurrentPP())
|
||||||
{
|
{
|
||||||
emit ZoomFitBestCurrent();
|
emit ZoomFitBestCurrent();
|
||||||
}
|
}
|
||||||
|
@ -748,8 +747,7 @@ void VMainGraphicsView::EnsureItemVisibleWithDelay(const QGraphicsItem *item, un
|
||||||
const QRectF itemRect = item->mapToScene(item->boundingRect()).boundingRect();
|
const QRectF itemRect = item->mapToScene(item->boundingRect()).boundingRect();
|
||||||
|
|
||||||
// If item's rect is bigger than view's rect ensureVisible works very unstable.
|
// If item's rect is bigger than view's rect ensureVisible works very unstable.
|
||||||
if (itemRect.height() + 2*ymargin < viewRect.height() &&
|
if (itemRect.height() + 2 * ymargin < viewRect.height() && itemRect.width() + 2 * xmargin < viewRect.width())
|
||||||
itemRect.width() + 2*xmargin < viewRect.width())
|
|
||||||
{
|
{
|
||||||
EnsureVisibleWithDelay(item, msecs, xmargin, ymargin);
|
EnsureVisibleWithDelay(item, msecs, xmargin, ymargin);
|
||||||
}
|
}
|
||||||
|
@ -759,8 +757,8 @@ void VMainGraphicsView::EnsureItemVisibleWithDelay(const QGraphicsItem *item, un
|
||||||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(item->scene());
|
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(item->scene());
|
||||||
SCASSERT(currentScene);
|
SCASSERT(currentScene);
|
||||||
const QPointF cursorPosition = currentScene->getScenePos();
|
const QPointF cursorPosition = currentScene->getScenePos();
|
||||||
EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale, 10/scale, 10/scale),
|
EnsureVisibleWithDelay(
|
||||||
msecs);
|
QRectF(cursorPosition.x() - 5 / scale, cursorPosition.y() - 5 / scale, 10 / scale, 10 / scale), msecs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,15 +842,15 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG
|
||||||
|
|
||||||
if (item == nullptr)
|
if (item == nullptr)
|
||||||
{
|
{
|
||||||
//Calculate view rect
|
// Calculate view rect
|
||||||
const QRectF viewRect = SceneVisibleArea(view);
|
const QRectF viewRect = SceneVisibleArea(view);
|
||||||
|
|
||||||
//Calculate scene rect
|
// Calculate scene rect
|
||||||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(sc);
|
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(sc);
|
||||||
SCASSERT(currentScene)
|
SCASSERT(currentScene)
|
||||||
const QRectF itemsRect = currentScene->VisibleItemsBoundingRect();
|
const QRectF itemsRect = currentScene->VisibleItemsBoundingRect();
|
||||||
|
|
||||||
//Unite two rects
|
// Unite two rects
|
||||||
sc->setSceneRect(itemsRect.united(viewRect));
|
sc->setSceneRect(itemsRect.united(viewRect));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -861,7 +859,7 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG
|
||||||
const QList<QGraphicsItem *> children = item->childItems();
|
const QList<QGraphicsItem *> children = item->childItems();
|
||||||
for (auto *child : children)
|
for (auto *child : children)
|
||||||
{
|
{
|
||||||
if(child->isVisible())
|
if (child->isVisible())
|
||||||
{
|
{
|
||||||
rect = rect.united(child->sceneBoundingRect());
|
rect = rect.united(child->sceneBoundingRect());
|
||||||
}
|
}
|
||||||
|
@ -878,6 +876,6 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG
|
||||||
auto VMainGraphicsView::SceneVisibleArea(QGraphicsView *view) -> QRectF
|
auto VMainGraphicsView::SceneVisibleArea(QGraphicsView *view) -> QRectF
|
||||||
{
|
{
|
||||||
SCASSERT(view != nullptr)
|
SCASSERT(view != nullptr)
|
||||||
//to receive the currently visible area, map the widgets bounds to the scene
|
// to receive the currently visible area, map the widgets bounds to the scene
|
||||||
return QRectF(view->mapToScene(0, 0), view->mapToScene(view->width(), view->height()));
|
return QRectF(view->mapToScene(0, 0), view->mapToScene(view->width(), view->height()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
#include "../vmisc/svgfont/vsvgfontdatabase.h"
|
#include "../vmisc/svgfont/vsvgfontdatabase.h"
|
||||||
#include "../vmisc/vabstractvalapplication.h"
|
#include "../vmisc/vabstractvalapplication.h"
|
||||||
#include "vtextgraphicsitem.h"
|
#include "vtextgraphicsitem.h"
|
||||||
#include <QtMath>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user