qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
nexus.h
Go to the documentation of this file.
1 /*
2  Copyright © 2015-2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #pragma once
22 
23 #include <QObject>
24 
25 #include "audio/iaudiocontrol.h"
26 
27 class Widget;
28 class Profile;
29 class Settings;
30 class LoginScreen;
31 class Core;
32 class QCommandLineParser;
33 
34 #ifdef Q_OS_MAC
35 class QMenuBar;
36 class QMenu;
37 class QAction;
38 class QWindow;
39 class QActionGroup;
40 class QSignalMapper;
41 #endif
42 
43 class Nexus : public QObject
44 {
45  Q_OBJECT
46 public:
47  void start();
48  void showMainGUI();
50  void setParser(QCommandLineParser* parser);
51  static Nexus& getInstance();
52  static void destroyInstance();
53  static Core* getCore();
54  static Profile* getProfile();
55  static Widget* getDesktopGUI();
56 
57 
58 #ifdef Q_OS_MAC
59 public:
60  QMenuBar* globalMenuBar;
61  QMenu* viewMenu;
62  QMenu* windowMenu;
63  QAction* minimizeAction;
64  QAction* fullscreenAction;
65  QAction* frontAction;
66  QMenu* dockMenu;
67 
68 public slots:
69  void retranslateUi();
70  void onWindowStateChanged(Qt::WindowStates state);
71  void updateWindows();
72  void updateWindowsClosed();
73  void updateWindowsStates();
74  void onOpenWindow(QObject* object);
75  void toggleFullscreen();
76  void bringAllToFront();
77 
78 private:
79  void updateWindowsArg(QWindow* closedWindow);
80 
81  QActionGroup* windowActions = nullptr;
82 #endif
83 signals:
85  void profileLoaded();
86  void profileLoadFailed();
87  void saveGlobal();
88 
89 public slots:
90  void onCreateNewProfile(const QString& name, const QString& pass);
91  void onLoadProfile(const QString& name, const QString& pass);
92  int showLogin(const QString& profileName = QString());
94 
95 private:
96  explicit Nexus(QObject* parent = nullptr);
97  void connectLoginScreen(const LoginScreen& loginScreen);
98  void setProfile(Profile* p);
99  ~Nexus();
100 
101 private:
105  std::unique_ptr<IAudioControl> audioControl;
106  QCommandLineParser* parser = nullptr;
107 };
Settings
Definition: settings.h:51
Nexus::showLogin
int showLogin(const QString &profileName=QString())
Hides the main GUI, delete the profile, and shows the login screen.
Definition: nexus.cpp:153
Nexus::setSettings
void setSettings(Settings *settings)
Definition: nexus.cpp:194
Nexus::~Nexus
~Nexus()
Definition: nexus.cpp:66
LoginScreen
Definition: loginscreen.h:33
Nexus::showMainGUI
void showMainGUI()
Definition: nexus.cpp:223
Nexus::onLoadProfile
void onLoadProfile(const QString &name, const QString &pass)
Definition: nexus.cpp:309
Profile
Handles all qTox internal paths.
Definition: profile.h:42
Nexus::setProfile
void setProfile(Profile *p)
Definition: nexus.cpp:318
Nexus::settings
Settings * settings
Definition: nexus.h:103
Nexus::saveGlobal
void saveGlobal()
Nexus::connectLoginScreen
void connectLoginScreen(const LoginScreen &loginScreen)
Definition: nexus.cpp:205
Nexus::onCreateNewProfile
void onCreateNewProfile(const QString &name, const QString &pass)
Creates a new profile and replaces the current one.
Definition: nexus.cpp:300
Nexus::getProfile
static Profile * getProfile()
Get current user profile.
Definition: nexus.cpp:290
Nexus::profileLoadFailed
void profileLoadFailed()
Nexus::Nexus
Nexus(QObject *parent=nullptr)
Definition: nexus.cpp:60
Nexus::profile
Profile * profile
Definition: nexus.h:102
Nexus::currentProfileChanged
void currentProfileChanged(Profile *Profile)
Nexus::audioControl
std::unique_ptr< IAudioControl > audioControl
Definition: nexus.h:105
Nexus::start
void start()
Sets up invariants and calls showLogin.
Definition: nexus.cpp:84
Nexus
Definition: nexus.h:43
Nexus::bootstrapWithProfile
void bootstrapWithProfile(Profile *p)
Definition: nexus.cpp:180
Nexus::parser
QCommandLineParser * parser
Definition: nexus.h:106
Nexus::getDesktopGUI
static Widget * getDesktopGUI()
Get desktop GUI widget.
Definition: nexus.cpp:340
Nexus::profileLoaded
void profileLoaded()
Nexus::destroyInstance
static void destroyInstance()
Definition: nexus.cpp:267
Nexus::getInstance
static Nexus & getInstance()
Returns the singleton instance.
Definition: nexus.cpp:259
Nexus::setParser
void setParser(QCommandLineParser *parser)
Definition: nexus.cpp:331
Nexus::widget
Widget * widget
Definition: nexus.h:104
Nexus::getCore
static Core * getCore()
Get core instance.
Definition: nexus.cpp:277
Core
Definition: core.h:59
Widget
Definition: widget.h:87