Henning Schröder avatar Henning Schröder committed 6e3d542

first commit

Comments (0)

Files changed (21)

+#!/bin/sh
+cd pyqtdesigner/EmbeddedDesigner
+qmake
+make
+
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+import sys
+from PyQt4.QtGui import QApplication, QMainWindow, QToolButton
+from pyqtdesigner import FormEditor
+
+
+
+if __name__ == "__main__":
+    app = QApplication(sys.argv)
+    win = QMainWindow()
+    win.setWindowTitle("Embedded Designer Test")
+    win.resize(1024, 768)
+    formedit = FormEditor(win)
+    formedit.load_file("example.ui")
+    
+    tool_toggle = QToolButton(text="Toggle toolbox", 
+            checkable=True, checked=True, autoRaise=True, 
+            toggled=formedit.toolbox.setVisible)
+    win.statusBar().addWidget(tool_toggle)
+
+    win.setCentralWidget(formedit)
+    win.show()
+    app.exec_()
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QDialogButtonBox" name="buttonBox">
+   <property name="geometry">
+    <rect>
+     <x>290</x>
+     <y>20</y>
+     <width>81</width>
+     <height>241</height>
+    </rect>
+   </property>
+   <property name="orientation">
+    <enum>Qt::Vertical</enum>
+   </property>
+   <property name="standardButtons">
+    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+   </property>
+  </widget>
+  <widget class="QTableWidget" name="tableWidget">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>40</y>
+     <width>256</width>
+     <height>192</height>
+    </rect>
+   </property>
+   <row>
+    <property name="text">
+     <string>one</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>two</string>
+    </property>
+   </row>
+   <column>
+    <property name="text">
+     <string>foo</string>
+    </property>
+   </column>
+   <column>
+    <property name="text">
+     <string>bar</string>
+    </property>
+   </column>
+   <item row="0" column="0">
+    <property name="text">
+     <string>1</string>
+    </property>
+   </item>
+   <item row="0" column="1">
+    <property name="text">
+     <string>2</string>
+    </property>
+   </item>
+   <item row="1" column="0">
+    <property name="text">
+     <string>3</string>
+    </property>
+   </item>
+   <item row="1" column="1">
+    <property name="text">
+     <string>4</string>
+    </property>
+   </item>
+  </widget>
+  <widget class="QToolButton" name="toolButton">
+   <property name="geometry">
+    <rect>
+     <x>30</x>
+     <y>10</y>
+     <width>51</width>
+     <height>22</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Test</string>
+   </property>
+  </widget>
+  <widget class="QCheckBox" name="checkBox">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>240</y>
+     <width>82</width>
+     <height>18</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>CheckBox</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>Dialog</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>Dialog</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>

pyqtdesigner/EmbeddedDesigner/EmbeddedDesigner.cpp

+#include <QApplication>
+#include "EmbeddedDesigner.h"
+#include "pyqtwrapper.h"
+
+
+EmbeddedDesigner::EmbeddedDesigner(QWidget* parent): EmbeddedDesignerForm(parent)
+{
+    //load("/home/jes/tmp/testprj/Project/NewProject.ui");
+    connect(this, SIGNAL(fileChanged()), SLOT(onFileChanged()));
+}
+
+EmbeddedDesigner::~EmbeddedDesigner()
+{
+
+}
+
+bool EmbeddedDesigner::load(const QString & fileName)
+{
+    return loadFile(fileName);
+}
+
+bool EmbeddedDesigner::save()
+{
+    return saveFile();
+}
+
+void EmbeddedDesigner::onFileChanged()
+{
+    emit changed();
+}
+
+
+extern "C"
+{
+
+   void *init() {
+     PyQtWrapper *wrapper = new PyQtWrapper(QApplication::instance());
+     wrapper->registerMetaObject(EmbeddedDesigner::staticMetaObject);
+     return (void*)wrapper;
+   }
+
+}

pyqtdesigner/EmbeddedDesigner/EmbeddedDesigner.h

+#ifndef EMBEDEDDESIGNER_H
+#define EMBEDEDDESIGNER_H
+
+#include "EmbeddedDesigner_global.h"
+#include "EmbeddedDesignerForm.h"
+
+class EMBEDEDDESIGNERSHARED_EXPORT EmbeddedDesigner: public EmbeddedDesignerForm {
+    Q_OBJECT
+public:
+    Q_INVOKABLE explicit EmbeddedDesigner(QWidget* parent = NULL);
+    virtual ~EmbeddedDesigner();
+public slots:
+    bool load(const QString & fileName);
+    bool save();
+signals:
+    void changed();
+private slots:
+    void onFileChanged();
+};
+
+
+extern "C"
+{
+  void *init();
+}
+
+#endif // EMBEDEDDESIGNER_H

pyqtdesigner/EmbeddedDesigner/EmbeddedDesigner.pro

+TARGET    =  EmbeddedDesigner
+TEMPLATE  =  lib
+CONFIG    += designer plugin
+LIBS      += -lQtDesignerComponents -lQtDesigner
+
+DEFINES   += EMBEDEDDESIGNER_LIBRARY
+
+
+SOURCES   += EmbeddedDesigner.cpp \
+             EmbeddedDesignerForm.cpp \
+             pyqtwrapper.cpp
+
+HEADERS   += EmbeddedDesigner.h\
+             EmbeddedDesigner_global.h \
+             EmbeddedDesignerForm.h \
+             internals/shared_global_p.h \
+             internals/qdesigner_integration_p.h \
+             pyqtwrapper.h
+
+FORMS     += EmbeddedDesignerForm.ui
+
+RESOURCES += EmbeddedDesigner.qrc

pyqtdesigner/EmbeddedDesigner/EmbeddedDesigner.qrc

+<RCC>
+    <qresource prefix="/images">
+        <file>images/buddytool.png</file>
+        <file>images/tabordertool.png</file>
+        <file>images/widgettool.png</file>
+    </qresource>
+</RCC>

pyqtdesigner/EmbeddedDesigner/EmbeddedDesignerForm.cpp

