!11 同步下游提交

Merge pull request !11 from 白俊杰/0822openkylin
This commit is contained in:
zhaikangning 2022-08-31 07:22:54 +00:00 committed by Gitee
commit 9f53cafb8d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 224 additions and 34 deletions

View File

@ -341,24 +341,25 @@ void ResultArea::mouseReleaseEvent(QMouseEvent *event)
bool ResultArea::viewportEvent(QEvent *event) bool ResultArea::viewportEvent(QEvent *event)
{ {
if(event->type() == QEvent::TouchBegin) { if (event->type() == QEvent::MouseButtonPress) {
QTouchEvent *e = dynamic_cast<QTouchEvent *>(event); QMouseEvent *e = dynamic_cast<QMouseEvent *>(event);
if(e->touchPoints().size() == 1) { if (e->source() == Qt::MouseEventSynthesizedByApplication) {
m_pressPoint = m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()); qDebug() << "MouseButtonPress MouseEventSynthesizedByApplication";
m_pressPoint = m_widget->mapFrom(this, e->pos());
event->accept(); event->accept();
return true; return true;
} }
} else if (event->type() == QEvent::TouchUpdate) { } else if (event->type() == QEvent::MouseMove) {
QTouchEvent *e = dynamic_cast<QTouchEvent *>(event); QMouseEvent *e = dynamic_cast<QMouseEvent *>(event);
// qDebug() << "touchpoint===========" << e->touchPoints().size(); if (e->source() == Qt::MouseEventSynthesizedByApplication) {
if(e->touchPoints().size() == 1) { qDebug() << "MouseMove MouseEventSynthesizedByApplication";
int delta = m_pressPoint.y() - m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()).y(); int delta = m_pressPoint.y() - m_widget->mapFrom(this, e->pos()).y();
// qDebug() << "last pos:" << m_pressPoint.y(); // qDebug() << "last pos:" << m_pressPoint.y();
// qDebug() << "new pos:" << m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()).y(); // qDebug() << "new pos:" << m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()).y();
// qDebug() << "delta" << delta; // qDebug() << "delta" << delta;
// qDebug() << "height" << m_widget->height() << "--" << verticalScrollBar()->maximum(); // qDebug() << "value" << verticalScrollBar()->value() << "--" << verticalScrollBar()->value() + delta;
this->verticalScrollBar()->setValue(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; return true;
} }
} }

View File

