use dbus interface to search keyword

This commit is contained in:
baijunjie@kylinos.cn 2021-08-11 17:50:00 +08:00
parent 8ab2857b1b
commit c6626ec369
7 changed files with 21 additions and 5 deletions

View File

@ -113,6 +113,11 @@ void SeachBarWidget::reSearch()
Q_EMIT this->m_searchLineEdit->requestSearchKeyword(m_searchLineEdit->text()); Q_EMIT this->m_searchLineEdit->requestSearchKeyword(m_searchLineEdit->text());
} }
void SeachBarWidget::setText(QString keyword)
{
m_searchLineEdit->setText(keyword);
}
void SeachBarWidget::paintEvent(QPaintEvent *e) void SeachBarWidget::paintEvent(QPaintEvent *e)
{ {
Q_UNUSED(e) Q_UNUSED(e)

View File

@ -69,6 +69,9 @@ protected:
Q_SIGNALS: Q_SIGNALS:
void requestSearchKeyword(QString text); void requestSearchKeyword(QString text);
public Q_SLOTS:
void setText(QString keyword);
private: private:
SearchLineEdit *m_searchLineEdit; SearchLineEdit *m_searchLineEdit;
QHBoxLayout *m_ly; QHBoxLayout *m_ly;

View File

@ -31,7 +31,7 @@ include(view/view.pri)
SOURCES += \ SOURCES += \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
ukui-search-dubs-service.cpp ukui-search-dbus-service.cpp
HEADERS += \ HEADERS += \

View File

@ -171,6 +171,7 @@ void MainWindow::initConnections()
connect(m_searchBarWidget, &SeachBarWidget::requestSearchKeyword, this, &MainWindow::searchKeywordSlot); connect(m_searchBarWidget, &SeachBarWidget::requestSearchKeyword, this, &MainWindow::searchKeywordSlot);
// connect(m_stackedWidget, &StackedWidget::effectiveSearch, m_searchLayout, &SearchBarHLayout::effectiveSearchRecord); // connect(m_stackedWidget, &StackedWidget::effectiveSearch, m_searchLayout, &SearchBarHLayout::effectiveSearchRecord);
//connect(m_searchResultPage, &SearchResultPage::resizeHeight, this, &MainWindow::resizeHeight); //connect(m_searchResultPage, &SearchResultPage::resizeHeight, this, &MainWindow::resizeHeight);
connect(this,&MainWindow::setText,m_searchBarWidget,&SeachBarWidget::setText);
} }
/** /**

View File

@ -87,6 +87,7 @@ protected:
Q_SIGNALS: Q_SIGNALS:
void searchMethodChanged(FileUtils::SearchMethod); void searchMethodChanged(FileUtils::SearchMethod);
void webEngineChanged(); void webEngineChanged();
void setText(QString keyword);
public Q_SLOTS: public Q_SLOTS:
/** /**

View File

@ -1,22 +1,27 @@
#include "ukui-search-dbus-service.h" #include "ukui-search-dbus-service.h"
using namespace Zeeker; using namespace Zeeker;
void UkuiSearchDbusServices::showWindow(){ void UkuiSearchDbusServices::showWindow(){
m_mainWindow->bootOptionsFilter("-s"); m_mainWindow->bootOptionsFilter("-s");
} }
void UkuiSearchDbusServices::searchKeyword(QString keyword)
{
showWindow();
m_mainWindow->setText(keyword);
}
UkuiSearchDbusServices::UkuiSearchDbusServices(MainWindow *m) UkuiSearchDbusServices::UkuiSearchDbusServices(MainWindow *m)
{ {
m_mainWindow = m; m_mainWindow = m;
//注册服务 //注册服务
QDBusConnection sessionBus = QDBusConnection::sessionBus(); QDBusConnection sessionBus = QDBusConnection::sessionBus();
if(!sessionBus.registerService("org.ukui.search.service")){ if(!sessionBus.registerService("org.ukui.search.service")){
qCritical() << "QDbus register service failed reason:" << sessionBus.lastError(); qWarning() << "ukui-search dbus register service failed reason:" << sessionBus.lastError();
exit(1);
} }
if(!sessionBus.registerObject("/", this, QDBusConnection::ExportAllSlots)){ if(!sessionBus.registerObject("/", this, QDBusConnection::ExportAllSlots)){
qCritical() << "QDbus register object failed reason:" << sessionBus.lastError(); qWarning() << "ukui-search dbus register object failed reason:" << sessionBus.lastError();
exit(2);
} }
} }

View File

@ -19,6 +19,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void showWindow(); void showWindow();
void searchKeyword(QString keyword);
private: private:
MainWindow *m_mainWindow; MainWindow *m_mainWindow;