Check for updates feature started...

This commit is contained in:
Martin Rotter 2014-02-19 17:41:14 +01:00
parent 1b1e52ab80
commit a2a8501ca9
9 changed files with 161 additions and 1 deletions

View File

@ -299,6 +299,7 @@ set(APP_SOURCES
src/gui/widgetwithstatus.cpp
src/gui/labelwithstatus.cpp
src/gui/messagebox.cpp
src/gui/formupdate.cpp
# CORE sources.
src/core/debugging.cpp
@ -367,6 +368,7 @@ set(APP_HEADERS
src/gui/widgetwithstatus.h
src/gui/labelwithstatus.h
src/gui/messagebox.h
src/gui/formupdate.h
# CORE headers.
src/core/settings.h
@ -386,6 +388,7 @@ set(APP_HEADERS
# Add form files.
set(APP_FORMS
src/gui/formupdate.ui
src/gui/formmain.ui
src/gui/formsettings.ui
src/gui/formwelcome.ui

View File

@ -181,7 +181,7 @@
</message>
<message>
<source>&lt;b&gt;%8&lt;/b&gt;&lt;br&gt;&lt;b&gt;Version:&lt;/b&gt; %1 (build on %2 with CMake %3)&lt;br&gt;&lt;b&gt;Revision:&lt;/b&gt; %4&lt;br&gt;&lt;b&gt;Build date:&lt;/b&gt; %5&lt;br&gt;&lt;b&gt;Qt:&lt;/b&gt; %6 (compiled against %7)&lt;br&gt;</source>
<translation>&lt;b&gt;%8&lt;/b&gt;&lt;br&gt;&lt;b&gt;Verze:&lt;/b&gt; %1 (OS při sestavování %2 verze CMake %3)&lt;br&gt;&lt;b&gt;Revize:&lt;/b&gt; %4&lt;br&gt;&lt;b&gt;Datum sestavení:&lt;/b&gt; %5&lt;br&gt;&lt;b&gt;Qt:&lt;/b&gt; %6 (při kompilaci %7)&lt;br&gt;</translation>
<translation>&lt;b&gt;%8&lt;/b&gt;&lt;br&gt;&lt;b&gt;Verze:&lt;/b&gt; %1 (při sestavování použit OS %2 a CMake %3)&lt;br&gt;&lt;b&gt;Revize:&lt;/b&gt; %4&lt;br&gt;&lt;b&gt;Datum sestavení:&lt;/b&gt; %5&lt;br&gt;&lt;b&gt;Qt:&lt;/b&gt; %6 (při kompilaci %7)&lt;br&gt;</translation>
</message>
<message>
<source>Thanks to page is available only in English language.</source>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -23,6 +23,7 @@
#define APP_VERSION "@APP_VERSION@"
#define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@; Webkit/") + qWebKitVersion()
#define RELEASES_LIST "https://bitbucket.org/skunkos/rssguard/raw/master/resources/text/UPDATES?at=master"
#define DEFAULT_LOCALE "en_GB"
#define DEFAULT_FEED_ENCODING "UTF-8"
#define URL_REGEXP "^(http|https|feed|ftp):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&amp;:/~\\+#]*[\\w\\-\\@?^=%&amp;/~\\+#])?$"

View File

@ -7,6 +7,7 @@
#include "gui/formabout.h"
#include "gui/formsettings.h"
#include "gui/feedsview.h"
#include "gui/messagebox.h"
#include "gui/webbrowser.h"
#include "gui/iconthemefactory.h"
#include "gui/systemtrayicon.h"
@ -15,6 +16,10 @@
#include "gui/feedmessageviewer.h"
#include "qtsingleapplication/qtsingleapplication.h"
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
#include "gui/formupdate.h"
#endif
#include <QCloseEvent>
#include <QSessionManager>
#include <QRect>
@ -105,6 +110,14 @@ void FormMain::prepareMenus() {
m_trayMenu = new QMenu(APP_NAME, this);
#endif
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
// Add "check for updates" item on some platforms.
m_actionCheckForUpdates = new QAction(tr("Check for updates"), this);
m_actionCheckForUpdates->setIcon(IconThemeFactory::instance()->fromTheme("check-for-updates"));
m_actionCheckForUpdates->setToolTip(tr("Check if new update for the application is available for download."));
m_ui->m_menuHelp->insertAction(m_ui->m_actionAboutGuard, m_actionCheckForUpdates);
#endif
// Add needed items to the menu.
m_trayMenu->addAction(m_ui->m_actionSwitchMainWindow);
m_trayMenu->addSeparator();
@ -328,6 +341,10 @@ void FormMain::createConnections() {
// Menu "Help" connections.
connect(m_ui->m_actionAboutGuard, SIGNAL(triggered()), this, SLOT(showAbout()));
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
connect(m_actionCheckForUpdates, SIGNAL(triggered()), this, SLOT(showUpdates()));
#endif
// General connections.
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
@ -384,6 +401,30 @@ void FormMain::showAbout() {
delete form_pointer.data();
}
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
void FormMain::showUpdates() {
if (!SystemFactory::instance()->applicationCloseLock()->tryLock()) {
if (SystemTrayIcon::isSystemTrayActivated()) {
SystemTrayIcon::instance()->showMessage(tr("Cannot check for updates"),
tr("You cannot check for updates because feed update is ongoing."),
QSystemTrayIcon::Warning);
}
else {
MessageBox::show(this,
QMessageBox::Warning,
tr("Cannot check for updates"),
tr("You cannot check for updates because feed update is ongoing."));
}
return;
}
QPointer<FormUpdate> form_update = new FormUpdate(this);
form_update.data()->exec();
delete form_update.data();
}
#endif
void FormMain::showSettings() {
QPointer<FormSettings> form_pointer = new FormSettings(this);
form_pointer.data()->exec();

View File

@ -93,7 +93,15 @@ class FormMain : public QMainWindow {
void showSettings();
void showAbout();
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
void showUpdates();
#endif
private:
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
QAction *m_actionCheckForUpdates;
#endif
Ui::FormMain *m_ui;
QMenu *m_trayMenu;
StatusBar *m_statusBar;

12
src/gui/formupdate.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "formupdate.h"
FormUpdate::FormUpdate(QWidget *parent)
: QDialog(parent), m_ui(new Ui::FormUpdate) {
m_ui->setupUi(this);
}
FormUpdate::~FormUpdate()
{
delete m_ui;
}

24
src/gui/formupdate.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef FORMUPDATE_H
#define FORMUPDATE_H
#include <QDialog>
#include "ui_formupdate.h"
namespace Ui {
class FormUpdate;
}
class FormUpdate : public QDialog {
Q_OBJECT
public:
explicit FormUpdate(QWidget *parent = 0);
virtual ~FormUpdate();
private:
Ui::FormUpdate *m_ui;
};
#endif // FORMUPDATE_H

71
src/gui/formupdate.ui Normal file
View File

@ -0,0 +1,71 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>FormUpdate</class>
<widget name="FormUpdate" class="QDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget name="buttonBox" class="QDialogButtonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</widget>
<pixmapfunction/>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>FormUpdate</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>FormUpdate</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>