mainwindow.h 2.94 KB
Newer Older
Edric Milaret's avatar
Edric Milaret committed
1
/***************************************************************************
2
 * Copyright (C) 2015-2017 by Savoir-faire Linux                                *
Edric Milaret's avatar
Edric Milaret committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 3 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program 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/>.   *
 **************************************************************************/

Edric Milaret's avatar
Edric Milaret committed
19
#pragma once
Edric Milaret's avatar
Edric Milaret committed
20

21 22
#include "globalsystemtray.h"

Edric Milaret's avatar
Edric Milaret committed
23 24
#include <QMainWindow>
#include <QMouseEvent>
Edric Milaret's avatar
Edric Milaret committed
25
#include <QNetworkConfigurationManager>
Edric Milaret's avatar
Edric Milaret committed
26

27
#include "navwidget.h"
28
#include "settingswidget.h"
29 30 31

// LRC
#include "call.h"
Edric Milaret's avatar
Edric Milaret committed
32

33 34
static constexpr char IDM_ABOUTBOX = 0x0010;

35 36 37 38 39 40
static constexpr uint32_t QtMaxDimension = 16777215;
static constexpr uint32_t mainWindowMinWidth = 1088;
static constexpr uint32_t mainWindowMinHeight = 600;
static constexpr uint32_t wizardDialogWidth = 512;
static constexpr uint32_t wizardDialogHeight = 512;

Edric Milaret's avatar
Edric Milaret committed
41 42 43 44 45 46 47 48 49
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
50 51 52 53
    inline static MainWindow& instance()  {
        static auto instance = new MainWindow();
        return *instance;
    }
54
    void createThumbBar();
Olivier SOLDANO's avatar
Olivier SOLDANO committed
55
    bool init();
Edric Milaret's avatar
Edric Milaret committed
56

57 58
    void show();

59
protected:
Edric Milaret's avatar
Edric Milaret committed
60 61
    bool nativeEvent(const QByteArray& eventType, void* message, long* result);
    void closeEvent(QCloseEvent* event);
Andreas Traczyk's avatar
Andreas Traczyk committed
62
    void resizeEvent(QResizeEvent *event);
63

Edric Milaret's avatar
Edric Milaret committed
64 65 66
public slots:
    void onRingEvent(const QString& uri);

Edric Milaret's avatar
Edric Milaret committed
67
private slots:
68
    void slotCurrentChanged(int index);
Edric Milaret's avatar
Edric Milaret committed
69
    void trayActivated(QSystemTrayIcon::ActivationReason reason);
Edric Milaret's avatar
Edric Milaret committed
70
    void onIncomingCall(Call* call);
71
    void switchNormalMaximize();
Edric Milaret's avatar
Edric Milaret committed
72
    void notificationClicked();
Edric Milaret's avatar
Edric Milaret committed
73 74

private:
Edric Milaret's avatar
Edric Milaret committed
75
    explicit MainWindow(QWidget* parent = 0);
76 77
    ~MainWindow();

78 79
    void setWindowSize(ScreenEnum scr, bool firstUse = false);
    ScreenEnum lastScr_;
80
    int lastAccountCount_;
81 82
    Qt::WindowFlags flags_;

83
    void readSettingsFromRegistry();
84

85
    Ui::MainWindow* ui;
Edric Milaret's avatar
Edric Milaret committed
86
    QNetworkConfigurationManager netManager_;
87
    QMetaObject::Connection screenChangedConnection_;
88
    QMetaObject::Connection activeChangedConnection_;
Edric Milaret's avatar
Edric Milaret committed
89
};