Reorganized view sphere and preview options. Fixes #584.

This commit is contained in:
Leonardo Zide 2020-12-30 10:39:04 -08:00
parent 855ca66018
commit 7ec71d8602
12 changed files with 108 additions and 424 deletions

View file

@ -50,14 +50,9 @@ void lcPreferences::LoadDefaults()
mAutoLoadMostRecent = lcGetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT); mAutoLoadMostRecent = lcGetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT);
mRestoreTabLayout = lcGetProfileInt(LC_PROFILE_RESTORE_TAB_LAYOUT); mRestoreTabLayout = lcGetProfileInt(LC_PROFILE_RESTORE_TAB_LAYOUT);
mColorTheme = static_cast<lcColorTheme>(lcGetProfileInt(LC_PROFILE_COLOR_THEME)); mColorTheme = static_cast<lcColorTheme>(lcGetProfileInt(LC_PROFILE_COLOR_THEME));
mPreviewViewSphereEnabled = lcGetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_ENABLED); mPreviewViewSphereEnabled = lcGetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_ENABLED);
mPreviewViewSphereSize = lcGetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE); mPreviewViewSphereSize = lcGetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE);
mPreviewViewSphereLocation = static_cast<lcViewSphereLocation>(lcGetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION)); mPreviewViewSphereLocation = static_cast<lcViewSphereLocation>(lcGetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION));
mPreviewEnabled = lcGetProfileInt(LC_PROFILE_PREVIEW_ENABLED);
mPreviewSize = lcGetProfileInt(LC_PROFILE_PREVIEW_SIZE);
mPreviewLocation = static_cast<lcPreviewLocation>(lcGetProfileInt(LC_PROFILE_PREVIEW_LOCATION));
mPreviewPosition = static_cast<lcPreviewPosition>(lcGetProfileInt(LC_PROFILE_PREVIEW_POSITION));
mDrawPreviewAxis = lcGetProfileInt(LC_PROFILE_PREVIEW_DRAW_AXES); mDrawPreviewAxis = lcGetProfileInt(LC_PROFILE_PREVIEW_DRAW_AXES);
} }
@ -97,14 +92,8 @@ void lcPreferences::SaveDefaults()
lcSetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT, mAutoLoadMostRecent); lcSetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT, mAutoLoadMostRecent);
lcSetProfileInt(LC_PROFILE_RESTORE_TAB_LAYOUT, mRestoreTabLayout); lcSetProfileInt(LC_PROFILE_RESTORE_TAB_LAYOUT, mRestoreTabLayout);
lcSetProfileInt(LC_PROFILE_COLOR_THEME, static_cast<int>(mColorTheme)); lcSetProfileInt(LC_PROFILE_COLOR_THEME, static_cast<int>(mColorTheme));
lcSetProfileInt(LC_PROFILE_PREVIEW_ENABLED, mPreviewViewSphereEnabled);
lcSetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE, mPreviewViewSphereSize); lcSetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE, mPreviewViewSphereSize);
lcSetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION, static_cast<int>(mPreviewViewSphereLocation)); lcSetProfileInt(LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION, static_cast<int>(mPreviewViewSphereLocation));
lcSetProfileInt(LC_PROFILE_PREVIEW_ENABLED, mPreviewEnabled);
lcSetProfileInt(LC_PROFILE_PREVIEW_SIZE, mPreviewSize);
lcSetProfileInt(LC_PROFILE_PREVIEW_LOCATION, static_cast<int>(mPreviewLocation));
lcSetProfileInt(LC_PROFILE_PREVIEW_POSITION, static_cast<int>(mPreviewPosition));
lcSetProfileInt(LC_PROFILE_PREVIEW_DRAW_AXES, mDrawPreviewAxis); lcSetProfileInt(LC_PROFILE_PREVIEW_DRAW_AXES, mDrawPreviewAxis);
} }
@ -1046,8 +1035,6 @@ void lcApplication::ShowPreferencesDialog()
Options.MouseShortcutsModified = false; Options.MouseShortcutsModified = false;
Options.MouseShortcutsDefault = false; Options.MouseShortcutsDefault = false;
lcPreviewPosition PreviewDockable = Options.Preferences.mPreviewPosition;
lcQPreferencesDialog Dialog(gMainWindow, &Options); lcQPreferencesDialog Dialog(gMainWindow, &Options);
if (Dialog.exec() != QDialog::Accepted) if (Dialog.exec() != QDialog::Accepted)
return; return;
@ -1074,11 +1061,6 @@ void lcApplication::ShowPreferencesDialog()
lcSetProfileInt(LC_PROFILE_ANTIALIASING_SAMPLES, Options.AASamples); lcSetProfileInt(LC_PROFILE_ANTIALIASING_SAMPLES, Options.AASamples);
lcSetProfileInt(LC_PROFILE_STUD_LOGO, Options.StudLogo); lcSetProfileInt(LC_PROFILE_STUD_LOGO, Options.StudLogo);
lcPreviewPosition Dockable = Options.Preferences.mPreviewPosition;
if (PreviewDockable != Dockable)
gMainWindow->TogglePreviewWidget(
Dockable == lcPreviewPosition::Dockable);
if (LanguageChanged || LibraryChanged || ColorsChanged || AAChanged) if (LanguageChanged || LibraryChanged || ColorsChanged || AAChanged)
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Some changes will only take effect the next time you start LeoCAD.")); QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Some changes will only take effect the next time you start LeoCAD."));

