-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathCodeEditorSettingsPage.h
136 lines (105 loc) · 3.57 KB
/
CodeEditorSettingsPage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//-----------------------------------------------------------------------------
// File: CodeEditorSettingsPage.h
//-----------------------------------------------------------------------------
// Project: Kactus 2
// Author: Joni-Matti Maatta
// Date: 14.6.2011
//
// Description:
// Code editor settings property page.
//-----------------------------------------------------------------------------
#ifndef CODEEDITORSETTINGSPAGE_H
#define CODEEDITORSETTINGSPAGE_H
#include "SettingsPage.h"
#include <common/widgets/colorBox/ColorBox.h>
#include <common/widgets/assistedTextEdit/HighlightStyleDesc.h>
#include <Plugins/common/LanguageHighlighter.h>
#include <QLineEdit>
#include <QSettings>
#include <QRadioButton>
#include <QFontComboBox>
#include <QComboBox>
#include <QListWidget>
#include <QFrame>
#include <QCheckBox>
//-----------------------------------------------------------------------------
//! CodeEditorSettingsPage class.
//-----------------------------------------------------------------------------
class CodeEditorSettingsPage : public SettingsPage
{
Q_OBJECT
public:
/*!
* Constructor.
*
* @param [in/out] settings The settings store.
*/
CodeEditorSettingsPage(QSettings& settings);
/*!
* Destructor.
*/
virtual ~CodeEditorSettingsPage() = default;
// Disable copying.
CodeEditorSettingsPage(CodeEditorSettingsPage const& rhs) = delete;
CodeEditorSettingsPage& operator=(CodeEditorSettingsPage const& rhs) = delete;
/*!
* Validates the contents of the page thoroughly.
*
* @return True, if the contents are valid. False, if they are invalid.
*
* @remarks Showing message boxes for errors is allowed.
*/
virtual bool validate() override final;
/*!
* Applies the changes that were done in the page.
*/
virtual void apply() override final;
public slots:
//! Requests the user to select a color.
void selectColor();
/*!
* Called when a different highlight style is selected from the list box.
*/
void onSelectStyle(QListWidgetItem* cur, QListWidgetItem* prev);
/*!
* Updates the highlight sample.
*/
void updateSample();
private:
//! Sets the page layout.
void setupLayout();
/*!
* Loads the current settings.
*/
void loadSettings();
enum
{
MIN_FONT_SIZE = 6,
MAX_FONT_SIZE = 24
};
//-----------------------------------------------------------------------------
// Data.
//-----------------------------------------------------------------------------
//! Indent width edit.
QLineEdit* indentWidthEdit_;
//! Indentation style radio buttons.
QRadioButton* indentStyleRadioButtons_[2];
//! Font combobox.
QFontComboBox* fontCombo_;
//! Font size combobox.
QComboBox* fontSizeCombo_;
//! Highlight type listbox.
QListWidget* highlightTypeList_;
//! Color box for showing the currently selected color.
ColorBox* colorBox_;
//! Check box for bold style.
QCheckBox* boldCheckBox_;
//! Check box for italic style.
QCheckBox* italicCheckBox_;
//! Color box for showing a sample of the highlighted text.
ColorBox* previewBox_;
//! The current (non-saved) highlight styles.
HighlightStyleDesc styles_[LanguageHighlighter::STYLE_COUNT];
};
//-----------------------------------------------------------------------------
#endif // CODEEDITORSETTINGSPAGE_H