From 0692435b26861b4eb9dcffa8c6703a76bfa64abd Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Tue, 11 Apr 2017 11:23:34 +0300 Subject: [PATCH] Dialog designers tool bar integration has been added --- limereport/dialogdesigner/dialogdesigner.pri | 3 + limereport/dialogdesigner/dialogdesigner.qrc | 9 ++ .../dialogdesigner/images/buddytool.png | Bin 0 -> 997 bytes limereport/dialogdesigner/images/editform.png | Bin 0 -> 349 bytes .../dialogdesigner/images/signalslottool.png | Bin 0 -> 1128 bytes .../dialogdesigner/images/tabordertool.png | Bin 0 -> 1205 bytes .../dialogdesigner/images/widgettool.png | Bin 0 -> 1039 bytes .../dialogdesigner/lrdialogdesigner.cpp | 99 +++++++++++++++--- limereport/dialogdesigner/lrdialogdesigner.h | 14 ++- limereport/lrreportdesignwidget.cpp | 48 ++++++++- limereport/lrreportdesignwidget.h | 12 ++- limereport/lrreportdesignwindow.cpp | 27 ++++- limereport/lrreportdesignwindow.h | 7 ++ limereport/lrscriptenginemanager.cpp | 11 ++ limereport/lrscriptenginemanager.h | 3 +- 15 files changed, 209 insertions(+), 24 deletions(-) create mode 100644 limereport/dialogdesigner/dialogdesigner.qrc create mode 100644 limereport/dialogdesigner/images/buddytool.png create mode 100644 limereport/dialogdesigner/images/editform.png create mode 100644 limereport/dialogdesigner/images/signalslottool.png create mode 100644 limereport/dialogdesigner/images/tabordertool.png create mode 100644 limereport/dialogdesigner/images/widgettool.png diff --git a/limereport/dialogdesigner/dialogdesigner.pri b/limereport/dialogdesigner/dialogdesigner.pri index 37a1ea1..df76e68 100644 --- a/limereport/dialogdesigner/dialogdesigner.pri +++ b/limereport/dialogdesigner/dialogdesigner.pri @@ -15,3 +15,6 @@ QT += designer designercomponents-private SOURCES += $$PWD/lrdialogdesigner.cpp HEADERS += $$PWD/lrdialogdesigner.h + +RESOURCES += \ + $$PWD/dialogdesigner.qrc diff --git a/limereport/dialogdesigner/dialogdesigner.qrc b/limereport/dialogdesigner/dialogdesigner.qrc new file mode 100644 index 0000000..67c62fb --- /dev/null +++ b/limereport/dialogdesigner/dialogdesigner.qrc @@ -0,0 +1,9 @@ + + + images/buddytool.png + images/editform.png + images/signalslottool.png + images/tabordertool.png + images/widgettool.png + + diff --git a/limereport/dialogdesigner/images/buddytool.png b/limereport/dialogdesigner/images/buddytool.png new file mode 100644 index 0000000000000000000000000000000000000000..4cd968bbf5fb473cecf134e7c1dc0793e869445d GIT binary patch literal 997 zcmVM&= zaCqIkO%%LMHg(=I2^41ZLv&gA?K~%)&gM4jz?bvB&pGG&dCq&D!z&VrM8Qnb|5Pvl zku6b^8jVKu_V!|Ma1c734t;%n{C!|xfNNxA1pWQ}d~A6R^`xq*Dsqw91q=-hp{1n- zjg5^^sZ?ldYePdr16ONnD>^zl_;XWJ6Q4&hnoCMZNN@}o9v+6OUImRt!_CxcHSfuY zVx;cwZXPEPy*D>Evt;U#n3(7opx5iUnYK%d_V#wZn07%i%9x(Jy1IB=t=8~3#Ylo6 zI0vAt$gHfa3<`w;6%`fe>FMF7v>O`l?Cj({#mStKNlr>~44^}#tt*vEgocJfB9UOH z$8PusMME5!jv&&hOs0$_Wg8$5CEh4!K;8)YMd78QZpdA@__JsLlf# zl)(GPD|#j4keoZukdl((9H6eQj+f$ci5@wf3B1i`eHQQ{19)-{i%T*WpM~juBqUK+ zAr6Uf449ahfL5!u)ICWO#n!ZxvTPaPT_K>1!Q!(R{46;SNPS_Bae*n#6Yib|vDMwL z*)CvaW(HKMq~!|~5-kTB6+l_6wdB6Q1s6~=$1+H|7q)v#zKEmq3he+sfGSC^H}LEY z1_Of6$=D8_0_AZly6y+WZ^G(kj@txNmNyvSlPw4b%+Ah2H>3ld1(}oh4m2ge%Y;9= z;SUJb<`xKpnq)pUAr=6ckByCCa&i)*qoW8tp983F;#*}r7W4K1Nv^Qh%!v$=?fVym z1Lo%DU^I>`$;e@Miz^Wpn+wy6IDEZi-`oO8c7-X|&kDi;^YimO^O=tyK?goPJ&mcU zDcn=MVvrmxSpI4X$-;etN!TmDD3bN<8#4Y{7QEK$zbC} z0jSOmLqXhr4iP!?!=XB-QZyCrgE?!9ZSyNEUVH$xx5FWX?ONHvdKYA^XfiD_Jq&*2)<;3$TJbVi36-_g=il`qIOwd2kX!xaZ$hv=M+6gnf=5 z%-sAu5Vb{-5Keg6z6ToxtcEP8Gx3I*Up#5&CjSdyHKgEj;JW7j1y~JP&z$rdsg5DL TV66v=00000NkvXXu0mjfW+uQs literal 0 HcmV?d00001 diff --git a/limereport/dialogdesigner/images/editform.png b/limereport/dialogdesigner/images/editform.png new file mode 100644 index 0000000000000000000000000000000000000000..452fcd8878b7c7999b5317aae0cb90c28df36a36 GIT binary patch literal 349 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbMaAH3s;Exc>kD-yxy_$O8fhL*Fs( z!rTArAO26TYTokr|C4Y3r{DNL<@)~%ENYmvXLW(Yb#V6h5A=elF{r5}E)%Jgjs8 literal 0 HcmV?d00001 diff --git a/limereport/dialogdesigner/images/signalslottool.png b/limereport/dialogdesigner/images/signalslottool.png new file mode 100644 index 0000000000000000000000000000000000000000..e80fd1caa625d6fa6342bec58bc5619386b21b7c GIT binary patch literal 1128 zcmV-u1eg1XP)cij(J$Niew-Fe^V>79p}CBfF#Kb$!;@Xr6oIsZ9~ zbnN2g!X37hN<@?QD9@FMS-QHNbHDQdnYPE<4jlUQhdo-#v^F=Rb->(gnJ9`0f&hSY zI!&om!We_K7NwN$0KL7vbar-j0S^XflUsfE!c|7cMrmDlmAxQXj6O$|&=&2aAGZH}F|O#iK$G&W``#@;ZFV;UM7`~->d z0w|7RwAPCQuACb?`{J`Z*uQUw=S@$~as1>(B4!9eyt#;=#G!OVCX>Qi>*1Mf#=l<_ zaHF58@;t0sv62tp%hS@FUKKtqnVMZ{4BMcQ1miXq_pXi`WE|&%HU}MbU000q% zk~D$j_~4zFXm5RtTZ08Y`QikroFmidIQ-oo^!zo#XkikioHwri2p$UX4?E|Wn~e!1 zn@qBwmF>$J9GT(Z;op*JPIIMi80X;cTjL;p_Y1X{3|`a%^&l;EeAJca~;^EqDjO1raQ`Fbz*syU^0x&r6 zW>I7jarE`{a<4EASUjNmPn6W+5)nkmr&0my)~%(jwTX194jm}Uy$D$k`YrjzDWtf%a>_RX!^pwsMfIt4q2=Kgt9{qXmBY{%f3bP(3D5 uf*=5X8s)Qs!JF5X4Cvmyy`_t#srw(dSG7JJtV|{V0000}MF0#M1Cu_l5A*Z$SYBQhmX?;VxUe9(MHMfom^nUMU0s!!IeEUgC^f|E z^@4hL8Qf}VL2qv_1_uXWx7#HqJv}{exm>ud*1osYV zu~;xLFaU?cA+ULPcv!?4Q$WYslxFN9+N{03J-UHeIkSmVbES!HW^QzJR3_x!>2wOL zp$TKwxYZDCZEevFtX8WOQh;KdUJFu$rdpVJ?)3mV&!dfL(ACuyK1&KxM8g~f^pQ+V zOvs)llarGeA0Nla$cWV1Y_{kI9UUFg%p$(Q*w~l|vysAFb&dv+=g)e5gx%fU(G7mN zX2aW`Hz7W&K}|G)6W{%bxC0ktf5YlT?UmcueY8<>g=Z}yMpGUo&9n)RDXPJlpRG9d zm01Kh;qh-<;c}0m?8i3j{^Sa3e(S*XRtK8f-BLqS-g$jIgmKI_;MKeMheMiKOp~dp zDO@%W$Xjslne?F3F(Nf>J#P4XUdij}X~4frR0CeQhGwTUb237M{lzz7s4i<}w@N*)zU;u<+#C|qb8-4s5Q%9fG2;i2x9gFo z({So$P@qZJV0Ly^rsP+WE5DMADaL1Q33nN= znZl)&^>`^GZ=Li!5u=FSuak@1#vlr>1@X0YO>)P-I41^geG?GE2E3a3n@@wJjC|B| zuAyl-HnsLOlr;yD{cBKG*1xdtV=*}ReLx5s@D8u6tjMc#O)?hXXng<$SA)n85gAA3 zG^UIHNDmFTlCVK>NePTbBQi2FWPRw-?MTh4z;nr&G1-@0iR`K_l(ht9W&M_C_K3lW zO94R}g#IU&_9tha9Ne?Ncz9dFfxkD!?Zu|J)OEJqK`5Vd#)jN;T}VGtfz3PKz*9+w z0y|#G!s*`wf*8n;!C=^+xJU7TVyj}OB1w^~NKw3|NDaX_WoOEVD5|mHonsYpRg;YQ zwbV$?EXCQ@fN-b5M#X)KhZRpMo>e@r*riBNB!+mAxm|ld!UuVk>c^Ht&WCz8s*}L` zrV6~L2pdG0+^e`>@t|U};xWY*#p8-6LNMN{Zp=@-ZR!fwg?iY#L5WsVI7Ib-$w&7< Tg6EMl00000NkvXXu0mjf6WBk& literal 0 HcmV?d00001 diff --git a/limereport/dialogdesigner/images/widgettool.png b/limereport/dialogdesigner/images/widgettool.png new file mode 100644 index 0000000000000000000000000000000000000000..a52224e068c4ac63c6e1ed7c41025d1108e6caaa GIT binary patch literal 1039 zcmV+q1n~QbP)z8wB<%qK}Q^REM+ z&I^UY*xK3}!Z3vEx~SD^sMqTVf9Ltvs&)jhAdBpkOz$F5?sA@59=$lEdbV3qlS4v zp-7Q);0MT$-^9ek1kMaS!k6U;u^6Yq02NUc1LIu=PjT?f~B}@ZgzlFAmWt@qaBAKITLZ_X+fPJ_A8~#t7P?#&K&>iu3S8W|JF52MVZ~N&)rhwPKG=tq{Egu`L51UR9A^|4gOY00I?wLDFZex_Lj4k@8kH9eWsN+9+UoVG+w4kSKB?LXT51x z(Qbo{tMq*i&)!bAiGfZyv!Gk|d8cEF*tGaj6 #include #include +#include +#include #include "pluginmanager_p.h" //#include @@ -30,64 +32,70 @@ DialogDesigner::DialogDesigner(QObject *parent) : QObject(parent) QDesignerComponents::initializePlugins(m_formEditor); QDesignerComponents::createTaskMenu(m_formEditor, this); + m_editWidgetsAction = new QAction(tr("Edit Widgets")); + m_editWidgetsAction->setIcon(QIcon(":/images/images/widgettool.png")); + m_editWidgetsAction->setEnabled(false); + connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(slotEditWidgets())); + connect(m_formEditor->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), + this, SLOT(slotActiveFormWindowChanged(QDesignerFormWindowInterface*)) ); + + m_modes = new QActionGroup(this); + m_modes->setExclusive(true); + m_modes->addAction(m_editWidgetsAction); + foreach ( QObject* o, QPluginLoader::staticInstances() << m_formEditor->pluginManager()->instances() ) { if ( QDesignerFormEditorPluginInterface* fep = qobject_cast( o ) ) { - // initialize plugin if needed if ( !fep->isInitialized() ) fep->initialize( m_formEditor ); - - // set action chackable -// fep->action()->setCheckable( true ); - -// // add action mode to group -// aModes->addAction( fep->action() ); + fep->action()->setCheckable( true ); + fep->action()->setIcon(QIcon(iconPathByName(fep->action()->objectName()))); + m_modes->addAction(fep->action()); } } - m_widgetBox = QDesignerComponents::createWidgetBox(m_formEditor, 0); m_widgetBox->setWindowTitle(tr("Widget Box")); m_widgetBox->setObjectName(QLatin1String("WidgetBox")); m_formEditor->setWidgetBox(m_widgetBox); m_formEditor->setTopLevel(m_widgetBox); m_designerToolWindows.append(m_widgetBox); - connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); + connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) ); m_objectInspector = QDesignerComponents::createObjectInspector(m_formEditor, 0); m_objectInspector->setWindowTitle(tr("Object Inspector")); m_objectInspector->setObjectName(QLatin1String("ObjectInspector")); m_formEditor->setObjectInspector(m_objectInspector); m_designerToolWindows.append(m_objectInspector); - connect(m_objectInspector, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); + connect(m_objectInspector, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) ); m_propertyEditor = QDesignerComponents::createPropertyEditor(m_formEditor, 0); m_propertyEditor->setWindowTitle(tr("Property Editor")); m_propertyEditor->setObjectName(QLatin1String("PropertyEditor")); m_formEditor->setPropertyEditor(m_propertyEditor); m_designerToolWindows.append(m_propertyEditor); - connect(m_propertyEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); + connect(m_propertyEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) ); m_signalSlotEditor = QDesignerComponents::createSignalSlotEditor(m_formEditor, 0); m_signalSlotEditor->setWindowTitle(tr("Signals && Slots Editor")); m_signalSlotEditor->setObjectName(QLatin1String("SignalsAndSlotsEditor")); m_designerToolWindows.append(m_signalSlotEditor); - connect(m_signalSlotEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); + connect(m_signalSlotEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) ); m_resourcesEditor = QDesignerComponents::createResourceEditor(m_formEditor, 0); m_resourcesEditor->setWindowTitle(tr("Resource Editor")); m_resourcesEditor->setObjectName(QLatin1String("ResourceEditor")); m_designerToolWindows.append(m_resourcesEditor); - connect(m_resourcesEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); + connect(m_resourcesEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) ); m_actionEditor = QDesignerComponents::createActionEditor(m_formEditor, 0); m_actionEditor->setWindowTitle(tr("Action Editor")); m_actionEditor->setObjectName("ActionEditor"); m_formEditor->setActionEditor(m_actionEditor); m_designerToolWindows.append(m_actionEditor); - connect(m_formEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); + connect(m_formEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) ); m_designerIntegration = new QDesignerIntegration(m_formEditor,this); m_formEditor->setIntegration(m_designerIntegration); @@ -105,6 +113,28 @@ DialogDesigner::~DialogDesigner() delete m_formEditor; } +void DialogDesigner::initToolBar(QToolBar *tb) +{ + tb->setIconSize(QSize(16,16)); + tb->addAction(m_formEditor->formWindowManager()->actionCopy()); + tb->addAction(m_formEditor->formWindowManager()->actionPaste()); + tb->addAction(m_formEditor->formWindowManager()->actionCut()); + tb->addAction(m_formEditor->formWindowManager()->actionUndo()); + tb->addAction(m_formEditor->formWindowManager()->actionRedo()); + + tb->addActions(m_modes->actions()); + + tb->addAction(m_formEditor->formWindowManager()->actionHorizontalLayout()); + tb->addAction(m_formEditor->formWindowManager()->actionVerticalLayout()); + tb->addAction(m_formEditor->formWindowManager()->actionSplitHorizontal()); + tb->addAction(m_formEditor->formWindowManager()->actionSplitVertical()); + tb->addAction(m_formEditor->formWindowManager()->actionGridLayout()); + m_formEditor->formWindowManager()->actionFormLayout()->setIcon(QIcon(":/images/images/editform.png")); + tb->addAction(m_formEditor->formWindowManager()->actionFormLayout()); + tb->addAction(m_formEditor->formWindowManager()->actionBreakLayout()); + tb->addAction(m_formEditor->formWindowManager()->actionAdjustSize()); +} + QWidget *DialogDesigner::createFormEditor(const QString &content) { QDesignerFormWindowInterface* wnd = m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window); @@ -113,12 +143,22 @@ QWidget *DialogDesigner::createFormEditor(const QString &content) m_formEditor->objectInspector()->setFormWindow(wnd); wnd->editWidgets(); + connect(wnd, SIGNAL(changed()), this, SIGNAL(dialogChanged())); + SharedTools::WidgetHost *placeholder = new SharedTools::WidgetHost(0,wnd); placeholder->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); placeholder->setFocusProxy( wnd ); - return placeholder; + return placeholder; +} +QByteArray DialogDesigner::getDialogDescription(QWidget *form) +{ + SharedTools::WidgetHost* wh = dynamic_cast(form); + if (wh){ + return wh->formWindow()->contents().toUtf8(); + } + return QByteArray(); } void DialogDesigner::setActiveEditor(QWidget *widget) @@ -127,7 +167,6 @@ void DialogDesigner::setActiveEditor(QWidget *widget) if (wh){ m_formEditor->formWindowManager()->setActiveFormWindow(wh->formWindow()); } - } QWidget* DialogDesigner::widgetBox() const @@ -160,7 +199,7 @@ QWidget *DialogDesigner::resourcesEditor() const return m_resourcesEditor; } -void DialogDesigner::objectDestroyed(QObject *object) +void DialogDesigner::slotObjectDestroyed(QObject *object) { for ( int i = 0; iformWindowManager()->formWindowCount(); ++i){ + m_formEditor->formWindowManager()->formWindow(i)->editWidgets(); + } +} + +void DialogDesigner::slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow) +{ + if (formWindow){ + m_editWidgetsAction->setEnabled(true); + m_activeWindowName = formWindow->objectName(); + } +} + +QString DialogDesigner::iconPathByName(const QString &name) +{ + if (name.compare("__qt_edit_signals_slots_action") == 0) + return ":/images/images/signalslottool.png"; + if (name.compare("__qt_edit_buddies_action") == 0) + return ":/images/images/buddytool.png"; + if (name.compare("_qt_edit_tab_order_action") == 0) + return ":/images/images/tabordertool.png"; + return ""; +} + } diff --git a/limereport/dialogdesigner/lrdialogdesigner.h b/limereport/dialogdesigner/lrdialogdesigner.h index 2620b71..bebc4dd 100644 --- a/limereport/dialogdesigner/lrdialogdesigner.h +++ b/limereport/dialogdesigner/lrdialogdesigner.h @@ -3,6 +3,7 @@ #include #include +#include class QDesignerFormEditorInterface; class QDesignerFormWindowInterface; @@ -21,7 +22,9 @@ class DialogDesigner : public QObject public: explicit DialogDesigner(QObject *parent = 0); ~DialogDesigner(); + void initToolBar(QToolBar* tb); QWidget* createFormEditor(const QString& content); + QByteArray getDialogDescription(QWidget* form); void setActiveEditor(QWidget* widget); QWidget* widgetBox() const; QWidget* actionEditor() const; @@ -29,8 +32,14 @@ public: QWidget* objectInspector() const; QWidget* signalSlotEditor() const; QWidget* resourcesEditor() const; +signals: + void dialogChanged(); private slots: - void objectDestroyed(QObject* object); + void slotObjectDestroyed(QObject* object); + void slotEditWidgets(); + void slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow); +private: + QString iconPathByName(const QString& name); private: QDesignerFormEditorInterface* m_formEditor; QDesignerIntegrationInterface* m_designerIntegration; @@ -41,6 +50,9 @@ private: QWidget* m_signalSlotEditor; QWidget* m_resourcesEditor; QVector m_designerToolWindows; + QAction* m_editWidgetsAction; + QActionGroup* m_modes; + QString m_activeWindowName; }; } // namespace LimeReport diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 6acb22a..97621ab 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -48,7 +48,11 @@ namespace LimeReport { ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow *mainWindow, QWidget *parent) : - QWidget(parent), m_dialogDesigner(new DialogDesigner(this)), m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false) + QWidget(parent), +#ifdef HAVE_QTDESIGNER_INTEGRATION + m_dialogDesigner(new DialogDesigner(this)), +#endif + m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false) { m_tabWidget = new QTabWidget(this); m_tabWidget->setTabPosition(QTabWidget::South); @@ -74,9 +78,14 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow m_scriptEditor->setPlainText(report->scriptContext()->initScript()); m_zoomer = new GraphicsViewZoomer(activeView()); + #ifdef Q_OS_WIN m_defaultFont = QFont("Arial",10); #endif + +#ifdef HAVE_QTDESIGNER_INTEGRATION + connect(m_dialogDesigner, SIGNAL(dialogChanged()), this, SLOT(slotDialogChanged())); +#endif } DialogDesigner *ReportDesignWidget::dialogDesigner() const @@ -112,6 +121,20 @@ ReportDesignWidget::EditorTabType ReportDesignWidget::activeTabType() return Page; } +void ReportDesignWidget::initDialogDesignerToolBar(QToolBar *toolBar) +{ + m_dialogDesigner->initToolBar(toolBar); +} + +void ReportDesignWidget::updateDialogs() +{ + for ( int i = 0; icount(); ++i ){ + if (m_tabWidget->tabWhatsThis(i).compare("dialog") == 0){ + m_report->scriptContext()->changeDialog(m_tabWidget->tabText(i), m_dialogDesigner->getDialogDescription(m_tabWidget->widget(i))); + } + } +} + bool ReportDesignWidget::useMagnet() const { return m_useMagnet; @@ -299,7 +322,12 @@ void ReportDesignWidget::slotItemSelected(BaseDesignIntf *item){ } void ReportDesignWidget::saveToFile(const QString &fileName){ + m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); +#ifdef HAVE_QTDESIGNER_INTEGRATION + updateDialogs(); +#endif + if (m_report->saveToFile(fileName)) { m_report->emitSaveFinished(); } @@ -308,6 +336,10 @@ void ReportDesignWidget::saveToFile(const QString &fileName){ bool ReportDesignWidget::save() { m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); +#ifdef HAVE_QTDESIGNER_INTEGRATION + updateDialogs(); +#endif + if (!m_report->reportFileName().isEmpty()){ if (m_report->saveToFile()){ m_report->emitSaveFinished(); @@ -499,12 +531,18 @@ void ReportDesignWidget::setBorders(const BaseDesignIntf::BorderLines& borders) void ReportDesignWidget::previewReport() { report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); +#ifdef HAVE_QTDESIGNER_INTEGRATION + updateDialogs(); +#endif report()->previewReport(); } void ReportDesignWidget::printReport() { report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); +#ifdef HAVE_QTDESIGNER_INTEGRATION + updateDialogs(); +#endif setCursor(Qt::WaitCursor); report()->printReport(); setCursor(Qt::ArrowCursor); @@ -653,6 +691,14 @@ void ReportDesignWidget::slotCurrentTabChanged(int index) emit activePageChanged(); } +#ifdef HAVE_QTDESIGNER_INTEGRATION + +void ReportDesignWidget::slotDialogChanged() +{ +} + +#endif + bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event) { if (event->type() == QEvent::Wheel){ diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index d624617..ee6a157 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -54,7 +54,6 @@ class ReportDesignWidget : public QWidget { Q_OBJECT Q_PROPERTY(QObject* datasourcesManager READ dataManager()) - friend class ReportDesignWindow; public: enum ToolWindowType{ WidgetBox = 1, @@ -69,6 +68,7 @@ public: Dialog, Script }; + ReportDesignWidget(ReportEnginePrivate* report,QMainWindow *mainWindow,QWidget *parent = 0); ~ReportDesignWidget(); void createStartPage(); void clear(); @@ -103,6 +103,10 @@ public: DialogDesigner *dialogDesigner() const; QWidget* toolWindow(ToolWindowType windowType); EditorTabType activeTabType(); +#ifdef HAVE_QTDESIGNER_INTEGRATION + void initDialogDesignerToolBar(QToolBar* toolBar); + void updateDialogs(); +#endif public slots: void saveToFile(const QString&); bool save(); @@ -135,13 +139,16 @@ public slots: void printReport(); void addPage(); void deleteCurrentPage(); + void slotPagesLoadFinished(); private slots: void slotItemSelected(LimeReport::BaseDesignIntf *item); void slotSelectionChanged(); - void slotPagesLoadFinished(); void slotDatasourceCollectionLoaded(const QString&); void slotSceneRectChanged(QRectF); void slotCurrentTabChanged(int index); +#ifdef HAVE_QTDESIGNER_INTEGRATION + void slotDialogChanged(); +#endif signals: void insertModeStarted(); void itemInserted(LimeReport::PageDesignIntf*,QPointF,const QString&); @@ -164,7 +171,6 @@ protected: void createTabs(); private: bool eventFilter(QObject *target, QEvent *event); - ReportDesignWidget(ReportEnginePrivate* report,QMainWindow *mainWindow,QWidget *parent = 0); private: ReportEnginePrivate* m_report; QGraphicsView *m_view; diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 8bdb62d..febddfd 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -80,6 +80,7 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivate *report, QWidget *par createDialogActionEditor(); createDialogResourceEditor(); createDialogSignalSlotEditor(); + createDialogDesignerToolBar(); #endif m_instance=this; m_statusBar=new QStatusBar(this); @@ -87,11 +88,12 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivate *report, QWidget *par m_statusBar->insertWidget(0,m_lblReportName); setStatusBar(m_statusBar); setWindowTitle("Lime Report Designer"); + showDefaultEditors(); + showDefaultToolBars(); restoreSetting(); m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea)); m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea)); m_editorTabType = ReportDesignWidget::Page; - showDefaultEditors(); } ReportDesignWindow::~ReportDesignWindow() @@ -323,6 +325,9 @@ void ReportDesignWindow::createToolBars() addToolBar(m_itemsBordersEditorBar); createReportToolBar(); + + m_pageTools << m_mainToolBar << m_reportToolBar << m_fontEditorBar << m_textAlignmentEditorBar << m_itemsBordersEditorBar; + } void ReportDesignWindow::createItemsActions() @@ -573,6 +578,14 @@ void ReportDesignWindow::createDialogSignalSlotEditor() m_dialogEditors.append(doc); } +void ReportDesignWindow::createDialogDesignerToolBar() +{ + m_dialogDesignerToolBar = addToolBar(tr("Dialog Designer Tools")); + m_dialogDesignerToolBar->setObjectName("DialogDesignerTools"); + m_reportDesignWidget->initDialogDesignerToolBar(m_dialogDesignerToolBar); + m_dialogTools << m_dialogDesignerToolBar; +} + #endif void ReportDesignWindow::createDataWindow() { @@ -622,6 +635,7 @@ void ReportDesignWindow::startNewReport() m_newReportFooter->setEnabled(true); m_editorTabType = ReportDesignWidget::Page; showDefaultEditors(); + showDefaultToolBars(); } void ReportDesignWindow::writePosition() @@ -1048,6 +1062,7 @@ void ReportDesignWindow::slotLoadReport() setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer"); addRecentFile(fileName); m_editorTabType = ReportDesignWidget::Page; + showDefaultToolBars(); showDefaultEditors(); } } @@ -1215,6 +1230,14 @@ void ReportDesignWindow::updateAvaibleBands(){ } } +void ReportDesignWindow::showDefaultToolBars(){ + foreach (QToolBar* tb, m_pageTools){ + tb->setVisible(m_editorTabType != ReportDesignWidget::Dialog); + } + foreach (QToolBar* tb, m_dialogTools){ + tb->setVisible(m_editorTabType == ReportDesignWidget::Dialog); + } +} void ReportDesignWindow::showDefaultEditors(){ foreach (QDockWidget* w, m_pageEditors) { @@ -1248,12 +1271,14 @@ void ReportDesignWindow::slotActivePageChanged() restoreState(m_dialogEditorsState); else showDefaultEditors(); + showDefaultToolBars(); break; default: if (!m_pageEditors.isEmpty()) restoreState(m_pageEditorsState); else showDefaultEditors(); + showDefaultToolBars(); break; } diff --git a/limereport/lrreportdesignwindow.h b/limereport/lrreportdesignwindow.h index ec37638..0abe16c 100644 --- a/limereport/lrreportdesignwindow.h +++ b/limereport/lrreportdesignwindow.h @@ -144,6 +144,7 @@ private: void createDialogActionEditor(); void createDialogResourceEditor(); void createDialogSignalSlotEditor(); + void createDialogDesignerToolBar(); #endif void updateRedoUndo(); void updateAvaibleBands(); @@ -154,6 +155,7 @@ private: void removeNotExistedRecentFiles(); void removeNotExistedRecentFilesFromMenu(const QString& fileName); void addRecentFile(const QString& fileName); + void showDefaultToolBars(); void showDefaultEditors(); private: static ReportDesignWindow* m_instance; @@ -162,6 +164,9 @@ private: QToolBar* m_fontToolBar; QToolBar* m_reportToolBar; QToolBar* m_alignToolBar; +#ifdef HAVE_QTDESIGNER_INTEGRATION + QToolBar* m_dialogDesignerToolBar; +#endif QToolButton* m_newBandButton; QMenuBar* m_mainMenu; QMenu* m_fileMenu; @@ -249,6 +254,8 @@ private: ReportDesignWidget::EditorTabType m_editorTabType; QByteArray m_pageEditorsState; QByteArray m_dialogEditorsState; + QVector m_pageTools; + QVector m_dialogTools; }; diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 613b4dc..b57ea88 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -1067,6 +1067,17 @@ void ScriptEngineContext::addDialog(const QString& name, const QByteArray& descr m_dialogs.push_back(DialogDescriber::create(name,description)); } +bool ScriptEngineContext::changeDialog(const QString& name, const QByteArray& description) +{ + foreach( DialogDescriber::Ptr describer, m_dialogs){ + if (describer->name().compare(name) == 0){ + describer->setDescription(description); + return true; + } + } + return false; +} + bool ScriptEngineContext::previewDialog(const QString& dialogName) { QDialog* dialog = getDialog(dialogName); diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 36ecda2..af97b63 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -144,7 +144,8 @@ public: #endif explicit ScriptEngineContext(QObject* parent=0):QObject(parent){} #ifdef HAVE_UI_LOADER - void addDialog(const QString& name, const QByteArray &description); + void addDialog(const QString& name, const QByteArray& description); + bool changeDialog(const QString& name, const QByteArray &description); bool previewDialog(const QString& dialogName); bool containsDialog(const QString& dialogName); const QVector& dialogDescribers(){return m_dialogs;}