View file

@ -14,21 +14,6 @@ enum class lcShadingMode
Full Full
}; };
enum class lcPreviewLocation
{
TopLeft,
TopRight,
BottomLeft,
BottomRight
};
enum class lcPreviewPosition
{
Dockable,
Floating,
Viewport // not implemented
};
enum class lcColorTheme enum class lcColorTheme
{ {
Dark, Dark,
@ -78,13 +63,9 @@ public:
bool mRestoreTabLayout; bool mRestoreTabLayout;
lcColorTheme mColorTheme; lcColorTheme mColorTheme;
int mPreviewEnabled;
int mPreviewViewSphereEnabled; int mPreviewViewSphereEnabled;
int mPreviewViewSphereSize; int mPreviewViewSphereSize;
lcViewSphereLocation mPreviewViewSphereLocation; lcViewSphereLocation mPreviewViewSphereLocation;
lcPreviewLocation mPreviewLocation;
lcPreviewPosition mPreviewPosition;
int mPreviewSize;
int mDrawPreviewAxis; int mDrawPreviewAxis;
}; };

View file

@ -554,9 +554,7 @@ void lcMainWindow::CreateMenus()
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_COLORS]); ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_COLORS]);
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_PROPERTIES]); ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_PROPERTIES]);
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_TIMELINE]); ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_TIMELINE]);
lcPreferences& Preferences = lcGetPreferences(); ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_PREVIEW]);
if (Preferences.mPreviewEnabled && Preferences.mPreviewPosition == lcPreviewPosition::Dockable)
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_PREVIEW]);
ToolBarsMenu->addSeparator(); ToolBarsMenu->addSeparator();
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_STANDARD]); ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_STANDARD]);
ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_TOOLS]); ToolBarsMenu->addAction(mActions[LC_VIEW_TOOLBAR_TOOLS]);
@ -775,10 +773,7 @@ void lcMainWindow::CreateToolBars()
mTimelineToolBar->setWidget(mTimelineWidget); mTimelineToolBar->setWidget(mTimelineWidget);
addDockWidget(Qt::RightDockWidgetArea, mTimelineToolBar); addDockWidget(Qt::RightDockWidgetArea, mTimelineToolBar);
// Preview CreatePreviewWidget();
const lcPreferences& Preferences = lcGetPreferences();
if (Preferences.mPreviewPosition == lcPreviewPosition::Dockable)
CreatePreviewWidget();
tabifyDockWidget(mPartsToolBar, mPropertiesToolBar); tabifyDockWidget(mPartsToolBar, mPropertiesToolBar);
tabifyDockWidget(mPropertiesToolBar, mTimelineToolBar); tabifyDockWidget(mPropertiesToolBar, mTimelineToolBar);
@ -805,34 +800,8 @@ lcView* lcMainWindow::CreateView(lcModel* Model)
void lcMainWindow::PreviewPiece(const QString& PartId, int ColorCode) void lcMainWindow::PreviewPiece(const QString& PartId, int ColorCode)
{ {
lcPreferences& Preferences = lcGetPreferences(); if (!mPreviewWidget->SetCurrentPiece(PartId, ColorCode))
QMessageBox::information(this, tr("Error"), tr("Part preview for '%1' failed.").arg(PartId));
if (!Preferences.mPreviewEnabled)
return;
if (Preferences.mPreviewPosition != lcPreviewPosition::Floating)
{
if (mPreviewWidget && mPreviewWidget->SetCurrentPiece(PartId, ColorCode))
return;
}
else
{
lcPreview* Preview = new lcPreview();
lcViewWidget* ViewWidget = new lcViewWidget(nullptr, Preview);
if (Preview && ViewWidget)
{
ViewWidget->setAttribute(Qt::WA_DeleteOnClose, true);
if (Preview->SetCurrentPiece(PartId, ColorCode))
{
ViewWidget->SetPreviewPosition(rect());
return;
}
}
}
QMessageBox::information(this, tr("Error"), tr("Part preview for '%1' failed.").arg(PartId));
} }
void lcMainWindow::CreatePreviewWidget() void lcMainWindow::CreatePreviewWidget()
@ -1003,9 +972,7 @@ QMenu* lcMainWindow::createPopupMenu()
Menu->addAction(mActions[LC_VIEW_TOOLBAR_COLORS]); Menu->addAction(mActions[LC_VIEW_TOOLBAR_COLORS]);
Menu->addAction(mActions[LC_VIEW_TOOLBAR_PROPERTIES]); Menu->addAction(mActions[LC_VIEW_TOOLBAR_PROPERTIES]);
Menu->addAction(mActions[LC_VIEW_TOOLBAR_TIMELINE]); Menu->addAction(mActions[LC_VIEW_TOOLBAR_TIMELINE]);
lcPreferences& Preferences = lcGetPreferences(); Menu->addAction(mActions[LC_VIEW_TOOLBAR_PREVIEW]);
if (Preferences.mPreviewEnabled && Preferences.mPreviewPosition == lcPreviewPosition::Dockable)
Menu->addAction(mActions[LC_VIEW_TOOLBAR_PREVIEW]);
Menu->addSeparator(); Menu->addSeparator();
Menu->addAction(mActions[LC_VIEW_TOOLBAR_STANDARD]); Menu->addAction(mActions[LC_VIEW_TOOLBAR_STANDARD]);
Menu->addAction(mActions[LC_VIEW_TOOLBAR_TOOLS]); Menu->addAction(mActions[LC_VIEW_TOOLBAR_TOOLS]);
@ -1023,9 +990,7 @@ void lcMainWindow::UpdateDockWidgetActions()
mActions[LC_VIEW_TOOLBAR_STANDARD]->setChecked(mStandardToolBar->isVisible()); mActions[LC_VIEW_TOOLBAR_STANDARD]->setChecked(mStandardToolBar->isVisible());
mActions[LC_VIEW_TOOLBAR_TOOLS]->setChecked(mToolsToolBar->isVisible()); mActions[LC_VIEW_TOOLBAR_TOOLS]->setChecked(mToolsToolBar->isVisible());
mActions[LC_VIEW_TOOLBAR_TIME]->setChecked(mTimeToolBar->isVisible()); mActions[LC_VIEW_TOOLBAR_TIME]->setChecked(mTimeToolBar->isVisible());
lcPreferences& Preferences = lcGetPreferences(); mActions[LC_VIEW_TOOLBAR_PREVIEW]->setChecked(mPreviewToolBar->isVisible());
if (Preferences.mPreviewEnabled && Preferences.mPreviewPosition == lcPreviewPosition::Dockable)
mActions[LC_VIEW_TOOLBAR_PREVIEW]->setChecked(mPreviewToolBar->isVisible());
} }
void lcMainWindow::UpdateGamepads() void lcMainWindow::UpdateGamepads()

