Skip to content

Commit

Permalink
plugingenerator: Last changes for pdk.
Browse files Browse the repository at this point in the history
Added init button, scopy preferences.

Signed-off-by: andreidanila1 <[email protected]>
  • Loading branch information
andreidanila1 committed Aug 23, 2024
1 parent 8d4e837 commit ad87ed3
Show file tree
Hide file tree
Showing 5 changed files with 399 additions and 91 deletions.
10 changes: 8 additions & 2 deletions tools/plugingenerator/plugin_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
else:
pdkPath = os.path.join(pdkPath, "ScopyPluginRunner")
try:
os.mkdir(pdkPath, mode)
os.makedirs(pdkPath, mode)
directoriesGenerated.append(pdkPath)
except FileExistsError:
print(pdkPath + " directory already exists!")
Expand Down Expand Up @@ -122,6 +122,11 @@

####################################################### pdk ##################################################
if pdkSupport:
pdkPreferencesPath = os.path.join(pdkPath, "preferences.ini")
if not os.path.exists(pdkPreferencesPath):
pdkPreferences = open(pdkPreferencesPath, "w")
pdkPreferences.close()

pdkCmakeFuncFilePath = os.path.join(pdkPath, "PdkSupport.cmake")
if not os.path.exists(pdkCmakeFuncFilePath):
pdkCmakeFuncTemplate = Template(
Expand All @@ -143,7 +148,8 @@
pdkCmakeContent = pdkCmakeTemplate.render(
deps_path=generatorOptions["pdk"]["deps_path"],
plugin_dir=pluginDirName,
plugin_name=pluginName
plugin_name=pluginName,
preferences_path = pdkPreferencesPath
)
pdkCmakeFile = open(pdkCmakeFilePath, "w")
pdkCmakeFile.write(pdkCmakeContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if(NOT EXISTS ${"${PDK_DEPS_LIB}"})
endif()

set(PLUGIN_INSTALL_PATH ${"${CMAKE_CURRENT_BINARY_DIR}"}/plugin/${plugin_dir}/libscopy-${plugin_name}.so)
set(PATH_TO_INI ${preferences_path})

find_package(QT NAMES Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${"${QT_VERSION_MAJOR}"} REQUIRED COMPONENTS Widgets Core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
#define PDK_UTIL_H_CMAKEIN

#define PLUGIN_INSTALL_PATH "@PLUGIN_INSTALL_PATH@"
#define PATH_TO_INI "@PATH_TO_INI@"

#endif // PDK_UTIL_H_CMAKEIN
44 changes: 36 additions & 8 deletions tools/plugingenerator/templates/pdk/pdk_header_template.mako
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public:
public Q_SLOTS:
void onConnect();
void onDisconnect();
void onInit();
void onDeinit();
void onLoad();
void onUnload();
Q_SIGNALS:
Expand All @@ -29,6 +31,8 @@ private:
QTabWidget *m_tabWidget;
QWidget *m_prefPage;
QList<QWidget *> m_toolList;
QList<QWidget *> m_loadedTools;
QLabel *m_aboutPage = nullptr;
MainWidget *m_mainWidget = nullptr;

void initMainWindow();
Expand All @@ -37,7 +41,10 @@ private:
void addPluginPrefPage();
void removePluginPrefPage();
QLabel *createTabLabel(QString name);
QWidget *addHorizontalTab(QWidget *w, QLabel *lbl);
QWidget *addHorizontalTab(QWidget *w, QLabel *lbl, bool tabEnabled = true);
QWidget *buildSaveSessionPreference();
QWidget *generalPreferences();
void initGeneralPreferences();
};

class MainWidget : public QWidget
Expand All @@ -47,39 +54,59 @@ public:
MainWidget(QWidget *parent);
~MainWidget();

QString pluginAbout();
QWidget *pluginPrefPage();
QList<scopy::ToolMenuEntry *> getPluginTools();

Q_SIGNALS:
void connected();
void disconnected();
void init();
void deinit();
void loaded();
void unloaded();

private Q_SLOTS:
void onConnect();
void onDisconnect();
void loadPlugin();
void unloadPlugin();
void deinitialize();
void onInit();
void onLoad();
void onUnload();
void browseFile(QLineEdit *pluginPathEdit);
void deletePluginManager();

private:
void unloadPluginDetails();
void loadPluginDetails();
void unloadInfoPage();
void loadInfoPage();
void changeVisibility(QPushButton *btn1, QPushButton *btn2);
void enableBrowseInit(bool en);
void enableLoadConn(bool en);
void updateStatusLbl(QString msg);
bool validConnection(QString uri, QString cat);
bool isCompatible(QString uri, QString cat);

PluginManager *m_pluginManager;
QLabel *m_statusLbl;
QLineEdit *m_uriEdit;
QLineEdit *m_pluginPathEdit;
QPushButton *m_connBtn;
QPushButton *m_disconnBtn;
QPushButton *m_browseBtn;
QPushButton *m_initBtn;
QPushButton *m_loadBtn;
QPushButton *m_unloadBtn;
QPushButton *m_connBtn;
QPushButton *m_disconnBtn;

QWidget *m_pluginIcon;
scopy::MenuCombo *m_deviceTypeCb;
QScrollArea *m_scrollArea;
bool m_connected;
QString m_currentPlugin;
enum State
{
Unloaded,
Loaded,
Connected
} m_state;
};

class PluginManager : public QObject
Expand All @@ -101,6 +128,7 @@ private:
bool pluginCategory(QString category);

scopy::Plugin *m_plugin = nullptr;
bool m_loaded;
};

class ConnectionStrategy : public QObject
Expand Down
Loading

0 comments on commit ad87ed3

Please sign in to comment.