1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

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.
This commit is contained in:
Anthony Bilinski 2022-03-13 03:56:17 -07:00
parent e4552cf905
commit 3444fed0ac
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
3 changed files with 2 additions and 26 deletions

View File

@ -245,7 +245,7 @@ void Nexus::showMainGUI()
// There are small instants on startup during which no // There are small instants on startup during which no
// profile is loaded but the GUI could still receive events, // profile is loaded but the GUI could still receive events,
// e.g. between two modal windows. Disable the GUI to prevent that. // e.g. between two modal windows. Disable the GUI to prevent that.
GUI::setEnabled(false); widget->setEnabled(false);
// Connections // Connections
connect(profile, &Profile::selfAvatarChanged, widget, &Widget::onSelfAvatarLoaded); connect(profile, &Profile::selfAvatarChanged, widget, &Widget::onSelfAvatarLoaded);
@ -259,7 +259,7 @@ void Nexus::showMainGUI()
profile->startCore(); profile->startCore();
GUI::setEnabled(true); widget->setEnabled(true);
} }
/** /**

View File

@ -61,21 +61,6 @@ GUI& GUI::getInstance()
// Implementation of the public clean interface // 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. * @brief Change the title of the main window.
* @param title Titile to set. * @param title Titile to set.
@ -209,13 +194,6 @@ bool GUI::askQuestion(const QString& title, const QString& msg, const QString& b
// Private implementations // Private implementations
void GUI::_setEnabled(bool state)
{
Widget* w = Nexus::getDesktopGUI();
if (w)
w->setEnabled(state);
}
void GUI::_setWindowTitle(const QString& title) void GUI::_setWindowTitle(const QString& title)
{ {
QWidget* w = getMainWidget(); QWidget* w = getMainWidget();

View File

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