View file

@ -4288,9 +4288,7 @@ void lcModel::ShowPropertiesDialog()
mProperties = Options.Properties; mProperties = Options.Properties;
lcPreferences& Preferences = lcGetPreferences(); gMainWindow->GetPreviewWidget()->UpdatePreview();
if (Preferences.mPreviewEnabled && Preferences.mPreviewPosition != lcPreviewPosition::Floating)
gMainWindow->GetPreviewWidget()->UpdatePreview();
SaveCheckpoint(tr("Changing Properties")); SaveCheckpoint(tr("Changing Properties"));
} }

View file

@ -131,13 +131,9 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
lcProfileEntry("POVRay", "Width", 1280), // LC_PROFILE_POVRAY_WIDTH lcProfileEntry("POVRay", "Width", 1280), // LC_PROFILE_POVRAY_WIDTH
lcProfileEntry("POVRay", "Height", 720), // LC_PROFILE_POVRAY_HEIGHT lcProfileEntry("POVRay", "Height", 720), // LC_PROFILE_POVRAY_HEIGHT
lcProfileEntry("Settgins", "PreviewViewSphereEnabled", 1), // LC_PROFILE_PREVIEW_VIEW_SPHERE_ENABLED lcProfileEntry("Settgins", "PreviewViewSphereEnabled", 0), // LC_PROFILE_PREVIEW_VIEW_SPHERE_ENABLED
lcProfileEntry("Settings", "PreviewViewSphereSize", 75), // LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE lcProfileEntry("Settings", "PreviewViewSphereSize", 75), // LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE
lcProfileEntry("Settings", "PreviewViewSphereLocation", (int)lcViewSphereLocation::TopRight), // LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION lcProfileEntry("Settings", "PreviewViewSphereLocation", (int)lcViewSphereLocation::TopRight), // LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION
lcProfileEntry("Settings", "PreviewEnabled", 1), // LC_PROFILE_PREVIEW_ENABLED
lcProfileEntry("Settings", "PreviewSize", 300), // LC_PROFILE_PREVIEW_SIZE
lcProfileEntry("Settings", "PreviewLocation", (int)lcPreviewLocation::BottomRight), // LC_PROFILE_PREVIEW_LOCATION
lcProfileEntry("Settings", "PreviewPosition", (int)lcPreviewPosition::Dockable), // LC_PROFILE_PREVIEW_POSITION
lcProfileEntry("Settings", "DrawPreviewAxis", 0), // LC_PROFILE_PREVIEW_DRAW_AXES lcProfileEntry("Settings", "DrawPreviewAxis", 0), // LC_PROFILE_PREVIEW_DRAW_AXES
}; };

