initial commit

This commit is contained in:
2023-05-29 10:08:17 +02:00
parent 5073d69d72
commit 9b62a0cf6b
24 changed files with 414 additions and 25 deletions
+14
View File
@@ -1,11 +1,25 @@
#include "cimportdigikey.h"
#include "csearchdialog.h"
//LM741CNNS/NOPB-ND
#define CLIENT_ID "ZpFbDx5TQEltK8SoBUFx0iwCyITCWsnH"
#define CLIENT_SECRET "Oklw6XsXaPu2h6cT"
QString cImportDigikey::pluginName()
{
return(PLUGIN_NAME);
}
qint16 cImportDigikey::pluginVersion()
{
return(PLUGIN_VERSION);
}
bool cImportDigikey::showSearch(QWidget* parent)
{
cSearchDialog* searchDialog = new cSearchDialog(parent);
searchDialog->show();
return(true);
}
+2
View File
@@ -19,6 +19,8 @@ class cImportDigikey : public QObject, cImportInterface
public:
QString pluginName() override;
qint16 pluginVersion() override;
bool showSearch(QWidget* parent) override;
};
#endif
+14
View File
@@ -0,0 +1,14 @@
#include "csearchdialog.h"
#include "ui_csearchdialog.h"
cSearchDialog::cSearchDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::cSearchDialog)
{
ui->setupUi(this);
}
cSearchDialog::~cSearchDialog()
{
delete ui;
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef CSEARCHDIALOG_H
#define CSEARCHDIALOG_H
#include <QDialog>
namespace Ui {
class cSearchDialog;
}
class cSearchDialog : public QDialog
{
Q_OBJECT
public:
explicit cSearchDialog(QWidget *parent = nullptr);
~cSearchDialog();
private:
Ui::cSearchDialog *ui;
};
#endif // CSEARCHDIALOG_H
+86
View File
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cSearchDialog</class>
<widget class="QDialog" name="cSearchDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>280</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="importDigiKey.qrc">:/logo/digikeySmall.png</pixmap>
</property>
</widget>
</widget>
<resources>
<include location="importDigiKey.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>cSearchDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>cSearchDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+10 -4
View File
@@ -1,15 +1,15 @@
#! [0]
TEMPLATE = lib
CONFIG += plugin
QT += widgets
INCLUDEPATH += ../inventryParts
HEADERS = \
cimportdigikey.h
cimportdigikey.h \
csearchdialog.h
SOURCES = \
cimportdigikey.cpp
cimportdigikey.cpp \
csearchdialog.cpp
TARGET = $$qtLibraryTarget(importDigiKey)
DESTDIR = ../plugins
#! [0]
EXAMPLE_FILES = importDigiKey.json
@@ -18,3 +18,9 @@ EXAMPLE_FILES = importDigiKey.json
#INSTALLS += target
CONFIG += install_ok # Do not cargo-cult this!
FORMS += \
csearchdialog.ui
RESOURCES += \
importDigiKey.qrc
+6
View File
@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>logo/digikeySmall.png</file>
<file>logo/digikey.png</file>
</qresource>
</RCC>
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

+20
View File
@@ -0,0 +1,20 @@
#include "cimportmouser.h"
#include "csearchdialog.h"
QString cImportMouser::pluginName()
{
return(PLUGIN_NAME);
}
qint16 cImportMouser::pluginVersion()
{
return(PLUGIN_VERSION);
}
bool cImportMouser::showSearch(QWidget* parent)
{
cSearchDialog* searchDialog = new cSearchDialog(parent);
searchDialog->show();
return(true);
}
+26
View File
@@ -0,0 +1,26 @@
#ifndef CIMPORTDIGIKEY_H
#define CIMPORTDIGIKEY_H
#include <QObject>
#include <QtPlugin>
#include "cimportinterface.h"
#define PLUGIN_NAME "Import Mouser"
#define PLUGIN_VERSION 1
class cImportMouser : public QObject, cImportInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "at.windesign.importInterface" FILE "importMouser.json")
Q_INTERFACES(cImportInterface)
public:
QString pluginName() override;
qint16 pluginVersion() override;
bool showSearch(QWidget* parent) override;
};
#endif
+14
View File
@@ -0,0 +1,14 @@
#include "csearchdialog.h"
#include "ui_csearchdialog.h"
cSearchDialog::cSearchDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::cSearchDialog)
{
ui->setupUi(this);
}
cSearchDialog::~cSearchDialog()
{
delete ui;
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef CSEARCHDIALOG_H
#define CSEARCHDIALOG_H
#include <QDialog>
namespace Ui {
class cSearchDialog;
}
class cSearchDialog : public QDialog
{
Q_OBJECT
public:
explicit cSearchDialog(QWidget *parent = nullptr);
~cSearchDialog();
private:
Ui::cSearchDialog *ui;
};
#endif // CSEARCHDIALOG_H
+86
View File
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cSearchDialog</class>
<widget class="QDialog" name="cSearchDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>280</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>131</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="importMouser.qrc">:/logo/mouserSmall.jpg</pixmap>
</property>
</widget>
</widget>
<resources>
<include location="importMouser.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>cSearchDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>cSearchDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
+1
View File
@@ -0,0 +1 @@
{}
+26
View File
@@ -0,0 +1,26 @@
TEMPLATE = lib
CONFIG += plugin
QT += widgets
INCLUDEPATH += ../inventryParts
HEADERS = \
cimportmouser.h \
csearchdialog.h
SOURCES = \
cimportmouser.cpp \
csearchdialog.cpp
TARGET = $$qtLibraryTarget(importMouser)
DESTDIR = ../plugins
EXAMPLE_FILES = importMouser.json
# install
#target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/importMouser/plugins
#INSTALLS += target
CONFIG += install_ok # Do not cargo-cult this!
FORMS += \
csearchdialog.ui
RESOURCES += \
importMouser.qrc
+6
View File
@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file>logo/mouser.jpg</file>
<file>logo/mouserSmall.jpg</file>
</qresource>
</RCC>
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

+2 -1
View File
@@ -1,3 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = inventryParts \
importDigiKey
importDigiKey \
importMouser
+2
View File
@@ -9,6 +9,8 @@ public:
virtual ~cImportInterface() = default;
virtual QString pluginName() = 0;
virtual qint16 pluginVersion() = 0;
virtual bool showSearch(QWidget* parent) = 0;
};
QT_BEGIN_NAMESPACE
+20 -13
View File
@@ -50,7 +50,7 @@ bool cMainWindow::loadPlugin()
#endif
pluginsDir.cd("plugins");
const QStringList entries = pluginsDir.entryList(QDir::Files);
const QStringList entries = pluginsDir.entryList(QStringList() << "*.dll", QDir::Files);
for(const QString &fileName : entries)
{
@@ -59,19 +59,26 @@ bool cMainWindow::loadPlugin()
if(plugin)
{
m_importInterface = qobject_cast<cImportInterface *>(plugin);
if(m_importInterface)
{
qDebug() << m_importInterface->pluginName();
qDebug() << m_importInterface->pluginVersion();
return true;
}
pluginLoader.unload();
cImportInterface* importInterface = qobject_cast<cImportInterface *>(plugin);
if(importInterface)
m_importInterfaceList.append(importInterface);
else
pluginLoader.unload();
}
}
return false;
return(true);
}
void cMainWindow::on_m_test_clicked()
{
for(int i = 0;i < m_importInterfaceList.count();i++)
{
qDebug() << m_importInterfaceList.at(i)->pluginName();
if(!m_importInterfaceList.at(i)->pluginName().compare("Import Mouser", Qt::CaseSensitive))
{
m_importInterfaceList.at(i)->showSearch(this);
return;
}
}
}
+10 -5
View File
@@ -5,6 +5,8 @@
#include "cimportinterface.h"
#include <QMainWindow>
#include <QPluginLoader>
#include <QList>
QT_BEGIN_NAMESPACE
@@ -19,11 +21,14 @@ public:
cMainWindow(QWidget *parent = nullptr);
~cMainWindow();
private:
Ui::cMainWindow* ui;
cImportInterface* m_importInterface;
private slots:
void on_m_test_clicked();
void createGUI();
bool loadPlugin();
private:
Ui::cMainWindow* ui;
QList<cImportInterface*> m_importInterfaceList;
void createGUI();
bool loadPlugin();
};
#endif // CMAINWINDOW_H
+25 -2
View File
@@ -13,8 +13,31 @@
<property name="windowTitle">
<string>cMainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar"/>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="m_test">
<property name="geometry">
<rect>
<x>50</x>
<y>40</y>
<width>75</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>test</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>