From 07d03651676189cf793317b0fe23fc8284b951b6 Mon Sep 17 00:00:00 2001 From: Trevor SANDY Date: Wed, 7 Oct 2020 13:42:43 +0200 Subject: [PATCH] 3D Preview - add preview display lock --- common/lc_previewwidget.cpp | 31 +++++++++++++++++++++++++- common/lc_previewwidget.h | 4 ++++ leocad.qrc | 2 ++ resources/action_preview_locked.png | Bin 0 -> 1142 bytes resources/action_preview_unlocked.png | Bin 0 -> 634 bytes 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 resources/action_preview_locked.png create mode 100644 resources/action_preview_unlocked.png diff --git a/common/lc_previewwidget.cpp b/common/lc_previewwidget.cpp index ddb40843..6db432dd 100644 --- a/common/lc_previewwidget.cpp +++ b/common/lc_previewwidget.cpp @@ -21,15 +21,28 @@ lcPreviewDockWidget::lcPreviewDockWidget(QMainWindow* Parent) setCentralWidget(mViewWidget); setMinimumSize(200, 200); + mLockAction = new QAction(QIcon(":/resources/action_preview_unlocked.png"),tr("Lock Preview"), this); + mLockAction->setCheckable(true); + mLockAction->setChecked(false); + mLockAction->setShortcut(tr("Ctrl+L")); + connect(mLockAction, SIGNAL(triggered()), this, SLOT(SetPreviewLock())); + SetPreviewLock(); + + mLabel = new QLabel(QString()); + mToolBar = addToolBar(tr("PreviewDescription")); mToolBar->setObjectName("PreviewDescription"); mToolBar->setMovable(false); - mLabel = new QLabel(QString()); + mToolBar->addAction(mLockAction); + mToolBar->addSeparator(); mToolBar->addWidget(mLabel); } bool lcPreviewDockWidget::SetCurrentPiece(const QString& PartType, int ColorCode) { + if (mLockAction->isChecked()) + return true; + mLabel->setText(tr("Loading...")); if (mPreview->SetCurrentPiece(PartType, ColorCode)) { @@ -45,6 +58,22 @@ void lcPreviewDockWidget::ClearPreview() mLabel->setText(QString()); } +void lcPreviewDockWidget::SetPreviewLock() +{ + bool Locked = mLockAction->isChecked(); + if (Locked && mPreview->GetActiveModel()->GetPieces().IsEmpty()) + { + mLockAction->setChecked(false); + return; + } + QIcon LockIcon(Locked ? ":/resources/action_preview_locked.png" : ":/resources/action_preview_unlocked.png"); + QString State(Locked ? tr("Unlock") : tr("Lock")); + QString StatusTip(tr("%1 the preview display to %2 updates").arg(State).arg(Locked ? "enable" : "disable")); + mLockAction->setToolTip(tr("%1 Preview").arg(State)); + mLockAction->setIcon(LockIcon); + mLockAction->setStatusTip(StatusTip); +} + lcPreviewWidget::lcPreviewWidget() : mLoader(new Project(true/*IsPreview*/)), mViewSphere(this/*Preview*/) diff --git a/common/lc_previewwidget.h b/common/lc_previewwidget.h index d97614dd..392ae5f9 100644 --- a/common/lc_previewwidget.h +++ b/common/lc_previewwidget.h @@ -25,7 +25,11 @@ public: bool SetCurrentPiece(const QString& PartType, int ColorCode); void ClearPreview(); +protected slots: + void SetPreviewLock(); + protected: + QAction* mLockAction; QToolBar* mToolBar; QLabel* mLabel; lcPreviewWidget* mPreview; diff --git a/leocad.qrc b/leocad.qrc index 52466b49..490f9281 100644 --- a/leocad.qrc +++ b/leocad.qrc @@ -30,6 +30,8 @@ resources/action_next.png resources/action_paint.png resources/action_pan.png + resources/action_preview_locked.png + resources/action_preview_unlocked.png resources/action_previous.png resources/action_roll.png resources/action_rotate.png diff --git a/resources/action_preview_locked.png b/resources/action_preview_locked.png new file mode 100644 index 0000000000000000000000000000000000000000..bc15f7538ca96313382e73c434f28c5ff5b67a7d GIT binary patch literal 1142 zcmV-+1d02JP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1Pe(-K~zXfrB%sq z8&w?sX7PB&&N!1ej^m_T+JZ|DD6P5>5rGg_3R2qxe*jV?P81|0Bsd@hcTU`q5L_r_ zQN#fu6)r#zfW%TcG>Nk}aazawtdHM&V>=#`R7CxxFZO%$-uL~saU>8fzyIy2072Fb ze6fBMs6<7TmTtWD!aQGdLFLlBUw(G&#WPo9Du4WFP!-_A&u`!S>YbOa($bgdkL-Gm z_VnXf7*-Cc;T#6j2PeOm7|LNLpM&H18SW(viBb@Rsg&vtzAsjw$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