This repository was archived by the owner on Nov 14, 2017. It is now read-only.
forked from luisfranciscocesar/Jentos_IDE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefsdialog.cpp
More file actions
executable file
·206 lines (159 loc) · 7.02 KB
/
prefsdialog.cpp
File metadata and controls
executable file
·206 lines (159 loc) · 7.02 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
Ted, a simple text editor/IDE.
Copyright 2012, Blitz Research Ltd.
See LICENSE.TXT for licensing terms.
*/
#include "prefsdialog.h"
#include "ui_prefsdialog.h"
#include "prefs.h"
#include "mainwindow.h"
#include "theme.h"
PrefsDialog::PrefsDialog(MainWindow *mainwnd, QWidget *parent ):QDialog( parent ),_ui( new Ui::PrefsDialog ),_prefs( Prefs::prefs() ),_used( false ){
_ui->setupUi( this );
_mainwnd = mainwnd;
connect(_ui->comboBoxTheme,SIGNAL(currentIndexChanged(int)), SLOT(onThemeChanged(int)));
}
PrefsDialog::~PrefsDialog(){
delete _ui;
}
void PrefsDialog::readSettings() {
QSettings *set = Prefs::settings();
if( set->value( "settingsVersion" ).toInt() < 2 ){
return;
}
set->beginGroup( "prefsDialog" );
restoreGeometry( set->value( "geometry" ).toByteArray() );
set->endGroup();
}
void PrefsDialog::writeSettings(){
QSettings *set = Prefs::settings();
set->beginGroup( "prefsDialog" );
if( _used )
set->setValue( "geometry",saveGeometry() );
set->endGroup();
}
int PrefsDialog::exec(){
if( !_used ){
QRect frect = frameGeometry();
frect.moveCenter(QDesktopWidget().availableGeometry().center());
move(frect.topLeft());
restoreGeometry( saveGeometry() );
_used = true;
}
_ui->fontComboBox->setCurrentFont( QFont( _prefs->getString( "fontFamily" ),_prefs->getInt("fontSize") ) );
_ui->fontSizeWidget->setValue( _prefs->getInt("fontSize") );
_ui->tabSizeWidget->setValue( _prefs->getInt( "tabSize" ) );
_ui->chbSmoothFonts->setChecked( _prefs->getBool( "smoothFonts" ) );
_ui->chbHighlightLine->setChecked( _prefs->getBool( "highlightLine" ) );
_ui->chbHighlightWord->setChecked( _prefs->getBool( "highlightWord" ) );
_ui->backgroundColorWidget->setColor( _prefs->getColor( "backgroundColor" ) );
_ui->defaultColorWidget->setColor( _prefs->getColor( "defaultColor" ) );
_ui->numbersColorWidget->setColor( _prefs->getColor( "numbersColor" ) );
_ui->stringsColorWidget->setColor( _prefs->getColor( "stringsColor" ) );
_ui->identifiersColorWidget->setColor( _prefs->getColor( "identifiersColor" ) );
_ui->keywordsColorWidget->setColor( _prefs->getColor( "keywordsColor" ) );
_ui->constantsColorWidget->setColor( _prefs->getColor( "constantsColor" ) );
_ui->funcDeclsColorWidget->setColor( _prefs->getColor( "funcDeclsColor" ) );
_ui->commentsColorWidget->setColor( _prefs->getColor( "commentsColor" ) );
_ui->highlightColorWidget->setColor( _prefs->getColor( "highlightColor" ) );
_ui->highlightColorErrorWidget->setColor( _prefs->getColor( "highlightColorError" ) );
_ui->highlightColorCaretRowWidget->setColor( _prefs->getColor( "highlightColorCaretRow" ) );
_ui->monkeywordsColorWidget->setColor( _prefs->getColor( "monkeywordsColor" ) );
_ui->userwordsColorWidget->setColor( _prefs->getColor( "userwordsColor" ) );
_ui->userwordsDeclColorWidget->setColor( _prefs->getColor( "userwordsDeclColor" ) );
_ui->userwordsFirstDeclColorWidget->setColor( _prefs->getColor( "userwordsFirstDeclColor" ) );
_ui->userwordsVarColorWidget->setColor( _prefs->getColor( "userwordsVarColor" ) );
_ui->paramsColorWidget->setColor( _prefs->getColor( "paramsColor" ) );
_ui->tabSizeWidget->setValue( _prefs->getInt( "tabSize" ) );
_ui->monkeyPathWidget->setText( _prefs->getString( "monkeyPath" ) );
_ui->checkBoxAutoformat->setChecked( _prefs->getBool( "codeAutoformat" ) );
_ui->checkBoxUseSpaces->setChecked( _prefs->getBool( "codeTabUseSpaces" ) );
_ui->checkBoxFillAucompInherit->setChecked( _prefs->getBool( "codeFillAucompInherit" ) );
_ui->checkBoxCheckUpdates->setChecked( _prefs->getBool( "updates" ) );
_ui->checkBoxAutoBracket->setChecked(_prefs->getBool("AutoBracket"));
_ui->checkBoxShowHelpInDock->setChecked(_prefs->getBool("showHelpInDock"));
_ui->checkBoxReplaceDocsStyle->setChecked(_prefs->getBool("replaceDocsStyle"));
Prefs *p = Prefs::prefs();
_ui->labelSettingsFile->setText( p->settings()->fileName() );
QString theme = p->getString("theme");
int index = 0;
if(theme == "netbeans")
index = 1;
else if(theme == "qt")
index = 2;
_ui->comboBoxTheme->setCurrentIndex(index);
//_ui->groupBox->setVisible(false);
QDialog::show();
return QDialog::exec();
}
void PrefsDialog::onCheckUpdatesChanged(){
_prefs->setValue( "updates", _ui->checkBoxCheckUpdates->isChecked() );
}
void PrefsDialog::onFontChanged( const QFont &font ){
_prefs->setValue( "fontFamily",font.family() );
}
void PrefsDialog::onFontSizeChanged( int size ){
_prefs->setValue( "fontSize",size );
}
void PrefsDialog::onTabSizeChanged( int size ){
_prefs->setValue( "tabSize",size );
}
void PrefsDialog::onSmoothFontsChanged( bool state ){
_prefs->setValue( "smoothFonts",state );
}
void PrefsDialog::onHighlightLineChanged(bool value) {
_prefs->setValue( "highlightLine", value );
}
void PrefsDialog::onHighlightWordChanged(bool value) {
_prefs->setValue( "highlightWord", value );
}
void PrefsDialog::onColorChanged(){
ColorSwatch *swatch=qobject_cast<ColorSwatch*>( sender() );
if( !swatch ) return;
QString name=swatch->objectName();
int i=name.indexOf( "Widget" );
if( i==-1 ) return;
name=name.left( i );
_prefs->setValue( name.toStdString().c_str(),swatch->color() );
}
void PrefsDialog::onAnalyzerChanged() {
if(sender() == _ui->checkBoxAutoformat)
_prefs->setValue( "codeAutoformat",_ui->checkBoxAutoformat->isChecked() );
else if(sender() == _ui->checkBoxFillAucompInherit)
_prefs->setValue( "codeFillAucompInherit",_ui->checkBoxFillAucompInherit->isChecked() );
else if(sender() == _ui->checkBoxUseSpaces)
_prefs->setValue( "codeTabUseSpaces",_ui->checkBoxUseSpaces->isChecked() );
}
void PrefsDialog::onBrowseForPath() {
QString path = QFileDialog::getExistingDirectory( this,"Select Monkey directory","",QFileDialog::ShowDirsOnly|QFileDialog::DontResolveSymlinks );
if( path.isEmpty() ) return;
path = fixPath( path );
QString trans;
if( MainWindow::isValidMonkeyPath(path, trans) ) {
_prefs->setValue( "monkeyPath",path );
_prefs->setValue( "transPath",trans );
_ui->monkeyPathWidget->setText( path );
}
else {
QMessageBox::warning( this,"","Invalid Monkey Path!\nPlease, choose the root directory of Monkey." );
_prefs->setValue( "monkeyPath","" );
}
}
void PrefsDialog::onThemeChanged(int index) {
if(index == 0)
_mainwnd->onThemeAndroidStudio();
else if(index == 1)
_mainwnd->onThemeNetBeans();
else
_mainwnd->onThemeQtCreator();
}
void PrefsDialog::onShowHelpInDockChanged() {
_prefs->setValue("showHelpInDock", _ui->checkBoxShowHelpInDock->isChecked());
}
void PrefsDialog::onReplaceDocsStyleChanged() {
_prefs->setValue("replaceDocsStyle", _ui->checkBoxReplaceDocsStyle->isChecked());
}
void PrefsDialog::on_checkBoxAutoBracket_stateChanged(int arg1)
{
_prefs->setValue( "AutoBracket", _ui->checkBoxAutoBracket->isChecked() );
}