mirror of
https://github.com/flameshot-org/flameshot
synced 2024-10-18 05:42:43 +00:00
Added button to config menu to allow users to copy system version info. (#1756)
This commit is contained in:
parent
8ba06b7292
commit
58248c9776
|
@ -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
|
||||
FormatStyle: none
|
||||
|
|
|
@ -3,15 +3,21 @@
|
|||
|
||||
#include "infowindow.h"
|
||||
#include "src/core/qguiappcurrentscreen.h"
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QHeaderView>
|
||||
#include <QIcon>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QSysInfo>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
|
||||
#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("<u><b>License</b></u>"), this);
|
||||
auto* licenseTitleLabel = new QLabel(tr("<u><b>License</b></u>"), 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("<u><b>Version</b></u>"), this);
|
||||
auto* versionTitleLabel = new QLabel(tr("<u><b>Version</b></u>"), 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;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,13 @@ public:
|
|||
protected:
|
||||
void keyPressEvent(QKeyEvent*);
|
||||
|
||||
private slots:
|
||||
void copyInfo();
|
||||
|
||||
private:
|
||||
void initLabels();
|
||||
QVBoxLayout* m_layout;
|
||||
};
|
||||
|
||||
QString generateVersionString();
|
||||
QString generateKernelString();
|
||||
|
|
Loading…
Reference in a new issue