2015-06-06 09:40:08 +08:00
|
|
|
/*
|
|
|
|
Copyright © 2014-2015 by The qTox Project
|
|
|
|
|
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
|
|
|
qTox is libre 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.
|
|
|
|
|
|
|
|
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2015-02-06 19:28:49 +08:00
|
|
|
#include "nexus.h"
|
2015-06-06 07:44:47 +08:00
|
|
|
#include "src/persistence/profile.h"
|
2015-04-24 08:32:09 +08:00
|
|
|
#include "src/core/core.h"
|
2015-09-28 01:59:26 +08:00
|
|
|
#include "src/core/coreav.h"
|
2015-06-06 07:44:47 +08:00
|
|
|
#include "persistence/settings.h"
|
2015-05-14 10:46:28 +08:00
|
|
|
#include "video/camerasource.h"
|
2015-02-07 02:01:31 +08:00
|
|
|
#include "widget/gui.h"
|
2015-10-14 01:02:28 +08:00
|
|
|
#include "widget/style.h"
|
2015-06-04 07:30:17 +08:00
|
|
|
#include "widget/loginscreen.h"
|
2015-02-06 19:28:49 +08:00
|
|
|
#include <QThread>
|
|
|
|
#include <QDebug>
|
2015-02-16 07:35:27 +08:00
|
|
|
#include <QImageReader>
|
2015-04-27 23:59:44 +08:00
|
|
|
#include <QFile>
|
2015-06-04 07:30:17 +08:00
|
|
|
#include <QApplication>
|
|
|
|
#include <cassert>
|
2015-06-26 19:00:16 +08:00
|
|
|
#include <vpx/vpx_image.h>
|
2015-02-06 19:28:49 +08:00
|
|
|
|
|
|
|
#ifdef Q_OS_ANDROID
|
|
|
|
#include <src/widget/androidgui.h>
|
|
|
|
#else
|
|
|
|
#include <src/widget/widget.h>
|
2015-06-04 08:10:06 +08:00
|
|
|
#include <QDesktopWidget>
|
2015-02-06 19:28:49 +08:00
|
|
|
#endif
|
|
|
|
|
2015-07-09 20:43:19 +08:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
#include <QWindow>
|
|
|
|
#include <QMenuBar>
|
2015-07-30 07:46:19 +08:00
|
|
|
#include <QActionGroup>
|
|
|
|
#include <QSignalMapper>
|
2015-07-09 20:43:19 +08:00
|
|
|
#endif
|
|
|
|
|
2015-10-08 06:52:05 +08:00
|
|
|
Q_DECLARE_OPAQUE_POINTER(ToxAV*)
|
|
|
|
|
2015-02-07 02:38:08 +08:00
|
|
|
static Nexus* nexus{nullptr};
|
|
|
|
|
2015-02-06 19:28:49 +08:00
|
|
|
Nexus::Nexus(QObject *parent) :
|
|
|
|
QObject(parent),
|
2015-06-04 07:30:17 +08:00
|
|
|
profile{nullptr},
|
2015-02-06 19:28:49 +08:00
|
|
|
widget{nullptr},
|
2015-06-04 17:42:49 +08:00
|
|
|
androidgui{nullptr},
|
|
|
|
loginScreen{nullptr}
|
2015-02-06 19:28:49 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Nexus::~Nexus()
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_ANDROID
|
|
|
|
delete androidgui;
|
|
|
|
#else
|
|
|
|
delete widget;
|
|
|
|
#endif
|
2015-06-04 17:42:49 +08:00
|
|
|
delete loginScreen;
|
|
|
|
delete profile;
|
2015-06-06 21:54:58 +08:00
|
|
|
Settings::getInstance().saveGlobal();
|
2015-07-09 20:43:19 +08:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
delete globalMenuBar;
|
|
|
|
#endif
|
2015-02-06 19:28:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::start()
|
|
|
|
{
|
2015-05-11 20:54:03 +08:00
|
|
|
qDebug() << "Starting up";
|
2015-02-06 19:28:49 +08:00
|
|
|
|
|
|
|
// Setup the environment
|
|
|
|
qRegisterMetaType<Status>("Status");
|
|
|
|
qRegisterMetaType<vpx_image>("vpx_image");
|
|
|
|
qRegisterMetaType<uint8_t>("uint8_t");
|
|
|
|
qRegisterMetaType<uint16_t>("uint16_t");
|
2015-04-20 05:12:44 +08:00
|
|
|
qRegisterMetaType<uint32_t>("uint32_t");
|
2015-02-06 19:28:49 +08:00
|
|
|
qRegisterMetaType<const int16_t*>("const int16_t*");
|
|
|
|
qRegisterMetaType<int32_t>("int32_t");
|
|
|
|
qRegisterMetaType<int64_t>("int64_t");
|
|
|
|
qRegisterMetaType<QPixmap>("QPixmap");
|
2015-06-06 21:54:58 +08:00
|
|
|
qRegisterMetaType<Profile*>("Profile*");
|
2015-10-08 06:52:05 +08:00
|
|
|
qRegisterMetaType<ToxAV*>("ToxAV*");
|
2015-02-06 19:28:49 +08:00
|
|
|
qRegisterMetaType<ToxFile>("ToxFile");
|
|
|
|
qRegisterMetaType<ToxFile::FileDirection>("ToxFile::FileDirection");
|
2015-05-14 10:46:28 +08:00
|
|
|
qRegisterMetaType<std::shared_ptr<VideoFrame>>("std::shared_ptr<VideoFrame>");
|
2015-02-06 19:28:49 +08:00
|
|
|
|
2015-07-30 07:46:19 +08:00
|
|
|
loginScreen = new LoginScreen();
|
2015-10-14 01:02:28 +08:00
|
|
|
loginScreen->setStyleSheet(Style::getStylesheet(":/ui/loginScreen/loginScreen.css"));
|
2015-07-30 07:46:19 +08:00
|
|
|
|
2015-07-09 20:43:19 +08:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
globalMenuBar = new QMenuBar(0);
|
2015-07-30 07:46:19 +08:00
|
|
|
dockMenu = new QMenu(globalMenuBar);
|
2015-07-09 20:43:19 +08:00
|
|
|
|
2015-07-30 07:46:19 +08:00
|
|
|
viewMenu = globalMenuBar->addMenu(QString());
|
|
|
|
|
|
|
|
windowMenu = globalMenuBar->addMenu(QString());
|
2015-07-09 20:43:19 +08:00
|
|
|
globalMenuBar->addAction(windowMenu->menuAction());
|
|
|
|
|
2015-07-30 07:46:19 +08:00
|
|
|
fullscreenAction = viewMenu->addAction(QString());
|
|
|
|
fullscreenAction->setShortcut(QKeySequence::FullScreen);
|
|
|
|
connect(fullscreenAction, &QAction::triggered, this, &Nexus::toggleFullscreen);
|
|
|
|
|
|
|
|
minimizeAction = windowMenu->addAction(QString());
|
2015-07-09 20:43:19 +08:00
|
|
|
minimizeAction->setShortcut(Qt::CTRL + Qt::Key_M);
|
2015-07-30 07:46:19 +08:00
|
|
|
connect(minimizeAction, &QAction::triggered, [this]()
|
2015-07-09 20:43:19 +08:00
|
|
|
{
|
2015-07-30 07:46:19 +08:00
|
|
|
minimizeAction->setEnabled(false);
|
2015-07-09 20:43:19 +08:00
|
|
|
QApplication::focusWindow()->showMinimized();
|
|
|
|
});
|
2015-07-30 07:46:19 +08:00
|
|
|
|
|
|
|
windowMenu->addSeparator();
|
|
|
|
frontAction = windowMenu->addAction(QString());
|
|
|
|
connect(frontAction, &QAction::triggered, this, &Nexus::bringAllToFront);
|
2015-07-09 20:43:19 +08:00
|
|
|
|
|
|
|
QAction* quitAction = new QAction(globalMenuBar);
|
|
|
|
quitAction->setMenuRole(QAction::QuitRole);
|
|
|
|
connect(quitAction, &QAction::triggered, qApp, &QApplication::quit);
|
|
|
|
|
2015-07-30 07:46:19 +08:00
|
|
|
windowMapper = new QSignalMapper(this);
|
|
|
|
connect(windowMapper, SIGNAL(mapped(QObject*)), this, SLOT(onOpenWindow(QObject*)));
|
|
|
|
|
|
|
|
connect(loginScreen, &LoginScreen::windowStateChanged, this, &Nexus::onWindowStateChanged);
|
|
|
|
|
|
|
|
retranslateUi();
|
|
|
|
#endif
|
2015-06-04 20:19:18 +08:00
|
|
|
|
|
|
|
if (profile)
|
|
|
|
showMainGUI();
|
|
|
|
else
|
|
|
|
showLogin();
|
2015-06-04 07:30:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::showLogin()
|
|
|
|
{
|
2015-06-04 17:56:19 +08:00
|
|
|
#ifdef Q_OS_ANDROID
|
|
|
|
delete androidui;
|
|
|
|
androidgui = nullptr;
|
|
|
|
#else
|
|
|
|
delete widget;
|
|
|
|
widget = nullptr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
delete profile;
|
|
|
|
profile = nullptr;
|
|
|
|
|
2015-06-04 07:30:17 +08:00
|
|
|
loginScreen->reset();
|
2015-06-04 08:10:06 +08:00
|
|
|
#ifndef Q_OS_ANDROID
|
|
|
|
loginScreen->move(QApplication::desktop()->screen()->rect().center() - loginScreen->rect().center());
|
|
|
|
#endif
|
2015-06-04 07:30:17 +08:00
|
|
|
loginScreen->show();
|
2015-06-04 17:56:19 +08:00
|
|
|
((QApplication*)qApp)->setQuitOnLastWindowClosed(true);
|
2015-06-04 07:30:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::showMainGUI()
|
|
|
|
{
|
|
|
|
assert(profile);
|
|
|
|
|
|
|
|
((QApplication*)qApp)->setQuitOnLastWindowClosed(false);
|
|
|
|
loginScreen->close();
|
|
|
|
|
2015-02-19 04:22:03 +08:00
|
|
|
// Create GUI
|
|
|
|
#ifndef Q_OS_ANDROID
|
|
|
|
widget = Widget::getInstance();
|
|
|
|
#endif
|
|
|
|
|
2015-02-06 19:28:49 +08:00
|
|
|
// Start GUI
|
|
|
|
#ifdef Q_OS_ANDROID
|
|
|
|
androidgui = new AndroidGUI;
|
|
|
|
androidgui->show();
|
|
|
|
#else
|
2015-02-19 04:22:03 +08:00
|
|
|
widget->init();
|
2015-02-06 19:28:49 +08:00
|
|
|
#endif
|
2015-02-07 02:01:31 +08:00
|
|
|
GUI::getInstance();
|
2015-02-06 19:28:49 +08:00
|
|
|
|
2015-04-26 03:05:29 +08:00
|
|
|
// Zetok protection
|
|
|
|
// There are small instants on startup during which no
|
|
|
|
// profile is loaded but the GUI could still receive events,
|
|
|
|
// e.g. between two modal windows. Disable the GUI to prevent that.
|
|
|
|
GUI::setEnabled(false);
|
|
|
|
|
2015-02-06 19:28:49 +08:00
|
|
|
// Connections
|
2015-06-04 07:30:17 +08:00
|
|
|
Core* core = profile->getCore();
|
2015-02-07 19:46:55 +08:00
|
|
|
#ifdef Q_OS_ANDROID
|
|
|
|
connect(core, &Core::connected, androidgui, &AndroidGUI::onConnected);
|
|
|
|
connect(core, &Core::disconnected, androidgui, &AndroidGUI::onDisconnected);
|
2015-05-26 04:28:59 +08:00
|
|
|
//connect(core, &Core::failedToStart, androidgui, &AndroidGUI::onFailedToStartCore, Qt::BlockingQueuedConnection);
|
|
|
|
//connect(core, &Core::badProxy, androidgui, &AndroidGUI::onBadProxyCore, Qt::BlockingQueuedConnection);
|
2015-02-07 19:46:55 +08:00
|
|
|
connect(core, &Core::statusSet, androidgui, &AndroidGUI::onStatusSet);
|
|
|
|
connect(core, &Core::usernameSet, androidgui, &AndroidGUI::setUsername);
|
|
|
|
connect(core, &Core::statusMessageSet, androidgui, &AndroidGUI::setStatusMessage);
|
|
|
|
connect(core, &Core::selfAvatarChanged, androidgui, &AndroidGUI::onSelfAvatarLoaded);
|
|
|
|
|
|
|
|
connect(androidgui, &AndroidGUI::statusSet, core, &Core::setStatus);
|
|
|
|
//connect(androidgui, &AndroidGUI::friendRequested, core, &Core::requestFriendship);
|
|
|
|
//connect(androidgui, &AndroidGUI::friendRequestAccepted, core, &Core::acceptFriendRequest);
|
|
|
|
//connect(androidgui, &AndroidGUI::changeProfile, core, &Core::switchConfiguration);
|
|
|
|
#else
|
2015-03-13 14:00:12 +08:00
|
|
|
connect(core, &Core::connected, widget, &Widget::onConnected);
|
|
|
|
connect(core, &Core::disconnected, widget, &Widget::onDisconnected);
|
2015-05-26 04:28:59 +08:00
|
|
|
connect(core, &Core::failedToStart, widget, &Widget::onFailedToStartCore, Qt::BlockingQueuedConnection);
|
|
|
|
connect(core, &Core::badProxy, widget, &Widget::onBadProxyCore, Qt::BlockingQueuedConnection);
|
2015-03-13 14:00:12 +08:00
|
|
|
connect(core, &Core::statusSet, widget, &Widget::onStatusSet);
|
|
|
|
connect(core, &Core::usernameSet, widget, &Widget::setUsername);
|
|
|
|
connect(core, &Core::statusMessageSet, widget, &Widget::setStatusMessage);
|
|
|
|
connect(core, &Core::selfAvatarChanged, widget, &Widget::onSelfAvatarLoaded);
|
|
|
|
connect(core, &Core::friendAdded, widget, &Widget::addFriend);
|
2015-06-15 21:48:34 +08:00
|
|
|
connect(core, &Core::friendshipChanged, widget, &Widget::onFriendshipChanged);
|
2015-03-13 14:00:12 +08:00
|
|
|
connect(core, &Core::failedToAddFriend, widget, &Widget::addFriendFailed);
|
|
|
|
connect(core, &Core::friendUsernameChanged, widget, &Widget::onFriendUsernameChanged);
|
|
|
|
connect(core, &Core::friendStatusChanged, widget, &Widget::onFriendStatusChanged);
|
2015-02-06 19:28:49 +08:00
|
|
|
connect(core, &Core::friendStatusMessageChanged, widget, &Widget::onFriendStatusMessageChanged);
|
2015-03-13 14:00:12 +08:00
|
|
|
connect(core, &Core::friendRequestReceived, widget, &Widget::onFriendRequestReceived);
|
|
|
|
connect(core, &Core::friendMessageReceived, widget, &Widget::onFriendMessageReceived);
|
|
|
|
connect(core, &Core::receiptRecieved, widget, &Widget::onReceiptRecieved);
|
|
|
|
connect(core, &Core::groupInviteReceived, widget, &Widget::onGroupInviteReceived);
|
|
|
|
connect(core, &Core::groupMessageReceived, widget, &Widget::onGroupMessageReceived);
|
|
|
|
connect(core, &Core::groupNamelistChanged, widget, &Widget::onGroupNamelistChanged);
|
|
|
|
connect(core, &Core::groupTitleChanged, widget, &Widget::onGroupTitleChanged);
|
|
|
|
connect(core, &Core::groupPeerAudioPlaying, widget, &Widget::onGroupPeerAudioPlaying);
|
2015-02-06 19:28:49 +08:00
|
|
|
connect(core, &Core::emptyGroupCreated, widget, &Widget::onEmptyGroupCreated);
|
|
|
|
connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged);
|
|
|
|
|
2015-04-20 05:12:44 +08:00
|
|
|
connect(core, &Core::messageSentResult, widget, &Widget::onMessageSendResult);
|
|
|
|
connect(core, &Core::groupSentResult, widget, &Widget::onGroupSendResult);
|
2015-02-06 19:28:49 +08:00
|
|
|
|
|
|
|
connect(widget, &Widget::statusSet, core, &Core::setStatus);
|
|
|
|
connect(widget, &Widget::friendRequested, core, &Core::requestFriendship);
|
|
|
|
connect(widget, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest);
|
|
|
|
#endif
|
|
|
|
|
2015-06-04 07:30:17 +08:00
|
|
|
profile->startCore();
|
2015-02-06 19:28:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Nexus& Nexus::getInstance()
|
|
|
|
{
|
2015-02-07 02:38:08 +08:00
|
|
|
if (!nexus)
|
|
|
|
nexus = new Nexus;
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2015-02-07 02:38:08 +08:00
|
|
|
return *nexus;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::destroyInstance()
|
|
|
|
{
|
|
|
|
delete nexus;
|
|
|
|
nexus = nullptr;
|
2015-02-06 19:28:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Core* Nexus::getCore()
|
|
|
|
{
|
2015-06-04 07:30:17 +08:00
|
|
|
Nexus& nexus = getInstance();
|
|
|
|
if (!nexus.profile)
|
|
|
|
return nullptr;
|
|
|
|
return nexus.profile->getCore();
|
|
|
|
}
|
|
|
|
|
|
|
|
Profile* Nexus::getProfile()
|
|
|
|
{
|
|
|
|
return getInstance().profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::setProfile(Profile* profile)
|
|
|
|
{
|
|
|
|
getInstance().profile = profile;
|
2015-06-06 21:54:58 +08:00
|
|
|
if (profile)
|
|
|
|
Settings::getInstance().loadPersonnal(profile);
|
2015-02-06 19:28:49 +08:00
|
|
|
}
|
2015-02-07 02:01:31 +08:00
|
|
|
|
|
|
|
AndroidGUI* Nexus::getAndroidGUI()
|
|
|
|
{
|
|
|
|
return getInstance().androidgui;
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget* Nexus::getDesktopGUI()
|
|
|
|
{
|
|
|
|
return getInstance().widget;
|
|
|
|
}
|
2015-02-16 07:35:27 +08:00
|
|
|
|
|
|
|
QString Nexus::getSupportedImageFilter()
|
|
|
|
{
|
|
|
|
QString res;
|
|
|
|
for (auto type : QImageReader::supportedImageFormats())
|
|
|
|
res += QString("*.%1 ").arg(QString(type));
|
2015-04-24 19:01:50 +08:00
|
|
|
|
2015-02-16 07:35:27 +08:00
|
|
|
return tr("Images (%1)", "filetype filter").arg(res.left(res.size()-1));
|
|
|
|
}
|
2015-03-17 05:41:59 +08:00
|
|
|
|
2015-04-26 23:39:39 +08:00
|
|
|
bool Nexus::tryRemoveFile(const QString& filepath)
|
2015-03-17 05:41:59 +08:00
|
|
|
{
|
|
|
|
QFile tmp(filepath);
|
|
|
|
bool writable = tmp.open(QIODevice::WriteOnly);
|
|
|
|
tmp.remove();
|
|
|
|
return writable;
|
|
|
|
}
|
2015-07-30 07:46:19 +08:00
|
|
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
void Nexus::retranslateUi()
|
|
|
|
{
|
|
|
|
viewMenu->menuAction()->setText(tr("View", "OS X Menu bar"));
|
|
|
|
windowMenu->menuAction()->setText(tr("Window", "OS X Menu bar"));
|
|
|
|
minimizeAction->setText(tr("Minimize", "OS X Menu bar"));
|
|
|
|
frontAction->setText((tr("Bring All to Front", "OS X Menu bar")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::onWindowStateChanged(Qt::WindowStates state)
|
|
|
|
{
|
|
|
|
minimizeAction->setEnabled(QApplication::activeWindow() != nullptr);
|
|
|
|
|
|
|
|
if (QApplication::activeWindow() != nullptr && sender() == QApplication::activeWindow())
|
|
|
|
{
|
|
|
|
if (state & Qt::WindowFullScreen)
|
|
|
|
minimizeAction->setEnabled(false);
|
|
|
|
|
|
|
|
if (state & Qt::WindowFullScreen)
|
|
|
|
fullscreenAction->setText(tr("Exit Fullscreen"));
|
|
|
|
else
|
|
|
|
fullscreenAction->setText(tr("Enter Fullscreen"));
|
|
|
|
|
|
|
|
updateWindows();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateWindowsStates();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::updateWindows()
|
|
|
|
{
|
|
|
|
updateWindowsArg(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::updateWindowsArg(QWindow* closedWindow)
|
|
|
|
{
|
|
|
|
QWindowList windowList = QApplication::topLevelWindows();
|
|
|
|
delete windowActions;
|
|
|
|
windowActions = new QActionGroup(this);
|
|
|
|
|
|
|
|
windowMenu->addSeparator();
|
|
|
|
|
|
|
|
QAction* dockLast;
|
|
|
|
if (dockMenu->actions().count() != 0)
|
|
|
|
dockLast = dockMenu->actions().first();
|
|
|
|
else
|
|
|
|
dockLast = nullptr;
|
|
|
|
|
|
|
|
QWindow* activeWindow;
|
|
|
|
|
|
|
|
if (QApplication::activeWindow())
|
|
|
|
activeWindow = QApplication::activeWindow()->windowHandle();
|
|
|
|
else
|
|
|
|
activeWindow = nullptr;
|
|
|
|
|
|
|
|
for (int i = 0; i < windowList.size(); ++i)
|
|
|
|
{
|
|
|
|
if (closedWindow == windowList[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
QAction* action = windowActions->addAction(windowList[i]->title());
|
|
|
|
action->setCheckable(true);
|
|
|
|
action->setChecked(windowList[i] == activeWindow);
|
|
|
|
connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
|
|
|
|
windowMapper->setMapping(action, windowList[i]);
|
|
|
|
windowMenu->addAction(action);
|
|
|
|
dockMenu->insertAction(dockLast, action);
|
|
|
|
}
|
|
|
|
|
2015-10-23 21:21:47 +08:00
|
|
|
if (dockLast && !dockLast->isSeparator())
|
2015-07-30 07:46:19 +08:00
|
|
|
dockMenu->insertSeparator(dockLast);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::updateWindowsClosed()
|
|
|
|
{
|
|
|
|
updateWindowsArg(static_cast<QWidget*>(sender())->windowHandle());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::updateWindowsStates()
|
|
|
|
{
|
|
|
|
bool exists = false;
|
|
|
|
QWindowList windowList = QApplication::topLevelWindows();
|
|
|
|
|
|
|
|
for (QWindow* window : windowList)
|
|
|
|
{
|
|
|
|
if (!(window->windowState() & Qt::WindowMinimized))
|
|
|
|
{
|
|
|
|
exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
frontAction->setEnabled(exists);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::onOpenWindow(QObject* object)
|
|
|
|
{
|
|
|
|
QWindow* window = static_cast<QWindow*>(object);
|
|
|
|
|
|
|
|
if (window->windowState() & QWindow::Minimized)
|
|
|
|
window->showNormal();
|
|
|
|
|
|
|
|
window->raise();
|
|
|
|
window->requestActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::toggleFullscreen()
|
|
|
|
{
|
|
|
|
QWidget* window = QApplication::activeWindow();
|
|
|
|
|
|
|
|
if (window->isFullScreen())
|
|
|
|
window->showNormal();
|
|
|
|
else
|
|
|
|
window->showFullScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Nexus::bringAllToFront()
|
|
|
|
{
|
|
|
|
QWindowList windowList = QApplication::topLevelWindows();
|
|
|
|
QWindow* focused = QApplication::focusWindow();
|
|
|
|
|
|
|
|
for (QWindow* window : windowList)
|
|
|
|
window->raise();
|
|
|
|
|
|
|
|
focused->raise();
|
|
|
|
}
|
|
|
|
#endif
|