diff --git a/qt/lc_qpreferencesdialog.cpp b/qt/lc_qpreferencesdialog.cpp index a2249895..2916deed 100644 --- a/qt/lc_qpreferencesdialog.cpp +++ b/qt/lc_qpreferencesdialog.cpp @@ -28,7 +28,6 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO delete ui->povrayLayout; #endif - ui->lineWidth->setValidator(new QDoubleValidator(ui->lineWidth)); connect(ui->FadeStepsColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->HighlightNewPartsColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); connect(ui->gridStudColor, SIGNAL(clicked()), this, SLOT(ColorButtonClicked())); @@ -69,7 +68,21 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO else ui->antiAliasingSamples->setCurrentIndex(0); ui->edgeLines->setChecked(mOptions->Preferences.mDrawEdgeLines); - ui->lineWidth->setText(lcFormatValueLocalized(mOptions->Preferences.mLineWidth)); + + if (QGLFormat::defaultFormat().sampleBuffers() && QGLFormat::defaultFormat().samples() > 1) + { + glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, mLineWidthRange); + glGetFloatv(GL_SMOOTH_LINE_WIDTH_GRANULARITY, &mLineWidthGranularity); + } + else + { + glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, mLineWidthRange); + mLineWidthGranularity = 1.0f; + } + + ui->LineWidthSlider->setRange(0, (mLineWidthRange[1] - mLineWidthRange[0]) / mLineWidthGranularity); + ui->LineWidthSlider->setValue((mOptions->Preferences.mLineWidth - mLineWidthRange[0]) / mLineWidthGranularity); + ui->MeshLOD->setChecked(mOptions->Preferences.mAllowLOD); ui->FadeSteps->setChecked(mOptions->Preferences.mFadeSteps); ui->HighlightNewParts->setChecked(mOptions->Preferences.mHighlightNewParts); @@ -137,6 +150,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO on_studLogo_toggled(); on_antiAliasing_toggled(); on_edgeLines_toggled(); + on_LineWidthSlider_valueChanged(); on_FadeSteps_toggled(); on_HighlightNewParts_toggled(); on_gridStuds_toggled(); @@ -205,7 +219,7 @@ void lcQPreferencesDialog::accept() mOptions->AASamples = 2; mOptions->Preferences.mDrawEdgeLines = ui->edgeLines->isChecked(); - mOptions->Preferences.mLineWidth = lcParseValueLocalized(ui->lineWidth->text()); + mOptions->Preferences.mLineWidth = mLineWidthRange[0] + static_cast(ui->LineWidthSlider->value()) * mLineWidthGranularity; mOptions->Preferences.mAllowLOD = ui->MeshLOD->isChecked(); mOptions->Preferences.mFadeSteps = ui->FadeSteps->isChecked(); mOptions->Preferences.mHighlightNewParts = ui->HighlightNewParts->isChecked(); @@ -375,7 +389,14 @@ void lcQPreferencesDialog::on_antiAliasing_toggled() void lcQPreferencesDialog::on_edgeLines_toggled() { - ui->lineWidth->setEnabled(ui->edgeLines->isChecked()); + ui->LineWidthSlider->setEnabled(ui->edgeLines->isChecked()); + ui->LineWidthLabel->setEnabled(ui->edgeLines->isChecked()); +} + +void lcQPreferencesDialog::on_LineWidthSlider_valueChanged() +{ + float Value = mLineWidthRange[0] + static_cast(ui->LineWidthSlider->value()) * mLineWidthGranularity; + ui->LineWidthLabel->setText(QString::number(Value)); } void lcQPreferencesDialog::on_FadeSteps_toggled() diff --git a/qt/lc_qpreferencesdialog.h b/qt/lc_qpreferencesdialog.h index 324c230e..9fe1f670 100644 --- a/qt/lc_qpreferencesdialog.h +++ b/qt/lc_qpreferencesdialog.h @@ -35,6 +35,7 @@ public slots: void ColorButtonClicked(); void on_antiAliasing_toggled(); void on_edgeLines_toggled(); + void on_LineWidthSlider_valueChanged(); void on_FadeSteps_toggled(); void on_HighlightNewParts_toggled(); void on_gridStuds_toggled(); @@ -68,5 +69,7 @@ private: void UpdateMouseTree(); void UpdateMouseTreeItem(int ItemIndex); void setShortcutModified(QTreeWidgetItem *treeItem, bool modified); -}; + float mLineWidthRange[2]; + float mLineWidthGranularity; +}; diff --git a/qt/lc_qpreferencesdialog.ui b/qt/lc_qpreferencesdialog.ui index 6c254830..4bbb64f1 100644 --- a/qt/lc_qpreferencesdialog.ui +++ b/qt/lc_qpreferencesdialog.ui @@ -7,7 +7,7 @@ 0 0 598 - 492 + 494 @@ -391,16 +391,6 @@ - - - - - 75 - 16777215 - - - - @@ -441,13 +431,6 @@ - - - - width - - - @@ -476,6 +459,29 @@ + + + + + 0 + 0 + + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + + + @@ -1220,7 +1226,8 @@ studLogo studLogoCombo edgeLines - lineWidth + LineWidthSlider + LineWidthLabel MeshLOD axisIcon FadeSteps