]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/DialogView.h
Remove question marks from Windows dialogs
[lyx.git] / src / frontends / qt4 / DialogView.h
1 // -*- C++ -*-
2 /**
3  * \file DialogView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef DIALOGVIEW_H
13 #define DIALOGVIEW_H
14
15 #include "Dialog.h"
16 #include "GuiView.h"
17
18 #include <QCloseEvent>
19 #include <QDialog>
20
21 namespace lyx {
22 namespace frontend {
23
24 class DialogView : public QDialog, public Dialog
25 {
26 public:
27         /// \param lv is the access point for the dialog to the LyX kernel.
28         /// \param name is the identifier given to the dialog by its parent
29         /// container.
30         /// \param title is the window title used for decoration.
31         DialogView(GuiView & lv, QString const & name, QString const & title)
32                 : QDialog(&lv), Dialog(lv, name, "LyX: " + title)
33         {
34                 // remove question marks from Windows dialogs
35                 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
36         }
37
38         virtual QWidget * asQWidget() { return this; }
39         virtual QWidget const * asQWidget() const { return this; }
40
41 protected:
42         /// \name Dialog inherited methods
43         //@{
44         void applyView() {}
45         bool initialiseParams(std::string const & /*data*/) { return true; }
46         void clearParams() {}
47         bool needBufferOpen() const { return isBufferDependent(); }
48         //@}
49         /// Any dialog that overrides this method should make sure to call it.
50         void closeEvent(QCloseEvent * ev)
51         {
52                 clearParams();
53                 Dialog::disconnect();
54                 ev->accept();
55         }
56         /// Any dialog that overrides this method should make sure to call it.
57         void hideEvent(QHideEvent * ev)
58         {
59                 if (!ev->spontaneous()) {
60                         clearParams();
61                         Dialog::disconnect();
62                         ev->accept();
63                 }
64         }
65 };
66
67 } // namespace frontend
68 } // namespace lyx
69
70 #endif // DIALOGVIEW_H