mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-29 14:53:18 +00:00
Help - improvement (#1522)
* Help - improvement * Adding shadow below icons * Adding keys icon + Update changelog * color according to the selected theme * submenu 'Keys and Shortcuts' * clang * + * remove keys_shortcuts --------- Co-authored-by: ¥IGA <164882787+Xphalnos@users.noreply.github.com>
This commit is contained in:
parent
0b59ebb22f
commit
07f451650f
12 changed files with 388 additions and 13 deletions
|
@ -1,13 +1,194 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QEvent>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QImage>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <common/config.h>
|
||||
#include "about_dialog.h"
|
||||
#include "main_window_themes.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_5->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);
|
||||
ui->image_5->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();
|
||||
originalImages[4] = ui->image_5->pixmap().copy();
|
||||
|
||||
for (int i = 0; i < 5; ++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);
|
||||
}
|
||||
updateImagesForCurrentTheme();
|
||||
}
|
||||
|
||||
void AboutDialog::updateImagesForCurrentTheme() {
|
||||
Theme currentTheme = static_cast<Theme>(Config::getMainWindowTheme());
|
||||
bool isDarkTheme = (currentTheme == Theme::Dark || currentTheme == Theme::Green ||
|
||||
currentTheme == Theme::Blue || currentTheme == Theme::Violet);
|
||||
if (isDarkTheme) {
|
||||
ui->image_1->setPixmap(invertedImages[0]);
|
||||
ui->image_2->setPixmap(invertedImages[1]);
|
||||
ui->image_3->setPixmap(invertedImages[2]);
|
||||
ui->image_4->setPixmap(invertedImages[3]);
|
||||
ui->image_5->setPixmap(invertedImages[4]);
|
||||
} else {
|
||||
ui->image_1->setPixmap(originalImages[0]);
|
||||
ui->image_2->setPixmap(originalImages[1]);
|
||||
ui->image_3->setPixmap(originalImages[2]);
|
||||
ui->image_4->setPixmap(originalImages[3]);
|
||||
ui->image_5->setPixmap(originalImages[4]);
|
||||
}
|
||||
}
|
||||
|
||||
bool AboutDialog::eventFilter(QObject* obj, QEvent* event) {
|
||||
if (event->type() == QEvent::Enter) {
|
||||
if (obj == ui->image_1) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_1->setPixmap(originalImages[0]);
|
||||
} else {
|
||||
ui->image_1->setPixmap(invertedImages[0]);
|
||||
}
|
||||
applyHoverEffect(ui->image_1);
|
||||
} else if (obj == ui->image_2) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_2->setPixmap(originalImages[1]);
|
||||
} else {
|
||||
ui->image_2->setPixmap(invertedImages[1]);
|
||||
}
|
||||
applyHoverEffect(ui->image_2);
|
||||
} else if (obj == ui->image_3) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_3->setPixmap(originalImages[2]);
|
||||
} else {
|
||||
ui->image_3->setPixmap(invertedImages[2]);
|
||||
}
|
||||
applyHoverEffect(ui->image_3);
|
||||
} else if (obj == ui->image_4) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_4->setPixmap(originalImages[3]);
|
||||
} else {
|
||||
ui->image_4->setPixmap(invertedImages[3]);
|
||||
}
|
||||
applyHoverEffect(ui->image_4);
|
||||
} else if (obj == ui->image_5) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_5->setPixmap(originalImages[4]);
|
||||
} else {
|
||||
ui->image_5->setPixmap(invertedImages[4]);
|
||||
}
|
||||
applyHoverEffect(ui->image_5);
|
||||
}
|
||||
} else if (event->type() == QEvent::Leave) {
|
||||
if (obj == ui->image_1) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_1->setPixmap(invertedImages[0]);
|
||||
} else {
|
||||
ui->image_1->setPixmap(originalImages[0]);
|
||||
}
|
||||
removeHoverEffect(ui->image_1);
|
||||
} else if (obj == ui->image_2) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_2->setPixmap(invertedImages[1]);
|
||||
} else {
|
||||
ui->image_2->setPixmap(originalImages[1]);
|
||||
}
|
||||
removeHoverEffect(ui->image_2);
|
||||
} else if (obj == ui->image_3) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_3->setPixmap(invertedImages[2]);
|
||||
} else {
|
||||
ui->image_3->setPixmap(originalImages[2]);
|
||||
}
|
||||
removeHoverEffect(ui->image_3);
|
||||
} else if (obj == ui->image_4) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_4->setPixmap(invertedImages[3]);
|
||||
} else {
|
||||
ui->image_4->setPixmap(originalImages[3]);
|
||||
}
|
||||
removeHoverEffect(ui->image_4);
|
||||
} else if (obj == ui->image_5) {
|
||||
if (isDarkTheme()) {
|
||||
ui->image_5->setPixmap(invertedImages[4]);
|
||||
} else {
|
||||
ui->image_5->setPixmap(originalImages[4]);
|
||||
}
|
||||
removeHoverEffect(ui->image_5);
|
||||
}
|
||||
} 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://www.youtube.com/@shadPS4/videos"));
|
||||
} else if (obj == ui->image_4) {
|
||||
QDesktopServices::openUrl(QUrl("https://ko-fi.com/shadps4"));
|
||||
} else if (obj == ui->image_5) {
|
||||
QDesktopServices::openUrl(QUrl("https://shadps4.net"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void AboutDialog::applyHoverEffect(QLabel* label) {
|
||||
QColor shadowColor = isDarkTheme() ? QColor(0, 0, 0) : QColor(169, 169, 169);
|
||||
QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect;
|
||||
shadow->setBlurRadius(5);
|
||||
shadow->setXOffset(2);
|
||||
shadow->setYOffset(2);
|
||||
shadow->setColor(shadowColor);
|
||||
label->setGraphicsEffect(shadow);
|
||||
}
|
||||
|
||||
void AboutDialog::removeHoverEffect(QLabel* label) {
|
||||
QColor shadowColor = isDarkTheme() ? QColor(50, 50, 50) : QColor(169, 169, 169);
|
||||
QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect;
|
||||
shadow->setBlurRadius(3);
|
||||
shadow->setXOffset(0);
|
||||
shadow->setYOffset(0);
|
||||
shadow->setColor(shadowColor);
|
||||
label->setGraphicsEffect(shadow);
|
||||
}
|
||||
|
||||
bool AboutDialog::isDarkTheme() const {
|
||||
Theme currentTheme = static_cast<Theme>(Config::getMainWindowTheme());
|
||||
return currentTheme == Theme::Dark || currentTheme == Theme::Green ||
|
||||
currentTheme == Theme::Blue || currentTheme == Theme::Violet;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QUrl>
|
||||
|
||||
namespace Ui {
|
||||
class AboutDialog;
|
||||
|
@ -15,7 +19,18 @@ class AboutDialog : public QDialog {
|
|||
public:
|
||||
explicit AboutDialog(QWidget* parent = nullptr);
|
||||
~AboutDialog();
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
private:
|
||||
Ui::AboutDialog* ui;
|
||||
};
|
||||
|
||||
void preloadImages();
|
||||
void updateImagesForCurrentTheme();
|
||||
void applyHoverEffect(QLabel* label);
|
||||
void removeHoverEffect(QLabel* label);
|
||||
|
||||
bool isDarkTheme() const;
|
||||
|
||||
QPixmap originalImages[5];
|
||||
QPixmap invertedImages[5];
|
||||
};
|
||||
|
|
|
@ -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,131 @@
|
|||
<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/youtube.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/ko-fi.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="image_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>670</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/website.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue