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