-
Notifications
You must be signed in to change notification settings - Fork 0
/
footerbararea.cpp
185 lines (156 loc) · 5.48 KB
/
footerbararea.cpp
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#include "footerbararea.h"
FooterBarArea::FooterBarArea(CodeEditor *editor) : QWidget(editor)
{
codeEditor = editor;
this->setObjectName("codeEditorFooter");
mainLayout = new QHBoxLayout();
this->setLayout(mainLayout);
mainLayout->setObjectName("footerMainLayout");
layout = new QVBoxLayout();
mainLayout->addLayout(layout);
layout2 = new QVBoxLayout();
layout2H1 = new QHBoxLayout();
layout2H = new QHBoxLayout();
mainLayout->addLayout(layout2);
layout3 = new QVBoxLayout();
mainLayout->addLayout(layout3);
layout3H = new QHBoxLayout();
layout3->addLayout(layout3H);
comboBox = new QComboBox();
searchBox = new QLineEdit();
filePathLabel = new QLabel();
resizeButton = new QPushButton();
moreButton = new QPushButton();
replaceButton = new QPushButton();
searchButton = new QPushButton();
replaceBox = new QLineEdit();
cursorInfoLabel = new QLabel();
languagesSupported = codeEditor->assetManager->getLoadedSupportFileNames();
comboBox->addItems(languagesSupported);
comboBox->addItem("None");
filePathLabel->setText(codeEditor->currentFile->absoluteFilePath());
comboBox->setObjectName("footerComboBox");
searchBox->setObjectName("footerSearchBox");
searchBox->setPlaceholderText("RegExp search...");
filePathLabel->setObjectName("footerFilePathLabel");
filePathLabel->setAlignment(Qt::AlignRight);
cursorInfoLabel->setObjectName("footerCursorInfoLabel");
moreButton->setObjectName("footerMoreButton");
replaceButton->setObjectName("footerReplaceButton");
searchButton->setObjectName("footerSearchButton");
resizeButton->setObjectName("footerResizeButton");
resizeButton->setText("▴");
layout->setObjectName("footerComboBoxLayout");
layout->addWidget(comboBox);
layout2H1->setObjectName("footerComboBoxLayout2");
layout2H1->addWidget(searchBox);
layout2H1->addWidget(searchButton);
layout2->addLayout(layout2H1);
layout2->addLayout(layout2H);
layout3H->addWidget(cursorInfoLabel);
layout3H->addWidget(resizeButton);
layout3H->setAlignment(resizeButton, Qt::AlignRight);
layout3H->setAlignment(cursorInfoLabel, Qt::AlignRight);
replaceBox->setPlaceholderText("Raplace with...");
replaceBox->setObjectName("footerReplaceBox");
cursorInfoLabel->setText("31:22");
moreButton->setText("More");
replaceButton->setText("Replace");
searchButton->setText("Search");
connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(comboChanged(int)));
connect(searchButton, SIGNAL(clicked()), this, SLOT(searchButtonClicked()));
connect(resizeButton, SIGNAL(clicked()), this, SLOT(toggleResize()));
connect(replaceButton, SIGNAL(clicked()), this, SLOT(replaceMatchedText()));
if(codeEditor->syntaxHighlighter->ruleSet != NULL)
{
QString currentLanguage = codeEditor->syntaxHighlighter->ruleSet->fileName;
for(int i = 0; i < languagesSupported.length(); i++)
{
if(languagesSupported[i] == currentLanguage)
comboBox->setCurrentIndex(i);
}
} else
{
comboBox->setCurrentIndex(comboBox->count()-1);
}
heightCollapsed = 40;
heightExpanded = 80;
height = heightCollapsed;
isExpanded = false;
}
void FooterBarArea::toggleResize()
{
if(isExpanded)
{
isExpanded = false;
height = heightCollapsed;
layout2H->removeWidget(replaceBox);
layout2H->removeWidget(replaceButton);
layout3->removeWidget(filePathLabel);
layout->removeWidget(moreButton);
resizeButton->setText("▴");
QString style = "QPlainTextEdit{padding-bottom: "+QString::number(heightCollapsed)+"px;}";
codeEditor->setStyleSheet(style);
} else
{
isExpanded = true;
height = heightExpanded;
layout2H->addWidget(replaceBox);
layout2H->addWidget(replaceButton);
layout3->addWidget(filePathLabel);
layout->addWidget(moreButton);
resizeButton->setText("▾");
QString style = "QPlainTextEdit{padding-bottom: "+QString::number(heightExpanded)+"px;}";
codeEditor->setStyleSheet(style);
}
codeEditor->setFooterHeight(height);
}
void FooterBarArea::setCursorInfoText(int charIndex, int lineIndex)
{
cursorInfoLabel->setText(QString::number(charIndex)+":"+QString::number(lineIndex));
}
void FooterBarArea::codeCursorChanged()
{
// text edit changed, update line number and char
int lineNumber = codeEditor->textCursor().blockNumber() + 1;
int charNumber = codeEditor->textCursor().columnNumber();
setCursorInfoText(charNumber, lineNumber);
}
void FooterBarArea::replaceMatchedText()
{
QRegExp exp(searchBox->text());
codeEditor->replaceSearchMatchedText(replaceBox->text(), exp);
}
FooterBarArea::~FooterBarArea()
{
delete layout3H;
layout3H = NULL;
delete layout3;
layout3 = NULL;
delete layout2H1;
layout2H1 = NULL;
delete layout2H;
layout2H = NULL;
delete layout2;
layout2 = NULL;
delete layout;
layout = NULL;
delete comboBox;
comboBox = NULL;
delete searchBox;
searchBox = NULL;
delete filePathLabel;
filePathLabel = NULL;
delete resizeButton;
resizeButton = NULL;
delete replaceBox;
replaceBox = NULL;
delete cursorInfoLabel;
cursorInfoLabel = NULL;
delete moreButton;
moreButton = NULL;
delete replaceButton;
replaceButton = NULL;
delete searchButton;
searchButton = NULL;
}