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

Merge pull request #3453

Diadlo (2):
      fix(genericchatform): Fixed position of screenshot button
      fix(video): Changed minimum window size with video
This commit is contained in:
sudden6 2016-07-12 19:49:29 +02:00
commit 0a595ea679
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
6 changed files with 106 additions and 48 deletions

View File

@ -18,9 +18,10 @@
*/ */
#include "genericnetcamview.h" #include "genericnetcamview.h"
#include <QBoxLayout> #include <QBoxLayout>
#include <QPushButton>
#include <QFrame> #include <QFrame>
#include <QPushButton>
GenericNetCamView::GenericNetCamView(QWidget *parent) GenericNetCamView::GenericNetCamView(QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -35,6 +36,7 @@ GenericNetCamView::GenericNetCamView(QWidget *parent)
buttonLayout->addStretch(); buttonLayout->addStretch();
button = new QPushButton(); button = new QPushButton();
buttonLayout->addWidget(button); buttonLayout->addWidget(button);
buttonLayout->setSizeConstraint(QLayout::SetMinimumSize);
connect(button, &QPushButton::clicked, this, &GenericNetCamView::showMessageClicked); connect(button, &QPushButton::clicked, this, &GenericNetCamView::showMessageClicked);
verLayout->addSpacing(spacing); verLayout->addSpacing(spacing);
@ -52,18 +54,26 @@ GenericNetCamView::GenericNetCamView(QWidget *parent)
setStyleSheet("NetCamView { background-color: #c1c1c1; }"); 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) 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")); button->setText(tr("Show Messages"));
if (notify) if (notify)
button->setIcon(QIcon(":/ui/chatArea/info.svg")); button->setIcon(QIcon(":/ui/chatArea/info.svg"));
} }
else
{
button->setText(tr("Hide Messages"));
button->setIcon(QIcon());
}
}

View File

@ -20,17 +20,18 @@
#ifndef GENERICNETCAMVIEW_H #ifndef GENERICNETCAMVIEW_H
#define GENERICNETCAMVIEW_H #define GENERICNETCAMVIEW_H
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget> #include <QWidget>
class VideoSurface; #include "src/video/videosurface.h"
class QPushButton;
class QVBoxLayout;
class GenericNetCamView : public QWidget class GenericNetCamView : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit GenericNetCamView(QWidget* parent); explicit GenericNetCamView(QWidget* parent);
QSize getSurfaceMinSize();
signals: signals:
void showMessageClicked(); void showMessageClicked();

View File

@ -18,6 +18,14 @@
*/ */
#include "contentdialog.h" #include "contentdialog.h"
#include <QBoxLayout>
#include <QDragEnterEvent>
#include <QGuiApplication>
#include <QMimeData>
#include <QShortcut>
#include <QSplitter>
#include "contentlayout.h" #include "contentlayout.h"
#include "friendwidget.h" #include "friendwidget.h"
#include "groupwidget.h" #include "groupwidget.h"
@ -34,12 +42,6 @@
#include "src/widget/friendlistlayout.h" #include "src/widget/friendlistlayout.h"
#include "src/widget/form/settingswidget.h" #include "src/widget/form/settingswidget.h"
#include "src/widget/translator.h" #include "src/widget/translator.h"
#include <QBoxLayout>
#include <QSplitter>
#include <QGuiApplication>
#include <QDragEnterEvent>
#include <QMimeData>
#include <QShortcut>
ContentDialog* ContentDialog::currentDialog = nullptr; ContentDialog* ContentDialog::currentDialog = nullptr;
QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> ContentDialog::friendList; QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> ContentDialog::friendList;
@ -49,6 +51,8 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
: ActivateDialog(parent, Qt::Window) : ActivateDialog(parent, Qt::Window)
, activeChatroomWidget(nullptr) , activeChatroomWidget(nullptr)
, settingsWidget(settingsWidget) , settingsWidget(settingsWidget)
, videoSurfaceSize(QSize())
, videoCount(0)
{ {
QVBoxLayout* boxLayout = new QVBoxLayout(this); QVBoxLayout* boxLayout = new QVBoxLayout(this);
boxLayout->setMargin(0); 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() ContentDialog* ContentDialog::current()
{ {
return currentDialog; return currentDialog;

View File

@ -20,10 +20,11 @@
#ifndef CONTENTDIALOG_H #ifndef CONTENTDIALOG_H
#define CONTENTDIALOG_H #define CONTENTDIALOG_H
#include "src/widget/tool/activatedialog.h"
#include <tuple> #include <tuple>
#include "src/core/corestructs.h" #include "src/core/corestructs.h"
#include "src/widget/genericchatitemlayout.h" #include "src/widget/genericchatitemlayout.h"
#include "src/widget/tool/activatedialog.h"
template <typename K, typename V> class QHash; template <typename K, typename V> class QHash;
template <typename T> class QSet; template <typename T> class QSet;
@ -54,6 +55,8 @@ public:
void ensureSplitterVisible(); void ensureSplitterVisible();
void cycleContacts(bool forward, bool loop = true); void cycleContacts(bool forward, bool loop = true);
void onVideoShow(QSize size);
void onVideoHide();
static ContentDialog* current(); static ContentDialog* current();
static bool existsFriendWidget(int friendId, bool focus); static bool existsFriendWidget(int friendId, bool focus);
@ -111,6 +114,9 @@ private:
GenericChatroomWidget* activeChatroomWidget; GenericChatroomWidget* activeChatroomWidget;
GenericChatroomWidget* displayWidget = nullptr; GenericChatroomWidget* displayWidget = nullptr;
SettingsWidget* settingsWidget; SettingsWidget* settingsWidget;
QSize videoSurfaceSize;
int videoCount;
static ContentDialog* currentDialog; static ContentDialog* currentDialog;
static QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> friendList; static QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> friendList;
static QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> groupList; static QHash<int, std::tuple<ContentDialog*, GenericChatroomWidget*>> groupList;

View File

@ -100,7 +100,7 @@ ChatForm::ChatForm(Friend* chatFriend)
headTextLayout->addWidget(callDuration, 1, Qt::AlignCenter); headTextLayout->addWidget(callDuration, 1, Qt::AlignCenter);
callDuration->hide(); callDuration->hide();
chatWidget->setMinimumHeight(160); chatWidget->setMinimumHeight(50);
connect(this, &GenericChatForm::messageInserted, this, &ChatForm::onMessageInserted); connect(this, &GenericChatForm::messageInserted, this, &ChatForm::onMessageInserted);
loadHistoryAction = menu.addAction(QString(), this, SLOT(onLoadHistory())); loadHistoryAction = menu.addAction(QString(), this, SLOT(onLoadHistory()));

View File

@ -19,33 +19,34 @@
#include "genericchatform.h" #include "genericchatform.h"
#include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QDebug>
#include <QShortcut>
#include <QKeyEvent> #include <QKeyEvent>
#include <QPushButton>
#include <QShortcut>
#include <QSplitter> #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/chatlog.h"
#include "src/chatlog/content/timestamp.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/tool/flyoutoverlaywidget.h"
#include "src/widget/translator.h" #include "src/widget/translator.h"
#include "src/widget/contentlayout.h" #include "src/widget/widget.h"
#include "src/widget/tool/croppinglabel.h"
#include <QPushButton>
#include "src/video/genericnetcamview.h"
GenericChatForm::GenericChatForm(QWidget *parent) GenericChatForm::GenericChatForm(QWidget *parent)
: QWidget(parent, Qt::Window) : QWidget(parent, Qt::Window)
@ -226,7 +227,7 @@ GenericChatForm::~GenericChatForm()
void GenericChatForm::adjustFileMenuPosition() void GenericChatForm::adjustFileMenuPosition()
{ {
QPoint pos = fileButton->pos(); QPoint pos = fileButton->mapTo(bodySplitter, QPoint());
QSize size = fileFlyout->size(); QSize size = fileFlyout->size();
fileFlyout->move(pos.x() - size.width(), pos.y()); fileFlyout->move(pos.x() - size.width(), pos.y());
} }
@ -244,7 +245,6 @@ void GenericChatForm::hideFileMenu()
{ {
if(fileFlyout->isShown() || fileFlyout->isBeingShown()) if(fileFlyout->isShown() || fileFlyout->isBeingShown())
fileFlyout->animateHide(); fileFlyout->animateHide();
} }
bool GenericChatForm::isEmpty() bool GenericChatForm::isEmpty()
@ -507,7 +507,7 @@ void GenericChatForm::resizeEvent(QResizeEvent* event)
bool GenericChatForm::eventFilter(QObject* object, QEvent* event) bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
{ {
EmoticonsWidget* ev = qobject_cast<EmoticonsWidget*>(object); EmoticonsWidget* ev = qobject_cast<EmoticonsWidget*>(object);
if (( ev) && (event->type() == QEvent::KeyPress) ) if (ev && event->type() == QEvent::KeyPress)
{ {
QKeyEvent* key = static_cast<QKeyEvent*>(event); QKeyEvent* key = static_cast<QKeyEvent*>(event);
msgEdit->sendKeyEvent(key); msgEdit->sendKeyEvent(key);
@ -527,15 +527,21 @@ bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
showFileMenu(); showFileMenu();
break; break;
case QEvent::Leave: { case QEvent::Leave:
QPoint pos = mapFromGlobal(QCursor::pos()); {
QRect fileRect(fileFlyout->pos(), fileFlyout->size()); QPoint flyPos = fileFlyout->mapToGlobal(QPoint());
fileRect = fileRect.united(QRect(fileButton->pos(), fileButton->size())); QSize flySize = fileFlyout->size();
if (!fileRect.contains(pos)) QPoint filePos = fileButton->mapToGlobal(QPoint());
QSize fileSize = fileButton->size();
QRect region = QRect(flyPos, flySize).united(QRect(filePos, fileSize));
if (!region.contains(QCursor::pos()))
hideFileMenu(); hideFileMenu();
} break; break;
}
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
hideFileMenu(); hideFileMenu();
@ -625,6 +631,11 @@ void GenericChatForm::showNetcam()
bodySplitter->insertWidget(0, netcam); bodySplitter->insertWidget(0, netcam);
bodySplitter->setCollapsible(0, false); bodySplitter->setCollapsible(0, false);
QSize minSize = netcam->getSurfaceMinSize();
ContentDialog* current = ContentDialog::current();
if (current)
current->onVideoShow(minSize);
} }
void GenericChatForm::hideNetcam() void GenericChatForm::hideNetcam()
@ -632,6 +643,10 @@ void GenericChatForm::hideNetcam()
if (!netcam) if (!netcam)
return; return;
ContentDialog* current = ContentDialog::current();
if (current)
current->onVideoHide();
netcam->close(); netcam->close();
netcam->hide(); netcam->hide();
delete netcam; delete netcam;