mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 01:41:19 +00:00
Added button to config menu to allow users to copy system version info. (#1756)
This commit is contained in:
@@ -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: '*'
|
WarningsAsErrors: '*'
|
||||||
HeaderFilterRegex: ''
|
HeaderFilterRegex: ''
|
||||||
FormatStyle: none
|
FormatStyle: none
|
||||||
@@ -3,15 +3,21 @@
|
|||||||
|
|
||||||
#include "infowindow.h"
|
#include "infowindow.h"
|
||||||
#include "src/core/qguiappcurrentscreen.h"
|
#include "src/core/qguiappcurrentscreen.h"
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QSysInfo>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
|
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// InfoWindow show basic information about the usage of Flameshot
|
// InfoWindow show basic information about the usage of Flameshot
|
||||||
@@ -38,35 +44,72 @@ InfoWindow::InfoWindow(QWidget* parent)
|
|||||||
|
|
||||||
void InfoWindow::initLabels()
|
void InfoWindow::initLabels()
|
||||||
{
|
{
|
||||||
QLabel* icon = new QLabel();
|
auto* icon = new QLabel();
|
||||||
icon->setPixmap(QPixmap(":img/app/flameshot.svg"));
|
icon->setPixmap(QPixmap(":img/app/flameshot.svg"));
|
||||||
icon->setAlignment(Qt::AlignHCenter);
|
icon->setAlignment(Qt::AlignHCenter);
|
||||||
m_layout->addWidget(icon);
|
m_layout->addWidget(icon);
|
||||||
|
|
||||||
QLabel* licenseTitleLabel = new QLabel(tr("<u><b>License</b></u>"), this);
|
auto* licenseTitleLabel = new QLabel(tr("<u><b>License</b></u>"), this);
|
||||||
licenseTitleLabel->setAlignment(Qt::AlignHCenter);
|
licenseTitleLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
licenseTitleLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
m_layout->addWidget(licenseTitleLabel);
|
m_layout->addWidget(licenseTitleLabel);
|
||||||
|
|
||||||
QLabel* licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this);
|
auto* licenseLabel = new QLabel(QStringLiteral("GPLv3+"), this);
|
||||||
licenseLabel->setAlignment(Qt::AlignHCenter);
|
licenseLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
licenseLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
m_layout->addWidget(licenseLabel);
|
m_layout->addWidget(licenseLabel);
|
||||||
m_layout->addStretch();
|
m_layout->addStretch();
|
||||||
|
|
||||||
QLabel* versionTitleLabel = new QLabel(tr("<u><b>Version</b></u>"), this);
|
auto* versionTitleLabel = new QLabel(tr("<u><b>Version</b></u>"), this);
|
||||||
versionTitleLabel->setAlignment(Qt::AlignHCenter);
|
versionTitleLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
versionTitleLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
m_layout->addWidget(versionTitleLabel);
|
m_layout->addWidget(versionTitleLabel);
|
||||||
QString versionMsg = "Flameshot " + QStringLiteral(APP_VERSION) + " (" +
|
|
||||||
QStringLiteral(FLAMESHOT_GIT_HASH) +
|
QString versionMsg = generateVersionString();
|
||||||
")\nCompiled with Qt " + QT_VERSION_STR;
|
|
||||||
QLabel* versionLabel = new QLabel(versionMsg, this);
|
auto* versionLabel = new QLabel(versionMsg, this);
|
||||||
versionLabel->setAlignment(Qt::AlignHCenter);
|
versionLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
m_layout->addWidget(versionLabel);
|
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);
|
m_layout->addSpacing(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InfoWindow::copyInfo()
|
||||||
|
{
|
||||||
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
clipboard->setText(generateVersionString() + "\n" + generateKernelString());
|
||||||
|
}
|
||||||
|
|
||||||
void InfoWindow::keyPressEvent(QKeyEvent* e)
|
void InfoWindow::keyPressEvent(QKeyEvent* e)
|
||||||
{
|
{
|
||||||
if (e->key() == Qt::Key_Escape) {
|
if (e->key() == Qt::Key_Escape) {
|
||||||
close();
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,7 +16,13 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent*);
|
void keyPressEvent(QKeyEvent*);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void copyInfo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initLabels();
|
void initLabels();
|
||||||
QVBoxLayout* m_layout;
|
QVBoxLayout* m_layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString generateVersionString();
|
||||||
|
QString generateKernelString();
|
||||||
|
|||||||
Reference in New Issue
Block a user