Commit c700f72d authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

allow the user via to configure Elisa not to rely on Baloo

allow users to workaround missing music files in Baloo index by
configuring Elisa not to rely only on it.

BUG: 417822
parent 5c4b45a0
......@@ -7,6 +7,8 @@
<group name="ElisaFileIndexer">
<entry key="RootPath" type="PathList" >
</entry>
<entry key="ForceUsageOfFastFileSearch" type="Bool" >
</entry>
</group>
<group name="PlayerSettings">
<entry key="ShowProgressOnTaskBar" type="Bool" >
......
......@@ -17,6 +17,7 @@
#include "localfilelisting.h"
#include "filescanner.h"
#include "abstractfile/indexercommon.h"
#include <QThread>
......@@ -86,5 +87,23 @@ void LocalFileListing::triggerStop()
AbstractFileListing::triggerStop();
}
DataTypes::TrackDataType LocalFileListing::scanOneFile(const QUrl &scanFile, const QFileInfo &scanFileInfo)
{
auto trackData = fileScanner().scanOneBalooFile(scanFile, scanFileInfo);
if (!trackData.isValid()) {
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::scanOneFile" << scanFile << "falling back to plain file metadata analysis";
trackData = AbstractFileListing::scanOneFile(scanFile, scanFileInfo);
}
if (trackData.isValid()) {
addCover(trackData);
} else {
qCDebug(orgKdeElisaIndexer()) << "LocalFileListing::scanOneFile" << scanFile << "invalid track";
}
return trackData;
}
#include "moc_localfilelisting.cpp"
......@@ -46,6 +46,8 @@ private:
void triggerStop() override;
DataTypes::TrackDataType scanOneFile(const QUrl &scanFile, const QFileInfo &scanFileInfo) override;
std::unique_ptr<LocalFileListingPrivate> d;
};
......
......@@ -36,6 +36,7 @@ ElisaConfigurationDialog::ElisaConfigurationDialog(QObject* parent)
setRootPath(Elisa::ElisaConfiguration::rootPath());
setShowProgressInTaskBar(Elisa::ElisaConfiguration::showProgressOnTaskBar());
setForceUsageOfFastFileSearch(Elisa::ElisaConfiguration::forceUsageOfFastFileSearch());
save();
mConfigFileWatcher.addPath(Elisa::ElisaConfiguration::self()->config()->name());
......@@ -86,6 +87,7 @@ void ElisaConfigurationDialog::save()
{
Elisa::ElisaConfiguration::setRootPath(mRootPath);
Elisa::ElisaConfiguration::setShowProgressOnTaskBar(mShowProgressInTaskBar);
Elisa::ElisaConfiguration::setForceUsageOfFastFileSearch(mForceUsageOfFastFileSearch);
Elisa::ElisaConfiguration::self()->save();
mIsDirty = false;
......@@ -104,6 +106,18 @@ void ElisaConfigurationDialog::setShowProgressInTaskBar(bool showProgressInTaskB
setDirty();
}
void ElisaConfigurationDialog::setForceUsageOfFastFileSearch(bool forceUsageOfFastFileSearch)
{
if (mForceUsageOfFastFileSearch == forceUsageOfFastFileSearch) {
return;
}
mForceUsageOfFastFileSearch = forceUsageOfFastFileSearch;
Q_EMIT forceUsageOfFastFileSearchChanged();
setDirty();
}
void ElisaConfigurationDialog::configChanged()
{
setRootPath(Elisa::ElisaConfiguration::rootPath());
......
......@@ -33,6 +33,11 @@ class ELISALIB_EXPORT ElisaConfigurationDialog : public QObject
WRITE setRootPath
NOTIFY rootPathChanged)
Q_PROPERTY(bool forceUsageOfFastFileSearch
READ forceUsageOfFastFileSearch
WRITE setForceUsageOfFastFileSearch
NOTIFY forceUsageOfFastFileSearchChanged)
Q_PROPERTY(bool showProgressInTaskBar
READ showProgressInTaskBar
WRITE setShowProgressInTaskBar
......@@ -60,6 +65,11 @@ public:
return mShowProgressInTaskBar;
}
bool forceUsageOfFastFileSearch() const
{
return mForceUsageOfFastFileSearch;
}
Q_SIGNALS:
void rootPathChanged(const QStringList &rootPath);
......@@ -68,6 +78,8 @@ Q_SIGNALS:
void showProgressInTaskBarChanged();
void forceUsageOfFastFileSearchChanged();
public Q_SLOTS:
void setRootPath(const QStringList &rootPath);
......@@ -76,6 +88,8 @@ public Q_SLOTS:
void setShowProgressInTaskBar(bool showProgressInTaskBar);
void setForceUsageOfFastFileSearch(bool forceUsageOfFastFileSearch);
private Q_SLOTS:
void configChanged();
......@@ -91,6 +105,7 @@ private:
bool mIsDirty = false;
bool mShowProgressInTaskBar = true;
bool mForceUsageOfFastFileSearch;
};
#endif
......@@ -222,6 +222,8 @@ auto MusicListenersManager::initializeRootPath()
}
Elisa::ElisaConfiguration::setRootPath(initialRootPath);
Elisa::ElisaConfiguration::setShowProgressOnTaskBar(true);
Elisa::ElisaConfiguration::setForceUsageOfFastFileSearch(true);
Elisa::ElisaConfiguration::self()->save();
return initialRootPath;
......@@ -365,16 +367,17 @@ void MusicListenersManager::configChanged()
}
#if defined KF5Baloo_FOUND && KF5Baloo_FOUND
if (d->mBalooIndexerAvailable && !d->mBalooIndexerActive && d->mBalooListener.canHandleRootPaths())
{
if (d->mBalooIndexerAvailable && !d->mBalooIndexerActive && d->mBalooListener.canHandleRootPaths() && currentConfiguration->forceUsageOfFastFileSearch()) {
qCDebug(orgKdeElisaIndexersManager()) << "trigger start of baloo file indexer";
QMetaObject::invokeMethod(d->mFileListener.fileListing(), "stop", Qt::BlockingQueuedConnection);
d->mFileSystemIndexerActive = false;
startBalooIndexing();
} else if (!d->mFileSystemIndexerActive && d->mBalooIndexerActive && !d->mBalooListener.canHandleRootPaths())
{
qCDebug(orgKdeElisaIndexersManager()) << "trigger stop of baloo file indexer";
QMetaObject::invokeMethod(d->mBalooListener.fileListing(), "stop", Qt::BlockingQueuedConnection);
} else if ((!d->mFileSystemIndexerActive && d->mBalooIndexerActive && !d->mBalooListener.canHandleRootPaths()) ||
!currentConfiguration->forceUsageOfFastFileSearch()) {
if (d->mBalooIndexerActive) {
qCDebug(orgKdeElisaIndexersManager()) << "trigger stop of baloo file indexer";
QMetaObject::invokeMethod(d->mBalooListener.fileListing(), "stop", Qt::BlockingQueuedConnection);
}
d->mBalooIndexerActive = false;
startLocalFileSystemIndexing();
}
......
......@@ -65,30 +65,34 @@ Window {
Kirigami.Heading {
text: i18n('General')
Layout.leftMargin: 5
Layout.rightMargin: 5
}
GeneralConfiguration {
Layout.fillWidth: true
Layout.topMargin: 10
Layout.leftMargin: 20
Layout.rightMargin: 10
}
Kirigami.Heading {
text: i18n('Music Search Paths')
text: i18n('Music Search Configuration')
Layout.topMargin: 15
Layout.leftMargin: 5
Layout.rightMargin: 5
Layout.topMargin: 15
}
FileScanningConfiguration {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin: 10
Layout.rightMargin: 10
Layout.topMargin: 10
Layout.leftMargin: 20
Layout.rightMargin: 10
}
DialogButtonBox {
......
......@@ -21,125 +21,144 @@ import QtQuick.Layouts 1.3
import QtQml.Models 2.3
import QtQuick.Dialogs 1.2 as Dialogs
RowLayout {
ColumnLayout {
spacing: 0
SystemPalette {
id: myPalette
colorGroup: SystemPalette.Active
}
CheckBox {
id: forceFileIndexerUsageCheckBox
Component {
id: highlightBar
text: i18n("Force use of filesystem indexing.\nThis is much slower than usage of fast search !\nPlease activate it only if Elisa cannot find your music and searching for the file also does not work.\nPlease report this as a bug.")
Rectangle {
width: 200; height: 50
color: myPalette.highlight
}
checked: !config.forceUsageOfFastFileSearch
onCheckedChanged: config.forceUsageOfFastFileSearch = !checked
}
Component {
id: pathDelegate
RowLayout {
Layout.fillHeight: true
Layout.fillWidth: true
Layout.topMargin: 10
Item {
id: delegateItem
spacing: 0
height: 3 * 30
SystemPalette {
id: myPalette
colorGroup: SystemPalette.Active
}
width: scrollBar.visible ? pathList.width - scrollBar.width : pathList.width
Component {
id: highlightBar
Rectangle {
anchors.fill: parent
anchors.margins: 0.1 * 30
width: 200; height: 50
color: myPalette.highlight
}
}
Component {
id: pathDelegate
Item {
id: delegateItem
height: 3 * 30
color: myPalette.base
width: scrollBar.visible ? pathList.width - scrollBar.width : pathList.width
MouseArea {
Rectangle {
anchors.fill: parent
anchors.margins: 0.1 * 30
hoverEnabled: true
color: myPalette.base
onEntered: pathList.currentIndex = delegateItem.DelegateModel.itemsIndex
MouseArea {
anchors.fill: parent
Label {
text: modelData
hoverEnabled: true
anchors.centerIn: parent
}
onEntered: pathList.currentIndex = delegateItem.DelegateModel.itemsIndex
Label {
text: modelData
anchors.centerIn: parent
}
ToolButton {
icon.name: 'list-remove'
ToolButton {
icon.name: 'list-remove'
Accessible.onPressAction: onClicked
Accessible.onPressAction: onClicked
anchors.top: parent.top
anchors.right: parent.right
anchors.top: parent.top
anchors.right: parent.right
onClicked:
{
var oldPaths = config.rootPath
oldPaths.splice(delegateItem.DelegateModel.itemsIndex, 1)
config.rootPath = oldPaths
onClicked:
{
var oldPaths = config.rootPath
oldPaths.splice(delegateItem.DelegateModel.itemsIndex, 1)
config.rootPath = oldPaths
}
}
}
}
}
}
}
ListView {
id:pathList
ListView {
id:pathList
Layout.fillWidth: true
Layout.fillHeight: true
boundsBehavior: Flickable.StopAtBounds
Layout.fillWidth: true
Layout.fillHeight: true
boundsBehavior: Flickable.StopAtBounds
clip: true
clip: true
model: DelegateModel {
model: config.rootPath
model: DelegateModel {
model: config.rootPath
delegate: pathDelegate
}
delegate: pathDelegate
}
ScrollBar.vertical: ScrollBar {
id: scrollBar
}
ScrollBar.vertical: ScrollBar {
id: scrollBar
}
highlight: highlightBar
}
highlight: highlightBar
}
ColumnLayout {
Layout.fillHeight: true
Layout.leftMargin: !LayoutMirroring.enabled ? (0.3 * 30) : 0
Layout.rightMargin: LayoutMirroring.enabled ? (0.3 * 30) : 0
ColumnLayout {
Layout.fillHeight: true
Layout.leftMargin: !LayoutMirroring.enabled ? (0.3 * 30) : 0
Layout.rightMargin: LayoutMirroring.enabled ? (0.3 * 30) : 0
Button {
text: i18n("Add new path")
onClicked: fileDialog.open()
Button {
text: i18n("Add new path")
onClicked: fileDialog.open()
Accessible.onPressAction: onClicked
Accessible.onPressAction: onClicked
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
Dialogs.FileDialog {
id: fileDialog
title: i18n("Choose a Folder")
folder: shortcuts.home
selectFolder: true
Dialogs.FileDialog {
id: fileDialog
title: i18n("Choose a Folder")
folder: shortcuts.home
selectFolder: true
visible: false
visible: false
onAccepted: {
var oldPaths = config.rootPath
oldPaths.push(fileDialog.fileUrls)
config.rootPath = oldPaths
onAccepted: {
var oldPaths = config.rootPath
oldPaths.push(fileDialog.fileUrls)
config.rootPath = oldPaths
}
}
}
}
Item {
Layout.fillHeight: true
Item {
Layout.fillHeight: true
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment