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)
|
void Core::micMuteToggle(int callId)
|
||||||
{
|
{
|
||||||
|
if (calls[callId].active) {
|
||||||
calls[callId].muteMic = !calls[callId].muteMic;
|
calls[callId].muteMic = !calls[callId].muteMic;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Core::onAvCancel(void* _toxav, int32_t callId, void* core)
|
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
|
Section: misc
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Standards-Version: 3.9.5
|
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
|
Package: qtox
|
||||||
Architecture: any
|
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>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>716</width>
|
<width>714</width>
|
||||||
<height>543</height>
|
<height>541</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
@ -1452,32 +1452,20 @@ QSplitter:handle{
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="ClickableLabel" name="profilePicture">
|
<spacer name="horizontalSpacer_4">
|
||||||
<property name="minimumSize">
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Maximum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>5</width>
|
||||||
<height>40</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
</spacer>
|
||||||
<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>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1">
|
||||||
|
@ -2095,8 +2083,8 @@ QSplitter:handle{
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>263</width>
|
<width>262</width>
|
||||||
<height>378</height>
|
<height>375</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
||||||
|
@ -3230,8 +3218,8 @@ QSplitter:handle{
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>716</width>
|
<width>714</width>
|
||||||
<height>19</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -3257,11 +3245,6 @@ QSplitter:handle{
|
||||||
<extends>QLabel</extends>
|
<extends>QLabel</extends>
|
||||||
<header>widget/croppinglabel.h</header>
|
<header>widget/croppinglabel.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>ClickableLabel</class>
|
|
||||||
<extends>QLabel</extends>
|
|
||||||
<header>widget/tool/clickablelabel.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="res.qrc"/>
|
<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/messageaction.h \
|
||||||
widget/tool/chatactions/filetransferaction.h \
|
widget/tool/chatactions/filetransferaction.h \
|
||||||
widget/tool/chatactions/systemmessageaction.h \
|
widget/tool/chatactions/systemmessageaction.h \
|
||||||
widget/tool/clickablelabel.h
|
widget/maskablepixmapwidget.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
widget/form/addfriendform.cpp \
|
widget/form/addfriendform.cpp \
|
||||||
|
@ -157,4 +157,5 @@ SOURCES += \
|
||||||
widget/settingsdialog.cpp \
|
widget/settingsdialog.cpp \
|
||||||
widget/tool/chatactions/messageaction.cpp \
|
widget/tool/chatactions/messageaction.cpp \
|
||||||
widget/tool/chatactions/filetransferaction.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/pl.qm</file>
|
||||||
<file>translations/fi.qm</file>
|
<file>translations/fi.qm</file>
|
||||||
<file>translations/mannol.qm</file>
|
<file>translations/mannol.qm</file>
|
||||||
|
<file>img/avatar_mask.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -56,9 +56,19 @@ done
|
||||||
if [[ $OPT_APT = "true" ]]; then
|
if [[ $OPT_APT = "true" ]]; then
|
||||||
echo "Installing missing tools (if any)..."
|
echo "Installing missing tools (if any)..."
|
||||||
if [[ $EUID -ne 0 && $OPT_SUDO = "true" ]]; then
|
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
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ ChatAreaWidget::ChatAreaWidget(QWidget *parent) :
|
||||||
setOpenExternalLinks(false);
|
setOpenExternalLinks(false);
|
||||||
setOpenLinks(false);
|
setOpenLinks(false);
|
||||||
setAcceptRichText(false);
|
setAcceptRichText(false);
|
||||||
|
setFrameStyle(QFrame::NoFrame);
|
||||||
|
|
||||||
chatTextTable = textCursor().insertTable(1,3);
|
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,1).firstCursorPosition().insertHtml(msgAction->getMessage());
|
||||||
chatTextTable->cellAt(row,2).firstCursorPosition().insertText(msgAction->getDate());
|
chatTextTable->cellAt(row,2).firstCursorPosition().insertText(msgAction->getDate());
|
||||||
|
|
||||||
msgAction->setTextCursor(cur);
|
msgAction->setup(cur, this);
|
||||||
|
|
||||||
messages.append(msgAction);
|
messages.append(msgAction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
|
#include <QBitmap>
|
||||||
#include "chatform.h"
|
#include "chatform.h"
|
||||||
#include "friend.h"
|
#include "friend.h"
|
||||||
#include "widget/friendwidget.h"
|
#include "widget/friendwidget.h"
|
||||||
|
@ -32,12 +33,13 @@
|
||||||
#include "widget/tool/chattextedit.h"
|
#include "widget/tool/chattextedit.h"
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "widget/widget.h"
|
#include "widget/widget.h"
|
||||||
|
#include "widget/maskablepixmapwidget.h"
|
||||||
|
|
||||||
ChatForm::ChatForm(Friend* chatFriend)
|
ChatForm::ChatForm(Friend* chatFriend)
|
||||||
: f(chatFriend)
|
: f(chatFriend)
|
||||||
{
|
{
|
||||||
nameLabel->setText(f->getName());
|
nameLabel->setText(f->getName());
|
||||||
avatarLabel->setPixmap(QPixmap(":/img/contact_dark.png"));
|
avatar->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||||
|
|
||||||
statusMessageLabel = new CroppingLabel();
|
statusMessageLabel = new CroppingLabel();
|
||||||
netcam = new NetCamView();
|
netcam = new NetCamView();
|
||||||
|
@ -475,8 +477,7 @@ void ChatForm::onAvatarChange(int FriendId, const QPixmap &pic)
|
||||||
if (FriendId != f->friendId)
|
if (FriendId != f->friendId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPixmap scaled = pic.scaled(40,40,Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
avatar->setPixmap(pic);
|
||||||
avatarLabel->setPixmap(scaled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::dragEnterEvent(QDragEnterEvent *ev)
|
void ChatForm::dragEnterEvent(QDragEnterEvent *ev)
|
||||||
|
@ -504,5 +505,5 @@ void ChatForm::onAvatarRemoved(int FriendId)
|
||||||
if (FriendId != f->friendId)
|
if (FriendId != f->friendId)
|
||||||
return;
|
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/tool/chatactions/systemmessageaction.h"
|
||||||
#include "widget/chatareawidget.h"
|
#include "widget/chatareawidget.h"
|
||||||
#include "widget/tool/chattextedit.h"
|
#include "widget/tool/chattextedit.h"
|
||||||
|
#include "widget/maskablepixmapwidget.h"
|
||||||
|
|
||||||
GenericChatForm::GenericChatForm(QWidget *parent) :
|
GenericChatForm::GenericChatForm(QWidget *parent) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
|
@ -35,7 +36,7 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
||||||
headWidget = new QWidget();
|
headWidget = new QWidget();
|
||||||
|
|
||||||
nameLabel = new CroppingLabel();
|
nameLabel = new CroppingLabel();
|
||||||
avatarLabel = new QLabel();
|
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||||
QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout();
|
QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout();
|
||||||
headTextLayout = new QVBoxLayout();
|
headTextLayout = new QVBoxLayout();
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
|
@ -99,7 +100,7 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
||||||
mainFootLayout->setSpacing(0);
|
mainFootLayout->setSpacing(0);
|
||||||
|
|
||||||
headWidget->setLayout(headLayout);
|
headWidget->setLayout(headLayout);
|
||||||
headLayout->addWidget(avatarLabel);
|
headLayout->addWidget(avatar);
|
||||||
headLayout->addLayout(headTextLayout);
|
headLayout->addLayout(headTextLayout);
|
||||||
headLayout->addLayout(volMicLayout);
|
headLayout->addLayout(volMicLayout);
|
||||||
headLayout->addWidget(callButton);
|
headLayout->addWidget(callButton);
|
||||||
|
|
|
@ -30,6 +30,7 @@ class QPushButton;
|
||||||
class CroppingLabel;
|
class CroppingLabel;
|
||||||
class ChatTextEdit;
|
class ChatTextEdit;
|
||||||
class ChatAreaWidget;
|
class ChatAreaWidget;
|
||||||
|
class MaskablePixmapWidget;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
@ -60,7 +61,7 @@ protected slots:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CroppingLabel *nameLabel;
|
CroppingLabel *nameLabel;
|
||||||
QLabel *avatarLabel;
|
MaskablePixmapWidget *avatar;
|
||||||
QWidget *headWidget;
|
QWidget *headWidget;
|
||||||
QPushButton *fileButton, *emoteButton, *callButton, *videoButton, *volButton, *micButton;
|
QPushButton *fileButton, *emoteButton, *callButton, *videoButton, *volButton, *micButton;
|
||||||
QVBoxLayout *headTextLayout;
|
QVBoxLayout *headTextLayout;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "widget/groupwidget.h"
|
#include "widget/groupwidget.h"
|
||||||
#include "widget/tool/chattextedit.h"
|
#include "widget/tool/chattextedit.h"
|
||||||
#include "widget/croppinglabel.h"
|
#include "widget/croppinglabel.h"
|
||||||
|
#include "widget/maskablepixmapwidget.h"
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
@ -42,7 +43,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
nameLabel->setText(group->widget->name.text());
|
nameLabel->setText(group->widget->name.text());
|
||||||
nusersLabel->setFont(small);
|
nusersLabel->setFont(small);
|
||||||
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
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;
|
QString names;
|
||||||
for (QString& s : group->peers)
|
for (QString& s : group->peers)
|
||||||
|
|
|
@ -22,11 +22,13 @@
|
||||||
#include "friend.h"
|
#include "friend.h"
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "widget/form/chatform.h"
|
#include "widget/form/chatform.h"
|
||||||
|
#include "widget/maskablepixmapwidget.h"
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QBitmap>
|
||||||
|
|
||||||
FriendWidget::FriendWidget(int FriendId, QString id)
|
FriendWidget::FriendWidget(int FriendId, QString id)
|
||||||
: friendId(FriendId), isDefaultAvatar{true}
|
: friendId(FriendId), isDefaultAvatar{true}
|
||||||
|
@ -42,7 +44,8 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
||||||
textLayout.setMargin(0);
|
textLayout.setMargin(0);
|
||||||
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
|
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);
|
name.setText(id);
|
||||||
//statusPic.setAlignment(Qt::AlignHCenter);
|
//statusPic.setAlignment(Qt::AlignHCenter);
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
|
statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
|
||||||
|
@ -65,7 +68,7 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
||||||
textLayout.addStretch();
|
textLayout.addStretch();
|
||||||
|
|
||||||
layout.addSpacing(20);
|
layout.addSpacing(20);
|
||||||
layout.addWidget(&avatar);
|
layout.addWidget(avatar);
|
||||||
layout.addSpacing(5);
|
layout.addSpacing(5);
|
||||||
layout.addLayout(&textLayout);
|
layout.addLayout(&textLayout);
|
||||||
layout.addSpacing(5);
|
layout.addSpacing(5);
|
||||||
|
@ -137,8 +140,6 @@ void FriendWidget::setAsActiveChatroom()
|
||||||
QPalette pal3;
|
QPalette pal3;
|
||||||
pal3.setColor(QPalette::Background, Qt::white);
|
pal3.setColor(QPalette::Background, Qt::white);
|
||||||
this->setPalette(pal3);
|
this->setPalette(pal3);
|
||||||
if (isDefaultAvatar)
|
|
||||||
avatar.setPixmap(QPixmap(":img/contact_dark.png"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendWidget::setAsInactiveChatroom()
|
void FriendWidget::setAsInactiveChatroom()
|
||||||
|
@ -157,9 +158,6 @@ void FriendWidget::setAsInactiveChatroom()
|
||||||
QPalette pal3;
|
QPalette pal3;
|
||||||
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
|
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
|
||||||
this->setPalette(pal3);
|
this->setPalette(pal3);
|
||||||
|
|
||||||
if (isDefaultAvatar)
|
|
||||||
avatar.setPixmap(QPixmap(":img/contact.png"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendWidget::updateStatusLight()
|
void FriendWidget::updateStatusLight()
|
||||||
|
@ -203,8 +201,7 @@ void FriendWidget::onAvatarChange(int FriendId, const QPixmap& pic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isDefaultAvatar = false;
|
isDefaultAvatar = false;
|
||||||
QPixmap scaled = pic.scaled(40,40,Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
avatar->setPixmap(pic);
|
||||||
avatar.setPixmap(scaled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendWidget::onAvatarRemoved(int FriendId)
|
void FriendWidget::onAvatarRemoved(int FriendId)
|
||||||
|
@ -213,7 +210,7 @@ void FriendWidget::onAvatarRemoved(int FriendId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isDefaultAvatar = true;
|
isDefaultAvatar = true;
|
||||||
avatar.setPixmap(QPixmap(":img/contact.png"));
|
avatar->setPixmap(QPixmap(":img/contact.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendWidget::mousePressEvent(QMouseEvent *ev)
|
void FriendWidget::mousePressEvent(QMouseEvent *ev)
|
||||||
|
@ -234,8 +231,7 @@ void FriendWidget::mouseMoveEvent(QMouseEvent *ev)
|
||||||
mdata->setData("friend", QString::number(friendId).toLatin1());
|
mdata->setData("friend", QString::number(friendId).toLatin1());
|
||||||
|
|
||||||
drag->setMimeData(mdata);
|
drag->setMimeData(mdata);
|
||||||
if (avatar.pixmap())
|
drag->setPixmap(avatar->getPixmap());
|
||||||
drag->setPixmap(*avatar.pixmap());
|
|
||||||
|
|
||||||
drag->exec(Qt::CopyAction | Qt::MoveAction);
|
drag->exec(Qt::CopyAction | Qt::MoveAction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "croppinglabel.h"
|
#include "croppinglabel.h"
|
||||||
|
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
|
class MaskablePixmapWidget;
|
||||||
|
|
||||||
struct FriendWidget : public GenericChatroomWidget
|
struct FriendWidget : public GenericChatroomWidget
|
||||||
{
|
{
|
||||||
|
@ -51,7 +52,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int friendId;
|
int friendId;
|
||||||
QLabel avatar, statusPic;
|
MaskablePixmapWidget* avatar;
|
||||||
|
QLabel statusPic;
|
||||||
CroppingLabel name, statusMessage;
|
CroppingLabel name, statusMessage;
|
||||||
bool isDefaultAvatar;
|
bool isDefaultAvatar;
|
||||||
QPoint dragStartPos;
|
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>
|
#include <QTextCursor>
|
||||||
|
|
||||||
class FileTransferInstance;
|
class FileTransferInstance;
|
||||||
|
class QTextEdit;
|
||||||
|
|
||||||
class ChatAction : public QObject
|
class ChatAction : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ChatAction(const bool &me, const QString &author, const QString &date) : isMe(me), name(author), date(date) {;}
|
ChatAction(const bool &me, const QString &author, const QString &date) : isMe(me), name(author), date(date) {;}
|
||||||
virtual ~ChatAction(){;}
|
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 getName();
|
||||||
virtual QString getMessage() = 0;
|
virtual QString getMessage() = 0;
|
||||||
|
|
|
@ -17,8 +17,12 @@
|
||||||
#include "filetransferaction.h"
|
#include "filetransferaction.h"
|
||||||
#include "filetransferinstance.h"
|
#include "filetransferinstance.h"
|
||||||
|
|
||||||
FileTransferAction::FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me) :
|
#include <QTextEdit>
|
||||||
ChatAction(me, author, date)
|
#include <QScrollBar>
|
||||||
|
|
||||||
|
FileTransferAction::FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me)
|
||||||
|
: ChatAction(me, author, date)
|
||||||
|
, edit(nullptr)
|
||||||
{
|
{
|
||||||
w = widget;
|
w = widget;
|
||||||
|
|
||||||
|
@ -39,20 +43,26 @@ QString FileTransferAction::getMessage()
|
||||||
return widgetHtml;
|
return widgetHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTransferAction::setTextCursor(QTextCursor cursor)
|
void FileTransferAction::setup(QTextCursor cursor, QTextEdit *textEdit)
|
||||||
{
|
{
|
||||||
cur = cursor;
|
cur = cursor;
|
||||||
cur.setKeepPositionOnInsert(true);
|
cur.setKeepPositionOnInsert(true);
|
||||||
int end=cur.selectionEnd();
|
int end=cur.selectionEnd();
|
||||||
cur.setPosition(cur.position());
|
cur.setPosition(cur.position());
|
||||||
cur.setPosition(end, QTextCursor::KeepAnchor);
|
cur.setPosition(end, QTextCursor::KeepAnchor);
|
||||||
|
|
||||||
|
edit = textEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileTransferAction::updateHtml()
|
void FileTransferAction::updateHtml()
|
||||||
{
|
{
|
||||||
if (cur.isNull())
|
if (cur.isNull() || !edit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// save old slider value
|
||||||
|
int vSliderVal = edit->verticalScrollBar()->value();
|
||||||
|
|
||||||
|
// update content
|
||||||
int pos = cur.selectionStart();
|
int pos = cur.selectionStart();
|
||||||
cur.removeSelectedText();
|
cur.removeSelectedText();
|
||||||
cur.setKeepPositionOnInsert(false);
|
cur.setKeepPositionOnInsert(false);
|
||||||
|
@ -62,6 +72,9 @@ void FileTransferAction::updateHtml()
|
||||||
cur.setPosition(pos);
|
cur.setPosition(pos);
|
||||||
cur.setPosition(end, QTextCursor::KeepAnchor);
|
cur.setPosition(end, QTextCursor::KeepAnchor);
|
||||||
|
|
||||||
|
// restore old slider value
|
||||||
|
edit->verticalScrollBar()->setValue(vSliderVal);
|
||||||
|
|
||||||
// Free our ressources if we'll never need to update again
|
// Free our ressources if we'll never need to update again
|
||||||
if (w->getState() == FileTransferInstance::TransfState::tsCanceled
|
if (w->getState() == FileTransferInstance::TransfState::tsCanceled
|
||||||
|| w->getState() == FileTransferInstance::TransfState::tsFinished)
|
|| w->getState() == FileTransferInstance::TransfState::tsFinished)
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me);
|
FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me);
|
||||||
virtual ~FileTransferAction();
|
virtual ~FileTransferAction();
|
||||||
virtual QString getMessage();
|
virtual QString getMessage();
|
||||||
virtual void setTextCursor(QTextCursor cursor) final;
|
virtual void setup(QTextCursor cursor, QTextEdit* textEdit) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateHtml();
|
void updateHtml();
|
||||||
|
@ -34,6 +34,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
FileTransferInstance *w;
|
FileTransferInstance *w;
|
||||||
QTextCursor cur;
|
QTextCursor cur;
|
||||||
|
QTextEdit* edit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILETRANSFERACTION_H
|
#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
|
// 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
|
// 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);
|
MessageAction(const QString &author, const QString &message, const QString &date, const bool &me);
|
||||||
virtual ~MessageAction(){;}
|
virtual ~MessageAction(){;}
|
||||||
virtual QString getMessage();
|
virtual QString getMessage();
|
||||||
virtual void setTextCursor(QTextCursor cursor) final;
|
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString message;
|
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>");
|
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
|
// 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
|
// Nobody should ask us to do anything with our content, we're on our own
|
||||||
|
|
|
@ -24,7 +24,7 @@ class SystemMessageAction : public ChatAction
|
||||||
public:
|
public:
|
||||||
SystemMessageAction(const QString &message, const QString& type, const QString &date);
|
SystemMessageAction(const QString &message, const QString& type, const QString &date);
|
||||||
virtual ~SystemMessageAction(){;}
|
virtual ~SystemMessageAction(){;}
|
||||||
virtual void setTextCursor(QTextCursor cursor) final;
|
virtual void setup(QTextCursor cursor, QTextEdit*) override;
|
||||||
|
|
||||||
virtual QString getName() {return QString();}
|
virtual QString getName() {return QString();}
|
||||||
virtual QString getMessage();
|
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 "camera.h"
|
||||||
#include "widget/form/chatform.h"
|
#include "widget/form/chatform.h"
|
||||||
#include "widget/settingsdialog.h"
|
#include "widget/settingsdialog.h"
|
||||||
|
#include "widget/maskablepixmapwidget.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
@ -111,6 +112,11 @@ Widget::Widget(QWidget *parent)
|
||||||
|
|
||||||
isWindowMinimized = 0;
|
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->mainContent->setLayout(new QVBoxLayout());
|
||||||
ui->mainHead->setLayout(new QVBoxLayout());
|
ui->mainHead->setLayout(new QVBoxLayout());
|
||||||
ui->mainHead->layout()->setMargin(0);
|
ui->mainHead->layout()->setMargin(0);
|
||||||
|
@ -214,7 +220,7 @@ Widget::Widget(QWidget *parent)
|
||||||
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
|
connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked()));
|
||||||
connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString)));
|
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->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(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
|
||||||
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
||||||
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
||||||
|
@ -322,8 +328,7 @@ void Widget::onAvatarClicked()
|
||||||
|
|
||||||
void Widget::onSelfAvatarLoaded(const QPixmap& pic)
|
void Widget::onSelfAvatarLoaded(const QPixmap& pic)
|
||||||
{
|
{
|
||||||
QPixmap scaled = pic.scaled(40,40, Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
profilePicture->setPixmap(pic);
|
||||||
ui->profilePicture->setPixmap(scaled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onConnected()
|
void Widget::onConnected()
|
||||||
|
|
|
@ -38,6 +38,7 @@ class Core;
|
||||||
class Camera;
|
class Camera;
|
||||||
class FriendListWidget;
|
class FriendListWidget;
|
||||||
class SettingsDialog;
|
class SettingsDialog;
|
||||||
|
class MaskablePixmapWidget;
|
||||||
|
|
||||||
class Widget : public QMainWindow
|
class Widget : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -144,6 +145,7 @@ private:
|
||||||
GenericChatroomWidget* activeChatroomWidget;
|
GenericChatroomWidget* activeChatroomWidget;
|
||||||
FriendListWidget* contactListWidget;
|
FriendListWidget* contactListWidget;
|
||||||
Camera* camera;
|
Camera* camera;
|
||||||
|
MaskablePixmapWidget* profilePicture;
|
||||||
bool notify(QObject *receiver, QEvent *event);
|
bool notify(QObject *receiver, QEvent *event);
|
||||||
bool eventFilter(QObject *, QEvent *event);
|
bool eventFilter(QObject *, QEvent *event);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user