]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiParagraph.h
PrefShortcuts: ShortcutEdit, adapted from Edwin's patch
[lyx.git] / src / frontends / qt4 / GuiParagraph.h
1 // -*- C++ -*-
2 /**
3  * \file GuiParagraph.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  * \author John Levon
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUIPARAGRAPH_H
15 #define GUIPARAGRAPH_H
16
17 // Uncomment this if you prefer dock widget
18 //#define USE_DOCK_WIDGET
19
20 #include "Layout.h"
21 #include "ui_ParagraphUi.h"
22 #include "Dialog.h"
23 #include "ParagraphParameters.h"
24 #include "GuiView.h"
25 #include "qt_helpers.h"
26 #include "debug.h"
27
28 #include <QCloseEvent>
29 #include <QDialog>
30 #include <QSettings>
31 #include <QShowEvent>
32 #include <QGridLayout>
33
34 #include <map>
35 #include <string>
36
37 namespace lyx {
38 namespace frontend {
39
40 class GuiParagraph
41         : public QDialog, public Ui::ParagraphUi, public Dialog
42 {
43         Q_OBJECT
44 public:
45         GuiParagraph(LyXView & lv);
46
47         /// update
48         void updateView();
49
50 private:
51         ///
52         void checkAlignmentRadioButtons();
53         ///
54         void alignmentToRadioButtons(LyXAlignment align = LYX_ALIGN_LAYOUT);
55         ///
56         LyXAlignment getAlignmentFromDialog();
57         ///
58         typedef std::map<LyXAlignment, QRadioButton *> RadioMap;
59         RadioMap radioMap;
60
61         QString const alignDefaultLabel;
62
63         void applyView() {}
64         void hideView()
65         {
66                 clearParams();
67                 QDialog::hide();
68         }
69         void showData(std::string const & data)
70         {
71                 initialiseParams(data);
72                 showView();
73         }
74         void showView()
75         {
76                 updateView();  // make sure its up-to-date
77                 QDialog::show();
78                 raise();
79                 activateWindow();
80         }
81         bool isVisibleView() const { return QDialog::isVisible(); }
82         void checkStatus() { updateView(); }
83         void redraw() { redrawView(); }
84         void redrawView() {}
85         void updateData(std::string const & data)
86         {
87                 initialiseParams(data);
88                 updateView();
89         }
90         void partialUpdateView(int /*id*/) {}
91         std::string name() const { return "paragraph"; }
92
93 private:
94         std::string name_;
95
96         void showEvent(QShowEvent * e)
97         {
98 #if (QT_VERSION >= 0x040200)
99                 QSettings settings;
100                 std::string key = name_ + "/geometry";
101                 QDialog::restoreGeometry(settings.value(key.c_str()).toByteArray());
102 #endif
103             QDialog::showEvent(e);
104         }
105
106         void closeEvent(QCloseEvent * e)
107         {
108 #if (QT_VERSION >= 0x040200)
109                 QSettings settings;
110                 std::string key = name_ + "/geometry";
111                 settings.setValue(key.c_str(), QDialog::saveGeometry());
112 #endif
113                 QDialog::closeEvent(e);
114         }
115
116 private Q_SLOTS:
117         ///
118         void changed();
119         ///
120         void on_synchronizedViewCB_toggled();
121         ///
122         void on_restorePB_clicked();
123         ///
124         void on_linespacing_activated(int);
125         /// Apply changes
126         void on_applyPB_clicked();
127
128 private:
129         ///
130         bool initialiseParams(std::string const & /*data*/) { return true; }
131         /// clean-up on hide.
132         void clearParams() {}
133         ///
134         void dispatchParams();
135         ///
136         bool isBufferDependent() const { return true; }
137         ///
138         ParagraphParameters & params();
139         ///
140         ParagraphParameters const & params() const;
141         ///
142         bool haveMulitParSelection();
143         ///
144         bool canIndent() const;
145         ///
146         LyXAlignment alignPossible() const;
147         ///
148         LyXAlignment alignDefault() const;
149
150 private:
151         ParagraphParameters multiparsel_;
152 };
153
154 } // namespace frontend
155 } // namespace lyx
156
157 #endif // QPARAGRAPH_H