From 2e7cbb6bf538876af98bf129275de6de35589dd4 Mon Sep 17 00:00:00 2001 From: Zhang TingAn Date: Mon, 20 Jan 2025 17:13:01 +0800 Subject: [PATCH] feat: [chat] modified ui of chat change text & icons & answer component Log: as title --- .../aimanager/option/addmodeldialog.cpp | 3 ++ .../codegeex/builtin/icons/uc_openai_16px.svg | 16 ++++++++++ src/plugins/codegeex/codegeex.qrc | 1 + src/plugins/codegeex/codegeexmanager.cpp | 6 ++++ src/plugins/codegeex/codegeexmanager.h | 2 ++ src/plugins/codegeex/widgets/codegeexwidget.h | 1 - src/plugins/codegeex/widgets/intropage.cpp | 29 ++++++------------- src/plugins/codegeex/widgets/intropage.h | 1 - .../codegeex/widgets/messagecomponent.cpp | 7 +++-- src/services/window/windowelement.h | 2 +- 10 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 src/plugins/codegeex/builtin/icons/uc_openai_16px.svg diff --git a/src/plugins/aimanager/option/addmodeldialog.cpp b/src/plugins/aimanager/option/addmodeldialog.cpp index 8daaa2831..d36ebd9df 100644 --- a/src/plugins/aimanager/option/addmodeldialog.cpp +++ b/src/plugins/aimanager/option/addmodeldialog.cpp @@ -147,6 +147,9 @@ void AddModelDialogPrivate::slotAddModel() return; } newLLMInfo.type = cbLLMType->currentData().value(); + if (newLLMInfo.type == LLMType::OPENAI) + newLLMInfo.icon = QIcon::fromTheme("uc_openai"); + newLLMInfo.modelPath = leApiUrl->text(); if (newLLMInfo.modelPath.isEmpty()) { leApiUrl->showAlertMessage(AddModelDialog::tr("This field cannot be empty.")); diff --git a/src/plugins/codegeex/builtin/icons/uc_openai_16px.svg b/src/plugins/codegeex/builtin/icons/uc_openai_16px.svg new file mode 100644 index 000000000..6bc564872 --- /dev/null +++ b/src/plugins/codegeex/builtin/icons/uc_openai_16px.svg @@ -0,0 +1,16 @@ + + + ICON /ai/common + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/plugins/codegeex/codegeex.qrc b/src/plugins/codegeex/codegeex.qrc index 2dbf05e09..4f0df599b 100644 --- a/src/plugins/codegeex/codegeex.qrc +++ b/src/plugins/codegeex/codegeex.qrc @@ -9,6 +9,7 @@ builtin/icons/codegeex_anwser_icon_24px.svg builtin/icons/codegeex_user_30px.svg builtin/icons/codegeex_logo_24px.svg + builtin/icons/uc_openai_16px.svg builtin/texts/codegeex_indicate_16px.svg builtin/texts/codegeex_advice_16px.svg builtin/texts/codegeex_comment_16px.svg diff --git a/src/plugins/codegeex/codegeexmanager.cpp b/src/plugins/codegeex/codegeexmanager.cpp index 6b1c1e808..c3acb97bf 100644 --- a/src/plugins/codegeex/codegeexmanager.cpp +++ b/src/plugins/codegeex/codegeexmanager.cpp @@ -93,6 +93,11 @@ AbstractLLM *CodeGeeXManager::getCurrentLLM() const return chatLLM; } +LLMInfo CodeGeeXManager::getCurrentLLMInfo() const +{ + return currentInfo; +} + void CodeGeeXManager::setLocale(CodeGeeX::Locale locale) { this->locale = locale; @@ -338,6 +343,7 @@ void CodeGeeXManager::onLLMChanged(const LLMInfo &llmInfo) chatLLM = selectedLLM; initLLM(chatLLM); + currentInfo = llmInfo; emit llmChanged(llmInfo); } diff --git a/src/plugins/codegeex/codegeexmanager.h b/src/plugins/codegeex/codegeexmanager.h index 1d4c5813d..44cf9a691 100644 --- a/src/plugins/codegeex/codegeexmanager.h +++ b/src/plugins/codegeex/codegeexmanager.h @@ -53,6 +53,7 @@ class CodeGeeXManager : public QObject bool condaHasInstalled(); AbstractLLM *getCurrentLLM() const; + LLMInfo getCurrentLLMInfo() const; void setLocale(CodeGeeX::Locale locale); @@ -148,6 +149,7 @@ public Q_SLOTS: int answerFlag = 0; // use to identify every single answer AbstractLLM *chatLLM { nullptr }; + LLMInfo currentInfo; AbstractLLM *liteLLM { nullptr }; //codegeex Lite. CodeGeeX::Locale locale { CodeGeeX::Zh }; }; diff --git a/src/plugins/codegeex/widgets/codegeexwidget.h b/src/plugins/codegeex/widgets/codegeexwidget.h index f76eadb31..1124ab343 100644 --- a/src/plugins/codegeex/widgets/codegeexwidget.h +++ b/src/plugins/codegeex/widgets/codegeexwidget.h @@ -20,7 +20,6 @@ class CodeGeeXWidget : public DTK_WIDGET_NAMESPACE::DFrame explicit CodeGeeXWidget(QWidget *parent = nullptr); public Q_SLOTS: - void onLogOut(); void onNewSessionCreated(); void onCloseHistoryWidget(); void onShowHistoryWidget(); diff --git a/src/plugins/codegeex/widgets/intropage.cpp b/src/plugins/codegeex/widgets/intropage.cpp index 68f624a8e..446f97087 100644 --- a/src/plugins/codegeex/widgets/intropage.cpp +++ b/src/plugins/codegeex/widgets/intropage.cpp @@ -66,7 +66,6 @@ void IntroPage::initUI() mainLayout->addStretch(1); initSuggestContent(); mainLayout->addStretch(1); - initLogoutButton(); } void IntroPage::initLogo() @@ -76,10 +75,11 @@ void IntroPage::initLogo() logoLayout->setSpacing(20); qobject_cast(layout())->addLayout(logoLayout); - DLabel *logo = new DLabel(this); - logo->setAlignment(Qt::AlignHCenter); - logo->setPixmap(QIcon::fromTheme("codegeex_anwser_icon").pixmap(50)); - logoLayout->addWidget(logo); +// DLabel *logo = new DLabel(this); +// logo->setAlignment(Qt::AlignHCenter); +// logo->setPixmap(QIcon::fromTheme("codegeex_anwser_icon").pixmap(50)); +// logoLayout->addWidget(logo); + logoLayout->addSpacing(70); DLabel *logoLabel = new DLabel(this); logoLabel->setAlignment(Qt::AlignHCenter); @@ -87,7 +87,7 @@ void IntroPage::initLogo() auto font = logoLabel->font(); font.setPointSize(11); logoLabel->setFont(font); - logoLabel->setText(tr("Welcome to CodeGeeX")); + logoLabel->setText(tr("Welcome to Chat")); logoLayout->addWidget(logoLabel); } @@ -98,9 +98,9 @@ void IntroPage::initIntroContent() introLayout->setSpacing(10); qobject_cast(layout())->addLayout(introLayout); - appendDescLabel(introLayout, tr("CodeGeeX provides code completion suggestions in editor, Press %1 Tab %2 to accept.").arg("", "")); - appendDescLabel(introLayout, tr("CodeGeeX provides inline chat functionality in editor, Press %1 Ctrl + T %2 to use it.").arg("", "")); - appendDescLabel(introLayout, tr("Also, you can directly %1 ask CodeGeeX any questions %2.").arg("", "")); + appendDescLabel(introLayout, tr("Chat provides code completion suggestions in editor, Press %1 Tab %2 to accept.").arg("", "")); + appendDescLabel(introLayout, tr("Chat provides inline chat functionality in editor, Press %1 Ctrl + T %2 to use it.").arg("", "")); + appendDescLabel(introLayout, tr("Also, you can directly %1 ask Chat any questions %2.").arg("", "")); } void IntroPage::initSuggestContent() @@ -117,17 +117,6 @@ void IntroPage::initSuggestContent() appendSuggestButton(suggestLayout, tr("What is the best way to start learning JavaScript?"), "codegeex_advice"); } -void IntroPage::initLogoutButton() -{ - QHBoxLayout *hlayout = new QHBoxLayout; - auto logoutButton = new DCommandLinkButton(tr("logout")); - - hlayout->addWidget(logoutButton); - hlayout->setAlignment(Qt::AlignHCenter); - - qobject_cast(layout())->addLayout(hlayout); -} - void IntroPage::appendDescLabel(QVBoxLayout *layout, const QString &text) { QHBoxLayout *descLayout = new QHBoxLayout; diff --git a/src/plugins/codegeex/widgets/intropage.h b/src/plugins/codegeex/widgets/intropage.h index 8208dd350..7145fd528 100644 --- a/src/plugins/codegeex/widgets/intropage.h +++ b/src/plugins/codegeex/widgets/intropage.h @@ -48,7 +48,6 @@ class IntroPage : public DWidget void initLogo(); void initIntroContent(); void initSuggestContent(); - void initLogoutButton(); void appendDescLabel(QVBoxLayout *layout, const QString &text); void appendSuggestButton(QVBoxLayout *layout, const QString &text, const QString &iconName = ""); diff --git a/src/plugins/codegeex/widgets/messagecomponent.cpp b/src/plugins/codegeex/widgets/messagecomponent.cpp index 1d838f810..3f83a9e72 100644 --- a/src/plugins/codegeex/widgets/messagecomponent.cpp +++ b/src/plugins/codegeex/widgets/messagecomponent.cpp @@ -173,6 +173,8 @@ void MessageComponent::initSenderInfo() editButton->setFixedSize(QSize(24, 24)); editButton->setToolTip(tr("edit")); + auto currentLLMInfo = CodeGeeXManager::instance()->getCurrentLLMInfo(); + switch (messageData.messageType()) { case MessageData::Ask: { senderName->setText("You"); @@ -180,8 +182,9 @@ void MessageComponent::initSenderInfo() break; } case MessageData::Anwser: - senderName->setText("CodeGeeX"); - senderHead->setPixmap(QIcon::fromTheme("codegeex_anwser_icon").pixmap(24, 24)); + senderName->setText(currentLLMInfo.modelName); + if (!currentLLMInfo.icon.isNull()) + senderHead->setPixmap(currentLLMInfo.icon.pixmap(24, 24)); editButton->setVisible(false); break; } diff --git a/src/services/window/windowelement.h b/src/services/window/windowelement.h index b87902265..bae1ef18d 100644 --- a/src/services/window/windowelement.h +++ b/src/services/window/windowelement.h @@ -20,7 +20,7 @@ inline const QString MWNA_DEBUG { QObject::tr("Debug") }; inline const QString MWNA_GIT { QObject::tr("Git") }; inline const QString MWNA_SVN { QObject::tr("Svn") }; inline const QString MWNA_RUNTIME { QObject::tr("Runtime") }; -inline const QString MWNA_CODEGEEX { QObject::tr("CodeGeeX") }; +inline const QString MWNA_CODEGEEX { QObject::tr("Chat") }; inline const QString MWNA_ADVANCEDSEARCH { QObject::tr("Advanced Search") }; // MWTG = MainWindow TopTool group