Add version info

This commit is contained in:
Ximi1970
2020-04-04 16:51:13 +02:00
parent 493be1d618
commit d316986858
10 changed files with 286 additions and 4 deletions

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@
/SysTray-X
/app/SysTray-X/.qmake.stash
/app/SysTray-X/SysTray-X.pro.user.*
/bin
/bin-*

View File

@@ -170,7 +170,8 @@ HEADERS += \
FORMS += \
debugwidget.ui \
preferences.ui
preferences.ui \
aboutdialog.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin

View File

@@ -10,5 +10,6 @@
<file>files/icons/window-close.png</file>
<file>files/icons/window-restore.png</file>
<file>files/icons/mail-unread.png</file>
<file>files/icons/help-about.png</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>284</width>
<height>186</height>
</rect>
</property>
<property name="windowTitle">
<string>About SysTray-X</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="header">
<property name="text">
<string>SysTray-X Companion App by Ximi1970</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="VersionLabel">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="version">
<property name="text">
<string>0.0.1</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="buildLabel">
<property name="text">
<string>Build:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="build">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="hashLabel">
<property name="text">
<string>Hash:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="hash">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="branchLabel">
<property name="text">
<string>Branch:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="branch">
<property name="text">
<string>master</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AboutDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AboutDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -34,6 +34,14 @@ Preferences::Preferences( QObject *parent ) : QObject( parent )
m_poll_interval = 30;
m_debug = false;
m_version_major = QLatin1String( APP_VERSION_MAJOR );
m_version_minor = QLatin1String( APP_VERSION_MINOR );
m_version_patch = QLatin1String( APP_VERSION_PATCH );
m_version_build = QLatin1String( APP_BUILD );
m_version_hash = QLatin1String( APP_GITHASH );
m_version_branch = QLatin1String( APP_GITBRANCH );
}
@@ -257,3 +265,39 @@ void Preferences::setDebug( bool state )
emit signalDebugChange();
}
}
/*
* Get the software version.
*/
QString Preferences::getVersion() const
{
return m_version_major + "." + m_version_minor + "." + m_version_patch;
}
/*
* Get the number of commits.
*/
QString Preferences::getBuild() const
{
return m_version_build;
}
/*
* Get the git hash.
*/
QString Preferences::getHash() const
{
return m_version_hash;
}
/*
* Get the software version.
*/
QString Preferences::getBranch() const
{
return m_version_branch;
}

View File

@@ -163,6 +163,34 @@ class Preferences : public QObject
*/
void setDebug( bool state );
/**
* @brief getVersion. Get the software version.
*
* @return The version.
*/
QString getVersion() const;
/**
* @brief getBuild. Get the git number of commits.
*
* @return The number of commits.
*/
QString getBuild() const;
/**
* @brief getHash. Get the git hash.
*
* @return The hash.
*/
QString getHash() const;
/**
* @brief getBuild. Get the git branch.
*
* @return The branch.
*/
QString getBranch() const;
signals:
/**
@@ -246,6 +274,37 @@ class Preferences : public QObject
* @brief m_debug. Display debug window.
*/
bool m_debug;
/**
* @brief m_version_major. Major version number.
*/
QString m_version_major;
/**
* @brief m_version_minor. Minor version number.
*/
QString m_version_minor;
/**
* @brief m_version_patch. patch version number.
*/
QString m_version_patch;
/**
* @brief m_version_build. Git commits count.
*/
QString m_version_build;
/**
* @brief m_version_build. Git hash.
*/
QString m_version_hash;
/**
* @brief m_version_build. Git branch.
*/
QString m_version_branch;
};
#endif // PREFERENCES_H

View File

@@ -157,6 +157,10 @@ void SysTrayX::createActions()
m_pref_action->setIcon( QIcon( ":/files/icons/gtk-preferences.png" ) );
connect( m_pref_action, &QAction::triggered, m_pref_dialog, &PreferencesDialog::showNormal );
m_about_action = new QAction(tr("&About"), this);
m_about_action->setIcon( QIcon( ":/files/icons/gtk-preferences.png" ) );
connect( m_about_action, &QAction::triggered, this, &SysTrayX::slotAbout );
m_quit_action = new QAction( tr("&Quit"), this );
m_quit_action->setIcon( QIcon( ":/files/icons/window-close.png" ) );
connect( m_quit_action, &QAction::triggered, this, &SysTrayX::slotShutdown );
@@ -181,6 +185,7 @@ void SysTrayX::createTrayIcon()
m_tray_icon_menu->addAction( m_showhide_action );
m_tray_icon_menu->addSeparator();
m_tray_icon_menu->addAction( m_pref_action );
m_tray_icon_menu->addAction( m_about_action );
m_tray_icon_menu->addSeparator();
m_tray_icon_menu->addAction( m_quit_action );
@@ -236,3 +241,22 @@ void SysTrayX::slotShutdown()
*/
QCoreApplication::quit();
}
/*
* Show the about dialog
*/
void SysTrayX::slotAbout()
{
Ui::AboutDialog ui;
QDialog dialog;
ui.setupUi( &dialog );
ui.version->setText( m_preferences->getVersion() );
ui.build->setText( m_preferences->getBuild() );
ui.hash->setText( m_preferences->getHash() );
ui.branch->setText( m_preferences->getBranch() );
dialog.exec();
}

View File

@@ -5,6 +5,7 @@
* Local includes
*/
#include "ui_debugwidget.h"
#include "ui_aboutdialog.h"
#include "preferences.h"
/*
@@ -87,6 +88,11 @@ class SysTrayX : public QObject
*/
void slotShutdown();
/**
* @brief slotAbout. Hnadle about request from the menu.
*/
void slotAbout();
private:
/**
@@ -127,9 +133,10 @@ class SysTrayX : public QObject
/**
* @brief m_xxxx_action. Pointer to the menu actions.
*/
QAction* m_pref_action;
QAction* m_quit_action;
QAction* m_showhide_action;
QAction* m_pref_action;
QAction* m_about_action;
QAction* m_quit_action;
};
#endif // SYSTRAYX_H

View File

@@ -6,7 +6,9 @@ var SysTrayX = {
pollInterval: "30"
},
platformInfo: undefined
platformInfo: undefined,
version: 0
};
SysTrayX.Messaging = {
@@ -357,6 +359,10 @@ async function start() {
console.log("Arch: " + SysTrayX.platformInfo.arch);
console.log("Nack-Arch: " + SysTrayX.platformInfo.nacl_arch);
// Get addon version
SysTrayX.version = browser.runtime.getManifest().version;
console.log("Addon version: "+SysTrayX.version);
// Init defaults before everything
await getDefaultIcon();