View file

@ -82,11 +82,6 @@ enum LC_PROFILE_KEY
LC_PROFILE_PREVIEW_VIEW_SPHERE_ENABLED, LC_PROFILE_PREVIEW_VIEW_SPHERE_ENABLED,
LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE, LC_PROFILE_PREVIEW_VIEW_SPHERE_SIZE,
LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION, LC_PROFILE_PREVIEW_VIEW_SPHERE_LOCATION,
LC_PROFILE_PREVIEW_ENABLED,
LC_PROFILE_PREVIEW_SIZE,
LC_PROFILE_PREVIEW_LOCATION,
LC_PROFILE_PREVIEW_POSITION,
LC_PROFILE_PREVIEW_DRAW_AXES, LC_PROFILE_PREVIEW_DRAW_AXES,
LC_NUM_PROFILE_KEYS LC_NUM_PROFILE_KEYS

View file

@ -71,54 +71,6 @@ void lcViewWidget::SetView(lcView* View)
mView = View; mView = View;
} }
void lcViewWidget::SetPreviewPosition(const QRect& ParentRect)
{
lcPreferences& Preferences = lcGetPreferences();
lcPreview* Preview = reinterpret_cast<lcPreview*>(mView);
setWindowTitle(tr("%1 Preview").arg(Preview->IsModel() ? "Submodel" : "Part"));
int Size[2] = { 300,200 };
if (Preferences.mPreviewSize == 400)
{
Size[0] = 400; Size[1] = 300;
}
mPreferredSize = QSize(Size[0], Size[1]);
const QRect desktop = QApplication::desktop()->geometry();
QPoint pos;
switch (Preferences.mPreviewLocation)
{
case lcPreviewLocation::TopRight:
pos = mapToGlobal(ParentRect.topRight());
break;
case lcPreviewLocation::TopLeft:
pos = mapToGlobal(ParentRect.topLeft());
break;
case lcPreviewLocation::BottomRight:
pos = mapToGlobal(ParentRect.bottomRight());
break;
default:
pos = mapToGlobal(ParentRect.bottomLeft());
break;
}
if (pos.x() < desktop.left())
pos.setX(desktop.left());
if (pos.y() < desktop.top())
pos.setY(desktop.top());
if ((pos.x() + width()) > desktop.right())
pos.setX(desktop.right() - width());
if ((pos.y() + height()) > desktop.bottom())
pos.setY(desktop.bottom() - height());
move(pos);
setMinimumSize(100,100);
show();
}
void lcViewWidget::initializeGL() void lcViewWidget::initializeGL()
{ {
mView->mContext->SetGLContext(context()); mView->mContext->SetGLContext(context());

View file

@ -20,7 +20,6 @@ public:
} }
void SetView(lcView* View); void SetView(lcView* View);
void SetPreviewPosition(const QRect& ParentRect);
QSize sizeHint() const override; QSize sizeHint() const override;

View file

@ -141,30 +141,6 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
ui->PreviewAxisIconCheckBox->setChecked(mOptions->Preferences.mDrawPreviewAxis); ui->PreviewAxisIconCheckBox->setChecked(mOptions->Preferences.mDrawPreviewAxis);
ui->PreviewViewSphereCheckBox->setChecked(mOptions->Preferences.mPreviewViewSphereEnabled);
ui->PreviewLocationCombo->setCurrentIndex((int)mOptions->Preferences.mPreviewLocation);
ui->PreviewPositionCombo->setCurrentIndex((int)mOptions->Preferences.mPreviewPosition);
if (mOptions->Preferences.mPreviewEnabled)
{
switch (mOptions->Preferences.mPreviewSize)
{
case 400:
ui->PreviewSizeCombo->setCurrentIndex(2);
break;
case 300:
ui->PreviewSizeCombo->setCurrentIndex(1);
break;
default: /*Disabled*/
ui->PreviewSizeCombo->setCurrentIndex(0);
break;
}
}
else
ui->PreviewSizeCombo->setCurrentIndex(0);
ui->PreviewViewSphereLocationCombo->setCurrentIndex((int)mOptions->Preferences.mPreviewViewSphereLocation); ui->PreviewViewSphereLocationCombo->setCurrentIndex((int)mOptions->Preferences.mPreviewViewSphereLocation);
if (mOptions->Preferences.mPreviewViewSphereEnabled) if (mOptions->Preferences.mPreviewViewSphereEnabled)
@ -258,13 +234,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
on_gridStuds_toggled(); on_gridStuds_toggled();
on_gridLines_toggled(); on_gridLines_toggled();
on_ViewSphereSizeCombo_currentIndexChanged(ui->ViewSphereSizeCombo->currentIndex()); on_ViewSphereSizeCombo_currentIndexChanged(ui->ViewSphereSizeCombo->currentIndex());
on_PreviewViewSphereSizeCombo_currentIndexChanged(ui->PreviewViewSphereSizeCombo->currentIndex()); on_PreviewViewSphereSizeCombo_currentIndexChanged(ui->PreviewViewSphereSizeCombo->currentIndex());
on_PreviewSizeCombo_currentIndexChanged(ui->PreviewSizeCombo->currentIndex());
on_PreviewPositionCombo_currentIndexChanged(ui->PreviewPositionCombo->currentIndex());
ui->PreviewLocationCombo->setEnabled(
ui->PreviewSizeCombo->currentIndex() != 0 &&
ui->PreviewPositionCombo->currentIndex() != 0);
updateCategories(); updateCategories();
ui->categoriesTree->setCurrentItem(ui->categoriesTree->topLevelItem(0)); ui->categoriesTree->setCurrentItem(ui->categoriesTree->topLevelItem(0));
@ -347,12 +317,15 @@ void lcQPreferencesDialog::accept()
{ {
case 3: case 3:
mOptions->Preferences.mViewSphereSize = 200; mOptions->Preferences.mViewSphereSize = 200;
mOptions->Preferences.mViewSphereEnabled = 1;
break; break;
case 2: case 2:
mOptions->Preferences.mViewSphereSize = 100; mOptions->Preferences.mViewSphereSize = 100;
mOptions->Preferences.mViewSphereEnabled = 1;
break; break;
case 1: case 1:
mOptions->Preferences.mViewSphereSize = 50; mOptions->Preferences.mViewSphereSize = 50;
mOptions->Preferences.mViewSphereEnabled = 1;
break; break;
default: default:
mOptions->Preferences.mViewSphereEnabled = 0; mOptions->Preferences.mViewSphereEnabled = 0;
@ -368,42 +341,27 @@ void lcQPreferencesDialog::accept()
mOptions->Preferences.mDrawPreviewAxis = ui->PreviewAxisIconCheckBox->isChecked(); mOptions->Preferences.mDrawPreviewAxis = ui->PreviewAxisIconCheckBox->isChecked();
mOptions->Preferences.mPreviewLocation = (lcPreviewLocation)ui->PreviewLocationCombo->currentIndex();
mOptions->Preferences.mPreviewPosition = (lcPreviewPosition)ui->PreviewPositionCombo->currentIndex();
switch (ui->PreviewSizeCombo->currentIndex())
{
case 2:
mOptions->Preferences.mPreviewSize = 400;
break;
case 1:
mOptions->Preferences.mPreviewSize = 300;
break;
default:
mOptions->Preferences.mPreviewEnabled = 0;
break;
}
mOptions->Preferences.mPreviewViewSphereLocation = (lcViewSphereLocation)ui->PreviewViewSphereLocationCombo->currentIndex(); mOptions->Preferences.mPreviewViewSphereLocation = (lcViewSphereLocation)ui->PreviewViewSphereLocationCombo->currentIndex();
switch (ui->PreviewViewSphereSizeCombo->currentIndex()) switch (ui->PreviewViewSphereSizeCombo->currentIndex())
{ {
case 3: case 3:
mOptions->Preferences.mPreviewViewSphereSize = 100; mOptions->Preferences.mPreviewViewSphereSize = 100;
mOptions->Preferences.mPreviewViewSphereEnabled = 1;
break; break;
case 2: case 2:
mOptions->Preferences.mPreviewViewSphereSize = 75; mOptions->Preferences.mPreviewViewSphereSize = 75;
mOptions->Preferences.mPreviewViewSphereEnabled = 1;
break; break;
case 1: case 1:
mOptions->Preferences.mPreviewViewSphereSize = 50; mOptions->Preferences.mPreviewViewSphereSize = 50;
mOptions->Preferences.mPreviewViewSphereEnabled = 1;
break; break;
default: default:
mOptions->Preferences.mPreviewViewSphereEnabled = 0;
break; break;
} }
mOptions->Preferences.mPreviewViewSphereEnabled = ui->PreviewViewSphereCheckBox->isChecked();
QDialog::accept(); QDialog::accept();
} }
@ -621,29 +579,9 @@ void lcQPreferencesDialog::on_PreviewViewSphereSizeCombo_currentIndexChanged(int
ui->PreviewViewSphereLocationCombo->setEnabled(Index != 0); ui->PreviewViewSphereLocationCombo->setEnabled(Index != 0);
} }
void lcQPreferencesDialog::on_PreviewSizeCombo_currentIndexChanged(int Index)
{
ui->PreviewLocationCombo->setEnabled(Index != 0);
if (ui->PreviewPositionCombo->currentIndex() != 0)
ui->PreviewPositionCombo->setEnabled(Index != 0);
ui->PreviewAxisIconCheckBox->setEnabled(Index != 0);
ui->PreviewViewSphereCheckBox->setEnabled(Index != 0);
}
void lcQPreferencesDialog::on_PreviewPositionCombo_currentIndexChanged(int Index)
{
ui->PreviewSizeCombo->setEnabled(Index != 0);
ui->PreviewLocationCombo->setEnabled(Index != 0);
}
void lcQPreferencesDialog::on_ViewSphereSizeCombo_currentIndexChanged(int Index) void lcQPreferencesDialog::on_ViewSphereSizeCombo_currentIndexChanged(int Index)
{ {
bool Enabled = Index != 0; ui->ViewSphereLocationCombo->setEnabled(Index != 0);
ui->ViewSphereLocationCombo->setEnabled(Enabled);
ui->ViewSphereColorButton->setEnabled(Enabled);
ui->ViewSphereTextColorButton->setEnabled(Enabled);
ui->ViewSphereHighlightColorButton->setEnabled(Enabled);
} }
void lcQPreferencesDialog::updateCategories() void lcQPreferencesDialog::updateCategories()

