Merge branch 'PrismLauncher:develop' into develop
This commit is contained in:
commit
ce1a4857cc
@ -62,6 +62,7 @@
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include "ui/WinDarkmode.h"
|
#include "ui/WinDarkmode.h"
|
||||||
|
#include <versionhelpers.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ui/setupwizard/SetupWizard.h"
|
#include "ui/setupwizard/SetupWizard.h"
|
||||||
@ -1136,15 +1137,6 @@ std::vector<ITheme *> Application::getValidApplicationThemes()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::isFlatpak()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
return QFile::exists("/.flatpak-info");
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::setApplicationTheme(const QString& name, bool initial)
|
void Application::setApplicationTheme(const QString& name, bool initial)
|
||||||
{
|
{
|
||||||
auto systemPalette = qApp->palette();
|
auto systemPalette = qApp->palette();
|
||||||
@ -1154,7 +1146,7 @@ void Application::setApplicationTheme(const QString& name, bool initial)
|
|||||||
auto & theme = (*themeIter).second;
|
auto & theme = (*themeIter).second;
|
||||||
theme->apply(initial);
|
theme->apply(initial);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (m_mainWindow) {
|
if (m_mainWindow && IsWindows10OrGreater()) {
|
||||||
if (QString::compare(theme->id(), "dark") == 0) {
|
if (QString::compare(theme->id(), "dark") == 0) {
|
||||||
WinDarkmode::setDarkWinTitlebar(m_mainWindow->winId(), true);
|
WinDarkmode::setDarkWinTitlebar(m_mainWindow->winId(), true);
|
||||||
} else {
|
} else {
|
||||||
@ -1395,10 +1387,13 @@ MainWindow* Application::showMainWindow(bool minimized)
|
|||||||
m_mainWindow->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("MainWindowState").toByteArray()));
|
m_mainWindow->restoreState(QByteArray::fromBase64(APPLICATION->settings()->get("MainWindowState").toByteArray()));
|
||||||
m_mainWindow->restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("MainWindowGeometry").toByteArray()));
|
m_mainWindow->restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("MainWindowGeometry").toByteArray()));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (QString::compare(settings()->get("ApplicationTheme").toString(), "dark") == 0) {
|
if (IsWindows10OrGreater())
|
||||||
WinDarkmode::setDarkWinTitlebar(m_mainWindow->winId(), true);
|
{
|
||||||
} else {
|
if (QString::compare(settings()->get("ApplicationTheme").toString(), "dark") == 0) {
|
||||||
WinDarkmode::setDarkWinTitlebar(m_mainWindow->winId(), false);
|
WinDarkmode::setDarkWinTitlebar(m_mainWindow->winId(), true);
|
||||||
|
} else {
|
||||||
|
WinDarkmode::setDarkWinTitlebar(m_mainWindow->winId(), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(minimized)
|
if(minimized)
|
||||||
|
@ -116,8 +116,6 @@ public:
|
|||||||
|
|
||||||
QIcon getThemedIcon(const QString& name);
|
QIcon getThemedIcon(const QString& name);
|
||||||
|
|
||||||
bool isFlatpak();
|
|
||||||
|
|
||||||
void setIconTheme(const QString& name);
|
void setIconTheme(const QString& name);
|
||||||
|
|
||||||
std::vector<ITheme *> getValidApplicationThemes();
|
std::vector<ITheme *> getValidApplicationThemes();
|
||||||
|
@ -119,7 +119,7 @@ bool openDirectory(const QString &path, bool ensureExists)
|
|||||||
return QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath()));
|
return QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath()));
|
||||||
};
|
};
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
if(!APPLICATION->isFlatpak())
|
if(!isFlatpak())
|
||||||
{
|
{
|
||||||
return IndirectOpen(f);
|
return IndirectOpen(f);
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ bool openFile(const QString &path)
|
|||||||
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
};
|
};
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
if(!APPLICATION->isFlatpak())
|
if(!isFlatpak())
|
||||||
{
|
{
|
||||||
return IndirectOpen(f);
|
return IndirectOpen(f);
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ bool openFile(const QString &application, const QString &path, const QString &wo
|
|||||||
qDebug() << "Opening file" << path << "using" << application;
|
qDebug() << "Opening file" << path << "using" << application;
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
|
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
|
||||||
if(!APPLICATION->isFlatpak())
|
if(!isFlatpak())
|
||||||
{
|
{
|
||||||
return IndirectOpen([&]()
|
return IndirectOpen([&]()
|
||||||
{
|
{
|
||||||
@ -178,7 +178,7 @@ bool run(const QString &application, const QStringList &args, const QString &wor
|
|||||||
{
|
{
|
||||||
qDebug() << "Running" << application << "with args" << args.join(' ');
|
qDebug() << "Running" << application << "with args" << args.join(' ');
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
if(!APPLICATION->isFlatpak())
|
if(!isFlatpak())
|
||||||
{
|
{
|
||||||
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
|
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
|
||||||
return IndirectOpen([&]()
|
return IndirectOpen([&]()
|
||||||
@ -203,7 +203,7 @@ bool openUrl(const QUrl &url)
|
|||||||
return QDesktopServices::openUrl(url);
|
return QDesktopServices::openUrl(url);
|
||||||
};
|
};
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
if(!APPLICATION->isFlatpak())
|
if(!isFlatpak())
|
||||||
{
|
{
|
||||||
return IndirectOpen(f);
|
return IndirectOpen(f);
|
||||||
}
|
}
|
||||||
@ -216,4 +216,13 @@ bool openUrl(const QUrl &url)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isFlatpak()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
return QFile::exists("/.flatpak-info");
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,4 +33,6 @@ namespace DesktopServices
|
|||||||
* Open the URL, most likely in a browser. Maybe.
|
* Open the URL, most likely in a browser. Maybe.
|
||||||
*/
|
*/
|
||||||
bool openUrl(const QUrl &url);
|
bool openUrl(const QUrl &url);
|
||||||
|
|
||||||
|
bool isFlatpak();
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include "DesktopServices.h"
|
||||||
|
|
||||||
#if defined Q_OS_WIN32
|
#if defined Q_OS_WIN32
|
||||||
#include <objbase.h>
|
#include <objbase.h>
|
||||||
@ -228,6 +229,9 @@ bool trash(QString path, QString *pathInTrash = nullptr)
|
|||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
|
// FIXME: Figure out trash in Flatpak. Qt seemingly doesn't use the Trash portal
|
||||||
|
if (DesktopServices::isFlatpak())
|
||||||
|
return false;
|
||||||
return QFile::moveToTrash(path, pathInTrash);
|
return QFile::moveToTrash(path, pathInTrash);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,12 @@ struct Language
|
|||||||
else if(key == "es_UY") {
|
else if(key == "es_UY") {
|
||||||
result = u8"español de Latinoamérica";
|
result = u8"español de Latinoamérica";
|
||||||
}
|
}
|
||||||
|
else if(key == "en@pirate") {
|
||||||
|
result = u8"Tongue of the High Seas";
|
||||||
|
}
|
||||||
|
else if(key == "en@uwu") {
|
||||||
|
result = u8"Cute Engwish";
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
result = locale.nativeLanguageName();
|
result = locale.nativeLanguageName();
|
||||||
}
|
}
|
||||||
|
@ -335,11 +335,10 @@ public:
|
|||||||
all_actions.append(&actionSettings);
|
all_actions.append(&actionSettings);
|
||||||
|
|
||||||
actionUndoTrashInstance = TranslatedAction(MainWindow);
|
actionUndoTrashInstance = TranslatedAction(MainWindow);
|
||||||
connect(actionUndoTrashInstance, SIGNAL(triggered(bool)), MainWindow, SLOT(undoTrashInstance()));
|
|
||||||
actionUndoTrashInstance->setObjectName(QStringLiteral("actionUndoTrashInstance"));
|
actionUndoTrashInstance->setObjectName(QStringLiteral("actionUndoTrashInstance"));
|
||||||
actionUndoTrashInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Undo Last Instance Deletion"));
|
actionUndoTrashInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Undo Last Instance Deletion"));
|
||||||
actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
|
actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
|
||||||
actionUndoTrashInstance->setShortcut(QKeySequence("Ctrl+Z"));
|
actionUndoTrashInstance->setShortcut(QKeySequence::Undo);
|
||||||
all_actions.append(&actionUndoTrashInstance);
|
all_actions.append(&actionUndoTrashInstance);
|
||||||
|
|
||||||
actionClearMetadata = TranslatedAction(MainWindow);
|
actionClearMetadata = TranslatedAction(MainWindow);
|
||||||
@ -1023,6 +1022,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(ui->actionUndoTrashInstance.operator->(), &QAction::triggered, this, &MainWindow::undoTrashInstance);
|
||||||
|
|
||||||
setSelectedInstanceById(APPLICATION->settings()->get("SelectedInstance").toString());
|
setSelectedInstanceById(APPLICATION->settings()->get("SelectedInstance").toString());
|
||||||
|
|
||||||
// removing this looks stupid
|
// removing this looks stupid
|
||||||
@ -1134,11 +1135,6 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
|||||||
connect(actionDeleteGroup, SIGNAL(triggered(bool)), SLOT(deleteGroup()));
|
connect(actionDeleteGroup, SIGNAL(triggered(bool)), SLOT(deleteGroup()));
|
||||||
actions.append(actionDeleteGroup);
|
actions.append(actionDeleteGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *actionUndoTrashInstance = new QAction("Undo last trash instance", this);
|
|
||||||
connect(actionUndoTrashInstance, SIGNAL(triggered(bool)), SLOT(undoTrashInstance()));
|
|
||||||
actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
|
|
||||||
actions.append(actionUndoTrashInstance);
|
|
||||||
}
|
}
|
||||||
QMenu myMenu;
|
QMenu myMenu;
|
||||||
myMenu.addActions(actions);
|
myMenu.addActions(actions);
|
||||||
@ -1834,6 +1830,7 @@ void MainWindow::deleteGroup()
|
|||||||
void MainWindow::undoTrashInstance()
|
void MainWindow::undoTrashInstance()
|
||||||
{
|
{
|
||||||
APPLICATION->instances()->undoTrashInstance();
|
APPLICATION->instances()->undoTrashInstance();
|
||||||
|
ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionViewInstanceFolder_triggered()
|
void MainWindow::on_actionViewInstanceFolder_triggered()
|
||||||
@ -1940,6 +1937,7 @@ void MainWindow::on_actionDeleteInstance_triggered()
|
|||||||
|
|
||||||
auto id = m_selectedInstance->id();
|
auto id = m_selectedInstance->id();
|
||||||
if (APPLICATION->instances()->trashInstance(id)) {
|
if (APPLICATION->instances()->trashInstance(id)) {
|
||||||
|
ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
|
#include "DesktopServices.h"
|
||||||
#include "ui/themes/ITheme.h"
|
#include "ui/themes/ITheme.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -143,7 +144,7 @@ void LauncherPage::on_instDirBrowseBtn_clicked()
|
|||||||
ui->instDirTextBox->setText(cooked_dir);
|
ui->instDirTextBox->setText(cooked_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(APPLICATION->isFlatpak() && raw_dir.startsWith("/run/user"))
|
else if(DesktopServices::isFlatpak() && raw_dir.startsWith("/run/user"))
|
||||||
{
|
{
|
||||||
QMessageBox warning;
|
QMessageBox warning;
|
||||||
warning.setText(tr("You're trying to specify an instance folder "
|
warning.setText(tr("You're trying to specify an instance folder "
|
||||||
|
Loading…
Reference in New Issue
Block a user