4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
17 #include "qt_helpers.h"
18 #include "support/debug.h"
20 #include <QCloseEvent>
24 #include <QGridLayout>
31 /// Window Dialog container for LyX dialogs.
32 /// This template class that encapsulates a given Widget inside a
33 /// QDialog and presents a Dialog interface
34 template<class MyWidget>
35 class DialogView : public QDialog, public Dialog
39 GuiView & parent, ///< the main window where to dock.
40 std::string const & name, ///< dialog identifier.
41 bool modal = false, ///< Window modality.
42 Qt::WindowFlags flags = 0
44 : QDialog(&parent, flags), Dialog(parent, name)
47 QGridLayout * gridLayout = new QGridLayout(this);
48 gridLayout->setMargin(0);
49 widget_ = new MyWidget(*this, this);
50 gridLayout->addWidget(widget_);
51 setWindowTitle("LyX: " + widget_->windowTitle());
54 /// Dialog inherited methods
62 void showData(std::string const & data)
64 initialiseParams(data);
69 widget_->updateView(); // make sure its up-to-date
74 bool isVisibleView() const { return QDialog::isVisible(); }
75 void checkStatus() { updateView(); }
76 void updateData(std::string const & data)
78 initialiseParams(data);
83 widget_->updateView();
87 /// The encapsulated widget.
90 void showEvent(QShowEvent * e)
93 std::string key = name() + "/geometry";
94 QDialog::restoreGeometry(settings.value(key.c_str()).toByteArray());
95 QDialog::showEvent(e);
98 void closeEvent(QCloseEvent * e)
101 std::string key = name() + "/geometry";
102 settings.setValue(key.c_str(), QDialog::saveGeometry());
103 QDialog::closeEvent(e);
110 #endif // DIALOG_VIEW_H