From 7c333778e96da3b84e7363405a8176d2662d14c3 Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Wed, 17 Aug 2022 10:04:24 +0800 Subject: [PATCH 1/4] Fix#135498 usd AddBtn of libukcc to repalce the Add Folder Button(origin is QPushButton). --- search-ukcc-plugin/search.cpp | 36 ++++++++++++++++++----------------- search-ukcc-plugin/search.h | 4 +++- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/search-ukcc-plugin/search.cpp b/search-ukcc-plugin/search.cpp index 5b88ddd..bf06223 100644 --- a/search-ukcc-plugin/search.cpp +++ b/search-ukcc-plugin/search.cpp @@ -195,8 +195,9 @@ void Search::initUi() m_addBlockDirFrame->setFrameShape(QFrame::Shape::NoFrame); m_addBlockDirFrame->setFixedHeight(60); - m_addBlockDirWidget = new QPushButton(m_addBlockDirFrame); - m_addBlockDirWidget->setFixedHeight(60); +// m_addBlockDirWidget = new QPushButton(m_addBlockDirFrame); + m_addBlockDirWidget = new AddBtn(m_addBlockDirFrame); +// m_addBlockDirWidget->setFixedHeight(60); // m_addBlockDirWidget->setObjectName("addBlockDirWidget"); // QPalette pal; @@ -212,27 +213,28 @@ void Search::initUi() // HoverWidget:hover:!pressed#addBlockDirWidget{background: %1; \ // border-radius: 4px;}").arg(stringColor)); - m_addBlockDirWidget->setProperty("useButtonPalette", true); -// m_addBlockDirWidget->setStyleSheet("QPushButton:!checked{background: palette(base);}"); - m_addBlockDirWidget->setFlat(true); + //之前自己写的添加按钮,目前方案用控制面板提供的AddBtn,后面有变动再放出来(属性全都注掉了,有问题找ukcc寻求帮助) +// m_addBlockDirWidget->setProperty("useButtonPalette", true); +//// m_addBlockDirWidget->setStyleSheet("QPushButton:!checked{background: palette(base);}"); +// m_addBlockDirWidget->setFlat(true); - m_addBlockDirIcon = new QLabel(m_addBlockDirWidget); - m_addBlockDirIcon->setPixmap(QIcon("/usr/share/ukui-search/search-ukcc-plugin/image/add.svg").pixmap(12, 12)); - m_addBlockDirIcon->setProperty("useIconHighlightEffect", true); - m_addBlockDirIcon->setProperty("iconHighlightEffectMode", 1); +// m_addBlockDirIcon = new QLabel(m_addBlockDirWidget); +// m_addBlockDirIcon->setPixmap(QIcon("/usr/share/ukui-search/search-ukcc-plugin/image/add.svg").pixmap(12, 12)); +// m_addBlockDirIcon->setProperty("useIconHighlightEffect", true); +// m_addBlockDirIcon->setProperty("iconHighlightEffectMode", 1); - m_addBlockDirLabel = new QLabel(m_addBlockDirWidget); - m_addBlockDirLabel->setText(tr("Choose folder")); +// m_addBlockDirLabel = new QLabel(m_addBlockDirWidget); +// m_addBlockDirLabel->setText(tr("Choose folder")); - m_addBlockDirLyt = new QHBoxLayout(m_addBlockDirWidget); - m_addBlockDirWidget->setLayout(m_addBlockDirLyt); +// m_addBlockDirLyt = new QHBoxLayout(m_addBlockDirWidget); +// m_addBlockDirWidget->setLayout(m_addBlockDirLyt); m_blockDirsLyt->addWidget(m_addBlockDirWidget); - m_addBlockDirLyt->addStretch(); - m_addBlockDirLyt->addWidget(m_addBlockDirIcon); - m_addBlockDirLyt->addWidget(m_addBlockDirLabel); - m_addBlockDirLyt->addStretch(); +// m_addBlockDirLyt->addStretch(); +// m_addBlockDirLyt->addWidget(m_addBlockDirIcon); +// m_addBlockDirLyt->addWidget(m_addBlockDirLabel); +// m_addBlockDirLyt->addStretch(); m_mainLyt->addSpacing(32); m_mainLyt->addWidget(m_blockDirTitleLabel); m_mainLyt->addWidget(m_blockDirDescLabel); diff --git a/search-ukcc-plugin/search.h b/search-ukcc-plugin/search.h index b86d8a1..6c61ae2 100644 --- a/search-ukcc-plugin/search.h +++ b/search-ukcc-plugin/search.h @@ -22,6 +22,7 @@ #include #include #include +#include #define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings" #define SEARCH_METHOD_KEY "fileIndexEnable" @@ -88,7 +89,8 @@ private: QLabel * m_blockDirDescLabel = nullptr; QFrame * m_blockDirsFrame = nullptr; QVBoxLayout * m_blockDirsLyt = nullptr; - QPushButton * m_addBlockDirWidget = nullptr; +// QPushButton * m_addBlockDirWidget = nullptr; + AddBtn * m_addBlockDirWidget = nullptr; QLabel * m_addBlockDirIcon = nullptr; QLabel * m_addBlockDirLabel = nullptr; QHBoxLayout * m_addBlockDirLyt = nullptr; From 75f568de6ba61a6dcb444993b68b7ed74afcfc10 Mon Sep 17 00:00:00 2001 From: jixiaoxu Date: Thu, 18 Aug 2022 13:39:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E6=90=9C=E7=B4=A2=E6=8F=92=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E8=97=8F=E6=96=87=E7=BF=BB=E8=AF=91=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search-ukcc-plugin/search-ukcc-plugin.pro | 3 +- search-ukcc-plugin/translations/bo_CN.ts | 129 ++++++++++++++++++++++ 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 search-ukcc-plugin/translations/bo_CN.ts diff --git a/search-ukcc-plugin/search-ukcc-plugin.pro b/search-ukcc-plugin/search-ukcc-plugin.pro index 900c877..930ca06 100644 --- a/search-ukcc-plugin/search-ukcc-plugin.pro +++ b/search-ukcc-plugin/search-ukcc-plugin.pro @@ -17,7 +17,8 @@ SOURCES += search.cpp HEADERS += search.h -TRANSLATIONS += translations/zh_CN.ts +TRANSLATIONS += translations/zh_CN.ts \ + translations/bo_CN.ts images.files = image/* images.path = /usr/share/ukui-search/search-ukcc-plugin/image/ diff --git a/search-ukcc-plugin/translations/bo_CN.ts b/search-ukcc-plugin/translations/bo_CN.ts new file mode 100644 index 0000000..83bbaad --- /dev/null +++ b/search-ukcc-plugin/translations/bo_CN.ts @@ -0,0 +1,129 @@ + + + + + Search + + + + Search + འཚོལ་ཞིབ། + + + + Create index + གསར་འཛུགས་འཚོལ་ཞིབ་བྱེད་པར་ཁྲིད་སྟོན། + /Search/Create index + + + + Creating index can help you getting results quickly. + སྟོན་གྲངས་གསར་སྐྲུན་བྱས་ན་ཁྱོད་ལ་མགྱོགས་མྱུར་ངང་གྲུབ་འབྲས་ཐོབ་པར་རོགས་རམ་བྱེད་ཐུབ། + + + + Default web searching engine + ཁོག་གི་དྲ་ཤོག་གཏོད་པ་བཤེར་འཚོལ་རིགས་དབྱིབས། + /Search/Default web searching engine + + + + baidu + པའེ་ཏུའུ། + + + + sougou + སོའོ་གོའུ། + + + + 360 + 360 + + + + Block Folders + ལྐོག་བཀོད་མིང་ཐོ། + /Search/Block Folders + + + + Following folders will not be searched. You can set it by adding and removing folders. + གཤམ་གྱི་ཡིག་སྣོད་འཚོལ་བཤེར་མི་བྱེད། ཡིག་སྣོད་གསར་སྣོན་དང་གསུབ་འཕྲི་བྱས་ཚེ་ཡིག་ཆའི་དཀར་ཆག་སྒྲིག་འགོད་བྱ་ཐུབ། + + + + Choose folder + བསལ་འདེམས་ཀྱི་དཀར་ཆག། + + + + delete + བསུབ་པ། + + + + Directories + དཀར་ཆག + + + + select blocked folder + བཀག་སྡོམ་བྱས་པའི་ཡིག་སྣོད་གདམ་གསེས + + + + Select + བདམས་ཐོན་བྱུང་བ། + + + + Position: + གོ་གནས་ནི། + + + + FileName: + ཡིག་ཆའི་མིང་ནི། + + + + FileType: + ཡིག་ཆའི་རིགས་དབྱིབས་ནི། + + + + Cancel + ཕྱིར་འཐེན། + + + + + + + Warning + ཐ་ཚིག་སྒྲོག་པ། + + + + Add blocked folder failed, choosen path is empty! + སྦྱོར་རྟ་ལྐོག་བཀོད་མིང་ཐོ་ཕམ་ཁ་བསལ་འདེམས་ཀྱི་ཐབས་ལམ་སྟོང་བ་རེད། + + + + Add blocked folder failed, it is not in home path! + སྦྱོར་རྟ་ལྐོག་བཀོད་མིང་ཐོ་ཕམ་ཁ་བསལ་འདེམས་ཀྱི་དཀར་ཆག་མི་ཁྱིམ་དཀར་ཆག་འོག། + + + + Add blocked folder failed, its parent dir is exist! + སྦྱོར་རྟ་ལྐོག་བཀོད་མིང་ཐོ་ཕམ་ཁ་བསལ་འདེམས་ཀྱི་དཀར་ཆག་ནི་ལྐོག་བཀོད་མིང་ཐོ་འི་ཁྲོད་ཀྱི་དཀར་ཆག་འོག + + + + Add blocked folder failed, it has been already blocked! + སྦྱོར་རྟ་ལྐོག་བཀོད་མིང་ཐོ་ཕམ་ཁ་བསལ་འདེམས་ཀྱི་དཀར་ཆག་ནི་ལྐོག་བཀོད་མིང་ཐོ་འི་ཁྲོད་ཀྱི་དཀར་ཆག་འོག + + + From 660f559c32147a8c95b4c5c5ff9fd1f4a88ca87a Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Thu, 18 Aug 2022 17:27:10 +0800 Subject: [PATCH 3/4] Fix#130073 touch event cannot trigger the selection of search result. --- .../stack-pages/search-page-section.cpp | 29 ++++++----- frontend/view/result-view.cpp | 51 +++++++++++++++++++ frontend/view/result-view.h | 2 + 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/frontend/control/stack-pages/search-page-section.cpp b/frontend/control/stack-pages/search-page-section.cpp index b363fd1..ee5191e 100644 --- a/frontend/control/stack-pages/search-page-section.cpp +++ b/frontend/control/stack-pages/search-page-section.cpp @@ -341,24 +341,25 @@ void ResultArea::mouseReleaseEvent(QMouseEvent *event) bool ResultArea::viewportEvent(QEvent *event) { - if(event->type() == QEvent::TouchBegin) { - QTouchEvent *e = dynamic_cast(event); - if(e->touchPoints().size() == 1) { - m_pressPoint = m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()); + if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent *e = dynamic_cast(event); + if (e->source() == Qt::MouseEventSynthesizedByApplication) { + qDebug() << "MouseButtonPress MouseEventSynthesizedByApplication"; + m_pressPoint = m_widget->mapFrom(this, e->pos()); event->accept(); return true; } - } else if (event->type() == QEvent::TouchUpdate) { - QTouchEvent *e = dynamic_cast(event); -// qDebug() << "touchpoint===========" << e->touchPoints().size(); - if(e->touchPoints().size() == 1) { - int delta = m_pressPoint.y() - m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()).y(); -// qDebug() << "last pos:" << m_pressPoint.y(); -// qDebug() << "new pos:" << m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()).y(); -// qDebug() << "delta" << delta; -// qDebug() << "height" << m_widget->height() << "--" << verticalScrollBar()->maximum(); + } else if (event->type() == QEvent::MouseMove) { + QMouseEvent *e = dynamic_cast(event); + if (e->source() == Qt::MouseEventSynthesizedByApplication) { + qDebug() << "MouseMove MouseEventSynthesizedByApplication"; + int delta = m_pressPoint.y() - m_widget->mapFrom(this, e->pos()).y(); + // qDebug() << "last pos:" << m_pressPoint.y(); + // qDebug() << "new pos:" << m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()).y(); + // qDebug() << "delta" << delta; + // qDebug() << "value" << verticalScrollBar()->value() << "--" << verticalScrollBar()->value() + delta; this->verticalScrollBar()->setValue(verticalScrollBar()->value() + delta); - m_pressPoint = m_widget->mapFrom(this,e->touchPoints().at(0).pos().toPoint()); + m_pressPoint = m_widget->mapFrom(this,e->pos()); return true; } } diff --git a/frontend/view/result-view.cpp b/frontend/view/result-view.cpp index 2df07a8..911f084 100644 --- a/frontend/view/result-view.cpp +++ b/frontend/view/result-view.cpp @@ -168,6 +168,7 @@ ResultView::ResultView(const QString &plugin_id, QWidget *parent) : QTreeView(pa { // setStyle(ResultItemStyle::getStyle()); this->setFrameShape(QFrame::NoFrame); + this->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); this->viewport()->setAutoFillBackground(false); this->setIconSize(QSize(VIEW_ICON_SIZE, VIEW_ICON_SIZE)); this->setRootIsDecorated(false); @@ -181,6 +182,9 @@ ResultView::ResultView(const QString &plugin_id, QWidget *parent) : QTreeView(pa m_plugin_id = plugin_id; m_styleDelegate = new ResultViewDelegate(this); this->setItemDelegate(m_styleDelegate); + m_touchTimer = new QTimer(this); + m_touchTimer->setSingleShot(true); + m_touchTimer->setInterval(100); } bool ResultView::isSelected() @@ -344,6 +348,53 @@ void ResultView::mouseMoveEvent(QMouseEvent *event) return QTreeView::mouseMoveEvent(event); } +bool ResultView::viewportEvent(QEvent *event) +{ + if (event->type() == QEvent::TouchBegin) { + qDebug() << "TouchBegin=============="; + QTouchEvent *e = dynamic_cast(event); + QMouseEvent me(QEvent::MouseButtonPress, + e->touchPoints().at(0).pos(), + this->mapTo(this->window(),e->touchPoints().at(0).pos().toPoint()), + this->mapToGlobal(e->touchPoints().at(0).pos().toPoint()), + Qt::LeftButton,Qt::LeftButton,Qt::NoModifier,Qt::MouseEventSynthesizedByApplication); + QApplication::sendEvent(parent(), &me); + m_touchTimer->start(); + event->accept(); + return true; + } else if (event->type() == QEvent::TouchEnd) { + qDebug() << "touchend==============" << m_touchTimer->remainingTime(); + if (m_touchTimer->remainingTime() > 0.001) { + QTouchEvent *e = dynamic_cast(event); + QMouseEvent me(QEvent::MouseButtonPress, + e->touchPoints().at(0).pos(), + this->mapTo(this->window(),e->touchPoints().at(0).pos().toPoint()), + this->mapToGlobal(e->touchPoints().at(0).pos().toPoint()), + Qt::LeftButton,Qt::LeftButton,Qt::NoModifier,Qt::MouseEventSynthesizedByApplication); + QApplication::sendEvent(this->viewport(),&me); + + QMouseEvent mer(QEvent::MouseButtonRelease, + e->touchPoints().at(0).pos(), + this->mapTo(this->window(),e->touchPoints().at(0).pos().toPoint()), + this->mapToGlobal(e->touchPoints().at(0).pos().toPoint()), + Qt::LeftButton,Qt::LeftButton,Qt::NoModifier,Qt::MouseEventSynthesizedByApplication); + QApplication::sendEvent(this->viewport(),&mer); + } + return true; + } else if (event->type() == QEvent::TouchUpdate) { + qDebug() << "touchupdate=============="; + QTouchEvent *e = dynamic_cast(event); + QMouseEvent me(QEvent::MouseMove, + e->touchPoints().at(0).pos(), + this->mapTo(this->window(),e->touchPoints().at(0).pos().toPoint()), + this->mapToGlobal(e->touchPoints().at(0).pos().toPoint()), + Qt::LeftButton,Qt::LeftButton,Qt::NoModifier,Qt::MouseEventSynthesizedByApplication); + QApplication::sendEvent(parent(), &me); + return true; + } + return QTreeView::viewportEvent(event); +} + void ResultView::initConnections() { connect(this, &ResultView::startSearch, [ = ](const QString &keyword) { diff --git a/frontend/view/result-view.h b/frontend/view/result-view.h index c670f28..dd9a3f2 100644 --- a/frontend/view/result-view.h +++ b/frontend/view/result-view.h @@ -37,6 +37,7 @@ protected: void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); + bool viewportEvent(QEvent *event); private: void initConnections(); @@ -47,6 +48,7 @@ private: int m_count = 0; QModelIndex m_tmpCurrentIndex; QModelIndex m_tmpMousePressIndex; + QTimer *m_touchTimer; Q_SIGNALS: void startSearch(const QString &); From a7c6899b1757bb48ae856d8697277ba77e071c07 Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Fri, 19 Aug 2022 10:58:29 +0800 Subject: [PATCH 4/4] Add FileSystemWatcher to the install files. --- libsearch/development-files/header-files/FileSystemWatcher | 1 + libsearch/libsearch.pro | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 libsearch/development-files/header-files/FileSystemWatcher diff --git a/libsearch/development-files/header-files/FileSystemWatcher b/libsearch/development-files/header-files/FileSystemWatcher new file mode 100644 index 0000000..f0a19a3 --- /dev/null +++ b/libsearch/development-files/header-files/FileSystemWatcher @@ -0,0 +1 @@ +#include "file-system-watcher.h" diff --git a/libsearch/libsearch.pro b/libsearch/libsearch.pro index a22b0b2..fe687c5 100644 --- a/libsearch/libsearch.pro +++ b/libsearch/libsearch.pro @@ -92,7 +92,8 @@ unix { searchinterface/ukui-search-task.h \ appdata/app-info-table.h \ searchinterface/search-controller.h \ - searchinterface/result-item.h + searchinterface/result-item.h \ + filesystemwatcher/file-system-watcher.h header.files += development-files/header-files/* INSTALLS += header