From 82ce8faec3c26d20a158a4e24df2edd917b7248b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sun, 17 Mar 2019 21:22:26 +0100 Subject: Add second logo key for better migration from old slx-admin We don't want to invalidate all the old branding config modules which are still only made for single file support. --- src/mainwindow.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 554d972..15736f0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -72,9 +72,9 @@ MainWindow::MainWindow(bool primary, int screen, const QRect &screenRect, QWidge } // Banner - if (!Settings::bannerImagePath().isEmpty()) { - qWarning() << "Have banner " << Settings::bannerImagePath(); - QSvgWidget *banner = new QSvgWidget(Settings::bannerImagePath(), this); + if (!Settings::bannerImageFile().isEmpty()) { + qWarning() << "Have banner " << Settings::bannerImageFile(); + QSvgWidget *banner = new QSvgWidget(Settings::bannerImageFile(), this); qWarning() << banner->sizeHint(); if (banner->renderer()->isValid()) { QSize sh; @@ -111,39 +111,41 @@ MainWindow::~MainWindow() QSize MainWindow::createLogo(QRect max) { - QString path = Settings::bottomLeftLogoPath(); - if (path.isEmpty()) - return QSize(0, 0); + QSize retval(0, 0); + QString path = Settings::bottomLeftLogoFile(); + if (!path.isEmpty()) { // Single explicit file first + createNextLogo(max, retval, path); + } + path = Settings::bottomLeftLogoDir(); // Check whether it's a file or directory - if (QFileInfo(path).isDir()) { - QSize retval(0, 0); + if (!path.isEmpty() && QFileInfo(path).isDir()) { 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()); + createNextLogo(max, retval, filePath); } return retval; } - return createNextLogo(max, path); + createNextLogo(max, retval, path); + return retval; } -QSize MainWindow::createNextLogo(const QRect &max, const QString &path) +void MainWindow::createNextLogo(QRect &max, QSize &retval, const QString &path) { if (max.height() <= 0) - return QSize(0, 0); + return; QSvgWidget *img = new QSvgWidget(path, this); if (!img->renderer()->isValid()) - return QSize(0, 0); + return; QSize virtualSize = img->sizeHint().scaled(max.width(), max.height(), Qt::KeepAspectRatio); QSize realSize = img->sizeHint().scaled(max.width() - 20, max.height() - 20, Qt::KeepAspectRatio); if (virtualSize.width() == 0 || virtualSize.height() == 0) - return QSize(0, 0); + return; QRect c(max.left() + 10, max.bottom() - realSize.height() - 10, realSize.width(), realSize.height()); img->setGeometry(c); - return virtualSize; + max.setHeight(max.height() - virtualSize.height()); + retval.setWidth(qMax(retval.width(), virtualSize.width())); + retval.setHeight(retval.height() + virtualSize.height()); } QSize MainWindow::createDistro(const QRect &max) @@ -290,7 +292,7 @@ int MainWindow::getOffset(QString settingsOffset, int maxVal, int defaultVal) void MainWindow::setBackground() { Qt::AspectRatioMode arMode = Qt::KeepAspectRatioByExpanding; - QString bgPath = Settings::backgrundImagePath(); + QString bgPath = Settings::backgrundImageFile(); if (bgPath.length() != 0) { m_background = QImage(bgPath); if (m_background.isNull()) { -- cgit v1.2.3-55-g7522