Chris@175
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@175
|
2
|
Chris@175
|
3 /*
|
Chris@175
|
4 EasyMercurial
|
Chris@175
|
5
|
Chris@175
|
6 Based on HgExplorer by Jari Korhonen
|
Chris@175
|
7 Copyright (c) 2010 Jari Korhonen
|
Chris@175
|
8 Copyright (c) 2010 Chris Cannam
|
Chris@175
|
9 Copyright (c) 2010 Queen Mary, University of London
|
Chris@175
|
10
|
Chris@175
|
11 This program is free software; you can redistribute it and/or
|
Chris@175
|
12 modify it under the terms of the GNU General Public License as
|
Chris@175
|
13 published by the Free Software Foundation; either version 2 of the
|
Chris@175
|
14 License, or (at your option) any later version. See the file
|
Chris@175
|
15 COPYING included with this distribution for more information.
|
Chris@175
|
16 */
|
Chris@175
|
17
|
Chris@175
|
18 #include "settingsdialog.h"
|
Chris@175
|
19 #include "common.h"
|
Chris@177
|
20 #include "debug.h"
|
Chris@175
|
21
|
Chris@175
|
22 #include <QGridLayout>
|
Chris@175
|
23 #include <QGroupBox>
|
Chris@175
|
24 #include <QDialogButtonBox>
|
Chris@175
|
25 #include <QSettings>
|
Chris@175
|
26
|
Chris@175
|
27 SettingsDialog::SettingsDialog(QWidget *parent) :
|
Chris@175
|
28 QDialog(parent)
|
Chris@175
|
29 {
|
Chris@175
|
30 setModal(true);
|
Chris@175
|
31 setWindowTitle(tr("Settings"));
|
Chris@175
|
32
|
Chris@175
|
33 QSettings settings;
|
Chris@175
|
34
|
Chris@175
|
35 QGridLayout *mainLayout = new QGridLayout;
|
Chris@175
|
36 setLayout(mainLayout);
|
Chris@175
|
37
|
Chris@175
|
38 QGroupBox *meBox = new QGroupBox(tr("About me"));
|
Chris@175
|
39 mainLayout->addWidget(meBox, 0, 0);
|
Chris@175
|
40 QGridLayout *meLayout = new QGridLayout;
|
Chris@175
|
41 meBox->setLayout(meLayout);
|
Chris@175
|
42
|
Chris@175
|
43 settings.beginGroup("User Information");
|
Chris@175
|
44
|
Chris@175
|
45 int row = 0;
|
Chris@175
|
46
|
Chris@175
|
47 meLayout->addWidget(new QLabel(tr("Name:")), row, 0);
|
Chris@175
|
48
|
Chris@175
|
49 m_nameEdit = new QLineEdit();
|
Chris@175
|
50 m_nameEdit->setText(settings.value("name", getUserRealName()).toString());
|
Chris@175
|
51 connect(m_nameEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
52 this, SLOT(realNameChanged(const QString &)));
|
Chris@175
|
53 meLayout->addWidget(m_nameEdit, row++, 1);
|
Chris@175
|
54
|
Chris@175
|
55 meLayout->addWidget(new QLabel(tr("Email address:")), row, 0);
|
Chris@175
|
56
|
Chris@175
|
57 m_emailEdit = new QLineEdit();
|
Chris@175
|
58 m_emailEdit->setText(settings.value("email").toString());
|
Chris@175
|
59 connect(m_emailEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
60 this, SLOT(emailChanged(const QString &)));
|
Chris@175
|
61 meLayout->addWidget(m_emailEdit, row++, 1);
|
Chris@175
|
62
|
Chris@175
|
63 settings.endGroup();
|
Chris@175
|
64
|
Chris@175
|
65 QGroupBox *pathsBox = new QGroupBox(tr("System application locations"));
|
Chris@175
|
66 mainLayout->addWidget(pathsBox, 1, 0);
|
Chris@175
|
67 QGridLayout *pathsLayout = new QGridLayout;
|
Chris@175
|
68 pathsBox->setLayout(pathsLayout);
|
Chris@175
|
69
|
Chris@175
|
70 settings.beginGroup("Locations");
|
Chris@175
|
71
|
Chris@175
|
72 row = 0;
|
Chris@175
|
73
|
Chris@175
|
74 pathsLayout->addWidget(new QLabel(tr("Mercurial (hg) program:")), row, 0);
|
Chris@175
|
75
|
Chris@175
|
76 m_hgPathEdit = new QLineEdit();
|
Chris@175
|
77 m_hgPathEdit->setText(settings.value("hgbinary").toString());
|
Chris@175
|
78 connect(m_hgPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
79 this, SLOT(hgPathChanged(const QString &)));
|
Chris@175
|
80 pathsLayout->addWidget(m_hgPathEdit, row, 1);
|
Chris@175
|
81
|
Chris@175
|
82 QPushButton *browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
83 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
84 connect(browse, SIGNAL(clicked()), this, SLOT(hgPathBrowse()));
|
Chris@175
|
85
|
Chris@175
|
86 pathsLayout->addWidget(new QLabel(tr("External diff program:")), row, 0);
|
Chris@175
|
87
|
Chris@175
|
88 m_diffPathEdit = new QLineEdit();
|
Chris@175
|
89 m_diffPathEdit->setText(settings.value("extdiffbinary").toString());
|
Chris@175
|
90 connect(m_diffPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
91 this, SLOT(diffPathChanged(const QString &)));
|
Chris@175
|
92 pathsLayout->addWidget(m_diffPathEdit, row, 1);
|
Chris@175
|
93
|
Chris@175
|
94 browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
95 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
96 connect(browse, SIGNAL(clicked()), this, SLOT(diffPathBrowse()));
|
Chris@175
|
97
|
Chris@175
|
98 pathsLayout->addWidget(new QLabel(tr("External file-merge program:")), row, 0);
|
Chris@175
|
99
|
Chris@175
|
100 m_mergePathEdit = new QLineEdit();
|
Chris@175
|
101 m_mergePathEdit->setText(settings.value("mergebinary").toString());
|
Chris@175
|
102 connect(m_mergePathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
103 this, SLOT(mergePathChanged(const QString &)));
|
Chris@175
|
104 pathsLayout->addWidget(m_mergePathEdit, row, 1);
|
Chris@175
|
105
|
Chris@175
|
106 browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
107 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
108 connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse()));
|
Chris@175
|
109
|
Chris@175
|
110 settings.endGroup();
|
Chris@176
|
111
|
Chris@176
|
112 settings.beginGroup("Locations");
|
Chris@176
|
113
|
Chris@176
|
114 pathsLayout->addWidget(new QLabel(tr("EasyHg Mercurial extension:")), row, 0);
|
Chris@176
|
115
|
Chris@176
|
116 m_extensionPathEdit = new QLineEdit();
|
Chris@176
|
117 m_extensionPathEdit->setText(settings.value("extensionpath").toString());
|
Chris@176
|
118 connect(m_extensionPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@176
|
119 this, SLOT(extensionPathChanged(const QString &)));
|
Chris@176
|
120 pathsLayout->addWidget(m_extensionPathEdit, row, 1);
|
Chris@176
|
121
|
Chris@176
|
122 browse = new QPushButton(tr("Browse..."));
|
Chris@176
|
123 pathsLayout->addWidget(browse, row++, 2);
|
Chris@176
|
124 connect(browse, SIGNAL(clicked()), this, SLOT(extensionPathBrowse()));
|
Chris@176
|
125
|
Chris@176
|
126 settings.endGroup();
|
Chris@176
|
127
|
Chris@176
|
128 settings.beginGroup("General");
|
Chris@176
|
129
|
Chris@176
|
130 //!!! more info plz
|
Chris@176
|
131 m_useExtension = new QCheckBox(tr("Use EasyHg Mercurial extension"));
|
Chris@176
|
132 m_useExtension->setChecked(settings.value("useextension", true).toBool());
|
Chris@176
|
133 pathsLayout->addWidget(m_useExtension, row++, 1);
|
Chris@176
|
134
|
Chris@176
|
135 settings.endGroup();
|
Chris@176
|
136
|
Chris@175
|
137
|
Chris@175
|
138 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@175
|
139 connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
|
Chris@175
|
140 mainLayout->addWidget(bbox, 2, 0);
|
Chris@175
|
141 m_ok = bbox->button(QDialogButtonBox::Ok);
|
Chris@175
|
142 // m_ok->setEnabled(false);
|
Chris@175
|
143
|
Chris@175
|
144 //!!! m_ok->setEnabled(m_name != "");
|
Chris@175
|
145 // updateExample();
|
Chris@175
|
146 }
|
Chris@175
|
147
|
Chris@175
|
148 void
|
Chris@175
|
149 SettingsDialog::realNameChanged(const QString &s)
|
Chris@175
|
150 {
|
Chris@175
|
151 }
|
Chris@175
|
152
|
Chris@175
|
153 void
|
Chris@175
|
154 SettingsDialog::emailChanged(const QString &s)
|
Chris@175
|
155 {
|
Chris@175
|
156 }
|
Chris@175
|
157
|
Chris@175
|
158 void
|
Chris@175
|
159 SettingsDialog::hgPathChanged(const QString &s)
|
Chris@175
|
160 {
|
Chris@175
|
161 }
|
Chris@175
|
162
|
Chris@175
|
163 void
|
Chris@175
|
164 SettingsDialog::hgPathBrowse()
|
Chris@175
|
165 {
|
Chris@175
|
166 }
|
Chris@175
|
167
|
Chris@175
|
168 void
|
Chris@175
|
169 SettingsDialog::diffPathChanged(const QString &s)
|
Chris@175
|
170 {
|
Chris@175
|
171 }
|
Chris@175
|
172
|
Chris@175
|
173 void
|
Chris@175
|
174 SettingsDialog::diffPathBrowse()
|
Chris@175
|
175 {
|
Chris@175
|
176 }
|
Chris@175
|
177
|
Chris@175
|
178 void
|
Chris@175
|
179 SettingsDialog::mergePathChanged(const QString &s)
|
Chris@175
|
180 {
|
Chris@175
|
181 }
|
Chris@175
|
182
|
Chris@175
|
183 void
|
Chris@175
|
184 SettingsDialog::mergePathBrowse()
|
Chris@175
|
185 {
|
Chris@175
|
186 }
|
Chris@175
|
187
|
Chris@175
|
188 void
|
Chris@175
|
189 SettingsDialog::editorPathChanged(const QString &s)
|
Chris@175
|
190 {
|
Chris@175
|
191 }
|
Chris@175
|
192
|
Chris@175
|
193 void
|
Chris@175
|
194 SettingsDialog::editorPathBrowse()
|
Chris@175
|
195 {
|
Chris@175
|
196 }
|
Chris@175
|
197
|
Chris@175
|
198 void
|
Chris@176
|
199 SettingsDialog::extensionPathChanged(const QString &s)
|
Chris@176
|
200 {
|
Chris@176
|
201 }
|
Chris@176
|
202
|
Chris@176
|
203 void
|
Chris@176
|
204 SettingsDialog::extensionPathBrowse()
|
Chris@176
|
205 {
|
Chris@176
|
206 }
|
Chris@176
|
207
|
Chris@176
|
208 void
|
Chris@175
|
209 SettingsDialog::accept()
|
Chris@175
|
210 {
|
Chris@177
|
211 DEBUG << "SettingsDialog::accept" << endl;
|
Chris@175
|
212 QSettings settings;
|
Chris@175
|
213 settings.beginGroup("User Information");
|
Chris@175
|
214 settings.setValue("name", m_nameEdit->text());
|
Chris@175
|
215 settings.setValue("email", m_emailEdit->text());
|
Chris@175
|
216 settings.endGroup();
|
Chris@175
|
217 settings.beginGroup("Locations");
|
Chris@175
|
218 settings.setValue("hgbinary", m_hgPathEdit->text());
|
Chris@175
|
219 settings.setValue("extdiffbinary", m_diffPathEdit->text());
|
Chris@175
|
220 settings.setValue("mergebinary", m_mergePathEdit->text());
|
Chris@176
|
221 settings.setValue("extensionpath", m_extensionPathEdit->text());
|
Chris@176
|
222 settings.endGroup();
|
Chris@176
|
223 settings.beginGroup("General");
|
Chris@176
|
224 settings.setValue("useextension", m_useExtension->isChecked());
|
Chris@175
|
225 settings.endGroup();
|
Chris@175
|
226 QDialog::accept();
|
Chris@175
|
227 }
|
Chris@175
|
228
|
Chris@175
|
229
|