/////////////////////////////////////////////////////////////////////////////////// // 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 . // /////////////////////////////////////////////////////////////////////////////////// #include #include #include "plugin/pluginapi.h" #include "util/simpleserializer.h" #include "rigctrl.h" #ifdef SERVER_MODE #else #include #include #include #include #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 ) { (void) mainWindow; return true; } void RigCtrlPlugin::showRigCtrlUI() { } #else bool RigCtrlPlugin::createTopLevelGUI( QMainWindow* mainWindow ) { m_mainWindow = mainWindow; QMenuBar *menuBar = mainWindow->menuBar(); QMenu *prefMenu = menuBar->findChild("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); }