diff --git a/.clang-tidy b/.clang-tidy index 84c717cd..180f676a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,6 @@ --- -Checks: '*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm-*,-llvmlibc-*' +Checks: '*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm-*,-llvmlibc-*,-performance-no-automatic-move,-cppcoreguidelines-owning-memory' WarningsAsErrors: '*' HeaderFilterRegex: '' -FormatStyle: none \ No newline at end of file +FormatStyle: none diff --git a/src/widgets/infowindow.cpp b/src/widgets/infowindow.cpp index 43eae3f2..3f367557 100644 --- a/src/widgets/infowindow.cpp +++ b/src/widgets/infowindow.cpp @@ -3,15 +3,21 @@ #include "infowindow.h" #include "src/core/qguiappcurrentscreen.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 @@ -38,35 +44,72 @@ InfoWindow::InfoWindow(QWidget* parent) void InfoWindow::initLabels() { - QLabel* icon = new QLabel(); + auto* icon = new QLabel(); icon->setPixmap(QPixmap(":img/app/flameshot.svg")); icon->setAlignment(Qt::AlignHCenter); m_layout->addWidget(icon); - QLabel* licenseTitleLabel = new QLabel(tr("License"), this); + auto* licenseTitleLabel = new QLabel(tr("License"), this); licenseTitleLabel->setAlignment(Qt::AlignHCenter); + licenseTitleLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); m_layout->addWidget(licenseTitleLabel); - QLabel* licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this); + auto* licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this); licenseLabel->setAlignment(Qt::AlignHCenter); + licenseLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); m_layout->addWidget(licenseLabel); m_layout->addStretch(); - QLabel* versionTitleLabel = new QLabel(tr("Version"), this); + auto* versionTitleLabel = new QLabel(tr("Version"), this); versionTitleLabel->setAlignment(Qt::AlignHCenter); + versionTitleLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); m_layout->addWidget(versionTitleLabel); - QString versionMsg = "Flameshot " + QStringLiteral(APP_VERSION) + " (" + - QStringLiteral(FLAMESHOT_GIT_HASH) + - ")\nCompiled with Qt " + QT_VERSION_STR; - QLabel* versionLabel = new QLabel(versionMsg, this); + + QString versionMsg = generateVersionString(); + + auto* versionLabel = new QLabel(versionMsg, this); versionLabel->setAlignment(Qt::AlignHCenter); + versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); m_layout->addWidget(versionLabel); + + QString kernelInfo = generateKernelString(); + auto* kernelLabel = new QLabel(kernelInfo, this); + kernelLabel->setAlignment(Qt::AlignHCenter); + kernelLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); + 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); } +void InfoWindow::copyInfo() +{ + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setText(generateVersionString() + "\n" + generateKernelString()); +} + void InfoWindow::keyPressEvent(QKeyEvent* e) { if (e->key() == Qt::Key_Escape) { close(); } } + +QString generateVersionString() +{ + QString version = "Flameshot " + QStringLiteral(APP_VERSION) + " (" + + QStringLiteral(FLAMESHOT_GIT_HASH) + + ")\nCompiled with Qt " + QT_VERSION_STR; + return version; +} + +QString generateKernelString() +{ + QString kernelVersion = + QSysInfo::kernelType() + ": " + QSysInfo::kernelVersion() + "\n" + + QSysInfo::productType() + ": " + QSysInfo::productVersion(); + return kernelVersion; +} diff --git a/src/widgets/infowindow.h b/src/widgets/infowindow.h index 1cd4e08a..1f7efe3a 100644 --- a/src/widgets/infowindow.h +++ b/src/widgets/infowindow.h @@ -16,7 +16,13 @@ public: protected: void keyPressEvent(QKeyEvent*); +private slots: + void copyInfo(); + private: void initLabels(); QVBoxLayout* m_layout; }; + +QString generateVersionString(); +QString generateKernelString();