Refactoring.
Code style.
This commit is contained in:
parent
807964e019
commit
bc1f47921f
|
@ -27,16 +27,16 @@
|
|||
*************************************************************************/
|
||||
#include "vpcarrousel.h"
|
||||
#include "ui_vpcarrousel.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QFontMetrics>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QFontMetrics>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
||||
#include "../vmisc/backport/qoverload.h"
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
||||
#include "../layout/vpsheet.h"
|
||||
#include "../layout/vplayout.h"
|
||||
#include "../layout/vpsheet.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QMenu>
|
||||
|
@ -51,8 +51,8 @@ Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") // NOLINT
|
|||
QT_WARNING_POP
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::VPCarrousel),
|
||||
m_layout(layout)
|
||||
{
|
||||
|
|
|
@ -27,17 +27,17 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vplayout.h"
|
||||
#include "vppiece.h"
|
||||
#include "vpsheet.h"
|
||||
#include "../vpapplication.h"
|
||||
#include "../vptilefactory.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../ifc/xml/vwatermarkconverter.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 <QUndoStack>
|
||||
#include <QPixmapCache>
|
||||
#include <QUndoStack>
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
||||
|
@ -48,10 +48,10 @@ Q_LOGGING_CATEGORY(pLayout, "p.layout") // NOLINT
|
|||
QT_WARNING_POP
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPLayout::VPLayout(QUndoStack *undoStack) :
|
||||
m_undoStack(undoStack)
|
||||
VPLayout::VPLayout(QUndoStack *undoStack)
|
||||
: m_undoStack(undoStack)
|
||||
{
|
||||
SCASSERT(m_undoStack != nullptr)
|
||||
SCASSERT(m_undoStack != nullptr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -60,6 +60,7 @@ VPLayout::~VPLayout()
|
|||
delete m_tileFactory;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
||||
{
|
||||
SCASSERT(undoStack != nullptr)
|
||||
|
@ -79,8 +80,8 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
|||
|
||||
layout->LayoutSettings().SetShowTiles(settings->GetLayoutTileShowTiles());
|
||||
layout->LayoutSettings().SetShowWatermark(settings->GetLayoutTileShowWatermark());
|
||||
layout->LayoutSettings().SetTilesSize(QSizeF(settings->GetLayoutTilePaperWidth(),
|
||||
settings->GetLayoutTilePaperHeight()));
|
||||
layout->LayoutSettings().SetTilesSize(
|
||||
QSizeF(settings->GetLayoutTilePaperWidth(), settings->GetLayoutTilePaperHeight()));
|
||||
layout->LayoutSettings().SetIgnoreTilesMargins(settings->GetLayoutTileIgnoreMargins());
|
||||
layout->LayoutSettings().SetTilesMargins(settings->GetLayoutTileMargins());
|
||||
|
||||
|
@ -204,7 +205,8 @@ auto VPLayout::IsSheetsUniform() const -> bool
|
|||
|
||||
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())
|
||||
{
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#include <QMap>
|
||||
#include <QUuid>
|
||||
|
||||
#include "vplayoutsettings.h"
|
||||
#include "layoutdef.h"
|
||||
#include "vplayoutsettings.h"
|
||||
|
||||
class VPPiece;
|
||||
class VPSheet;
|
||||
|
@ -44,6 +44,7 @@ struct VWatermarkData;
|
|||
class VPLayout : public QObject
|
||||
{
|
||||
Q_OBJECT // NOLINT
|
||||
|
||||
public:
|
||||
~VPLayout() override;
|
||||
|
||||
|
|
|
@ -27,15 +27,14 @@
|
|||
*************************************************************************/
|
||||
#include "vpsheet.h"
|
||||
|
||||
#include "vplayout.h"
|
||||
#include "vppiece.h"
|
||||
#include "../scene/vpgraphicspiece.h"
|
||||
#include "../scene/vpgraphicspiececontrols.h"
|
||||
#include "../scene/vpgraphicssheet.h"
|
||||
#include "../scene/vpgraphicstilegrid.h"
|
||||
#include "../vpapplication.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../scene/vpgraphicssheet.h"
|
||||
#include "../scene/vpgraphicspiece.h"
|
||||
#include "../scene/vpgraphicstilegrid.h"
|
||||
#include "../scene/vpgraphicspiececontrols.h"
|
||||
#include "../scene/vpgraphicstilegrid.h"
|
||||
#include "vplayout.h"
|
||||
#include "vppiece.h"
|
||||
|
||||
// VPSheetSceneData
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -60,10 +59,10 @@ VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheet
|
|||
m_rotationOrigin->setVisible(false);
|
||||
m_scene->addItem(m_rotationOrigin);
|
||||
|
||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::ShowOrigin,
|
||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_ShowOrigin);
|
||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::TransformationOriginChanged,
|
||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::SetTransformationOrigin);
|
||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::ShowOrigin, m_rotationOrigin,
|
||||
&VPGraphicsTransformationOrigin::on_ShowOrigin);
|
||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::TransformationOriginChanged, m_rotationOrigin,
|
||||
&VPGraphicsTransformationOrigin::SetTransformationOrigin);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -305,20 +304,17 @@ void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece)
|
|||
return;
|
||||
}
|
||||
|
||||
QObject::connect(layout.data(), &VPLayout::PieceTransformationChanged, piece,
|
||||
&VPGraphicsPiece::on_RefreshPiece);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceZValueChanged, piece,
|
||||
&VPGraphicsPiece::PieceZValueChanged);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceSelectionChanged,
|
||||
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
||||
QObject::connect(layout.data(), &VPLayout::PiecePositionValidityChanged,
|
||||
piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||
QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged,
|
||||
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
||||
m_rotationControls, &VPGraphicsPieceControls::on_HideHandles);
|
||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_HideHandles);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceTransformationChanged, piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceZValueChanged, piece, &VPGraphicsPiece::PieceZValueChanged);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceSelectionChanged, m_rotationControls,
|
||||
&VPGraphicsPieceControls::on_UpdateControls);
|
||||
QObject::connect(layout.data(), &VPLayout::PiecePositionValidityChanged, piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||
QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged, m_rotationControls,
|
||||
&VPGraphicsPieceControls::on_UpdateControls);
|
||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles, m_rotationControls,
|
||||
&VPGraphicsPieceControls::on_HideHandles);
|
||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles, m_rotationOrigin,
|
||||
&VPGraphicsTransformationOrigin::on_HideHandles);
|
||||
}
|
||||
|
||||
// VPSheet
|
||||
|
@ -571,7 +567,6 @@ void VPSheet::ValidatePieceOutOfBound(const VPPiecePtr &piece) const
|
|||
emit layout->PiecePositionValidityChanged(piece);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -774,8 +769,7 @@ void VPSheet::SetSheetSize(const QSizeF &size)
|
|||
void VPSheet::SetSheetSizeConverted(const QSizeF &size)
|
||||
{
|
||||
Unit unit = SheetUnits();
|
||||
m_size = QSizeF(UnitConvertor(size.width(), unit, Unit::Px),
|
||||
UnitConvertor(size.height(), unit, Unit::Px));
|
||||
m_size = QSizeF(UnitConvertor(size.width(), unit, Unit::Px), UnitConvertor(size.height(), unit, Unit::Px));
|
||||
|
||||
if (m_sceneData != nullptr)
|
||||
{
|
||||
|
@ -793,10 +787,8 @@ auto VPSheet::GetSheetSize() const -> QSizeF
|
|||
auto VPSheet::GetSheetSizeConverted() const -> QSizeF
|
||||
{
|
||||
Unit unit = SheetUnits();
|
||||
QSizeF convertedSize = QSizeF(
|
||||
UnitConvertor(m_size.width(), Unit::Px, unit),
|
||||
UnitConvertor(m_size.height(), Unit::Px, unit)
|
||||
);
|
||||
QSizeF convertedSize =
|
||||
QSizeF(UnitConvertor(m_size.width(), Unit::Px, unit), UnitConvertor(m_size.height(), Unit::Px, unit));
|
||||
|
||||
return convertedSize;
|
||||
}
|
||||
|
|
|
@ -612,9 +612,16 @@ void VApplication::BeginLogging()
|
|||
void VApplication::ClearOldLogs()
|
||||
{
|
||||
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")));
|
||||
QDir::setCurrent(LogDirPath());
|
||||
QDir::setCurrent(logDirPath);
|
||||
|
||||
// Restore working directory
|
||||
auto restore = qScopeGuard([workingDirectory] { QDir::setCurrent(workingDirectory); });
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <QLineF>
|
||||
#include <QSharedData>
|
||||
#include <QtDebug>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../qmuparser/qmutokenparser.h"
|
||||
#include "../vmisc/def.h"
|
||||
|
|
|
@ -408,8 +408,6 @@ void VLayoutExporter::ExportToHPGL2(const QVector<VLayoutPiece> &details) const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VLayoutExporter::SupportPDFConversion() -> bool
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
QProcess proc;
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
|
||||
// Seek pdftops in app bundle or near valentina.exe
|
||||
|
@ -421,13 +419,11 @@ auto VLayoutExporter::SupportPDFConversion() -> bool
|
|||
const int timeout = 15000;
|
||||
if (proc.waitForStarted(timeout) && (proc.waitForFinished(timeout) || proc.state() == QProcess::NotRunning))
|
||||
{
|
||||
res = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
qDebug() << *PDFTOPS << "error" << proc.error() << proc.errorString();
|
||||
}
|
||||
return res;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#include "dialogexporttocsv.h"
|
||||
#include "ui_dialogexporttocsv.h"
|
||||
|
||||
#include "../vcommonsettings.h"
|
||||
#include "../qxtcsvmodel.h"
|
||||
#include "../vabstractapplication.h"
|
||||
#include "../vcommonsettings.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPushButton>
|
||||
#include <QShowEvent>
|
||||
#include <QDebug>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include "../vtextcodec.h"
|
||||
|
@ -71,7 +71,8 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
|||
|
||||
QPushButton *bDefaults = ui->buttonBox->button(QDialogButtonBox::RestoreDefaults);
|
||||
SCASSERT(bDefaults != nullptr)
|
||||
connect(bDefaults, &QPushButton::clicked, this, [this]()
|
||||
connect(bDefaults, &QPushButton::clicked, this,
|
||||
[this]()
|
||||
{
|
||||
ui->comboBoxCodec->blockSignals(true);
|
||||
ui->checkBoxWithHeader->blockSignals(true);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
#include "../vmisc/defglobal.h"
|
||||
#include "../defglobal.h"
|
||||
#endif
|
||||
|
||||
enum class VColorSheme
|
||||
|
|
|
@ -32,37 +32,37 @@
|
|||
#include <QCursor>
|
||||
#include <QEvent>
|
||||
#include <QFlags>
|
||||
#include <QGestureEvent>
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QLineF>
|
||||
#include <QList>
|
||||
#include <QMessageLogger>
|
||||
#include <QMimeData>
|
||||
#include <QMimeDatabase>
|
||||
#include <QMouseEvent>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPainter>
|
||||
#include <QPoint>
|
||||
#include <QScreen>
|
||||
#include <QScrollBar>
|
||||
#include <QThread>
|
||||
#include <QTimeLine>
|
||||
#include <QTransform>
|
||||
#include <QWheelEvent>
|
||||
#include <QWidget>
|
||||
#include <QThread>
|
||||
#include <QGestureEvent>
|
||||
#include <QScreen>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QMimeData>
|
||||
#include <QMimeDatabase>
|
||||
#include <QtMath>
|
||||
|
||||
#include "../ifc/xml/utils.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "vmaingraphicsscene.h"
|
||||
#include "vsimplecurve.h"
|
||||
#include "vcontrolpointspline.h"
|
||||
#include "../vmisc/literals.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/vcommonsettings.h"
|
||||
#include "../vmisc/literals.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
#include "global.h"
|
||||
#include "../ifc/xml/utils.h"
|
||||
#include "vcontrolpointspline.h"
|
||||
#include "vmaingraphicsscene.h"
|
||||
#include "vsimplecurve.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ auto PrioritizeItems(const QList<QGraphicsItem *> &list) -> QList<QGraphicsItem
|
|||
|
||||
return prioritized + nonPrioritized;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView *view)
|
||||
|
@ -174,8 +174,8 @@ void GraphicsViewZoom::gentle_zoom(double factor)
|
|||
FictiveSceneRect(_view->scene(), _view);
|
||||
}
|
||||
_view->centerOn(target_scene_pos);
|
||||
QPointF delta_viewport_pos = target_viewport_pos - QPointF(_view->viewport()->width() / 2.0,
|
||||
_view->viewport()->height() / 2.0);
|
||||
QPointF delta_viewport_pos =
|
||||
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;
|
||||
_view->centerOn(_view->mapToScene(viewport_center.toPoint()));
|
||||
// In the end we just set correct scene size
|
||||
|
@ -379,8 +379,8 @@ void GraphicsViewZoom::StartHorizontalScrollings(QWheelEvent *wheel_event)
|
|||
{
|
||||
if (not wheel_event->pixelDelta().isNull())
|
||||
{ // Native scrolling animation
|
||||
_view->horizontalScrollBar()->setValue(qCeil(_view->horizontalScrollBar()->value() -
|
||||
ScrollingSteps(wheel_event)));
|
||||
_view->horizontalScrollBar()->setValue(
|
||||
qCeil(_view->horizontalScrollBar()->value() - ScrollingSteps(wheel_event)));
|
||||
animFinished();
|
||||
}
|
||||
else
|
||||
|
@ -602,10 +602,9 @@ void VMainGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
|||
{
|
||||
QCursor cur = viewport()->cursor();
|
||||
// No way to restore bitmap from shape and we really don't need this for now.
|
||||
if (m_currentCursor != Qt::BitmapCursor
|
||||
&& cur.shape() == Qt::BitmapCursor
|
||||
&& cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowOpenHand).cacheKey()
|
||||
&& cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowCloseHand).cacheKey())
|
||||
if (m_currentCursor != Qt::BitmapCursor && cur.shape() == Qt::BitmapCursor &&
|
||||
cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowOpenHand).cacheKey() &&
|
||||
cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowCloseHand).cacheKey())
|
||||
{
|
||||
viewport()->setCursor(m_currentCursor);
|
||||
}
|
||||
|
@ -748,8 +747,7 @@ void VMainGraphicsView::EnsureItemVisibleWithDelay(const QGraphicsItem *item, un
|
|||
const QRectF itemRect = item->mapToScene(item->boundingRect()).boundingRect();
|
||||
|
||||
// If item's rect is bigger than view's rect ensureVisible works very unstable.
|
||||
if (itemRect.height() + 2*ymargin < viewRect.height() &&
|
||||
itemRect.width() + 2*xmargin < viewRect.width())
|
||||
if (itemRect.height() + 2 * ymargin < viewRect.height() && itemRect.width() + 2 * xmargin < viewRect.width())
|
||||
{
|
||||
EnsureVisibleWithDelay(item, msecs, xmargin, ymargin);
|
||||
}
|
||||
|
@ -759,8 +757,8 @@ void VMainGraphicsView::EnsureItemVisibleWithDelay(const QGraphicsItem *item, un
|
|||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(item->scene());
|
||||
SCASSERT(currentScene);
|
||||
const QPointF cursorPosition = currentScene->getScenePos();
|
||||
EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale, 10/scale, 10/scale),
|
||||
msecs);
|
||||
EnsureVisibleWithDelay(
|
||||
QRectF(cursorPosition.x() - 5 / scale, cursorPosition.y() - 5 / scale, 10 / scale, 10 / scale), msecs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "../vmisc/svgfont/vsvgfontdatabase.h"
|
||||
#include "../vmisc/vabstractvalapplication.h"
|
||||
#include "vtextgraphicsitem.h"
|
||||
#include <QtMath>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user