blob: a0b4cd6ad228547cae2c57e55eff1618b7872267 [file] [log] [blame]
Edric Milaret627500d2015-03-27 16:41:40 -04001/***************************************************************************
Anthony LĂ©onard2fde81d2017-04-17 10:06:55 -04002 * Copyright (C) 2015-2017 by Savoir-faire Linux *
Edric Milaret627500d2015-03-27 16:41:40 -04003 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
Edric Milaret5f316da2015-09-28 11:57:42 -040019#pragma once
Edric Milaret627500d2015-03-27 16:41:40 -040020
Edric Milaret2cf34292015-06-22 16:27:03 -040021#include "globalsystemtray.h"
22
Edric Milaret627500d2015-03-27 16:41:40 -040023#include <QMainWindow>
24#include <QMouseEvent>
Edric Milaret28290e32016-09-07 15:51:41 -040025#include <QNetworkConfigurationManager>
Edric Milaret627500d2015-03-27 16:41:40 -040026
Olivier SOLDANOc1ca2df2017-09-06 16:01:46 -040027#include "navwidget.h"
Andreas Traczykb81281e2018-12-13 13:13:28 -050028#include "settingswidget.h"
Olivier SOLDANOc1ca2df2017-09-06 16:01:46 -040029
Edric Milareted0b2802015-10-01 15:10:02 -040030static constexpr char IDM_ABOUTBOX = 0x0010;
31
Andreas Traczykfc33a492018-12-14 13:53:13 -050032static constexpr uint32_t QtMaxDimension = 16777215;
33static constexpr uint32_t mainWindowMinWidth = 1088;
34static constexpr uint32_t mainWindowMinHeight = 600;
35static constexpr uint32_t wizardDialogWidth = 512;
36static constexpr uint32_t wizardDialogHeight = 512;
37
Edric Milaret627500d2015-03-27 16:41:40 -040038namespace Ui {
39class MainWindow;
40}
41
42class MainWindow : public QMainWindow
43{
44 Q_OBJECT
45
46public:
Edric Milaret9c3e7f72016-01-27 10:48:20 -050047 inline static MainWindow& instance() {
48 static auto instance = new MainWindow();
49 return *instance;
50 }
Edric Milaret2cf34292015-06-22 16:27:03 -040051 void createThumbBar();
Olivier SOLDANO2100f1c2017-09-06 16:45:20 -040052 bool init();
Andreas Traczykfc33a492018-12-14 13:53:13 -050053 void show();
Andreas Traczyk29650142019-01-03 20:33:56 -050054 float getCurrentScalingRatio();
Andreas Traczykfc33a492018-12-14 13:53:13 -050055
Edric Milareted0b2802015-10-01 15:10:02 -040056protected:
Edric Milaretdb818e52016-02-02 14:53:19 -050057 bool nativeEvent(const QByteArray& eventType, void* message, long* result);
58 void closeEvent(QCloseEvent* event);
Andreas Traczyk6ace34f2018-12-14 14:31:23 -050059 void resizeEvent(QResizeEvent *event);
Andreas Traczykdc17c812019-01-11 15:35:20 -050060 void keyReleaseEvent(QKeyEvent* ke);
Andreas Traczykad099082019-01-18 13:19:03 -050061 void changeEvent(QEvent* e);
Andreas Traczykdc17c812019-01-11 15:35:20 -050062
63signals:
64 void keyReleased(QKeyEvent*ke);
Nicolas Jager97a21b42015-12-03 16:55:45 -050065
Edric Milaretfe390942015-08-04 13:41:03 -040066public slots:
67 void onRingEvent(const QString& uri);
68
Edric Milaret627500d2015-03-27 16:41:40 -040069private slots:
Andreas Traczykfc33a492018-12-14 13:53:13 -050070 void slotCurrentChanged(int index);
Edric Milaret627500d2015-03-27 16:41:40 -040071 void trayActivated(QSystemTrayIcon::ActivationReason reason);
Edric Milaret568a0e52016-09-02 16:26:58 -040072 void notificationClicked();
Andreas Traczyk29650142019-01-03 20:33:56 -050073 void slotScreenChanged(QScreen* screen);
Edric Milaret627500d2015-03-27 16:41:40 -040074
75private:
Edric Milaretdb818e52016-02-02 14:53:19 -050076 explicit MainWindow(QWidget* parent = 0);
Andreas Traczykd063d5a2018-08-10 12:56:23 -040077 ~MainWindow();
78
Andreas Traczykfc33a492018-12-14 13:53:13 -050079 void setWindowSize(ScreenEnum scr, bool firstUse = false);
80 ScreenEnum lastScr_;
Andreas Traczyk3199a1f2018-12-26 18:20:09 -050081 int lastAccountCount_;
Andreas Traczykfc33a492018-12-14 13:53:13 -050082 Qt::WindowFlags flags_;
Andreas Traczyk59ba48a2019-01-04 16:12:03 -050083 float currentScalingRatio_;
Andreas Traczykad099082019-01-18 13:19:03 -050084 Qt::WindowState currentWindowState_{ Qt::WindowState::WindowNoState };
Andreas Traczykfc33a492018-12-14 13:53:13 -050085
Andreas Traczykd063d5a2018-08-10 12:56:23 -040086 void readSettingsFromRegistry();
Andreas Traczykfdc7f9b2018-08-14 18:42:03 -040087
Nicolas Jager97a21b42015-12-03 16:55:45 -050088 Ui::MainWindow* ui;
Edric Milaret28290e32016-09-07 15:51:41 -040089 QNetworkConfigurationManager netManager_;
Andreas Traczykfc33a492018-12-14 13:53:13 -050090 QMetaObject::Connection screenChangedConnection_;
Edric Milaret627500d2015-03-27 16:41:40 -040091};