From ab7778e2955b3c5192ee2de2bdd714888b7b1056 Mon Sep 17 00:00:00 2001 From: Kalle Dalheimer Date: Fri, 23 Mar 2001 22:07:56 +0000 Subject: [PATCH] First attempt at converting copyright dialog to MVC architecture Changed copyright dialog to new naming scheme git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1821 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/Dialogs.C | 18 ++- src/frontends/qt2/FormBase.C | 121 ++++++++++++++++++ src/frontends/qt2/FormBase.h | 113 ++++++++++++++++ src/frontends/qt2/FormCopyright.C | 53 ++++---- src/frontends/qt2/FormCopyright.h | 42 +++--- src/frontends/qt2/FormCopyrightDialog.C | 22 ---- src/frontends/qt2/FormCopyrightDialog.h | 15 --- ...htDialogBase.ui => FormCopyrightDialog.ui} | 100 +++++++-------- src/frontends/qt2/FormCopyrightDialogBase.C | 80 ------------ src/frontends/qt2/FormCopyrightDialogBase.h | 37 ------ src/frontends/qt2/FormCopyrightDialogImpl.C | 22 ++++ src/frontends/qt2/FormCopyrightDialogImpl.h | 15 +++ src/frontends/qt2/Makefile.am | 24 +++- src/frontends/qt2/qt2BC.C | 65 ++++++++++ src/frontends/qt2/qt2BC.h | 87 +++++++++++++ 15 files changed, 553 insertions(+), 261 deletions(-) create mode 100644 src/frontends/qt2/FormBase.C create mode 100644 src/frontends/qt2/FormBase.h delete mode 100644 src/frontends/qt2/FormCopyrightDialog.C delete mode 100644 src/frontends/qt2/FormCopyrightDialog.h rename src/frontends/qt2/{FormCopyrightDialogBase.ui => FormCopyrightDialog.ui} (92%) delete mode 100644 src/frontends/qt2/FormCopyrightDialogBase.C delete mode 100644 src/frontends/qt2/FormCopyrightDialogBase.h create mode 100644 src/frontends/qt2/FormCopyrightDialogImpl.C create mode 100644 src/frontends/qt2/FormCopyrightDialogImpl.h create mode 100644 src/frontends/qt2/qt2BC.C create mode 100644 src/frontends/qt2/qt2BC.h diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 65726edf58..72e71ea02d 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -17,10 +17,13 @@ #include "Dialogs.h" +#include "FormCopyrightDialogImpl.h" +#undef emit + #include "FormCharacter.h" #include "FormCitation.h" #include "FormCredits.h" -//#include "FormCopyright.h" +#include "FormCopyright.h" //#include "FormDocument.h" #include "FormError.h" #include "FormGraphics.h" @@ -36,6 +39,11 @@ //#include "FormToc.h" //#include "FormUrl.h" +#include "BufferView.h" + +#include "controllers/ControlCopyright.h" + +#include "qt2BC.h" // Signal enabling all visible popups to be redrawn if so desired. // E.g., when the GUI colours have been remapped. @@ -45,6 +53,14 @@ SigC::Signal0 Dialogs::redrawGUI; Dialogs::Dialogs(LyXView * lv) { splash_.reset( new FormSplash(lv, this) ); + + // dialogs that have been converted to new scheme + add( new GUICopyright( *lv, *this ) ); + + + // ------------------------------------------ + + // dialogs that are still old-style add( new FormCharacter(lv, this)); add( new FormCitation(lv, this)); // add(new FormCopyright(lv, this)); diff --git a/src/frontends/qt2/FormBase.C b/src/frontends/qt2/FormBase.C new file mode 100644 index 0000000000..d6b11a4944 --- /dev/null +++ b/src/frontends/qt2/FormBase.C @@ -0,0 +1,121 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + * + * \author Angus Leeming + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include +#undef emit + +#include "Dialogs.h" +#include "FormBase.h" +#include "qt2BC.h" +#include "support/LAssert.h" + + +FormBase::FormBase(ControlBase & c, string const & t) + : ViewBC(c), title_(t) +{} + + + +void FormBase::show() +{ + if (!form()) { + build(); + } + + update(); // make sure its up-to-date + + if (form()->isVisible()) { + form()->raise(); + } else { + form()->setCaption( title_.c_str() ); + form()->show(); + } +} + + +void FormBase::hide() +{ + if (form() && form()->isVisible() ) + form()->hide(); +} + + +// void FormBase::InputCB(FL_OBJECT * ob, long data) +// { +// bc().input(input(ob, data)); +// } + + +// ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, 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 + + +// 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; +// } + + +// extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long) +// { +// GetForm(ob)->ApplyButton(); +// } + + +// extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long) +// { +// GetForm(ob)->OKButton(); +// } + + +// 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(); +// } + + +// 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 new file mode 100644 index 0000000000..0451eb5d68 --- /dev/null +++ b/src/frontends/qt2/FormBase.h @@ -0,0 +1,113 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + * + * \author Angus Leeming + */ + +#ifndef FORMBASE_H +#define FORMBASE_H + +#include + +class QDialog; + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "ViewBase.h" +#include "LString.h" +#include "ButtonPolicies.h" + +class qt2BC; + +/** This class is an Qt2 GUI base class. + */ +class FormBase : public ViewBC +{ +public: + /// + FormBase(ControlBase &, string const &); + /// + virtual ~FormBase() {} + +protected: + /// Build the dialog + virtual void build() = 0; + /// Hide the dialog. + void hide(); + /// Create the dialog if necessary, update it and display it. + void show(); + +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); + +private: + /// dialog title, displayed by WM. + string title_; +}; + + +template +class FormDB: public FormBase +{ +protected: + /// + FormDB(ControlBase &, string const &); + /// Pointer to the actual instantiation of the Qt dialog + virtual QDialog* form() const; + /// Real GUI implementation. + boost::scoped_ptr dialog_; +}; + + +template +FormDB::FormDB(ControlBase & c, string const & t) + : FormBase(c, t) +{} + + +template +QDialog* FormDB::form() const +{ + return dialog_.get(); +} + + +template +class FormCB: public Base +{ +protected: + /// + FormCB(ControlBase &, string const &); + /// The parent controller + Controller & controller() const; +}; + + +template +FormCB::FormCB(ControlBase & c, string const & t) + : Base(c, t) +{} + + +template +Controller & FormCB::controller() const +{ + return static_cast(controller_); + //return dynamic_cast(controller_); +} + + +#endif // FORMBASE_H diff --git a/src/frontends/qt2/FormCopyright.C b/src/frontends/qt2/FormCopyright.C index 99fdefc2e6..73d53eebed 100644 --- a/src/frontends/qt2/FormCopyright.C +++ b/src/frontends/qt2/FormCopyright.C @@ -2,8 +2,8 @@ formcopyright.cpp - description ------------------- begin : Thu Feb 3 2000 - copyright : (C) 2000 by Jürgen Vigna - email : jug@sad.it + copyright : (C) 2000 by Jürgen Vigna, 2001 by Kalle Dalheimer + email : kalle@klaralvdalens-datakonsult.se ***************************************************************************/ /*************************************************************************** @@ -17,37 +17,36 @@ #include -#include "Dialogs.h" + +#include "FormCopyrightDialogImpl.h" +#include +#include +#undef emit +#include "qt2BC.h" +#include "ControlCopyright.h" #include "FormCopyright.h" -#include "FormCopyrightDialog.h" -#include "gettext.h" -FormCopyright::FormCopyright(LyXView *v, Dialogs *d) - : dialog_(0), lv_(v), d_(d), h_(0) +typedef FormCB > base_class; + +FormCopyright::FormCopyright( ControlCopyright& c ) : + base_class( c, _( "Copyright and Warranty" ) ) { - // let the dialog be shown - // This is a permanent connection so we won't bother - // storing a copy because we won't be disconnecting. - d->showCopyright.connect(slot(this, &FormCopyright::show)); } -FormCopyright::~FormCopyright() + +void FormCopyright::build() { - delete dialog_; + // PENDING(kalle) Parent??? + dialog_.reset( new FormCopyrightDialogImpl() ); + + 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().refresh(); } -void FormCopyright::show() -{ - if (!dialog_) - dialog_ = new FormCopyrightDialog(0, _("Copyright and Warranty"), - false); - if (!dialog_->isVisible()) - h_ = d_->hideAll.connect(slot(this, &FormCopyright::hide)); - dialog_->show(); -} -void FormCopyright::hide() -{ - dialog_->hide(); - h_.disconnect(); -} + diff --git a/src/frontends/qt2/FormCopyright.h b/src/frontends/qt2/FormCopyright.h index 852d051f21..1c8348d7aa 100644 --- a/src/frontends/qt2/FormCopyright.h +++ b/src/frontends/qt2/FormCopyright.h @@ -2,8 +2,8 @@ formcopyright.h - description ------------------- begin : Thu Feb 3 2000 - copyright : (C) 2000 by Jürgen Vigna - email : jug@sad.it + copyright : (C) 2000 by Jürgen Vigna, 2001 by Kalle Dalheimer + email : kalle@klaralvdalens-datakonsult.se ***************************************************************************/ /*************************************************************************** @@ -18,40 +18,30 @@ #ifndef FORMCOPYRIGHT_H #define FORMCOPYRIGHT_H -#include "DialogBase.h" +#include "FormBase.h" #include "boost/utility.hpp" class Dialogs; class LyXView; -class FormCopyrightDialog; +class FormCopyrightDialogImpl; +class ControlCopyright; /** - @author Jürgen Vigna + @author Kalle Dalheimer */ -class FormCopyright : public DialogBase { +class FormCopyright + : public FormCB > +{ public: - FormCopyright(LyXView *, Dialogs *); - ~FormCopyright(); + FormCopyright( ControlCopyright& ); private: - /// Create the dialog if necessary, update it and display it. - void show(); - /// Hide the dialog. - void hide(); - - /// Real GUI implementation. - FormCopyrightDialog * dialog_; - /** Which LyXFunc do we use? - We could modify Dialogs to have a visible LyXFunc* instead and - save a couple of bytes per dialog. - */ - LyXView * lv_; - /** Which Dialogs do we belong to? - Used so we can get at the signals we have to connect to. - */ - Dialogs * d_; - /// Hide connection. - Connection h_; + /// not needed + virtual void apply() {} + /// not needed + virtual void update() {} + // build the dialog + virtual void build(); }; #endif diff --git a/src/frontends/qt2/FormCopyrightDialog.C b/src/frontends/qt2/FormCopyrightDialog.C deleted file mode 100644 index ff3164e8a6..0000000000 --- a/src/frontends/qt2/FormCopyrightDialog.C +++ /dev/null @@ -1,22 +0,0 @@ -#include "FormCopyrightDialog.h" - -/* - * Constructs a FormCopyrightDialog which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - * - * The dialog will by default be modeless, unless you set 'modal' to - * TRUE to construct a modal dialog. - */ -FormCopyrightDialog::FormCopyrightDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) - : FormCopyrightDialogBase( parent, name, modal, fl ) -{ -} - -/* - * Destroys the object and frees any allocated resources - */ -FormCopyrightDialog::~FormCopyrightDialog() -{ - // no need to delete child widgets, Qt does it all for us -} - diff --git a/src/frontends/qt2/FormCopyrightDialog.h b/src/frontends/qt2/FormCopyrightDialog.h deleted file mode 100644 index d91a84e386..0000000000 --- a/src/frontends/qt2/FormCopyrightDialog.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef FORMCOPYRIGHTDIALOG_H -#define FORMCOPYRIGHTDIALOG_H -#include "FormCopyrightDialogBase.h" - -class FormCopyrightDialog : public FormCopyrightDialogBase -{ - Q_OBJECT - -public: - FormCopyrightDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); - ~FormCopyrightDialog(); - -}; - -#endif // FORMCOPYRIGHTDIALOG_H diff --git a/src/frontends/qt2/FormCopyrightDialogBase.ui b/src/frontends/qt2/FormCopyrightDialog.ui similarity index 92% rename from src/frontends/qt2/FormCopyrightDialogBase.ui rename to src/frontends/qt2/FormCopyrightDialog.ui index 41d2555dc1..ce27f42e09 100644 --- a/src/frontends/qt2/FormCopyrightDialogBase.ui +++ b/src/frontends/qt2/FormCopyrightDialog.ui @@ -1,17 +1,17 @@ -FormCopyrightDialogBase +FormCopyrightDialog QDialog name - FormCopyrightDialogBase + FormCopyrightDialog geometry 0 0 - 472 + 468 454 @@ -32,12 +32,7 @@ QLabel name - TextLabel5 - - - text - KLyX is Copyright (C) 1995 by Matthias Ettrich, -1995-2001 by LyX Team + copyrightLA frameShape @@ -51,6 +46,11 @@ margin 6 + + text + KLyX is Copyright (C) 1995 by Matthias Ettrich, +1995-2001 by LyX Team + alignment AlignCenter @@ -63,11 +63,14 @@ QLabel name - TextLabel5_2 + licenseLA - text - This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + sizePolicy + + 1 + 1 + frameShape @@ -82,15 +85,12 @@ 6 - alignment - WordBreak|AlignCenter + text + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - sizePolicy - - 1 - 1 - + alignment + WordBreak|AlignCenter hAlign @@ -103,20 +103,21 @@ QLabel name - TextLabel5_2_2 + disclaimerLA - text - KLyX is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY, -without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General -Public License for more details. -You should have received a copy of the GNU -General Public License along with this program; -if not, write to thee Free Software Foundation, Inc., -675 Mass Ave, Cambridge, MA 02139, USA. + sizePolicy + + 5 + 5 + + + + minimumSize + + 0 + 0 + frameShape @@ -130,24 +131,23 @@ if not, write to thee Free Software Foundation, Inc., margin 6 + + text + KLyX is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY, +without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General +Public License for more details. +You should have received a copy of the GNU +General Public License along with this program; +if not, write to the Free Software Foundation, Inc., +675 Mass Ave, Cambridge, MA 02139, USA. + alignment WordBreak|AlignCenter - - sizePolicy - - 1 - 1 - - - - minimumSize - - 0 - 0 - - hAlign @@ -161,10 +161,6 @@ if not, write to thee Free Software Foundation, Inc., name okPB - - text - &OK - sizePolicy @@ -172,6 +168,10 @@ if not, write to thee Free Software Foundation, Inc., 0 + + text + &OK + default true @@ -183,7 +183,7 @@ if not, write to thee Free Software Foundation, Inc., okPB clicked() - FormCopyrightDialogBase + FormCopyrightDialog reject() diff --git a/src/frontends/qt2/FormCopyrightDialogBase.C b/src/frontends/qt2/FormCopyrightDialogBase.C deleted file mode 100644 index 37bee172db..0000000000 --- a/src/frontends/qt2/FormCopyrightDialogBase.C +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** Form implementation generated from reading ui file 'FormCopyrightDialogBase.ui' -** -** Created: Wed Feb 7 18:46:40 2001 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#include "FormCopyrightDialogBase.h" - -#include -#include -#include -#include -#include -#include - -/* - * Constructs a FormCopyrightDialogBase which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - * - * The dialog will by default be modeless, unless you set 'modal' to - * TRUE to construct a modal dialog. - */ -FormCopyrightDialogBase::FormCopyrightDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, name, modal, fl ) -{ - if ( !name ) - setName( "FormCopyrightDialogBase" ); - resize( 472, 454 ); - setCaption( tr( "Form1" ) ); - FormCopyrightDialogBaseLayout = new QVBoxLayout( this ); - FormCopyrightDialogBaseLayout->setSpacing( 6 ); - FormCopyrightDialogBaseLayout->setMargin( 11 ); - - TextLabel5 = new QLabel( this, "TextLabel5" ); - TextLabel5->setText( tr( "LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2001 LyX Team" ) ); - TextLabel5->setFrameShape( QLabel::Box ); - TextLabel5->setFrameShadow( QLabel::Sunken ); - TextLabel5->setMargin( 6 ); - TextLabel5->setAlignment( int( QLabel::AlignCenter ) ); - FormCopyrightDialogBaseLayout->addWidget( TextLabel5 ); - - TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); - TextLabel5_2->setText( tr( "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version." ) ); - TextLabel5_2->setFrameShape( QLabel::Box ); - TextLabel5_2->setFrameShadow( QLabel::Sunken ); - TextLabel5_2->setMargin( 6 ); - TextLabel5_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); - TextLabel5_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, TextLabel5_2->sizePolicy().hasHeightForWidth() ) ); - FormCopyrightDialogBaseLayout->addWidget( TextLabel5_2 ); - - TextLabel5_2_2 = new QLabel( this, "TextLabel5_2_2" ); - TextLabel5_2_2->setText( tr( "LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA." ) ); - TextLabel5_2_2->setFrameShape( QLabel::Box ); - TextLabel5_2_2->setFrameShadow( QLabel::Sunken ); - TextLabel5_2_2->setMargin( 6 ); - TextLabel5_2_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); - TextLabel5_2_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, TextLabel5_2_2->sizePolicy().hasHeightForWidth() ) ); - TextLabel5_2_2->setMinimumSize( QSize( 0, 0 ) ); - FormCopyrightDialogBaseLayout->addWidget( TextLabel5_2_2 ); - - okPB = new QPushButton( this, "okPB" ); - okPB->setText( tr( "&OK" ) ); - okPB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, okPB->sizePolicy().hasHeightForWidth() ) ); - okPB->setDefault( TRUE ); - FormCopyrightDialogBaseLayout->addWidget( okPB ); - - // signals and slots connections - connect( okPB, SIGNAL( clicked() ), this, SLOT( reject() ) ); -} - -/* - * Destroys the object and frees any allocated resources - */ -FormCopyrightDialogBase::~FormCopyrightDialogBase() -{ - // no need to delete child widgets, Qt does it all for us -} - diff --git a/src/frontends/qt2/FormCopyrightDialogBase.h b/src/frontends/qt2/FormCopyrightDialogBase.h deleted file mode 100644 index 62f4627f7f..0000000000 --- a/src/frontends/qt2/FormCopyrightDialogBase.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** Form interface generated from reading ui file 'FormCopyrightDialogBase.ui' -** -** Created: Wed Jan 24 12:18:18 2001 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#ifndef FORMCOPYRIGHTDIALOGBASE_H -#define FORMCOPYRIGHTDIALOGBASE_H - -#include -#include -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QLabel; -class QPushButton; - -class FormCopyrightDialogBase : public QDialog -{ - Q_OBJECT - -public: - FormCopyrightDialogBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); - ~FormCopyrightDialogBase(); - - QLabel* TextLabel5; - QLabel* TextLabel5_2; - QLabel* TextLabel5_2_2; - QPushButton* okPB; - -protected: - QVBoxLayout* FormCopyrightDialogBaseLayout; -}; - -#endif // FORMCOPYRIGHTDIALOGBASE_H diff --git a/src/frontends/qt2/FormCopyrightDialogImpl.C b/src/frontends/qt2/FormCopyrightDialogImpl.C new file mode 100644 index 0000000000..f09e45e1e4 --- /dev/null +++ b/src/frontends/qt2/FormCopyrightDialogImpl.C @@ -0,0 +1,22 @@ +#include "FormCopyrightDialogImpl.h" + +/* + * Constructs a FormCopyrightDialogImpl which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +FormCopyrightDialogImpl::FormCopyrightDialogImpl( QWidget* parent, const char* name, bool modal, WFlags fl ) + : FormCopyrightDialog( parent, name, modal, fl ) +{ +} + +/* + * Destroys the object and frees any allocated resources + */ +FormCopyrightDialogImpl::~FormCopyrightDialogImpl() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/frontends/qt2/FormCopyrightDialogImpl.h b/src/frontends/qt2/FormCopyrightDialogImpl.h new file mode 100644 index 0000000000..05f40d5575 --- /dev/null +++ b/src/frontends/qt2/FormCopyrightDialogImpl.h @@ -0,0 +1,15 @@ +#ifndef FORMCOPYRIGHTDIALOGIMPL_H +#define FORMCOPYRIGHTDIALOGIMPL_H +#include "FormCopyrightDialog.h" + +class FormCopyrightDialogImpl : public FormCopyrightDialog +{ + Q_OBJECT + +public: + FormCopyrightDialogImpl( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~FormCopyrightDialogImpl(); + +}; + +#endif // FORMCOPYRIGHTDIALOGIMPL_H diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index f729294e5a..e4f3f1ca54 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -33,12 +33,10 @@ libqt2_la_OBJADD = \ ../controllers/ButtonController.lo \ ../xforms/combox.lo \ ../xforms/Color.lo \ - ../xforms/FormBase.lo \ ../xforms/FormBaseDeprecated.lo \ ../xforms/FormBibitem.lo \ ../xforms/FormBibtex.lo \ ../xforms/FormBrowser.lo \ - ../xforms/FormCopyright.lo \ ../xforms/FormDocument.lo \ ../xforms/FormError.lo \ ../xforms/FormExternal.lo \ @@ -99,12 +97,20 @@ libqt2_la_SOURCES = \ chardlgimpl.h \ FileDialog.C \ FileDialog_private.C \ + FormBase.C \ + FormBase.h \ FormCitation.C \ FormCitation.h \ FormCitationDialog.C \ FormCitationDialog.h \ FormCitationDialogImpl.C \ FormCitationDialogImpl.h \ + FormCopyright.C \ + FormCopyright.h \ + FormCopyrightDialog.C \ + FormCopyrightDialog.h \ + FormCopyrightDialogImpl.C \ + FormCopyrightDialogImpl.h \ FormParagraph.C \ FormParagraph.h \ paragraphdlg.C \ @@ -134,7 +140,9 @@ libqt2_la_SOURCES = \ tabularcreatedlg.C \ tabularcreatedlg.h \ tabularcreatedlgimpl.C \ - tabularcreatedlgimpl.h + tabularcreatedlgimpl.h \ + qt2BC.C \ + qt2BC.h # just copied from old lyx repository dist-hook: @@ -160,6 +168,16 @@ moc_FormCitationDialog.C: FormCitationDialog.h moc_FormCitationDialogImpl.C: FormCitationDialogImpl.h $(MOC) -o $@ $< +FormCopyright.C: FormCopyrightDialogImpl.h +FormCopyrightDialog.h: FormCopyrightDialog.ui + $(UIC) -o $@ $< +FormCopyrightDialog.C: FormCopyrightDialog.ui + $(UIC) -impl FormCopyrightDialog.h -o $@ $< +moc_FormCopyrightDialog.C: FormCopyrightDialog.h + $(MOC) -o $@ $< +moc_FormCopyrightDialogImpl.C: FormCopyrightDialogImpl.h + $(MOC) -o $@ $< + FormParagraph.C: paragraphdlg.h paragraphdlg.h: paragraphdlg.ui $(UIC) -o $@ $< diff --git a/src/frontends/qt2/qt2BC.C b/src/frontends/qt2/qt2BC.C new file mode 100644 index 0000000000..270fc28ae1 --- /dev/null +++ b/src/frontends/qt2/qt2BC.C @@ -0,0 +1,65 @@ +/** + * \file xformsBC.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author Allan Rae + * \author Angus Leeming + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "qt2BC.h" + +#include + +qt2BC::qt2BC(string const & cancel, string const & close) + : ButtonControllerBase(cancel, close), + okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_() +{} + + +void qt2BC::refresh() +{ + if (okay_) { + if (bp().buttonStatus(ButtonPolicy::OKAY)) { + okay_->setEnabled( true ); + } else { + okay_->setEnabled( false ); + } + } + if (apply_) { + if (bp().buttonStatus(ButtonPolicy::APPLY)) { + apply_->setEnabled( true ); + } else { + apply_->setEnabled( false ); + } + } + if (undo_all_) { + if (bp().buttonStatus(ButtonPolicy::UNDO_ALL)) { + undo_all_->setEnabled( true ); + } else { + undo_all_->setEnabled( false ); + } + } + if (cancel_) { + if (bp().buttonStatus(ButtonPolicy::CANCEL)) { + cancel_->setText( cancel_label.c_str() ); + } else { + cancel_->setText( close_label.c_str() ); + } + } + if (!read_only_.empty()) { + bool enable = true; + if (bp().isReadOnly()) enable = false; + + for (std::list::iterator iter = read_only_.begin(); + iter != read_only_.end(); ++iter) { + (*iter)->setEnabled( enable ); + } + } +} diff --git a/src/frontends/qt2/qt2BC.h b/src/frontends/qt2/qt2BC.h new file mode 100644 index 0000000000..d70f51f6f7 --- /dev/null +++ b/src/frontends/qt2/qt2BC.h @@ -0,0 +1,87 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1995 Matthias Ettrich + * Copyright 1995-2000 The LyX Team. + * + * This file Copyright 2000 + * Allan Rae + * ====================================================== + * + * Author: Allan Rae + * Non-xforms-specific code stripped-out and placed in a base class by + * Angus Leeming + */ + +#ifndef QT2BC_H +#define QT2BC_H + +#include + +#ifdef __GNUG__ +#pragma interface +#endif + +class QButton; + +#include "ButtonController.h" + +/** General purpose button controller for up to four buttons. + Controls the activation of the OK, Apply and Cancel buttons. + Actually supports 4 buttons in all and it's up to the user to decide on + the activation policy and which buttons correspond to which output of the + state machine. +*/ +class qt2BC : public ButtonControllerBase +{ +public: + /// + qt2BC(string const &, string const &); + + /* Initialise Button Functions */ + /// Call refresh() when finished setting the buttons. + void setOK(QButton * obj) { + okay_ = obj; + } + /// + void setApply(QButton * obj) { + apply_ = obj; + } + /// + void setCancel(QButton * obj) { + cancel_ = obj; + } + /// + void setUndoAll(QButton * obj) { + undo_all_ = obj; + } + /// + void addReadOnly(QButton * obj) { + read_only_.push_front(obj); + } + /// + void eraseReadOnly() { + read_only_.erase(read_only_.begin(), read_only_.end()); + } + + /* Action Functions */ + /// force a refresh of the buttons + virtual void refresh(); + +private: + /// + QButton * okay_; + /// + QButton * apply_; + /// + QButton * cancel_; + /// + QButton * undo_all_; + /// List of items to be deactivated when in one of the read-only states + std::list read_only_; +}; + +#endif // XFORMSBC_H