From: Konrad Rosenbaum Date: Tue, 24 Jun 2014 19:49:56 +0000 (+0200) Subject: draft for GUI plugin and networking X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9b3f8193d1ee4891332a7941afe723d8d9134595;p=web%2Fkonrad%2Fskid.git draft for GUI plugin and networking --- diff --git a/examples/gui-system-in-test/calculator.cpp b/examples/gui-system-in-test/calculator.cpp new file mode 100644 index 0000000..53c92b2 --- /dev/null +++ b/examples/gui-system-in-test/calculator.cpp @@ -0,0 +1,60 @@ +// +// SKID Examples: System In Test +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include +#include +#include +#include +#include +#include +#include + +#include "calculator.h" + +Calculator::Calculator ( QWidget *parent, Qt::WindowFlags f ) : QDialog ( parent, f ) +{ + setWindowTitle("Stupid Calculator"); + + QVBoxLayout*vl; + setLayout(vl=new QVBoxLayout); + QMenuBar*mb; + vl->addWidget(mb=new QMenuBar,0); + QMenu*m=mb->addMenu("&Window"); + m->addAction("&About",this,SLOT(about())); + m->addAction("About Q&t",qApp,SLOT(aboutQt())); + m->addSeparator(); + m->addAction("&Quit",qApp,SLOT(quit())); + + m=mb->addMenu("&Calculate"); + m->addAction("&Add",this,SLOT(addSomething())); + m->addAction("&Multiply",this,SLOT(multiplySomething())); + + vl->addWidget(new QLabel("Please use the menu!"),1); +} + +void Calculator::addSomething() +{ + +} + +void Calculator::multiplySomething() +{ + +} + +void Calculator::about() +{ + QMessageBox::about(this,"About Stupid Calculator", + "

About Stupid Calculator

" + "This is a very stupid an unergonomic calculator." + "Do not expect it to make much sense, it exists to demonstrate" + "SKID GUI manipulation techniques.

