From e523398c70f685e1c85af3608b31806ed123cab9 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 4 Aug 2019 11:00:41 -0700 Subject: [PATCH] Added option to hide part aliases. Fixes #378. --- common/lc_partselectionwidget.cpp | 24 ++++++++++++++++++++++++ common/lc_partselectionwidget.h | 8 ++++++++ common/lc_profile.cpp | 1 + common/lc_profile.h | 1 + 4 files changed, 34 insertions(+) diff --git a/common/lc_partselectionwidget.cpp b/common/lc_partselectionwidget.cpp index 6d4eae25..56e53c13 100644 --- a/common/lc_partselectionwidget.cpp +++ b/common/lc_partselectionwidget.cpp @@ -42,6 +42,7 @@ lcPartSelectionListModel::lcPartSelectionListModel(QObject* Parent) mShowPartNames = lcGetProfileInt(LC_PROFILE_PARTS_LIST_NAMES); mListMode = lcGetProfileInt(LC_PROFILE_PARTS_LIST_LISTMODE); mShowDecoratedParts = lcGetProfileInt(LC_PROFILE_PARTS_LIST_DECORATED); + mShowPartAliases = lcGetProfileInt(LC_PROFILE_PARTS_LIST_ALIASES); int ColorCode = lcGetProfileInt(LC_PROFILE_PARTS_LIST_COLOR); if (ColorCode == -1) @@ -214,6 +215,8 @@ void lcPartSelectionListModel::SetFilter(const QString& Filter) if (!mShowDecoratedParts && Info->IsPatterned()) Visible = false; + else if (!mShowPartAliases && Info->m_strDescription[0] == '=') + Visible = false; else if (mFilter.isEmpty()) Visible = true; else @@ -407,6 +410,16 @@ void lcPartSelectionListModel::SetShowDecoratedParts(bool Show) SetFilter(mFilter); } +void lcPartSelectionListModel::SetShowPartAliases(bool Show) +{ + if (Show == mShowPartAliases) + return; + + mShowPartAliases = Show; + + SetFilter(mFilter); +} + void lcPartSelectionListModel::SetIconSize(int Size) { if (Size == mIconSize) @@ -503,6 +516,10 @@ void lcPartSelectionListView::CustomContextMenuRequested(QPoint Pos) DecoratedParts->setCheckable(true); DecoratedParts->setChecked(mListModel->GetShowDecoratedParts()); + QAction* PartAliases = Menu->addAction(tr("Show Part Aliases"), this, SLOT(TogglePartAliases())); + PartAliases->setCheckable(true); + PartAliases->setChecked(mListModel->GetShowPartAliases()); + if (mListModel->GetIconSize() != 0) { QAction* ListMode = Menu->addAction(tr("List Mode"), this, SLOT(ToggleListMode())); @@ -557,6 +574,13 @@ void lcPartSelectionListView::ToggleDecoratedParts() lcSetProfileInt(LC_PROFILE_PARTS_LIST_DECORATED, Show); } +void lcPartSelectionListView::TogglePartAliases() +{ + bool Show = !mListModel->GetShowPartAliases(); + mListModel->SetShowPartAliases(Show); + lcSetProfileInt(LC_PROFILE_PARTS_LIST_ALIASES, Show); +} + void lcPartSelectionListView::ToggleListMode() { mListModel->ToggleListMode(); diff --git a/common/lc_partselectionwidget.h b/common/lc_partselectionwidget.h index 5b649cba..ef2f0640 100644 --- a/common/lc_partselectionwidget.h +++ b/common/lc_partselectionwidget.h @@ -50,6 +50,11 @@ public: return mShowDecoratedParts; } + bool GetShowPartAliases() const + { + return mShowPartAliases; + } + int GetIconSize() const { return mIconSize; @@ -80,6 +85,7 @@ public: void SetFilter(const QString& Filter); void RequestPreview(int InfoIndex); void SetShowDecoratedParts(bool Show); + void SetShowPartAliases(bool Show); void SetIconSize(int Size); void SetShowPartNames(bool Show); @@ -99,6 +105,7 @@ protected: bool mShowPartNames; bool mListMode; bool mShowDecoratedParts; + bool mShowPartAliases; QByteArray mFilter; std::pair mRenderFramebuffer; }; @@ -133,6 +140,7 @@ public slots: void SetExtraLargeIcons(); void TogglePartNames(); void ToggleDecoratedParts(); + void TogglePartAliases(); void ToggleListMode(); void ToggleFixedColor(); diff --git a/common/lc_profile.cpp b/common/lc_profile.cpp index 1d83c57b..496d1c9d 100644 --- a/common/lc_profile.cpp +++ b/common/lc_profile.cpp @@ -96,6 +96,7 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] = lcProfileEntry("Settings", "PartsListNames", 0), // LC_PROFILE_PARTS_LIST_NAMES lcProfileEntry("Settings", "PartsListFixedColor", -1), // LC_PROFILE_PARTS_LIST_FIXED_COLOR lcProfileEntry("Settings", "PartsListDecorated", 1), // LC_PROFILE_PARTS_LIST_DECORATED + lcProfileEntry("Settings", "PartsListAliases", 1), // LC_PROFILE_PARTS_LIST_ALIASES lcProfileEntry("Settings", "PartsListListMode", 0), // LC_PROFILE_PARTS_LIST_LISTMODE lcProfileEntry("Defaults", "Author", ""), // LC_PROFILE_DEFAULT_AUTHOR_NAME diff --git a/common/lc_profile.h b/common/lc_profile.h index c5fc9a3d..94d5c1f6 100644 --- a/common/lc_profile.h +++ b/common/lc_profile.h @@ -44,6 +44,7 @@ enum LC_PROFILE_KEY LC_PROFILE_PARTS_LIST_NAMES, LC_PROFILE_PARTS_LIST_COLOR, LC_PROFILE_PARTS_LIST_DECORATED, + LC_PROFILE_PARTS_LIST_ALIASES, LC_PROFILE_PARTS_LIST_LISTMODE, // Defaults for new projects.