mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 02:36:51 -07:00
Add Icons
This commit is contained in:
parent
4fadc02947
commit
f8c9ddade4
8 changed files with 83 additions and 7 deletions
|
@ -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)
|
||||
|
|
1
gui/res/add-24px.svg
Normal file
1
gui/res/add-24px.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"/></svg>
|
After Width: | Height: | Size: 238 B |
1
gui/res/discover-24px.svg
Normal file
1
gui/res/discover-24px.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z"/></svg>
|
After Width: | Height: | Size: 305 B |
7
gui/res/resources.qrc
Normal file
7
gui/res/resources.qrc
Normal file
|
@ -0,0 +1,7 @@
|
|||
<RCC>
|
||||
<qresource prefix="icons">
|
||||
<file>settings-20px.svg</file>
|
||||
<file>add-24px.svg</file>
|
||||
<file>discover-24px.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
1
gui/res/settings-20px.svg
Normal file
1
gui/res/settings-20px.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path fill="none" d="M0 0h20v20H0V0z"/><path d="M15.95 10.78c.03-.25.05-.51.05-.78s-.02-.53-.06-.78l1.69-1.32c.15-.12.19-.34.1-.51l-1.6-2.77c-.1-.18-.31-.24-.49-.18l-1.99.8c-.42-.32-.86-.58-1.35-.78L12 2.34c-.03-.2-.2-.34-.4-.34H8.4c-.2 0-.36.14-.39.34l-.3 2.12c-.49.2-.94.47-1.35.78l-1.99-.8c-.18-.07-.39 0-.49.18l-1.6 2.77c-.1.18-.06.39.1.51l1.69 1.32c-.04.25-.07.52-.07.78s.02.53.06.78L2.37 12.1c-.15.12-.19.34-.1.51l1.6 2.77c.1.18.31.24.49.18l1.99-.8c.42.32.86.58 1.35.78l.3 2.12c.04.2.2.34.4.34h3.2c.2 0 .37-.14.39-.34l.3-2.12c.49-.2.94-.47 1.35-.78l1.99.8c.18.07.39 0 .49-.18l1.6-2.77c.1-.18.06-.39-.1-.51l-1.67-1.32zM10 13c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z"/></svg>
|
After Width: | Height: | Size: 774 B |
|
@ -57,6 +57,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
Settings settings;
|
||||
|
||||
QCommandLineParser parser;
|
||||
|
|
|
@ -31,6 +31,57 @@
|
|||
#include <QToolBar>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QIconEngine>
|
||||
#include <QSvgRenderer>
|
||||
#include <QApplication>
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue