mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
86e44143ad
commit
f8a45b4051
|
@ -18,9 +18,10 @@
|
|||
*/
|
||||
|
||||
#include "genericnetcamview.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QFrame>
|
||||
#include <QPushButton>
|
||||
|
||||
GenericNetCamView::GenericNetCamView(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
@ -35,6 +36,7 @@ GenericNetCamView::GenericNetCamView(QWidget *parent)
|
|||
buttonLayout->addStretch();
|
||||
button = new QPushButton();
|
||||
buttonLayout->addWidget(button);
|
||||
buttonLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||
connect(button, &QPushButton::clicked, this, &GenericNetCamView::showMessageClicked);
|
||||
|
||||
verLayout->addSpacing(spacing);
|
||||
|
@ -52,18 +54,26 @@ GenericNetCamView::GenericNetCamView(QWidget *parent)
|
|||
setStyleSheet("NetCamView { background-color: #c1c1c1; }");
|
||||
}
|
||||
|
||||
QSize GenericNetCamView::getSurfaceMinSize()
|
||||
{
|
||||
QSize surfaceSize = videoSurface->minimumSize();
|
||||
QSize buttonSize = button->size();
|
||||
QSize panelSize(0, 45);
|
||||
|
||||
return surfaceSize + buttonSize + panelSize;
|
||||
}
|
||||
|
||||
void GenericNetCamView::setShowMessages(bool show, bool notify)
|
||||
{
|
||||
if (show)
|
||||
if (!show)
|
||||
{
|
||||
button->setText(tr("Hide Messages"));
|
||||
button->setIcon(QIcon());
|
||||
return;
|
||||
}
|
||||
|
||||
button->setText(tr("Show Messages"));
|
||||
|
||||
if (notify)
|
||||
button->setIcon(QIcon(":/ui/chatArea/info.svg"));
|
||||
}
|
||||
else
|
||||
{
|
||||
button->setText(tr("Hide Messages"));
|
||||
button->setIcon(QIcon());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,17 +20,18 @@
|
|||
#ifndef GENERICNETCAMVIEW_H
|
||||
#define GENERICNETCAMVIEW_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
class VideoSurface;
|
||||
class QPushButton;
|
||||
class QVBoxLayout;
|
||||
#include "src/video/videosurface.h"
|
||||
|
||||
class GenericNetCamView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GenericNetCamView(QWidget* parent);
|
||||
QSize getSurfaceMinSize();
|
||||
|
||||
signals:
|
||||
void showMessageClicked();
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
*/
|
||||
|
||||
#include "contentdialog.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QGuiApplication>
|
||||
#include <QMimeData>
|
||||
#include <QShortcut>
|
||||
#include <QSplitter>
|
||||
|
||||
#include "contentlayout.h"
|
||||
#include "friendwidget.h"
|
||||
#include "groupwidget.h"
|
||||
|
@ -34,12 +42,6 @@
|
|||
#include "src/widget/friendlistlayout.h"
|
||||
#include "src/widget/form/settingswidget.h"
|
||||
#include "src/widget/translator.h"
|
||||
#include <QBoxLayout>
|
||||
#include <QSplitter>
|
||||
#include <QGuiApplication>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QMimeData>
|
||||
#include <QShortcut>
|
||||
|
||||
ContentDialog* ContentDialog::currentDialog = nullptr;
|
||||
QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> ContentDialog::friendList;
|
||||
|
@ -49,6 +51,8 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
|
|||
: ActivateDialog(parent, Qt::Window)
|
||||
, activeChatroomWidget(nullptr)
|
||||
, settingsWidget(settingsWidget)
|
||||
, videoSurfaceSize(QSize())
|
||||
, videoCount(0)
|
||||
{
|
||||
QVBoxLayout* boxLayout = new QVBoxLayout(this);
|
||||
boxLayout->setMargin(0);
|
||||
|
@ -360,6 +364,28 @@ void ContentDialog::cycleContacts(bool forward, bool loop)
|
|||
}
|
||||
}
|
||||
|
||||
void ContentDialog::onVideoShow(QSize size)
|
||||
{
|
||||
videoCount++;
|
||||
if (videoCount > 1)
|
||||
return;
|
||||
|
||||
videoSurfaceSize = size;
|
||||
QSize minSize = minimumSize();
|
||||
setMinimumSize(minSize + videoSurfaceSize);
|
||||
}
|
||||
|
||||
void ContentDialog::onVideoHide()
|
||||
{
|
||||
videoCount--;
|
||||
if (videoCount > 0)
|
||||
return;
|
||||
|
||||
QSize minSize = minimumSize();
|
||||
setMinimumSize(minSize - videoSurfaceSize);
|
||||
videoSurfaceSize = QSize();
|
||||
}
|
||||
|
||||
ContentDialog* ContentDialog::current()
|
||||
{
|
||||
return currentDialog;
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
#ifndef CONTENTDIALOG_H
|
||||
#define CONTENTDIALOG_H
|
||||
|
||||
#include "src/widget/tool/activatedialog.h"
|
||||
#include <tuple>
|
||||
|
||||
#include "src/core/corestructs.h"
|
||||
#include "src/widget/genericchatitemlayout.h"
|
||||
#include "src/widget/tool/activatedialog.h"
|
||||
|
||||
template <typename K, typename V> class QHash;
|
||||
template <typename T> class QSet;
|
||||
|
@ -54,6 +55,8 @@ public:
|
|||
void ensureSplitterVisible();
|
||||
|
||||
void cycleContacts(bool forward, bool loop = true);
|
||||
void onVideoShow(QSize size);
|
||||
void onVideoHide();
|
||||
|
||||
static ContentDialog* current();
|
||||
static bool existsFriendWidget(int friendId, bool focus);
|
||||
|
@ -111,6 +114,9 @@ private:
|
|||
GenericChatroomWidget* activeChatroomWidget;
|
||||
GenericChatroomWidget* displayWidget = nullptr;
|
||||
SettingsWidget* settingsWidget;
|
||||
QSize videoSurfaceSize;
|
||||
int videoCount;
|
||||
|
||||
static ContentDialog* currentDialog;
|
||||
static QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> friendList;
|
||||
static QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> groupList;
|
||||
|
|
|
@ -100,7 +100,7 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
headTextLayout->addWidget(callDuration, 1, Qt::AlignCenter);
|
||||
callDuration->hide();
|
||||
|
||||
chatWidget->setMinimumHeight(160);
|
||||
chatWidget->setMinimumHeight(50);
|
||||
connect(this, &GenericChatForm::messageInserted, this, &ChatForm::onMessageInserted);
|
||||
|
||||
loadHistoryAction = menu.addAction(QString(), this, SLOT(onLoadHistory()));
|
||||
|
|
|
@ -19,33 +19,34 @@
|
|||
|
||||
#include "genericchatform.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QShortcut>
|
||||
#include <QKeyEvent>
|
||||
#include <QPushButton>
|
||||
#include <QShortcut>
|
||||
#include <QSplitter>
|
||||
|
||||
#include "src/persistence/smileypack.h"
|
||||
#include "src/widget/emoticonswidget.h"
|
||||
#include "src/widget/style.h"
|
||||
#include "src/widget/widget.h"
|
||||
#include "src/persistence/settings.h"
|
||||
#include "src/widget/tool/chattextedit.h"
|
||||
#include "src/widget/maskablepixmapwidget.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/grouplist.h"
|
||||
#include "src/group.h"
|
||||
#include "src/friendlist.h"
|
||||
#include "src/friend.h"
|
||||
#include "src/chatlog/chatlog.h"
|
||||
#include "src/chatlog/content/timestamp.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/friend.h"
|
||||
#include "src/friendlist.h"
|
||||
#include "src/group.h"
|
||||
#include "src/grouplist.h"
|
||||
#include "src/persistence/settings.h"
|
||||
#include "src/persistence/smileypack.h"
|
||||
#include "src/video/genericnetcamview.h"
|
||||
#include "src/widget/contentdialog.h"
|
||||
#include "src/widget/contentlayout.h"
|
||||
#include "src/widget/emoticonswidget.h"
|
||||
#include "src/widget/maskablepixmapwidget.h"
|
||||
#include "src/widget/style.h"
|
||||
#include "src/widget/tool/chattextedit.h"
|
||||
#include "src/widget/tool/croppinglabel.h"
|
||||
#include "src/widget/tool/flyoutoverlaywidget.h"
|
||||
#include "src/widget/translator.h"
|
||||
#include "src/widget/contentlayout.h"
|
||||
#include "src/widget/tool/croppinglabel.h"
|
||||
#include <QPushButton>
|
||||
#include "src/video/genericnetcamview.h"
|
||||
#include "src/widget/widget.h"
|
||||
|
||||
GenericChatForm::GenericChatForm(QWidget *parent)
|
||||
: QWidget(parent, Qt::Window)
|
||||
|
@ -630,6 +631,11 @@ void GenericChatForm::showNetcam()
|
|||
|
||||
bodySplitter->insertWidget(0, netcam);
|
||||
bodySplitter->setCollapsible(0, false);
|
||||
|
||||
QSize minSize = netcam->getSurfaceMinSize();
|
||||
ContentDialog* current = ContentDialog::current();
|
||||
if (current)
|
||||
current->onVideoShow(minSize);
|
||||
}
|
||||
|
||||
void GenericChatForm::hideNetcam()
|
||||
|
@ -637,6 +643,10 @@ void GenericChatForm::hideNetcam()
|
|||
if (!netcam)
|
||||
return;
|
||||
|
||||
ContentDialog* current = ContentDialog::current();
|
||||
if (current)
|
||||
current->onVideoHide();
|
||||
|
||||
netcam->close();
|
||||
netcam->hide();
|
||||
delete netcam;
|
||||
|
|
Loading…
Reference in New Issue
Block a user