mirror of
https://github.com/YACReader/yacreader
synced 2025-05-25 18:00:46 -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));
|
||||
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->setIcon(QIcon(":/images/viewer_toolbar/openFolder.png"));
|
||||
openFolderAction->setToolTip(tr("Open image folder"));
|
||||
@ -645,6 +665,8 @@ void MainWindowViewer::createToolBars()
|
||||
//file
|
||||
auto fileMenu = new QMenu(tr("File"));
|
||||
|
||||
fileMenu->addAction(newInstanceAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(openAction);
|
||||
fileMenu->addAction(openLatestComicAction);
|
||||
fileMenu->addAction(openFolderAction);
|
||||
@ -1258,7 +1280,11 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
<< showFlowAction
|
||||
<< toggleFullScreenAction
|
||||
<< toggleToolbarsAction
|
||||
<< showEditShortcutsAction);
|
||||
<< showEditShortcutsAction
|
||||
#ifdef Q_OS_MAC
|
||||
<< newInstanceAction
|
||||
#endif
|
||||
);
|
||||
|
||||
allActions << tmpList;
|
||||
|
||||
|
@ -106,6 +106,9 @@ private:
|
||||
|
||||
//! Actions
|
||||
QAction *openAction;
|
||||
#ifdef Q_OS_MAC
|
||||
QAction *newInstanceAction; //needed in macos
|
||||
#endif
|
||||
QAction *openFolderAction;
|
||||
QAction *openLatestComicAction;
|
||||
QList<QAction *> recentFilesActionList;
|
||||
|
@ -74,6 +74,10 @@ void ShortcutsManager::initDefaultShorcuts()
|
||||
defaultShorcuts.insert(ZOOM_IN_MGLASS_ACTION_Y, Qt::Key_Asterisk);
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
|
||||
//ACTION NAMES YACReader
|
||||
#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 SAVE_IMAGE_ACTION_Y "SAVE_IMAGE_ACTION_Y"
|
||||
#define OPEN_PREVIOUS_COMIC_ACTION_Y "OPEN_PREVIOUS_COMIC_ACTION_Y"
|
||||
|
Loading…
Reference in New Issue
Block a user