Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions include/PluginLoadFailedDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef PLUGIN_LOAD_FAILED_DIALOG
#define PLUGIN_LOAD_FAILED_DIALOG

#include <QDialog>

class QLabel;
class QTableWidget;

namespace lmms
{

void pluginLoadFailed(QString pluginName, QString error);

namespace gui
{

class PluginLoadFailedDialog : public QDialog
{
Q_OBJECT

public:
static inline PluginLoadFailedDialog* inst()
{
if (s_inst == nullptr) { s_inst = new PluginLoadFailedDialog; }
return s_inst;
}
PluginLoadFailedDialog();
~PluginLoadFailedDialog() override;
void addEntry(QString pluginName, QString error);

private:
static PluginLoadFailedDialog* s_inst;
QTableWidget* m_table;
QLabel* m_label;
};

} // namespace gui

} // namespace lmms

#endif
18 changes: 3 additions & 15 deletions src/core/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "AutomatableModel.h"
#include "Song.h"
#include "PluginFactory.h"
#include "PluginLoadFailedDialog.h"

namespace lmms
{
Expand Down Expand Up @@ -213,14 +214,7 @@ Plugin * Plugin::instantiate(const QString& pluginName, Model * parent,
Plugin* inst;
if( pi.isNull() )
{
if (gui::getGUI() != nullptr)
{
QMessageBox::information( nullptr,
tr( "Plugin not found" ),
tr( "The plugin \"%1\" wasn't found or could not be loaded!\nReason: \"%2\"" ).
arg( pluginName ).arg( getPluginFactory()->errorString(pluginName) ),
QMessageBox::Ok | QMessageBox::Default );
}
pluginLoadFailed(pluginName, getPluginFactory()->errorString(pluginName));
inst = new DummyPlugin();
}
else
Expand All @@ -235,13 +229,7 @@ Plugin * Plugin::instantiate(const QString& pluginName, Model * parent,
}
else
{
if (gui::getGUI() != nullptr)
{
QMessageBox::information( nullptr,
tr( "Error while loading plugin" ),
tr( "Failed to load plugin \"%1\"!").arg( pluginName ),
QMessageBox::Ok | QMessageBox::Default );
}
pluginLoadFailed(pluginName, tr("Unable to find an entry point"));
inst = new DummyPlugin();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ SET(LMMS_SRCS
gui/modals/EffectSelectDialog.cpp
gui/modals/ExportProjectDialog.cpp
gui/modals/FileDialog.cpp
gui/modals/PluginLoadFailedDialog.cpp
gui/modals/RenameDialog.cpp
gui/modals/SetupDialog.cpp
gui/modals/VersionedSaveDialog.cpp
Expand Down
76 changes: 76 additions & 0 deletions src/gui/modals/PluginLoadFailedDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include "PluginLoadFailedDialog.h"

#include "GuiApplication.h"
#include "MainWindow.h"

#include <QBoxLayout>
#include <QDebug>
#include <QDialog>
#include <QDialogButtonBox>
#include <QHeaderView>
#include <QLabel>
#include <QLayout>
#include <QTableWidget>
#include <QString>

namespace lmms
{

void pluginLoadFailed(QString pluginName, QString error)
{
if (gui::getGUI())
{
gui::PluginLoadFailedDialog::inst()->addEntry(pluginName, error);
}
else
{
qWarning() << "Plugin" << pluginName << "failed to load:" << error;
}
}

namespace gui {

PluginLoadFailedDialog::PluginLoadFailedDialog()
: QDialog{getGUI()->mainWindow()}
{
setModal(false);
setAttribute(Qt::WA_DeleteOnClose);
setLayout(new QVBoxLayout);

m_label = new QLabel{tr("<strong>The following plugins failed to load:</strong>")};
layout()->addWidget(m_label);

m_table = new QTableWidget;
m_table->setEditTriggers(QAbstractItemView::NoEditTriggers); // Disable cell editing
m_table->setFocusPolicy(Qt::NoFocus);
m_table->setSelectionMode(QAbstractItemView::NoSelection); // Disable cell focus/selection
m_table->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); // Smooth scroll
m_table->setColumnCount(2);
m_table->setHorizontalHeaderLabels({tr("Plugin name"), tr("Reason")});
m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
m_table->verticalHeader()->hide(); // Hide row numbers
layout()->addWidget(m_table);

auto* dialogButtons = new QDialogButtonBox{QDialogButtonBox::Ok};
connect(dialogButtons, &QDialogButtonBox::accepted, this, &QDialog::accept);
layout()->addWidget(dialogButtons);
}

PluginLoadFailedDialog::~PluginLoadFailedDialog()
{
if (s_inst == this) { s_inst = nullptr; }
}

void PluginLoadFailedDialog::addEntry(QString pluginName, QString error)
{
m_table->insertRow(m_table->rowCount());
m_table->setItem(m_table->rowCount()-1, 0, new QTableWidgetItem{pluginName});
m_table->setItem(m_table->rowCount()-1, 1, new QTableWidgetItem{error});
show();
}

PluginLoadFailedDialog* PluginLoadFailedDialog::s_inst = nullptr;

} // namespace gui

} // namespace lmms
Loading