mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
cleanup, applied some of the "Tox User Interface Guidelines"
This commit is contained in:
parent
c260a7a100
commit
a4cd2d34db
|
@ -19,8 +19,9 @@
|
|||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
#include <QVector>
|
||||
|
||||
QString Style::get(const QString &filename)
|
||||
QString Style::getStylesheet(const QString &filename)
|
||||
{
|
||||
if (!Settings::getInstance().getUseNativeStyle())
|
||||
{
|
||||
|
@ -28,8 +29,46 @@ QString Style::get(const QString &filename)
|
|||
if (file.open(QFile::ReadOnly | QFile::Text))
|
||||
return file.readAll();
|
||||
else
|
||||
qWarning() << "Style " << filename << " not found";
|
||||
qWarning() << "Stylesheet " << filename << " not found";
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QColor Style::getColor(Style::ColorPalette entry)
|
||||
{
|
||||
static QColor palette[] = {
|
||||
QColor("#6bc260"),
|
||||
QColor("#cebf44"),
|
||||
QColor("#c84e4e"),
|
||||
QColor("#000000"),
|
||||
QColor("#1c1c1c"),
|
||||
QColor("#414141"),
|
||||
QColor("#d1d1d1"),
|
||||
QColor("#ffffff"),
|
||||
};
|
||||
|
||||
return palette[entry];
|
||||
}
|
||||
|
||||
QFont appFont(int pixelSize, int weight) {
|
||||
auto font = QFont();
|
||||
font.setPixelSize(pixelSize);
|
||||
font.setWeight(weight);
|
||||
return font;
|
||||
}
|
||||
|
||||
QFont Style::getFont(Style::Font font)
|
||||
{
|
||||
static QFont fonts[] = {
|
||||
appFont(14, QFont::Bold),
|
||||
appFont(12, QFont::Normal),
|
||||
appFont(12, QFont::Bold),
|
||||
appFont(11, QFont::Normal),
|
||||
appFont(11, QFont::Bold),
|
||||
appFont(10, QFont::Normal),
|
||||
appFont(10, QFont::Light),
|
||||
};
|
||||
|
||||
return fonts[font];
|
||||
}
|
||||
|
|
30
misc/style.h
30
misc/style.h
|
@ -17,12 +17,40 @@
|
|||
#ifndef STYLE_H
|
||||
#define STYLE_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QFont>
|
||||
|
||||
class QString;
|
||||
|
||||
class Style
|
||||
{
|
||||
public:
|
||||
static QString get(const QString& filename);
|
||||
enum ColorPalette
|
||||
{
|
||||
Green,
|
||||
Yellow,
|
||||
Red,
|
||||
Black,
|
||||
DarkGrey,
|
||||
MediumGrey,
|
||||
LightGrey,
|
||||
White,
|
||||
};
|
||||
|
||||
enum Font
|
||||
{
|
||||
ExtraBig, // 14px, bold
|
||||
Big, // 12px
|
||||
BigBold, // 12px, bold
|
||||
Medium, // 11px
|
||||
MediumBold, // 11px, bold
|
||||
Small, // 10px
|
||||
SmallLight // 10px, light
|
||||
};
|
||||
|
||||
static QString getStylesheet(const QString& filename);
|
||||
static QColor getColor(ColorPalette entry);
|
||||
static QFont getFont(Font font);
|
||||
private:
|
||||
Style();
|
||||
};
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 216 B |
Binary file not shown.
Before Width: | Height: | Size: 263 B After Width: | Height: | Size: 234 B |
Binary file not shown.
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 233 B |
|
@ -35,6 +35,6 @@ QRadioButton::indicator::checked
|
|||
|
||||
QMenu
|
||||
{
|
||||
background-color: rgb(240,240,240); /* sets background of the menu */
|
||||
border: 1px solid;
|
||||
background-color: #414141; /* sets background of the menu */
|
||||
border: 0px solid;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
|
||||
QMenu(parent)
|
||||
{
|
||||
setStyleSheet(Style::get(":/ui/emoticonWidget/emoticonWidget.css"));
|
||||
setStyleSheet(Style::getStylesheet(":/ui/emoticonWidget/emoticonWidget.css"));
|
||||
setLayout(&layout);
|
||||
layout.addWidget(&stack);
|
||||
|
||||
|
|
|
@ -34,18 +34,25 @@
|
|||
#include "core.h"
|
||||
#include "widget/widget.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include "style.h"
|
||||
|
||||
ChatForm::ChatForm(Friend* chatFriend)
|
||||
: f(chatFriend)
|
||||
{
|
||||
nameLabel->setText(f->getName());
|
||||
avatar->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
|
||||
avatar->setPixmap(QPixmap(":/img/contact_dark.png"), Qt::transparent);
|
||||
|
||||
statusMessageLabel = new CroppingLabel();
|
||||
statusMessageLabel->setFont(Style::getFont(Style::Medium));
|
||||
QPalette pal; pal.setColor(QPalette::WindowText, Style::getColor(Style::MediumGrey));
|
||||
statusMessageLabel->setPalette(pal);
|
||||
|
||||
netcam = new NetCamView();
|
||||
|
||||
headTextLayout->addWidget(statusMessageLabel);
|
||||
headTextLayout->addStretch();
|
||||
headTextLayout->setSpacing(0);
|
||||
|
||||
connect(Core::getInstance(), &Core::fileSendStarted, this, &ChatForm::startFileSend);
|
||||
connect(Core::getInstance(), &Core::videoFrameReceived, netcam, &NetCamView::updateDisplay);
|
||||
|
@ -507,5 +514,5 @@ void ChatForm::onAvatarRemoved(int FriendId)
|
|||
if (FriendId != f->friendId)
|
||||
return;
|
||||
|
||||
avatar->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
avatar->setPixmap(QPixmap(":/img/contact_dark.png"), Qt::transparent);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
|||
headWidget = new QWidget();
|
||||
|
||||
nameLabel = new CroppingLabel();
|
||||
nameLabel->setFont(Style::getFont(Style::MediumBold));
|
||||
QPalette pal; pal.setColor(QPalette::WindowText, Style::getColor(Style::DarkGrey));
|
||||
nameLabel->setPalette(pal);
|
||||
|
||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout();
|
||||
headTextLayout = new QVBoxLayout();
|
||||
|
@ -43,8 +47,8 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
|||
QVBoxLayout *footButtonsSmall = new QVBoxLayout(), *volMicLayout = new QVBoxLayout();
|
||||
|
||||
chatWidget = new ChatAreaWidget();
|
||||
chatWidget->document()->setDefaultStyleSheet(Style::get(":ui/chatArea/innerStyle.css"));
|
||||
chatWidget->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css"));
|
||||
chatWidget->document()->setDefaultStyleSheet(Style::getStylesheet(":ui/chatArea/innerStyle.css"));
|
||||
chatWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatArea.css"));
|
||||
|
||||
msgEdit = new ChatTextEdit();
|
||||
|
||||
|
@ -63,25 +67,25 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
|||
|
||||
footButtonsSmall->setSpacing(2);
|
||||
|
||||
msgEdit->setStyleSheet(Style::get(":/ui/msgEdit/msgEdit.css"));
|
||||
msgEdit->setStyleSheet(Style::getStylesheet(":/ui/msgEdit/msgEdit.css"));
|
||||
msgEdit->setFixedHeight(50);
|
||||
msgEdit->setFrameStyle(QFrame::NoFrame);
|
||||
|
||||
sendButton->setStyleSheet(Style::get(":/ui/sendButton/sendButton.css"));
|
||||
fileButton->setStyleSheet(Style::get(":/ui/fileButton/fileButton.css"));
|
||||
emoteButton->setStyleSheet(Style::get(":/ui/emoteButton/emoteButton.css"));
|
||||
sendButton->setStyleSheet(Style::getStylesheet(":/ui/sendButton/sendButton.css"));
|
||||
fileButton->setStyleSheet(Style::getStylesheet(":/ui/fileButton/fileButton.css"));
|
||||
emoteButton->setStyleSheet(Style::getStylesheet(":/ui/emoteButton/emoteButton.css"));
|
||||
|
||||
callButton->setObjectName("green");
|
||||
callButton->setStyleSheet(Style::get(":/ui/callButton/callButton.css"));
|
||||
callButton->setStyleSheet(Style::getStylesheet(":/ui/callButton/callButton.css"));
|
||||
|
||||
videoButton->setObjectName("green");
|
||||
videoButton->setStyleSheet(Style::get(":/ui/videoButton/videoButton.css"));
|
||||
videoButton->setStyleSheet(Style::getStylesheet(":/ui/videoButton/videoButton.css"));
|
||||
|
||||
QString volButtonStylesheet = Style::get(":/ui/volButton/volButton.css");
|
||||
QString volButtonStylesheet = Style::getStylesheet(":/ui/volButton/volButton.css");
|
||||
volButton->setObjectName("green");
|
||||
volButton->setStyleSheet(volButtonStylesheet);
|
||||
|
||||
QString micButtonStylesheet = Style::get(":/ui/micButton/micButton.css");
|
||||
QString micButtonStylesheet = Style::getStylesheet(":/ui/micButton/micButton.css");
|
||||
micButton->setObjectName("green");
|
||||
micButton->setStyleSheet(micButtonStylesheet);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "widget/croppinglabel.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include "core.h"
|
||||
#include "style.h"
|
||||
#include <QPushButton>
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
|
@ -41,9 +42,13 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
|||
small.setPixelSize(10);
|
||||
|
||||
nameLabel->setText(group->widget->name.text());
|
||||
nusersLabel->setFont(small);
|
||||
|
||||
nusersLabel->setFont(Style::getFont(Style::Medium));
|
||||
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
||||
avatar->setPixmap(QPixmap(":/img/group_dark.png"));
|
||||
QPalette pal; pal.setColor(QPalette::WindowText, Style::getColor(Style::MediumGrey));
|
||||
nusersLabel->setPalette(pal);
|
||||
|
||||
avatar->setPixmap(QPixmap(":/img/group_dark.png"), Qt::transparent);
|
||||
|
||||
QString names;
|
||||
for (QString& s : group->peers)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "core.h"
|
||||
#include "widget/form/chatform.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include "style.h"
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QDrag>
|
||||
|
@ -31,7 +32,8 @@
|
|||
#include <QBitmap>
|
||||
|
||||
FriendWidget::FriendWidget(int FriendId, QString id)
|
||||
: friendId(FriendId), isDefaultAvatar{true}
|
||||
: friendId(FriendId)
|
||||
, isDefaultAvatar{true}
|
||||
{
|
||||
setMouseTracking(true);
|
||||
setAutoFillBackground(true);
|
||||
|
@ -45,22 +47,28 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
|
||||
|
||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
avatar->setPixmap(QPixmap(":img/contact_dark.png"));
|
||||
avatar->setPixmap(QPixmap(":img/contact.png"), Qt::transparent);
|
||||
|
||||
name.setText(id);
|
||||
//statusPic.setAlignment(Qt::AlignHCenter);
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
statusMessage.setFont(small);
|
||||
|
||||
// status text
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::WindowText,Qt::gray);
|
||||
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,Qt::white);
|
||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::White));
|
||||
name.setPalette(pal2);
|
||||
name.setFont(Style::getFont(Style::Big));
|
||||
|
||||
// background
|
||||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
|
||||
this->setPalette(pal3);
|
||||
pal3.setColor(QPalette::Background, Style::getColor(Style::MediumGrey));
|
||||
setPalette(pal3);
|
||||
|
||||
textLayout.addStretch();
|
||||
textLayout.addWidget(&name);
|
||||
|
@ -69,13 +77,11 @@ FriendWidget::FriendWidget(int FriendId, QString id)
|
|||
|
||||
layout.addSpacing(20);
|
||||
layout.addWidget(avatar);
|
||||
layout.addSpacing(5);
|
||||
layout.addSpacing(10);
|
||||
layout.addLayout(&textLayout);
|
||||
layout.addSpacing(5);
|
||||
layout.addSpacing(10);
|
||||
layout.addWidget(&statusPic);
|
||||
layout.addSpacing(5);
|
||||
|
||||
isActiveWidget = 0;
|
||||
layout.addSpacing(10);
|
||||
|
||||
layout.invalidate();
|
||||
layout.update();
|
||||
|
@ -126,38 +132,39 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
|
||||
void FriendWidget::setAsActiveChatroom()
|
||||
{
|
||||
isActiveWidget = 1;
|
||||
setActive(true);
|
||||
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
statusMessage.setFont(small);
|
||||
// status
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::WindowText,Qt::darkGray);
|
||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::MediumGrey));
|
||||
statusMessage.setPalette(pal);
|
||||
|
||||
// name
|
||||
QPalette pal2;
|
||||
pal2.setColor(QPalette::WindowText,Qt::black);
|
||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::DarkGrey));
|
||||
name.setPalette(pal2);
|
||||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, Qt::white);
|
||||
this->setPalette(pal3);
|
||||
|
||||
if (isDefaultAvatar)
|
||||
avatar->setPixmap(QPixmap(":img/contact_dark.png"), Qt::transparent);
|
||||
}
|
||||
|
||||
void FriendWidget::setAsInactiveChatroom()
|
||||
{
|
||||
isActiveWidget = 0;
|
||||
setActive(false);
|
||||
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
statusMessage.setFont(small);
|
||||
// status
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::WindowText,Qt::gray);
|
||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::LightGrey));
|
||||
statusMessage.setPalette(pal);
|
||||
|
||||
// name
|
||||
QPalette pal2;
|
||||
pal2.setColor(QPalette::WindowText,Qt::white);
|
||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::White));
|
||||
name.setPalette(pal2);
|
||||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
|
||||
this->setPalette(pal3);
|
||||
|
||||
if (isDefaultAvatar)
|
||||
avatar->setPixmap(QPixmap(":img/contact.png"), Qt::transparent);
|
||||
}
|
||||
|
||||
void FriendWidget::updateStatusLight()
|
||||
|
@ -211,7 +218,7 @@ void FriendWidget::onAvatarRemoved(int FriendId)
|
|||
return;
|
||||
|
||||
isDefaultAvatar = true;
|
||||
avatar->setPixmap(QPixmap(":img/contact_dark.png"));
|
||||
avatar->setPixmap(QPixmap(":img/contact.png"), Qt::transparent);
|
||||
}
|
||||
|
||||
void FriendWidget::mousePressEvent(QMouseEvent *ev)
|
||||
|
|
|
@ -15,55 +15,55 @@
|
|||
*/
|
||||
|
||||
#include "genericchatroomwidget.h"
|
||||
#include "style.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
GenericChatroomWidget::GenericChatroomWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, isActiveWidget(false)
|
||||
{
|
||||
}
|
||||
|
||||
int GenericChatroomWidget::isActive()
|
||||
bool GenericChatroomWidget::isActive()
|
||||
{
|
||||
return isActiveWidget;
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::mousePressEvent(QMouseEvent *event)
|
||||
void GenericChatroomWidget::setActive(bool active)
|
||||
{
|
||||
if ((event->buttons() & Qt::LeftButton) == Qt::LeftButton)
|
||||
isActiveWidget = active;
|
||||
|
||||
if (active)
|
||||
{
|
||||
if (isActive())
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(250,250,250,255));
|
||||
this->setPalette(pal);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(85,85,85,255));
|
||||
this->setPalette(pal);
|
||||
}
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, Style::getColor(Style::White));
|
||||
setPalette(pal);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, Style::getColor(Style::MediumGrey));
|
||||
setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::leaveEvent(QEvent *)
|
||||
{
|
||||
if (isActive() != 1)
|
||||
if (!isActive())
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, lastColor);
|
||||
this->setPalette(pal);
|
||||
pal.setColor(QPalette::Background, Style::getColor(Style::MediumGrey));
|
||||
setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
void GenericChatroomWidget::enterEvent(QEvent *)
|
||||
{
|
||||
if (isActive() != 1)
|
||||
if (!isActive())
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor(75,75,75,255));
|
||||
lastColor = this->palette().background().color();
|
||||
this->setPalette(pal);
|
||||
pal.setColor(QPalette::Background, Style::getColor(Style::MediumGrey).lighter(120));
|
||||
setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ class GenericChatroomWidget : public QWidget
|
|||
Q_OBJECT
|
||||
public:
|
||||
GenericChatroomWidget(QWidget *parent = 0);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent (QMouseEvent* event);
|
||||
void leaveEvent(QEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
|
@ -41,15 +40,18 @@ public:
|
|||
virtual void setChatForm(Ui::MainWindow &){;}
|
||||
virtual void resetEventFlags(){;}
|
||||
|
||||
int isActive();
|
||||
bool isActive();
|
||||
void setActive(bool active);
|
||||
|
||||
signals:
|
||||
void chatroomWidgetClicked(GenericChatroomWidget* widget);
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
bool isActiveWidget;
|
||||
|
||||
protected:
|
||||
int isActiveWidget;
|
||||
QColor lastColor;
|
||||
QHBoxLayout layout;
|
||||
QVBoxLayout textLayout;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "misc/settings.h"
|
||||
#include "widget/form/groupchatform.h"
|
||||
#include "widget/maskablepixmapwidget.h"
|
||||
#include "style.h"
|
||||
#include <QPalette>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
|
@ -40,21 +41,28 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
setLayoutDirection(Qt::LeftToRight); // parent might have set Qt::RightToLeft
|
||||
|
||||
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.png");
|
||||
avatar->setPixmap(QPixmap(":img/group_dark.png"));
|
||||
avatar->setPixmap(QPixmap(":img/group.png"), Qt::transparent);
|
||||
|
||||
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
|
||||
name.setText(Name);
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
nusers.setFont(small);
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::WindowText,Qt::gray);
|
||||
nusers.setPalette(pal);
|
||||
|
||||
// name
|
||||
QPalette pal2;
|
||||
pal2.setColor(QPalette::WindowText,Qt::white);
|
||||
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));
|
||||
|
||||
// background
|
||||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
|
||||
pal3.setColor(QPalette::Background, Style::getColor(Style::MediumGrey));
|
||||
this->setPalette(pal3);
|
||||
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
if (g)
|
||||
nusers.setText(GroupWidget::tr("%1 users in chat").arg(g->peers.size()));
|
||||
|
@ -68,14 +76,12 @@ GroupWidget::GroupWidget(int GroupId, QString Name)
|
|||
|
||||
layout.addSpacing(20);
|
||||
layout.addWidget(avatar);
|
||||
layout.addSpacing(5);
|
||||
layout.addSpacing(10);
|
||||
layout.addLayout(&textLayout);
|
||||
layout.addStretch();
|
||||
layout.addSpacing(5);
|
||||
layout.addSpacing(10);
|
||||
layout.addWidget(&statusPic);
|
||||
layout.addSpacing(5);
|
||||
|
||||
isActiveWidget = 0;
|
||||
layout.addSpacing(10);
|
||||
}
|
||||
|
||||
void GroupWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||
|
@ -106,40 +112,36 @@ void GroupWidget::onUserListChanged()
|
|||
|
||||
void GroupWidget::setAsActiveChatroom()
|
||||
{
|
||||
isActiveWidget = 1;
|
||||
setActive(true);
|
||||
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
nusers.setFont(small);
|
||||
// status
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::WindowText,Qt::darkGray);
|
||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::MediumGrey));
|
||||
nusers.setPalette(pal);
|
||||
|
||||
// name
|
||||
QPalette pal2;
|
||||
pal2.setColor(QPalette::WindowText,Qt::black);
|
||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::DarkGrey));
|
||||
name.setPalette(pal2);
|
||||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, Qt::white);
|
||||
this->setPalette(pal3);
|
||||
avatar->setPixmap(QPixmap(":img/group_dark.png"));
|
||||
|
||||
avatar->setPixmap(QPixmap(":img/group_dark.png"), Qt::transparent);
|
||||
}
|
||||
|
||||
void GroupWidget::setAsInactiveChatroom()
|
||||
{
|
||||
isActiveWidget = 0;
|
||||
setActive(false);
|
||||
|
||||
QFont small;
|
||||
small.setPixelSize(10);
|
||||
nusers.setFont(small);
|
||||
// status
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::WindowText,Qt::gray);
|
||||
pal.setColor(QPalette::WindowText, Style::getColor(Style::LightGrey));
|
||||
nusers.setPalette(pal);
|
||||
|
||||
// name
|
||||
QPalette pal2;
|
||||
pal2.setColor(QPalette::WindowText,Qt::white);
|
||||
pal2.setColor(QPalette::WindowText, Style::getColor(Style::White));
|
||||
name.setPalette(pal2);
|
||||
QPalette pal3;
|
||||
pal3.setColor(QPalette::Background, QColor(65,65,65,255));
|
||||
this->setPalette(pal3);
|
||||
avatar->setPixmap(QPixmap(":img/group_dark.png"));
|
||||
|
||||
avatar->setPixmap(QPixmap(":img/group.png"), Qt::transparent);
|
||||
}
|
||||
|
||||
void GroupWidget::updateStatusLight()
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
#include "maskablepixmapwidget.h"
|
||||
#include <QPainter>
|
||||
|
||||
MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName, bool autopickBackground)
|
||||
MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName)
|
||||
: QWidget(parent)
|
||||
, backgroundColor(Qt::white)
|
||||
, clickable(false)
|
||||
, autoBackground(autopickBackground)
|
||||
{
|
||||
setFixedSize(size);
|
||||
|
||||
|
@ -38,29 +37,30 @@ void MaskablePixmapWidget::autopickBackground()
|
|||
if (pic.isNull())
|
||||
return;
|
||||
|
||||
qreal r = 0.0f;
|
||||
qreal g = 0.0f;
|
||||
qreal b = 0.0f;
|
||||
float weight = 1.0f;
|
||||
int r = 0;
|
||||
int g = 0;
|
||||
int b = 0;
|
||||
int weight = 0;
|
||||
|
||||
for (int x=0;x<pic.width();++x)
|
||||
{
|
||||
for (int y=0;y<pic.height();++y)
|
||||
{
|
||||
QRgb color = pic.pixel(x,y);
|
||||
r += qRed(color) / 255.0f;
|
||||
g += qGreen(color) / 255.0f;
|
||||
b += qBlue(color) / 255.0f;
|
||||
r += qRed(color);
|
||||
g += qGreen(color);
|
||||
b += qBlue(color);
|
||||
|
||||
weight += qAlpha(color) / 255.0f;
|
||||
weight += qAlpha(color);
|
||||
}
|
||||
}
|
||||
|
||||
weight = qMax(1, weight / 255);
|
||||
r /= weight;
|
||||
g /= weight;
|
||||
b /= weight;
|
||||
|
||||
QColor color = QColor::fromRgbF(r,g,b);
|
||||
QColor color = QColor::fromRgb(r,g,b);
|
||||
backgroundColor = QColor::fromRgb(0xFFFFFF ^ color.rgb());
|
||||
|
||||
update();
|
||||
|
@ -82,14 +82,23 @@ void MaskablePixmapWidget::setClickable(bool clickable)
|
|||
unsetCursor();
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::setPixmap(const QPixmap &pmap, QColor background)
|
||||
{
|
||||
if (!pmap.isNull())
|
||||
{
|
||||
pixmap = pmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
backgroundColor = background;
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::setPixmap(const QPixmap &pmap)
|
||||
{
|
||||
if (!pmap.isNull())
|
||||
{
|
||||
pixmap = pmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
|
||||
if (autoBackground)
|
||||
autopickBackground();
|
||||
autopickBackground();
|
||||
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -23,11 +23,12 @@ class MaskablePixmapWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName = QString(), bool autopickBackground = true);
|
||||
MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName = QString());
|
||||
|
||||
void autopickBackground();
|
||||
void setBackground(QColor color);
|
||||
void setClickable(bool clickable);
|
||||
void setPixmap(const QPixmap &pmap, QColor background);
|
||||
void setPixmap(const QPixmap &pmap);
|
||||
QPixmap getPixmap() const;
|
||||
|
||||
|
@ -45,7 +46,6 @@ private:
|
|||
QString maskName;
|
||||
QColor backgroundColor;
|
||||
bool clickable;
|
||||
bool autoBackground;
|
||||
};
|
||||
|
||||
#endif // MASKABLEPIXMAPWIDGET_H
|
||||
|
|
|
@ -68,17 +68,17 @@ Widget::Widget(QWidget *parent)
|
|||
this->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
ui->friendList->setObjectName("friendList");
|
||||
ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));
|
||||
ui->friendList->setStyleSheet(Style::getStylesheet(":ui/friendList/friendList.css"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setObjectName("activeWindow");
|
||||
this->setStyleSheet(Style::get(":ui/window/window.css"));
|
||||
this->setStyleSheet(Style::getStylesheet(":ui/window/window.css"));
|
||||
ui->statusPanel->setStyleSheet(QString(""));
|
||||
ui->friendList->setStyleSheet(QString(""));
|
||||
|
||||
ui->friendList->setObjectName("friendList");
|
||||
ui->friendList->setStyleSheet(Style::get(":ui/friendList/friendList.css"));
|
||||
ui->friendList->setStyleSheet(Style::getStylesheet(":ui/friendList/friendList.css"));
|
||||
|
||||
ui->tbMenu->setIcon(QIcon(":ui/window/applicationIcon.png"));
|
||||
ui->pbMin->setObjectName("minimizeButton");
|
||||
|
@ -116,6 +116,7 @@ Widget::Widget(QWidget *parent)
|
|||
profilePicture->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||
profilePicture->setClickable(true);
|
||||
ui->horizontalLayout_3->insertWidget(0,profilePicture);
|
||||
ui->horizontalLayout_3->insertSpacing(1, 7);
|
||||
|
||||
ui->mainContent->setLayout(new QVBoxLayout());
|
||||
ui->mainHead->setLayout(new QVBoxLayout());
|
||||
|
@ -129,13 +130,16 @@ Widget::Widget(QWidget *parent)
|
|||
ui->nameLabel->setEditable(true);
|
||||
ui->statusLabel->setEditable(true);
|
||||
|
||||
ui->statusLabel->setFont(Style::getFont(Style::Medium));
|
||||
ui->nameLabel->setFont(Style::getFont(Style::ExtraBig));
|
||||
|
||||
// delay setting username and message until Core inits
|
||||
//ui->nameLabel->setText(core->getUsername());
|
||||
ui->nameLabel->setStyleSheet("QLabel { color : white; font-size: 11pt; font-weight:bold;}");
|
||||
//ui->statusLabel->setText(core->getStatusMessage());
|
||||
ui->statusLabel->setStyleSheet("QLabel { color : white; font-size: 8pt;}");
|
||||
|
||||
ui->statusButton->setStyleSheet(Style::get(":/ui/statusButton/statusButton.css"));
|
||||
ui->statusButton->setStyleSheet(Style::getStylesheet(":/ui/statusButton/statusButton.css"));
|
||||
|
||||
QMenu *statusButtonMenu = new QMenu(ui->statusButton);
|
||||
QAction* setStatusOnline = statusButtonMenu->addAction(Widget::tr("Online","Button to set your status to 'Online'"));
|
||||
|
|
Loading…
Reference in New Issue
Block a user