mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'master' of https://github.com/tux3/qTox
This commit is contained in:
commit
4b61c0f188
|
@ -273,8 +273,10 @@ void Core::decreaseVideoBusyness()
|
|||
|
||||
void Core::micMuteToggle(int callId)
|
||||
{
|
||||
if (calls[callId].active) {
|
||||
calls[callId].muteMic = !calls[callId].muteMic;
|
||||
}
|
||||
}
|
||||
|
||||
void Core::onAvCancel(void* _toxav, int32_t callId, void* core)
|
||||
{
|
||||
|
|
2
debian/control
vendored
2
debian/control
vendored
|
@ -3,7 +3,7 @@ Maintainer: John Smith <barrdetwix@gmail.com>
|
|||
Section: misc
|
||||
Priority: optional
|
||||
Standards-Version: 3.9.5
|
||||
Build-Depends: debhelper (>= 9), cdbs, qt5-qmake, qt5-default, libopenal-dev, libopencv-dev, libopus-dev
|
||||
Build-Depends: debhelper (>= 9), cdbs, qt5-qmake, libopenal-dev, libopencv-dev, libopus-dev
|
||||
|
||||
Package: qtox
|
||||
Architecture: any
|
||||
|
|
BIN
img/avatar_mask.png
Normal file
BIN
img/avatar_mask.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>716</width>
|
||||
<height>543</height>
|
||||
<width>714</width>
|
||||
<height>541</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
|
@ -1452,32 +1452,20 @@ QSplitter:handle{
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ClickableLabel" name="profilePicture">
|
||||
<property name="minimumSize">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
<width>5</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="res.qrc">:/img/contact.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1">
|
||||
|
@ -2095,8 +2083,8 @@ QSplitter:handle{
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>263</width>
|
||||
<height>378</height>
|
||||
<width>262</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
||||
|
@ -3230,8 +3218,8 @@ QSplitter:handle{
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>716</width>
|
||||
<height>19</height>
|
||||
<width>714</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -3257,11 +3245,6 @@ QSplitter:handle{
|
|||
<extends>QLabel</extends>
|
||||
<header>widget/croppinglabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ClickableLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>widget/tool/clickablelabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="res.qrc"/>
|
||||
|
|
5
qtox.pro
5
qtox.pro
|
@ -117,7 +117,7 @@ HEADERS += widget/form/addfriendform.h \
|
|||
widget/tool/chatactions/messageaction.h \
|
||||
widget/tool/chatactions/filetransferaction.h \
|
||||
widget/tool/chatactions/systemmessageaction.h \
|
||||
widget/tool/clickablelabel.h
|
||||
widget/maskablepixmapwidget.h
|
||||
|
||||
SOURCES += \
|
||||
widget/form/addfriendform.cpp \
|
||||
|
@ -157,4 +157,5 @@ SOURCES += \
|
|||
widget/settingsdialog.cpp \
|
||||
widget/tool/chatactions/messageaction.cpp \
|
||||
widget/tool/chatactions/filetransferaction.cpp \
|
||||
widget/tool/chatactions/systemmessageaction.cpp
|
||||
widget/tool/chatactions/systemmessageaction.cpp \
|
||||
widget/maskablepixmapwidget.cpp
|
||||
|
|
1
res.qrc
1
res.qrc
|
@ -142,5 +142,6 @@
|
|||
<file>translations/pl.qm</file>
|
||||
<file>translations/fi.qm</file>
|
||||
<file>translations/mannol.qm</file>
|
||||
<file>img/avatar_mask.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -56,9 +56,19 @@ done
|
|||
if [[ $OPT_APT = "true" ]]; then
|
||||
echo "Installing missing tools (if any)..."
|
||||
if [[ $EUID -ne 0 && $OPT_SUDO = "true" ]]; then
|
||||
sudo apt-get install wget debhelper cdbs devscripts alien tar gzip build-essential
|
||||
sudo apt-get install wget debhelper cdbs devscripts alien tar gzip build-essential -y
|
||||
else
|
||||
apt-get install wget debhelper cdbs devscripts alien tar gzip build-essential
|
||||
apt-get install wget debhelper cdbs devscripts alien tar gzip build-essential -y
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get the requried dependencies if needed
|
||||
if [[ $OPT_APT = "true" ]]; then
|
||||
echo "Installing missing dependencies (if any)..."
|
||||
if [[ $EUID -ne 0 && $OPT_SUDO = "true" ]]; then
|
||||
sudo apt-get install qt5-qmake libopenal-dev libopencv-dev libopus-dev -y
|
||||
else
|
||||
apt-get install qt5-qmake libopenal-dev libopencv-dev libopus-dev -y
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ ChatAreaWidget::ChatAreaWidget(QWidget *parent) :
|
|||
setOpenExternalLinks(false);
|
||||
setOpenLinks(false);
|
||||
setAcceptRichText(false);
|
||||
setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
chatTextTable = textCursor().insertTable(1,3);
|
||||
|
||||
|
@ -117,7 +118,7 @@ void ChatAreaWidget::insertMessage(ChatAction *msgAction)
|
|||
chatTextTable->cellAt(row,1).firstCursorPosition().insertHtml(msgAction->getMessage());
|
||||
chatTextTable->cellAt(row,2).firstCursorPosition().insertText(msgAction->getDate());
|
||||
|
||||
msgAction->setTextCursor(cur);
|
||||
msgAction->setup(cur, this);
|
||||
|
||||
messages.append(msgAction);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QMimeData>
|
||||
#include <QFileInfo>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QBitmap>
|
||||
#include "chatform.h"
|
||||
#include "friend.h"
|
||||
#include "widget/friendwidget.h"
|
||||
|
@ -32,12 +33,13 @@
|
|||
#include "widget/tool/chattextedit.h"
|
||||
#include "core.h"
|
||||
#include "widget/widget.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
|
||||
ChatForm::ChatForm(Friend* chatFriend)
|
||||
: f(chatFriend)
|
||||
{
|
||||
nameLabel->setText(f->getName());
|
||||
avatarLabel->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
avatar->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
|
||||
statusMessageLabel = new CroppingLabel();
|
||||
netcam = new NetCamView();
|
||||
|
@ -475,8 +477,7 @@ void ChatForm::onAvatarChange(int FriendId, const QPixmap &pic)
|
|||
if (FriendId != f->friendId)
|
||||
return;
|
||||
|
||||
QPixmap scaled = pic.scaled(40,40,Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
||||
avatarLabel->setPixmap(scaled);
|
||||
avatar->setPixmap(pic);
|
||||
}
|
||||
|
||||
void ChatForm::dragEnterEvent(QDragEnterEvent *ev)
|
||||
|
@ -504,5 +505,5 @@ void ChatForm::onAvatarRemoved(int FriendId)
|
|||
if (FriendId != f->friendId)
|
||||
return;
|
||||
|
||||
avatarLabel->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
avatar->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "widget/tool/chatactions/systemmessageaction.h"
|
||||
#include "widget/chatareawidget.h"
|
||||
#include "widget/tool/chattextedit.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
|
||||
GenericChatForm::GenericChatForm(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
|
@ -35,7 +36,7 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
|||
headWidget = new QWidget();
|
||||
|
||||
nameLabel = new CroppingLabel();
|
||||
avatarLabel = new QLabel();
|
||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout();
|
||||
headTextLayout = new QVBoxLayout();
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
|
@ -99,7 +100,7 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
|||
mainFootLayout->setSpacing(0);
|
||||
|
||||
headWidget->setLayout(headLayout);
|
||||
headLayout->addWidget(avatarLabel);
|
||||
headLayout->addWidget(avatar);
|
||||
headLayout->addLayout(headTextLayout);
|
||||
headLayout->addLayout(volMicLayout);
|
||||
headLayout->addWidget(callButton);
|
||||
|
|
|
@ -30,6 +30,7 @@ class QPushButton;
|
|||
class CroppingLabel;
|
||||
class ChatTextEdit;
|
||||
class ChatAreaWidget;
|
||||
class MaskablePixmapWidget;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
|
@ -60,7 +61,7 @@ protected slots:
|
|||
|
||||
protected:
|
||||
CroppingLabel *nameLabel;
|
||||
QLabel *avatarLabel;
|
||||
MaskablePixmapWidget *avatar;
|
||||
QWidget *headWidget;
|
||||
QPushButton *fileButton, *emoteButton, *callButton, *videoButton, *volButton, *micButton;
|
||||
QVBoxLayout *headTextLayout;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "widget/groupwidget.h"
|
||||
#include "widget/tool/chattextedit.h"
|
||||
#include "widget/croppinglabel.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include "core.h"
|
||||
#include <QPushButton>
|
||||
#include <QMimeData>
|
||||
|
@ -42,7 +43,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
|||
nameLabel->setText(group->widget->name.text());
|
||||
nusersLabel->setFont(small);
|
||||
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
||||
avatarLabel->setPixmap(QPixmap(":/img/group_dark.png"));
|
||||
avatar->setPixmap(QPixmap(":/img/group_dark.png"));
|
||||
|
||||
QString names;
|
||||
for (QString& s : group->peers)
|
||||
|
|
|
@ -22,11 +22,13 @@
|
|||
#include "friend.h"
|
||||
#include "core.h"
|
||||
#include "widget/form/chatform.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QDrag>
|
||||
#include <QMimeData>
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
|
||||
FriendWidget::FriendWidget(int FriendId, QString id)
|
||||
: friendId(FriendId), isDefaultAvatar{true}
|
||||
|
@ -42,7 +44,8 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
textLayout.setMargin(0);
|
||||
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
|
||||
|
||||
avatar.setPixmap(QPixmap(":img/contact.png"));
|
||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
avatar->setPixmap(QPixmap(":img/contact_dark.png"));
|
||||
name.setText(id);
|
||||
//statusPic.setAlignment(Qt::AlignHCenter);
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
|
||||
|
@ -65,7 +68,7 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
textLayout.addStretch();
|
||||
|
||||
layout.addSpacing(20);
|
||||
layout.addWidget(&avatar);
|
||||
layout.addWidget(avatar);
|
||||
layout.addSpacing(5);
|
||||
layout.addLayout(&textLayout);
|
||||
layout.addSpacing(5);
|
||||
|
@ -137,8 +140,6 @@ void FriendWidget::setAsActiveChatroom()
|
|||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, Qt::white);
|
||||
this->setPalette(pal3);
|
||||
if (isDefaultAvatar)
|
||||
avatar.setPixmap(QPixmap(":img/contact_dark.png"));
|
||||
}
|
||||
|
||||
void FriendWidget::setAsInactiveChatroom()
|
||||
|
@ -157,9 +158,6 @@ void FriendWidget::setAsInactiveChatroom()
|
|||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
|
||||
this->setPalette(pal3);
|
||||
|
||||
if (isDefaultAvatar)
|
||||
avatar.setPixmap(QPixmap(":img/contact.png"));
|
||||
}
|
||||
|
||||
void FriendWidget::updateStatusLight()
|
||||
|
@ -203,8 +201,7 @@ void FriendWidget::onAvatarChange(int FriendId, const QPixmap& pic)
|
|||
return;
|
||||
|
||||
isDefaultAvatar = false;
|
||||
QPixmap scaled = pic.scaled(40,40,Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
||||
avatar.setPixmap(scaled);
|
||||
avatar->setPixmap(pic);
|
||||
}
|
||||
|
||||
void FriendWidget::onAvatarRemoved(int FriendId)
|
||||
|
@ -213,7 +210,7 @@ void FriendWidget::onAvatarRemoved(int FriendId)
|
|||
return;
|
||||
|
||||
isDefaultAvatar = true;
|
||||
avatar.setPixmap(QPixmap(":img/contact.png"));
|
||||
avatar->setPixmap(QPixmap(":img/contact.png"));
|
||||
}
|
||||
|
||||
void FriendWidget::mousePressEvent(QMouseEvent *ev)
|
||||
|
@ -234,8 +231,7 @@ void FriendWidget::mouseMoveEvent(QMouseEvent *ev)
|
|||
mdata->setData("friend", QString::number(friendId).toLatin1());
|
||||
|
||||
drag->setMimeData(mdata);
|
||||
if (avatar.pixmap())
|
||||
drag->setPixmap(*avatar.pixmap());
|
||||
drag->setPixmap(avatar->getPixmap());
|
||||
|
||||
drag->exec(Qt::CopyAction | Qt::MoveAction);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "croppinglabel.h"
|
||||
|
||||
class QPixmap;
|
||||
class MaskablePixmapWidget;
|
||||
|
||||
struct FriendWidget : public GenericChatroomWidget
|
||||
{
|
||||
|
@ -51,7 +52,8 @@ protected:
|
|||
|
||||
public:
|
||||
int friendId;
|
||||
QLabel avatar, statusPic;
|
||||
MaskablePixmapWidget* avatar;
|
||||
QLabel statusPic;
|
||||
CroppingLabel name, statusMessage;
|
||||
bool isDefaultAvatar;
|
||||
QPoint dragStartPos;
|
||||
|
|
72
widget/maskablepixmapwidget.cpp
Normal file
72
widget/maskablepixmapwidget.cpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "maskablepixmapwidget.h"
|
||||
#include <QPainter>
|
||||
|
||||
MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName, QColor background)
|
||||
: QWidget(parent)
|
||||
, backgroundColor(background)
|
||||
, clickable(false)
|
||||
{
|
||||
setFixedSize(size);
|
||||
mask = QPixmap(maskName).scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::setClickable(bool clickable)
|
||||
{
|
||||
this->clickable = clickable;
|
||||
|
||||
if (clickable)
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
else
|
||||
unsetCursor();
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::setPixmap(const QPixmap &pmap)
|
||||
{
|
||||
pixmap = pmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
QPixmap MaskablePixmapWidget::getPixmap() const
|
||||
{
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPixmap tmp(width(), height());
|
||||
tmp.fill(Qt::transparent);
|
||||
|
||||
QPoint offset((width() - pixmap.size().width())/2,(height() - pixmap.size().height())/2); // centering the pixmap
|
||||
|
||||
QPainter painter(&tmp);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
painter.fillRect(0,0,width(),height(),backgroundColor);
|
||||
painter.drawPixmap(offset,pixmap);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||
painter.drawPixmap(0,0,mask);
|
||||
painter.end();
|
||||
|
||||
painter.begin(this);
|
||||
painter.drawPixmap(0,0,tmp);
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::mousePressEvent(QMouseEvent*)
|
||||
{
|
||||
if(clickable)
|
||||
emit clicked();
|
||||
}
|
48
widget/maskablepixmapwidget.h
Normal file
48
widget/maskablepixmapwidget.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||
|
||||
This program is libre software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef MASKABLEPIXMAPWIDGET_H
|
||||
#define MASKABLEPIXMAPWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class MaskablePixmapWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName, QColor background = Qt::white);
|
||||
|
||||
void setClickable(bool clickable);
|
||||
void setPixmap(const QPixmap &pmap);
|
||||
QPixmap getPixmap() const;
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
virtual void mousePressEvent(QMouseEvent *);
|
||||
|
||||
private:
|
||||
QPixmap pixmap;
|
||||
QPixmap mask;
|
||||
QSize size;
|
||||
QString maskName;
|
||||
QColor backgroundColor;
|
||||
bool clickable;
|
||||
};
|
||||
|
||||
#endif // MASKABLEPIXMAPWIDGET_H
|
|
@ -21,13 +21,14 @@
|
|||
#include <QTextCursor>
|
||||
|
||||
class FileTransferInstance;
|
||||
class QTextEdit;
|
||||
|
||||
class ChatAction : public QObject
|
||||
{
|
||||
public:
|
||||
ChatAction(const bool &me, const QString &author, const QString &date) : isMe(me), name(author), date(date) {;}
|
||||
virtual ~ChatAction(){;}
|
||||
virtual void setTextCursor(QTextCursor cursor){(void)cursor;} ///< Call once, and then you MUST let the object update itself
|
||||
virtual void setup(QTextCursor cursor, QTextEdit* textEdit) = 0; ///< Call once, and then you MUST let the object update itself
|
||||
|
||||
virtual QString getName();
|
||||
virtual QString getMessage() = 0;
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
#include "filetransferaction.h"
|
||||
#include "filetransferinstance.h"
|
||||
|
||||
FileTransferAction::FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me) :
|
||||
ChatAction(me, author, date)
|
||||
#include <QTextEdit>
|
||||
#include <QScrollBar>
|
||||
|
||||
FileTransferAction::FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me)
|
||||
: ChatAction(me, author, date)
|
||||
, edit(nullptr)
|
||||
{
|
||||
w = widget;
|
||||
|
||||
|
@ -39,20 +43,26 @@ QString FileTransferAction::getMessage()
|
|||
return widgetHtml;
|
||||
}
|
||||
|
||||
void FileTransferAction::setTextCursor(QTextCursor cursor)
|
||||
void FileTransferAction::setup(QTextCursor cursor, QTextEdit *textEdit)
|
||||
{
|
||||
cur = cursor;
|
||||
cur.setKeepPositionOnInsert(true);
|
||||
int end=cur.selectionEnd();
|
||||
cur.setPosition(cur.position());
|
||||
cur.setPosition(end, QTextCursor::KeepAnchor);
|
||||
|
||||
edit = textEdit;
|
||||
}
|
||||
|
||||
void FileTransferAction::updateHtml()
|
||||
{
|
||||
if (cur.isNull())
|
||||
if (cur.isNull() || !edit)
|
||||
return;
|
||||
|
||||
// save old slider value
|
||||
int vSliderVal = edit->verticalScrollBar()->value();
|
||||
|
||||
// update content
|
||||
int pos = cur.selectionStart();
|
||||
cur.removeSelectedText();
|
||||
cur.setKeepPositionOnInsert(false);
|
||||
|
@ -62,6 +72,9 @@ void FileTransferAction::updateHtml()
|
|||
cur.setPosition(pos);
|
||||
cur.setPosition(end, QTextCursor::KeepAnchor);
|
||||
|
||||
// restore old slider value
|
||||
edit->verticalScrollBar()->setValue(vSliderVal);
|
||||
|
||||
// Free our ressources if we'll never need to update again
|
||||
if (w->getState() == FileTransferInstance::TransfState::tsCanceled
|
||||
|| w->getState() == FileTransferInstance::TransfState::tsFinished)
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me);
|
||||
virtual ~FileTransferAction();
|
||||
virtual QString getMessage();
|
||||
virtual void setTextCursor(QTextCursor cursor) final;
|
||||
virtual void setup(QTextCursor cursor, QTextEdit* textEdit) override;
|
||||
|
||||
private slots:
|
||||
void updateHtml();
|
||||
|
@ -34,6 +34,7 @@ private slots:
|
|||
private:
|
||||
FileTransferInstance *w;
|
||||
QTextCursor cur;
|
||||
QTextEdit* edit;
|
||||
};
|
||||
|
||||
#endif // FILETRANSFERACTION_H
|
||||
|
|
|
@ -23,7 +23,7 @@ MessageAction::MessageAction(const QString &author, const QString &message, cons
|
|||
{
|
||||
}
|
||||
|
||||
void MessageAction::setTextCursor(QTextCursor cursor)
|
||||
void MessageAction::setup(QTextCursor cursor, QTextEdit *)
|
||||
{
|
||||
// When this function is called, we're supposed to only update ourselve when needed
|
||||
// Nobody should ask us to do anything with our content, we're on our own
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
MessageAction(const QString &author, const QString &message, const QString &date, const bool &me);
|
||||
virtual ~MessageAction(){;}
|
||||
virtual QString getMessage();
|
||||
virtual void setTextCursor(QTextCursor cursor) final;
|
||||
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
||||
|
||||
private:
|
||||
QString message;
|
||||
|
|
|
@ -28,7 +28,7 @@ QString SystemMessageAction::getMessage()
|
|||
return QString("<table width=100%><tr><td align=center><div class=" + type + ">" + message + "</td><tr></div></table>");
|
||||
}
|
||||
|
||||
void SystemMessageAction::setTextCursor(QTextCursor cursor)
|
||||
void SystemMessageAction::setup(QTextCursor cursor, QTextEdit *)
|
||||
{
|
||||
// When this function is called, we're supposed to only update ourselve when needed
|
||||
// Nobody should ask us to do anything with our content, we're on our own
|
||||
|
|
|
@ -24,7 +24,7 @@ class SystemMessageAction : public ChatAction
|
|||
public:
|
||||
SystemMessageAction(const QString &message, const QString& type, const QString &date);
|
||||
virtual ~SystemMessageAction(){;}
|
||||
virtual void setTextCursor(QTextCursor cursor) final;
|
||||
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
||||
|
||||
virtual QString getName() {return QString();}
|
||||
virtual QString getMessage();
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef CLICKABLELABEL_H
|
||||
#define CLICKABLELABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class QMouseEvent;
|
||||
class QWidget;
|
||||
|
||||
class ClickableLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ClickableLabel(QWidget* parent = 0) : QLabel(parent) {}
|
||||
signals:
|
||||
void clicked();
|
||||
protected:
|
||||
void mousePressEvent (QMouseEvent*) {emit clicked();}
|
||||
};
|
||||
|
||||
|
||||
#endif // CLICKABLELABEL_H
|
|
@ -32,6 +32,7 @@
|
|||
#include "camera.h"
|
||||
#include "widget/form/chatform.h"
|
||||
#include "widget/settingsdialog.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
@ -111,6 +112,11 @@ Widget::Widget(QWidget *parent)
|
|||
|
||||
isWindowMinimized = 0;
|
||||
|
||||
profilePicture = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
profilePicture->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
profilePicture->setClickable(true);
|
||||
ui->horizontalLayout_3->insertWidget(0,profilePicture);
|
||||
|
||||
ui->mainContent->setLayout(new QVBoxLayout());
|
||||
ui->mainHead->setLayout(new QVBoxLayout());
|
||||
ui->mainHead->layout()->setMargin(0);
|
||||
|
@ -214,7 +220,7 @@ Widget::Widget(QWidget *parent)
|
|||
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
|
||||
connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString)));
|
||||
connect(ui->statusLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onStatusMessageChanged(QString,QString)));
|
||||
connect(ui->profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
|
||||
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
|
||||
connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
|
||||
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
||||
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
||||
|
@ -322,8 +328,7 @@ void Widget::onAvatarClicked()
|
|||
|
||||
void Widget::onSelfAvatarLoaded(const QPixmap& pic)
|
||||
{
|
||||
QPixmap scaled = pic.scaled(40,40, Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
||||
ui->profilePicture->setPixmap(scaled);
|
||||
profilePicture->setPixmap(pic);
|
||||
}
|
||||
|
||||
void Widget::onConnected()
|
||||
|
|
|
@ -38,6 +38,7 @@ class Core;
|
|||
class Camera;
|
||||
class FriendListWidget;
|
||||
class SettingsDialog;
|
||||
class MaskablePixmapWidget;
|
||||
|
||||
class Widget : public QMainWindow
|
||||
{
|
||||
|
@ -144,6 +145,7 @@ private:
|
|||
GenericChatroomWidget* activeChatroomWidget;
|
||||
FriendListWidget* contactListWidget;
|
||||
Camera* camera;
|
||||
MaskablePixmapWidget* profilePicture;
|
||||
bool notify(QObject *receiver, QEvent *event);
|
||||
bool eventFilter(QObject *, QEvent *event);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user