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