summary refs log tree commit diff
path: root/src/MainWindow.cpp
diff options
context:
space:
mode:
authorredsky17 <joedonofry@gmail.com>2019-01-26 18:03:49 +0000
committerredsky17 <joedonofry@gmail.com>2019-01-26 18:03:49 +0000
commit6c31f5fe7a417ba904b7c31aa5065363a8f9d94b (patch)
tree3f2e9cb311f3f4cc951a616207fce65e99939518 /src/MainWindow.cpp
parentFix lint issue (diff)
downloadnheko-6c31f5fe7a417ba904b7c31aa5065363a8f9d94b.tar.xz
Add initial support for QtIndenticon
Add initial loading of qt jdenticon plugin:
https://github.com/redsky17/qt-jdenticon

Currently, the library's functionality has not been integrated
into the rest of nheko.  Next step is to add a configuration
item in the User Settings and use the plugin to generate
avatars for users without their own picture.  These avatars
should be cached in the Cache object.
Diffstat (limited to '')
-rw-r--r--src/MainWindow.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp

index 2e062c0c..8da7d659 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp
@@ -19,6 +19,7 @@ #include <QLayout> #include <QSettings> #include <QShortcut> +#include <QPluginLoader> #include <mtx/requests.hpp> @@ -166,6 +167,10 @@ MainWindow::MainWindow(QWidget *parent) showChatPage(); } + + if (loadJdenticonPlugin()) { + nhlog::ui()->info("loaded jdenticon."); + } } void @@ -479,3 +484,27 @@ MainWindow::showDialog(QWidget *dialog) dialog->raise(); dialog->show(); } + +bool +MainWindow::loadJdenticonPlugin() +{ + QDir pluginsDir(qApp->applicationDirPath()); + + bool plugins = pluginsDir.cd("plugins"); + if (plugins) { + foreach (QString fileName, pluginsDir.entryList(QDir::Files)) { + QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); + QObject *plugin = pluginLoader.instance(); + if (plugin) { + jdenticonInteface_ = qobject_cast<JdenticonInterface *>(plugin); + if (jdenticonInteface_) { + nhlog::ui()->info("Found jdenticon plugin."); + return true; + } + } + } + } + + nhlog::ui()->info("jdenticon plugin not found."); + return false; +} \ No newline at end of file