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());
}
void SeachBarWidget::setText(QString keyword)
{
m_searchLineEdit->setText(keyword);
}
void SeachBarWidget::paintEvent(QPaintEvent *e)
{
Q_UNUSED(e)

View File

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

View File

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

View File

@ -171,6 +171,7 @@ void MainWindow::initConnections()
connect(m_searchBarWidget, &SeachBarWidget::requestSearchKeyword, this, &MainWindow::searchKeywordSlot);
// connect(m_stackedWidget, &StackedWidget::effectiveSearch, m_searchLayout, &SearchBarHLayout::effectiveSearchRecord);
//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:
void searchMethodChanged(FileUtils::SearchMethod);
void webEngineChanged();
void setText(QString keyword);
public Q_SLOTS:
/**

View File

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

View File

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