" + ); +} diff --git a/examples/gui-system-in-test/calculator.h b/examples/gui-system-in-test/calculator.h new file mode 100644 index 0000000..b7e0596 --- /dev/null +++ b/examples/gui-system-in-test/calculator.h @@ -0,0 +1,28 @@ +// +// SKID Examples: System In Test +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef SKID_EXAMPLE_CALCULATOR_H +#define SKID_EXAMPLE_CALCULATOR_H + +#include + +class Calculator:public QDialog +{ + Q_OBJECT + public: + explicit Calculator ( QWidget *parent = 0, Qt::WindowFlags f = 0 ); + public slots: + void addSomething(); + void multiplySomething(); + + void about(); +}; + +#endif diff --git a/examples/gui-system-in-test/sit.pro b/examples/gui-system-in-test/sit.pro new file mode 100644 index 0000000..81195a8 --- /dev/null +++ b/examples/gui-system-in-test/sit.pro @@ -0,0 +1,11 @@ +#project file for system in test example: non-instrumented GUI +TEMPLATE = app +TARGET = guisit +QT += widgets + +include(../../common.pri) +DESTDIR = $$BINDIR + +#our actual sources: +SOURCES += sitmain.cpp calculator.cpp +HEADERS += calculator.h \ No newline at end of file diff --git a/examples/gui-system-in-test/siti.pro b/examples/gui-system-in-test/siti.pro new file mode 100644 index 0000000..125931b --- /dev/null +++ b/examples/gui-system-in-test/siti.pro @@ -0,0 +1,12 @@ +#project file for system in test example: instrumented GUI +TEMPLATE = app +TARGET = guisiti +QT += widgets + +include(../../common.pri) +DESTDIR = $$BINDIR +INCLUDEPATH += ../../runnerlib/qt5gui/include + +#our actual sources: +SOURCES += sitinstrumented.cpp calculator.cpp +HEADERS += calculator.h \ No newline at end of file diff --git a/examples/gui-system-in-test/sitinstrumented.cpp b/examples/gui-system-in-test/sitinstrumented.cpp new file mode 100644 index 0000000..d1e2995 --- /dev/null +++ b/examples/gui-system-in-test/sitinstrumented.cpp @@ -0,0 +1,28 @@ +// +// SKID Examples: System In Test +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include +#include + +#include "calculator.h" +#include + + +int main(int ac,char**av) +{ + QApplication app(ac,av); + if(!Skid::Gui::initialize()) + qDebug()<<"Unable to instrument this program with SKID GUI controller"; + + Calculator c; + c.show(); + + return app.exec(); +} \ No newline at end of file diff --git a/examples/gui-system-in-test/sitmain.cpp b/examples/gui-system-in-test/sitmain.cpp new file mode 100644 index 0000000..df2a632 --- /dev/null +++ b/examples/gui-system-in-test/sitmain.cpp @@ -0,0 +1,24 @@ +// +// SKID Examples: System In Test +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include + +#include "calculator.h" + + +int main(int ac,char**av) +{ + QApplication app(ac,av); + + Calculator c; + c.show(); + + return app.exec(); +} \ No newline at end of file diff --git a/guiplugin/gplugin.cpp b/guiplugin/gplugin.cpp new file mode 100644 index 0000000..b0289e7 --- /dev/null +++ b/guiplugin/gplugin.cpp @@ -0,0 +1,55 @@ +// +// SKID Examples: GUI Style Plugin Interface +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include +#include +#include +#include + +#include "gplugin.h" +#include "observer.h" + +#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) +#define STYLE "fusion" +#elif defined(Q_OS_WIN) +#define STYLE "windows" +#elif defined(Q_OS_MAC) +#define STYLE "macintosh" +#else +#define STYLE "fusion" +#endif + +QStyle *SkidStylePlugin::create ( const QString &key ) +{ + qDebug()<<"SKID init via Style Path"; + Skid::Gui::Observer::initialize(); + QString substyle=STYLE; + if(1){ + const QByteArray st=qgetenv("SKIDSTYLE"); + if(!st.isEmpty()) + substyle=QString::fromLocal8Bit(st); + } + if(qApp!=nullptr){ + for(const QString&arg:qApp->arguments()) + if(arg.startsWith("-skidstyle=")) + substyle=arg.mid(11); + } + if(key=="skidstyle"){ + qDebug()<<"SKID creating instance of style"<, (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef SKID_GUI_STYLE_PLUGIN_H +#define SKID_GUI_STYLE_PLUGIN_H + +#include + +///The pseudo style used to infuse a GUI based system-in-test with the SKID GUI observer. +///It is usually selected by setting the QT_PLUGIN_PATH and QT_STYLE_OVERRIDE variables, +///alternatively the -style parameter can be used or the program can be instrumented directly. +///It returns the platform default style instead of creating a new one. +///The environment variable SKIDSTYLE or the parameter -skidstyle=(style) +///can be used to select a real style. +class SkidStylePlugin:public QStylePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "skidstyle.json") + + public: + SkidStylePlugin() {} + + QStringList keys() const; + QStyle *create(const QString &key); +}; + +#endif diff --git a/guiplugin/guiplugin.pro b/guiplugin/guiplugin.pro new file mode 100644 index 0000000..d2f9c84 --- /dev/null +++ b/guiplugin/guiplugin.pro @@ -0,0 +1,17 @@ +#project file for SKID pseudo style plugin + +#test runners are applications... +TEMPLATE = lib +CONFIG += plugin +TARGET = skidstyle + +#it is usually designed to be non-graphical +QT += gui widgets + +#config +include (../common.pri) +DESTDIR = $$LIBDIR/styles + +#our actual sources: +SOURCES += gplugin.cpp observer.cpp +HEADERS += gplugin.h observer.h diff --git a/guiplugin/observer.cpp b/guiplugin/observer.cpp new file mode 100644 index 0000000..c11fd35 --- /dev/null +++ b/guiplugin/observer.cpp @@ -0,0 +1,57 @@ +// +// SKID Examples: GUI Style Plugin Interface +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "observer.h" +#include +#include +#include + +using namespace Skid::Gui; + +static Observer *observer=nullptr; + +void Observer::initialize() +{ + if(observer)return; + observer=new Observer; + qDebug()<<"Initialized SKID GUI Observer"; +} + +static void observer_init(){Observer::initialize();} + +Q_COREAPP_STARTUP_FUNCTION(observer_init); + +Observer::Observer() : QObject() +{ + qApp->installEventFilter(this); +} + +bool Observer::eventFilter ( QObject *, QEvent *event ) +{ + if(event) + switch(event->type()) + { + //events that influence window visibility + case QEvent::Close: + case QEvent::Hide: + case QEvent::Show: + case QEvent::ShowWindowRequest: + QTimer::singleShot(0,this,SLOT(reschedule())); + break; + default:/*nothing*/ break; + } + //pass events on to the actual program + return false; +} + +void Observer::reschedule() +{ + qDebug()<<"SKID scheduler"; +} diff --git a/guiplugin/observer.h b/guiplugin/observer.h new file mode 100644 index 0000000..01ecbf2 --- /dev/null +++ b/guiplugin/observer.h @@ -0,0 +1,34 @@ +// +// SKID Examples: GUI Style Plugin Interface +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef SKID_GUI_OBSERVER_H +#define SKID_GUI_OBSERVER_H + +#include + +namespace Skid { namespace Gui { + +class Observer:public QObject +{ + Q_OBJECT + public: + static void initialize(); + protected: + bool eventFilter(QObject *obj, QEvent *event); + Observer (); + private slots: + void reschedule(); +}; + + +//end of namespace +}} + +#endif diff --git a/guiplugin/skidstyle.json b/guiplugin/skidstyle.json new file mode 100644 index 0000000..1183c85 --- /dev/null +++ b/guiplugin/skidstyle.json @@ -0,0 +1 @@ +{ "Keys": [ "skidstyle" ] } \ No newline at end of file diff --git a/network/include/skid-connection.h b/network/include/skid-connection.h new file mode 100644 index 0000000..cb49755 --- /dev/null +++ b/network/include/skid-connection.h @@ -0,0 +1,32 @@ +// +// network connection include file for SKID +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef SKID_NETWORK_CONNECTION_H +#define SKID_NETWORK_CONNECTION_H + +#include + +class QTcpSocket; +class QLocalSocket; +class QSslSocket; + +namespace Skid { +class Connection:public QObject +{ + Q_OBJECT + public: + explicit Connection ( QTcpSocket*, QObject *parent = 0 ); + private slots: + void readData(); +}; + +} + +#endif diff --git a/network/include/skidnet-export.h b/network/include/skidnet-export.h new file mode 100644 index 0000000..04f0761 --- /dev/null +++ b/network/include/skidnet-export.h @@ -0,0 +1,26 @@ +// +// main include file for SKID +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef SKID_NETLIB_QT_SKID_EXPORT_H +#define SKID_NETLIB_QT_SKID_EXPORT_H + +#include + +#ifdef SKIDNET_LIBBUILDSTATIC +# define SKID_NETLIB_EXPORT +#else +# ifdef SKIDNET_LIBBUILD +# define SKID_NETLIB_EXPORT Q_DECL_EXPORT +# else +# define SKID_NETLIB_EXPORT Q_DECL_IMPORT +# endif +#endif + +#endif \ No newline at end of file diff --git a/network/include/skidnet.h b/network/include/skidnet.h new file mode 100644 index 0000000..5d4c7a5 --- /dev/null +++ b/network/include/skidnet.h @@ -0,0 +1,28 @@ +// +// main network include file for SKID +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +///\file skid.h +///Include this file to gain access to all SKID runner facilities. + +#ifndef SKID_NETLIB_QT_SKID_H +#define SKID_NETLIB_QT_SKID_H + +#include "skidnet-export.h" + +///This is the main namespace in which all SKID specific functions and classes exist. +namespace Skid { +}; + + +#include "skid-connection.h" + +using namespace Skid; + +#endif diff --git a/network/network.pro b/network/network.pro new file mode 100644 index 0000000..b57a467 --- /dev/null +++ b/network/network.pro @@ -0,0 +1,52 @@ +#project file for SKID network lib + +#change this if you want to change the way the library is linked +# static - static library (linked into runner executable) +# shared - DLL or shared object (potentially less disk space, but you need to deploy the DLL) +# Note: don't use CONFIG directly it will be overwritten below +RUNNERBUILD += static +#RUNNERBUILD += shared + +#how to handle debug symbols of the runner lib itself +# debug - with debug symbols +# release - no debug symbols, release mode +# debug_and_release - build both (recommended for Windows) +# -> with Visual Studio the above have to match your runner +CONFIG += debug +#CONFIG += release +#CONFIG += debug_and_release + +#END of configuration +########################## + +include (../common.pri) + +#non-negotiable configuration :-) +DEFINES += SKIDNET_LIBBUILD=1 + +equals(RUNNERBUILD, static) { + DEFINES += SKIDNET_LIBBUILDSTATIC=1 + PRL_EXPORT_DEFINES += SKIDNET_LIBBUILDSTATIC=1 + CONFIG += static +} else { + CONFIG += shared separate_debug_info +} + + +#target spec +TEMPLATE = lib +TARGET = skidnet +DESTDIR = $$LIBDIR +QT += network +QT -= gui + +#source dirs +INCLUDEPATH += $$PWD/include $$PWD/src +DEPENDPATH += $$INCLUDEPATH + +#sources +SOURCES += \ + src/skid-connection.cpp + +HEADERS += \ + include/skid-connection.h \ No newline at end of file diff --git a/network/src/skid-connection.cpp b/network/src/skid-connection.cpp new file mode 100644 index 0000000..9deb637 --- /dev/null +++ b/network/src/skid-connection.cpp @@ -0,0 +1,19 @@ +// +// network connection for SKID +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#include "skidnet.h" + +Connection::Connection ( QTcpSocket*, QObject *parent ) + :QObject(parent) +{ +} + +void Connection::readData(){} + diff --git a/runnerlib/qt5gui/guilibqt5.pro b/runnerlib/qt5gui/guilibqt5.pro new file mode 100644 index 0000000..e336c3e --- /dev/null +++ b/runnerlib/qt5gui/guilibqt5.pro @@ -0,0 +1,51 @@ +#project file for SKID runnerlib for Qt5 based test runners + +#TODO: move this to skid.config +#change this if you want to change the way the library is linked +# static - static library (linked into runner executable) +# shared - DLL or shared object (potentially less disk space, but you need to deploy the DLL) +# Note: don't use CONFIG directly it will be overwritten below +RUNNERBUILD += static +#RUNNERBUILD += shared + +#how to handle debug symbols of the runner lib itself +# debug - with debug symbols +# release - no debug symbols, release mode +# debug_and_release - build both (recommended for Windows) +# -> with Visual Studio the above have to match your runner +CONFIG += debug +#CONFIG += release +#CONFIG += debug_and_release + +#END of configuration +########################## + +include (../../common.pri) + +#non-negotiable configuration :-) +DEFINES += RUNNERQT5_LIBBUILD=1 + +equals(RUNNERBUILD, static) { + DEFINES += RUNNERQT5_LIBBUILDSTATIC=1 + PRL_EXPORT_DEFINES += RUNNERQT5_LIBBUILDSTATIC=1 + CONFIG += static +} else { + CONFIG += shared separate_debug_info +} + + +#target spec +TEMPLATE = lib +TARGET = skidguiqt5 +DESTDIR = $$LIBDIR +QT += network +QT -= gui + +#source dirs +INCLUDEPATH += $$PWD/include $$PWD/src +DEPENDPATH += $$INCLUDEPATH + +#sources +SOURCES += + +HEADERS += \ No newline at end of file diff --git a/runnerlib/qt5gui/include/skidguiinit.h b/runnerlib/qt5gui/include/skidguiinit.h new file mode 100644 index 0000000..4b44d93 --- /dev/null +++ b/runnerlib/qt5gui/include/skidguiinit.h @@ -0,0 +1,35 @@ +// +// SKID Examples: System In Test - initialize the GUI wrapper +// This file is included by applications that want to auto-initialize. +// +// +// Author: Konrad Rosenbaum , (C) 2014 +// +// Copyright: See README/COPYING files that come with this distribution +// +// + +#ifndef SKID_GUI_PLUGIN_INIT_H +#define SKID_GUI_PLUGIN_INIT_H + +#include +#include + +namespace Skid { namespace Gui { + +static inline bool initialize() +{ + //call the factory, which will implicitly load the plugin, + //the side effect of this is that the SKID GUI controller is initialized, + //... we don't really need the style object though ... + QStyle *st=QStyleFactory::create("skidstyle"); + if(st){ + delete st; + return true; + }else + return false; +} + +}} + +#endif diff --git a/skid.pro b/skid.pro index dd74852..15164d4 100644 --- a/skid.pro +++ b/skid.pro @@ -3,9 +3,9 @@ TEMPLATE = subdirs SUBDIRS = copygen version \ agent controller gui \ - runnerqt5 \ + runnerqt5 guiqt5 guiplugin \ qt-simple qt-distrib \ - sit + sit guisit guisiti network runnerqt5.file = runnerlib/qt5/runnerqt5.pro @@ -20,8 +20,19 @@ qt-distrib.depends = runnerqt5 copygen version sit.file = examples/system-in-test/sit.pro sit.depends = copygen version +guisit.file = examples/gui-system-in-test/sit.pro +guisit.depends = copygen version + +guisiti.file = examples/gui-system-in-test/siti.pro +guisiti.depends = copygen version guiqt5 + +guiqt5.file = runnerlib/qt5gui/guilibqt5.pro +guiqt5.depends = copygen version + gui.depends = copygen version +guiplugin.file = guiplugin/guiplugin.pro + copygen.file = copygen/copygen.pro version.depends = copygen