Help - improvement

This commit is contained in:
DanielSvoboda 2024-11-11 20:46:47 -03:00
parent 7ab851592b
commit 7936c25705
10 changed files with 212 additions and 10 deletions

BIN
src/images/discord.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
src/images/github.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
src/images/ko-fi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
src/images/youtube.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -1,13 +1,89 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <QDesktopServices>
#include <QEvent>
#include <QImage>
#include <QLabel>
#include <QPixmap>
#include "about_dialog.h"
#include "ui_about_dialog.h"
AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) {
ui->setupUi(this);
preloadImages();
ui->image_1->setAttribute(Qt::WA_Hover, true);
ui->image_2->setAttribute(Qt::WA_Hover, true);
ui->image_3->setAttribute(Qt::WA_Hover, true);
ui->image_4->setAttribute(Qt::WA_Hover, true);
ui->image_1->installEventFilter(this);
ui->image_2->installEventFilter(this);
ui->image_3->installEventFilter(this);
ui->image_4->installEventFilter(this);
}
AboutDialog::~AboutDialog() {
delete ui;
}
void AboutDialog::preloadImages() {
originalImages[0] = ui->image_1->pixmap().copy();
originalImages[1] = ui->image_2->pixmap().copy();
originalImages[2] = ui->image_3->pixmap().copy();
originalImages[3] = ui->image_4->pixmap().copy();
for (int i = 0; i < 4; ++i) {
QImage image = originalImages[i].toImage();
for (int y = 0; y < image.height(); ++y) {
for (int x = 0; x < image.width(); ++x) {
QColor color = image.pixelColor(x, y);
color.setRed(255 - color.red());
color.setGreen(255 - color.green());
color.setBlue(255 - color.blue());
image.setPixelColor(x, y, color);
}
}
invertedImages[i] = QPixmap::fromImage(image);
}
}
bool AboutDialog::eventFilter(QObject* obj, QEvent* event) {
if (event->type() == QEvent::Enter) {
if (obj == ui->image_1) {
ui->image_1->setPixmap(invertedImages[0]);
} else if (obj == ui->image_2) {
ui->image_2->setPixmap(invertedImages[1]);
} else if (obj == ui->image_3) {
ui->image_3->setPixmap(invertedImages[2]);
} else if (obj == ui->image_4) {
ui->image_4->setPixmap(invertedImages[3]);
}
} else if (event->type() == QEvent::Leave) {
if (obj == ui->image_1) {
ui->image_1->setPixmap(originalImages[0]);
} else if (obj == ui->image_2) {
ui->image_2->setPixmap(originalImages[1]);
} else if (obj == ui->image_3) {
ui->image_3->setPixmap(originalImages[2]);
} else if (obj == ui->image_4) {
ui->image_4->setPixmap(originalImages[3]);
}
} else if (event->type() == QEvent::MouseButtonPress) {
if (obj == ui->image_1) {
QDesktopServices::openUrl(QUrl("https://github.com/shadps4-emu/shadPS4"));
} else if (obj == ui->image_2) {
QDesktopServices::openUrl(QUrl("https://discord.gg/bFJxfftGW6"));
} else if (obj == ui->image_3) {
QDesktopServices::openUrl(QUrl("https://ko-fi.com/shadps4"));
} else if (obj == ui->image_4) {
QDesktopServices::openUrl(QUrl("https://www.youtube.com/@shadPS4/videos"));
}
return true;
}
return QDialog::eventFilter(obj, event);
}

View File

