diff --git a/src/widget/circlewidget.cpp b/src/widget/circlewidget.cpp index 079682610..e59290c5e 100644 --- a/src/widget/circlewidget.cpp +++ b/src/widget/circlewidget.cpp @@ -137,7 +137,9 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event) dialog->addFriend(friendWidget->friendId, f->getDisplayedName()); } } + dialog->show(); + dialog->ensureSplitterVisible(); } setContainerAttribute(Qt::WA_UnderMouse, false); diff --git a/src/widget/contentdialog.cpp b/src/widget/contentdialog.cpp index dce517f72..220340137 100644 --- a/src/widget/contentdialog.cpp +++ b/src/widget/contentdialog.cpp @@ -245,6 +245,14 @@ int ContentDialog::chatroomWidgetCount() const return friendLayout->friendTotalCount() + groupLayout.getLayout()->count(); } +void ContentDialog::ensureSplitterVisible() +{ + if (splitter->sizes().at(0) == 0) + splitter->setSizes({1, 1}); + + update(); +} + void ContentDialog::cycleContacts(bool forward, bool loop) { Settings::getInstance().getGroupchatPosition(); @@ -374,6 +382,37 @@ void ContentDialog::nextContact() cycleContacts(true); } +bool ContentDialog::event(QEvent* event) +{ + switch (event->type()) + { + case QEvent::WindowActivate: + if (activeChatroomWidget != nullptr) + { + activeChatroomWidget->resetEventFlags(); + activeChatroomWidget->updateStatusLight(); + QString windowTitle = activeChatroomWidget->getName(); + if (!activeChatroomWidget->getStatusString().isNull()) + windowTitle += " (" + activeChatroomWidget->getStatusString() + ")"; + setWindowTitle(windowTitle); + + Friend* frnd = activeChatroomWidget->getFriend(); + + if (frnd) + { + frnd->getFriendWidget()->resetEventFlags(); + frnd->getFriendWidget()->updateStatusLight(); + } + } + + currentDialog = this; + default: + break; + } + + return QWidget::event(event); +} + void ContentDialog::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasFormat("friend")) @@ -407,10 +446,7 @@ void ContentDialog::dropEvent(QDropEvent *event) Friend* contact = FriendList::findFriend(friendId); Widget::getInstance()->addFriendDialog(contact, this); - - // Display friend list after dropping, if not already visible. - if (splitter->sizes().at(0) == 0) - splitter->setSizes({1, 1}); + ensureSplitterVisible(); } else if (event->mimeData()->hasFormat("group")) { @@ -422,10 +458,7 @@ void ContentDialog::dropEvent(QDropEvent *event) Group* contact = GroupList::findGroup(groupId); Widget::getInstance()->addGroupDialog(contact, this); - - // Display friend list after dropping, if not already visible. - if (splitter->sizes().at(0) == 0) - splitter->setSizes({1, 1}); + ensureSplitterVisible(); } } diff --git a/src/widget/contentdialog.h b/src/widget/contentdialog.h index d05bb4b03..40e742c08 100644 --- a/src/widget/contentdialog.h +++ b/src/widget/contentdialog.h @@ -50,6 +50,7 @@ public: bool hasFriendWidget(int friendId, GenericChatroomWidget* chatroomWidget); bool hasGroupWidget(int groupId, GenericChatroomWidget* chatroomWidget); int chatroomWidgetCount() const; + void ensureSplitterVisible(); void cycleContacts(bool forward, bool loop = true); @@ -69,6 +70,7 @@ public slots: void nextContact(); protected: + bool event(QEvent* event) final override; void dragEnterEvent(QDragEnterEvent* event) final override; void dropEvent(QDropEvent* event) final override; void changeEvent(QEvent* event) override; diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 74aa3b268..5653f4101 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -565,7 +565,10 @@ void Widget::onSeparateWindowChanged(bool separate, bool clicked) setMinimumWidth(ui->tooliconsZone->sizeHint().width()); if (clicked) + { + showNormal(); resize(width, height()); + } setWindowTitle(QString()); setActiveToolMenuButton(None); @@ -1401,7 +1404,7 @@ void Widget::removeGroup(Group* g, bool fake) GroupList::removeGroup(g->getGroupId(), fake); Nexus::getCore()->removeGroup(g->getGroupId(), fake); delete g; - if (contentLayout->mainHead->layout()->isEmpty()) + if (contentLayout != nullptr && contentLayout->mainHead->layout()->isEmpty()) onAddClicked(); contactListWidget->reDraw();