View file

@ -74,6 +74,7 @@ public slots:
void on_gridStuds_toggled(); void on_gridStuds_toggled();
void on_gridLines_toggled(); void on_gridLines_toggled();
void on_ViewSphereSizeCombo_currentIndexChanged(int Index); void on_ViewSphereSizeCombo_currentIndexChanged(int Index);
void on_PreviewViewSphereSizeCombo_currentIndexChanged(int Index);
void updateParts(); void updateParts();
void on_newCategory_clicked(); void on_newCategory_clicked();
void on_editCategory_clicked(); void on_editCategory_clicked();
@ -96,10 +97,6 @@ public slots:
void on_studLogo_toggled(); void on_studLogo_toggled();
void MouseTreeItemChanged(QTreeWidgetItem* Current); void MouseTreeItemChanged(QTreeWidgetItem* Current);
void on_PreviewSizeCombo_currentIndexChanged(int Index);
void on_PreviewViewSphereSizeCombo_currentIndexChanged(int Index);
void on_PreviewPositionCombo_currentIndexChanged(int Index);
private: private:
Ui::lcQPreferencesDialog *ui; Ui::lcQPreferencesDialog *ui;

View file

@ -542,23 +542,85 @@
</widget> </widget>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
<string>Interface</string> <string>Views</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_13">
<item> <item>
<widget class="QGroupBox" name="groupBox_6"> <widget class="QGroupBox" name="groupBox_6">
<property name="title"> <property name="title">
<string>Overlays</string> <string>Model Views</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="AxisIconCheckBox"> <widget class="QCheckBox" name="AxisIconCheckBox">
<property name="text"> <property name="text">
<string>Axis icon</string> <string>Axis icon</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QLabel" name="ViewSphereLocationLabel">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>View Sphere:</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="ViewSphereSizeCombo">
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>Small</string>
</property>
</item>
<item>
<property name="text">
<string>Medium</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="ViewSphereLocationCombo">
<item>
<property name="text">
<string>Top Left</string>
</property>
</item>
<item>
<property name="text">
<string>Top Right</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Left</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Right</string>
</property>
</item>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_7"> <spacer name="horizontalSpacer_7">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -628,50 +690,20 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="ViewSphereGroup_2"> <widget class="QGroupBox" name="PreviewGroup">
<property name="title"> <property name="title">
<string>View Sphere</string> <string>Part Preview</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1"> <item row="2" column="0" colspan="2">
<widget class="QComboBox" name="ViewSphereSizeCombo"> <widget class="QCheckBox" name="PreviewAxisIconCheckBox">
<item> <property name="text">
<property name="text"> <string>Axis Icon</string>
<string>Disabled</string> </property>
</property>
</item>
<item>
<property name="text">
<string>Small</string>
</property>
</item>
<item>
<property name="text">
<string>Medium</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="0" column="5"> <item row="1" column="3">
<spacer name="horizontalSpacer_9"> <widget class="QComboBox" name="PreviewViewSphereLocationCombo">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="ViewSphereLocationCombo">
<item> <item>
<property name="text"> <property name="text">
<string>Top Left</string> <string>Top Left</string>
@ -694,34 +726,13 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_24"> <widget class="QLabel" name="PreviewViewSphereLocationLabel">
<property name="text"> <property name="text">
<string>Location:</string> <string>Location:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Preview Location</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Preview Size:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="PreviewViewSphereSizeCombo"> <widget class="QComboBox" name="PreviewViewSphereSizeCombo">
<item> <item>
@ -746,132 +757,14 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="0">
<widget class="QComboBox" name="PreviewViewSphereLocationCombo"> <widget class="QLabel" name="label_8">
<item>
<property name="text">
<string>Top Left</string>
</property>
</item>
<item>
<property name="text">
<string>Top Right</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Left</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Right</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="PreviewGroup">
<property name="title">
<string>Preview</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="2">
<widget class="QLabel" name="label_16">
<property name="text"> <property name="text">
<string>Location:</string> <string>View Sphere:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="1" column="4">
<widget class="QCheckBox" name="PreviewViewSphereCheckBox">
<property name="text">
<string>View Sphere</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QComboBox" name="PreviewPositionCombo">
<item>
<property name="text">
<string>Dockable</string>
</property>
</item>
<item>
<property name="text">
<string>Floating</string>
</property>
</item>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Position:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="PreviewLocationCombo">
<item>
<property name="text">
<string>Top Left</string>
</property>
</item>
<item>
<property name="text">
<string>Top Right</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Left</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Right</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QCheckBox" name="PreviewAxisIconCheckBox">
<property name="text">
<string>Axis Icon</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="PreviewSizeCombo">
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>Small</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
</widget>
</item>
<item row="0" column="6">
<spacer name="horizontalSpacer_11"> <spacer name="horizontalSpacer_11">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -1762,18 +1655,14 @@
<tabstop>HighlightNewParts</tabstop> <tabstop>HighlightNewParts</tabstop>
<tabstop>HighlightNewPartsColor</tabstop> <tabstop>HighlightNewPartsColor</tabstop>
<tabstop>ShadingMode</tabstop> <tabstop>ShadingMode</tabstop>
<tabstop>ViewSphereSizeCombo</tabstop>
<tabstop>ViewSphereLocationCombo</tabstop>
<tabstop>AxisIconCheckBox</tabstop> <tabstop>AxisIconCheckBox</tabstop>
<tabstop>gridStuds</tabstop> <tabstop>gridStuds</tabstop>
<tabstop>gridLines</tabstop> <tabstop>gridLines</tabstop>
<tabstop>gridLineSpacing</tabstop> <tabstop>gridLineSpacing</tabstop>
<tabstop>ViewSphereSizeCombo</tabstop>
<tabstop>ViewSphereLocationCombo</tabstop>
<tabstop>PreviewViewSphereSizeCombo</tabstop> <tabstop>PreviewViewSphereSizeCombo</tabstop>
<tabstop>PreviewViewSphereLocationCombo</tabstop> <tabstop>PreviewViewSphereLocationCombo</tabstop>
<tabstop>PreviewSizeCombo</tabstop>
<tabstop>PreviewLocationCombo</tabstop>
<tabstop>PreviewPositionCombo</tabstop>
<tabstop>PreviewViewSphereCheckBox</tabstop>
<tabstop>PreviewAxisIconCheckBox</tabstop> <tabstop>PreviewAxisIconCheckBox</tabstop>
<tabstop>BackgroundSolidRadio</tabstop> <tabstop>BackgroundSolidRadio</tabstop>
<tabstop>BackgroundSolidColorButton</tabstop> <tabstop>BackgroundSolidColorButton</tabstop>

