refactor: ui less aboutDialog
This commit is contained in:
parent
f87b4bc0c2
commit
155e4d6b32
9 changed files with 107 additions and 408 deletions
|
|
@ -12,6 +12,7 @@
|
|||
"Compat",
|
||||
"contribs",
|
||||
"Daun",
|
||||
"Devs",
|
||||
"Deskflow",
|
||||
"distro",
|
||||
"distros",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
<file>icons/128x128/tray.png</file>
|
||||
<file>image/welcome.png</file>
|
||||
<file>icons/64x64/folder.png</file>
|
||||
<file>icons/64x64/copy-light.png</file>
|
||||
<file>icons/64x64/copy-dark.png</file>
|
||||
<file>image/placeholder.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
BIN
res/gui/icons/64x64/copy-dark.png
Normal file
BIN
res/gui/icons/64x64/copy-dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
res/gui/icons/64x64/copy-light.png
Normal file
BIN
res/gui/icons/64x64/copy-light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2024 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* Copyright (C) 2012 Symless Ltd.
|
||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||
*
|
||||
|
|
@ -22,123 +23,61 @@
|
|||
#include "common/version.h"
|
||||
#include "gui/style_utils.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDateTime>
|
||||
#include <QGuiApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QStyle>
|
||||
|
||||
using namespace deskflow::gui;
|
||||
|
||||
//
|
||||
// AboutDialog::Deps
|
||||
//
|
||||
|
||||
bool AboutDialog::Deps::isDarkMode() const
|
||||
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
return ::isDarkMode();
|
||||
}
|
||||
|
||||
//
|
||||
// AboutDialog
|
||||
//
|
||||
|
||||
AboutDialog::AboutDialog(QMainWindow *parent, std::shared_ptr<Deps> deps)
|
||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::AboutDialogBase(),
|
||||
m_pDeps(deps)
|
||||
{
|
||||
|
||||
setupUi(this);
|
||||
|
||||
this->setFixedSize(this->size());
|
||||
setWindowTitle(tr("About Deskflow"));
|
||||
|
||||
QString version = QString::fromStdString(deskflow::version());
|
||||
m_pLabelDeskflowVersion->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
m_pLabelDeskflowVersion->setText(version);
|
||||
|
||||
QString buildDateString = QString::fromLocal8Bit(BUILD_DATE).simplified();
|
||||
QDate buildDate = QLocale("en_US").toDate(buildDateString, "yyyy-MM-dd");
|
||||
m_pLabelBuildDate->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
m_pLabelBuildDate->setText(buildDate.toString(QLocale::system().dateFormat(QLocale::LongFormat)));
|
||||
auto copyIcon = QIcon::fromTheme(
|
||||
QIcon::ThemeIcon::EditCopy, deskflow::gui::isDarkMode() ? QIcon(s_darkCopy) : QIcon(s_lightCopy)
|
||||
);
|
||||
|
||||
this->setWindowTitle(QString("About %1").arg(DESKFLOW_APP_NAME));
|
||||
}
|
||||
|
||||
int AboutDialog::exec()
|
||||
{
|
||||
m_pDevelopersLabel->setText(importantDevelopers());
|
||||
m_pCopyrightLabel->setText(QString::fromStdString(deskflow::copyright()));
|
||||
updateLogo();
|
||||
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
void AboutDialog::setLogo(const char *const &filename) const
|
||||
{
|
||||
QPixmap logo(filename);
|
||||
if (!logo.isNull()) {
|
||||
m_pLabel_Logo->setPixmap(logo);
|
||||
} else {
|
||||
qCritical("logo file not found: %s", qPrintable(filename));
|
||||
}
|
||||
}
|
||||
|
||||
void AboutDialog::updateLogo() const
|
||||
{
|
||||
if (m_pDeps->isDarkMode()) {
|
||||
qDebug("showing dark logo");
|
||||
setLogo(":/image/logo-dark.png");
|
||||
} else {
|
||||
qDebug("showing light logo");
|
||||
setLogo(":/image/logo-light.png");
|
||||
}
|
||||
}
|
||||
|
||||
QString AboutDialog::importantDevelopers() const
|
||||
{
|
||||
QStringList awesomePeople;
|
||||
awesomePeople
|
||||
|
||||
// Chris is the ultimate creator, and the one who started it all in 2001.
|
||||
<< "Chris Schoeneman"
|
||||
|
||||
// Richard and Adam developed CosmoDeskflow, the 90's predecessor project.
|
||||
<< "Richard Lee"
|
||||
<< "Adam Feder"
|
||||
|
||||
// Nick continued the legacy in 2009 started by Chris.
|
||||
<< "Nick Bolton"
|
||||
|
||||
// Volker wrote the first version of the GUI (QSynergy) in 2008.
|
||||
<< "Volker Lanz"
|
||||
|
||||
// Re-ignited the project in 2008 and rebuilt the community.
|
||||
<< "Sorin Sbârnea"
|
||||
|
||||
// Contributors of bug fixes in the early days.
|
||||
<< "Ryan Breen"
|
||||
<< "Guido Poschta"
|
||||
<< "Bertrand Landry Hetu"
|
||||
<< "Tom Chadwick"
|
||||
<< "Brent Priddy"
|
||||
<< "Jason Axelson"
|
||||
<< "Jake Petroules"
|
||||
|
||||
// Implemented Wayland support (libei and libportal).
|
||||
<< "Peter Hutterer"
|
||||
<< "Olivier Fourdan"
|
||||
|
||||
// Symless employees (in order of joining).
|
||||
<< "Kyle Bloom"
|
||||
<< "Daun Chung"
|
||||
<< "Serhii Hadzhylov"
|
||||
<< "Oleksandr Lysytsia"
|
||||
<< "Olena Kutytska"
|
||||
<< "Owen Phillips"
|
||||
<< "Daniel Evenson";
|
||||
|
||||
for (auto &person : awesomePeople) {
|
||||
// prevent names from breaking on the space when wrapped
|
||||
person = person.replace(" ", QString::fromUtf8(" "));
|
||||
}
|
||||
|
||||
return awesomePeople.join(", ") + ".";
|
||||
auto btnCopyVersion = new QPushButton(copyIcon, QString(), this);
|
||||
btnCopyVersion->setFlat(true);
|
||||
connect(btnCopyVersion, &QPushButton::clicked, this, [version] { qApp->clipboard()->setText(version); });
|
||||
|
||||
auto versionLayout = new QHBoxLayout();
|
||||
versionLayout->addWidget(new QLabel(tr("Version:")));
|
||||
versionLayout->addWidget(new QLabel(version));
|
||||
versionLayout->addWidget(btnCopyVersion);
|
||||
versionLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
|
||||
auto lblLogo = new QLabel(this);
|
||||
lblLogo->setPixmap(deskflow::gui::isDarkMode() ? s_darkLogo : s_lightLogo);
|
||||
|
||||
auto lblCopyright = new QLabel(QString::fromStdString(deskflow::kCopyright));
|
||||
|
||||
auto boldFont = font();
|
||||
boldFont.setBold(true);
|
||||
|
||||
auto lblDevsTitle = new QLabel(tr("Important developers"));
|
||||
lblDevsTitle->setFont(boldFont);
|
||||
|
||||
auto lblDevsBody = new QLabel(QStringLiteral("%1\n").arg(s_awesomeDevs.join(", ")));
|
||||
lblDevsBody->setWordWrap(true);
|
||||
|
||||
auto btnOk = new QPushButton(tr("Ok"), this);
|
||||
btnOk->setDefault(true);
|
||||
connect(btnOk, &QPushButton::clicked, this, [this] { close(); });
|
||||
|
||||
auto mainLayout = new QVBoxLayout();
|
||||
mainLayout->addWidget(lblLogo);
|
||||
mainLayout->addLayout(versionLayout);
|
||||
mainLayout->addWidget(new QLabel(tr("Keyboard and mouse sharing application"), this));
|
||||
mainLayout->addWidget(lblCopyright);
|
||||
mainLayout->addWidget(lblDevsTitle);
|
||||
mainLayout->addWidget(lblDevsBody);
|
||||
mainLayout->addWidget(btnOk);
|
||||
|
||||
setLayout(mainLayout);
|
||||
adjustSize();
|
||||
setFixedSize(size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2024 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* Copyright (C) 2012 Symless Ltd.
|
||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||
*
|
||||
|
|
@ -18,32 +19,60 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "ui_AboutDialogBase.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMainWindow>
|
||||
|
||||
class QWidget;
|
||||
class QString;
|
||||
|
||||
class AboutDialog : public QDialog, public Ui::AboutDialogBase
|
||||
class AboutDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct Deps
|
||||
{
|
||||
virtual ~Deps() = default;
|
||||
virtual bool isDarkMode() const;
|
||||
};
|
||||
|
||||
explicit AboutDialog(QMainWindow *parent, std::shared_ptr<Deps> deps = std::make_shared<Deps>());
|
||||
int exec() override;
|
||||
explicit AboutDialog(QWidget *parent = nullptr);
|
||||
~AboutDialog() = default;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Deps> m_pDeps;
|
||||
inline static const auto s_lightCopy = QStringLiteral(":/icons/64x64/copy-light.png");
|
||||
inline static const auto s_darkCopy = QStringLiteral(":/icons/64x64/copy-dark.png");
|
||||
inline static const auto s_lightLogo = QStringLiteral(":/image/logo-light.png");
|
||||
inline static const auto s_darkLogo = QStringLiteral(":/image/logo-dark.png");
|
||||
inline static const auto s_awesomeDevs = QStringList{
|
||||
// Chris is the ultimate creator, and the one who started it all in 2001.
|
||||
QStringLiteral("Chris Schoeneman"),
|
||||
|
||||
void updateLogo() const;
|
||||
void setLogo(const char *const &filename) const;
|
||||
QString importantDevelopers() const;
|
||||
// Richard and Adam developed CosmoSynergy, the 90's predecessor project.
|
||||
QStringLiteral("Richard Lee"),
|
||||
QStringLiteral("Adam Feder"),
|
||||
|
||||
// Nick continued the legacy in 2009 started by Chris.
|
||||
QStringLiteral("Nick Bolton"),
|
||||
|
||||
// Volker wrote the first version of the GUI (QSynergy) in 2008.
|
||||
QStringLiteral("Volker Lanz"),
|
||||
|
||||
// Re-ignited the project in 2008 and rebuilt the community.
|
||||
QStringLiteral("Sorin Sbârnea"),
|
||||
|
||||
// Contributors of bug fixes in the early days.
|
||||
QStringLiteral("Ryan Breen"),
|
||||
QStringLiteral("Guido Poschta"),
|
||||
QStringLiteral("Bertrand Landry Hetu"),
|
||||
QStringLiteral("Tom Chadwick"),
|
||||
QStringLiteral("Brent Priddy"),
|
||||
QStringLiteral("Jason Axelson"),
|
||||
QStringLiteral("Jake Petroules"),
|
||||
|
||||
// Implemented Wayland support (libei and libportal).
|
||||
QStringLiteral("Peter Hutterer"),
|
||||
QStringLiteral("Olivier Fourdan"),
|
||||
|
||||
// Symless employees (in order of joining).
|
||||
QStringLiteral("Kyle Bloom"),
|
||||
QStringLiteral("Daun Chung"),
|
||||
QStringLiteral("Serhii Hadzhylov"),
|
||||
QStringLiteral("Oleksandr Lysytsia"),
|
||||
QStringLiteral("Olena Kutytska"),
|
||||
QStringLiteral("Owen Phillips"),
|
||||
QStringLiteral("Daniel Evenson"),
|
||||
|
||||
// Prominent Deskflow development community members
|
||||
QStringLiteral("Chris Rizzitello"),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,255 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AboutDialogBase</class>
|
||||
<widget class="QDialog" name="AboutDialogBase">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>About Deskflow</string>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="m_pCopyrightLabel">
|
||||
<property name="text">
|
||||
<string>Copyright</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Build Date: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_pLabelBuildDate">
|
||||
<property name="text">
|
||||
<string>Unknown</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonOk">
|
||||
<property name="text">
|
||||
<string>&Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="m_pTitleLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Important developers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="m_pDescriptionLabel">
|
||||
<property name="text">
|
||||
<string>Keyboard and mouse sharing application.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<spacer name="verticalSpacer_1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="m_pLabel_Logo">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/image/placeholder.png</pixmap>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="2">
|
||||
<widget class="QLabel" name="m_pDevelopersLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Developers</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<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 row="14" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Version:</string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_pLabelDeskflowVersion">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unknown</string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonOk</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>AboutDialogBase</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>315</x>
|
||||
<y>374</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>301</x>
|
||||
<y>3</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
@ -17,27 +17,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace deskflow {
|
||||
|
||||
const auto kCopyrightFormat = //
|
||||
"Copyright (C) 2012-%s Symless Ltd.\n"
|
||||
const auto kCopyright = //
|
||||
"Copyright (C) 2024 Deskflow Developers\n"
|
||||
"Copyright (C) 2012-2024 Symless Ltd.\n"
|
||||
"Copyright (C) 2009-2012 Nick Bolton\n"
|
||||
"Copyright (C) 2002-2009 Chris Schoeneman";
|
||||
|
||||
inline std::string copyright()
|
||||
{
|
||||
const std::string date = BUILD_DATE;
|
||||
const auto year = date.substr(0, 4);
|
||||
const auto kBufferLength = 256;
|
||||
std::vector<char> buffer(kBufferLength);
|
||||
std::snprintf( // NOSONAR
|
||||
buffer.data(), kBufferLength, kCopyrightFormat, year.c_str()
|
||||
);
|
||||
return std::string(buffer.data());
|
||||
}
|
||||
|
||||
} // namespace deskflow
|
||||
|
|
|
|||
|
|
@ -94,13 +94,12 @@ App::~App()
|
|||
void App::version()
|
||||
{
|
||||
const auto version = deskflow::version();
|
||||
const auto copyright = deskflow::copyright();
|
||||
|
||||
const auto kBufferLength = 1024;
|
||||
std::vector<char> buffer(kBufferLength);
|
||||
std::snprintf( // NOSONAR
|
||||
buffer.data(), kBufferLength, "%s v%s, protocol v%d.%d\n%s", //
|
||||
argsBase().m_pname, version.c_str(), kProtocolMajorVersion, kProtocolMinorVersion, copyright.c_str()
|
||||
argsBase().m_pname, version.c_str(), kProtocolMajorVersion, kProtocolMinorVersion, deskflow::kCopyright
|
||||
);
|
||||
|
||||
std::cout << std::string(buffer.data()) << std::endl;
|
||||
|
|
|
|||
Loading…
Reference in a new issue