From 347261f8895d959269afc0e63f2b0d98826086c4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 15 Mar 2019 22:30:14 +0100 Subject: Support passing dir as bottom-left-logo-path *.svg found in that directory will be shown in the bottom left corner, stacked on top of each other, in alphabetical order (top -> bottom). --- src/loginform.ui | 9 ++++++--- src/mainwindow.cpp | 26 +++++++++++++++++++++++--- src/mainwindow.h | 4 +++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/loginform.ui b/src/loginform.ui index abb196f..10f7105 100644 --- a/src/loginform.ui +++ b/src/loginform.ui @@ -80,12 +80,12 @@ QComboBox QAbstractItemView::item { - - 8 - 9 + + 8 + @@ -137,6 +137,9 @@ QComboBox QAbstractItemView::item { 30 + + Qt::NoFocus + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b66a73d..554d972 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -93,7 +93,7 @@ MainWindow::MainWindow(bool primary, int screen, const QRect &screenRect, QWidge int ls = (spaceY > 500 ? 500 : spaceY); if (ls > screenRect.height() / 5) ls = screenRect.height() / 5; if (ls > screenRect.width() / 5) ls = screenRect.width() / 5; - QRect logoRect(QPoint(0, screenRect.height() - ls), QSize(ls, ls)); + QRect logoRect(QPoint(0, screenRect.height() / 3), QSize(ls, screenRect.height() * 2 / 3)); QSize logoSize = createLogo(logoRect); QRect distroRect(QPoint(screenRect.width() - ls, screenRect.height() - ls), QSize(ls, ls)); QSize distroSize = createDistro(distroRect); @@ -109,11 +109,31 @@ MainWindow::~MainWindow() { } -QSize MainWindow::createLogo(const QRect &max) +QSize MainWindow::createLogo(QRect max) { QString path = Settings::bottomLeftLogoPath(); if (path.isEmpty()) return QSize(0, 0); + // Check whether it's a file or directory + if (QFileInfo(path).isDir()) { + QSize retval(0, 0); + QFileInfoList fileInfoList = QDir(path).entryInfoList(QStringList() << "*.svg", QDir::Files, QDir::Name | QDir::Reversed); + for (QFileInfo fileInfo : fileInfoList) { + QString filePath = fileInfo.absoluteFilePath(); + QSize s = createNextLogo(max, filePath); + max.setHeight(max.height() - s.height()); + retval.setWidth(qMax(retval.width(), s.width())); + retval.setHeight(retval.height() + s.height()); + } + return retval; + } + return createNextLogo(max, path); +} + +QSize MainWindow::createNextLogo(const QRect &max, const QString &path) +{ + if (max.height() <= 0) + return QSize(0, 0); QSvgWidget *img = new QSvgWidget(path, this); if (!img->renderer()->isValid()) return QSize(0, 0); @@ -121,7 +141,7 @@ QSize MainWindow::createLogo(const QRect &max) QSize realSize = img->sizeHint().scaled(max.width() - 20, max.height() - 20, Qt::KeepAspectRatio); if (virtualSize.width() == 0 || virtualSize.height() == 0) return QSize(0, 0); - QRect c(10, max.bottom() - realSize.height() - 10, realSize.width(), realSize.height()); + QRect c(max.left() + 10, max.bottom() - realSize.height() - 10, realSize.width(), realSize.height()); img->setGeometry(c); return virtualSize; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 8a5bcf7..dad9089 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -33,7 +33,9 @@ public: void setFocus(Qt::FocusReason reason); - QSize createLogo(const QRect &max); + QSize createLogo(QRect max); + + QSize createNextLogo(const QRect &max, const QString &path); QSize createDistro(const QRect &max); -- cgit v1.2.3-55-g7522