Skip to content

Commit

Permalink
Merge branch 'main' into cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongGino committed Dec 3, 2024
2 parents 61723cc + 81e4578 commit c907f8b
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 67 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sudo dnf install qt6-qtbase-devel qt6-qttools-devel qt6-qt5compat-devel quazip-q
```
#### Debian/Ubuntu (& derivatives)
```
sudo apt install build-essential cmake qt6-base-dev qttools6-dev qt6-5compat-dev libquazip1-qt6
sudo apt install build-essential cmake qt6-base-dev qt6-tools-dev qt6-5compat-dev libquazip1-qt6-dev
```

Additionally, Nero uses the following external components, either implicitly or optionally:
Expand Down
48 changes: 28 additions & 20 deletions src/nerofs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <QMessageBox>
#include <QFileDialog>
#include <QStandardPaths>

NeroFS::NeroFS() {}

Expand All @@ -38,7 +39,7 @@ QStringList NeroFS::prefixes;
QStringList NeroFS::availableProtons;

bool NeroFS::InitPaths() {
QSettings managerCfg(QString("%1/NeroLauncher.ini").arg(qEnvironmentVariable("XDG_CONFIG_HOME")), QSettings::IniFormat);
QSettings managerCfg(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/Nero-UMU.ini", QSettings::IniFormat);
managerCfg.beginGroup("NeroSettings");

if(managerCfg.value("Home").toString().isEmpty()) {
Expand All @@ -52,27 +53,26 @@ bool NeroFS::InitPaths() {
QString dir = QFileDialog::getExistingDirectory(NULL,
"Select Nero Home Directory",
qEnvironmentVariable("HOME"));
if(!dir.isEmpty()) {
managerCfg.setValue("Home", dir);
} else {
if(!dir.isEmpty()) managerCfg.setValue("Home", dir);
else {
QMessageBox::critical(NULL,
"ERROR: No directory!",
"ERROR: No Home Directory!",
"Directory is empty, or the operation was canceled.");
return false;
}
}
prefixesPath.setPath(managerCfg.value("Home").toString());

QDir steamDir(QString("%1/.steam/steam/compatibilitytools.d").arg(qEnvironmentVariable("HOME")));
QDir steamDir(qEnvironmentVariable("HOME") + "/.steam/steam/compatibilitytools.d");
if(steamDir.exists()) {
protonsPath.setPath(steamDir.path());
printf("Steam detected, using existing compatibilitytools.d\n");
} else {
printf("Working Steam install not detected, using Nero data directory for Proton versions\n");
protonsPath.setPath(QString("%1/NeroLauncher/protons").arg(qEnvironmentVariable("XDG_DATA_HOME")));
protonsPath.setPath(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/Nero-UMU/protons");
if(!protonsPath.exists()) {
printf("Nero directory doesn't exist! Creating paths...\n");
protonsPath.mkpath(QString("%1/NeroLauncher/protons").arg(qEnvironmentVariable("XDG_DATA_HOME")));
protonsPath.mkpath(".");
}
}

Expand All @@ -82,10 +82,10 @@ bool NeroFS::InitPaths() {
QStringList NeroFS::GetPrefixes()
{
if(prefixes.isEmpty()) {
prefixes = NeroFS::GetPrefixesPath().entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
prefixes = prefixesPath.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
for(int i = prefixes.count()-1; i >= 0; i--) {
// should we do ACTUAL ini verification? Or just checking to make sure it exists?
if(!QDir(NeroFS::GetPrefixesPath()).exists(QString("%1/nero-settings.ini").arg(prefixes.at(i)))) {
if(!prefixesPath.exists(prefixes.at(i) + "/nero-settings.ini")) {
prefixes.removeAt(i);
}
}
Expand All @@ -96,7 +96,7 @@ QStringList NeroFS::GetPrefixes()

void NeroFS::CreateUserLinks(QString prefixName)
{
QDir prefixDir(QString("%1/%2").arg(NeroFS::GetPrefixesPath().path(), prefixName));
QDir prefixDir(NeroFS::GetPrefixesPath().path() + '/' + prefixName);
if(prefixDir.exists()) {
// TODO: should we allow the user to selectively link certain directories?
prefixDir.setPath(QString("%1/%2/drive_c/users/%3/Desktop").arg(NeroFS::GetPrefixesPath().path(),
Expand Down Expand Up @@ -201,11 +201,19 @@ QString NeroFS::GetUmU()
} else { return ""; }
}

QString NeroFS::GetWinetricks()
QString NeroFS::GetWinetricks(const QString &runner)
{
// Each Proton version comes with a Winetricks script. Neat!
if(QDir(QString("%1/%2/protonfixes").arg(GetProtonsPath().path(), GetCurrentRunner())).exists("winetricks"))
return QString("%1/%2/protonfixes/winetricks").arg(GetProtonsPath().path(), GetCurrentRunner());
if(!runner.isEmpty()) {
if(QDir(protonsPath.path() + '/' + runner + "/protonfixes").exists("winetricks"))
return protonsPath.path() + '/' + runner + "/protonfixes/winetricks";
else {
// fall back to system winetricks
if(QDir("/usr/bin").exists("winetricks"))
return "/usr/bin/winetricks";
else return "";
}
} else if(QDir(protonsPath.path() + '/' + currentRunner + "/protonfixes").exists("winetricks"))
return protonsPath.path() + '/' + currentRunner + "/protonfixes/winetricks";
else {
// fall back to system winetricks
if(QDir("/usr/bin").exists("winetricks"))
Expand All @@ -228,7 +236,7 @@ QSettings* NeroFS::GetCurrentPrefixCfg()
{
if(prefixCfg != nullptr) { delete prefixCfg; }
if(!currentPrefix.isEmpty()) {
prefixCfg = new QSettings(QString("%1/%2/nero-settings.ini").arg(prefixesPath.path(), currentPrefix), QSettings::IniFormat);
prefixCfg = new QSettings(prefixesPath.path() + '/' + currentPrefix + "/nero-settings.ini", QSettings::IniFormat);
return prefixCfg;
} else {
// if we're running into this problem, then something's gone horribly wrong.
Expand Down Expand Up @@ -340,7 +348,7 @@ QMap<QString, QVariant> NeroFS::GetShortcutSettings(const QString shortcutHash)
{
GetCurrentPrefixCfg();
if(!prefixCfg->group().isEmpty()) prefixCfg->endGroup();
prefixCfg->beginGroup(QString("Shortcuts--%1").arg(shortcutHash));
prefixCfg->beginGroup("Shortcuts--" + shortcutHash);
const QStringList settingKeys = prefixCfg->childKeys();
QMap<QString, QVariant> settings;
for(const auto &key : settingKeys) {
Expand Down Expand Up @@ -391,7 +399,7 @@ QMap<QString, QString> NeroFS::GetCurrentShortcutsMap()
bool NeroFS::DeletePrefix(const QString prefix)
{
prefixes.removeOne(prefix);
if(QDir(QString("%1/%2").arg(prefixesPath.path(), prefix)).removeRecursively())
if(QDir(prefixesPath.path() + '/' + prefix).removeRecursively())
return true;
else return false;
}
Expand All @@ -404,9 +412,9 @@ void NeroFS::DeleteShortcut(const QString shortcutHash)
QString name = prefixCfg->value(shortcutHash).toString();
prefixCfg->remove(shortcutHash);
prefixCfg->endGroup();
prefixCfg->beginGroup(QString("Shortcuts--%1").arg(shortcutHash));
prefixCfg->beginGroup("Shortcuts--" + shortcutHash);
prefixCfg->remove("");
prefixCfg->endGroup();
QFile icoFile(QString("%1/%2/.icoCache/%3-%4.png").arg(prefixesPath.path(), currentPrefix, name, shortcutHash));
QFile icoFile(prefixesPath.path() + '/' + currentPrefix + "/.icoCache/" + name + '-' + shortcutHash + ".png");
if(icoFile.exists()) icoFile.remove();
}
2 changes: 1 addition & 1 deletion src/nerofs.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class NeroFS
static QString GetIcoextract();
static QString GetIcoutils();
static QString GetUmU();
static QString GetWinetricks();
static QString GetWinetricks(const QString & = "");

static void SetCurrentPrefix(const QString);
static bool SetCurrentPrefixCfg(const QString, const QString, const QVariant);
Expand Down
25 changes: 19 additions & 6 deletions src/neromanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ NeroManagerWindow::NeroManagerWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::NeroManagerWindow)
{
QCoreApplication::setApplicationName("Nero-UMU");

// rand + undefined int, bit shifted to only give the three least significant bytes (0-7)
// THIS can be set before window setup...
switch(((LOLRANDOM + rand()) >> 29)) {
Expand Down Expand Up @@ -75,7 +77,7 @@ NeroManagerWindow::NeroManagerWindow(QWidget *parent)
"Please install at least one Proton version at:\n\n" +
NeroFS::GetProtonsPath().path() +
"\n\nYou can install new runners either through Steam, or a Proton Manager such as ProtonUp-Qt or ProtonPlus."
"\n\nNero Will now exit, umu.");
"\n\nNero will now exit, umu.");
exit(1);
}
managerCfg = new QSettings(NeroFS::GetManagerCfg());
Expand Down Expand Up @@ -106,11 +108,7 @@ NeroManagerWindow::NeroManagerWindow(QWidget *parent)

ui->prefixContentsScrollArea->setVisible(false);

if(NeroFS::GetWinetricks().isEmpty()) {
ui->prefixTricksBtn->setEnabled(false);
ui->prefixTricksBtn->setText("Winetricks Not Found");
ui->prefixTricksBtn->setStyleSheet("color: red");
}
CheckWinetricks();

blinkTimer = new QTimer();
connect(blinkTimer, &QTimer::timeout, this, &NeroManagerWindow::blinkTimer_timeout);
Expand Down Expand Up @@ -376,6 +374,19 @@ void NeroManagerWindow::CreatePrefix(const QString newPrefix, const QString runn
QGuiApplication::restoreOverrideCursor();
}

void NeroManagerWindow::CheckWinetricks()
{
if(NeroFS::GetWinetricks().isEmpty()) {
ui->prefixTricksBtn->setEnabled(false);
ui->prefixTricksBtn->setText("Winetricks Not Found");
ui->prefixTricksBtn->setStyleSheet("color: red");
} else {
ui->prefixTricksBtn->setEnabled(true);
ui->prefixTricksBtn->setText("Install Winetricks Components");
ui->prefixTricksBtn->setStyleSheet("");
}
}

void NeroManagerWindow::AddTricks(QStringList verbs, const QString prefix)
{
QProcess umu;
Expand Down Expand Up @@ -571,6 +582,8 @@ void NeroManagerWindow::prefixMainButtons_clicked()
}

SetHeader(NeroFS::GetCurrentPrefix(), NeroFS::GetCurrentPrefixShortcuts().count());

CheckWinetricks();
}

void NeroManagerWindow::prefixDeleteButtons_clicked()
Expand Down
1 change: 1 addition & 0 deletions src/neromanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private slots:

// METHODS
void SetHeader(const QString prefix = "", const unsigned int shortcutsCount = 0);
void CheckWinetricks();
void RenderPrefixes();
void RenderPrefixList();
void CreatePrefix(const QString newPrefix, const QString runner, QStringList tricksToInstall = {});
Expand Down
10 changes: 8 additions & 2 deletions src/neromanager.ui
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<item>
<widget class="QLabel" name="topSubtitle">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
Expand All @@ -85,6 +85,9 @@
<pointsize>9</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: gray</string>
</property>
<property name="text">
<string>Subtitle</string>
</property>
Expand Down Expand Up @@ -261,7 +264,10 @@
<item>
<widget class="QLabel" name="missingPrefixesLabel">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">color: gray</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt; font-weight:700;&quot;&gt;There are no Proton prefixes available!&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Press the + button above to create one.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
Expand Down
6 changes: 6 additions & 0 deletions src/neroprefixsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ NeroPrefixSettingsWindow::NeroPrefixSettingsWindow(QWidget *parent, const QStrin
// QComboboxes aren't new syntax friendly?
if(!child->property("isFor").isNull()) connect(child, SIGNAL(activated(int)), this, SLOT(OptionSet()));
}

// light mode styling adjustments:
if(this->palette().window().color().value() > this->palette().text().color().value()) {
ui->infoBox->setStyleSheet("QGroupBox::title { color: #909000 }");
ui->infoText->setStyleSheet("color: doubledarkgray");
}
}

bool NeroPrefixSettingsWindow::eventFilter(QObject* object, QEvent* event)
Expand Down
15 changes: 5 additions & 10 deletions src/neroprefixsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>454</height>
<width>618</width>
<height>359</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down Expand Up @@ -1685,12 +1685,7 @@
</font>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox::title {
color: yellow
}</string>
</property>
<property name="title">
<string/>
<string notr="true">QGroupBox::title { color: yellow }</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
Expand All @@ -1715,8 +1710,8 @@ color: yellow
<rect>
<x>0</x>
<y>0</y>
<width>624</width>
<height>68</height>
<width>636</width>
<height>229</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
Expand Down
12 changes: 6 additions & 6 deletions src/nerotricks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
QStringList NeroTricksWindow::winetricksAvailVerbs;
QStringList NeroTricksWindow::winetricksDescriptions;

NeroTricksWindow::NeroTricksWindow(QWidget *parent)
NeroTricksWindow::NeroTricksWindow(QWidget *parent, const QString &runner)
: QDialog(parent)
, ui(new Ui::NeroTricksWindow)
{
ui->setupUi(this);

if(winetricksAvailVerbs.isEmpty()) { InitVerbs(); }
if(winetricksAvailVerbs.isEmpty()) { InitVerbs(runner); }

for(int i = 0; i < winetricksAvailVerbs.count(); i++) {
verbSelector << new QCheckBox(winetricksAvailVerbs.at(i), this);
Expand Down Expand Up @@ -74,14 +74,14 @@ NeroTricksWindow::~NeroTricksWindow()
delete ui;
}

void NeroTricksWindow::InitVerbs()
void NeroTricksWindow::InitVerbs(const QString &runner)
{
if(winetricksAvailVerbs.isEmpty()) {
if(!NeroFS::GetWinetricks().isEmpty()) {
if(!NeroFS::GetWinetricks(runner).isEmpty()) {
QProcess winetricksList;
QMessageBox waitBox(QMessageBox::NoIcon, "Winetricks Loading", "Please wait...");

winetricksList.start(NeroFS::GetWinetricks(), {"dlls", "list"});
winetricksList.start(NeroFS::GetWinetricks(runner), {"dlls", "list"});
waitBox.open();
waitBox.raise();
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
Expand All @@ -97,7 +97,7 @@ void NeroTricksWindow::InitVerbs()
winetricksDescriptions.clear();
}

if(NeroFS::GetWinetricks().contains("protontricks"))
if(NeroFS::GetWinetricks(runner).contains("protontricks"))
// read first line, which is boilerplate cd
winetricksList.readLine();

Expand Down
4 changes: 2 additions & 2 deletions src/nerotricks.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class NeroTricksWindow : public QDialog
Q_OBJECT

public:
explicit NeroTricksWindow(QWidget *parent = nullptr);
explicit NeroTricksWindow(QWidget *parent = nullptr, const QString & = "");
~NeroTricksWindow();

void InitVerbs();
void InitVerbs(const QString & = "");

void AddTricks(const QStringList newTricks);
void SetPreinstalledVerbs(const QStringList installed);
Expand Down
5 changes: 4 additions & 1 deletion src/nerowizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ NeroPrefixWizard::NeroPrefixWizard(QWidget *parent)
connect(winetricksPresets.at(1), &QAction::triggered, this, &NeroPrefixWizard::SetDXtricks);
connect(winetricksPresets.at(2), &QAction::triggered, this, &NeroPrefixWizard::SetVCRunTricks);
connect(winetricksPresets.at(3), &QAction::triggered, this, &NeroPrefixWizard::SetXactTricks);

if(this->palette().window().color().value() > this->palette().text().color().value())
ui->symlinkDisclaimer->setStyleSheet("color: doubledarkgray");
}

NeroPrefixWizard::~NeroPrefixWizard()
Expand Down Expand Up @@ -95,7 +98,7 @@ void NeroPrefixWizard::on_prefixNameInput_textChanged(const QString &arg1)

void NeroPrefixWizard::on_winetricksBox_clicked()
{
if(tricks == nullptr) { tricks = new NeroTricksWindow(this); }
if(tricks == nullptr) { tricks = new NeroTricksWindow(this, ui->protonRunnerBox->currentText()); }
bool confirmed = false;
QStringList prevVerbs = verbsToInstall;

Expand Down
Loading

0 comments on commit c907f8b

Please sign in to comment.