+#include <QDebug>
+#include <QFile>
+#include <QPluginLoader>
+#include <QMdiSubWindow>
+#include <QMessageBox>
+#include <QDir>
+#include <QCloseEvent>
+#include <QScrollBar>
+#include <QTextCodec>
+#include <QtDesigner/QDesignerFormEditorInterface>
+#include <QtDesigner/QDesignerComponents>
+#include <QtDesigner/QDesignerWidgetBoxInterface>
+#include <QtDesigner/QDesignerFormEditorPluginInterface>
+#include <QtDesigner/QDesignerFormWindowManagerInterface>
+#include <QtDesigner/QDesignerObjectInspectorInterface>
+#include <QtDesigner/QDesignerPropertyEditorInterface>
+#include "internals/qdesigner_integration_p.h"
+
+#include "EmbeddedDesignerForm.h"
+#include "ui_EmbeddedDesignerForm.h"
+
+EmbeddedDesignerForm::EmbeddedDesignerForm(QWidget *parentWidget) :
+    QWidget(parentWidget),
+    ui(new Ui::EmbeddedDesignerForm)
+{
+    ui->setupUi(this);
+    ui->splitter_2->setStretchFactor(1, 100);
+
+    QDesignerFormEditorInterface *iface = QDesignerComponents::createFormEditor(this);
+    QDesignerComponents::createTaskMenu(iface, parent());
+    QDesignerComponents::initializePlugins( iface );
+    QDesignerComponents::initializeResources();
+    iface->setTopLevel(this);
+    iface->setWidgetBox(QDesignerComponents::createWidgetBox(iface, this));
+
+    iface->widgetBox()->setFileName(QLatin1String(":/trolltech/widgetbox/widgetbox.xml"));
+    iface->widgetBox()->load();
+
+    iface->setPropertyEditor(QDesignerComponents::createPropertyEditor(iface, 0));
+    iface->setObjectInspector(QDesignerComponents::createObjectInspector(iface, 0));
+    iface->setActionEditor(QDesignerComponents::createActionEditor(iface, 0));
+
+    _designer = new qdesigner_internal::QDesignerIntegration(iface, this);
+    iface->setIntegration(_designer);
+    qdesigner_internal::QDesignerIntegration::initializePlugins( iface );
+
+    QDesignerFormEditorPluginInterface *fep;
+    foreach (QObject *plugin, QPluginLoader::staticInstances()) {
+        if ( (fep = qobject_cast<QDesignerFormEditorPluginInterface*>(plugin)) ) {
+            if (!fep->isInitialized())
+                fep->initialize(_designer->core());
+
+            QString actionText = fep->action()->text();
+            if (actionText == "Edit Tab Order")
+                _editTabAction = fep->action();
+
+            if (actionText == "Edit Buddies")
+                _editBuddies = fep->action();
+        }
+    }
+
+    QWidget * widgetBox = _designer->core()->widgetBox();
+    //QDesignerWidgetBoxInterface *widgetBox = QDesignerComponents::createWidgetBox(iface, 0);
+    ui->widgetsPlace->layout()->addWidget(widgetBox);
+    widgetBox->setObjectName("toolbox");
+
+    QWidget * widgetObjectInspector = qobject_cast<QDesignerObjectInspectorInterface *>(_designer->core()->objectInspector());
+    ui->objectsPlace->layout()->addWidget(widgetObjectInspector);
+    widgetObjectInspector->setObjectName("inspector");
+
+    QWidget * widgetPropertyEditor = qobject_cast<QDesignerPropertyEditorInterface * >(_designer->core()->propertyEditor());
+    ui->propertyPlace->layout()->addWidget(widgetPropertyEditor);
+    widgetPropertyEditor->setObjectName("properties");
+
+    QWidget *signalSlotEditor = QDesignerComponents::createSignalSlotEditor(iface, 0);
+    signalSlotEditor->hide();
+    ui->propertyPlace->layout()->addWidget(signalSlotEditor);
+    signalSlotEditor->setObjectName("signals2slots");
+     
+    //QWidget * actionEditor = qobject_cast<QDesignerActionEditorInterface * >(_designer->core()->actionEditor());
+    QDesignerActionEditorInterface *actionEditor = QDesignerComponents::createActionEditor(iface, 0);
+    iface->setActionEditor(actionEditor);
+    //ui->propertyPlace->layout()->addWidget(actionEditor);
+
+
+    connect(ui->editSwitch, SIGNAL(buttonPressed(QAbstractButton*)), SLOT(onEditSwithPressed(QAbstractButton*)));
+    _modified = false;
+}
+
+void EmbeddedDesignerForm::showEvent(QShowEvent *)
+{
+    QList<int> sizes;
+    sizes << 250 << ui->splitter_2->width() - 450 << 250;
+    ui->splitter_2->setSizes(sizes);
+    //qDebug() << ui->formPlace->horizontalScrollBar()->value();
+    //ui->formPlace->horizontalScrollBar()->setValue(-ui->formPlace->horizontalScrollBar()->value());
+    //ui->formPlace->scroll(-ui->formPlace->horizontalScrollBar()->value(),0);
+}
+
+EmbeddedDesignerForm::~EmbeddedDesignerForm()
+{
+    delete ui;
+}
+
+bool EmbeddedDesignerForm::loadFile(const QString & fileName)
+{
+    if (QFile::exists(fileName)){
+        QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
+        _fileName = fileName;
+        _form = _designer->core()->formWindowManager()->createFormWindow(this);
+        _form->setFileName(_fileName);
+
+        QFile f(fileName);
+        f.open(QIODevice::ReadOnly | QIODevice::Text);
+        _form->setContents(f.readAll());
+        f.close();
+
+        QMdiSubWindow *wnd = ui->formPlace->addSubWindow(_form, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
+        const QSize containerSize = _form->mainContainer()->size();
+        const QSize containerMinimumSize = _form->mainContainer()->minimumSize();
+        const QSize containerMaximumSize = _form->mainContainer()->maximumSize();
+        const QSize decorationSize = wnd->geometry().size() - wnd->contentsRect().size();
+        qDebug() << containerSize;
+        wnd->resize(containerSize+decorationSize);
+        wnd->setMinimumSize(containerMinimumSize+decorationSize);
+        if( containerMaximumSize == QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX) )
+            wnd->setMaximumSize(containerMaximumSize);
+        else
+            wnd->setMaximumSize(containerMaximumSize+decorationSize);
+        wnd->setWindowTitle( _form->mainContainer()->windowTitle() );
+
+        connect(_form, SIGNAL(changed()), SLOT(onFormChanged()));
+        _designer->core()->formWindowManager()->setActiveFormWindow(_form);
+        _form->editWidgets();
+        return true;
+    }
+    return false;
+}
+
+void EmbeddedDesignerForm::onEditSwithPressed(QAbstractButton* btn)
+{
+    QString id = btn->property("id").toString();
+    if (id == "widgets") {
+        QDesignerFormWindowManagerInterface *formWindowManager = _designer->core()->formWindowManager();
+        for (int i=0; i<formWindowManager->formWindowCount(); ++i) {
+            QDesignerFormWindowInterface *formWindow = formWindowManager->formWindow(i);
+            formWindow->editWidgets();
+        }
+    }
+
+    if (id == "tabs") {
+        _editTabAction->trigger();
+    }
+
+    if (id == "buddies") {
+        _editBuddies->trigger();
+    }
+}
+
+bool EmbeddedDesignerForm::saveFile()
+{
+    QFile file(_fileName);
+    if (file.open(QIODevice::WriteOnly | QIODevice::Text)){
+        file.write(_form->contents().toUtf8());
+        file.close();
+        _modified = false;
+        return true;
+    }
+    qDebug() << "cannot save file" << _fileName;
+    return false;
+}
+
+void EmbeddedDesignerForm::onFormChanged()
+{
+    qDebug() << "Changed";
+    _modified = true;
+    emit fileChanged();
+}
+
+void EmbeddedDesignerForm::closeEvent(QCloseEvent *event)
+{
+    if (_modified){
+        QMessageBox::StandardButton res = QMessageBox::question(this, "Close editor",
+                        QString("The document \"%1\" has unsaved changes. Would you like to save them?").arg(_fileName),
+                        QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
+        if ( res == QMessageBox::Ok){
+            saveFile();
+        }
+        if (res == QMessageBox::Cancel){
+            event->ignore();
+        }
+    }
+}

pyqtdesigner/EmbeddedDesigner/EmbeddedDesignerForm.h

+#ifndef EMBEDEDDESIGNERFORM_H
+#define EMBEDEDDESIGNERFORM_H
+
+#include <QWidget>
+#include <QAbstractButton>
+
+namespace Ui {
+    class EmbeddedDesignerForm;
+}
+
+namespace qdesigner_internal {
+    class QDesignerIntegration;
+}
+class QDesignerFormWindowInterface;
+class EmbeddedDesignerForm : public QWidget
+{
+    Q_OBJECT
+
+public:
+    explicit EmbeddedDesignerForm(QWidget *parent = 0);
+    ~EmbeddedDesignerForm();
+protected:
+    void showEvent(QShowEvent *);
+    void closeEvent(QCloseEvent *);
+    bool loadFile(const QString & fileName);
+    bool saveFile();
+private:
+    Ui::EmbeddedDesignerForm *ui;
+    qdesigner_internal::QDesignerIntegration *_designer;
+    QAction *_editTabAction;
+    QAction *_editBuddies;
+    bool _modified;
+    QString _fileName;
+    QDesignerFormWindowInterface * _form;
+
+signals:
+    void fileChanged();
+private slots:
+    void onEditSwithPressed(QAbstractButton*);
+    void onFormChanged();
+};
+
+#endif // EMBEDEDDESIGNERFORM_H

pyqtdesigner/EmbeddedDesigner/EmbeddedDesignerForm.ui

+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EmbeddedDesignerForm</class>
+ <widget class="QWidget" name="EmbeddedDesignerForm">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>942</width>
+    <height>530</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
+      <item>
+       <widget class="QToolButton" name="editWidgetsBtn">
+        <property name="text">
+         <string>Edit Widgets</string>
+        </property>
+        <property name="icon">
+         <iconset resource="EmbeddedDesigner.qrc">
+          <normaloff>:/images/images/widgettool.png</normaloff>:/images/images/widgettool.png</iconset>
+        </property>
+        <property name="checkable">
+         <bool>true</bool>
+        </property>
+        <property name="autoExclusive">
+         <bool>true</bool>
+        </property>
+        <property name="id" stdset="0">
+         <string>widgets</string>
+        </property>
+        <attribute name="buttonGroup">
+         <string>editSwitch</string>
+        </attribute>
+       </widget>
+      </item>
+      <item>
+       <widget class="QToolButton" name="editTabBtn">
+        <property name="text">
+         <string>Edit Tab Order</string>
+        </property>
+        <property name="icon">
+         <iconset resource="EmbeddedDesigner.qrc">
+          <normaloff>:/images/images/tabordertool.png</normaloff>:/images/images/tabordertool.png</iconset>
+        </property>
+        <property name="checkable">
+         <bool>true</bool>
+        </property>
+        <property name="autoExclusive">
+         <bool>true</bool>
+        </property>
+        <property name="id" stdset="0">
+         <string>tabs</string>
+        </property>
+        <attribute name="buttonGroup">
+         <string>editSwitch</string>
+        </attribute>
+       </widget>
+      </item>
+      <item>
+       <widget class="QToolButton" name="editBuddyBtn">
+        <property name="text">
+         <string>Edit Buddies</string>
+        </property>
+        <property name="icon">
+         <iconset resource="EmbeddedDesigner.qrc">
+          <normaloff>:/images/images/buddytool.png</normaloff>:/images/images/buddytool.png</iconset>
+        </property>
+        <property name="checkable">
+         <bool>true</bool>
+        </property>
+        <property name="autoExclusive">
+         <bool>true</bool>
+        </property>
+        <property name="id" stdset="0">
+         <string>buddies</string>
+        </property>
+        <attribute name="buttonGroup">
+         <string>editSwitch</string>
+        </attribute>
+       </widget>
+      </item>
+      <item>
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>0</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QSplitter" name="splitter_2">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <widget class="QWidget" name="widgetsPlace" native="true">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="minimumSize">
+       <size>
+        <width>150</width>
+        <height>0</height>
+       </size>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <property name="spacing">
+        <number>0</number>
+       </property>
+       <property name="margin">
+        <number>0</number>
+       </property>
+      </layout>
+     </widget>
+     <widget class="QMdiArea" name="formPlace">
+      <property name="frameShape">
+       <enum>QFrame::NoFrame</enum>
+      </property>
+      <property name="frameShadow">
+       <enum>QFrame::Plain</enum>
+      </property>
+      <property name="verticalScrollBarPolicy">
+       <enum>Qt::ScrollBarAsNeeded</enum>
+      </property>
+      <property name="horizontalScrollBarPolicy">
+       <enum>Qt::ScrollBarAsNeeded</enum>
+      </property>
+      <property name="background">
+       <brush brushstyle="SolidPattern">
+        <color alpha="255">
+         <red>44</red>
+         <green>42</green>
+         <blue>42</blue>
+        </color>
+       </brush>
+      </property>
+     </widget>
+     <widget class="QSplitter" name="splitter">
+      <property name="minimumSize">
+       <size>
+        <width>150</width>
+        <height>0</height>
+       </size>
+      </property>
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <widget class="QWidget" name="objectsPlace" native="true">
+       <property name="minimumSize">
+        <size>
+         <width>150</width>
+         <height>0</height>
+        </size>
+       </property>
+       <layout class="QVBoxLayout" name="verticalLayout_3">
+        <property name="spacing">
+         <number>0</number>
+        </property>
+        <property name="margin">
+         <number>0</number>
+        </property>
+       </layout>
+      </widget>
+      <widget class="QWidget" name="propertyPlace" native="true">
+       <property name="minimumSize">
+        <size>
+         <width>150</width>
+         <height>0</height>
+        </size>
+       </property>
+       <layout class="QVBoxLayout" name="verticalLayout_4">
+        <property name="spacing">
+         <number>0</number>
+        </property>
+        <property name="margin">
+         <number>0</number>
+        </property>
+       </layout>
+      </widget>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="EmbeddedDesigner.qrc"/>
+ </resources>
+ <connections/>
+ <buttongroups>
+  <buttongroup name="editSwitch"/>
+ </buttongroups>
+</ui>

pyqtdesigner/EmbeddedDesigner/EmbeddedDesigner_global.h

+#ifndef EMBEDEDDESIGNER_GLOBAL_H
+#define EMBEDEDDESIGNER_GLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(EMBEDEDDESIGNER_LIBRARY)
+#  define EMBEDEDDESIGNERSHARED_EXPORT Q_DECL_EXPORT
+#else
+#  define EMBEDEDDESIGNERSHARED_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // EMBEDEDDESIGNER_GLOBAL_H

pyqtdesigner/EmbeddedDesigner/README

+This code is based on an early version of pynoto (http://code.google.com/p/pynoto/)
+by Dmitriy Zhukov (zjesclean@gmail.com)
+License: GNU GPL v3
Add a comment to this file

pyqtdesigner/EmbeddedDesigner/images/buddytool.png

Added
New image
Add a comment to this file

pyqtdesigner/EmbeddedDesigner/images/tabordertool.png

Added
New image
Add a comment to this file

pyqtdesigner/EmbeddedDesigner/images/widgettool.png

Added
New image

pyqtdesigner/EmbeddedDesigner/internals/qdesigner_integration_p.h

+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+//
+//  W A R N I N G
+//  -------------
+//
+// This file is not part of the Qt API.  It exists for the convenience
+// of Qt Designer.  This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QDESIGNER_INTEGRATION_H
+#define QDESIGNER_INTEGRATION_H
+
+#include "shared_global_p.h"
+#include <QtDesigner/QDesignerIntegrationInterface>
+
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QDesignerFormEditorInterface;
+class QDesignerFormWindowInterface;
+class QDesignerResourceBrowserInterface;
+
+class QVariant;
+class QWidget;
+
+namespace qdesigner_internal {
+
+struct Selection;
+class QDesignerIntegrationPrivate;
+
+class QDESIGNER_SHARED_EXPORT QDesignerIntegration: public QDesignerIntegrationInterface
+{
+    Q_OBJECT
+public:
+    explicit QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = 0);
+    virtual ~QDesignerIntegration();
+
+    static void requestHelp(const QDesignerFormEditorInterface *core, const QString &manual, const QString &document);
+
+    virtual QWidget *containerWindow(QWidget *widget) const;
+
+    // Load plugins into widget database and factory.
+    static void initializePlugins(QDesignerFormEditorInterface *formEditor);
+    void emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object,
+                               const QString &newName, const QString &oldName);
+    void emitNavigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList &parameterNames);
+    void emitNavigateToSlot(const QString &slotSignature);
+
+    // Create a resource browser specific to integration. Language integration takes precedence
+    virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = 0);
+
+    enum ResourceFileWatcherBehaviour {
+        NoWatcher,
+        ReloadSilently,
+        PromptAndReload
+    };
+
+    ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const;
+    bool isResourceEditingEnabled() const;
+    bool isSlotNavigationEnabled() const;
+
+    QString contextHelpId() const;
+
+protected:
+
+    void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour); // PromptAndReload by default
+    void setResourceEditingEnabled(bool enable); // true by default
+    void setSlotNavigationEnabled(bool enable); // false by default
+
+signals:
+    void propertyChanged(QDesignerFormWindowInterface *formWindow, const QString &name, const QVariant &value);
+    void objectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName);
+    void helpRequested(const QString &manual, const QString &document);
+
+    void navigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList &parameterNames);
+    void navigateToSlot(const QString &slotSignature);
+
+public slots:
+    virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling);
+    // Additional signals of designer property editor
+    virtual void resetProperty(const QString &name);
+    virtual void addDynamicProperty(const QString &name, const QVariant &value);
+    virtual void removeDynamicProperty(const QString &name);
+
+    virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow);
+    virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow);
+    virtual void updateSelection();
+    virtual void updateGeometry();
+    virtual void activateWidget(QWidget *widget);
+
+    void updateCustomWidgetPlugins();
+
+private slots:
+    void updatePropertyPrivate(const QString &name, const QVariant &value);
+
+private:
+    void initialize();
+    void getSelection(Selection &s);
+    QObject *propertyEditorObject();
+
+    QDesignerIntegrationPrivate *m_d;
+};
+
+} // namespace qdesigner_internal
+
+QT_END_NAMESPACE
+
+#endif // QDESIGNER_INTEGRATION_H

