Browse Source

refactor(GUI): Remove GUI setEnabled, call on Widget directly

Nexus is the only caller and has access to Widget. Because only Nexus
calls it, and Nexus runs on GUI thread, remove check and queued
connection.
reviewable/pr6566/r16
Anthony Bilinski 4 years ago
parent
commit
3444fed0ac
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 4
      src/nexus.cpp
  2. 22
      src/widget/gui.cpp
  3. 2
      src/widget/gui.h

4
src/nexus.cpp

@ -245,7 +245,7 @@ void Nexus::showMainGUI() @@ -245,7 +245,7 @@ void Nexus::showMainGUI()
// 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);
widget->setEnabled(false);
// Connections
connect(profile, &Profile::selfAvatarChanged, widget, &Widget::onSelfAvatarLoaded);
@ -259,7 +259,7 @@ void Nexus::showMainGUI() @@ -259,7 +259,7 @@ void Nexus::showMainGUI()
profile->startCore();
GUI::setEnabled(true);
widget->setEnabled(true);
}
/**

22
src/widget/gui.cpp

@ -61,21 +61,6 @@ GUI& GUI::getInstance() @@ -61,21 +61,6 @@ GUI& GUI::getInstance()
// Implementation of the public clean interface
/**
* @brief Will enable or disable the GUI.
* @note A disabled GUI can't be interacted with by the user.
* @param state Enable/disable GUI.
*/
void GUI::setEnabled(bool state)
{
if (QThread::currentThread() == qApp->thread()) {
getInstance()._setEnabled(state);
} else {
QMetaObject::invokeMethod(&getInstance(), "_setEnabled", Qt::BlockingQueuedConnection,
Q_ARG(bool, state));
}
}
/**
* @brief Change the title of the main window.
* @param title Titile to set.
@ -209,13 +194,6 @@ bool GUI::askQuestion(const QString& title, const QString& msg, const QString& b @@ -209,13 +194,6 @@ bool GUI::askQuestion(const QString& title, const QString& msg, const QString& b
// Private implementations
void GUI::_setEnabled(bool state)
{
Widget* w = Nexus::getDesktopGUI();
if (w)
w->setEnabled(state);
}
void GUI::_setWindowTitle(const QString& title)
{
QWidget* w = getMainWidget();

2
src/widget/gui.h

@ -30,7 +30,6 @@ class GUI : public QObject @@ -30,7 +30,6 @@ class GUI : public QObject
public:
static GUI& getInstance();
static QWidget* getMainWidget();
static void setEnabled(bool state);
static void setWindowTitle(const QString& title);
static void reloadTheme();
static void showInfo(const QString& title, const QString& msg);
@ -48,7 +47,6 @@ private: @@ -48,7 +47,6 @@ private:
private slots:
// Private implementation, those must be called from the GUI thread
void _setEnabled(bool state);
void _setWindowTitle(const QString& title);
void _showInfo(const QString& title, const QString& msg);
void _showWarning(const QString& title, const QString& msg);

Loading…
Cancel
Save