Add functionality to clear the openrecent list

This commit is contained in:
Felix Kauselmann 2015-12-30 13:19:17 +01:00
parent c850cc5b55
commit 6b19a3093c
3 changed files with 17 additions and 1 deletions

View File

@ -68,6 +68,7 @@ using namespace YACReader;
//openRecent
QStringList openRecentList() { return settings->value("recentFiles").toStringList(); }
void updateOpenRecentList (QString path);
void clearOpenRecentList() { settings->remove("recentFiles"); }
//Old fitmodes
/*

View File

@ -227,6 +227,10 @@ void MainWindowViewer::createActions()
QObject::connect(recentFileAction, &QAction::triggered, this, &MainWindowViewer::openRecent);
recentFilesActionList.append(recentFileAction);
}
clearRecentFilesAction = new QAction(tr("Clear"),this);
clearRecentFilesAction->setToolTip(tr("Clear openrecent list"));
connect(clearRecentFilesAction, &QAction::triggered, this, &MainWindowViewer::clearRecentFiles);
saveImageAction = new QAction(tr("Save"),this);
saveImageAction->setIcon(QIcon(":/images/viewer_toolbar/save.png"));
@ -514,8 +518,10 @@ void MainWindowViewer::createToolBars()
#else
QMenu * recentmenu = new QMenu("Open recent");
recentmenu->addActions(recentFilesActionList);
recentmenu->addSeparator();
recentmenu->addAction(clearRecentFilesAction);
refreshRecentFilesActionList();
QToolButton * tb = new QToolButton();
tb->addAction(openAction);
tb->addAction(openFolderAction);
@ -683,6 +689,13 @@ void MainWindowViewer::refreshRecentFilesActionList()
}
}
void MainWindowViewer::clearRecentFiles()
{
qDebug() << "clear triggered";
Configuration::getConfiguration().clearOpenRecentList();
refreshRecentFilesActionList();
}
void MainWindowViewer::openRecent()
{
QAction *action = qobject_cast<QAction *>(sender());

View File

@ -106,6 +106,7 @@ class EditShortcutsDialog;
QAction *openAction;
QAction *openFolderAction;
QList<QAction*> recentFilesActionList;
QAction *clearRecentFilesAction;
QAction *saveImageAction;
QAction *openPreviousComicAction;
QAction *openNextComicAction;
@ -148,6 +149,7 @@ class EditShortcutsDialog;
void createActions();
void createToolBars();
void refreshRecentFilesActionList();
void clearRecentFiles();
void getSiblingComics(QString path,QString currentComic);
//! Manejadores de evento: