mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-10 01:49:27 -04:00
Add rigctrl plugin.
plugins/misc/rigctrl - Add rigctrl plugin. sdrbase/plugin/pluginapi.h/.cpp - Add misc plugin registration. sdrbase/plugin/pluginmanager.h/.cpp - Add misc plugin registration. sdrbase/plugin/plugininterface.h/.cpp - Add top level UI and global settings serialization callbacks. sdrbase/settings/mainsettings.h/cpp - Allow plugins to save global settings in main settings file. sdrgui/mainwindow.cpp - Load settings after plugins are loaded, to allow plugin settings to be loaded and saved. sdrsrv/maincore.cpp - Support loading/saving of plugin settings.
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QtDebug>
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtWidgets/QMenuBar>
|
||||
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
#include "rigctrl.h"
|
||||
#ifdef SERVER_MODE
|
||||
#else
|
||||
#include "rigctrlgui.h"
|
||||
#endif
|
||||
#include "rigctrlplugin.h"
|
||||
|
||||
const PluginDescriptor RigCtrlPlugin::m_pluginDescriptor = {
|
||||
QString("rigctrl"),
|
||||
QString("rigctrl Server"),
|
||||
QString("4.15.5"),
|
||||
QString("(c) Jon Beniston, M7RCE"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
QString("https://github.com/srcejon/sdrangel/tree/rigctrl")
|
||||
};
|
||||
|
||||
RigCtrlPlugin::RigCtrlPlugin(RigCtrl *rigCtrl, QObject* parent) :
|
||||
m_rigCtrl(rigCtrl),
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
const PluginDescriptor& RigCtrlPlugin::getPluginDescriptor() const
|
||||
{
|
||||
return m_pluginDescriptor;
|
||||
}
|
||||
|
||||
void RigCtrlPlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
{
|
||||
m_rigCtrl = new RigCtrl();
|
||||
pluginAPI->registerMiscPlugin(RIGCTRL_DEVICE_TYPE_ID, this);
|
||||
}
|
||||
|
||||
|
||||
#ifdef SERVER_MODE
|
||||
bool RigCtrlPlugin::createTopLevelGUI(
|
||||
QMainWindow* mainWindow
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
bool RigCtrlPlugin::createTopLevelGUI(
|
||||
QMainWindow* mainWindow
|
||||
)
|
||||
{
|
||||
m_mainWindow = mainWindow;
|
||||
QMenuBar *menuBar = mainWindow->menuBar();
|
||||
|
||||
QMenu *prefMenu = menuBar->findChild<QMenu *>("menuPreferences", Qt::FindDirectChildrenOnly);
|
||||
if (prefMenu == nullptr) {
|
||||
qDebug() << "RigCtrlPlugin::createTopLevelGUI - Failed to find Preferences menu";
|
||||
return false;
|
||||
}
|
||||
|
||||
QAction *prefAction;
|
||||
prefAction = new QAction(tr("rigctrl"), this);
|
||||
prefAction->setStatusTip(tr("Display preferences for rigctrl"));
|
||||
prefMenu->addAction(prefAction);
|
||||
connect(prefAction, &QAction::triggered, this, &RigCtrlPlugin::showRigCtrlUI);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RigCtrlPlugin::showRigCtrlUI()
|
||||
{
|
||||
RigCtrlGUI dlg(m_rigCtrl, m_mainWindow);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QByteArray RigCtrlPlugin::serializeGlobalSettings() const
|
||||
{
|
||||
return m_rigCtrl->serialize();
|
||||
}
|
||||
|
||||
bool RigCtrlPlugin::deserializeGlobalSettings(const QByteArray& data)
|
||||
{
|
||||
return m_rigCtrl->deserialize(data);
|
||||
}
|
||||
Reference in New Issue
Block a user