diff --git a/src/frontends/qt2/.cvsignore b/src/frontends/qt2/.cvsignore index 334f280e30..6904cd62bd 100644 --- a/src/frontends/qt2/.cvsignore +++ b/src/frontends/qt2/.cvsignore @@ -10,3 +10,5 @@ FormDocumentDialogBase.h FormDocumentDialogBase.C FormCitationDialog.h FormCitationDialog.C +FormCopyrightDialog.C +FormCopyrightDialog.h diff --git a/src/frontends/qt2/FormBase.C b/src/frontends/qt2/FormBase.C index d6b11a4944..cb2d5cf3ae 100644 --- a/src/frontends/qt2/FormBase.C +++ b/src/frontends/qt2/FormBase.C @@ -25,6 +25,8 @@ #include "qt2BC.h" #include "support/LAssert.h" +#include + FormBase::FormBase(ControlBase & c, string const & t) : ViewBC(c), title_(t) @@ -34,17 +36,27 @@ FormBase::FormBase(ControlBase & c, string const & t) void FormBase::show() { - if (!form()) { + fprintf( stderr, "FormBase::show() 1\n" ); + if (!form()) { + fprintf( stderr, "FormBase::show() 2\n" ); build(); + fprintf( stderr, "FormBase::show() 3\n" ); } + fprintf( stderr, "FormBase::show() 4\n" ); update(); // make sure its up-to-date + fprintf( stderr, "FormBase::show() 5\n" ); if (form()->isVisible()) { + fprintf( stderr, "FormBase::show() 6\n" ); form()->raise(); + fprintf( stderr, "FormBase::show() 7\n" ); } else { + fprintf( stderr, "FormBase::show() 8\n" ); form()->setCaption( title_.c_str() ); + fprintf( stderr, "FormBase::show() 9\n" ); form()->show(); + fprintf( stderr, "FormBase::show() 10\n" ); } } @@ -56,65 +68,52 @@ void FormBase::hide() } +// PENDING(kalle) Handle this with QValidator? // void FormBase::InputCB(FL_OBJECT * ob, long data) // { // bc().input(input(ob, data)); // } -// ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long) -// { -// return ButtonPolicy::SMI_VALID; -// } +ButtonPolicy::SMInput FormBase::input(QWidget*, long) +{ + return ButtonPolicy::SMI_VALID; +} -namespace { -// FormBase * GetForm(QWidget * ob) -// { -// Assert(ob && ob->form && ob->form->u_vdata); -// FormBase * pre = static_cast(ob->form->u_vdata); -// return pre; -// } - -} // namespace anon +void FormBase::slotWMHide() +{ + CancelButton(); +} -// extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *) -// { -// // Close the dialog cleanly, even if the WM is used to do so. -// Assert(form && form->u_vdata); -// FormBase * pre = static_cast(form->u_vdata); -// pre->CancelButton(); -// return FL_CANCEL; -// } + +void FormBase::slotApply() +{ + ApplyButton(); +} -// extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long) -// { -// GetForm(ob)->ApplyButton(); -// } +void FormBase::slotOK() +{ + OKButton(); +} -// extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long) -// { -// GetForm(ob)->OKButton(); -// } +void FormBase::slotCancel() +{ + CancelButton(); +} -// extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long) -// { -// FormBase * form = GetForm(ob); -// form->CancelButton(); -// } - - -// extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long) -// { -// GetForm(ob)->RestoreButton(); -// } +void FormBase::slotRestore() +{ + RestoreButton(); +} +// PENDING(kalle) How to handle this? // extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d) // { // GetForm(ob)->InputCB(ob, d); diff --git a/src/frontends/qt2/FormBase.h b/src/frontends/qt2/FormBase.h index 0451eb5d68..c48c03e0c3 100644 --- a/src/frontends/qt2/FormBase.h +++ b/src/frontends/qt2/FormBase.h @@ -18,6 +18,9 @@ class QDialog; +#include +#include + #ifdef __GNUG__ #pragma interface #endif @@ -30,8 +33,9 @@ class qt2BC; /** This class is an Qt2 GUI base class. */ -class FormBase : public ViewBC +class FormBase : public QObject, public ViewBC { + Q_OBJECT public: /// FormBase(ControlBase &, string const &); @@ -46,12 +50,28 @@ protected: /// Create the dialog if necessary, update it and display it. void show(); +protected slots: + // dialog closed from WM + void slotWMHide(); + + // Apply button clicked + void slotApply(); + + // OK button clicked + void slotOK(); + + // Cancel button clicked + void slotCancel(); + + // Restore button clicked + void slotRestore(); + private: /// Pointer to the actual instantiation of xform's form virtual QDialog* form() const = 0; -// /** Filter the inputs on callback from xforms -// Return true if inputs are valid. */ -// virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + /** Filter the inputs on callback from xforms + Return true if inputs are valid. */ + virtual ButtonPolicy::SMInput input(QWidget*, long); private: /// dialog title, displayed by WM. diff --git a/src/frontends/qt2/FormCopyright.C b/src/frontends/qt2/FormCopyright.C index 73d53eebed..a76a7deb0d 100644 --- a/src/frontends/qt2/FormCopyright.C +++ b/src/frontends/qt2/FormCopyright.C @@ -38,13 +38,15 @@ void FormCopyright::build() { // PENDING(kalle) Parent??? dialog_.reset( new FormCopyrightDialogImpl() ); - + connect( dialog_.get()->closePB, SIGNAL( clicked() ), + this, SLOT( slotCancel() ) ); + dialog_->copyrightLA->setText( controller().getCopyright().c_str() ); dialog_->licenseLA->setText( controller().getLicence().c_str() ); dialog_->disclaimerLA->setText( controller().getDisclaimer().c_str() ); // Manage the cancel/close button - bc().setCancel(dialog_->okPB); + bc().setCancel(dialog_->closePB); bc().refresh(); } diff --git a/src/frontends/qt2/FormCopyrightDialog.ui b/src/frontends/qt2/FormCopyrightDialog.ui index ce27f42e09..a66e57e6ff 100644 --- a/src/frontends/qt2/FormCopyrightDialog.ui +++ b/src/frontends/qt2/FormCopyrightDialog.ui @@ -17,7 +17,7 @@ caption - Form1 + Copyright and Warranty @@ -159,7 +159,7 @@ if not, write to the Free Software Foundation, Inc., QPushButton name - okPB + closePB sizePolicy @@ -170,7 +170,7 @@ if not, write to the Free Software Foundation, Inc., text - &OK + &Close default @@ -181,7 +181,7 @@ if not, write to the Free Software Foundation, Inc., - okPB + closePB clicked() FormCopyrightDialog reject() diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index 0385d54b55..399ccd86e8 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -12,6 +12,7 @@ CXXFLAGS += -DQT_CLEAN_NAMESPACE -fno-rtti -fno-exceptions # moc generated files BUILTSOURCES = \ moc_FileDialog_private.C \ + moc_FormBase.C \ moc_FormCitationDialog.C \ moc_FormCitationDialogImpl.C \ moc_FormCopyrightDialog.C \ @@ -160,6 +161,9 @@ dist-hook: done ; \ done +moc_FormBase.C: FormBase.h + $(MOC) -o $@ $< + FormCitation.C: FormCitationDialog.h FormCitationDialog.h: FormCitationDialog.ui $(UIC) -o $@ $<