Skip to content

Commit

Permalink
一些显示优化; Windows切换设置窗口崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
eiilpux17 committed Aug 5, 2024
1 parent aeef646 commit f02ba30
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/UI/widget/OMenuWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ class OMenuWidget : public QFrame {
}

private:
Module* module;
Module* module = nullptr;
};
} // namespace UI
1 change: 1 addition & 0 deletions src/UI/window/main/qss/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ QPushButton {
border-radius: 12px;
width: 52px;
height: 52px;
outline: none;
}

QPushButton#chatBtn,
Expand Down
2 changes: 2 additions & 0 deletions src/UI/window/main/src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ OMenuWidget* MainWindow::createChatModule(MainWindow* pWindow) {
auto w = new OMenuWidget(this);
w->setModule(m);
w->setLayout(new QGridLayout());
w->layout()->setContentsMargins(0, 0, 0, 0);
w->layout()->addWidget(m->widget());
return w;
}
Expand All @@ -393,6 +394,7 @@ OMenuWidget* MainWindow::createPlatformModule(MainWindow* pWindow) {
auto w = new OMenuWidget(this);
w->setModule(m);
w->setLayout(new QGridLayout());
w->layout()->setContentsMargins(0, 0, 0, 0);
w->layout()->addWidget(m->widget());

return w;
Expand Down
2 changes: 0 additions & 2 deletions src/modules/im/src/widget/friendlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ FriendListWidget::FriendListWidget(MainLayout* parent, ContentLayout* contentLay

// Prevent QLayout's add child warning before setting the mode.
listLayout = new FriendListLayout(this);
listLayout->removeItem(listLayout->getLayoutOnline());
listLayout->removeItem(listLayout->getLayoutOffline());
setLayout(listLayout);

mode = Settings::getInstance().getFriendSortingMode();
Expand Down
14 changes: 12 additions & 2 deletions src/modules/im/src/widget/genericchatitemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <src/core/core.h>
#include <src/friendlist.h>
#include <src/nexus.h>
#include <QIcon>
#include <QSvgRenderer>
#include <QVariant>
#include "maskablepixmapwidget.h"
#include "src/lib/settings/style.h"
Expand Down Expand Up @@ -75,7 +77,12 @@ void GenericChatItemWidget::searchName(const QString& searchString, bool hide) {
setVisible(!hide && getName().contains(searchString, Qt::CaseInsensitive));
}

void GenericChatItemWidget::setLastMessage(const QString& msg) { lastMessageLabel->setText(msg); }
void GenericChatItemWidget::setLastMessage(const QString& msg) {
if (msg.contains(QChar('\n')))
lastMessageLabel->setText(QString(msg).replace(QChar('\n'), QChar(' ')));
else
lastMessageLabel->setText(msg);
}

void GenericChatItemWidget::updateLastMessage(const Message& m) {
QString prefix;
Expand All @@ -102,7 +109,10 @@ void GenericChatItemWidget::updateStatusLight(Status::Status status, bool event)
auto pix = Status::getIconPath(status, event);
if (pix.isEmpty()) return;

statusPic->setPixmap(QPixmap(pix));
// 图片是svg格式,按照原有逻辑先获取默认尺寸
QSvgRenderer svgrender(pix);
QSize s = svgrender.defaultSize();
statusPic->setPixmap(QIcon(pix).pixmap(this->window()->windowHandle(), s));
}

void GenericChatItemWidget::clearStatusLight() { statusPic->clear(); }
Expand Down

0 comments on commit f02ba30

Please sign in to comment.