diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index 58af76e94..6128312e0 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -35,14 +35,7 @@ Plugins::Plugins(QObject* parent) , m_speedDial(new SpeedDial(this)) { loadSettings(); - - m_pythonPlugin = new QLibrary(QSL("PyFalkonPrivate"), this); - m_pythonPlugin->setLoadHints(QLibrary::ExportExternalSymbolsHint); - if (!m_pythonPlugin->load()) { - qDebug() << "Failed to load python support plugin" << m_pythonPlugin->errorString(); - delete m_pythonPlugin; - m_pythonPlugin = nullptr; - } + loadPythonSupport(); } QList Plugins::getAvailablePlugins() @@ -168,6 +161,9 @@ void Plugins::loadAvailablePlugins() for (const QString &dir : qAsConst(dirs)) { const auto files = QDir(dir).entryInfoList(QDir::Files); for (const QFileInfo &info : files) { + if (info.baseName() == QL1S("PyFalkon")) { + continue; + } Plugin plugin = loadSharedLibraryPlugin(info.absoluteFilePath()); if (plugin.pluginSpec.name.isEmpty()) { qWarning() << "Invalid plugin spec of" << info.absoluteFilePath() << "plugin"; @@ -209,6 +205,26 @@ void Plugins::refreshLoadedPlugins() } } +void Plugins::loadPythonSupport() +{ + const QStringList dirs = DataPaths::allPaths(DataPaths::Plugins); + for (const QString &dir : dirs) { + const auto files = QDir(dir).entryInfoList({QSL("PyFalkon*")}, QDir::Files); + for (const QFileInfo &info : files) { + m_pythonPlugin = new QLibrary(info.absoluteFilePath(), this); + m_pythonPlugin->setLoadHints(QLibrary::ExportExternalSymbolsHint); + if (!m_pythonPlugin->load()) { + qWarning() << "Failed to load python support plugin" << m_pythonPlugin->errorString(); + delete m_pythonPlugin; + m_pythonPlugin = nullptr; + } else { + std::cout << "Falkon: Python plugin support initialized" << std::endl; + return; + } + } + } +} + Plugins::Plugin Plugins::loadPlugin(const QString &id) { QString name; diff --git a/src/lib/plugins/plugins.h b/src/lib/plugins/plugins.h index 02a58fba4..bfd77b5f6 100644 --- a/src/lib/plugins/plugins.h +++ b/src/lib/plugins/plugins.h @@ -108,6 +108,7 @@ Q_SIGNALS: void pluginUnloaded(PluginInterface* plugin); private: + void loadPythonSupport(); Plugin loadPlugin(const QString &id); Plugin loadInternalPlugin(const QString &name); Plugin loadSharedLibraryPlugin(const QString &name); diff --git a/src/plugins/PyFalkon/CMakeLists.txt b/src/plugins/PyFalkon/CMakeLists.txt index 428f48301..d9f61d745 100644 --- a/src/plugins/PyFalkon/CMakeLists.txt +++ b/src/plugins/PyFalkon/CMakeLists.txt @@ -1,6 +1,3 @@ -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") - # Enable policy to run automoc on generated files. if(POLICY CMP0071) cmake_policy(SET CMP0071 NEW) @@ -95,11 +92,10 @@ set( PyFalkon_SRCS ${GENERATED_SOURCES} ) -add_library(PyFalkonPrivate SHARED ${PyFalkon_SRCS}) -set_target_properties(PyFalkonPrivate PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "2") -install(TARGETS PyFalkonPrivate ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) +add_library(PyFalkon MODULE ${PyFalkon_SRCS}) +install(TARGETS PyFalkon DESTINATION ${FALKON_INSTALL_PLUGINDIR}) -target_include_directories(PyFalkonPrivate +target_include_directories(PyFalkon PRIVATE ${SHIBOKEN_INCLUDE_DIR} ${SHIBOKEN_PYTHON_INCLUDE_DIR} @@ -109,7 +105,7 @@ target_include_directories(PyFalkonPrivate ${CMAKE_CURRENT_BINARY_DIR}/PyFalkon ) -target_link_libraries(PyFalkonPrivate +target_link_libraries(PyFalkon PRIVATE FalkonPrivate ${PYTHON_LIBRARIES} @@ -119,4 +115,4 @@ target_link_libraries(PyFalkonPrivate ) # Same as CONFIG += no_keywords to avoid syntax errors in object.h due to the usage of the word Slot -target_compile_definitions(PyFalkonPrivate PRIVATE QT_NO_KEYWORDS) +target_compile_definitions(PyFalkon PRIVATE QT_NO_KEYWORDS)