Show disabled action instead of empty menu.

This commit is contained in:
Roman Telezhynskyi 2023-10-24 19:15:14 +03:00
parent 61854d2fa8
commit b9b1d2fb66
4 changed files with 40 additions and 0 deletions

View File

@ -5035,6 +5035,14 @@ void TMainWindow::InitSearchHistory()
{
QStringList searchHistory = MApplication::VApp()->TapeSettings()->GetTapeSearchHistory();
m_searchHistory->clear();
if (searchHistory.isEmpty())
{
QAction *action = m_searchHistory->addAction('<'_L1 + tr("Empty", "list") + '>'_L1);
action->setDisabled(true);
return;
}
for (const auto &term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);

View File

@ -885,6 +885,14 @@ void DialogFinalMeasurements::InitSearchHistory()
QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetFinalMeasurementsSearchHistory();
m_searchHistory->clear();
if (searchHistory.isEmpty())
{
QAction *action = m_searchHistory->addAction('<'_L1 + tr("Empty", "list") + '>'_L1);
action->setDisabled(true);
return;
}
for (const auto &term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);

View File

@ -767,6 +767,14 @@ void DialogHistory::InitSearchHistory()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetHistorySearchHistory();
m_searchHistory->clear();
if (searchHistory.isEmpty())
{
QAction *action = m_searchHistory->addAction('<'_L1 + tr("Empty", "list") + '>'_L1);
action->setDisabled(true);
return;
}
for (const auto &term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);

View File

@ -1131,6 +1131,14 @@ void DialogIncrements::InitIncrementsSearchHistory()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetIncrementsSearchHistory();
m_searchHistory->clear();
if (searchHistory.isEmpty())
{
QAction *action = m_searchHistory->addAction('<'_L1 + tr("Empty", "list") + '>'_L1);
action->setDisabled(true);
return;
}
for (const auto &term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);
@ -1156,6 +1164,14 @@ void DialogIncrements::InitPreviewCalculationsSearchHistory()
QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
m_searchHistoryPC->clear();
if (searchHistory.isEmpty())
{
QAction *action = m_searchHistoryPC->addAction('<'_L1 + tr("Empty", "list") + '>'_L1);
action->setDisabled(true);
return;
}
for (const auto &term : searchHistory)
{
QAction *action = m_searchHistoryPC->addAction(term);