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:
parent
a0b312dd97
commit
00022355e8
|
@ -76,9 +76,7 @@ CircleWidget::CircleWidget(FriendListWidget *parent)
|
||||||
lineFrame->setObjectName("line");
|
lineFrame->setObjectName("line");
|
||||||
lineFrame->setFrameShape(QFrame::HLine);
|
lineFrame->setFrameShape(QFrame::HLine);
|
||||||
lineFrame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
lineFrame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||||
qDebug() << lineFrame->sizeHint();
|
|
||||||
lineFrame->resize(0, 0);
|
lineFrame->resize(0, 0);
|
||||||
qDebug() << QSpacerItem(0, 0).sizeHint();
|
|
||||||
|
|
||||||
listLayout = new FriendListLayout();
|
listLayout = new FriendListLayout();
|
||||||
|
|
||||||
|
@ -148,7 +146,10 @@ void CircleWidget::renameCircle()
|
||||||
|
|
||||||
bool CircleWidget::operator<(const CircleWidget& other) const
|
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)
|
void CircleWidget::onCompactChanged(bool _compact)
|
||||||
|
|
|
@ -75,14 +75,16 @@ void FriendListWidget::addCircleWidget(const QString &name)
|
||||||
CircleWidget *circleWidget = new CircleWidget(this);
|
CircleWidget *circleWidget = new CircleWidget(this);
|
||||||
circleWidget->setName(name);
|
circleWidget->setName(name);
|
||||||
circleLayout2.addSortedWidget(circleWidget);
|
circleLayout2.addSortedWidget(circleWidget);
|
||||||
|
connect(this, &FriendListWidget::onCompactChanged, circleWidget, &CircleWidget::onCompactChanged);
|
||||||
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
|
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
|
||||||
//circleLayout->addWidget(circleWidget);
|
//circleLayout->addWidget(circleWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
CircleWidget* FriendListWidget::addCircleWidget(FriendWidget *friendWidget)
|
void FriendListWidget::addCircleWidget(FriendWidget *friendWidget)
|
||||||
{
|
{
|
||||||
CircleWidget *circleWidget = new CircleWidget(this);
|
CircleWidget *circleWidget = new CircleWidget(this);
|
||||||
circleLayout2.addSortedWidget(circleWidget);
|
circleLayout2.addSortedWidget(circleWidget);
|
||||||
|
connect(this, &FriendListWidget::onCompactChanged, circleWidget, &CircleWidget::onCompactChanged);
|
||||||
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
|
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
|
||||||
//circleLayout->addWidget(circleWidget);
|
//circleLayout->addWidget(circleWidget);
|
||||||
if (friendWidget != nullptr)
|
if (friendWidget != nullptr)
|
||||||
|
@ -91,7 +93,6 @@ CircleWidget* FriendListWidget::addCircleWidget(FriendWidget *friendWidget)
|
||||||
circleWidget->toggle();
|
circleWidget->toggle();
|
||||||
}
|
}
|
||||||
circleWidget->show(); // Avoid flickering.
|
circleWidget->show(); // Avoid flickering.
|
||||||
return circleWidget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendListWidget::removeCircleWidget(CircleWidget *widget)
|
void FriendListWidget::removeCircleWidget(CircleWidget *widget)
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
void addGroupWidget(GroupWidget *widget);
|
void addGroupWidget(GroupWidget *widget);
|
||||||
void addFriendWidget(FriendWidget *w, Status s, int circleIndex);
|
void addFriendWidget(FriendWidget *w, Status s, int circleIndex);
|
||||||
void addCircleWidget(const QString &name);
|
void addCircleWidget(const QString &name);
|
||||||
CircleWidget *addCircleWidget(FriendWidget *widget = nullptr);
|
void addCircleWidget(FriendWidget *widget = nullptr);
|
||||||
void removeCircleWidget(CircleWidget *widget);
|
void removeCircleWidget(CircleWidget *widget);
|
||||||
|
|
||||||
void searchChatrooms(const QString &searchString, bool hideOnline = false, bool hideOffline = false, bool hideGroups = false);
|
void searchChatrooms(const QString &searchString, bool hideOnline = false, bool hideOffline = false, bool hideGroups = false);
|
||||||
|
@ -60,9 +60,11 @@ public:
|
||||||
|
|
||||||
void reDraw();
|
void reDraw();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void onCompactChanged(bool compact);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void renameCircleWidget(const QString &newName);
|
void renameCircleWidget(const QString &newName);
|
||||||
//void onCompactChanged(bool compact);
|
|
||||||
void onGroupchatPositionChanged(bool top);
|
void onGroupchatPositionChanged(bool top);
|
||||||
void moveWidget(FriendWidget *w, Status s, bool add = false);
|
void moveWidget(FriendWidget *w, Status s, bool add = false);
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
else if (selectedItem == newCircleAction)
|
else if (selectedItem == newCircleAction)
|
||||||
{
|
{
|
||||||
qDebug() << friendList->parentWidget();
|
qDebug() << friendList->parentWidget();
|
||||||
CircleWidget *newcircle = friendList->addCircleWidget(this);
|
friendList->addCircleWidget(this);
|
||||||
//connect(settingsWidget, &SettingsWidget::compactToggled, newcircle, &CircleWidget::onCompactChanged);
|
|
||||||
}
|
}
|
||||||
else if (groupActions.contains(selectedItem))
|
else if (groupActions.contains(selectedItem))
|
||||||
{
|
{
|
||||||
|
@ -164,6 +163,9 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
}
|
}
|
||||||
else if (circleActions.contains(selectedItem))
|
else if (circleActions.contains(selectedItem))
|
||||||
{
|
{
|
||||||
|
if (circleWidget != nullptr)
|
||||||
|
circleWidget->updateStatus();
|
||||||
|
|
||||||
CircleWidget* circle = circleActions[selectedItem];
|
CircleWidget* circle = circleActions[selectedItem];
|
||||||
circle->addFriendWidget(this, FriendList::findFriend(friendId)->getStatus());
|
circle->addFriendWidget(this, FriendList::findFriend(friendId)->getStatus());
|
||||||
circle->expand();
|
circle->expand();
|
||||||
|
|
|
@ -56,6 +56,7 @@ template <typename T, QBoxLayout::Direction Dir>
|
||||||
void SortingBoxLayout<T, Dir>::addSortedWidget(T* widget)
|
void SortingBoxLayout<T, Dir>::addSortedWidget(T* widget)
|
||||||
{
|
{
|
||||||
int closest = indexOfClosestSortedWidget(widget);
|
int closest = indexOfClosestSortedWidget(widget);
|
||||||
|
qDebug() << closest;
|
||||||
layout->insertWidget(closest, widget);
|
layout->insertWidget(closest, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ QLayout* SortingBoxLayout<T, Dir>::getLayout() const
|
||||||
template <typename T, QBoxLayout::Direction Dir>
|
template <typename T, QBoxLayout::Direction Dir>
|
||||||
int SortingBoxLayout<T, Dir>::indexOfClosestSortedWidget(T* widget)
|
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)
|
while (min < max)
|
||||||
{
|
{
|
||||||
mid = (max - min) / 2 + min;
|
mid = (max - min) / 2 + min;
|
||||||
|
@ -105,9 +106,9 @@ int SortingBoxLayout<T, Dir>::indexOfClosestSortedWidget(T* widget)
|
||||||
assert(atMid != nullptr);
|
assert(atMid != nullptr);
|
||||||
|
|
||||||
if (*widget < *atMid)
|
if (*widget < *atMid)
|
||||||
max = mid;
|
|
||||||
else
|
|
||||||
min = mid + 1;
|
min = mid + 1;
|
||||||
|
else
|
||||||
|
max = mid;
|
||||||
}
|
}
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,7 @@ void Widget::init()
|
||||||
ui->settingsButton->setCheckable(true);
|
ui->settingsButton->setCheckable(true);
|
||||||
setActiveToolMenuButton(Widget::AddButton);
|
setActiveToolMenuButton(Widget::AddButton);
|
||||||
|
|
||||||
|
connect(settingsWidget, &SettingsWidget::compactToggled, contactListWidget, &FriendListWidget::onCompactChanged);
|
||||||
connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged);
|
connect(settingsWidget, &SettingsWidget::groupchatPositionToggled, contactListWidget, &FriendListWidget::onGroupchatPositionChanged);
|
||||||
#if (AUTOUPDATE_ENABLED)
|
#if (AUTOUPDATE_ENABLED)
|
||||||
if (Settings::getInstance().getCheckUpdates())
|
if (Settings::getInstance().getCheckUpdates())
|
||||||
|
@ -1419,8 +1420,7 @@ void Widget::friendListContextMenu(const QPoint &pos)
|
||||||
|
|
||||||
if (chosenAction == addCircleAction)
|
if (chosenAction == addCircleAction)
|
||||||
{
|
{
|
||||||
CircleWidget *newcircle = contactListWidget->addCircleWidget();
|
contactListWidget->addCircleWidget();
|
||||||
connect(settingsWidget, &SettingsWidget::compactToggled, newcircle, &CircleWidget::onCompactChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,11 @@ QWidget#circleWidgetContainer:hover
|
||||||
background-color: @themeLight;
|
background-color: @themeLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget#circleWidgetContainer QLineEdit
|
||||||
|
{
|
||||||
|
background-color: @themeLight;
|
||||||
|
}
|
||||||
|
|
||||||
QWidget#circleWidgetContainer > QLabel#status
|
QWidget#circleWidgetContainer > QLabel#status
|
||||||
{
|
{
|
||||||
font: @small;
|
font: @small;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user