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

Fixed circle compact mode and sort bugs, inline text editing stylesheet

This commit is contained in:
Daniel Hrabovcak 2015-06-01 16:17:39 -04:00 committed by tux3
parent a0b312dd97
commit 00022355e8
7 changed files with 26 additions and 14 deletions

View File

@ -76,9 +76,7 @@ CircleWidget::CircleWidget(FriendListWidget *parent)
lineFrame->setObjectName("line");
lineFrame->setFrameShape(QFrame::HLine);
lineFrame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
qDebug() << lineFrame->sizeHint();
lineFrame->resize(0, 0);
qDebug() << QSpacerItem(0, 0).sizeHint();
listLayout = new FriendListLayout();
@ -148,7 +146,10 @@ void CircleWidget::renameCircle()
bool CircleWidget::operator<(const CircleWidget& other) const
{
return nameLabel->text().localeAwareCompare(other.nameLabel->text()) < 0;
int compareValue = nameLabel->text().localeAwareCompare(other.nameLabel->text());
if (compareValue == 0)
return this < &other; // Consistent ordering.
return compareValue > 0;
}
void CircleWidget::onCompactChanged(bool _compact)

View File

@ -75,14 +75,16 @@ void FriendListWidget::addCircleWidget(const QString &name)
CircleWidget *circleWidget = new CircleWidget(this);
circleWidget->setName(name);
circleLayout2.addSortedWidget(circleWidget);
connect(this, &FriendListWidget::onCompactChanged, circleWidget, &CircleWidget::onCompactChanged);
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
//circleLayout->addWidget(circleWidget);
}
CircleWidget* FriendListWidget::addCircleWidget(FriendWidget *friendWidget)
void FriendListWidget::addCircleWidget(FriendWidget *friendWidget)
{
CircleWidget *circleWidget = new CircleWidget(this);
circleLayout2.addSortedWidget(circleWidget);
connect(this, &FriendListWidget::onCompactChanged, circleWidget, &CircleWidget::onCompactChanged);
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
//circleLayout->addWidget(circleWidget);
if (friendWidget != nullptr)
@ -91,7 +93,6 @@ CircleWidget* FriendListWidget::addCircleWidget(FriendWidget *friendWidget)
circleWidget->toggle();
}
circleWidget->show(); // Avoid flickering.
return circleWidget;
}
void FriendListWidget::removeCircleWidget(CircleWidget *widget)

View File

@ -49,7 +49,7 @@ public:
void addGroupWidget(GroupWidget *widget);
void addFriendWidget(FriendWidget *w, Status s, int circleIndex);
void addCircleWidget(const QString &name);
CircleWidget *addCircleWidget(FriendWidget *widget = nullptr);
void addCircleWidget(FriendWidget *widget = nullptr);
void removeCircleWidget(CircleWidget *widget);
void searchChatrooms(const QString &searchString, bool hideOnline = false, bool hideOffline = false, bool hideGroups = false);
@ -60,9 +60,11 @@ public:
void reDraw();
signals:
void onCompactChanged(bool compact);
public slots:
void renameCircleWidget(const QString &newName);
//void onCompactChanged(bool compact);
void onGroupchatPositionChanged(bool top);
void moveWidget(FriendWidget *w, Status s, bool add = false);

View File

@ -150,8 +150,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
else if (selectedItem == newCircleAction)
{
qDebug() << friendList->parentWidget();
CircleWidget *newcircle = friendList->addCircleWidget(this);
//connect(settingsWidget, &SettingsWidget::compactToggled, newcircle, &CircleWidget::onCompactChanged);
friendList->addCircleWidget(this);
}
else if (groupActions.contains(selectedItem))
{
@ -164,6 +163,9 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
}
else if (circleActions.contains(selectedItem))
{
if (circleWidget != nullptr)
circleWidget->updateStatus();
CircleWidget* circle = circleActions[selectedItem];
circle->addFriendWidget(this, FriendList::findFriend(friendId)->getStatus());
circle->expand();

View File

@ -56,6 +56,7 @@ template <typename T, QBoxLayout::Direction Dir>
void SortingBoxLayout<T, Dir>::addSortedWidget(T* widget)
{
int closest = indexOfClosestSortedWidget(widget);
qDebug() << closest;
layout->insertWidget(closest, widget);
}
@ -97,7 +98,7 @@ QLayout* SortingBoxLayout<T, Dir>::getLayout() const
template <typename T, QBoxLayout::Direction Dir>
int SortingBoxLayout<T, Dir>::indexOfClosestSortedWidget(T* widget)
{
int min = 0, max = layout->count() - 1, mid;
int min = 0, max = layout->count(), mid;
while (min < max)
{
mid = (max - min) / 2 + min;
@ -105,9 +106,9 @@ int SortingBoxLayout<T, Dir>::indexOfClosestSortedWidget(T* widget)
assert(atMid != nullptr);
if (*widget < *atMid)
max = mid;
else
min = mid + 1;
else
max = mid;
}
return min;
}

View File

@ -222,6 +222,7 @@ void Widget::init()
ui->settingsButton->setCheckable(true);
setActiveToolMenuButton(Widget::AddButton);
connect(settingsWidget, &SettingsWidget::compactToggled, contactListWidget, &FriendListWidget::onCompactChanged);
connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged);
#if (AUTOUPDATE_ENABLED)
if (Settings::getInstance().getCheckUpdates())
@ -1419,8 +1420,7 @@ void Widget::friendListContextMenu(const QPoint &pos)
if (chosenAction == addCircleAction)
{
CircleWidget *newcircle = contactListWidget->addCircleWidget();
connect(settingsWidget, &SettingsWidget::compactToggled, newcircle, &CircleWidget::onCompactChanged);
contactListWidget->addCircleWidget();
}
}

View File

@ -13,6 +13,11 @@ QWidget#circleWidgetContainer:hover
background-color: @themeLight;
}
QWidget#circleWidgetContainer QLineEdit
{
background-color: @themeLight;
}
QWidget#circleWidgetContainer > QLabel#status
{
font: @small;