aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
Diffstat (limited to 'launcher')
-rw-r--r--launcher/FileSystem.cpp13
-rw-r--r--launcher/FileSystem.h5
-rw-r--r--launcher/ui/MainWindow.cpp29
-rw-r--r--launcher/ui/MainWindow.h2
4 files changed, 49 insertions, 0 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 4026d6c1..13bb95d9 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -163,6 +163,19 @@ bool ensureFolderPathExists(QString foldernamepath)
return success;
}
+bool symlink(const QString& source, const QString& target)
+{
+ std::error_code err;
+
+ fs::create_symlink(toStdString(source), toStdString(target));
+
+ if (err) {
+ qWarning() << "Failed to symlink files:" << QString::fromStdString(err.message());
+ }
+
+ return err.value() == 0;
+}
+
bool copy::operator()(const QString& offset)
{
using copy_opts = fs::copy_options;
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index b46f3281..2d4dfb56 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -54,6 +54,11 @@ class FileSystemException : public ::Exception {
void write(const QString& filename, const QByteArray& data);
/**
+ * create a symlink
+ */
+bool symlink(const QString& target, const QString& link);
+
+/**
* read data from a file safely\
*/
QByteArray read(const QString& filename);
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index afbc505e..80d212e9 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -61,6 +61,7 @@
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
+#include <QFileDialog>
#include <QInputDialog>
#include <QLabel>
#include <QToolButton>
@@ -253,6 +254,7 @@ public:
QMenu * helpMenu = nullptr;
TranslatedToolButton helpMenuButton;
TranslatedAction actionClearMetadata;
+ TranslatedAction actionAddToPATH;
TranslatedAction actionReportBug;
TranslatedAction actionDISCORD;
TranslatedAction actionMATRIX;
@@ -348,6 +350,14 @@ public:
actionClearMetadata.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Clear cached metadata"));
all_actions.append(&actionClearMetadata);
+ #ifdef Q_OS_MAC
+ actionAddToPATH = TranslatedAction(MainWindow);
+ actionAddToPATH->setObjectName(QStringLiteral("actionAddToPATH"));
+ actionAddToPATH.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Add to &PATH"));
+ actionAddToPATH.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Add the prism binary to PATH."));
+ all_actions.append(&actionAddToPATH);
+ #endif
+
if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) {
actionReportBug = TranslatedAction(MainWindow);
actionReportBug->setObjectName(QStringLiteral("actionReportBug"));
@@ -448,6 +458,10 @@ public:
helpMenu->addAction(actionClearMetadata);
+ #ifdef Q_OS_MAC
+ helpMenu->addAction(actionAddToPATH);
+ #endif
+
if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) {
helpMenu->addAction(actionReportBug);
}
@@ -533,6 +547,9 @@ public:
helpMenu = menuBar->addMenu(tr("&Help"));
helpMenu->setSeparatorsCollapsible(false);
helpMenu->addAction(actionClearMetadata);
+ #ifdef Q_OS_MAC
+ helpMenu->addAction(actionAddToPATH);
+ #endif
helpMenu->addSeparator();
helpMenu->addAction(actionAbout);
helpMenu->addAction(actionOpenWiki);
@@ -1902,6 +1919,18 @@ void MainWindow::on_actionClearMetadata_triggered()
APPLICATION->metacache()->evictAll();
}
+void MainWindow::on_actionAddToPATH_triggered() {
+ auto binaryPath = APPLICATION->arguments().first();
+
+ auto outcome = FS::symlink(binaryPath, "/usr/local/bin/prism");
+
+ if (!outcome) {
+ QMessageBox::critical(this, tr("Failed to add Prism to PATH"), tr(""));
+ } else {
+ QMessageBox::information(this, tr("Added Prism to PATH"), tr("Prism was successfully added to your PATH."));
+ }
+}
+
void MainWindow::on_actionOpenWiki_triggered()
{
DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg("")));
diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h
index cb8cb4aa..097b0983 100644
--- a/launcher/ui/MainWindow.h
+++ b/launcher/ui/MainWindow.h
@@ -128,6 +128,8 @@ private slots:
void on_actionClearMetadata_triggered();
+ void on_actionAddToPATH_triggered();
+
void on_actionOpenWiki_triggered();
void on_actionMoreNews_triggered();