mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Added new action for opening the latest issue opened, by default CTRL+R.
This commit is contained in:
parent
8b20014cc8
commit
ddf59849cc
@ -84,6 +84,7 @@ MainWindowViewer::~MainWindowViewer()
|
||||
//delete sliderAction;
|
||||
delete openAction;
|
||||
delete openFolderAction;
|
||||
delete openLatestComicAction;
|
||||
delete saveImageAction;
|
||||
delete openPreviousComicAction;
|
||||
delete openNextComicAction;
|
||||
@ -222,7 +223,13 @@ void MainWindowViewer::createActions()
|
||||
openFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_FOLDER_ACTION_Y));
|
||||
connect(openFolderAction, SIGNAL(triggered()), this, SLOT(openFolder()));
|
||||
|
||||
QAction* recentFileAction = 0;
|
||||
openLatestComicAction = new QAction(tr("Open latest comic"), this);
|
||||
openLatestComicAction->setToolTip(tr("Open the latest comic opened in the previous reading session"));
|
||||
openLatestComicAction->setData(OPEN_LATEST_COMIC_Y);
|
||||
openLatestComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_LATEST_COMIC_Y));
|
||||
connect(openLatestComicAction, SIGNAL(triggered()), this, SLOT(openLatestComic()));
|
||||
|
||||
QAction* recentFileAction = nullptr;
|
||||
//TODO: Replace limit with a configurable value
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@ -516,10 +523,6 @@ void MainWindowViewer::createToolBars()
|
||||
comicToolBar->setStyleSheet("QToolBar{border:none;}");
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
comicToolBar->addAction(openAction);
|
||||
comicToolBar->addAction(openFolderAction);
|
||||
#else
|
||||
QMenu * recentmenu = new QMenu(tr("Open recent"));
|
||||
recentmenu->addActions(recentFilesActionList);
|
||||
recentmenu->addSeparator();
|
||||
@ -528,13 +531,14 @@ void MainWindowViewer::createToolBars()
|
||||
|
||||
QToolButton * tb = new QToolButton();
|
||||
tb->addAction(openAction);
|
||||
tb->addAction(openLatestComicAction);
|
||||
tb->addAction(openFolderAction);
|
||||
tb->addAction(recentmenu->menuAction());
|
||||
tb->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
tb->setDefaultAction(openAction);
|
||||
|
||||
comicToolBar->addWidget(tb);
|
||||
#endif
|
||||
|
||||
comicToolBar->addAction(saveImageAction);
|
||||
comicToolBar->addAction(openPreviousComicAction);
|
||||
comicToolBar->addAction(openNextComicAction);
|
||||
@ -757,22 +761,39 @@ void MainWindowViewer::clearRecentFiles()
|
||||
void MainWindowViewer::openRecent()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
if (action)
|
||||
{
|
||||
QFileInfo info1 (action->data().toString());
|
||||
if (info1.exists())
|
||||
{
|
||||
if (info1.isFile())
|
||||
{
|
||||
openComicFromPath(action->data().toString());
|
||||
}
|
||||
else if (info1.isDir())
|
||||
{
|
||||
openFolderFromPath(action->data().toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
openComicFromRecentAction(action);
|
||||
}
|
||||
|
||||
void MainWindowViewer::openLatestComic()
|
||||
{
|
||||
if (recentFilesActionList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
openComicFromRecentAction(recentFilesActionList[0]);
|
||||
}
|
||||
|
||||
void MainWindowViewer::openComicFromRecentAction(QAction *action)
|
||||
{
|
||||
if (action == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QFileInfo info1 (action->data().toString());
|
||||
if (info1.exists())
|
||||
{
|
||||
if (info1.isFile())
|
||||
{
|
||||
openComicFromPath(action->data().toString());
|
||||
}
|
||||
else if (info1.isDir())
|
||||
{
|
||||
openFolderFromPath(action->data().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowViewer::reloadOptions()
|
||||
@ -1245,12 +1266,12 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
|
||||
|
||||
editShortcutsDialog->addActionsGroup(tr("Comics"),QIcon(":/images/shortcuts_group_comics.png"),
|
||||
tmpList = QList<QAction *>()
|
||||
<< openAction
|
||||
<< openFolderAction
|
||||
<< saveImageAction
|
||||
<< openPreviousComicAction
|
||||
<< openNextComicAction);
|
||||
tmpList = { openAction,
|
||||
openLatestComicAction,
|
||||
openFolderAction,
|
||||
saveImageAction,
|
||||
openPreviousComicAction,
|
||||
openNextComicAction });
|
||||
|
||||
allActions << tmpList;
|
||||
|
||||
|
@ -35,6 +35,8 @@ class EditShortcutsDialog;
|
||||
void open(QString path, qint64 comicId, qint64 libraryId);
|
||||
void openFolder();
|
||||
void openRecent();
|
||||
void openLatestComic();
|
||||
void openComicFromRecentAction(QAction *action);
|
||||
void saveImage();
|
||||
void toggleToolBars();
|
||||
void hideToolBars();
|
||||
@ -106,6 +108,7 @@ class EditShortcutsDialog;
|
||||
//! Actions
|
||||
QAction *openAction;
|
||||
QAction *openFolderAction;
|
||||
QAction *openLatestComicAction;
|
||||
QList<QAction*> recentFilesActionList;
|
||||
QAction *clearRecentFilesAction;
|
||||
QAction *saveImageAction;
|
||||
|
@ -31,6 +31,7 @@ void ShortcutsManager::initDefaultShorcuts()
|
||||
//COMMANDS (used in keypressevent)
|
||||
#else
|
||||
defaultShorcuts.insert(OPEN_ACTION_Y, Qt::Key_O);
|
||||
defaultShorcuts.insert(OPEN_LATEST_COMIC_Y, Qt::CTRL | Qt::Key_R);
|
||||
defaultShorcuts.insert(OPEN_FOLDER_ACTION_Y, Qt::CTRL | Qt::Key_O);
|
||||
defaultShorcuts.insert(OPEN_PREVIOUS_COMIC_ACTION_Y, Qt::CTRL | Qt::Key_Left);
|
||||
defaultShorcuts.insert(OPEN_NEXT_COMIC_ACTION_Y, Qt::CTRL | Qt::Key_Right);
|
||||
|
@ -113,6 +113,7 @@ public:
|
||||
#define FIT_TO_PAGE_ACTION_Y "FIT_TO_PAGE_ACTION_Y"
|
||||
#define SHOW_FLOW_ACTION_Y "SHOW_FLOW_ACTION_Y"
|
||||
#define SHOW_EDIT_SHORTCUTS_ACTION_Y "SHOW_EDIT_SHORTCUTS_ACTION_Y"
|
||||
#define OPEN_LATEST_COMIC_Y "OPEN_LATEST_COMIC_Y"
|
||||
|
||||
//COMMANDS YACReader
|
||||
//main_viewer_window
|
||||
|
Loading…
Reference in New Issue
Block a user