diff --git a/libsearch/index/first-run-indexer.cpp b/libsearch/index/first-run-indexer.cpp index 9b0aa41..282a7d0 100644 --- a/libsearch/index/first-run-indexer.cpp +++ b/libsearch/index/first-run-indexer.cpp @@ -28,7 +28,7 @@ #include "file-content-indexer.h" #include "writable-database.h" using namespace UkuiSearch; -FirstRunIndexer::FirstRunIndexer(const QStringList &folders, const QStringList &blackList, QAtomicInt& stop, WorkModes mode, Targets target) +FirstRunIndexer::FirstRunIndexer(const QStringList &folders, const QStringList &blackList, QAtomicInt& stop, WorkMode mode, Targets target) : m_folders(folders), m_blackList(blackList), m_stop(&stop), @@ -58,7 +58,7 @@ void FirstRunIndexer::run() m_cache.clear(); malloc_trim(0); qDebug() << "FirstRunIndexer: time :" << t.elapsed(); - Q_EMIT done(); + Q_EMIT done(m_mode); } void FirstRunIndexer::fetch() diff --git a/libsearch/index/first-run-indexer.h b/libsearch/index/first-run-indexer.h index 0d25605..c20c460 100644 --- a/libsearch/index/first-run-indexer.h +++ b/libsearch/index/first-run-indexer.h @@ -41,7 +41,7 @@ public: Add = 1, Rebuild }; - Q_DECLARE_FLAGS(WorkModes, WorkMode) + Q_ENUM(WorkMode) /** * @brief The Target enum * 要进行索引的数据库 @@ -57,7 +57,7 @@ public: }; Q_DECLARE_FLAGS(Targets, Target) - FirstRunIndexer(const QStringList& folders, const QStringList& blackList, QAtomicInt& stop, WorkModes mode = WorkMode::Update, Targets target = Target::All); + FirstRunIndexer(const QStringList& folders, const QStringList& blackList, QAtomicInt& stop, WorkMode mode = WorkMode::Update, Targets target = Target::All); ~FirstRunIndexer(); void run() override; @@ -65,14 +65,14 @@ Q_SIGNALS: void progress(IndexType type, uint all, uint finished); void basicIndexDone(int size); void contentIndexDone(int size); - void done(); + void done(WorkMode); private: void fetch(); void basicIndex(); void contentIndex(); - WorkModes m_mode; + WorkMode m_mode; Targets m_target; QStringList m_folders; QStringList m_blackList; diff --git a/libsearch/index/index-scheduler.cpp b/libsearch/index/index-scheduler.cpp index 9a7dada..6e74e91 100644 --- a/libsearch/index/index-scheduler.cpp +++ b/libsearch/index/index-scheduler.cpp @@ -29,6 +29,7 @@ IndexScheduler::IndexScheduler(QObject *parent) : m_stop(0) { qRegisterMetaType("IndexerState"); + qRegisterMetaType("FirstRunIndexer::WorkMode"); m_threadPool.setMaxThreadCount(1); connect(&m_fileWatcher, &FileWatcher::filesUpdate, this, &IndexScheduler::updateIndex); connect(m_config, &FileIndexerConfig::fileIndexEnableStatusChanged, this, &IndexScheduler::fileIndexEnable); @@ -50,6 +51,7 @@ void IndexScheduler::addNewPath(const QString &folders, const QStringList &black } m_isAddNewPathFinished = false; m_state = Running; + Q_EMIT stateChange(m_state); FirstRunIndexer::Targets target = FirstRunIndexer::Target::None; if(m_config->isFileIndexEnable()) { target |= FirstRunIndexer::Target::Basic; @@ -57,10 +59,9 @@ void IndexScheduler::addNewPath(const QString &folders, const QStringList &black if(m_config->isContentIndexEnable()) { target |= FirstRunIndexer::Target::Content; } + FirstRunIndexer::WorkMode mode = FirstRunIndexer::WorkMode::Add; + startIndexJob(QStringList() << folders, blackList, mode, target); if(FirstRunIndexer::Target::None != target) { - FirstRunIndexer *indexer = new FirstRunIndexer(QStringList(folders), blackList, m_stop, FirstRunIndexer::WorkMode::Add, target); - connect(indexer, &FirstRunIndexer::done, this, &IndexScheduler::addNewPathFinished, Qt::QueuedConnection); - m_threadPool.start(indexer); m_fileWatcher.addWatch(folders, blackList); } } @@ -96,7 +97,7 @@ void IndexScheduler::scheduleIndexing() Q_EMIT stateChange(m_state); FirstRunIndexer::Targets rebuiltTarget = checkAndRebuild(); - FirstRunIndexer::WorkModes mode = FirstRunIndexer::WorkMode::Update; + FirstRunIndexer::WorkMode mode = FirstRunIndexer::WorkMode::Update; FirstRunIndexer::Targets target = FirstRunIndexer::Target::None; //如果数据库被执行过重建,那么跳过增量更新步骤。 @@ -108,7 +109,7 @@ void IndexScheduler::scheduleIndexing() target |= FirstRunIndexer::Target::Content; m_statusRecorder->setStatus(CONTENT_INDEX_DATABASE_STATE_KEY, IndexStatusRecorder::State::Updating); } - startIndexJob(mode, target); + startIndexJob(m_config->currentIndexableDir(), m_config->currentBlackListOfIndex(), mode, target); //启动监听 m_fileWatcher.installWatches(); @@ -121,7 +122,7 @@ IndexScheduler::IndexerState IndexScheduler::getIndexState() FirstRunIndexer::Targets IndexScheduler::checkAndRebuild() { - FirstRunIndexer::WorkModes mode = FirstRunIndexer::WorkMode::Rebuild; + FirstRunIndexer::WorkMode mode = FirstRunIndexer::WorkMode::Rebuild; FirstRunIndexer::Targets target = FirstRunIndexer::Target::None; if((m_statusRecorder->getStatus(INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::Error || !m_statusRecorder->versionCheck(INDEX_DATABASE_VERSION_KEY, INDEX_DATABASE_VERSION)) && m_config->isFileIndexEnable()) { @@ -136,14 +137,14 @@ FirstRunIndexer::Targets IndexScheduler::checkAndRebuild() target |= FirstRunIndexer::Target::Content; m_statusRecorder->setStatus(CONTENT_INDEX_DATABASE_STATE_KEY, IndexStatusRecorder::State::Initializing); } - startIndexJob(mode, target); + startIndexJob(m_config->currentIndexableDir(), m_config->currentBlackListOfIndex(), mode, target); return target; } -void IndexScheduler::startIndexJob(FirstRunIndexer::WorkModes &mode, FirstRunIndexer::Targets &target) +void IndexScheduler::startIndexJob(const QStringList& folders,const QStringList& blackList, FirstRunIndexer::WorkMode mode, FirstRunIndexer::Targets target) { if(FirstRunIndexer::Target::None != target) { - FirstRunIndexer *indexer = new FirstRunIndexer(m_config->currentIndexableDir(), m_config->currentBlackListOfIndex(), m_stop, mode, target); + FirstRunIndexer *indexer = new FirstRunIndexer(folders, blackList, m_stop, mode, target); connect(indexer, &FirstRunIndexer::done, this, &IndexScheduler::firstRunFinished, Qt::QueuedConnection); connect(indexer, &FirstRunIndexer::progress, this, &IndexScheduler::process); @@ -188,13 +189,25 @@ void IndexScheduler::updateIndex(const QVector &files) m_threadPool.start(updateJob); } -void IndexScheduler::firstRunFinished() +void IndexScheduler::firstRunFinished(FirstRunIndexer::WorkMode mode) { if((m_statusRecorder->getStatus(INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::Ready) && m_statusRecorder->getStatus(CONTENT_INDEX_DATABASE_STATE_KEY).toInt() == IndexStatusRecorder::State::Ready) { - m_isFirstRunFinished = true; + switch (mode) { + case FirstRunIndexer::WorkMode::Add: + m_isAddNewPathFinished = true; + break; + case FirstRunIndexer::WorkMode::Rebuild: + m_isRebuildFinished = true; + break; + case FirstRunIndexer::WorkMode::Update: + m_isFirstRunFinished = true; + break; + default: + break; + } } - if(m_isFirstRunFinished && m_isAddNewPathFinished && m_isUpdateFinished) { + if(isIdle()) { m_state = Idle; Q_EMIT stateChange(m_state); } @@ -203,18 +216,13 @@ void IndexScheduler::firstRunFinished() void IndexScheduler::updateFinished() { m_isUpdateFinished = true; - if(m_isFirstRunFinished && m_isAddNewPathFinished) { + if(isIdle()) { m_state = Idle; Q_EMIT stateChange(m_state); } } -void IndexScheduler::addNewPathFinished() +bool IndexScheduler::isIdle() { - m_isAddNewPathFinished = true; - if(m_isFirstRunFinished && m_isUpdateFinished) { - m_state = Idle; - Q_EMIT stateChange(m_state); - } + return m_isFirstRunFinished && m_isAddNewPathFinished && m_isUpdateFinished && m_isRebuildFinished; } - diff --git a/libsearch/index/index-scheduler.h b/libsearch/index/index-scheduler.h index d89955b..960783b 100644 --- a/libsearch/index/index-scheduler.h +++ b/libsearch/index/index-scheduler.h @@ -68,9 +68,9 @@ Q_SIGNALS: private Q_SLOTS: void fileIndexEnable(bool enable); void updateIndex(const QVector& files); - void firstRunFinished(); + void firstRunFinished(FirstRunIndexer::WorkMode mode); void updateFinished(); - void addNewPathFinished(); + bool isIdle(); private: /** @@ -79,7 +79,7 @@ private: * @return 返回需要重建的数据库 */ FirstRunIndexer::Targets checkAndRebuild(); - void startIndexJob(FirstRunIndexer::WorkModes &mode, FirstRunIndexer::Targets &target); + void startIndexJob(const QStringList &folders, const QStringList &blackList, FirstRunIndexer::WorkMode mode, FirstRunIndexer::Targets target); FileWatcher m_fileWatcher; IndexStatusRecorder *m_statusRecorder = nullptr; FileIndexerConfig *m_config = nullptr; @@ -88,6 +88,7 @@ private: QThreadPool m_threadPool; bool m_isFirstRunFinished = true; + bool m_isRebuildFinished = true; bool m_isUpdateFinished = true; bool m_isAddNewPathFinished = true; }; diff --git a/libsearch/index/monitor.cpp b/libsearch/index/monitor.cpp index e9d7f98..38521dd 100644 --- a/libsearch/index/monitor.cpp +++ b/libsearch/index/monitor.cpp @@ -1,4 +1,24 @@ +/* + * Copyright (C) 2022, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: iaom + * + */ #include "monitor.h" +#include #include "file-indexer-config.h" using namespace UkuiSearch; Monitor::Monitor(IndexScheduler *scheduler, QObject *parent) @@ -7,9 +27,10 @@ Monitor::Monitor(IndexScheduler *scheduler, QObject *parent) m_basicDatabase(DataBaseType::Basic), m_contentDatabase(DataBaseType::Content) { - connect(scheduler, &IndexScheduler::stateChange, this, &Monitor::indexStateChanged); connect(scheduler, &IndexScheduler::stateChange, this, &Monitor::onIndexStateChanged); connect(scheduler, &IndexScheduler::process, this, &Monitor::processUpdate); + connect(scheduler, &IndexScheduler::basicIndexDone, this, &Monitor::basicIndexDone); + connect(scheduler, &IndexScheduler::contentIndexDone, this, &Monitor::contentIndexDone); } QStringList Monitor::getCurrentIndexPaths() @@ -17,9 +38,10 @@ QStringList Monitor::getCurrentIndexPaths() return FileIndexerConfig::getInstance()->currentIndexableDir(); } -IndexScheduler::IndexerState Monitor::getIndexState() +QString Monitor::getIndexState() { - return m_scheduler->getIndexState(); + QMetaEnum metaEnum = QMetaEnum::fromType(); + return QString::fromLocal8Bit(metaEnum.valueToKey(m_scheduler->getIndexState())); } uint Monitor::getBasicIndexSize() @@ -68,6 +90,8 @@ void Monitor::onIndexStateChanged(IndexScheduler::IndexerState state) Q_EMIT basicIndexDocNumUpdate(m_basicDatabase.getIndexDocCount()); Q_EMIT contentIndexDocNumUpdate(m_contentDatabase.getIndexDocCount()); } + QMetaEnum metaEnum = QMetaEnum::fromType(); + Q_EMIT indexStateChanged(QString::fromLocal8Bit(metaEnum.valueToKey(state))); } void Monitor::processUpdate(IndexType type, uint all, uint finished) diff --git a/libsearch/index/monitor.h b/libsearch/index/monitor.h index ce6a861..1bcbd84 100644 --- a/libsearch/index/monitor.h +++ b/libsearch/index/monitor.h @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2022, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: iaom + * + */ #ifndef MONITOR_H #define MONITOR_H @@ -14,7 +33,7 @@ class Monitor : public QObject { Q_OBJECT Q_PROPERTY(QStringList currentIndexPaths READ getCurrentIndexPaths) - Q_PROPERTY(IndexScheduler::IndexerState indexState READ getIndexState NOTIFY indexStateChanged) + Q_PROPERTY(QString indexState READ getIndexState NOTIFY indexStateChanged) Q_PROPERTY(uint basicIndexSize READ getBasicIndexSize NOTIFY basicIndexSizeChange) Q_PROPERTY(uint contentIndexSize READ getContentIndexSize NOTIFY contentIndexSizeChange) Q_PROPERTY(uint ocrIndexSize READ getOCRIndexSize NOTIFY ocrIndexSizeChange) @@ -26,28 +45,114 @@ class Monitor : public QObject public: explicit Monitor(IndexScheduler* scheduler, QObject *parent = nullptr); + /** + * @brief getCurrentIndexPaths + * @return 当前索引的所有目录 + */ QStringList getCurrentIndexPaths(); - IndexScheduler::IndexerState getIndexState(); + /** + * @brief getIndexState + * @return 当前索引调度器的状态 + */ + QString getIndexState(); + /** + * @brief getBasicIndexSize + * @return 当前需要处理的基础索引数量 + */ uint getBasicIndexSize(); + /** + * @brief getContentIndexSize + * @return 当前需要处理的内容索引数量 + */ uint getContentIndexSize(); + /** + * @brief getOCRIndexSize + * @return 当前需要处理的OCR索引数量 + */ uint getOCRIndexSize(); + /** + * @brief getBasicIndexProgress + * @return 基础索引进度 + */ uint getBasicIndexProgress(); + /** + * @brief getContentIndexProgress + * @return 内容索引进度 + */ uint getContentIndexProgress(); + /** + * @brief getOCRIndexProgress + * @return ocr索引进度 + */ uint getOCRIndexProgress(); + /** + * @brief getBasicIndexDocNum + * @return 基础索引完成的总文档数 + */ uint getBasicIndexDocNum(); + /** + * @brief getContentIndexDocNum + * @return 内容索引完成的总文档数 + */ uint getContentIndexDocNum(); Q_SIGNALS: - void indexStateChanged(IndexScheduler::IndexerState); + /** + * @brief indexStateChanged + * 索引调度器状态 + */ + void indexStateChanged(QString); + /** + * @brief basicIndexSizeChange + * 基础索引进度 + */ void basicIndexSizeChange(uint); + /** + * @brief contentIndexSizeChange + * 内容索引总量(包括OCR索引) + */ void contentIndexSizeChange(uint); + /** + * @brief ocrIndexSizeChange + * OCR索引总量 + */ void ocrIndexSizeChange(uint); + /** + * @brief basicIndexProgressUpdate + * 基础索引进度 + */ void basicIndexProgressUpdate(uint); + /** + * @brief contentIndexProgressUpdate + * 内容索引进度(包含OCR索引) + */ void contentIndexProgressUpdate(uint); + /** + * @brief ocrIndexProgressUpdate + * OCR索引进度 + */ void ocrIndexProgressUpdate(uint); + /** + * @brief basicIndexDocNumUpdate + * 基础索引完成的总文档数 + */ void basicIndexDocNumUpdate(uint); + /** + * @brief contentIndexDocNumUpdate + * 内容索引完成的总文档数 + */ void contentIndexDocNumUpdate(uint); + /** + * @brief basicIndexDone + * 基础索引数据库建立完成或完成增量更新 + */ + void basicIndexDone(); + /** + * @brief contentIndexDone + * 内容索引数据库建立完成或完成增量更新 + */ + void contentIndexDone(); private Q_SLOTS: void onIndexStateChanged(IndexScheduler::IndexerState); diff --git a/ukui-search-service/main.cpp b/ukui-search-service/main.cpp index 7daf387..bddb052 100644 --- a/ukui-search-service/main.cpp +++ b/ukui-search-service/main.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2022, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: iaom + * + */ #include #include #include diff --git a/ukui-search-service/qml/IndexMonitor.qml b/ukui-search-service/qml/IndexMonitor.qml index 7ae4791..f0c9983 100644 --- a/ukui-search-service/qml/IndexMonitor.qml +++ b/ukui-search-service/qml/IndexMonitor.qml @@ -1,6 +1,137 @@ +/* + * Copyright (C) 2022, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: iaom + * + */ import QtQuick 2.0 -import QtQuick.Window 2.12 +import QtQuick.Layouts 1.12 -Window { +Rectangle { + height: 180 + width: 320 + Column { + visible: true + width: parent.width + height: childrenRect.height + StatusKeyValue { + id: basicIndexDocumentNum + keyText: qsTr("Basic index document number") + valueText: "--" + } + StatusKeyValue { + id: contentIndexDocumentNum + keyText: qsTr("Content index document number") + valueText: "--" + } + + StatusKeyValue { + id: indexState + keyText: qsTr("Index state") + valueText: "--" + } + + IndexProgressBar { + id: basicIndexProgress + width: parent.width; + name: "Basic index progress" + from: 0 + visible: false + } + + IndexProgressBar { + id: contentIndexProgress + width: parent.width; + name: "Content index progress" + from: 0 + visible: false + } + + IndexProgressBar { + id: ocrIndexProgress + name: "OCR index progress" + width: parent.width; + from: 0 + visible: false + } + + Component.onCompleted: { + basicIndexDocumentNum.valueText = monitor.basicIndexDocNum + contentIndexDocumentNum.valueText = monitor.contentIndexDocNum + indexState.valueText = monitor.indexState + monitor.basicIndexDocNumUpdate.connect(onBasicIndexDocNumUpdate); + monitor.contentIndexDocNumUpdate.connect(onContentIndexDocumentNum); + monitor.indexStateChanged.connect(onIndexStateChanged); + monitor.basicIndexSizeChange.connect(onBasicIndexSizeChange); + monitor.basicIndexProgressUpdate.connect(onBasicIndexProgressUpdate); + monitor.contentIndexSizeChange.connect(onContentIndexSizeChange); + monitor.contentIndexProgressUpdate.connect(onContentIndexProgressUpdate); + monitor.ocrIndexSizeChange.connect(onOcrIndexSizeChange); + monitor.onOcrIndexProgressUpdate.connect(onOcrIndexProgressUpdate); + monitor.basicIndexDone.connect(onBasicIndexDone); + monitor.contentIndexDone.connect(onContentIndexDone); + } + function onBasicIndexDocNumUpdate(num) { + var numStr = "%1"; + basicIndexDocumentNum.valueText = numStr.arg(num); + } + function onContentIndexDocumentNum(num) { + var numStr = "%1"; + contentIndexDocumentNum.valueText = numStr.arg(num); + } + function onIndexStateChanged(state) { + indexState.valueText = state; + } + function onBasicIndexSizeChange(num) { + if(!basicIndexProgress.visible) { + basicIndexProgress.visible = true; + } + basicIndexProgress.to = num; + } + function onBasicIndexProgressUpdate(num) { + basicIndexProgress.value = num; + basicIndexProgress.state = "Running" + } + function onContentIndexSizeChange(num) { + if(!contentIndexProgress.visible) { + contentIndexProgress.visible = true; + } + contentIndexProgress.to = num; + } + function onContentIndexProgressUpdate(num) { + contentIndexProgress.value = num; + contentIndexProgress.state = "Running" + } + function onOcrIndexSizeChange(num) { + if(!ocrIndexProgress.visible) { + ocrIndexProgress.visible = true; + } + ocrIndexProgress.to = num; + } + function onOcrIndexProgressUpdate(num) { + ocrIndexProgress.value = num; + ocrIndexProgress.state = "Running" + } + function onBasicIndexDone() { + basicIndexProgress.state = "Done" + } + function onContentIndexDone() { + contentIndexProgress.state = "Done" + ocrIndexProgress.state = "Done" + } + } } diff --git a/ukui-search-service/qml/IndexProgressBar.qml b/ukui-search-service/qml/IndexProgressBar.qml index d4ac4f6..35cf945 100644 --- a/ukui-search-service/qml/IndexProgressBar.qml +++ b/ukui-search-service/qml/IndexProgressBar.qml @@ -1,8 +1,105 @@ +/* + * Copyright (C) 2022, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: iaom + * + */ import QtQuick 2.0 import QtQuick.Controls 2.5 -Item { - ProgressBar { +Column { + id: progressBar + width: parent.width + property var from: 0 + property var to: 0 + property var value: 0 + property string name: "" + property string state: "" + + Row { + Text { + id: progressName + anchors.left: parent.Left + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.family: "stxihei" + font.pixelSize: 14 + color: "black" + text: progressBar.name + } + Text { + id: progressState + anchors.left: parent.Right + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.family: "stxihei" + font.pixelSize: 14 + color: "blue" + text: progressBar.state + } + } + + + Row { + width: parent.width + ProgressBar { + width: parent.width * 2 / 3 + height: 16 + from: progressBar.from + to: progressBar.to + value: progressBar.value + } + Text { + id: progressNum + anchors.left: parent.Right + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.family: "stxihei" + font.pixelSize: 10 + color: "blue" + + text: "--/--" + } + } + + Component.onCompleted: { + updateProgressNum(); } + onToChanged: { + updateProgressNum(); + } + + onValueChanged: { + updateProgressNum(); + } + + onNameChanged: { + progressName.text = progressBar.name; + } + + onStateChanged: { + progressState.text = progressBar.state; + } + + function updateProgressNum() { + var str = "%1/%2"; + progressNum.text = str.arg(progressBar.value).arg(progressBar.to); + } } + + + diff --git a/ukui-search-service/qml/StatusKeyValue.qml b/ukui-search-service/qml/StatusKeyValue.qml new file mode 100644 index 0000000..8a35535 --- /dev/null +++ b/ukui-search-service/qml/StatusKeyValue.qml @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2022, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: iaom + * + */ +import QtQuick 2.0 + +Row { + id: kvRow + width: parent.width + height: childrenRect.height + property string keyText : "--" + property string valueText :"--" + Text { + id: keyTextLabel + anchors.left: parent.Left + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.family: "stxihei" + font.pixelSize: 16 + color: "black" + text: kvRow.keyText + } + Text { + id: valueTextLabel + anchors.left: parent.Right + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.family: "stxihei" + font.pixelSize: 16 + color: "blue" + text: kvRow.valueText + } + onKeyTextChanged: { + keyTextLabel.text = keyText + } + onValueTextChanged: { + valueTextLabel.text = valueText + } +} + diff --git a/ukui-search-service/qml/qml.pri b/ukui-search-service/qml/qml.pri index 209c524..51168f2 100644 --- a/ukui-search-service/qml/qml.pri +++ b/ukui-search-service/qml/qml.pri @@ -4,5 +4,6 @@ RESOURCES += qmlFile DISTFILES += \ $$PWD/IndexMonitor.qml \ - $$PWD/IndexProgressBar.qml + $$PWD/IndexProgressBar.qml \ + $$PWD/StatusKeyValue.qml diff --git a/ukui-search-service/ukui-search-service.cpp b/ukui-search-service/ukui-search-service.cpp index 6a7b87c..54d0dab 100644 --- a/ukui-search-service/ukui-search-service.cpp +++ b/ukui-search-service/ukui-search-service.cpp @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2022, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: iaom + * + */ #include #include #include @@ -91,8 +110,12 @@ void UkuiSearchService::parseCmd(QString msg, bool isPrimary) void UkuiSearchService::loadMonitorWindow() { + if(!m_monitor) { + m_monitor = new Monitor(m_indexScheduler, this); + } if(!m_quickView) { m_quickView = new QQuickView(); + m_quickView->setResizeMode(QQuickView::SizeRootObjectToView); m_quickView->rootContext()->setContextProperty("monitor", m_monitor); m_quickView->setSource(m_qmlPath); } diff --git a/ukui-search-service/ukui-search-service.h b/ukui-search-service/ukui-search-service.h index c361e97..c0ee5ca 100644 --- a/ukui-search-service/ukui-search-service.h +++ b/ukui-search-service/ukui-search-service.h @@ -27,7 +27,7 @@ private: IndexScheduler *m_indexScheduler = nullptr; Monitor *m_monitor = nullptr; QQuickView *m_quickView = nullptr; - QString m_qmlPath = "qrc:/qml/IndexMonitor.qml"; + QUrl m_qmlPath = QString("qrc:/qml/IndexMonitor.qml"); }; }