Skip to content

Commit

Permalink
Merge pull request #19375 from mathesoncalum/13242-style_page_recall
Browse files Browse the repository at this point in the history
Fix #13242: Style dialog now opens at last used page
  • Loading branch information
RomanPudashkin authored Sep 13, 2023
2 parents f4b6b1b + d3e0022 commit 1c4889f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/notation/view/widgets/editstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,10 +1043,11 @@ EditStyle::EditStyle(QWidget* parent)
resetTabStylesButton->setVisible(false);

connect(textStyles, &QListWidget::currentRowChanged, this, &EditStyle::textStyleChanged);
textStyles->setCurrentRow(0);
textStyles->setCurrentRow(s_lastSubPageRow);

connect(pageList, &QListWidget::currentRowChanged, pageStack, &QStackedWidget::setCurrentIndex);
pageList->setCurrentRow(0);
connect(pageList, &QListWidget::currentRowChanged, this, &EditStyle::on_pageRowSelectionChanged);
pageList->setCurrentRow(s_lastPageRow);

adjustPagesStackSize(0);

Expand Down Expand Up @@ -1280,6 +1281,10 @@ QString EditStyle::currentSubPageCode() const
return m_currentSubPageCode;
}

int EditStyle::s_lastPageRow = 0;

int EditStyle::s_lastSubPageRow = 0;

QString EditStyle::pageCodeForElement(const EngravingItem* element)
{
IF_ASSERT_FAILED(element) {
Expand Down Expand Up @@ -1569,6 +1574,15 @@ void EditStyle::on_resetTabStylesButton_clicked()
}
}

//---------------------------------------------------------
// On pageRowSelectionChanged
//---------------------------------------------------------

void EditStyle::on_pageRowSelectionChanged()
{
s_lastPageRow = pageList->currentRow();
}

//---------------------------------------------------------
// unhandledType
//---------------------------------------------------------
Expand Down Expand Up @@ -2290,6 +2304,8 @@ void EditStyle::textStyleChanged(int row)
styleName->setText(score->getTextStyleUserName(tid).qTranslated());
styleName->setEnabled(int(tid) >= int(TextStyleType::USER1));
resetTextStyleName->setEnabled(styleName->text() != TConv::translatedUserName(tid));

s_lastSubPageRow = row;
}

//---------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/notation/view/widgets/editstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,17 @@ private slots:
void on_buttonTogglePagelist_clicked();
void on_resetStylesButton_clicked();
void on_resetTabStylesButton_clicked();
void on_pageRowSelectionChanged();
void editUserStyleName();
void endEditUserStyleName();
void resetUserStyleName();

private:
QString m_currentPageCode;
QString m_currentSubPageCode;

static int s_lastPageRow;
static int s_lastSubPageRow;
};
}

Expand Down

0 comments on commit 1c4889f

Please sign in to comment.