View file

@ -766,16 +766,12 @@ void lcQPropertiesTree::slotSetValue(int Value)
PieceInfo* Info = (PieceInfo*)editor->itemData(Value).value<void*>(); PieceInfo* Info = (PieceInfo*)editor->itemData(Value).value<void*>();
Model->SetSelectedPiecesPieceInfo(Info); Model->SetSelectedPiecesPieceInfo(Info);
lcPreferences& Preferences = lcGetPreferences(); int ColorIndex = gDefaultColor;
if (Preferences.mPreviewEnabled && Preferences.mPreviewPosition != lcPreviewPosition::Floating) lcObject* Focus = gMainWindow->GetActiveModel()->GetFocusObject();
{ if (Focus && Focus->IsPiece())
int ColorIndex = gDefaultColor; ColorIndex = ((lcPiece*)Focus)->mColorIndex;
lcObject* Focus = gMainWindow->GetActiveModel()->GetFocusObject(); quint32 ColorCode = lcGetColorCode(ColorIndex);
if (Focus && Focus->IsPiece()) gMainWindow->PreviewPiece(Info->mFileName, ColorCode);
ColorIndex = ((lcPiece*)Focus)->mColorIndex;
quint32 ColorCode = lcGetColorCode(ColorIndex);
gMainWindow->PreviewPiece(Info->mFileName, ColorCode);
}
} }
} }
} }
@ -950,12 +946,8 @@ void lcQPropertiesTree::SetPiece(const lcArray<lcObject*>& Selection, lcObject*
Hide = Piece->GetStepHide(); Hide = Piece->GetStepHide();
ColorIndex = Piece->mColorIndex; ColorIndex = Piece->mColorIndex;
Info = Piece->mPieceInfo; Info = Piece->mPieceInfo;
lcPreferences& Preferences = lcGetPreferences(); quint32 ColorCode = lcGetColorCode(ColorIndex);
if (Preferences.mPreviewEnabled && Preferences.mPreviewPosition != lcPreviewPosition::Floating) gMainWindow->PreviewPiece(Info->mFileName, ColorCode);
{
quint32 ColorCode = lcGetColorCode(ColorIndex);
gMainWindow->PreviewPiece(Info->mFileName, ColorCode);
}
} }
else else
{ {