diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 34d4d7f..9a72982 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -34,7 +34,9 @@ add_executable(chiaki
include/avopenglwidget.h
src/avopenglwidget.cpp
include/avopenglframeuploader.h
- src/avopenglframeuploader.cpp)
+ src/avopenglframeuploader.cpp
+ include/servericonwidget.h
+ src/servericonwidget.cpp)
target_include_directories(chiaki PRIVATE include)
target_link_libraries(chiaki chiaki-lib chiaki-cli-lib)
diff --git a/gui/include/servericonwidget.h b/gui/include/servericonwidget.h
new file mode 100644
index 0000000..0dc5343
--- /dev/null
+++ b/gui/include/servericonwidget.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of Chiaki.
+ *
+ * Chiaki is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chiaki is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Chiaki. If not, see .
+ */
+
+#ifndef CHIAKI_SERVERICONWIDGET_H
+#define CHIAKI_SERVERICONWIDGET_H
+
+#include
+
+#include
+
+class ServerIconWidget : public QWidget
+{
+ Q_OBJECT
+
+ private:
+ ChiakiDiscoveryHostState state = CHIAKI_DISCOVERY_HOST_STATE_UNKNOWN;
+
+ protected:
+ void paintEvent(QPaintEvent *event) override;
+
+ public:
+ explicit ServerIconWidget(QWidget *parent = nullptr) : QWidget(parent) {}
+
+ void SetState(ChiakiDiscoveryHostState state) { this->state = state; update(); }
+};
+
+#endif // CHIAKI_SERVERICONWIDGET_H
diff --git a/gui/include/serveritemwidget.h b/gui/include/serveritemwidget.h
index 6398631..032b380 100644
--- a/gui/include/serveritemwidget.h
+++ b/gui/include/serveritemwidget.h
@@ -20,6 +20,8 @@
#include
+class ServerIconWidget;
+
class ServerItemWidget : public QWidget
{
Q_OBJECT
@@ -27,6 +29,8 @@ class ServerItemWidget : public QWidget
private:
bool selected;
+ ServerIconWidget *icon_widget;
+
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
diff --git a/gui/src/servericonwidget.cpp b/gui/src/servericonwidget.cpp
new file mode 100644
index 0000000..05f74e8
--- /dev/null
+++ b/gui/src/servericonwidget.cpp
@@ -0,0 +1,49 @@
+/*
+ * This file is part of Chiaki.
+ *
+ * Chiaki is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chiaki is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Chiaki. If not, see .
+ */
+
+#include
+
+#include
+
+void ServerIconWidget::paintEvent(QPaintEvent *event)
+{
+ static const float icon_aspect = 100.0f / 17.0f;
+
+ if(width() == 0 || height() == 0)
+ return;
+
+ QPainter painter(this);
+
+ QRect icon_rect;
+ float widget_aspect = (float)width() / (float)height();
+ if(widget_aspect > icon_aspect)
+ {
+ icon_rect.setHeight(height());
+ icon_rect.setWidth((int)((float)height() * icon_aspect));
+ icon_rect.moveTop(0);
+ icon_rect.moveLeft((width() - icon_rect.width()) / 2);
+ }
+ else
+ {
+ icon_rect.setWidth(width());
+ icon_rect.setHeight((int)((float)width() / icon_aspect));
+ icon_rect.moveLeft(0);
+ icon_rect.moveTop((height() - icon_rect.height()) / 2);
+ }
+
+ painter.fillRect(icon_rect, Qt::red);
+}
\ No newline at end of file
diff --git a/gui/src/serveritemwidget.cpp b/gui/src/serveritemwidget.cpp
index 18a1a21..a8c16e5 100644
--- a/gui/src/serveritemwidget.cpp
+++ b/gui/src/serveritemwidget.cpp
@@ -16,6 +16,7 @@
*/
#include
+#include
#include
#include
@@ -29,6 +30,9 @@ ServerItemWidget::ServerItemWidget(QWidget *parent) : QWidget(parent)
auto label = new QLabel("Server", this);
layout->addWidget(label);
+ icon_widget = new ServerIconWidget(this);
+ layout->addWidget(icon_widget);
+
this->selected = true;
SetSelected(false);