Merge branch '0802sub' into 'new-frontend'

use dbus interface to search keyword

See merge request kylin-desktop/ukui-search!86
This commit is contained in:
PengfeiZhang 2021-08-12 06:57:27 +00:00
commit 0a4fdfb21e
8 changed files with 73 additions and 1 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

@ -30,11 +30,13 @@ include(view/view.pri)
SOURCES += \
main.cpp \
mainwindow.cpp
mainwindow.cpp \
ukui-search-dbus-service.cpp
HEADERS += \
mainwindow.h \
ukui-search-dbus-service.h
# Default rules for deployment.

View File

@ -38,6 +38,7 @@
#include "qt-local-peer.h"
#include "libsearch.h"
#include "global-settings.h"
#include "ukui-search-dbus-service.h"
using namespace Zeeker;
@ -263,6 +264,7 @@ int main(int argc, char *argv[]) {
//set main window to the center of screen
MainWindow *w = new MainWindow;
UkuiSearchDbusServices dbusService(w);
qApp->setWindowIcon(QIcon::fromTheme("kylin-search"));
centerToScreen(w);

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

@ -0,0 +1,29 @@
#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")){
qWarning() << "ukui-search dbus register service failed reason:" << sessionBus.lastError();
}
if(!sessionBus.registerObject("/", this, QDBusConnection::ExportAllSlots)){
qWarning() << "ukui-search dbus register object failed reason:" << sessionBus.lastError();
}
}
UkuiSearchDbusServices::~UkuiSearchDbusServices(){
}

View File

@ -0,0 +1,29 @@
#ifndef UKUISEARCHDBUSSERVICE_H
#define UKUISEARCHDBUSSERVICE_H
#include <QDBusConnection>
#include <QObject>
#include "mainwindow.h"
namespace Zeeker {
class UkuiSearchDbusServices: public QObject{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface","org.ukui.search.service")
public:
explicit UkuiSearchDbusServices(MainWindow *m);
~UkuiSearchDbusServices();
public Q_SLOTS:
void showWindow();
void searchKeyword(QString keyword);
private:
MainWindow *m_mainWindow;
};
}
#endif // UKUISEARCHDBUSSERVICE_H