3D Preview - add preview display lock

This commit is contained in:
Trevor SANDY 2020-10-07 13:42:43 +02:00
parent 11966ca428
commit 07d0365167
5 changed files with 36 additions and 1 deletions

View file

@ -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*/)

View file

@ -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;

View file

@ -30,6 +30,8 @@
<file>resources/action_next.png</file>
<file>resources/action_paint.png</file>
<file>resources/action_pan.png</file>
<file>resources/action_preview_locked.png</file>
<file>resources/action_preview_unlocked.png</file>
<file>resources/action_previous.png</file>
<file>resources/action_roll.png</file>
<file>resources/action_rotate.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B