@ -3,7 +3,11 @@
#pragma once
#include <QDesktopServices>
#include <QDialog>
#include <QLabel>
#include <QPixmap>
#include <QUrl>
namespace Ui {
class AboutDialog;
@ -15,7 +19,12 @@ class AboutDialog : public QDialog {
public:
explicit AboutDialog(QWidget* parent = nullptr);
~AboutDialog();
bool eventFilter(QObject* obj, QEvent* event);
private:
Ui::AboutDialog* ui;
void preloadImages();
QPixmap originalImages[4];
QPixmap invertedImages[4];
};

View File

@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>780</width>
<height>320</height>
<height>310</height>
</rect>
</property>
<property name="windowTitle">
@ -22,14 +22,14 @@
<widget class="QLabel" name="shad_logo">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<x>15</x>
<y>15</y>
<width>271</width>
<height>261</height>
<height>271</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
@ -45,7 +45,7 @@
<property name="geometry">
<rect>
<x>310</x>
<y>40</y>
<y>15</y>
<width>171</width>
<height>41</height>
</rect>
@ -64,9 +64,9 @@
<property name="geometry">
<rect>
<x>310</x>
<y>90</y>
<y>60</y>
<width>451</width>
<height>101</height>
<height>70</height>
</rect>
</property>
<property name="font">
@ -85,9 +85,9 @@
<property name="geometry">
<rect>
<x>310</x>
<y>180</y>
<y>130</y>
<width>451</width>
<height>101</height>
<height>70</height>
</rect>
</property>
<property name="font">
@ -102,6 +102,106 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="image_1">
<property name="geometry">
<rect>
<x>310</x>
<y>210</y>
<width>80</width>
<height>80</height>
</rect>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/github.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="image_2">
<property name="geometry">
<rect>
<x>400</x>
<y>210</y>
<width>80</width>
<height>80</height>
</rect>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/discord.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="image_3">
<property name="geometry">
<rect>
<x>490</x>
<y>210</y>
<width>80</width>
<height>80</height>
</rect>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/ko-fi.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="image_4">
<property name="geometry">
<rect>
<x>580</x>
<y>210</y>
<width>80</width>
<height>80</height>
</rect>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/youtube.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</widget>
<resources/>
<connections/>

View File

@ -267,6 +267,11 @@ void MainWindow::CreateConnects() {
});
#endif
connect(ui->keys_shortcuts, &QAction::triggered, this, [this]() {
auto aboutDialog = new AboutDialog(this);
aboutDialog->exec();
});
connect(ui->aboutAct, &QAction::triggered, this, [this]() {
auto aboutDialog = new AboutDialog(this);
aboutDialog->exec();
@ -947,6 +952,7 @@ void MainWindow::SetUiIcons(bool isWhite) {
ui->downloadCheatsPatchesAct->setIcon(
RecolorIcon(ui->downloadCheatsPatchesAct->icon(), isWhite));
ui->dumpGameListAct->setIcon(RecolorIcon(ui->dumpGameListAct->icon(), isWhite));
ui->keys_shortcuts->setIcon(RecolorIcon(ui->keys_shortcuts->icon(), isWhite));
ui->aboutAct->setIcon(RecolorIcon(ui->aboutAct->icon(), isWhite));
ui->setlistModeListAct->setIcon(RecolorIcon(ui->setlistModeListAct->icon(), isWhite));
ui->setlistModeGridAct->setIcon(RecolorIcon(ui->setlistModeGridAct->icon(), isWhite));

View File

@ -30,6 +30,7 @@ public:
QAction* updaterAct;
#endif
QAction* aboutAct;
QAction* keys_shortcuts;
QAction* configureAct;
QAction* setThemeDark;
QAction* setThemeLight;
@ -140,6 +141,9 @@ public:
aboutAct = new QAction(MainWindow);
aboutAct->setObjectName("aboutAct");
aboutAct->setIcon(QIcon(":images/about_icon.png"));
keys_shortcuts = new QAction(MainWindow);
keys_shortcuts->setObjectName("keys_shortcuts");
keys_shortcuts->setIcon(QIcon(":images/about_icon.png"));
configureAct = new QAction(MainWindow);
configureAct->setObjectName("configureAct");
configureAct->setIcon(QIcon(":images/settings_icon.png"));
@ -298,6 +302,7 @@ public:
#ifdef ENABLE_UPDATER
menuHelp->addAction(updaterAct);
#endif
menuHelp->addAction(keys_shortcuts);
menuHelp->addAction(aboutAct);
retranslateUi(MainWindow);
@ -317,6 +322,8 @@ public:
QCoreApplication::translate("MainWindow", "Check for Updates", nullptr));
#endif
aboutAct->setText(QCoreApplication::translate("MainWindow", "About shadPS4", nullptr));
keys_shortcuts->setText(
QCoreApplication::translate("MainWindow", "Keys and Shortcuts", nullptr));
configureAct->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
#if QT_CONFIG(tooltip)
bootInstallPkgAct->setToolTip(QCoreApplication::translate(

View File

@ -24,5 +24,9 @@
<file>images/flag_us.png</file>
<file>images/flag_world.png</file>
<file>images/flag_china.png</file>
<file>images/github.png</file>
<file>images/discord.png</file>
<file>images/ko-fi.png</file>
<file>images/youtube.png</file>
</qresource>
</RCC>