diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 1c95feb..b9b0639 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -3,9 +3,8 @@ option(CHIAKI_GUI_ENABLE_QT_GAMEPAD "Use QtGamepad for Input" ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
-find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Multimedia OpenGL)
+find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Multimedia OpenGL Svg)
if(CHIAKI_GUI_ENABLE_QT_GAMEPAD)
find_package(Qt5 REQUIRED COMPONENTS Gamepad)
endif()
@@ -46,12 +45,13 @@ add_executable(chiaki
include/settingsdialog.h
src/settingsdialog.cpp
include/manualhostdialog.h
- src/manualhostdialog.cpp)
+ src/manualhostdialog.cpp
+ res/resources.qrc)
target_include_directories(chiaki PRIVATE include)
target_link_libraries(chiaki chiaki-lib chiaki-cli-lib)
target_link_libraries(chiaki FFMPEG::avcodec)
-target_link_libraries(chiaki Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Multimedia Qt5::OpenGL)
+target_link_libraries(chiaki Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Multimedia Qt5::OpenGL Qt5::Svg)
if(CHIAKI_GUI_ENABLE_QT_GAMEPAD)
target_link_libraries(chiaki Qt5::Gamepad)
target_compile_definitions(chiaki PRIVATE CHIAKI_GUI_ENABLE_QT_GAMEPAD)
diff --git a/gui/res/add-24px.svg b/gui/res/add-24px.svg
new file mode 100644
index 0000000..875bd8f
--- /dev/null
+++ b/gui/res/add-24px.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/gui/res/discover-24px.svg b/gui/res/discover-24px.svg
new file mode 100644
index 0000000..a490b68
--- /dev/null
+++ b/gui/res/discover-24px.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/gui/res/resources.qrc b/gui/res/resources.qrc
new file mode 100644
index 0000000..28ea56e
--- /dev/null
+++ b/gui/res/resources.qrc
@@ -0,0 +1,7 @@
+
+
+ settings-20px.svg
+ add-24px.svg
+ discover-24px.svg
+
+
diff --git a/gui/res/settings-20px.svg b/gui/res/settings-20px.svg
new file mode 100644
index 0000000..0737ecb
--- /dev/null
+++ b/gui/res/settings-20px.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/gui/src/main.cpp b/gui/src/main.cpp
index f1a920a..da2d7c4 100644
--- a/gui/src/main.cpp
+++ b/gui/src/main.cpp
@@ -57,6 +57,8 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
+ QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+
Settings settings;
QCommandLineParser parser;
diff --git a/gui/src/mainwindow.cpp b/gui/src/mainwindow.cpp
index c9c903e..c2d162a 100644
--- a/gui/src/mainwindow.cpp
+++ b/gui/src/mainwindow.cpp
@@ -31,6 +31,57 @@
#include
#include
#include
+#include
+#include
+#include
+#include
+
+class IconEngine : public QIconEngine
+{
+ private:
+ QString filename;
+ QSvgRenderer renderer;
+
+ public:
+ IconEngine(const QString &filename) : filename(filename), renderer(filename) {};
+
+ QIconEngine *clone() const override { return new IconEngine(filename); }
+
+ QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override
+ {
+ auto r = QPixmap(size);
+ r.fill(Qt::transparent);
+ QPainter painter(&r);
+ paint(&painter, r.rect(), mode, state);
+ painter.end();
+ return r;
+ }
+
+ void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override
+ {
+ painter->setCompositionMode(QPainter::CompositionMode::CompositionMode_Source);
+ renderer.render(painter, rect);
+ painter->setCompositionMode(QPainter::CompositionMode::CompositionMode_SourceAtop);
+
+ QPalette::ColorGroup color_group = QPalette::ColorGroup::Normal;
+ switch(mode)
+ {
+ case QIcon::Mode::Disabled:
+ color_group = QPalette::ColorGroup::Disabled;
+ break;
+ case QIcon::Mode::Active:
+ color_group = QPalette::ColorGroup::Active;
+ break;
+ case QIcon::Mode::Normal:
+ color_group = QPalette::ColorGroup::Normal;
+ break;
+ case QIcon::Mode::Selected:
+ color_group = QPalette::ColorGroup::Normal;
+ break;
+ }
+ painter->fillRect(rect, qApp->palette().brush(color_group, QPalette::ColorRole::ButtonText));
+ }
+};
MainWindow::MainWindow(Settings *settings, QWidget *parent)
: QMainWindow(parent),
@@ -42,11 +93,16 @@ MainWindow::MainWindow(Settings *settings, QWidget *parent)
setCentralWidget(main_widget);
layout->setMargin(0);
+ auto LoadIcon = [this](const QString &filename) {
+ return QIcon(new IconEngine(filename));
+ };
+
auto tool_bar = new QToolBar(this);
tool_bar->setMovable(false);
addToolBar(tool_bar);
discover_action = new QAction(tr("Automatically Search for Consoles"), this);
+ discover_action->setIcon(LoadIcon(":/icons/discover-24px.svg"));
discover_action->setCheckable(true);
discover_action->setChecked(settings->GetDiscoveryEnabled());
tool_bar->addAction(discover_action);
@@ -56,14 +112,16 @@ MainWindow::MainWindow(Settings *settings, QWidget *parent)
tool_bar_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored);
tool_bar->addWidget(tool_bar_spacer);
- auto regist_action = new QAction(tr("Add Console manually"), this);
- tool_bar->addAction(regist_action);
- connect(regist_action, &QAction::triggered, this, [this]() {
+ auto add_manual_action = new QAction(tr("Add Console manually"), this);
+ add_manual_action->setIcon(LoadIcon(":/icons/add-24px.svg"));
+ tool_bar->addAction(add_manual_action);
+ connect(add_manual_action, &QAction::triggered, this, [this]() {
ManualHostDialog dialog(this->settings, -1, this);
dialog.exec();
});
auto settings_action = new QAction(tr("Settings"), this);
+ settings_action->setIcon(LoadIcon(":/icons/settings-20px.svg"));
tool_bar->addAction(settings_action);
connect(settings_action, &QAction::triggered, this, &MainWindow::ShowSettings);
diff --git a/gui/src/streamsession.cpp b/gui/src/streamsession.cpp
index a53de32..cb146a6 100644
--- a/gui/src/streamsession.cpp
+++ b/gui/src/streamsession.cpp
@@ -138,6 +138,12 @@ void StreamSession::HandleKeyboardEvent(QKeyEvent *event)
case Qt::Key::Key_Backspace:
button_mask = CHIAKI_CONTROLLER_BUTTON_MOON;
break;
+ case Qt::Key::Key_Escape:
+ button_mask = CHIAKI_CONTROLLER_BUTTON_PS;
+ break;
+ case Qt::Key::Key_T:
+ button_mask = CHIAKI_CONTROLLER_BUTTON_TOUCHPAD;
+ break;
default:
// not interested
return;