Special contributor mentions on the about screen (#7197)
* Remove obsolete data * Add section "Key contributors" * Add "Elite Backers" label * Add Elite Backers * Remove borders for Elite backers section * Add link "Become an Elite Backer" * Become an Elite Backer as a separate label * Add link to the credits page * Fix for macOS * Fix fonts and spaces for Windows * Fix window size for Linux * Loading credits using API * Update ChangeLog * Fix code smells * Requested changes * Change URL * Update AboutDialogBase.ui Co-authored-by: Serhii Hadzhilov <serhii@symless.com>
This commit is contained in:
parent
bcfeb251a9
commit
268b0f660f
6 changed files with 435 additions and 129 deletions
|
|
@ -9,6 +9,7 @@ Enhancements:
|
||||||
- #7183 Refactoring for Synergy 3 licenses
|
- #7183 Refactoring for Synergy 3 licenses
|
||||||
- #7190 Maintenance license serial key support
|
- #7190 Maintenance license serial key support
|
||||||
- #7193 Support for maintenance licenses in China
|
- #7193 Support for maintenance licenses in China
|
||||||
|
- #7197 Special contributor mentions on the about screen
|
||||||
|
|
||||||
1.14.4
|
1.14.4
|
||||||
======
|
======
|
||||||
|
|
|
||||||
|
|
@ -17,26 +17,29 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AboutDialog.h"
|
#include "AboutDialog.h"
|
||||||
|
#include "CreditsLoader.h"
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
#include "OSXHelpers.h"
|
#include "OSXHelpers.h"
|
||||||
|
|
||||||
AboutDialog::AboutDialog(QWidget* parent, const QString& synergyApp) :
|
AboutDialog::AboutDialog(MainWindow* parent, const QString& synergyApp) :
|
||||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
Ui::AboutDialogBase()
|
Ui::AboutDialogBase(),
|
||||||
|
credits(*parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
setupCreditsLoader();
|
||||||
|
|
||||||
QString aboutText(R"(<p>
|
QString aboutText(R"(<p>
|
||||||
Keyboard and mouse sharing application. Cross platform and open source.<br /><br />
|
Keyboard and mouse sharing application. Cross platform and open source.<br /><br />
|
||||||
Copyright © 2012-%%YEAR%% Symless Ltd.<br />
|
Copyright © %%YEAR%% Symless Ltd.<br /><br />
|
||||||
Copyright © 2002-2012 Chris Schoeneman, Nick Bolton, Volker Lanz.<br /><br />
|
Synergy is released under the GNU General Public License (GPLv2).</p>
|
||||||
Synergy is released under the GNU General Public License (GPLv2).<br /><br />
|
<p style="font-size: 14px">Key contributors<br>
|
||||||
Synergy is based on CosmoSynergy by Richard Lee and Adam Feder.<br />
|
<span style="font-size: 11px">Chris Schoeneman, Nick Bolton, Richard Lee, Adam Feder, Volker Lanz,
|
||||||
The Synergy GUI is based on QSynergy by Volker Lanz.<br /><br />
|
Ryan Breen, Guido Poschta, Bertrand Landry Hetu, Tom Chadwick, Brent Priddy, Kyle Bloom,
|
||||||
Visit our website for help and info (symless.com).
|
Daun Chung, Serhii Hadzhylov, Oleksandr Lysytsia, Olena Kutytska, Francisco Magalhães.</span>
|
||||||
</p>)");
|
</p>)");
|
||||||
|
|
||||||
m_versionChecker.setApp(synergyApp);
|
m_versionChecker.setApp(synergyApp);
|
||||||
|
|
@ -56,7 +59,7 @@ Visit our website for help and info (symless.com).
|
||||||
|
|
||||||
// change default size based on os
|
// change default size based on os
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
QSize size(600, 380);
|
QSize size(600, 490);
|
||||||
setMaximumSize(size);
|
setMaximumSize(size);
|
||||||
setMinimumSize(size);
|
setMinimumSize(size);
|
||||||
resize(size);
|
resize(size);
|
||||||
|
|
@ -69,9 +72,20 @@ Visit our website for help and info (symless.com).
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
QSize size(600, 330);
|
QSize size(600, 420);
|
||||||
setMaximumSize(size);
|
setMaximumSize(size);
|
||||||
setMinimumSize(size);
|
setMinimumSize(size);
|
||||||
resize(size);
|
resize(size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AboutDialog::setupCreditsLoader()
|
||||||
|
{
|
||||||
|
connect(&credits, SIGNAL(loaded(const QString&)), this, SLOT(updateEliteBackers(const QString&)));
|
||||||
|
credits.loadEliteBackers();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AboutDialog::updateEliteBackers(const QString& eliteBackers) const
|
||||||
|
{
|
||||||
|
this->labelEliteBackersData->setText(eliteBackers);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "VersionChecker.h"
|
#include "VersionChecker.h"
|
||||||
|
#include "CreditsLoader.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include "ui_AboutDialogBase.h"
|
#include "ui_AboutDialogBase.h"
|
||||||
|
|
||||||
|
|
@ -33,10 +35,15 @@ class AboutDialog : public QDialog, public Ui::AboutDialogBase
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AboutDialog(QWidget* parent, const QString& synergyApp = QString());
|
AboutDialog(MainWindow* parent, const QString& synergyApp = QString());
|
||||||
|
public slots:
|
||||||
|
void updateEliteBackers(const QString& eliteBackers) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CreditsLoader credits;
|
||||||
VersionChecker m_versionChecker;
|
VersionChecker m_versionChecker;
|
||||||
|
|
||||||
|
void setupCreditsLoader();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>450</width>
|
<width>450</width>
|
||||||
<height>300</height>
|
<height>495</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|
@ -25,13 +25,13 @@
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>450</width>
|
<width>450</width>
|
||||||
<height>300</height>
|
<height>495</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>450</width>
|
<width>450</width>
|
||||||
<height>300</height>
|
<height>495</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
@ -41,7 +41,256 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<item row="5" column="1" colspan="2">
|
<item row="10" column="1">
|
||||||
|
<widget class="QLabel" name="labelCreditsLink">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"><a href="https://symless.com/synergy/credits?source=gui" style="color: #4285F4;">View the complete credits</a></string>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<widget class="QLabel" name="labelEliteBackerLink">
|
||||||
|
<property name="text">
|
||||||
|
<string><a href="https://symless.com/synergy/account-status?source=gui" style="color: #4285F4;">Become an Elite Backer</a></string>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>9</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="2">
|
||||||
|
<spacer name="spacer">
|
||||||
|
<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="6" column="1">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetNoConstraint</enum>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelEliteBackers">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>-1</pointsize>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">font-size: 14px</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Elite Backers</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollArea" name="scrollAreaEliteBackers">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>419</width>
|
||||||
|
<height>83</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelEliteBackersData">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>10</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>-1</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">font-size: 11px;s</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Loading...</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label_Logo">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="../res/Synergy.qrc">:/res/image/about.png</pixmap>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="14" 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="11" column="1" colspan="2">
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="13" column="1" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
|
@ -90,120 +339,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" 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="2" column="1" colspan="2">
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1" colspan="2">
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Preferred</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1" colspan="2">
|
|
||||||
<spacer name="spacer">
|
|
||||||
<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="label_Logo">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="pixmap">
|
|
||||||
<pixmap resource="../res/Synergy.qrc">:/res/image/about.png</pixmap>
|
|
||||||
</property>
|
|
||||||
<property name="scaledContents">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
|
||||||
106
src/gui/src/CreditsLoader.cpp
Normal file
106
src/gui/src/CreditsLoader.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2015-2022 Symless Ltd.
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CreditsLoader.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class CreditsResponse {
|
||||||
|
public:
|
||||||
|
explicit CreditsResponse(const QByteArray& response) {
|
||||||
|
auto data = parseJson(response);
|
||||||
|
m_status = data["status"].toString();
|
||||||
|
|
||||||
|
if (isSuccess()) {
|
||||||
|
m_data = data["data"].toString();
|
||||||
|
}
|
||||||
|
else if (isFailed()) {
|
||||||
|
m_data = data["message"].toString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_data = "Unknown response from the server";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSuccess() const {
|
||||||
|
return (m_status == "success");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isFailed() const {
|
||||||
|
return (m_status == "failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& getData() const {
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap<QString, QVariant> parseJson(const QByteArray& json) const {
|
||||||
|
QJsonParseError jsonError;
|
||||||
|
auto data = QJsonDocument::fromJson(json, &jsonError);
|
||||||
|
if (jsonError.error == QJsonParseError::NoError) {
|
||||||
|
return data.toVariant().toMap();
|
||||||
|
}
|
||||||
|
return QMap<QString, QVariant>();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString m_data;
|
||||||
|
QString m_status;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CreditsLoader::CreditsLoader(MainWindow& mainWindow) :
|
||||||
|
m_mainWindow(mainWindow)
|
||||||
|
{
|
||||||
|
connect(&m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreditsLoader::loadEliteBackers()
|
||||||
|
{
|
||||||
|
const auto ELITE_BACKERS_URL = "https://api2.prod.symless.com/credits/elite-backers";
|
||||||
|
m_mainWindow.appendLogDebug(QString("Send request: %1").arg(ELITE_BACKERS_URL));
|
||||||
|
const auto url = QUrl(ELITE_BACKERS_URL);
|
||||||
|
const auto request = QNetworkRequest(url);
|
||||||
|
m_manager.get(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreditsLoader::replyFinished(QNetworkReply* reply) const
|
||||||
|
{
|
||||||
|
auto response = reply->readAll();
|
||||||
|
m_mainWindow.appendLogDebug(QString("Received response: %1").arg(response.toStdString().c_str()));
|
||||||
|
|
||||||
|
CreditsResponse creditsResponse(response);
|
||||||
|
if (creditsResponse.isSuccess()) {
|
||||||
|
emit loaded(creditsResponse.getData());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error(QString("Server error: %1").arg(creditsResponse.getData()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreditsLoader::error(const QString& error) const
|
||||||
|
{
|
||||||
|
m_mainWindow.appendLogError(error);
|
||||||
|
emit loaded("Something went wrong when retrieving the list of Elite Backers. Check the logs for more info.");
|
||||||
|
}
|
||||||
43
src/gui/src/CreditsLoader.h
Normal file
43
src/gui/src/CreditsLoader.h
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* synergy -- mouse and keyboard sharing utility
|
||||||
|
* Copyright (C) 2015-2022 Symless Ltd.
|
||||||
|
*
|
||||||
|
* This package is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* found in the file LICENSE that should have accompanied this file.
|
||||||
|
*
|
||||||
|
* This package is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
|
||||||
|
class QNetworkReply;
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
class CreditsLoader : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CreditsLoader(MainWindow& mainWindow);
|
||||||
|
void loadEliteBackers();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void loaded(const QString& eliteBakers) const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void replyFinished(QNetworkReply* reply) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
MainWindow& m_mainWindow;
|
||||||
|
QNetworkAccessManager m_manager;
|
||||||
|
|
||||||
|
void error(const QString& error) const;
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue