Merge branch 'PrismLauncher:develop' into menu-themes
This commit is contained in:
@ -61,6 +61,7 @@
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QLabel>
|
||||
#include <QToolButton>
|
||||
@ -253,6 +254,9 @@ public:
|
||||
QMenu * helpMenu = nullptr;
|
||||
TranslatedToolButton helpMenuButton;
|
||||
TranslatedAction actionClearMetadata;
|
||||
#ifdef Q_OS_MAC
|
||||
TranslatedAction actionAddToPATH;
|
||||
#endif
|
||||
TranslatedAction actionReportBug;
|
||||
TranslatedAction actionDISCORD;
|
||||
TranslatedAction actionMATRIX;
|
||||
@ -352,6 +356,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", "Install to &PATH"));
|
||||
actionAddToPATH.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Install a prismlauncher symlink to /usr/local/bin"));
|
||||
all_actions.append(&actionAddToPATH);
|
||||
#endif
|
||||
|
||||
if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) {
|
||||
actionReportBug = TranslatedAction(MainWindow);
|
||||
actionReportBug->setObjectName(QStringLiteral("actionReportBug"));
|
||||
@ -462,6 +474,10 @@ public:
|
||||
|
||||
helpMenu->addAction(actionClearMetadata);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
helpMenu->addAction(actionAddToPATH);
|
||||
#endif
|
||||
|
||||
if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) {
|
||||
helpMenu->addAction(actionReportBug);
|
||||
}
|
||||
@ -551,6 +567,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);
|
||||
@ -1955,6 +1974,29 @@ void MainWindow::on_actionClearMetadata_triggered()
|
||||
APPLICATION->metacache()->SaveNow();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void MainWindow::on_actionAddToPATH_triggered()
|
||||
{
|
||||
auto binaryPath = APPLICATION->applicationFilePath();
|
||||
auto targetPath = QString("/usr/local/bin/%1").arg(BuildConfig.LAUNCHER_APP_BINARY_NAME);
|
||||
qDebug() << "Symlinking" << binaryPath << "to" << targetPath;
|
||||
|
||||
QStringList args;
|
||||
args << "-e";
|
||||
args << QString("do shell script \"mkdir -p /usr/local/bin && ln -sf '%1' '%2'\" with administrator privileges")
|
||||
.arg(binaryPath, targetPath);
|
||||
auto outcome = QProcess::execute("/usr/bin/osascript", args);
|
||||
if (!outcome) {
|
||||
QMessageBox::information(this, tr("Successfully added %1 to PATH").arg(BuildConfig.LAUNCHER_DISPLAYNAME),
|
||||
tr("%1 was successfully added to your PATH. You can now start it by running `%2`.")
|
||||
.arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.LAUNCHER_APP_BINARY_NAME));
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Failed to add %1 to PATH").arg(BuildConfig.LAUNCHER_DISPLAYNAME),
|
||||
tr("An error occurred while trying to add %1 to PATH").arg(BuildConfig.LAUNCHER_DISPLAYNAME));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::on_actionOpenWiki_triggered()
|
||||
{
|
||||
DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg("")));
|
||||
|
@ -128,6 +128,10 @@ private slots:
|
||||
|
||||
void on_actionClearMetadata_triggered();
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void on_actionAddToPATH_triggered();
|
||||
#endif
|
||||
|
||||
void on_actionOpenWiki_triggered();
|
||||
|
||||
void on_actionMoreNews_triggered();
|
||||
|
@ -400,11 +400,11 @@ public:
|
||||
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
||||
{
|
||||
return m_servers.size();
|
||||
return parent.isValid() ? 0 : m_servers.size();
|
||||
}
|
||||
int columnCount(const QModelIndex & parent) const override
|
||||
{
|
||||
return COLUMN_COUNT;
|
||||
return parent.isValid() ? 0 : COLUMN_COUNT;
|
||||
}
|
||||
|
||||
Server * at(int index)
|
||||
|
@ -20,8 +20,8 @@ class ListModel : public QAbstractListModel {
|
||||
ListModel(ModPage* parent);
|
||||
~ListModel() override;
|
||||
|
||||
inline auto rowCount(const QModelIndex& parent) const -> int override { return modpacks.size(); };
|
||||
inline auto columnCount(const QModelIndex& parent) const -> int override { return 1; };
|
||||
inline auto rowCount(const QModelIndex& parent) const -> int override { return parent.isValid() ? 0 : modpacks.size(); };
|
||||
inline auto columnCount(const QModelIndex& parent) const -> int override { return parent.isValid() ? 0 : 1; };
|
||||
inline auto flags(const QModelIndex& index) const -> Qt::ItemFlags override { return QAbstractListModel::flags(index); };
|
||||
|
||||
auto debugName() const -> QString;
|
||||
@ -41,12 +41,12 @@ class ListModel : public QAbstractListModel {
|
||||
void requestModVersions(const ModPlatform::IndexedPack& current, QModelIndex index);
|
||||
|
||||
virtual void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) = 0;
|
||||
virtual void loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObject& obj) {};
|
||||
virtual void loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObject& obj) = 0;
|
||||
virtual void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) = 0;
|
||||
|
||||
void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback);
|
||||
|
||||
inline auto canFetchMore(const QModelIndex& parent) const -> bool override { return searchState == CanPossiblyFetchMore; };
|
||||
inline auto canFetchMore(const QModelIndex& parent) const -> bool override { return parent.isValid() ? false : searchState == CanPossiblyFetchMore; };
|
||||
|
||||
public slots:
|
||||
void searchRequestFinished(QJsonDocument& doc);
|
||||
|
@ -262,7 +262,7 @@ void ModPage::openUrl(const QUrl& url)
|
||||
|
||||
const QString address = url.host() + url.path();
|
||||
QRegularExpressionMatch match;
|
||||
const char* page;
|
||||
QString page;
|
||||
|
||||
match = modrinth.match(address);
|
||||
if (match.hasMatch())
|
||||
@ -276,7 +276,7 @@ void ModPage::openUrl(const QUrl& url)
|
||||
page = "curseforge";
|
||||
}
|
||||
|
||||
if (match.hasMatch()) {
|
||||
if (!page.isNull()) {
|
||||
const QString slug = match.captured(1);
|
||||
|
||||
// ensure the user isn't opening the same mod
|
||||
|
@ -32,12 +32,12 @@ ListModel::~ListModel()
|
||||
|
||||
int ListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return modpacks.size();
|
||||
return parent.isValid() ? 0 : modpacks.size();
|
||||
}
|
||||
|
||||
int ListModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 1;
|
||||
return parent.isValid() ? 0 : 1;
|
||||
}
|
||||
|
||||
QVariant ListModel::data(const QModelIndex &index, int role) const
|
||||
|
@ -75,12 +75,12 @@ QVector<QString> AtlOptionalModListModel::getResult() {
|
||||
}
|
||||
|
||||
int AtlOptionalModListModel::rowCount(const QModelIndex &parent) const {
|
||||
return m_mods.size();
|
||||
return parent.isValid() ? 0 : m_mods.size();
|
||||
}
|
||||
|
||||
int AtlOptionalModListModel::columnCount(const QModelIndex &parent) const {
|
||||
// Enabled, Name, Description
|
||||
return 3;
|
||||
return parent.isValid() ? 0 : 3;
|
||||
}
|
||||
|
||||
QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const {
|
||||
|
@ -15,12 +15,12 @@ ListModel::~ListModel() {}
|
||||
|
||||
int ListModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return modpacks.size();
|
||||
return parent.isValid() ? 0 : modpacks.size();
|
||||
}
|
||||
|
||||
int ListModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 1;
|
||||
return parent.isValid() ? 0 : 1;
|
||||
}
|
||||
|
||||
QVariant ListModel::data(const QModelIndex& index, int role) const
|
||||
|
@ -34,12 +34,12 @@ ListModel::~ListModel()
|
||||
|
||||
int ListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return modpacks.size();
|
||||
return parent.isValid() ? 0 : modpacks.size();
|
||||
}
|
||||
|
||||
int ListModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 1;
|
||||
return parent.isValid() ? 0 : 1;
|
||||
}
|
||||
|
||||
QVariant ListModel::data(const QModelIndex &index, int role) const
|
||||
|
@ -125,12 +125,12 @@ QString ListModel::translatePackType(PackType type) const
|
||||
|
||||
int ListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return modpacks.size();
|
||||
return parent.isValid() ? 0 : modpacks.size();
|
||||
}
|
||||
|
||||
int ListModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 1;
|
||||
return parent.isValid() ? 0 : 1;
|
||||
}
|
||||
|
||||
QVariant ListModel::data(const QModelIndex &index, int role) const
|
||||
|
@ -55,8 +55,8 @@ class ModpackListModel : public QAbstractListModel {
|
||||
ModpackListModel(ModrinthPage* parent);
|
||||
~ModpackListModel() override = default;
|
||||
|
||||
inline auto rowCount(const QModelIndex& parent) const -> int override { return modpacks.size(); };
|
||||
inline auto columnCount(const QModelIndex& parent) const -> int override { return 1; };
|
||||
inline auto rowCount(const QModelIndex& parent) const -> int override { return parent.isValid() ? 0 : modpacks.size(); };
|
||||
inline auto columnCount(const QModelIndex& parent) const -> int override { return parent.isValid() ? 0 : 1; };
|
||||
inline auto flags(const QModelIndex& index) const -> Qt::ItemFlags override { return QAbstractListModel::flags(index); };
|
||||
|
||||
auto debugName() const -> QString;
|
||||
@ -74,7 +74,7 @@ class ModpackListModel : public QAbstractListModel {
|
||||
|
||||
void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback);
|
||||
|
||||
inline auto canFetchMore(const QModelIndex& parent) const -> bool override { return searchState == CanPossiblyFetchMore; };
|
||||
inline auto canFetchMore(const QModelIndex& parent) const -> bool override { return parent.isValid() ? false : searchState == CanPossiblyFetchMore; };
|
||||
|
||||
public slots:
|
||||
void searchRequestFinished(QJsonDocument& doc_all);
|
||||
|
@ -80,14 +80,14 @@ QVariant Technic::ListModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int Technic::ListModel::columnCount(const QModelIndex&) const
|
||||
int Technic::ListModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 1;
|
||||
return parent.isValid() ? 0 : 1;
|
||||
}
|
||||
|
||||
int Technic::ListModel::rowCount(const QModelIndex&) const
|
||||
int Technic::ListModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
return modpacks.size();
|
||||
return parent.isValid() ? 0 : modpacks.size();
|
||||
}
|
||||
|
||||
void Technic::ListModel::searchWithTerm(const QString& term)
|
||||
|
Reference in New Issue
Block a user