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

Fix circles: Fix rename on creation and graphical bug

This commit is contained in:
TheSpiritXIII 2015-06-16 16:26:20 -04:00 committed by tux3
parent c662c0aa92
commit 9dd277623a
4 changed files with 29 additions and 28 deletions

View File

@ -81,6 +81,7 @@ void CategoryWidget::setExpanded(bool isExpanded)
{
expanded = isExpanded;
listWidget->setVisible(isExpanded);
listWidget->move(1000, 1000);
if (isExpanded)
{
statusPic.setPixmap(QPixmap(":/ui/chatArea/scrollBarDownArrow.svg"));
@ -90,6 +91,15 @@ void CategoryWidget::setExpanded(bool isExpanded)
statusPic.setPixmap(QPixmap(":/ui/chatArea/scrollBarRightArrow.svg"));
}
// The listWidget will recieve a enterEvent for some reason if now visible.
// Using the following, we prevent that.
hide();
show();
// However, the above also removes the hover, so we need to reenable it.
if (underMouse())
setContainerAttribute(Qt::WA_UnderMouse, true); // Simulate hover.
onExpand();
}

View File

@ -21,14 +21,11 @@
#include "friendwidget.h"
#include "friendlistwidget.h"
#include "tool/croppinglabel.h"
#include "src/widget/style.h"
#include "src/persistence/settings.h"
#include "src/friendlist.h"
#include "src/friend.h"
#include "widget.h"
#include <QVariant>
#include <QLabel>
#include <QBoxLayout>
#include <QMouseEvent>
#include <QDragEnterEvent>
@ -38,14 +35,12 @@
QHash<int, CircleWidget*> CircleWidget::circleList;
CircleWidget::CircleWidget(FriendListWidget* parent, int id_)
CircleWidget::CircleWidget(FriendListWidget* parent, int id)
: CategoryWidget(parent)
, id(id_)
, id(id)
{
if (id != -1)
{
setName(Settings::getInstance().getCircleName(id));
}
setName(Settings::getInstance().getCircleName(id));
circleList[id] = this;
connect(nameLabel, &CroppingLabel::editFinished, [this](const QString &newName)
{
@ -59,23 +54,6 @@ CircleWidget::CircleWidget(FriendListWidget* parent, int id_)
nameLabel->minimizeMaximumWidth();
});
bool isNew = false;
auto circleIt = circleList.find(id);
if (circleIt == circleList.end())
{
if (id == -1)
{
isNew = true;
id = Settings::getInstance().addCircle();
nameLabel->setText(tr("Circle #%1").arg(id + 1));
Settings::getInstance().setCircleName(id, nameLabel->fullText());
}
}
circleList[id] = this;
if (isNew)
editName();
setExpanded(Settings::getInstance().getCircleExpanded(id));
updateStatus();
}
@ -85,6 +63,11 @@ CircleWidget::~CircleWidget()
circleList.remove(id);
}
void CircleWidget::editName()
{
CategoryWidget::editName();
}
CircleWidget* CircleWidget::getFromID(int id)
{
auto circleIt = circleList.find(id);
@ -104,7 +87,7 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event)
editName();
else if (selectedItem == removeAction)
{
FriendListWidget* friendList = dynamic_cast<FriendListWidget*>(parentWidget());
FriendListWidget* friendList = static_cast<FriendListWidget*>(parentWidget());
moveFriendWidgets(friendList);
friendList->removeCircleWidget(this);

View File

@ -26,9 +26,10 @@ class CircleWidget final : public CategoryWidget
{
Q_OBJECT
public:
CircleWidget(FriendListWidget* parent = 0, int id = -1);
CircleWidget(FriendListWidget* parent, int id);
~CircleWidget();
void editName();
static CircleWidget* getFromID(int id);
signals:

View File

@ -546,9 +546,12 @@ void FriendListWidget::reDraw()
CircleWidget* FriendListWidget::createCircleWidget(int id)
{
bool isNew = (id == -1);
if (id == -1)
id = Settings::getInstance().addCircle();
// Stop, after it has been created. Code after this is for displaying.
if (mode == Activity)
return nullptr;
@ -557,6 +560,10 @@ CircleWidget* FriendListWidget::createCircleWidget(int id)
connect(this, &FriendListWidget::onCompactChanged, circleWidget, &CircleWidget::onCompactChanged);
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
circleWidget->show(); // Avoid flickering.
if (isNew)
circleWidget->editName();
return circleWidget;
}