1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Minor code cleanup for circles and related

This commit is contained in:
TheSpiritXIII 2015-06-09 13:40:45 -04:00 committed by tux3
parent 8e796a1d8b
commit cc9edf6f90
8 changed files with 14 additions and 22 deletions

View File

@ -51,12 +51,11 @@ CircleWidget::CircleWidget(FriendListWidget *parent, int id_)
container->setLayoutDirection(Qt::LeftToRight); container->setLayoutDirection(Qt::LeftToRight);
// status text // status text
statusLabel = new QLabel("0 / 0", this); statusLabel = new QLabel(this);
statusLabel->setObjectName("status"); statusLabel->setObjectName("status");
statusLabel->setTextFormat(Qt::PlainText); statusLabel->setTextFormat(Qt::PlainText);
arrowLabel = new QLabel(this); statusPic.setPixmap(QPixmap(":/ui/chatArea/scrollBarRightArrow.svg"));
arrowLabel->setPixmap(QPixmap(":/ui/chatArea/scrollBarRightArrow.svg"));
fullLayout = new QVBoxLayout(this); fullLayout = new QVBoxLayout(this);
fullLayout->setSpacing(0); fullLayout->setSpacing(0);
@ -109,6 +108,8 @@ CircleWidget::CircleWidget(FriendListWidget *parent, int id_)
renameCircle(); renameCircle();
setExpanded(Settings::getInstance().getCircleExpanded(id)); setExpanded(Settings::getInstance().getCircleExpanded(id));
updateStatus();
} }
void CircleWidget::addFriendWidget(FriendWidget *w, Status s) void CircleWidget::addFriendWidget(FriendWidget *w, Status s)
@ -124,11 +125,11 @@ void CircleWidget::setExpanded(bool isExpanded)
listWidget->setVisible(isExpanded); listWidget->setVisible(isExpanded);
if (isExpanded) if (isExpanded)
{ {
arrowLabel->setPixmap(QPixmap(":/ui/chatArea/scrollBarDownArrow.svg")); statusPic.setPixmap(QPixmap(":/ui/chatArea/scrollBarDownArrow.svg"));
} }
else else
{ {
arrowLabel->setPixmap(QPixmap(":/ui/chatArea/scrollBarRightArrow.svg")); statusPic.setPixmap(QPixmap(":/ui/chatArea/scrollBarRightArrow.svg"));
} }
Settings::getInstance().setCircleExpanded(id, isExpanded); Settings::getInstance().setCircleExpanded(id, isExpanded);
@ -286,7 +287,7 @@ void CircleWidget::onCompactChanged(bool _compact)
container->setLayout(topLayout); container->setLayout(topLayout);
topLayout->addSpacing(18); topLayout->addSpacing(18);
topLayout->addWidget(arrowLabel); topLayout->addWidget(&statusPic);
topLayout->addSpacing(5); topLayout->addSpacing(5);
topLayout->addWidget(nameLabel, 100); topLayout->addWidget(nameLabel, 100);
topLayout->addWidget(lineFrame, 1); topLayout->addWidget(lineFrame, 1);
@ -306,7 +307,7 @@ void CircleWidget::onCompactChanged(bool _compact)
container->setFixedHeight(55); container->setFixedHeight(55);
container->setLayout(mainLayout); container->setLayout(mainLayout);
topLayout->addWidget(arrowLabel); topLayout->addWidget(&statusPic);
topLayout->addSpacing(10); topLayout->addSpacing(10);
topLayout->addWidget(nameLabel, 1); topLayout->addWidget(nameLabel, 1);
topLayout->addSpacing(5); topLayout->addSpacing(5);
@ -405,7 +406,7 @@ void CircleWidget::updateStatus()
void CircleWidget::updateID(int index) void CircleWidget::updateID(int index)
{ {
// For when a circle gets destroyed, another takes its id. // For when a circle gets destroyed, another takes its id.
// This function updates all friends widgets. // This function updates all friends widgets for this new id.
id = index; id = index;
circleList[id] = this; circleList[id] = this;

View File

@ -72,7 +72,6 @@ private:
FriendListLayout* listLayout; FriendListLayout* listLayout;
QVBoxLayout* fullLayout; QVBoxLayout* fullLayout;
QVBoxLayout* mainLayout = nullptr; QVBoxLayout* mainLayout = nullptr;
QLabel* arrowLabel;
QLabel* statusLabel; QLabel* statusLabel;
QFrame* lineFrame; QFrame* lineFrame;
QWidget* container; QWidget* container;

View File

@ -25,15 +25,13 @@
#include "friendwidget.h" #include "friendwidget.h"
#include "groupwidget.h" #include "groupwidget.h"
#include "circlewidget.h" #include "circlewidget.h"
#include "widget.h"
#include <QGridLayout> #include <QGridLayout>
#include <QMimeData> #include <QMimeData>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QDragLeaveEvent> #include <QDragLeaveEvent>
#include <cassert> #include <cassert>
#include <QDebug>
#include "widget.h"
FriendListWidget::FriendListWidget(Widget* parent, bool groupsOnTop) FriendListWidget::FriendListWidget(Widget* parent, bool groupsOnTop)
: QWidget(parent) : QWidget(parent)
, groupsOnTop(groupsOnTop) , groupsOnTop(groupsOnTop)

View File

@ -19,6 +19,8 @@
#include "src/group.h" #include "src/group.h"
#include "src/grouplist.h" #include "src/grouplist.h"
#include "groupwidget.h" #include "groupwidget.h"
#include "circlewidget.h"
#include "friendlistwidget.h"
#include "src/friendlist.h" #include "src/friendlist.h"
#include "src/friend.h" #include "src/friend.h"
#include "src/core/core.h" #include "src/core/core.h"
@ -37,9 +39,6 @@
#include <QFileDialog> #include <QFileDialog>
#include <QDebug> #include <QDebug>
#include <QInputDialog> #include <QInputDialog>
#include "circlewidget.h"
#include "friendlistwidget.h"
#include <cassert> #include <cassert>
FriendWidget::FriendWidget(int FriendId, QString id) FriendWidget::FriendWidget(int FriendId, QString id)

View File

@ -16,6 +16,7 @@
#define GENERICCHATITEMWIDGET_H #define GENERICCHATITEMWIDGET_H
#include <QFrame> #include <QFrame>
#include <QLabel>
class CroppingLabel; class CroppingLabel;
@ -43,6 +44,7 @@ public:
protected: protected:
CroppingLabel* nameLabel; CroppingLabel* nameLabel;
QLabel statusPic;
private: private:
bool compact; bool compact;

View File

@ -39,11 +39,6 @@ GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
statusMessageLabel->setTextFormat(Qt::PlainText); statusMessageLabel->setTextFormat(Qt::PlainText);
statusMessageLabel->setForegroundRole(QPalette::WindowText); statusMessageLabel->setForegroundRole(QPalette::WindowText);
// name text
nameLabel = new CroppingLabel(this);
nameLabel->setTextFormat(Qt::PlainText);
nameLabel->setForegroundRole(QPalette::WindowText);*/
setAutoFillBackground(true); setAutoFillBackground(true);
reloadTheme(); reloadTheme();
setCompact(compact); setCompact(compact);

View File

@ -76,7 +76,6 @@ protected:
QHBoxLayout* mainLayout = nullptr; QHBoxLayout* mainLayout = nullptr;
QVBoxLayout* textLayout = nullptr; QVBoxLayout* textLayout = nullptr;
MaskablePixmapWidget* avatar; MaskablePixmapWidget* avatar;
QLabel statusPic;
CroppingLabel* statusMessageLabel; CroppingLabel* statusMessageLabel;
bool compact, active; bool compact, active;
}; };

View File

@ -581,7 +581,6 @@ void Widget::reloadHistory()
void Widget::addFriend(int friendId, const QString &userId) void Widget::addFriend(int friendId, const QString &userId)
{ {
qDebug() << "ADDING FRIEND ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;";
ToxId userToxId = ToxId(userId); ToxId userToxId = ToxId(userId);
Friend* newfriend = FriendList::addFriend(friendId, userToxId); Friend* newfriend = FriendList::addFriend(friendId, userToxId);
contactListWidget->addFriendWidget(newfriend->getFriendWidget(),Status::Offline,Settings::getInstance().getFriendCircleID(newfriend->getToxId())); contactListWidget->addFriendWidget(newfriend->getFriendWidget(),Status::Offline,Settings::getInstance().getFriendCircleID(newfriend->getToxId()));