mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Circles: Fix quick switch crash, remove circle crash
This commit is contained in:
parent
5c80d06ee9
commit
7f7ab9a1bc
|
@ -256,9 +256,10 @@ void CategoryWidget::onCompactChanged(bool _compact)
|
|||
topLayout->setSpacing(0);
|
||||
topLayout->setMargin(0);
|
||||
|
||||
setCompact(_compact);
|
||||
(void)_compact;
|
||||
setCompact(true);
|
||||
|
||||
if (isCompact())
|
||||
if (true)
|
||||
{
|
||||
nameLabel->minimizeMaximumWidth();
|
||||
|
||||
|
@ -277,7 +278,7 @@ void CategoryWidget::onCompactChanged(bool _compact)
|
|||
topLayout->addSpacing(5);
|
||||
topLayout->activate();
|
||||
}
|
||||
else
|
||||
/*else
|
||||
{
|
||||
nameLabel->setMaximumWidth(QWIDGETSIZE_MAX);
|
||||
|
||||
|
@ -285,7 +286,7 @@ void CategoryWidget::onCompactChanged(bool _compact)
|
|||
mainLayout->setSpacing(0);
|
||||
mainLayout->setContentsMargins(20, 0, 20, 0);
|
||||
|
||||
container->setFixedHeight(35);
|
||||
container->setFixedHeight(25);
|
||||
container->setLayout(mainLayout);
|
||||
|
||||
topLayout->addWidget(&statusPic);
|
||||
|
@ -300,7 +301,7 @@ void CategoryWidget::onCompactChanged(bool _compact)
|
|||
mainLayout->addWidget(lineFrame);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->activate();
|
||||
}
|
||||
}*/
|
||||
|
||||
Style::repolish(this);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ CircleWidget::CircleWidget(FriendListWidget* parent, int id)
|
|||
|
||||
CircleWidget::~CircleWidget()
|
||||
{
|
||||
circleList.remove(id);
|
||||
if (circleList[id] == this)
|
||||
circleList.remove(id);
|
||||
}
|
||||
|
||||
void CircleWidget::editName()
|
||||
|
@ -96,12 +97,15 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event)
|
|||
|
||||
friendList->removeCircleWidget(this);
|
||||
|
||||
circleList.remove(id);
|
||||
int replacedCircle = Settings::getInstance().removeCircle(id);
|
||||
|
||||
auto circleReplace = circleList.find(replacedCircle);
|
||||
if (circleReplace != circleList.end())
|
||||
circleReplace.value()->updateID(id);
|
||||
else
|
||||
assert(true); // This should never happen.
|
||||
|
||||
circleList.remove(replacedCircle);
|
||||
}
|
||||
setContainerAttribute(Qt::WA_UnderMouse, false);
|
||||
}
|
||||
|
@ -168,6 +172,10 @@ void CircleWidget::updateID(int index)
|
|||
{
|
||||
// For when a circle gets destroyed, another takes its id.
|
||||
// This function updates all friends widgets for this new id.
|
||||
|
||||
if (id == index)
|
||||
return;
|
||||
|
||||
id = index;
|
||||
circleList[id] = this;
|
||||
|
||||
|
|
|
@ -374,10 +374,12 @@ void FriendListWidget::addCircleWidget(FriendWidget* friendWidget)
|
|||
|
||||
if (circleOriginal != nullptr)
|
||||
Widget::getInstance()->searchCircle(circleOriginal);
|
||||
|
||||
}
|
||||
|
||||
Widget::getInstance()->searchCircle(circleWidget);
|
||||
}
|
||||
circleWidget->editName();
|
||||
}
|
||||
|
||||
void FriendListWidget::removeCircleWidget(CircleWidget* widget)
|
||||
|
@ -660,8 +662,6 @@ void FriendListWidget::reDraw()
|
|||
|
||||
CircleWidget* FriendListWidget::createCircleWidget(int id)
|
||||
{
|
||||
bool isNew = (id == -1);
|
||||
|
||||
if (id == -1)
|
||||
id = Settings::getInstance().addCircle();
|
||||
|
||||
|
@ -677,9 +677,6 @@ CircleWidget* FriendListWidget::createCircleWidget(int id)
|
|||
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
|
||||
circleWidget->show(); // Avoid flickering.
|
||||
|
||||
if (isNew)
|
||||
circleWidget->editName();
|
||||
|
||||
return circleWidget;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,17 @@
|
|||
#include <QResizeEvent>
|
||||
#include <QLineEdit>
|
||||
|
||||
class LineEdit : public QLineEdit
|
||||
{
|
||||
public:
|
||||
LineEdit(QWidget* parent = 0) : QLineEdit(parent) {}
|
||||
protected:
|
||||
void focusOutEvent(QFocusEvent *)
|
||||
{
|
||||
emit editingFinished();
|
||||
}
|
||||
};
|
||||
|
||||
CroppingLabel::CroppingLabel(QWidget* parent)
|
||||
: QLabel(parent)
|
||||
, blockPaintEvents(false)
|
||||
|
|
|
@ -1499,13 +1499,17 @@ void Widget::searchContacts()
|
|||
|
||||
void Widget::changeDisplayMode()
|
||||
{
|
||||
filterDisplayGroup->setEnabled(false);
|
||||
|
||||
if (filterDisplayGroup->checkedAction() == filterDisplayActivity)
|
||||
contactListWidget->setMode(FriendListWidget::Activity);
|
||||
else if (filterDisplayGroup->checkedAction() == filterDisplayName)
|
||||
contactListWidget->setMode(FriendListWidget::Name);
|
||||
|
||||
updateFilterText();
|
||||
searchContacts();
|
||||
filterDisplayGroup->setEnabled(true);
|
||||
|
||||
updateFilterText();
|
||||
}
|
||||
|
||||
void Widget::updateFilterText()
|
||||
|
|
Loading…
Reference in New Issue
Block a user