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.
pull/27/head
redsky17 6 years ago
parent 22a08ba6a4
commit 6c31f5fe7a
  1. 3
      CMakeLists.txt
  2. 17
      includes/jdenticoninterface.h
  3. 29
      src/MainWindow.cpp
  4. 6
      src/MainWindow.h

@ -282,6 +282,9 @@ include_directories(SYSTEM ${TWEENY_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src) include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS})
# local inclue directory
include_directories(includes)
qt5_wrap_cpp(MOC_HEADERS qt5_wrap_cpp(MOC_HEADERS
# Dialogs # Dialogs
src/dialogs/CreateRoom.h src/dialogs/CreateRoom.h

@ -0,0 +1,17 @@
#ifndef JDENTICONINTERFACE_H
#define JDENTICONINTERFACE_H
#include <QString>
class JdenticonInterface
{
public:
virtual ~JdenticonInterface() {}
virtual QString generate(const QString &message, uint16_t size) = 0;
};
#define JdenticonInterface_iid "redsky17.Qt.JdenticonInterface"
Q_DECLARE_INTERFACE(JdenticonInterface, JdenticonInterface_iid)
#endif // JDENTICONINTERFACE_H

@ -19,6 +19,7 @@
#include <QLayout> #include <QLayout>
#include <QSettings> #include <QSettings>
#include <QShortcut> #include <QShortcut>
#include <QPluginLoader>
#include <mtx/requests.hpp> #include <mtx/requests.hpp>
@ -166,6 +167,10 @@ MainWindow::MainWindow(QWidget *parent)
showChatPage(); showChatPage();
} }
if (loadJdenticonPlugin()) {
nhlog::ui()->info("loaded jdenticon.");
}
} }
void void
@ -479,3 +484,27 @@ MainWindow::showDialog(QWidget *dialog)
dialog->raise(); dialog->raise();
dialog->show(); 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;
}

@ -31,6 +31,8 @@
#include "dialogs/UserProfile.h" #include "dialogs/UserProfile.h"
#include "ui/OverlayModal.h" #include "ui/OverlayModal.h"
#include "jdenticoninterface.h"
class ChatPage; class ChatPage;
class LoadingIndicator; class LoadingIndicator;
class OverlayModal; class OverlayModal;
@ -129,6 +131,8 @@ private slots:
void removeOverlayProgressBar(); void removeOverlayProgressBar();
private: private:
bool loadJdenticonPlugin();
void showDialog(QWidget *dialog); void showDialog(QWidget *dialog);
bool hasActiveUser(); bool hasActiveUser();
void restoreWindowSize(); void restoreWindowSize();
@ -158,4 +162,6 @@ private:
//! Overlay modal used to project other widgets. //! Overlay modal used to project other widgets.
OverlayModal *modal_ = nullptr; OverlayModal *modal_ = nullptr;
LoadingIndicator *spinner_ = nullptr; LoadingIndicator *spinner_ = nullptr;
JdenticonInterface *jdenticonInteface_ = nullptr;
}; };

Loading…
Cancel
Save