pyqtdesigner/EmbeddedDesigner/internals/shared_global_p.h

+/****************************************************************************
+**
+** Copyright 1992-2006 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** This file may be used under the terms of the GNU General Public
+** License version 2.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of
+** this file.  Please review the following information to ensure GNU
+** General Public Licensing requirements will be met:
+** http://www.trolltech.com/products/qt/opensource.html
+**
+** If you are unsure which license is appropriate for your use, please
+** review the following information:
+** http://www.trolltech.com/products/qt/licensing.html or contact the
+** sales department at sales@trolltech.com.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
+//
+//  W A R N I N G
+//  -------------
+//
+// This file is not part of the Qt API.  It exists for the convenience
+// of Qt Designer.  This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef SHARED_GLOBAL_H
+#define SHARED_GLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#ifdef QT_DESIGNER_STATIC
+#define QDESIGNER_SHARED_EXTERN
+#define QDESIGNER_SHARED_IMPORT
+#else
+#define QDESIGNER_SHARED_EXTERN Q_DECL_EXPORT
+#define QDESIGNER_SHARED_IMPORT Q_DECL_IMPORT
+#endif
+
+#ifndef QT_NO_SHARED_EXPORT
+#  ifdef QDESIGNER_SHARED_LIBRARY
+#    define QDESIGNER_SHARED_EXPORT QDESIGNER_SHARED_EXTERN
+#  else
+#    define QDESIGNER_SHARED_EXPORT QDESIGNER_SHARED_IMPORT
+#  endif
+#else
+#  define QDESIGNER_SHARED_EXPORT
+#endif
+
+#endif // SHARED_GLOBAL_H

pyqtdesigner/EmbeddedDesigner/pyqtwrapper.cpp

+#include "pyqtwrapper.h"
+#include <QApplication>
+#include <QVariant>
+#include <QPushButton>
+#include <qdebug.h>
+
+
+PyQtWrapper *PyQtWrapper::_instance = 0;
+
+
+PyQtWrapper::PyQtWrapper(QObject *parent) :
+    QObject(parent)
+{
+    PyQtWrapper::_instance = this;
+    setObjectName("PyQtWrapper");
+    QApplication::instance()->setProperty("pyqtwrapper",
+                                          qVariantFromValue((QObject*)this));
+    //registerObject(this);
+}
+
+
+void PyQtWrapper::deleteLater() {
+    QApplication::instance()->setProperty("pyqtwrapper",
+                                          qVariantFromValue(NULL));
+}
+
+
+
+void* PyQtWrapper::metaObjectByName(const QString &name) {
+    return (void*)classes[name];
+}
+
+QObject* PyQtWrapper::objectByName(const QString &name) {
+    return (QObject*)objects[name];
+}
+
+
+QStringList PyQtWrapper::availableClasses() {
+    return classes.keys();
+}
+
+
+QStringList PyQtWrapper::availableObjects() {
+    return objects.keys();
+}
+
+
+void PyQtWrapper::registerMetaObject(const QMetaObject &mo) {
+    classes[mo.className()] = &mo;
+}
+
+
+void PyQtWrapper::registerObject(const QObject &obj) {
+    //connect(obj, SIGNAL(destroyed()), unregister_objec);
+    objects[obj.objectName()] = &obj;
+}
+

pyqtdesigner/EmbeddedDesigner/pyqtwrapper.h

+#ifndef PYQTWRAPPER_H
+#define PYQTWRAPPER_H
+
+#include <QObject>
+#include <QMetaObject>
+#include <QMap>
+#include <QStringList>
+
+#define REGISTER_CLASS(cls) PyQtWrapper::instance()->registerMetaObject(cls::staticMetaObject);
+#define REGISTER_INSTANCE(obj) PyQtWrapper::instance()->registerObject(obj);
+
+
+class PyQtWrapper : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit PyQtWrapper(QObject *parent = 0);
+    static PyQtWrapper *instance();
+
+public slots:
+    void deleteLater();
+    void* metaObjectByName(const QString &name);
+    QObject* objectByName(const QString &name);
+    QStringList availableClasses();
+    QStringList availableObjects();
+    void registerMetaObject(const QMetaObject &mo);
+    void registerObject(const QObject &obj);
+
+private:
+    static PyQtWrapper *_instance;
+    QMap<QString,const QMetaObject*> classes;
+    QMap<QString,const QObject*> objects;
+};
+
+
+#endif // PYQTWRAPPER_H

pyqtdesigner/__init__.py

+# -*- coding: utf-8 -*-
+import os
+import tempfile
+
+import sip
+from PyQt4.QtCore import pyqtSignal
+from PyQt4.QtGui import QWidget, QVBoxLayout
+
+from wrapper import LibWrapper
+
+
+_lib = None
+
+def init():
+    global _lib
+    path = os.path.dirname(os.path.abspath(__file__))
+    lib_filename = os.path.join(path, "EmbeddedDesigner", "libEmbeddedDesigner.so")
+    _lib = LibWrapper(lib_filename)
+
+
+
+
+def EmbeddedDesigner(parent, **properties):
+    if not _lib:
+        init()
+    obj = _lib.EmbeddedDesigner(parent, **properties)
+    return obj
+
+
+
+class FormEditor(QWidget):
+
+
+    def __init__(self, parent=None):
+        super(FormEditor, self).__init__(parent)
+        self._layout = QVBoxLayout(self)
+        self._designer = EmbeddedDesigner(self)
+        self.layout().addWidget(self._designer)
+        self.inspector = self._designer.findChild(QWidget, "inspector")
+        self.propedit = self._designer.findChild(QWidget, "properties")
+        self.toolbox = self._designer.findChild(QWidget, "toolbox")
+        self.signals2slots = self._designer.findChild(QWidget, "signals2slots")
+        #self.signals2slots.show()
+        self._designer.changed.connect(self.on_changed)
+        
+        
+    def on_changed(self):
+        print "form changed"
+        
+
+    def load_file(self, filename):
+        self._designer.load(filename)
+
+        
+    def save(self):
+        self._designer.save()
+    
+
+
+
+__all__ = ["FormEditor"]
+
+
+

pyqtdesigner/wrapper.py

+# -*- coding: utf-8 -*-
+import ctypes
+
+import sip
+from PyQt4.QtCore import QObject, QMetaObject, pyqtSignal, Q_ARG
+
+
+
+def cfunc(func, *args, **kwargs):
+	result_type = kwargs.pop("type", None)
+	if kwargs:
+		raise TypeError("Unknown keyword argument(s): %r" % kwargs)
+	ptr = func(*args)
+	if isinstance(ptr, sip.voidptr):
+		ptr = int(ptr)
+	if result_type is not None:
+		return sip.wrapinstance(ptr, result_type)
+	return ptr
+
+
+
+def new_instance(mo, *args, **properties):
+	obj = None
+	for mi in range(mo.constructorCount()):
+		mm = mo.constructor(mi)
+		names = [str(n) for n in mm.parameterNames()]
+		types = [str(t).rstrip("&*") for t in mm.parameterTypes()]
+		param_types = zip(names, types)
+		if len(param_types) != len(args):
+			continue
+		arg_types = []
+		for i, (pn, pt) in enumerate(param_types):
+			a = args[i]
+			classes = [type(a)]
+			at = None
+			for cls in classes:
+				if cls.__name__ == pt:
+					at = cls
+					break
+				for base in cls.__bases__:
+					if base not in classes:
+						classes.append(base)
+			if not at:
+				break
+			arg_types.append(at)
+		if len(arg_types) == len(args):
+			obj = mo.newInstance(*[Q_ARG(at, an) for (at,an) in zip(arg_types, args)])
+			obj.pyqtConfigure(**properties)
+			if obj is not None:
+				break
+
+	if not obj:
+		raise TypeError("Could not find matching constructor for %s" % class_name)
+	return obj
+
+
+
+
+
+class LibWrapper(object):
+
+
+	def __init__(self, filename):
+		self._lib = ctypes.cdll.LoadLibrary(filename)
+		self._instance = cfunc(self._lib.init, type=QObject)
+
+
+	
+	def __getattr__(self, name):
+		mo = cfunc(self._instance.metaObjectByName, name, type=QMetaObject)
+		if mo is not None:
+			cls = lambda *args, **properties: new_instance(mo, *args, **properties)
+			setattr(self, name, cls)
+			return cls
+		else:
+			obj = cfunc(self._instance.classByName, name, type=QObject)
+			if obj is not None:
+				setattr(self, name, obj)
+				return obj
+		raise AttributeError(name)
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.