From 449825c5f95d25ff9f3b0c3e08ae05e5e796f559 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Fri, 19 Mar 2021 10:15:30 +0800 Subject: [PATCH] feat(frontend): Reset geometry for ukui-search. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 重新计算搜索主界面的显示位置 Log: 重新计算搜索主界面的显示位置 --- libsearch/index/pinyinWithTone.txt | 6 ++-- libsearch/index/pinyinWithoutTone.txt | 6 ++-- src/mainwindow.cpp | 42 ++++++++++++++------------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/libsearch/index/pinyinWithTone.txt b/libsearch/index/pinyinWithTone.txt index 3e862b9..41eaeec 100644 --- a/libsearch/index/pinyinWithTone.txt +++ b/libsearch/index/pinyinWithTone.txt @@ -6009,7 +6009,7 @@ zhòng 仲 pǐ,pí,bì 仳 wò 仴 wǔ 仵 -jiàn,móu 件 +jiàn 件 jià,jiè,jie 价 yǎo,fó 仸 fēng 仹 @@ -11099,7 +11099,7 @@ tuō,chǐ 拖 jū,gōu,jǔ,jú 拘 zhuō 拙 pàn,biàn,fèn,fān,pīn 拚 -zhāo,qiáo,sháo 招 +zhāo 招 bài 拜 bài 拝 dǐ 拞 @@ -12449,7 +12449,7 @@ guā,tiǎn,kuò 栝 kān 栞 bēn,bīng 栟 rěn 栠 -xiào,jiào,jiǎo,qiāo 校 +xiào,jiào,jiǎo 校 bǎi 栢 rěn 栣 bìng 栤 diff --git a/libsearch/index/pinyinWithoutTone.txt b/libsearch/index/pinyinWithoutTone.txt index 4106e11..9e3abac 100644 --- a/libsearch/index/pinyinWithoutTone.txt +++ b/libsearch/index/pinyinWithoutTone.txt @@ -6009,7 +6009,7 @@ zhong 仲 pi,bi 仳 wo 仴 wu 仵 -mou,jian 件 +jian 件 jie,jia 价 fo,yao 仸 feng 仹 @@ -11099,7 +11099,7 @@ niu,yu,ao 拗 ju,gou 拘 zhuo 拙 pin,fan,pan,fen,bian 拚 -shao,qiao,zhao 招 +zhao 招 bai 拜 bai 拝 di 拞 @@ -12449,7 +12449,7 @@ kuo,tian,gua 栝 kan 栞 bing,ben 栟 ren 栠 -jiao,qiao,xiao 校 +jiao,xiao 校 bai 栢 ren 栣 bing 栤 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 737a58b..97cb405 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -128,12 +128,20 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_sys_tray_icon,&QSystemTrayIcon::activated,this,[=](QSystemTrayIcon::ActivationReason reason){ if(reason == QSystemTrayIcon::Trigger) { - clearSearchResult(); - this->moveToPanel(); - this->show(); - this->m_searchLayout->focusIn(); //打开主界面时输入框夺焦,可直接输入 - this->raise(); - this->activateWindow(); + if (!this->isVisible()) { + clearSearchResult(); + this->moveToPanel(); + this->show(); + this->m_searchLayout->focusIn(); //打开主界面时输入框夺焦,可直接输入 + this->raise(); + this->activateWindow(); + } else { + this->hide(); + m_contentFrame->closeWebView(); + m_search_result_thread->requestInterruption(); + m_search_result_thread->quit(); + m_seach_app_thread->stop(); + } } }); } @@ -334,12 +342,15 @@ void MainWindow::moveToPanel() QDBusConnection::sessionBus()); if (QDBusReply(primaryScreenInterface.call("x")).isValid()) { QDBusReply x = primaryScreenInterface.call("x"); + QDBusReply y = primaryScreenInterface.call("y"); QDBusReply width = primaryScreenInterface.call("width"); QDBusReply height = primaryScreenInterface.call("height"); screenGeometry.setX(x); + screenGeometry.setY(y); screenGeometry.setWidth(width); screenGeometry.setHeight(height); availableGeometry.setX(x); + availableGeometry.setY(y); availableGeometry.setWidth(width); availableGeometry.setHeight(height); } @@ -354,29 +365,20 @@ void MainWindow::moveToPanel() int position = QDBusReply(interface.call("GetPanelPosition", "position")); int height = QDBusReply(interface.call("GetPanelPosition", "height")); - int d = 2; //窗口边沿到任务栏距离 + int d = 8; //窗口边沿到任务栏距离 if (position == 0) { //任务栏在下侧 - this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + availableGeometry.height() - this->height() - height - d); + this->move(availableGeometry.x() + availableGeometry.width() - this->width() - d, screenMainRect.y() + availableGeometry.height() - this->height() - height - d); } else if(position == 1) { //任务栏在上侧 - qDebug()<<"任务栏在上侧"; - this->move(availableGeometry.x() + availableGeometry.width() - this->width(), screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + height + d); + this->move(availableGeometry.x() + availableGeometry.width() - this->width() - d, screenMainRect.y() + screenGeometry.height() - availableGeometry.height() + height + d); } else if (position == 2) { //任务栏在左侧 - if (screenGeometry.x() == 0) {//主屏在左侧 - this->move(height + d, screenMainRect.y() + screenMainRect.height() - this->height()); - } else {//主屏在右侧 - this->move(screenMainRect.x() + height + d, screenMainRect.y() + screenMainRect.height() - this->height()); - } + this->move(screenGeometry.x() + screenGeometry.width() - availableGeometry.width() + d, screenGeometry.y() + screenGeometry.height() - this->height() - d); } else if (position == 3) { //任务栏在右侧 - if (screenGeometry.x() == 0) {//主屏在左侧 - this->move(screenMainRect.width() - this->width() - height - d, screenMainRect.y() + screenMainRect.height() - this->height()); - } else {//主屏在右侧 - this->move(screenMainRect.x() + screenMainRect.width() - this->width() - height - d, screenMainRect.y() + screenMainRect.height() - this->height()); - } + this->move(screenGeometry.x() + availableGeometry.width() - this->width() - d, screenGeometry.y() + screenGeometry.height() - this->height() - d); } }