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

remove unused code, removed unused checks

This commit is contained in:
agilob 2015-10-14 18:53:46 +01:00 committed by Zetok Zalbavar
parent 884547cd34
commit d875221e53
No known key found for this signature in database
GPG Key ID: C953D3880212068A
10 changed files with 17 additions and 115 deletions

View File

@ -358,13 +358,13 @@ contains(ENABLE_SYSTRAY_GTK_BACKEND, NO) {
src/widget/form/loadhistorydialog.h \ src/widget/form/loadhistorydialog.h \
src/widget/form/setpassworddialog.h \ src/widget/form/setpassworddialog.h \
src/widget/form/tabcompleter.h \ src/widget/form/tabcompleter.h \
src/ipc.h \
src/net/autoupdate.h \ src/net/autoupdate.h \
src/widget/tool/callconfirmwidget.h \ src/widget/tool/callconfirmwidget.h \
src/widget/systemtrayicon.h \ src/widget/systemtrayicon.h \
src/widget/qrwidget.h \ src/widget/qrwidget.h \
src/widget/systemtrayicon_private.h \ src/widget/systemtrayicon_private.h \
src/widget/loginscreen.h src/widget/loginscreen.h \
src/ipc.h
SOURCES += \ SOURCES += \
src/widget/form/addfriendform.cpp \ src/widget/form/addfriendform.cpp \
@ -383,7 +383,6 @@ contains(ENABLE_SYSTRAY_GTK_BACKEND, NO) {
src/widget/form/loadhistorydialog.cpp \ src/widget/form/loadhistorydialog.cpp \
src/widget/form/setpassworddialog.cpp \ src/widget/form/setpassworddialog.cpp \
src/widget/form/tabcompleter.cpp \ src/widget/form/tabcompleter.cpp \
src/ipc.cpp \
src/widget/flowlayout.cpp \ src/widget/flowlayout.cpp \
src/net/autoupdate.cpp \ src/net/autoupdate.cpp \
src/widget/tool/callconfirmwidget.cpp \ src/widget/tool/callconfirmwidget.cpp \
@ -426,7 +425,8 @@ contains(ENABLE_SYSTRAY_GTK_BACKEND, NO) {
src/persistence/offlinemsgengine.cpp \ src/persistence/offlinemsgengine.cpp \
src/widget/qrwidget.cpp \ src/widget/qrwidget.cpp \
src/widget/genericchatroomwidget.cpp \ src/widget/genericchatroomwidget.cpp \
src/widget/loginscreen.cpp src/widget/loginscreen.cpp \
src/ipc.cpp
} }
win32 { win32 {

View File

@ -295,12 +295,12 @@ void Audio::playGroupAudio(int group, int peer, const int16_t* data,
alSourcef(call.alSources[peer], AL_GAIN, outputVolume); alSourcef(call.alSources[peer], AL_GAIN, outputVolume);
} }
size_t volume = 0;//data[1]; qreal volume = 0.;
int bufsize = samples * 2 * channels; int bufsize = samples * 2 * channels;
for (int i = 0; i < bufsize; ++i) for (int i = 0; i < bufsize; ++i)
volume += abs(data[i]);//std::max(volume, data[i]); volume += abs(data[i]);//std::max(volume, data[i]);
emit groupAudioPlayed(group, peer, volume / static_cast<float>(bufsize)); emit groupAudioPlayed(group, peer, volume / bufsize);
playAudioBuffer(call.alSources[peer], data, samples, channels, sample_rate); playAudioBuffer(call.alSources[peer], data, samples, channels, sample_rate);
} }

View File

@ -46,29 +46,6 @@ Group::~Group()
widget->deleteLater(); widget->deleteLater();
} }
/*
void Group::addPeer(int peerId, QString name)
{
if (peers.contains(peerId))
qWarning() << "addPeer: peerId already used, overwriting anyway";
if (name.isEmpty())
peers[peerId] = "<Unknown>";
else
peers[peerId] = name;
nPeers++;
widget->onUserListChanged();
chatForm->onUserListChanged();
}
void Group::removePeer(int peerId)
{
peers.remove(peerId);
nPeers--;
widget->onUserListChanged();
chatForm->onUserListChanged();
}
*/
void Group::updatePeer(int peerId, QString name) void Group::updatePeer(int peerId, QString name)
{ {
ToxId id = Core::getInstance()->getGroupPeerToxId(groupId, peerId); ToxId id = Core::getInstance()->getGroupPeerToxId(groupId, peerId);
@ -77,19 +54,13 @@ void Group::updatePeer(int peerId, QString name)
toxids[toxid] = name; toxids[toxid] = name;
Friend *f = FriendList::findFriend(id); Friend *f = FriendList::findFriend(id);
if (f && f->hasAlias())
// I don't know what this is doing here but it changes back to the old name. if (f != nullptr && f->hasAlias())
/*Friend *f = FriendList::findFriend(id);
if (f)
{ {
peers[peerId] = f->getDisplayedName(); widget->onUserListChanged();
toxids[toxid] = f->getDisplayedName(); chatForm->onUserListChanged();
}*/ emit userListChanged(getGroupWidget());
}
widget->onUserListChanged();
chatForm->onUserListChanged();
emit userListChanged(getGroupWidget());
} }
void Group::setName(const QString& name) void Group::setName(const QString& name)

