Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
Anthony LĂ©onard | 2fde81d | 2017-04-17 10:06:55 -0400 | [diff] [blame] | 2 | * Copyright (C) 2015-2017 by Savoir-faire Linux * |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 3 | * 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 Milaret | 5f316da | 2015-09-28 11:57:42 -0400 | [diff] [blame] | 19 | #pragma once |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 20 | |
Edric Milaret | 2cf3429 | 2015-06-22 16:27:03 -0400 | [diff] [blame] | 21 | #include "globalsystemtray.h" |
| 22 | |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 23 | #include <QMainWindow> |
| 24 | #include <QMouseEvent> |
Edric Milaret | 28290e3 | 2016-09-07 15:51:41 -0400 | [diff] [blame] | 25 | #include <QNetworkConfigurationManager> |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 26 | |
Olivier SOLDANO | c1ca2df | 2017-09-06 16:01:46 -0400 | [diff] [blame] | 27 | #include "navwidget.h" |
Andreas Traczyk | b81281e | 2018-12-13 13:13:28 -0500 | [diff] [blame] | 28 | #include "settingswidget.h" |
Olivier SOLDANO | c1ca2df | 2017-09-06 16:01:46 -0400 | [diff] [blame] | 29 | |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 30 | static constexpr char IDM_ABOUTBOX = 0x0010; |
| 31 | |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 32 | static constexpr uint32_t QtMaxDimension = 16777215; |
| 33 | static constexpr uint32_t mainWindowMinWidth = 1088; |
| 34 | static constexpr uint32_t mainWindowMinHeight = 600; |
| 35 | static constexpr uint32_t wizardDialogWidth = 512; |
| 36 | static constexpr uint32_t wizardDialogHeight = 512; |
| 37 | |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 38 | namespace Ui { |
| 39 | class MainWindow; |
| 40 | } |
| 41 | |
| 42 | class MainWindow : public QMainWindow |
| 43 | { |
| 44 | Q_OBJECT |
| 45 | |
| 46 | public: |
Edric Milaret | 9c3e7f7 | 2016-01-27 10:48:20 -0500 | [diff] [blame] | 47 | inline static MainWindow& instance() { |
| 48 | static auto instance = new MainWindow(); |
| 49 | return *instance; |
| 50 | } |
Edric Milaret | 2cf3429 | 2015-06-22 16:27:03 -0400 | [diff] [blame] | 51 | void createThumbBar(); |
Olivier SOLDANO | 2100f1c | 2017-09-06 16:45:20 -0400 | [diff] [blame] | 52 | bool init(); |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 53 | void show(); |
Andreas Traczyk | 2965014 | 2019-01-03 20:33:56 -0500 | [diff] [blame] | 54 | float getCurrentScalingRatio(); |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 55 | |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 56 | protected: |
Edric Milaret | db818e5 | 2016-02-02 14:53:19 -0500 | [diff] [blame] | 57 | bool nativeEvent(const QByteArray& eventType, void* message, long* result); |
| 58 | void closeEvent(QCloseEvent* event); |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 59 | void resizeEvent(QResizeEvent *event); |
Andreas Traczyk | dc17c81 | 2019-01-11 15:35:20 -0500 | [diff] [blame] | 60 | void keyReleaseEvent(QKeyEvent* ke); |
Andreas Traczyk | ad09908 | 2019-01-18 13:19:03 -0500 | [diff] [blame] | 61 | void changeEvent(QEvent* e); |
Andreas Traczyk | dc17c81 | 2019-01-11 15:35:20 -0500 | [diff] [blame] | 62 | |
| 63 | signals: |
| 64 | void keyReleased(QKeyEvent*ke); |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 65 | |
Edric Milaret | fe39094 | 2015-08-04 13:41:03 -0400 | [diff] [blame] | 66 | public slots: |
| 67 | void onRingEvent(const QString& uri); |
| 68 | |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 69 | private slots: |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 70 | void slotCurrentChanged(int index); |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 71 | void trayActivated(QSystemTrayIcon::ActivationReason reason); |
Edric Milaret | 568a0e5 | 2016-09-02 16:26:58 -0400 | [diff] [blame] | 72 | void notificationClicked(); |
Andreas Traczyk | 2965014 | 2019-01-03 20:33:56 -0500 | [diff] [blame] | 73 | void slotScreenChanged(QScreen* screen); |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 74 | |
| 75 | private: |
Edric Milaret | db818e5 | 2016-02-02 14:53:19 -0500 | [diff] [blame] | 76 | explicit MainWindow(QWidget* parent = 0); |
Andreas Traczyk | d063d5a | 2018-08-10 12:56:23 -0400 | [diff] [blame] | 77 | ~MainWindow(); |
| 78 | |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 79 | void setWindowSize(ScreenEnum scr, bool firstUse = false); |
| 80 | ScreenEnum lastScr_; |
Andreas Traczyk | 3199a1f | 2018-12-26 18:20:09 -0500 | [diff] [blame] | 81 | int lastAccountCount_; |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 82 | Qt::WindowFlags flags_; |
Andreas Traczyk | 59ba48a | 2019-01-04 16:12:03 -0500 | [diff] [blame] | 83 | float currentScalingRatio_; |
Andreas Traczyk | ad09908 | 2019-01-18 13:19:03 -0500 | [diff] [blame] | 84 | Qt::WindowState currentWindowState_{ Qt::WindowState::WindowNoState }; |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 85 | |
Andreas Traczyk | d063d5a | 2018-08-10 12:56:23 -0400 | [diff] [blame] | 86 | void readSettingsFromRegistry(); |
Andreas Traczyk | fdc7f9b | 2018-08-14 18:42:03 -0400 | [diff] [blame] | 87 | |
Nicolas Jager | 97a21b4 | 2015-12-03 16:55:45 -0500 | [diff] [blame] | 88 | Ui::MainWindow* ui; |
Edric Milaret | 28290e3 | 2016-09-07 15:51:41 -0400 | [diff] [blame] | 89 | QNetworkConfigurationManager netManager_; |
Andreas Traczyk | fc33a49 | 2018-12-14 13:53:13 -0500 | [diff] [blame] | 90 | QMetaObject::Connection screenChangedConnection_; |
Edric Milaret | 627500d | 2015-03-27 16:41:40 -0400 | [diff] [blame] | 91 | }; |