From 738d5b06ba27f238dfdae4a7bd708d9be6b8fd49 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Thu, 27 Sep 2007 11:27:52 +0000 Subject: [PATCH] * qt4/DialogView.h: new template class based on QDialog. * qt4/Dialogs.cpp: use DialogView by default instead of DockView for GuiParagraph git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20534 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/DialogView.h | 97 ++++++++++++++++++++++++++++++ src/frontends/qt4/Dialogs.cpp | 13 +++- src/frontends/qt4/GuiParagraph.cpp | 4 +- src/frontends/qt4/GuiParagraph.h | 2 +- src/frontends/qt4/Makefile.am | 1 + 5 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 src/frontends/qt4/DialogView.h diff --git a/src/frontends/qt4/DialogView.h b/src/frontends/qt4/DialogView.h new file mode 100644 index 0000000000..6309f0821c --- /dev/null +++ b/src/frontends/qt4/DialogView.h @@ -0,0 +1,97 @@ +// -*- C++ -*- +/** + * \file DialogView.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Abdelrazak Younes + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef DIALOG_VIEW_H +#define DIALOG_VIEW_H + +#include "controllers/Dialog.h" +#include "GuiView.h" +#include "qt_helpers.h" +#include "debug.h" + +#include + +#include + +namespace lyx { +namespace frontend { + +/// Window Dialog container for LyX dialogs. +/// This template class that encapsulates a given Widget inside a +/// QDialog and presents a Dialog interface +template +class DialogView : public QDialog, public Dialog +{ +public: + DialogView( + GuiViewBase & parent, ///< the main window where to dock. + std::string const & name, ///< dialog identifier. + bool modal = false, ///< Window modality. + Qt::WindowFlags flags = 0 + ) + : QDialog(&parent, flags), name_(name) + { + setModal(modal); + MyController * c = new MyController(*this); + controller_ = c; + controller_->setLyXView(parent); + widget_ = new MyWidget(*c, this); + setWindowTitle("LyX: " + widget_->windowTitle()); + } + + /// Dialog inherited methods + //@{ + void applyView() {} + void hideView() + { + controller().clearParams(); + QDialog::hide(); + } + void showData(std::string const & data) + { + controller_->initialiseParams(data); + showView(); + } + void showView() + { + widget_->updateView(); // make sure its up-to-date + QDialog::show(); + raise(); + activateWindow(); + } + bool isVisibleView() const { return QDialog::isVisible(); } + void checkStatus() { updateView(); } + void redraw() { redrawView(); } + void redrawView() {} + void updateData(std::string const & data) + { + controller_->initialiseParams(data); + updateView(); + } + void updateView() + { + widget_->updateView(); + } + void partialUpdateView(int /*id*/) {} + Controller & controller() { return *controller_; } + std::string name() const { return name_; } + //@} +private: + /// The encapsulated widget. + MyWidget * widget_; + Controller * controller_; + std::string name_; +}; + +} // frontend +} // lyx + +#endif // DIALOG_VIEW_H diff --git a/src/frontends/qt4/Dialogs.cpp b/src/frontends/qt4/Dialogs.cpp index 9ec2290a91..2fdd7c6857 100644 --- a/src/frontends/qt4/Dialogs.cpp +++ b/src/frontends/qt4/Dialogs.cpp @@ -14,6 +14,7 @@ #include "GuiDialog.h" #include "ButtonController.h" +#include "DialogView.h" #include "DockView.h" #include "GuiAbout.h" #include "GuiBibitem.h" @@ -62,6 +63,9 @@ #include "GuiThesaurus.h" #endif +// Uncomment this if you prefer dock widget +//#define USE_DOCK_WIDGET + #include "qt_helpers.h" #include @@ -172,9 +176,14 @@ Dialog * Dialogs::build(string const & name) } else if (name == "note") { dialog = new GuiNoteDialog(lyxview_); } else if (name == "paragraph") { +#ifdef USE_DOCK_WIDGET DockView * dv = - new DockView(guiview, name); - dv->setFloating(true); + new DockView(guiview, name, + Qt::TopDockWidgetArea); +#else + DialogView * dv = + new DialogView(guiview, name); +#endif dialog = dv; } else if (name == "prefs") { dialog = new GuiPrefsDialog(lyxview_); diff --git a/src/frontends/qt4/GuiParagraph.cpp b/src/frontends/qt4/GuiParagraph.cpp index 877d8a3b25..091ed7b7bb 100644 --- a/src/frontends/qt4/GuiParagraph.cpp +++ b/src/frontends/qt4/GuiParagraph.cpp @@ -36,8 +36,8 @@ using std::endl; namespace lyx { namespace frontend { -GuiParagraph::GuiParagraph(ControlParagraph & controller) - : controller_(controller) +GuiParagraph::GuiParagraph(ControlParagraph & controller, QWidget * parent) + : QWidget(parent), controller_(controller) { setupUi(this); setWindowTitle(qt_("Paragraph Settings")); diff --git a/src/frontends/qt4/GuiParagraph.h b/src/frontends/qt4/GuiParagraph.h index 1bc6657814..9e4604c56b 100644 --- a/src/frontends/qt4/GuiParagraph.h +++ b/src/frontends/qt4/GuiParagraph.h @@ -28,7 +28,7 @@ class GuiParagraph : public QWidget, public Ui::ParagraphUi { Q_OBJECT public: - GuiParagraph(ControlParagraph & controller); + GuiParagraph(ControlParagraph & controller, QWidget * parent = 0); /// update void updateView(); diff --git a/src/frontends/qt4/Makefile.am b/src/frontends/qt4/Makefile.am index e073f62467..d1709a8e82 100644 --- a/src/frontends/qt4/Makefile.am +++ b/src/frontends/qt4/Makefile.am @@ -129,6 +129,7 @@ MOCHEADER = \ Action.h \ BulletsModule.h \ ColorCache.h \ + DialogView.h \ DockView.h \ EmptyTable.h \ FloatPlacement.h \ -- 2.39.2