forked from flameshot-org/flameshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfowindow.cpp
More file actions
57 lines (48 loc) · 1.48 KB
/
infowindow.cpp
File metadata and controls
57 lines (48 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: GPL-3.0-or-later
// 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 <QKeyEvent>
#include <QScreen>
InfoWindow::InfoWindow(QWidget* parent)
: QWidget(parent)
, ui(new Ui::InfoWindow)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
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();
QScreen* screen = QGuiAppCurrentScreen().currentScreen();
position.moveCenter(screen->availableGeometry().center());
move(position.topLeft());
#endif
show();
}
InfoWindow::~InfoWindow()
{
delete ui;
}
void InfoWindow::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Escape) {
close();
}
}
QString generateKernelString()
{
QString kernelVersion =
QSysInfo::kernelType() + ": " + QSysInfo::kernelVersion() + "\n" +
QSysInfo::productType() + ": " + QSysInfo::productVersion();
return kernelVersion;
}
void InfoWindow::on_CopyInfoButton_clicked()
{
FlameshotDaemon::copyToClipboard(GlobalValues::versionInfo() + "\n" +
generateKernelString());
}