mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
unmessification
This commit is contained in:
parent
f7f0f696d8
commit
04f56cc9ec
|
@ -36,19 +36,17 @@ Friend::~Friend()
|
||||||
|
|
||||||
void Friend::setName(QString name)
|
void Friend::setName(QString name)
|
||||||
{
|
{
|
||||||
widget->name.setText(name);
|
widget->setName(name);
|
||||||
widget->name.setToolTip(name); // for overlength names
|
|
||||||
chatForm->setName(name);
|
chatForm->setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Friend::setStatusMessage(QString message)
|
void Friend::setStatusMessage(QString message)
|
||||||
{
|
{
|
||||||
widget->statusMessage.setText(message);
|
widget->setStatusMsg(message);
|
||||||
widget->statusMessage.setToolTip(message); // for overlength messsages
|
|
||||||
chatForm->setStatusMessage(message);
|
chatForm->setStatusMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Friend::getName()
|
QString Friend::getName()
|
||||||
{
|
{
|
||||||
return widget->name.text();
|
return widget->getName();
|
||||||
}
|
}
|
||||||
|
|
1
res.qrc
1
res.qrc
|
@ -145,5 +145,6 @@
|
||||||
<file>translations/uk.qm</file>
|
<file>translations/uk.qm</file>
|
||||||
<file>img/avatar_mask.png</file>
|
<file>img/avatar_mask.png</file>
|
||||||
<file>img/group_2x.png</file>
|
<file>img/group_2x.png</file>
|
||||||
|
<file>ui/chatroomWidgets/genericChatroomWidget.css</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "widget/widget.h"
|
#include "widget/widget.h"
|
||||||
#include "widget/maskablepixmapwidget.h"
|
#include "widget/maskablepixmapwidget.h"
|
||||||
|
#include "widget/croppinglabel.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
|
|
||||||
ChatForm::ChatForm(Friend* chatFriend)
|
ChatForm::ChatForm(Friend* chatFriend)
|
||||||
|
|
|
@ -41,7 +41,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
QFont small;
|
QFont small;
|
||||||
small.setPixelSize(10);
|
small.setPixelSize(10);
|
||||||
|
|
||||||
nameLabel->setText(group->widget->name.text());
|
nameLabel->setText(group->widget->getName());
|
||||||
|
|
||||||
nusersLabel->setFont(Style::getFont(Style::Medium));
|
nusersLabel->setFont(Style::getFont(Style::Medium));
|
||||||
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()));
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "widget/form/chatform.h"
|
#include "widget/form/chatform.h"
|
||||||
#include "widget/maskablepixmapwidget.h"
|
#include "widget/maskablepixmapwidget.h"
|
||||||
|
#include "widget/croppinglabel.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -35,37 +36,9 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
||||||
: friendId(FriendId)
|
: friendId(FriendId)
|
||||||
, isDefaultAvatar{true}
|
, isDefaultAvatar{true}
|
||||||
{
|
{
|
||||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
|
||||||
avatar->setPixmap(QPixmap(":img/contact.png"), Qt::transparent);
|
avatar->setPixmap(QPixmap(":img/contact.png"), Qt::transparent);
|
||||||
|
|
||||||
name.setText(id);
|
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
|
statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
|
||||||
|
nameLabel->setText(id);
|
||||||
// status text
|
|
||||||
QPalette pal;
|
|
||||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::LightGrey));
|
|
||||||
statusMessage.setPalette(pal);
|
|
||||||
statusMessage.setFont(Style::getFont(Style::Medium));
|
|
||||||
|
|
||||||
// name text
|
|
||||||
QPalette pal2;
|
|
||||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::White));
|
|
||||||
name.setPalette(pal2);
|
|
||||||
name.setFont(Style::getFont(Style::Big));
|
|
||||||
|
|
||||||
textLayout.addStretch();
|
|
||||||
textLayout.addWidget(&name);
|
|
||||||
textLayout.addWidget(&statusMessage);
|
|
||||||
textLayout.addStretch();
|
|
||||||
|
|
||||||
layout.addSpacing(20);
|
|
||||||
layout.addWidget(avatar);
|
|
||||||
layout.addSpacing(10);
|
|
||||||
layout.addLayout(&textLayout);
|
|
||||||
layout.addSpacing(10);
|
|
||||||
layout.addWidget(&statusPic);
|
|
||||||
layout.addSpacing(10);
|
|
||||||
layout.activate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
|
@ -77,7 +50,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
QMap<QAction*, Group*> groupActions;
|
QMap<QAction*, Group*> groupActions;
|
||||||
for (Group* group : GroupList::groupList)
|
for (Group* group : GroupList::groupList)
|
||||||
{
|
{
|
||||||
QAction* groupAction = inviteMenu->addAction(group->widget->name.text());
|
QAction* groupAction = inviteMenu->addAction(group->widget->getName());
|
||||||
groupActions[groupAction] = group;
|
groupActions[groupAction] = group;
|
||||||
}
|
}
|
||||||
if (groupActions.isEmpty())
|
if (groupActions.isEmpty())
|
||||||
|
@ -113,16 +86,6 @@ void FriendWidget::setAsActiveChatroom()
|
||||||
{
|
{
|
||||||
setActive(true);
|
setActive(true);
|
||||||
|
|
||||||
// status
|
|
||||||
QPalette pal;
|
|
||||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::MediumGrey));
|
|
||||||
statusMessage.setPalette(pal);
|
|
||||||
|
|
||||||
// name
|
|
||||||
QPalette pal2;
|
|
||||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::DarkGrey));
|
|
||||||
name.setPalette(pal2);
|
|
||||||
|
|
||||||
if (isDefaultAvatar)
|
if (isDefaultAvatar)
|
||||||
avatar->setPixmap(QPixmap(":img/contact_dark.png"), Qt::transparent);
|
avatar->setPixmap(QPixmap(":img/contact_dark.png"), Qt::transparent);
|
||||||
}
|
}
|
||||||
|
@ -131,17 +94,6 @@ void FriendWidget::setAsInactiveChatroom()
|
||||||
{
|
{
|
||||||
setActive(false);
|
setActive(false);
|
||||||
|
|
||||||
// status
|
|
||||||
QPalette pal;
|
|
||||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::LightGrey));
|
|
||||||
statusMessage.setPalette(pal);
|
|
||||||
|
|
||||||
// name
|
|
||||||
QPalette pal2;
|
|
||||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::White));
|
|
||||||
name.setPalette(pal2);
|
|
||||||
QPalette pal3;
|
|
||||||
|
|
||||||
if (isDefaultAvatar)
|
if (isDefaultAvatar)
|
||||||
avatar->setPixmap(QPixmap(":img/contact.png"), Qt::transparent);
|
avatar->setPixmap(QPixmap(":img/contact.png"), Qt::transparent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include "genericchatroomwidget.h"
|
#include "genericchatroomwidget.h"
|
||||||
#include "croppinglabel.h"
|
|
||||||
|
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
class MaskablePixmapWidget;
|
class MaskablePixmapWidget;
|
||||||
|
@ -52,9 +51,6 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int friendId;
|
int friendId;
|
||||||
MaskablePixmapWidget* avatar;
|
|
||||||
QLabel statusPic;
|
|
||||||
CroppingLabel name, statusMessage;
|
|
||||||
bool isDefaultAvatar;
|
bool isDefaultAvatar;
|
||||||
QPoint dragStartPos;
|
QPoint dragStartPos;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,13 +16,14 @@
|
||||||
|
|
||||||
#include "genericchatroomwidget.h"
|
#include "genericchatroomwidget.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
|
#include "widget/maskablepixmapwidget.h"
|
||||||
|
#include "croppinglabel.h"
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QStyle>
|
||||||
|
|
||||||
GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, isActiveWidget(false)
|
|
||||||
{
|
{
|
||||||
setMouseTracking(true);
|
|
||||||
setFixedHeight(55);
|
setFixedHeight(55);
|
||||||
|
|
||||||
setLayout(&layout);
|
setLayout(&layout);
|
||||||
|
@ -32,33 +33,64 @@ GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
||||||
textLayout.setMargin(0);
|
textLayout.setMargin(0);
|
||||||
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
|
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
|
||||||
|
|
||||||
setStyleSheet(QString("background-color: %1").arg(Style::getColor(Style::MediumGrey).name()));
|
// avatar
|
||||||
|
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||||
|
|
||||||
|
// status text
|
||||||
|
statusMessageLabel = new CroppingLabel(this);
|
||||||
|
statusMessageLabel->setObjectName("status");
|
||||||
|
|
||||||
|
// name text
|
||||||
|
nameLabel = new CroppingLabel(this);
|
||||||
|
nameLabel->setObjectName("name");
|
||||||
|
|
||||||
|
textLayout.addStretch();
|
||||||
|
textLayout.addWidget(nameLabel);
|
||||||
|
textLayout.addWidget(statusMessageLabel);
|
||||||
|
textLayout.addStretch();
|
||||||
|
|
||||||
|
layout.addSpacing(20);
|
||||||
|
layout.addWidget(avatar);
|
||||||
|
layout.addSpacing(10);
|
||||||
|
layout.addLayout(&textLayout);
|
||||||
|
layout.addSpacing(10);
|
||||||
|
layout.addWidget(&statusPic);
|
||||||
|
layout.addSpacing(10);
|
||||||
|
layout.activate();
|
||||||
|
|
||||||
|
setProperty("active", false);
|
||||||
|
setStyleSheet(Style::getStylesheet(":/ui/chatroomWidgets/genericChatroomWidget.css"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericChatroomWidget::isActive()
|
bool GenericChatroomWidget::isActive()
|
||||||
{
|
{
|
||||||
return isActiveWidget;
|
return property("active").toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericChatroomWidget::setActive(bool active)
|
void GenericChatroomWidget::setActive(bool active)
|
||||||
{
|
{
|
||||||
isActiveWidget = active;
|
setProperty("active", active);
|
||||||
|
Style::repolish(this);
|
||||||
if (active)
|
|
||||||
setStyleSheet(QString("background-color: %1").arg(Style::getColor(Style::White).name()));
|
|
||||||
else
|
|
||||||
setStyleSheet(QString("background-color: %1").arg(Style::getColor(Style::MediumGrey).name()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericChatroomWidget::leaveEvent(QEvent *)
|
void GenericChatroomWidget::setName(const QString &name)
|
||||||
{
|
{
|
||||||
if (!isActive())
|
nameLabel->setText(name);
|
||||||
setStyleSheet(QString("background-color: %1").arg(Style::getColor(Style::MediumGrey).name()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericChatroomWidget::enterEvent(QEvent *)
|
void GenericChatroomWidget::setStatusMsg(const QString &status)
|
||||||
{
|
{
|
||||||
if (!isActive())
|
statusMessageLabel->setText(status);
|
||||||
setStyleSheet(QString("background-color: %1").arg(Style::getColor(Style::MediumGrey).lighter(120).name()));
|
}
|
||||||
|
|
||||||
|
QString GenericChatroomWidget::getName() const
|
||||||
|
{
|
||||||
|
return nameLabel->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GenericChatroomWidget::getStatusMsg() const
|
||||||
|
{
|
||||||
|
return statusMessageLabel->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent*)
|
void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent*)
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
class CroppingLabel;
|
||||||
|
class MaskablePixmapWidget;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
@ -31,8 +35,6 @@ class GenericChatroomWidget : public QWidget
|
||||||
public:
|
public:
|
||||||
GenericChatroomWidget(QWidget *parent = 0);
|
GenericChatroomWidget(QWidget *parent = 0);
|
||||||
void mouseReleaseEvent (QMouseEvent* event);
|
void mouseReleaseEvent (QMouseEvent* event);
|
||||||
void leaveEvent(QEvent *);
|
|
||||||
void enterEvent(QEvent *);
|
|
||||||
|
|
||||||
virtual void setAsActiveChatroom(){;}
|
virtual void setAsActiveChatroom(){;}
|
||||||
virtual void setAsInactiveChatroom(){;}
|
virtual void setAsInactiveChatroom(){;}
|
||||||
|
@ -43,18 +45,24 @@ public:
|
||||||
bool isActive();
|
bool isActive();
|
||||||
void setActive(bool active);
|
void setActive(bool active);
|
||||||
|
|
||||||
|
void setName(const QString& name);
|
||||||
|
void setStatusMsg(const QString& status);
|
||||||
|
|
||||||
|
QString getName() const;
|
||||||
|
QString getStatusMsg() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void chatroomWidgetClicked(GenericChatroomWidget* widget);
|
void chatroomWidgetClicked(GenericChatroomWidget* widget);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
|
||||||
bool isActiveWidget;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QColor lastColor;
|
QColor lastColor;
|
||||||
QHBoxLayout layout;
|
QHBoxLayout layout;
|
||||||
QVBoxLayout textLayout;
|
QVBoxLayout textLayout;
|
||||||
|
MaskablePixmapWidget* avatar;
|
||||||
|
QLabel statusPic;
|
||||||
|
CroppingLabel *nameLabel, *statusMessageLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GENERICCHATROOMWIDGET_H
|
#endif // GENERICCHATROOMWIDGET_H
|
||||||
|
|
|
@ -30,44 +30,15 @@
|
||||||
GroupWidget::GroupWidget(int GroupId, QString Name)
|
GroupWidget::GroupWidget(int GroupId, QString Name)
|
||||||
: groupId{GroupId}
|
: groupId{GroupId}
|
||||||
{
|
{
|
||||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
|
||||||
avatar->setPixmap(QPixmap(":img/group.png"), Qt::transparent);
|
avatar->setPixmap(QPixmap(":img/group.png"), Qt::transparent);
|
||||||
|
|
||||||
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
||||||
|
nameLabel->setText(Name);
|
||||||
// name
|
|
||||||
QPalette pal2;
|
|
||||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::White));
|
|
||||||
name.setPalette(pal2);
|
|
||||||
name.setText(Name);
|
|
||||||
name.setFont(Style::getFont(Style::Big));
|
|
||||||
|
|
||||||
// status
|
|
||||||
QPalette pal;
|
|
||||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::LightGrey));
|
|
||||||
nusers.setPalette(pal);
|
|
||||||
nusers.setFont(Style::getFont(Style::Medium));
|
|
||||||
|
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
if (g)
|
if (g)
|
||||||
nusers.setText(GroupWidget::tr("%1 users in chat").arg(g->peers.size()));
|
statusMessageLabel->setText(GroupWidget::tr("%1 users in chat").arg(g->peers.size()));
|
||||||
else
|
else
|
||||||
nusers.setText(GroupWidget::tr("0 users in chat"));
|
statusMessageLabel->setText(GroupWidget::tr("0 users in chat"));
|
||||||
|
|
||||||
textLayout.addStretch();
|
|
||||||
textLayout.addWidget(&name);
|
|
||||||
textLayout.addWidget(&nusers);
|
|
||||||
textLayout.addStretch();
|
|
||||||
|
|
||||||
layout.addSpacing(20);
|
|
||||||
layout.addWidget(avatar);
|
|
||||||
layout.addSpacing(10);
|
|
||||||
layout.addLayout(&textLayout);
|
|
||||||
layout.addStretch();
|
|
||||||
layout.addSpacing(10);
|
|
||||||
layout.addWidget(&statusPic);
|
|
||||||
layout.addSpacing(10);
|
|
||||||
layout.activate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
|
@ -91,42 +62,20 @@ void GroupWidget::onUserListChanged()
|
||||||
{
|
{
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
if (g)
|
if (g)
|
||||||
nusers.setText(tr("%1 users in chat").arg(g->nPeers));
|
statusMessageLabel->setText(tr("%1 users in chat").arg(g->nPeers));
|
||||||
else
|
else
|
||||||
nusers.setText(tr("0 users in chat"));
|
statusMessageLabel->setText(tr("0 users in chat"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::setAsActiveChatroom()
|
void GroupWidget::setAsActiveChatroom()
|
||||||
{
|
{
|
||||||
setActive(true);
|
setActive(true);
|
||||||
|
|
||||||
// status
|
|
||||||
QPalette pal;
|
|
||||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::MediumGrey));
|
|
||||||
nusers.setPalette(pal);
|
|
||||||
|
|
||||||
// name
|
|
||||||
QPalette pal2;
|
|
||||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::DarkGrey));
|
|
||||||
name.setPalette(pal2);
|
|
||||||
|
|
||||||
avatar->setPixmap(QPixmap(":img/group_dark.png"), Qt::transparent);
|
avatar->setPixmap(QPixmap(":img/group_dark.png"), Qt::transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupWidget::setAsInactiveChatroom()
|
void GroupWidget::setAsInactiveChatroom()
|
||||||
{
|
{
|
||||||
setActive(false);
|
setActive(false);
|
||||||
|
|
||||||
// status
|
|
||||||
QPalette pal;
|
|
||||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::LightGrey));
|
|
||||||
nusers.setPalette(pal);
|
|
||||||
|
|
||||||
// name
|
|
||||||
QPalette pal2;
|
|
||||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::White));
|
|
||||||
name.setPalette(pal2);
|
|
||||||
|
|
||||||
avatar->setPixmap(QPixmap(":img/group.png"), Qt::transparent);
|
avatar->setPixmap(QPixmap(":img/group.png"), Qt::transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "genericchatroomwidget.h"
|
#include "genericchatroomwidget.h"
|
||||||
|
|
||||||
class MaskablePixmapWidget;
|
|
||||||
|
|
||||||
class GroupWidget : public GenericChatroomWidget
|
class GroupWidget : public GenericChatroomWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -41,8 +39,6 @@ signals:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int groupId;
|
int groupId;
|
||||||
QLabel name, nusers, statusPic;
|
|
||||||
MaskablePixmapWidget* avatar;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GROUPWIDGET_H
|
#endif // GROUPWIDGET_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user