From 3553deab9c4597c1e968d5fbe8d1b4aa4b7370cb Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Fri, 28 Jan 2022 13:07:26 -0600 Subject: [PATCH] reworked info window (#2333) * reworked info window * clang format --- src/CMakeLists.txt | 8 ++- src/widgets/CMakeLists.txt | 5 +- src/widgets/infowindow.cpp | 88 +++++------------------ src/widgets/infowindow.h | 25 ++++--- src/widgets/infowindow.ui | 138 +++++++++++++++++++++++++++++++++++++ 5 files changed, 181 insertions(+), 83 deletions(-) create mode 100644 src/widgets/infowindow.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4adc66a9..22deecb3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,8 +80,6 @@ add_subdirectory(widgets) add_subdirectory(tools) - - set(FLAMESHOT_TS_FILES ${CMAKE_SOURCE_DIR}/data/translations/Internationalization_bg.ts ${CMAKE_SOURCE_DIR}/data/translations/Internationalization_ca.ts @@ -174,6 +172,12 @@ target_include_directories( $ $ $) +target_include_directories( + flameshot + PUBLIC + $ + ) + if (USE_EXTERNAL_SINGLEAPPLICATION) add_compile_definitions(USE_EXTERNAL_SINGLEAPPLICATION=1) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index e649d340..65ab8a38 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -4,7 +4,10 @@ add_subdirectory(capture) # Required to generate MOC target_sources( flameshot - PRIVATE capturelauncher.h + PRIVATE + infowindow.ui + + capturelauncher.h draggablewidgetmaker.h imagelabel.h infowindow.h diff --git a/src/widgets/infowindow.cpp b/src/widgets/infowindow.cpp index e1215bb7..83cffcd5 100644 --- a/src/widgets/infowindow.cpp +++ b/src/widgets/infowindow.cpp @@ -1,35 +1,24 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors +// SPDX-FileCopyrightText: 2021-2022 Jeremy Borgman & Contributors #include "infowindow.h" +#include "./ui_infowindow.h" #include "src/core/flameshotdaemon.h" #include "src/core/qguiappcurrentscreen.h" #include "src/utils/globalvalues.h" -#include -#include -#include -#include #include -#include -#include -#include -#include - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - -#include #include -#endif - -// InfoWindow show basic information about the usage of Flameshot - InfoWindow::InfoWindow(QWidget* parent) : QWidget(parent) + , ui(new Ui::InfoWindow) { + ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); - setWindowIcon(QIcon(GlobalValues::iconPath())); - setWindowTitle(tr("About")); + + ui->IconSVG->setPixmap(QPixmap(GlobalValues::iconPath())); + ui->VersionDetails->setText(GlobalValues::versionInfo()); + ui->OperatingSystemDetails->setText(generateKernelString()); #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) QRect position = frameGeometry(); @@ -38,64 +27,17 @@ InfoWindow::InfoWindow(QWidget* parent) move(position.topLeft()); #endif - m_layout = new QVBoxLayout(this); - m_layout->setAlignment(Qt::AlignHCenter); - initLabels(); show(); } -void InfoWindow::initLabels() +InfoWindow::~InfoWindow() { - auto* icon = new QLabel(); - icon->setPixmap(QPixmap(GlobalValues::iconPath())); - icon->setAlignment(Qt::AlignHCenter); - m_layout->addWidget(icon); - - auto* licenseTitleLabel = new QLabel(tr("License"), this); - licenseTitleLabel->setAlignment(Qt::AlignHCenter); - licenseTitleLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - m_layout->addWidget(licenseTitleLabel); - - auto* licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this); - licenseLabel->setAlignment(Qt::AlignHCenter); - licenseLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - m_layout->addWidget(licenseLabel); - m_layout->addStretch(); - - auto* versionTitleLabel = new QLabel(tr("Version"), this); - versionTitleLabel->setAlignment(Qt::AlignHCenter); - versionTitleLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - m_layout->addWidget(versionTitleLabel); - - auto* versionLabel = new QLabel(GlobalValues::versionInfo(), this); - versionLabel->setAlignment(Qt::AlignHCenter); - versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - versionLabel->setCursor(QCursor(Qt::IBeamCursor)); - m_layout->addWidget(versionLabel); - - QString kernelInfo = generateKernelString(); - auto* kernelLabel = new QLabel(kernelInfo, this); - kernelLabel->setAlignment(Qt::AlignHCenter); - kernelLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); - kernelLabel->setCursor(QCursor(Qt::IBeamCursor)); - m_layout->addWidget(kernelLabel); - - auto* copyVersion = new QPushButton("Copy Info", this); - m_layout->addWidget(copyVersion); - connect(copyVersion, &QPushButton::pressed, this, &InfoWindow::copyInfo); - - m_layout->addSpacing(30); + delete ui; } -void InfoWindow::copyInfo() +void InfoWindow::keyPressEvent(QKeyEvent* event) { - FlameshotDaemon::copyToClipboard(GlobalValues::versionInfo() + "\n" + - generateKernelString()); -} - -void InfoWindow::keyPressEvent(QKeyEvent* e) -{ - if (e->key() == Qt::Key_Escape) { + if (event->key() == Qt::Key_Escape) { close(); } } @@ -107,3 +49,9 @@ QString generateKernelString() QSysInfo::productType() + ": " + QSysInfo::productVersion(); return kernelVersion; } + +void InfoWindow::on_CopyInfoButton_clicked() +{ + FlameshotDaemon::copyToClipboard(GlobalValues::versionInfo() + "\n" + + generateKernelString()); +} diff --git a/src/widgets/infowindow.h b/src/widgets/infowindow.h index acf74b8e..f8c1c4ff 100644 --- a/src/widgets/infowindow.h +++ b/src/widgets/infowindow.h @@ -1,27 +1,32 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors +// SPDX-FileCopyrightText: 2021-2022 Jeremy Borgman & Contributors #pragma once #include -class QVBoxLayout; +QT_BEGIN_NAMESPACE +namespace Ui { +class InfoWindow; +} +QT_END_NAMESPACE class InfoWindow : public QWidget { Q_OBJECT + public: explicit InfoWindow(QWidget* parent = nullptr); - -protected: - void keyPressEvent(QKeyEvent*); - -private slots: - void copyInfo(); + ~InfoWindow(); private: - void initLabels(); - QVBoxLayout* m_layout; + Ui::InfoWindow* ui; + +protected: + void keyPressEvent(QKeyEvent* event); + +private slots: + void on_CopyInfoButton_clicked(); }; QString generateKernelString(); diff --git a/src/widgets/infowindow.ui b/src/widgets/infowindow.ui new file mode 100644 index 00000000..651abf09 --- /dev/null +++ b/src/widgets/infowindow.ui @@ -0,0 +1,138 @@ + + + InfoWindow + + + + 0 + 0 + 182 + 262 + + + + About + + + + :/img/app/flameshot.svg:/img/app/flameshot.svg + + + + + + + + Icon + + + Qt::AlignCenter + + + + + + + + true + true + + + + License + + + Qt::AlignCenter + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + GPLv3+ + + + Qt::AlignCenter + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + true + true + + + + Version + + + Qt::AlignCenter + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Flameshot v + + + Qt::AlignCenter + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + OS Info + + + Qt::AlignCenter + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Copy Info + + + + + + + + + + + +