From b33ff1b169e300918a6aceaabba596bfc045b296 Mon Sep 17 00:00:00 2001 From: Rokos Josef Date: Thu, 23 Jun 2016 16:05:36 +0200 Subject: [PATCH] Button for core plugin is not generated to navigation bar. Added macro for plugin path. --- application/mainwindow.cpp | 21 ++++++++++++--------- core/context.cpp | 2 +- core/define.h | 8 ++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/application/mainwindow.cpp b/application/mainwindow.cpp index 546ac36..a03046b 100644 --- a/application/mainwindow.cpp +++ b/application/mainwindow.cpp @@ -42,16 +42,19 @@ MainWindow::MainWindow(QWidget *parent) : int i = 0; foreach (IPlugin *plugin, Context::instance().plugins()) { - QToolButton *plugButton = new QToolButton(this); - plugButton->setText(plugin->pluginName()); - plugButton->setIcon(plugin->pluginIcon()); - plugButton->setIconSize(QSize(32, 32)); - plugButton->setAutoRaise(true); - plugButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - ui->navigation->layout()->addWidget(plugButton); - plugButton->setProperty(PLUGIN_INDEX, i); + if (plugin->pluginId() != "CORE") + { + QToolButton *plugButton = new QToolButton(this); + plugButton->setText(plugin->pluginName()); + plugButton->setIcon(plugin->pluginIcon()); + plugButton->setIconSize(QSize(32, 32)); + plugButton->setAutoRaise(true); + plugButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + ui->navigation->layout()->addWidget(plugButton); + plugButton->setProperty(PLUGIN_INDEX, i); + connect(plugButton, SIGNAL(clicked()), this, SLOT(openPlugin()) ); + } i++; - connect(plugButton, SIGNAL(clicked()), this, SLOT(openPlugin()) ); } ((QVBoxLayout*)ui->navigation->layout())->addStretch(1); diff --git a/core/context.cpp b/core/context.cpp index 9f656dd..08cf434 100644 --- a/core/context.cpp +++ b/core/context.cpp @@ -52,7 +52,7 @@ void Context::loadPlugins() m_plugins.append(new Users); m_plugins.append(new Roles); - QDir pluginsDir(qApp->applicationDirPath() + "/../../plugins"); + QDir pluginsDir(qApp->applicationDirPath() + PLUGIN_ROOT); foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) { QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); diff --git a/core/define.h b/core/define.h index 74647ff..1cee27f 100644 --- a/core/define.h +++ b/core/define.h @@ -13,5 +13,13 @@ #define TO_DEC(num) QDecDouble((double)num / DEC_MULTIPLE) #define FROM_DEC(num) num.toDouble() * DEC_MULTIPLE +#ifndef PLUGIN_ROOT + #ifdef _WIN32 + #define PLUGIN_ROOT "/../../plugins" + #else + #define PLUGIN_ROOT "/../plugins" + #endif +#endif + #endif // DEFINE_H