From 9d0175b81ab702467cd5c707669c12b6bbcb913e Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 16 Jul 2023 17:46:00 +0300 Subject: [PATCH 1/4] Added welcome screen Signed-off-by: Trial97 --- launcher/ui/instanceview/InstanceView.cpp | 79 +++++++++++++++++------ 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 1911dd59a..a1acf5875 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -35,32 +35,32 @@ #include "InstanceView.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "VisualGroup.h" #include "ui/themes/ThemeManager.h" -#include #include #include - -template bool listsIntersect(const QList &l1, const QList t2) +template +bool listsIntersect(const QList& l1, const QList t2) { - for (auto &item : l1) - { - if (t2.contains(item)) - { + for (auto& item : l1) { + if (t2.contains(item)) { return true; } } @@ -536,11 +536,50 @@ void InstanceView::paintEvent(QPaintEvent* event) #endif option.widget = this; + if (model()->rowCount() == 0) { + painter.save(); + const QString line1 = "Welcome!"; + const QString line2 = "Add an instance to get started."; + auto rect = this->viewport()->rect(); + auto font = option.font; + font.setPointSize(64); + painter.setFont(font); + auto fm = painter.fontMetrics(); + + if (rect.height() <= (fm.height() * 5) || rect.width() <= fm.horizontalAdvance(line2)) { + auto s = rect.height() / (5. * fm.height()); + auto sx = rect.width() * 1. / fm.horizontalAdvance(line2); + if (s >= sx) + s = sx; + auto ps = font.pointSize() * s; + if (ps <= 0) + ps = 1; + font.setPointSize(ps); + painter.setFont(font); + fm = painter.fontMetrics(); + } + // about icon + auto about = QIcon::fromTheme("about"); + QRect aboutRect(0, 0, fm.height() * .75, fm.height() * .75); + aboutRect.moveCenter(rect.center()); + aboutRect.moveTop(fm.height() * .75); + auto px = about.pixmap(about.actualSize(aboutRect.size())); + if (!px.isNull()) + painter.drawPixmap(aboutRect, px); + + // text + rect.setTop(rect.top() + fm.height() * 1.5); + painter.drawText(rect, Qt::AlignHCenter, line1); + rect.setTop(rect.top() + fm.height()); + painter.drawText(rect, Qt::AlignHCenter, line2); + painter.restore(); + return; + } + int wpWidth = viewport()->width(); option.rect.setWidth(wpWidth); - for (int i = 0; i < m_groups.size(); ++i) - { - VisualGroup *category = m_groups.at(i); + for (int i = 0; i < m_groups.size(); ++i) { + VisualGroup* category = m_groups.at(i); int y = category->verticalPosition(); y -= verticalOffset(); QRect backup = option.rect; From 7441974d9d22ad8596a52cf9fd70ae5e2e0e721a Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 16 Jul 2023 21:23:22 +0300 Subject: [PATCH 2/4] Removed icon Signed-off-by: Trial97 --- launcher/ui/instanceview/InstanceView.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index a1acf5875..9b0022229 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -542,7 +542,7 @@ void InstanceView::paintEvent(QPaintEvent* event) const QString line2 = "Add an instance to get started."; auto rect = this->viewport()->rect(); auto font = option.font; - font.setPointSize(64); + font.setPointSize(53); painter.setFont(font); auto fm = painter.fontMetrics(); @@ -558,14 +558,6 @@ void InstanceView::paintEvent(QPaintEvent* event) painter.setFont(font); fm = painter.fontMetrics(); } - // about icon - auto about = QIcon::fromTheme("about"); - QRect aboutRect(0, 0, fm.height() * .75, fm.height() * .75); - aboutRect.moveCenter(rect.center()); - aboutRect.moveTop(fm.height() * .75); - auto px = about.pixmap(about.actualSize(aboutRect.size())); - if (!px.isNull()) - painter.drawPixmap(aboutRect, px); // text rect.setTop(rect.top() + fm.height() * 1.5); From f5891940e0d8b52b2250b3e5b80532c71c39c7e8 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 17 Jul 2023 17:22:35 +0300 Subject: [PATCH 3/4] translate strings Signed-off-by: Trial97 --- launcher/ui/instanceview/InstanceView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 9b0022229..025382cb7 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -538,8 +538,8 @@ void InstanceView::paintEvent(QPaintEvent* event) if (model()->rowCount() == 0) { painter.save(); - const QString line1 = "Welcome!"; - const QString line2 = "Add an instance to get started."; + const QString line1 = tr("Welcome!"); + const QString line2 = tr("Add an instance to get started."); auto rect = this->viewport()->rect(); auto font = option.font; font.setPointSize(53); From 79652799bd88299f1e1bdb1b16449fae56c59913 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Sun, 27 Aug 2023 21:30:46 +0300 Subject: [PATCH 4/4] Made text smaller Signed-off-by: Trial97 --- launcher/ui/instanceview/InstanceView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 11402e58f..7530fdfba 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -482,10 +482,10 @@ void InstanceView::paintEvent([[maybe_unused]] QPaintEvent* event) if (model()->rowCount() == 0) { painter.save(); const QString line1 = tr("Welcome!"); - const QString line2 = tr("Add an instance to get started."); + const QString line2 = tr("Click \"Add Instance\" to get started."); auto rect = this->viewport()->rect(); auto font = option.font; - font.setPointSize(53); + font.setPointSize(37); painter.setFont(font); auto fm = painter.fontMetrics();