mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Add new action to create a new instance of the viewer in macos
This commit is contained in:
parent
f65395c11d
commit
1f8be886ec
@ -204,6 +204,26 @@ void MainWindowViewer::createActions()
|
|||||||
openAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_ACTION_Y));
|
openAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_ACTION_Y));
|
||||||
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
|
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
newInstanceAction = new QAction(tr("New instance"), this);
|
||||||
|
newInstanceAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(NEW_INSTANCE_ACTION_Y));
|
||||||
|
connect(newInstanceAction, &QAction::triggered,
|
||||||
|
[=]() {
|
||||||
|
QStringList possiblePaths { QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../../../") };
|
||||||
|
possiblePaths += QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
|
||||||
|
|
||||||
|
for (auto &&ypath : possiblePaths) {
|
||||||
|
QString yacreaderPath = QDir::cleanPath(ypath + "/YACReader.app");
|
||||||
|
if (QFileInfo(yacreaderPath).exists()) {
|
||||||
|
QStringList parameters { "-n", "-a", yacreaderPath };
|
||||||
|
QProcess::startDetached("open", parameters);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newInstanceAction->setData(NEW_INSTANCE_ACTION_Y);
|
||||||
|
#endif
|
||||||
|
|
||||||
openFolderAction = new QAction(tr("Open Folder"), this);
|
openFolderAction = new QAction(tr("Open Folder"), this);
|
||||||
openFolderAction->setIcon(QIcon(":/images/viewer_toolbar/openFolder.png"));
|
openFolderAction->setIcon(QIcon(":/images/viewer_toolbar/openFolder.png"));
|
||||||
openFolderAction->setToolTip(tr("Open image folder"));
|
openFolderAction->setToolTip(tr("Open image folder"));
|
||||||
@ -645,6 +665,8 @@ void MainWindowViewer::createToolBars()
|
|||||||
//file
|
//file
|
||||||
auto fileMenu = new QMenu(tr("File"));
|
auto fileMenu = new QMenu(tr("File"));
|
||||||
|
|
||||||
|
fileMenu->addAction(newInstanceAction);
|
||||||
|
fileMenu->addSeparator();
|
||||||
fileMenu->addAction(openAction);
|
fileMenu->addAction(openAction);
|
||||||
fileMenu->addAction(openLatestComicAction);
|
fileMenu->addAction(openLatestComicAction);
|
||||||
fileMenu->addAction(openFolderAction);
|
fileMenu->addAction(openFolderAction);
|
||||||
@ -1258,7 +1280,11 @@ void MainWindowViewer::setUpShortcutsManagement()
|
|||||||
<< showFlowAction
|
<< showFlowAction
|
||||||
<< toggleFullScreenAction
|
<< toggleFullScreenAction
|
||||||
<< toggleToolbarsAction
|
<< toggleToolbarsAction
|
||||||
<< showEditShortcutsAction);
|
<< showEditShortcutsAction
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
<< newInstanceAction
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
allActions << tmpList;
|
allActions << tmpList;
|
||||||
|
|
||||||
|
@ -106,6 +106,9 @@ private:
|
|||||||
|
|
||||||
//! Actions
|
//! Actions
|
||||||
QAction *openAction;
|
QAction *openAction;
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
QAction *newInstanceAction; //needed in macos
|
||||||
|
#endif
|
||||||
QAction *openFolderAction;
|
QAction *openFolderAction;
|
||||||
QAction *openLatestComicAction;
|
QAction *openLatestComicAction;
|
||||||
QList<QAction *> recentFilesActionList;
|
QList<QAction *> recentFilesActionList;
|
||||||
|
@ -74,6 +74,10 @@ void ShortcutsManager::initDefaultShorcuts()
|
|||||||
defaultShorcuts.insert(ZOOM_IN_MGLASS_ACTION_Y, Qt::Key_Asterisk);
|
defaultShorcuts.insert(ZOOM_IN_MGLASS_ACTION_Y, Qt::Key_Asterisk);
|
||||||
defaultShorcuts.insert(ZOOM_OUT_MGLASS_ACTION_Y, Qt::Key_Underscore);
|
defaultShorcuts.insert(ZOOM_OUT_MGLASS_ACTION_Y, Qt::Key_Underscore);
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
defaultShorcuts.insert(NEW_INSTANCE_ACTION_Y, Qt::Key_N);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ public:
|
|||||||
|
|
||||||
//ACTION NAMES YACReader
|
//ACTION NAMES YACReader
|
||||||
#define OPEN_ACTION_Y "OPEN_ACTION_Y"
|
#define OPEN_ACTION_Y "OPEN_ACTION_Y"
|
||||||
|
#define NEW_INSTANCE_ACTION_Y "NEW_INSTANCE_ACTION_Y"
|
||||||
#define OPEN_FOLDER_ACTION_Y "OPEN_FOLDER_ACTION_Y"
|
#define OPEN_FOLDER_ACTION_Y "OPEN_FOLDER_ACTION_Y"
|
||||||
#define SAVE_IMAGE_ACTION_Y "SAVE_IMAGE_ACTION_Y"
|
#define SAVE_IMAGE_ACTION_Y "SAVE_IMAGE_ACTION_Y"
|
||||||
#define OPEN_PREVIOUS_COMIC_ACTION_Y "OPEN_PREVIOUS_COMIC_ACTION_Y"
|
#define OPEN_PREVIOUS_COMIC_ACTION_Y "OPEN_PREVIOUS_COMIC_ACTION_Y"
|
||||||
|
Loading…
Reference in New Issue
Block a user