reworked info window (#2333)

* reworked info window

* clang format
This commit is contained in:
borgmanJeremy
2022-01-28 13:07:26 -06:00
committed by GitHub
parent 5ab76e233b
commit 3553deab9c
5 changed files with 181 additions and 83 deletions

View File

@@ -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(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/widgets/panel>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/widgets/capture>
$<INSTALL_INTERFACE:include/mylib>)
target_include_directories(
flameshot
PUBLIC
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/>
)
if (USE_EXTERNAL_SINGLEAPPLICATION)
add_compile_definitions(USE_EXTERNAL_SINGLEAPPLICATION=1)

View File

@@ -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

View File

@@ -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 <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
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("<u><b>License</b></u>"), 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("<u><b>Version</b></u>"), 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());
}

View File

@@ -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 <QWidget>
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();

138
src/widgets/infowindow.ui Normal file
View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InfoWindow</class>
<widget class="QWidget" name="InfoWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>182</width>
<height>262</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<property name="windowIcon">
<iconset resource="../../data/graphics.qrc">
<normaloff>:/img/app/flameshot.svg</normaloff>:/img/app/flameshot.svg</iconset>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="IconSVG">
<property name="text">
<string>Icon</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="License">
<property name="font">
<font>
<bold>true</bold>
<underline>true</underline>
</font>
</property>
<property name="text">
<string>License</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="LicenseDetails">
<property name="text">
<string>GPLv3+</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="Version">
<property name="font">
<font>
<bold>true</bold>
<underline>true</underline>
</font>
</property>
<property name="text">
<string>Version</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="VersionDetails">
<property name="text">
<string>Flameshot v</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="OperatingSystemDetails">
<property name="text">
<string>OS Info</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="CopyInfoButton">
<property name="text">
<string>Copy Info</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../data/graphics.qrc"/>
</resources>
<connections/>
</ui>