View File

@ -54,11 +54,6 @@ public:
void setMentionedFlag(int f); void setMentionedFlag(int f);
int getMentionedFlag() const; int getMentionedFlag() const;
/*
void addPeer(int peerId, QString name);
void removePeer(int peerId);
*/
void updatePeer(int peerId, QString newName); void updatePeer(int peerId, QString newName);
void setName(const QString& name); void setName(const QString& name);
QString getName() const; QString getName() const;

View File

@ -40,8 +40,6 @@ CameraSource::CameraSource()
biglock{false}, freelistLock{false}, biglock{false}, freelistLock{false},
isOpen{false}, subscriptions{0} isOpen{false}, subscriptions{0}
{ {
//qDebug() << "CameraSource()";
subscriptions = 0; subscriptions = 0;
av_register_all(); av_register_all();
avdevice_register_all(); avdevice_register_all();
@ -75,8 +73,6 @@ void CameraSource::open(const QString deviceName)
void CameraSource::open(const QString DeviceName, VideoMode Mode) void CameraSource::open(const QString DeviceName, VideoMode Mode)
{ {
//qDebug() << "open(const QString DeviceName, VideoMode Mode)";
{ {
bool expected = false; bool expected = false;
while (!biglock.compare_exchange_weak(expected, true)) while (!biglock.compare_exchange_weak(expected, true))
@ -137,7 +133,7 @@ CameraSource::~CameraSource()
if (cctxOrig) if (cctxOrig)
avcodec_close(cctxOrig); avcodec_close(cctxOrig);
for (int i = subscriptions; i; --i) for(int i = 0; i < subscriptions; i++)
device->close(); device->close();
device = nullptr; device = nullptr;
@ -152,8 +148,6 @@ CameraSource::~CameraSource()
bool CameraSource::subscribe() bool CameraSource::subscribe()
{ {
//qDebug() << "subscribe";
// Fast lock // Fast lock
{ {
bool expected = false; bool expected = false;
@ -164,8 +158,6 @@ bool CameraSource::subscribe()
if (!isOpen) if (!isOpen)
{ {
++subscriptions; ++subscriptions;
//qDebug() << "is not open, subscriptions: " << subscriptions;
biglock = false; biglock = false;
return true; return true;
} }
@ -173,8 +165,6 @@ bool CameraSource::subscribe()
if (openDevice()) if (openDevice())
{ {
++subscriptions; ++subscriptions;
//qDebug() << "open device, subscriptions: " << subscriptions;
biglock = false; biglock = false;
return true; return true;
} }
@ -189,13 +179,11 @@ bool CameraSource::subscribe()
biglock = false; biglock = false;
return false; return false;
} }
//qDebug() << "END subscribe";
} }
void CameraSource::unsubscribe() void CameraSource::unsubscribe()
{ {
//qDebug() << "unsubscribe";
// Fast lock // Fast lock
{ {
bool expected = false; bool expected = false;
@ -205,7 +193,6 @@ void CameraSource::unsubscribe()
if (!isOpen) if (!isOpen)
{ {
//qDebug() << "is not open";
subscriptions--; subscriptions--;
biglock = false; biglock = false;
return; return;
@ -213,18 +200,14 @@ void CameraSource::unsubscribe()
if (!device) if (!device)
{ {
//qWarning() << "Unsubscribing with zero subscriber"; qWarning() << "Unsubscribing with zero subscriber";
biglock = false; biglock = false;
return; return;
} }
//qDebug() << "1. device: " << device;
//qDebug() << "2. subscriptions:" << subscriptions;
if (subscriptions - 1 == 0) if (subscriptions - 1 == 0)
{ {
//qDebug() << "first block";
closeDevice(); closeDevice();
biglock = false; biglock = false;
// Synchronize with our stream thread // Synchronize with our stream thread
@ -233,19 +216,15 @@ void CameraSource::unsubscribe()
} }
else else
{ {
//qDebug() << "second block";
device->close(); device->close();
biglock = false; biglock = false;
} }
subscriptions--; subscriptions--;
//qDebug() << "3. subscriptions: " << subscriptions;
} }
bool CameraSource::openDevice() bool CameraSource::openDevice()
{ {
//qDebug() << "Opening device: " << deviceName;
if (device) if (device)
{ {
device->open(); device->open();
@ -317,8 +296,6 @@ bool CameraSource::openDevice()
void CameraSource::closeDevice() void CameraSource::closeDevice()
{ {
//qDebug() << "Closing device " << deviceName;
// Free all remaining VideoFrame // Free all remaining VideoFrame
// Locking must be done precisely this way to avoid races // Locking must be done precisely this way to avoid races
for (int i = 0; i < freelist.size(); i++) for (int i = 0; i < freelist.size(); i++)

View File

@ -38,18 +38,16 @@ public:
LabeledVideo(const QPixmap& avatar, QWidget* parent = 0, bool expanding = true) LabeledVideo(const QPixmap& avatar, QWidget* parent = 0, bool expanding = true)
: QFrame(parent) : QFrame(parent)
{ {
//setFrameStyle(QFrame::Box);
qDebug() << "Created expanding? " << expanding; qDebug() << "Created expanding? " << expanding;
videoSurface = new VideoSurface(avatar, 0, expanding); videoSurface = new VideoSurface(avatar, 0, expanding);
videoSurface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); videoSurface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
videoSurface->setMinimumHeight(32); videoSurface->setMinimumHeight(32);
//videoSurface->setMaximumHeight(96);
connect(videoSurface, &VideoSurface::ratioChanged, this, &LabeledVideo::updateSize); connect(videoSurface, &VideoSurface::ratioChanged, this, &LabeledVideo::updateSize);
label = new CroppingLabel(this); label = new CroppingLabel(this);
label->setTextFormat(Qt::PlainText); label->setTextFormat(Qt::PlainText);
label->setStyleSheet("color: white"); label->setStyleSheet("color: white");
//label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
//qDebug() << label->sizePolicy();
label->setAlignment(Qt::AlignCenter); label->setAlignment(Qt::AlignCenter);
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
@ -102,7 +100,6 @@ private slots:
int width = videoSurface->height() * videoSurface->getRatio(); int width = videoSurface->height() * videoSurface->getRatio();
videoSurface->setMinimumWidth(width); videoSurface->setMinimumWidth(width);
videoSurface->setMaximumWidth(width); videoSurface->setMaximumWidth(width);
//setMaximumWidth(width + layout()->margin() * 2);
qDebug() << videoSurface->minimumWidth(); qDebug() << videoSurface->minimumWidth();
} }
} }
@ -119,15 +116,12 @@ GroupNetCamView::GroupNetCamView(int group, QWidget *parent)
{ {
videoLabelSurface = new LabeledVideo(QPixmap(), this, false); videoLabelSurface = new LabeledVideo(QPixmap(), this, false);
videoSurface = videoLabelSurface->getVideoSurface(); videoSurface = videoLabelSurface->getVideoSurface();
//videoSurface->setExpanding(false);
videoSurface->setMinimumHeight(256); videoSurface->setMinimumHeight(256);
videoSurface->setContentsMargins(6, 6, 6, 0); videoSurface->setContentsMargins(6, 6, 6, 0);
videoLabelSurface->setContentsMargins(0, 0, 0, 0); videoLabelSurface->setContentsMargins(0, 0, 0, 0);
videoLabelSurface->layout()->setMargin(0); videoLabelSurface->layout()->setMargin(0);
videoLabelSurface->setStyleSheet("QFrame { background-color: black; }"); videoLabelSurface->setStyleSheet("QFrame { background-color: black; }");
//verLayout->insertWidget(0, videoLabelSurface, 1);
QSplitter* splitter = new QSplitter(Qt::Vertical, this); QSplitter* splitter = new QSplitter(Qt::Vertical, this);
splitter->setChildrenCollapsible(false); splitter->setChildrenCollapsible(false);
verLayout->insertWidget(0, splitter, 1); verLayout->insertWidget(0, splitter, 1);
@ -145,13 +139,10 @@ GroupNetCamView::GroupNetCamView(int group, QWidget *parent)
selfVideoSurface = new LabeledVideo(Settings::getInstance().getSavedAvatar(Core::getInstance()->getSelfId().toString()), this); selfVideoSurface = new LabeledVideo(Settings::getInstance().getSavedAvatar(Core::getInstance()->getSelfId().toString()), this);
horLayout->addWidget(selfVideoSurface); horLayout->addWidget(selfVideoSurface);
//horLayout->setAlignment(selfVideoSurface, Qt::AlignCenter | Qt::AlignHCenter);
horLayout->addStretch(1); horLayout->addStretch(1);
splitter->addWidget(scrollArea); splitter->addWidget(scrollArea);
scrollArea->setWidget(widget); scrollArea->setWidget(widget);
//verLayout->insertWidget(1, scrollArea);
//scrollArea->setMinimumHeight(selfVideoSurface->height());
connect(&Audio::getInstance(), &Audio::groupAudioPlayed, this, &GroupNetCamView::groupAudioPlayed); connect(&Audio::getInstance(), &Audio::groupAudioPlayed, this, &GroupNetCamView::groupAudioPlayed);

View File

@ -28,7 +28,6 @@
#include <QPainter> #include <QPainter>
#include <QLabel> #include <QLabel>
#include <cassert>
#include <QDebug> #include <QDebug>
float getSizeRatio(const QSize size) float getSizeRatio(const QSize size)
@ -99,8 +98,6 @@ QPixmap VideoSurface::getAvatar() const
void VideoSurface::subscribe() void VideoSurface::subscribe()
{ {
assert(hasSubscribed >= 0);
if (source && hasSubscribed++ == 0) if (source && hasSubscribed++ == 0)
{ {
source->subscribe(); source->subscribe();
@ -110,8 +107,6 @@ void VideoSurface::subscribe()
void VideoSurface::unsubscribe() void VideoSurface::unsubscribe()
{ {
assert(hasSubscribed >= 0);
if (!source || hasSubscribed == 0) if (!source || hasSubscribed == 0)
return; return;
@ -185,8 +180,9 @@ void VideoSurface::resizeEvent(QResizeEvent* event)
emit boundaryChanged(); emit boundaryChanged();
} }
void VideoSurface::showEvent(QShowEvent*) void VideoSurface::showEvent(QShowEvent* e)
{ {
Q_UNUSED(e);
//emit ratioChanged(); //emit ratioChanged();
} }

View File

@ -119,8 +119,6 @@ ChatForm::ChatForm(Friend* chatFriend)
retranslateUi(); retranslateUi();
Translator::registerHandler(std::bind(&ChatForm::retranslateUi, this), this); Translator::registerHandler(std::bind(&ChatForm::retranslateUi, this), this);
//showNetcam();
} }
ChatForm::~ChatForm() ChatForm::~ChatForm()

View File

@ -209,29 +209,6 @@ void AVForm::onVideoDevChanged(int index)
createVideoSurface(); createVideoSurface();
} }
/*void AVForm::onResProbingFinished(QList<QSize> res)
{
QSize savedRes = Settings::getInstance().getCamVideoRes();
int savedResIndex = -1;
bodyUI->videoModescomboBox->clear();
bodyUI->videoModescomboBox->blockSignals(true);
for (int i=0; i<res.size(); ++i)
{
QSize& r = res[i];
bodyUI->videoModescomboBox->addItem(QString("%1x%2").arg(QString::number(r.width()),QString::number(r.height())), r);
if (r == savedRes)
savedResIndex = i;
}
//reset index, otherwise cameras with only one resolution won't get initialized
bodyUI->videoModescomboBox->setCurrentIndex(-1);
bodyUI->videoModescomboBox->blockSignals(false);
if (savedResIndex != -1)
bodyUI->videoModescomboBox->setCurrentIndex(savedResIndex);
else
bodyUI->videoModescomboBox->setCurrentIndex(bodyUI->videoModescomboBox->count()-1);
}*/
void AVForm::hideEvent(QHideEvent *) void AVForm::hideEvent(QHideEvent *)
{ {
if (camVideoSurface) if (camVideoSurface)
@ -256,8 +233,6 @@ void AVForm::getVideoDevices()
if (device.first == settingsInDev) if (device.first == settingsInDev)
videoDevIndex = bodyUI->videoDevCombobox->count()-1; videoDevIndex = bodyUI->videoDevCombobox->count()-1;
} }
//addItem changes currentIndex -> reset
//bodyUI->videoDevCombobox->setCurrentIndex(-1);
bodyUI->videoDevCombobox->setCurrentIndex(videoDevIndex); bodyUI->videoDevCombobox->setCurrentIndex(videoDevIndex);
bodyUI->videoDevCombobox->blockSignals(false); bodyUI->videoDevCombobox->blockSignals(false);
updateVideoModes(videoDevIndex); updateVideoModes(videoDevIndex);

View File

@ -63,7 +63,6 @@ private slots:
// camera // camera
void onVideoDevChanged(int index); void onVideoDevChanged(int index);
void onVideoModesIndexChanged(int index); void onVideoModesIndexChanged(int index);
//void onResProbingFinished(QList<QSize> res);
virtual void hideEvent(QHideEvent*) final override; virtual void hideEvent(QHideEvent*) final override;
virtual void showEvent(QShowEvent*) final override; virtual void showEvent(QShowEvent*) final override;