From 52c9257bd0722a029726c8604dda4c02c9d4a7d6 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 31 Jul 2021 09:24:38 +0300 Subject: [PATCH] Highlight active sheet. --- src/app/puzzle/vpcarrousel.cpp | 28 +++++++++++++++++++++++++++- src/app/puzzle/vpcarrousel.h | 1 + src/app/puzzle/vpmaingraphicsview.h | 1 - 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/app/puzzle/vpcarrousel.cpp b/src/app/puzzle/vpcarrousel.cpp index 89de72f83..bb64d2591 100644 --- a/src/app/puzzle/vpcarrousel.cpp +++ b/src/app/puzzle/vpcarrousel.cpp @@ -76,6 +76,7 @@ void VPCarrousel::Refresh() { VPCarrouselSheet carrouselSheet; carrouselSheet.unplaced = true; + carrouselSheet.active = false; carrouselSheet.name = tr("Unplaced pieces"); carrouselSheet.pieces = m_layout->GetUnplacedPieces(); @@ -87,6 +88,7 @@ void VPCarrousel::Refresh() { VPCarrouselSheet carrouselSheet; carrouselSheet.unplaced = false; + carrouselSheet.active = (sheet == m_layout->GetFocusedSheet()); carrouselSheet.name = sheet->GetName(); carrouselSheet.pieces = sheet->GetPieces(); @@ -122,6 +124,7 @@ void VPCarrousel::RefreshSheetNames() for (int i=0; i < sheets.size(); ++i) { m_pieceLists[i+1].name = sheets.at(i)->GetName(); + m_pieceLists[i+1].active = (sheets.at(i) == m_layout->GetFocusedSheet()); ui->comboBoxPieceList->setItemText(i+1, GetSheetName(m_pieceLists.at(i+1))); } } @@ -143,11 +146,24 @@ void VPCarrousel::on_ActivePieceListChanged(int index) if (not m_pieceLists.isEmpty() && index >= 0 && index < m_pieceLists.size()) { ui->listWidget->SetCurrentPieceList(m_pieceLists.at(index).pieces); + + if (index > 0) + { + QList sheets = m_layout->GetSheets(); + + if (index <= sheets.size()) + { + m_layout->SetFocusedSheet(sheets.at(index - 1)); + } + } } else { ui->listWidget->SetCurrentPieceList(QList()); + m_layout->SetFocusedSheet(nullptr); } + + RefreshSheetNames(); } //--------------------------------------------------------------------------------------------------------------------- @@ -202,5 +218,15 @@ void VPCarrousel::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- auto VPCarrousel::GetSheetName(const VPCarrouselSheet &sheet) -> QString { - return sheet.unplaced ? sheet.name : tr("Pieces of ") + sheet.name; + if (sheet.unplaced) + { + return sheet.name; + } + + if (sheet.active) + { + return QStringLiteral("--> %1 %2 <--").arg(tr("Pieces of"), sheet.name); + } + + return tr("Pieces of ") + sheet.name; } diff --git a/src/app/puzzle/vpcarrousel.h b/src/app/puzzle/vpcarrousel.h index 67d4b9170..74e8984a1 100644 --- a/src/app/puzzle/vpcarrousel.h +++ b/src/app/puzzle/vpcarrousel.h @@ -43,6 +43,7 @@ class VPCarrousel; struct VPCarrouselSheet { bool unplaced{true}; + bool active{false}; QString name{}; QList pieces{}; }; diff --git a/src/app/puzzle/vpmaingraphicsview.h b/src/app/puzzle/vpmaingraphicsview.h index a6e7ca162..6b2023daf 100644 --- a/src/app/puzzle/vpmaingraphicsview.h +++ b/src/app/puzzle/vpmaingraphicsview.h @@ -51,7 +51,6 @@ public: */ void RefreshLayout(); - /** * @brief GetScene Returns the scene of the view * @return scene of the view