mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(widget): remove Widget::getInstance
This commit is contained in:
parent
7fca93bde9
commit
105f9ec401
|
@ -34,8 +34,8 @@
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <vpx/vpx_image.h>
|
|
||||||
#include <src/audio/audio.h>
|
#include <src/audio/audio.h>
|
||||||
|
#include <vpx/vpx_image.h>
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
|
@ -169,7 +169,7 @@ int Nexus::showLogin(const QString& profileName)
|
||||||
return returnval;
|
return returnval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nexus::bootstrapWithProfile(Profile *p)
|
void Nexus::bootstrapWithProfile(Profile* p)
|
||||||
{
|
{
|
||||||
// kriby: This is a hack until a proper controller is written
|
// kriby: This is a hack until a proper controller is written
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ void Nexus::showMainGUI()
|
||||||
assert(profile);
|
assert(profile);
|
||||||
|
|
||||||
// Create GUI
|
// Create GUI
|
||||||
widget = Widget::getInstance(audioControl.get());
|
widget = new Widget(*audioControl);
|
||||||
|
|
||||||
// Start GUI
|
// Start GUI
|
||||||
widget->init();
|
widget->init();
|
||||||
|
@ -309,7 +309,8 @@ void Nexus::onLoadProfile(const QString& name, const QString& pass)
|
||||||
* Changes the loaded profile and notifies listeners.
|
* Changes the loaded profile and notifies listeners.
|
||||||
* @param p
|
* @param p
|
||||||
*/
|
*/
|
||||||
void Nexus::setProfile(Profile* p) {
|
void Nexus::setProfile(Profile* p)
|
||||||
|
{
|
||||||
if (!p) {
|
if (!p) {
|
||||||
emit profileLoadFailed();
|
emit profileLoadFailed();
|
||||||
// Warnings are issued during respective createNew/load calls
|
// Warnings are issued during respective createNew/load calls
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "src/widget/style.h"
|
#include "src/widget/style.h"
|
||||||
#include "src/widget/widget.h"
|
#include "src/widget/widget.h"
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QFontMetrics>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
|
@ -30,7 +31,6 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QFontMetrics>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,12 +76,12 @@ CallConfirmWidget::CallConfirmWidget(const QWidget* anchor)
|
||||||
// Note: At the moment this may not work properly. For languages written
|
// Note: At the moment this may not work properly. For languages written
|
||||||
// from right to left, there is no translation for the phrase "Incoming call...".
|
// from right to left, there is no translation for the phrase "Incoming call...".
|
||||||
// In this situation, the phrase "Incoming call..." looks as "...oming call..."
|
// In this situation, the phrase "Incoming call..." looks as "...oming call..."
|
||||||
Qt::TextElideMode elideMode = (QGuiApplication::layoutDirection() == Qt::LeftToRight)
|
Qt::TextElideMode elideMode =
|
||||||
? Qt::ElideRight : Qt::ElideLeft;
|
(QGuiApplication::layoutDirection() == Qt::LeftToRight) ? Qt::ElideRight : Qt::ElideLeft;
|
||||||
int marginSize = 12;
|
int marginSize = 12;
|
||||||
QFontMetrics fontMetrics(callLabel->font());
|
QFontMetrics fontMetrics(callLabel->font());
|
||||||
QString elidedText = fontMetrics.elidedText(callLabel->text(), elideMode,
|
QString elidedText =
|
||||||
rectW - marginSize * 2 - 4);
|
fontMetrics.elidedText(callLabel->text(), elideMode, rectW - marginSize * 2 - 4);
|
||||||
callLabel->setText(elidedText);
|
callLabel->setText(elidedText);
|
||||||
|
|
||||||
QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
|
||||||
|
@ -154,14 +154,11 @@ void CallConfirmWidget::paintEvent(QPaintEvent*)
|
||||||
|
|
||||||
void CallConfirmWidget::showEvent(QShowEvent*)
|
void CallConfirmWidget::showEvent(QShowEvent*)
|
||||||
{
|
{
|
||||||
|
// Kriby: Legacy comment, is this still true?
|
||||||
// If someone does show() from Widget or lower, the event will reach us
|
// If someone does show() from Widget or lower, the event will reach us
|
||||||
// because it's our parent, and we could show up in the wrong form.
|
// because it's our parent, and we could show up in the wrong form.
|
||||||
// So check here if our friend's form is actually the active one.
|
// So check here if our friend's form is actually the active one.
|
||||||
// if (!Widget::getInstance()->isFriendWidgetCurActiveWidget(&f))
|
|
||||||
{
|
|
||||||
// QWidget::hide();
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
reposition();
|
reposition();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -601,23 +601,6 @@ Widget::~Widget()
|
||||||
instance = nullptr;
|
instance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param audio Only used for initialization from Nexus, to pass IAudioControl
|
|
||||||
* @brief Returns the singleton instance.
|
|
||||||
*/
|
|
||||||
Widget* Widget::getInstance(IAudioControl* audio)
|
|
||||||
{
|
|
||||||
if (!instance) {
|
|
||||||
// Passing audio via pointer here is a hack
|
|
||||||
// to allow for default paramters.
|
|
||||||
// once Widget::getInstance is removed it won't be neccessary
|
|
||||||
assert(audio != nullptr);
|
|
||||||
instance = new Widget(*audio);
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Switches to the About settings page.
|
* @brief Switches to the About settings page.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user