forked from openkylin/ukui-search
Add the refresh of search dirs' ui in ukcc plugin when the udisk is unplugged.
This commit is contained in:
parent
020f869a29
commit
29c6440e23
|
@ -19,6 +19,10 @@ Search::Search()
|
|||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
|
||||
if (m_interface->isValid()) {
|
||||
connect(m_interface, SIGNAL(indexDirsChanged()), this, SLOT(refreshSearchDirsUi()));
|
||||
}
|
||||
|
||||
m_setSearchDirInterface = new QDBusInterface("com.ukui.search.fileindex.service",
|
||||
"/org/ukui/search/fileindex",
|
||||
"org.ukui.search.fileindex",
|
||||
|
@ -386,6 +390,17 @@ void Search::initUi()
|
|||
m_mainLyt->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void Search::refreshSearchDirsUi()
|
||||
{
|
||||
qWarning() << "==========refreshUi!!!!";
|
||||
while (m_searchDirLyt->count() - 1) {
|
||||
QWidget *widget = m_searchDirLyt->itemAt(m_searchDirLyt->count() - 1)->widget();
|
||||
m_searchDirLyt->removeWidget(widget);
|
||||
widget->deleteLater();
|
||||
}
|
||||
initSearchDirs();
|
||||
}
|
||||
|
||||
void Search::initFileDialog()
|
||||
{
|
||||
//添加黑名单对话框
|
||||
|
|
|
@ -62,6 +62,9 @@ public:
|
|||
QIcon icon() const Q_DECL_OVERRIDE;
|
||||
bool isEnable() const Q_DECL_OVERRIDE;
|
||||
|
||||
public Q_SLOTS:
|
||||
void refreshSearchDirsUi();
|
||||
|
||||
private:
|
||||
QWidget * m_pluginWidget = nullptr;
|
||||
QString m_plugin_name = "";
|
||||
|
|
|
@ -66,15 +66,21 @@ void DirWatcher::updateIndexableDirs()
|
|||
m_indexableDirList = m_qSettings->value(INDEXABLE_DIR_VALUE).toStringList();
|
||||
m_qSettings->endGroup();
|
||||
QStringList indexableDirs = m_indexableDirList;
|
||||
bool changed(false);
|
||||
for (const QString& dir : m_indexableDirList) {
|
||||
if (!QFileInfo(dir).isDir()) {
|
||||
indexableDirs.removeAll(dir);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
m_qSettings->beginGroup(INDEXABLE_DIR_VALUE);
|
||||
m_qSettings->setValue(INDEXABLE_DIR_VALUE, indexableDirs);
|
||||
m_qSettings->endGroup();
|
||||
m_indexableDirList = indexableDirs;
|
||||
|
||||
if (changed) {
|
||||
m_qSettings->beginGroup(INDEXABLE_DIR_VALUE);
|
||||
m_qSettings->setValue(INDEXABLE_DIR_VALUE, indexableDirs);
|
||||
m_qSettings->endGroup();
|
||||
m_indexableDirList = indexableDirs;
|
||||
Q_EMIT this->indexDirsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QStringList DirWatcher::currentBlackListOfIndex()
|
||||
|
@ -249,8 +255,9 @@ void DirWatcher::mountRemoveCallback(GVolumeMonitor *monitor, GMount *gmount, Di
|
|||
qDebug() << "Mount Removed";
|
||||
pThis->handleDisk();
|
||||
QMutexLocker locker(&s_mutex);
|
||||
//处理u盘设备(由于udisk2信号连不上,不生效)
|
||||
//处理u盘设备
|
||||
if (pThis->m_removedUDiskDevice != NULL) {
|
||||
pThis->updateIndexableDirs();//更新索引名单,排除失效目录
|
||||
pThis->m_currentUDiskDeviceInfo.remove(pThis->m_removedUDiskDevice);
|
||||
qDebug() << "m_currentUDiskDeviceInfo(after remove):" << pThis->m_currentUDiskDeviceInfo;
|
||||
pThis->m_removedUDiskDevice = "";
|
||||
|
|
|
@ -106,6 +106,7 @@ Q_SIGNALS:
|
|||
void udiskRemoved();
|
||||
void appendIndexItem(const QString&, const QStringList&);
|
||||
void removeIndexItem(const QString&);
|
||||
void indexDirsChanged();
|
||||
};
|
||||
|
||||
#endif // MOUNTDISKLISTENER_H
|
||||
|
|
Loading…
Reference in New Issue