@ -168,6 +168,7 @@ ResultView::ResultView(const QString &plugin_id, QWidget *parent) : QTreeView(pa
{ {
// setStyle(ResultItemStyle::getStyle()); // setStyle(ResultItemStyle::getStyle());
this->setFrameShape(QFrame::NoFrame); this->setFrameShape(QFrame::NoFrame);
this->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
this->viewport()->setAutoFillBackground(false); this->viewport()->setAutoFillBackground(false);
this->setIconSize(QSize(VIEW_ICON_SIZE, VIEW_ICON_SIZE)); this->setIconSize(QSize(VIEW_ICON_SIZE, VIEW_ICON_SIZE));
this->setRootIsDecorated(false); this->setRootIsDecorated(false);
@ -181,6 +182,9 @@ ResultView::ResultView(const QString &plugin_id, QWidget *parent) : QTreeView(pa
m_plugin_id = plugin_id; m_plugin_id = plugin_id;
m_styleDelegate = new ResultViewDelegate(this); m_styleDelegate = new ResultViewDelegate(this);
this->setItemDelegate(m_styleDelegate); this->setItemDelegate(m_styleDelegate);
m_touchTimer = new QTimer(this);
m_touchTimer->setSingleShot(true);
m_touchTimer->setInterval(100);
} }
bool ResultView::isSelected() bool ResultView::isSelected()
@ -344,6 +348,53 @@ void ResultView::mouseMoveEvent(QMouseEvent *event)
return QTreeView::mouseMoveEvent(event); return QTreeView::mouseMoveEvent(event);
} }
bool ResultView::viewportEvent(QEvent *event)
{
if (event->type() == QEvent::TouchBegin) {
qDebug() << "TouchBegin==============";
QTouchEvent *e = dynamic_cast<QTouchEvent *>(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<QTouchEvent *>(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<QTouchEvent *>(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() void ResultView::initConnections()
{ {
connect(this, &ResultView::startSearch, [ = ](const QString &keyword) { connect(this, &ResultView::startSearch, [ = ](const QString &keyword) {

View File

@ -37,6 +37,7 @@ protected:
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
bool viewportEvent(QEvent *event);
private: private:
void initConnections(); void initConnections();
@ -47,6 +48,7 @@ private:
int m_count = 0; int m_count = 0;
QModelIndex m_tmpCurrentIndex; QModelIndex m_tmpCurrentIndex;
QModelIndex m_tmpMousePressIndex; QModelIndex m_tmpMousePressIndex;
QTimer *m_touchTimer;
Q_SIGNALS: Q_SIGNALS:
void startSearch(const QString &); void startSearch(const QString &);

View File

@ -0,0 +1 @@
#include "file-system-watcher.h"

View File

@ -92,7 +92,8 @@ unix {
searchinterface/ukui-search-task.h \ searchinterface/ukui-search-task.h \
appdata/app-info-table.h \ appdata/app-info-table.h \
searchinterface/search-controller.h \ searchinterface/search-controller.h \
searchinterface/result-item.h searchinterface/result-item.h \
filesystemwatcher/file-system-watcher.h
header.files += development-files/header-files/* header.files += development-files/header-files/*
INSTALLS += header INSTALLS += header

View File

@ -17,7 +17,8 @@ SOURCES += search.cpp
HEADERS += search.h HEADERS += search.h
TRANSLATIONS += translations/zh_CN.ts TRANSLATIONS += translations/zh_CN.ts \
translations/bo_CN.ts
images.files = image/* images.files = image/*
images.path = /usr/share/ukui-search/search-ukcc-plugin/image/ images.path = /usr/share/ukui-search/search-ukcc-plugin/image/

View File

@ -195,8 +195,9 @@ void Search::initUi()
m_addBlockDirFrame->setFrameShape(QFrame::Shape::NoFrame); m_addBlockDirFrame->setFrameShape(QFrame::Shape::NoFrame);
m_addBlockDirFrame->setFixedHeight(60); m_addBlockDirFrame->setFixedHeight(60);
m_addBlockDirWidget = new QPushButton(m_addBlockDirFrame); // m_addBlockDirWidget = new QPushButton(m_addBlockDirFrame);
m_addBlockDirWidget->setFixedHeight(60); m_addBlockDirWidget = new AddBtn(m_addBlockDirFrame);
// m_addBlockDirWidget->setFixedHeight(60);
// m_addBlockDirWidget->setObjectName("addBlockDirWidget"); // m_addBlockDirWidget->setObjectName("addBlockDirWidget");
// QPalette pal; // QPalette pal;
@ -212,27 +213,28 @@ void Search::initUi()
// HoverWidget:hover:!pressed#addBlockDirWidget{background: %1; \ // HoverWidget:hover:!pressed#addBlockDirWidget{background: %1; \
// border-radius: 4px;}").arg(stringColor)); // border-radius: 4px;}").arg(stringColor));
m_addBlockDirWidget->setProperty("useButtonPalette", true); //之前自己写的添加按钮目前方案用控制面板提供的AddBtn后面有变动再放出来(属性全都注掉了有问题找ukcc寻求帮助
// m_addBlockDirWidget->setStyleSheet("QPushButton:!checked{background: palette(base);}"); // m_addBlockDirWidget->setProperty("useButtonPalette", true);
m_addBlockDirWidget->setFlat(true); //// m_addBlockDirWidget->setStyleSheet("QPushButton:!checked{background: palette(base);}");
// m_addBlockDirWidget->setFlat(true);
m_addBlockDirIcon = new QLabel(m_addBlockDirWidget); // 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->setPixmap(QIcon("/usr/share/ukui-search/search-ukcc-plugin/image/add.svg").pixmap(12, 12));
m_addBlockDirIcon->setProperty("useIconHighlightEffect", true); // m_addBlockDirIcon->setProperty("useIconHighlightEffect", true);
m_addBlockDirIcon->setProperty("iconHighlightEffectMode", 1); // m_addBlockDirIcon->setProperty("iconHighlightEffectMode", 1);
m_addBlockDirLabel = new QLabel(m_addBlockDirWidget); // m_addBlockDirLabel = new QLabel(m_addBlockDirWidget);
m_addBlockDirLabel->setText(tr("Choose folder")); // m_addBlockDirLabel->setText(tr("Choose folder"));
m_addBlockDirLyt = new QHBoxLayout(m_addBlockDirWidget); // m_addBlockDirLyt = new QHBoxLayout(m_addBlockDirWidget);
m_addBlockDirWidget->setLayout(m_addBlockDirLyt); // m_addBlockDirWidget->setLayout(m_addBlockDirLyt);
m_blockDirsLyt->addWidget(m_addBlockDirWidget); m_blockDirsLyt->addWidget(m_addBlockDirWidget);
m_addBlockDirLyt->addStretch(); // m_addBlockDirLyt->addStretch();
m_addBlockDirLyt->addWidget(m_addBlockDirIcon); // m_addBlockDirLyt->addWidget(m_addBlockDirIcon);
m_addBlockDirLyt->addWidget(m_addBlockDirLabel); // m_addBlockDirLyt->addWidget(m_addBlockDirLabel);
m_addBlockDirLyt->addStretch(); // m_addBlockDirLyt->addStretch();
m_mainLyt->addSpacing(32); m_mainLyt->addSpacing(32);
m_mainLyt->addWidget(m_blockDirTitleLabel); m_mainLyt->addWidget(m_blockDirTitleLabel);
m_mainLyt->addWidget(m_blockDirDescLabel); m_mainLyt->addWidget(m_blockDirDescLabel);

View File

@ -22,6 +22,7 @@
#include <ukcc/widgets/switchbutton.h> #include <ukcc/widgets/switchbutton.h>
#include <ukcc/widgets/comboxframe.h> #include <ukcc/widgets/comboxframe.h>
#include <ukcc/widgets/titlelabel.h> #include <ukcc/widgets/titlelabel.h>
#include <ukcc/widgets/addbtn.h>
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings" #define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
#define SEARCH_METHOD_KEY "fileIndexEnable" #define SEARCH_METHOD_KEY "fileIndexEnable"
@ -88,7 +89,8 @@ private:
QLabel * m_blockDirDescLabel = nullptr; QLabel * m_blockDirDescLabel = nullptr;
QFrame * m_blockDirsFrame = nullptr; QFrame * m_blockDirsFrame = nullptr;
QVBoxLayout * m_blockDirsLyt = nullptr; QVBoxLayout * m_blockDirsLyt = nullptr;
QPushButton * m_addBlockDirWidget = nullptr; // QPushButton * m_addBlockDirWidget = nullptr;
AddBtn * m_addBlockDirWidget = nullptr;
QLabel * m_addBlockDirIcon = nullptr; QLabel * m_addBlockDirIcon = nullptr;
QLabel * m_addBlockDirLabel = nullptr; QLabel * m_addBlockDirLabel = nullptr;
QHBoxLayout * m_addBlockDirLyt = nullptr; QHBoxLayout * m_addBlockDirLyt = nullptr;

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>Search</name>
<message>
<location filename="../search.cpp" line="13"/>
<location filename="../search.cpp" line="121"/>
<source>Search</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="145"/>
<source>Create index</source>
<translation></translation>
<extra-contents_path>/Search/Create index</extra-contents_path>
</message>
<message>
<location filename="../search.cpp" line="146"/>
<source>Creating index can help you getting results quickly.</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="165"/>
<source>Default web searching engine</source>
<translation></translation>
<extra-contents_path>/Search/Default web searching engine</extra-contents_path>
</message>
<message>
<location filename="../search.cpp" line="169"/>
<source>baidu</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="170"/>
<source>sougou</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="171"/>
<source>360</source>
<translation>360</translation>
</message>
<message>
<location filename="../search.cpp" line="179"/>
<source>Block Folders</source>
<translation></translation>
<extra-contents_path>/Search/Block Folders</extra-contents_path>
</message>
<message>
<location filename="../search.cpp" line="184"/>
<source>Following folders will not be searched. You can set it by adding and removing folders.</source>
<translation> </translation>
</message>
<message>
<location filename="../search.cpp" line="225"/>
<source>Choose folder</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="338"/>
<source>delete</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="393"/>
<source>Directories</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="394"/>
<source>select blocked folder</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="395"/>
<source>Select</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="396"/>
<source>Position: </source>
<translation> </translation>
</message>
<message>
<location filename="../search.cpp" line="397"/>
<source>FileName: </source>
<translation> </translation>
</message>
<message>
<location filename="../search.cpp" line="398"/>
<source>FileType: </source>
<translation> </translation>
</message>
<message>
<location filename="../search.cpp" line="399"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="415"/>
<location filename="../search.cpp" line="419"/>
<location filename="../search.cpp" line="423"/>
<location filename="../search.cpp" line="427"/>
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="415"/>
<source>Add blocked folder failed, choosen path is empty!</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="419"/>
<source>Add blocked folder failed, it is not in home path!</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="423"/>
<source>Add blocked folder failed, its parent dir is exist!</source>
<translation></translation>
</message>
<message>
<location filename="../search.cpp" line="427"/>
<source>Add blocked folder failed, it has been already blocked!</source>
<translation></translation>
</message>
</context>
</TS>