Skip to content

Commit

Permalink
Handling Enable / Disable menu items (doxywizard)
Browse files Browse the repository at this point in the history
Only enable menu item "Reset to factory defaults" in case the current settings are different from the default settings.
Only enable "Clear recent list" and "Open recent" in case there are recent files.
  • Loading branch information
albert-github committed Nov 3, 2020
1 parent 67132b8 commit 6deb25b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions addon/doxywizard/doxywizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ MainWindow::MainWindow()
this, SLOT(quit()), Qt::CTRL+Qt::Key_Q);

QMenu *settings = menuBar()->addMenu(tr("Settings"));
settings->addAction(tr("Reset to factory defaults"),
m_resetDefault = settings->addAction(tr("Reset to factory defaults"),
this,SLOT(resetToDefaults()));
settings->addAction(tr("Use current settings at startup"),
this,SLOT(makeDefaults()));
settings->addAction(tr("Clear recent list"),
m_clearRecent = settings->addAction(tr("Clear recent list"),
this,SLOT(clearRecent()));

QMenu *help = menuBar()->addMenu(tr("Help"));
Expand Down Expand Up @@ -379,6 +379,8 @@ void MainWindow::clearRecent()
{
m_settings.setValue(QString::fromLatin1("recent/config%1").arg(i++),QString::fromLatin1(""));
}
m_clearRecent->setEnabled(false);
m_recentMenu->setEnabled(false);
m_settings.sync();
}

Expand All @@ -396,6 +398,8 @@ void MainWindow::resetToDefaults()
m_expert->resetToDefaults();
m_settings.setValue(QString::fromLatin1("wizard/loadsettings"), false);
m_settings.sync();
m_modified = false;
updateTitle();
m_wizard->refresh();
}
}
Expand Down Expand Up @@ -474,6 +478,9 @@ void MainWindow::addRecentFileList(const QString &fileName)
m_recentFiles.removeLast();
m_recentFiles.prepend(fileName);
}
m_clearRecent->setEnabled(m_recentFiles.count()>0);
m_recentMenu->setEnabled(m_recentFiles.count()>0);
m_settings.sync();
}
void MainWindow::updateRecentFile(void)
{
Expand All @@ -488,6 +495,9 @@ void MainWindow::updateRecentFile(void)
{
m_settings.setValue(QString::fromLatin1("recent/config%1").arg(i),QString::fromLatin1(""));
}
m_clearRecent->setEnabled(m_recentFiles.count()>0);
m_recentMenu->setEnabled(m_recentFiles.count()>0);
m_settings.sync();
}

void MainWindow::openRecent(QAction *action)
Expand Down Expand Up @@ -685,6 +695,7 @@ void MainWindow::configChanged()
void MainWindow::updateTitle()
{
QString title = tr("Doxygen GUI frontend");
m_resetDefault->setEnabled(m_modified);
if (m_modified)
{
title+=QString::fromLatin1(" +");
Expand Down
2 changes: 2 additions & 0 deletions addon/doxywizard/doxywizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class MainWindow : public QMainWindow
QSettings m_settings;
QMenu *m_recentMenu;
QStringList m_recentFiles;
QAction *m_resetDefault;
QAction *m_clearRecent;
QProcess *m_runProcess;
QTimer *m_timer;
QTabWidget *m_tabs;
Expand Down

0 comments on commit 6deb25b

Please sign in to comment.