Delete unused
This commit is contained in:
parent
ec4bffde8b
commit
f60defc695
@ -23,6 +23,7 @@ namespace fuzzy
|
||||
|
||||
class FuzzyFinder
|
||||
{
|
||||
void addDesktopApps(); // Deprecated - use PluginManager instead
|
||||
public:
|
||||
// Find method for string candidates
|
||||
std::vector<FuzzyMatch> find(const std::vector<std::string> &candidates,
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "ui/AppListModel.hpp"
|
||||
#include "plugins/PluginManager.hpp"
|
||||
#include "plugins/DesktopAppPlugin.hpp"
|
||||
#include "plugins/FileSearch/FileSearchPlugin.hpp"
|
||||
#include "plugins/FileSearchPlugin.hpp"
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
@ -47,7 +47,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Initialize plugin system
|
||||
auto &pluginManager = plugins::PluginManager::instance();
|
||||
// pluginManager.registerPlugin(std::make_unique<plugins::DesktopAppPlugin>());
|
||||
pluginManager.registerPlugin(std::make_unique<plugins::DesktopAppPlugin>());
|
||||
pluginManager.registerPlugin(std::make_unique<plugins::FileSearchPlugin>());
|
||||
|
||||
// Enable system theme support
|
||||
|
@ -1,54 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../lib/plugins/PluginInterface.hpp"
|
||||
#include "../../lib/ui/GenericListItem.hpp"
|
||||
|
||||
namespace plugins
|
||||
{
|
||||
// Example of how simple it is to create a new plugin
|
||||
class ExamplePlugin : public SearchPlugin
|
||||
{
|
||||
public:
|
||||
std::vector<ListItemPtr> search(const QString& query) override
|
||||
{
|
||||
std::vector<ListItemPtr> results;
|
||||
|
||||
// Example: Create some sample items that match any query
|
||||
if (query.contains("test", Qt::CaseInsensitive)) {
|
||||
// Using the convenient factory function
|
||||
results.push_back(ListItems::createItem(
|
||||
"Test Item 1",
|
||||
"This is a test item",
|
||||
"example",
|
||||
[]() { /* custom action */ }
|
||||
));
|
||||
|
||||
// Or create directly with GenericListItem
|
||||
results.push_back(std::make_shared<GenericListItem>(
|
||||
"Test Item 2",
|
||||
"Another test item",
|
||||
QUrl(), // no icon
|
||||
"example",
|
||||
[]() {
|
||||
// Custom execute action
|
||||
qDebug() << "Test item executed!";
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
std::vector<ListItemPtr> getAllItems() override
|
||||
{
|
||||
// Return some default items
|
||||
return {
|
||||
ListItems::createItem("Example Item", "Always visible", "example")
|
||||
};
|
||||
}
|
||||
|
||||
QString pluginName() const override { return "Example Plugin"; }
|
||||
QString pluginDescription() const override { return "Demonstrates easy plugin creation"; }
|
||||
int priority() const override { return 10; } // Low priority
|
||||
};
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "FileSearchPlugin.hpp"
|
||||
#include <QDir>
|
||||
|
||||
namespace plugins
|
||||
{
|
||||
// Example configurations for the FileSearchPlugin
|
||||
|
||||
// Configuration 1: Document searcher
|
||||
inline std::unique_ptr<FileSearchPlugin> createDocumentSearcher() {
|
||||
std::vector<std::string> searchDirs = {
|
||||
QDir::homePath().toStdString() + "/Documents",
|
||||
QDir::homePath().toStdString() + "/Desktop"
|
||||
};
|
||||
|
||||
std::vector<std::string> ignoreDirs = {
|
||||
QDir::homePath().toStdString() + "/.cache",
|
||||
QDir::homePath().toStdString() + "/.local/share/Trash"
|
||||
};
|
||||
|
||||
return std::make_unique<FileSearchPlugin>(
|
||||
searchDirs,
|
||||
ignoreDirs,
|
||||
2, // max depth
|
||||
500 // max files
|
||||
);
|
||||
}
|
||||
|
||||
// Configuration 2: Code project searcher
|
||||
inline std::unique_ptr<FileSearchPlugin> createCodeSearcher() {
|
||||
std::vector<std::string> searchDirs = {
|
||||
QDir::homePath().toStdString() + "/projects",
|
||||
QDir::homePath().toStdString() + "/dev",
|
||||
QDir::homePath().toStdString() + "/code"
|
||||
};
|
||||
|
||||
std::vector<std::string> ignoreDirs = {
|
||||
QDir::homePath().toStdString() + "/projects/node_modules",
|
||||
QDir::homePath().toStdString() + "/projects/.git",
|
||||
QDir::homePath().toStdString() + "/projects/build",
|
||||
QDir::homePath().toStdString() + "/projects/target"
|
||||
};
|
||||
|
||||
return std::make_unique<FileSearchPlugin>(
|
||||
searchDirs,
|
||||
ignoreDirs,
|
||||
4, // deeper search for code projects
|
||||
1000 // more files for code projects
|
||||
);
|
||||
}
|
||||
|
||||
// Configuration 3: Media searcher
|
||||
inline std::unique_ptr<FileSearchPlugin> createMediaSearcher() {
|
||||
std::vector<std::string> searchDirs = {
|
||||
QDir::homePath().toStdString() + "/Pictures",
|
||||
QDir::homePath().toStdString() + "/Music",
|
||||
QDir::homePath().toStdString() + "/Videos",
|
||||
QDir::homePath().toStdString() + "/Downloads"
|
||||
};
|
||||
|
||||
std::vector<std::string> ignoreDirs = {
|
||||
QDir::homePath().toStdString() + "/.thumbnails"
|
||||
};
|
||||
|
||||
return std::make_unique<FileSearchPlugin>(
|
||||
searchDirs,
|
||||
ignoreDirs,
|
||||
3, // medium depth
|
||||
2000 // lots of media files
|
||||
);
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
// Example showing how to integrate FileSearchPlugin into main.cpp
|
||||
// This is not compiled - it's just a reference for how to use the plugin
|
||||
|
||||
/*
|
||||
#include "plugins/FileSearchPlugin.hpp"
|
||||
#include "plugins/FileSearchExample.hpp"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
QCoreApplication::setApplicationName("waycast");
|
||||
|
||||
// Initialize plugin system
|
||||
auto& pluginManager = plugins::PluginManager::instance();
|
||||
|
||||
// Register desktop app plugin
|
||||
pluginManager.registerPlugin(std::make_unique<plugins::DesktopAppPlugin>());
|
||||
|
||||
// Register file search plugins with different configurations
|
||||
|
||||
// Option 1: Use default configuration
|
||||
pluginManager.registerPlugin(std::make_unique<plugins::FileSearchPlugin>());
|
||||
|
||||
// Option 2: Use custom configuration
|
||||
std::vector<std::string> customSearchDirs = {
|
||||
"/home/user/Documents",
|
||||
"/home/user/Projects"
|
||||
};
|
||||
std::vector<std::string> customIgnoreDirs = {
|
||||
"/home/user/.cache",
|
||||
"/home/user/Projects/node_modules"
|
||||
};
|
||||
pluginManager.registerPlugin(std::make_unique<plugins::FileSearchPlugin>(
|
||||
customSearchDirs,
|
||||
customIgnoreDirs,
|
||||
3, // max depth
|
||||
1000 // max files
|
||||
));
|
||||
|
||||
// Option 3: Use predefined configurations
|
||||
pluginManager.registerPlugin(plugins::createDocumentSearcher());
|
||||
pluginManager.registerPlugin(plugins::createMediaSearcher());
|
||||
|
||||
// Continue with rest of Qt application setup...
|
||||
// ...
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
*/
|
@ -8,6 +8,8 @@
|
||||
#include <QProcess>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <QIcon>
|
||||
#include <QFile>
|
||||
#include <filesystem>
|
||||
#include <unordered_set>
|
||||
#include <algorithm>
|
||||
@ -250,34 +252,136 @@ namespace plugins
|
||||
QUrl getFileIcon(const std::filesystem::path &filePath) const
|
||||
{
|
||||
QString ext = QString::fromStdString(filePath.extension().string()).toLower();
|
||||
|
||||
// Return basic icon URLs - you could expand this with a proper icon system
|
||||
if (ext == ".txt" || ext == ".md" || ext == ".rst")
|
||||
QString iconName;
|
||||
|
||||
// Use freedesktop.org standard icon names that respect user themes
|
||||
if (ext == ".txt" || ext == ".md" || ext == ".rst" || ext == ".readme")
|
||||
{
|
||||
return QUrl("qrc:/icons/text-file.svg");
|
||||
iconName = "text-x-generic";
|
||||
}
|
||||
else if (ext == ".pdf")
|
||||
{
|
||||
return QUrl("qrc:/icons/pdf-file.svg");
|
||||
iconName = "application-pdf";
|
||||
}
|
||||
else if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif" || ext == ".bmp")
|
||||
else if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif" ||
|
||||
ext == ".bmp" || ext == ".svg" || ext == ".webp" || ext == ".tiff")
|
||||
{
|
||||
return QUrl("qrc:/icons/image-file.svg");
|
||||
iconName = "image-x-generic";
|
||||
}
|
||||
else if (ext == ".mp3" || ext == ".wav" || ext == ".ogg" || ext == ".flac")
|
||||
else if (ext == ".mp3" || ext == ".wav" || ext == ".ogg" || ext == ".flac" ||
|
||||
ext == ".m4a" || ext == ".aac" || ext == ".wma")
|
||||
{
|
||||
return QUrl("qrc:/icons/audio-file.svg");
|
||||
iconName = "audio-x-generic";
|
||||
}
|
||||
else if (ext == ".mp4" || ext == ".avi" || ext == ".mkv" || ext == ".webm")
|
||||
else if (ext == ".mp4" || ext == ".avi" || ext == ".mkv" || ext == ".webm" ||
|
||||
ext == ".mov" || ext == ".wmv" || ext == ".flv" || ext == ".m4v")
|
||||
{
|
||||
return QUrl("qrc:/icons/video-file.svg");
|
||||
iconName = "video-x-generic";
|
||||
}
|
||||
else if (ext == ".cpp" || ext == ".hpp" || ext == ".c" || ext == ".h" || ext == ".py" || ext == ".js")
|
||||
else if (ext == ".zip" || ext == ".tar" || ext == ".gz" || ext == ".bz2" ||
|
||||
ext == ".xz" || ext == ".7z" || ext == ".rar")
|
||||
{
|
||||
return QUrl("qrc:/icons/code-file.svg");
|
||||
iconName = "package-x-generic";
|
||||
}
|
||||
else if (ext == ".cpp" || ext == ".hpp" || ext == ".c" || ext == ".h")
|
||||
{
|
||||
iconName = "text-x-c++src";
|
||||
}
|
||||
else if (ext == ".py")
|
||||
{
|
||||
iconName = "text-x-python";
|
||||
}
|
||||
else if (ext == ".js" || ext == ".ts" || ext == ".json")
|
||||
{
|
||||
iconName = "text-x-javascript";
|
||||
}
|
||||
else if (ext == ".html" || ext == ".htm" || ext == ".css")
|
||||
{
|
||||
iconName = "text-html";
|
||||
}
|
||||
else if (ext == ".xml" || ext == ".xsl" || ext == ".xsd")
|
||||
{
|
||||
iconName = "text-xml";
|
||||
}
|
||||
else if (ext == ".sh" || ext == ".bash" || ext == ".zsh")
|
||||
{
|
||||
iconName = "text-x-script";
|
||||
}
|
||||
else if (ext == ".doc" || ext == ".docx" || ext == ".odt")
|
||||
{
|
||||
iconName = "application-vnd.oasis.opendocument.text";
|
||||
}
|
||||
else if (ext == ".xls" || ext == ".xlsx" || ext == ".ods")
|
||||
{
|
||||
iconName = "application-vnd.oasis.opendocument.spreadsheet";
|
||||
}
|
||||
else if (ext == ".ppt" || ext == ".pptx" || ext == ".odp")
|
||||
{
|
||||
iconName = "application-vnd.oasis.opendocument.presentation";
|
||||
}
|
||||
else
|
||||
{
|
||||
iconName = "text-x-generic";
|
||||
}
|
||||
|
||||
// Use Qt's icon theme system to find the actual icon file
|
||||
return resolveThemeIcon(iconName);
|
||||
}
|
||||
|
||||
return QUrl("qrc:/icons/file.svg");
|
||||
QUrl resolveThemeIcon(const QString& iconName) const
|
||||
{
|
||||
// First try Qt's theme system
|
||||
QIcon icon = QIcon::fromTheme(iconName);
|
||||
if (!icon.isNull()) {
|
||||
// Try to find the actual file path by searching standard locations
|
||||
QStringList dataDirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
|
||||
|
||||
// Icon subdirectories in order of preference
|
||||
QStringList iconSubDirs = {
|
||||
"icons/hicolor/scalable/mimetypes",
|
||||
"icons/hicolor/48x48/mimetypes",
|
||||
"icons/hicolor/32x32/mimetypes",
|
||||
"icons/hicolor/24x24/mimetypes",
|
||||
"icons/hicolor/16x16/mimetypes",
|
||||
"icons/Adwaita/scalable/mimetypes",
|
||||
"icons/Adwaita/48x48/mimetypes",
|
||||
"icons/Adwaita/32x32/mimetypes",
|
||||
"icons/breeze/mimetypes/22", // KDE Plasma
|
||||
"icons/breeze-dark/mimetypes/22",
|
||||
"icons/Papirus/48x48/mimetypes", // Popular icon theme
|
||||
"icons/elementary/mimetypes/48", // Elementary OS
|
||||
};
|
||||
|
||||
QStringList extensions = {".svg", ".png", ".xpm"};
|
||||
|
||||
for (const QString& dataDir : dataDirs) {
|
||||
for (const QString& iconSubDir : iconSubDirs) {
|
||||
QString basePath = dataDir + "/" + iconSubDir + "/";
|
||||
for (const QString& ext : extensions) {
|
||||
QString fullPath = basePath + iconName + ext;
|
||||
if (QFile::exists(fullPath)) {
|
||||
return QUrl::fromLocalFile(fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to a generic file icon if nothing found
|
||||
QIcon fallbackIcon = QIcon::fromTheme("text-x-generic");
|
||||
if (!fallbackIcon.isNull()) {
|
||||
// Try to resolve the fallback icon the same way
|
||||
QStringList dataDirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
|
||||
for (const QString& dataDir : dataDirs) {
|
||||
QString path = dataDir + "/icons/hicolor/48x48/mimetypes/text-x-generic.png";
|
||||
if (QFile::exists(path)) {
|
||||
return QUrl::fromLocalFile(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ultimate fallback - return empty URL and let QML handle with default
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
// Member variables
|
Loading…
x
Reference in New Issue
Block a user