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 <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());
}
}

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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()));

View File

@ -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)
@ -226,7 +227,7 @@ GenericChatForm::~GenericChatForm()
void GenericChatForm::adjustFileMenuPosition()
{
QPoint pos = fileButton->pos();
QPoint pos = fileButton->mapTo(bodySplitter, QPoint());
QSize size = fileFlyout->size();
fileFlyout->move(pos.x() - size.width(), pos.y());
}
@ -244,7 +245,6 @@ void GenericChatForm::hideFileMenu()
{
if(fileFlyout->isShown() || fileFlyout->isBeingShown())
fileFlyout->animateHide();
}
bool GenericChatForm::isEmpty()
@ -507,7 +507,7 @@ void GenericChatForm::resizeEvent(QResizeEvent* event)
bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
{
EmoticonsWidget* ev = qobject_cast<EmoticonsWidget*>(object);
if (( ev) && (event->type() == QEvent::KeyPress) )
if (ev && event->type() == QEvent::KeyPress)
{
QKeyEvent* key = static_cast<QKeyEvent*>(event);
msgEdit->sendKeyEvent(key);
@ -527,15 +527,21 @@ bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
showFileMenu();
break;
case QEvent::Leave: {
QPoint pos = mapFromGlobal(QCursor::pos());
QRect fileRect(fileFlyout->pos(), fileFlyout->size());
fileRect = fileRect.united(QRect(fileButton->pos(), fileButton->size()));
case QEvent::Leave:
{
QPoint flyPos = fileFlyout->mapToGlobal(QPoint());
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();
} break;
break;
}
case QEvent::MouseButtonPress:
hideFileMenu();
@ -625,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()
@ -632,6 +643,10 @@ void GenericChatForm::hideNetcam()
if (!netcam)
return;
ContentDialog* current = ContentDialog::current();
if (current)
current->onVideoHide();
netcam->close();
netcam->hide();
delete netcam;