view ui/mainwindow.h @ 60:6acb1dae6185

Use strn functions and improve error handling. Even if we know the strings are NULL terminated we use length terminated string functions after a first strlen this makes it easier to assert that at one point we know the string is terminated and afterwards use the length of that.
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 18 Mar 2014 11:28:02 +0000
parents c6125d73faf4
children f22a99f7cb69
line wrap: on
line source
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QSystemTrayIcon>
#include <QDialog>
#include <QSettings>

#include "downloader.h"
class QMenu;
class QAction;
class QTimer;

class MainWindow : public QDialog
{
    Q_OBJECT

public:
    MainWindow();

    void setMessage(const QString message) {mCurMessage = message;}
    QString getMessage() {return mCurMessage;}

    enum CurrentState {
        BeforeDownload,
        NewListAvailable,
        NewSoftwareAvailable,
        TransferError
    };

    CurrentState getState() {return mCurState;}
    void setState(CurrentState state) {mCurState = state;}

private slots:
    void showMessage();
    void iconActivated(QSystemTrayIcon::ActivationReason reason);
    void checkUpdates();
    void handleNewList(const QString& fileName, const QDateTime& modDate);
    void handleNewSW(const QString& fileName, const QDateTime& modDate);
    void downloaderError(const QString &message, SSLConnection::ErrorCode error);

private:
    void verifyAvailableData();
    void createTrayIcon();
    void createActions();

    QString mCurMessage;
    QString mInstalledSWVersion;
    QString mInstalledListVersion;

    QSettings mSettings;

    QSystemTrayIcon *mTrayIcon;
    QTimer *mMessageTimer;
    QMenu *mTrayMenu;
    QAction *mCheckUpdates;
    QAction *mQuitAction;
    CurrentState mCurState;
};

#endif // MAINWINDOW_H

http://wald.intevation.org/projects/trustbridge/