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@175
|
20
|
Chris@175
|
21 #include <QGridLayout>
|
Chris@175
|
22 #include <QGroupBox>
|
Chris@175
|
23 #include <QDialogButtonBox>
|
Chris@175
|
24 #include <QSettings>
|
Chris@175
|
25
|
Chris@175
|
26 SettingsDialog::SettingsDialog(QWidget *parent) :
|
Chris@175
|
27 QDialog(parent)
|
Chris@175
|
28 {
|
Chris@175
|
29 setModal(true);
|
Chris@175
|
30 setWindowTitle(tr("Settings"));
|
Chris@175
|
31
|
Chris@175
|
32 QSettings settings;
|
Chris@175
|
33
|
Chris@175
|
34 QGridLayout *mainLayout = new QGridLayout;
|
Chris@175
|
35 setLayout(mainLayout);
|
Chris@175
|
36
|
Chris@175
|
37 QGroupBox *meBox = new QGroupBox(tr("About me"));
|
Chris@175
|
38 mainLayout->addWidget(meBox, 0, 0);
|
Chris@175
|
39 QGridLayout *meLayout = new QGridLayout;
|
Chris@175
|
40 meBox->setLayout(meLayout);
|
Chris@175
|
41
|
Chris@175
|
42 settings.beginGroup("User Information");
|
Chris@175
|
43
|
Chris@175
|
44 int row = 0;
|
Chris@175
|
45
|
Chris@175
|
46 meLayout->addWidget(new QLabel(tr("Name:")), row, 0);
|
Chris@175
|
47
|
Chris@175
|
48 m_nameEdit = new QLineEdit();
|
Chris@175
|
49 m_nameEdit->setText(settings.value("name", getUserRealName()).toString());
|
Chris@175
|
50 connect(m_nameEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
51 this, SLOT(realNameChanged(const QString &)));
|
Chris@175
|
52 meLayout->addWidget(m_nameEdit, row++, 1);
|
Chris@175
|
53
|
Chris@175
|
54 meLayout->addWidget(new QLabel(tr("Email address:")), row, 0);
|
Chris@175
|
55
|
Chris@175
|
56 m_emailEdit = new QLineEdit();
|
Chris@175
|
57 m_emailEdit->setText(settings.value("email").toString());
|
Chris@175
|
58 connect(m_emailEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
59 this, SLOT(emailChanged(const QString &)));
|
Chris@175
|
60 meLayout->addWidget(m_emailEdit, row++, 1);
|
Chris@175
|
61
|
Chris@175
|
62 settings.endGroup();
|
Chris@175
|
63
|
Chris@175
|
64 QGroupBox *pathsBox = new QGroupBox(tr("System application locations"));
|
Chris@175
|
65 mainLayout->addWidget(pathsBox, 1, 0);
|
Chris@175
|
66 QGridLayout *pathsLayout = new QGridLayout;
|
Chris@175
|
67 pathsBox->setLayout(pathsLayout);
|
Chris@175
|
68
|
Chris@175
|
69 settings.beginGroup("Locations");
|
Chris@175
|
70
|
Chris@175
|
71 row = 0;
|
Chris@175
|
72
|
Chris@175
|
73 pathsLayout->addWidget(new QLabel(tr("Mercurial (hg) program:")), row, 0);
|
Chris@175
|
74
|
Chris@175
|
75 m_hgPathEdit = new QLineEdit();
|
Chris@175
|
76 m_hgPathEdit->setText(settings.value("hgbinary").toString());
|
Chris@175
|
77 connect(m_hgPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
78 this, SLOT(hgPathChanged(const QString &)));
|
Chris@175
|
79 pathsLayout->addWidget(m_hgPathEdit, row, 1);
|
Chris@175
|
80
|
Chris@175
|
81 QPushButton *browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
82 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
83 connect(browse, SIGNAL(clicked()), this, SLOT(hgPathBrowse()));
|
Chris@175
|
84
|
Chris@175
|
85 pathsLayout->addWidget(new QLabel(tr("External diff program:")), row, 0);
|
Chris@175
|
86
|
Chris@175
|
87 m_diffPathEdit = new QLineEdit();
|
Chris@175
|
88 m_diffPathEdit->setText(settings.value("extdiffbinary").toString());
|
Chris@175
|
89 connect(m_diffPathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
90 this, SLOT(diffPathChanged(const QString &)));
|
Chris@175
|
91 pathsLayout->addWidget(m_diffPathEdit, row, 1);
|
Chris@175
|
92
|
Chris@175
|
93 browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
94 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
95 connect(browse, SIGNAL(clicked()), this, SLOT(diffPathBrowse()));
|
Chris@175
|
96
|
Chris@175
|
97 pathsLayout->addWidget(new QLabel(tr("External file-merge program:")), row, 0);
|
Chris@175
|
98
|
Chris@175
|
99 m_mergePathEdit = new QLineEdit();
|
Chris@175
|
100 m_mergePathEdit->setText(settings.value("mergebinary").toString());
|
Chris@175
|
101 connect(m_mergePathEdit, SIGNAL(textChanged(const QString &)),
|
Chris@175
|
102 this, SLOT(mergePathChanged(const QString &)));
|
Chris@175
|
103 pathsLayout->addWidget(m_mergePathEdit, row, 1);
|
Chris@175
|
104
|
Chris@175
|
105 browse = new QPushButton(tr("Browse..."));
|
Chris@175
|
106 pathsLayout->addWidget(browse, row++, 2);
|
Chris@175
|
107 connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse()));
|
Chris@175
|
108
|
Chris@175
|
109 settings.endGroup();
|
Chris@175
|
110
|
Chris@175
|
111 QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@175
|
112 connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
|
Chris@175
|
113 mainLayout->addWidget(bbox, 2, 0);
|
Chris@175
|
114 m_ok = bbox->button(QDialogButtonBox::Ok);
|
Chris@175
|
115 // m_ok->setEnabled(false);
|
Chris@175
|
116
|
Chris@175
|
117 //!!! m_ok->setEnabled(m_name != "");
|
Chris@175
|
118 // updateExample();
|
Chris@175
|
119 }
|
Chris@175
|
120
|
Chris@175
|
121 void
|
Chris@175
|
122 SettingsDialog::realNameChanged(const QString &s)
|
Chris@175
|
123 {
|
Chris@175
|
124 }
|
Chris@175
|
125
|
Chris@175
|
126 void
|
Chris@175
|
127 SettingsDialog::emailChanged(const QString &s)
|
Chris@175
|
128 {
|
Chris@175
|
129 }
|
Chris@175
|
130
|
Chris@175
|
131 void
|
Chris@175
|
132 SettingsDialog::hgPathChanged(const QString &s)
|
Chris@175
|
133 {
|
Chris@175
|
134 }
|
Chris@175
|
135
|
Chris@175
|
136 void
|
Chris@175
|
137 SettingsDialog::hgPathBrowse()
|
Chris@175
|
138 {
|
Chris@175
|
139 }
|
Chris@175
|
140
|
Chris@175
|
141 void
|
Chris@175
|
142 SettingsDialog::diffPathChanged(const QString &s)
|
Chris@175
|
143 {
|
Chris@175
|
144 }
|
Chris@175
|
145
|
Chris@175
|
146 void
|
Chris@175
|
147 SettingsDialog::diffPathBrowse()
|
Chris@175
|
148 {
|
Chris@175
|
149 }
|
Chris@175
|
150
|
Chris@175
|
151 void
|
Chris@175
|
152 SettingsDialog::mergePathChanged(const QString &s)
|
Chris@175
|
153 {
|
Chris@175
|
154 }
|
Chris@175
|
155
|
Chris@175
|
156 void
|
Chris@175
|
157 SettingsDialog::mergePathBrowse()
|
Chris@175
|
158 {
|
Chris@175
|
159 }
|
Chris@175
|
160
|
Chris@175
|
161 void
|
Chris@175
|
162 SettingsDialog::editorPathChanged(const QString &s)
|
Chris@175
|
163 {
|
Chris@175
|
164 }
|
Chris@175
|
165
|
Chris@175
|
166 void
|
Chris@175
|
167 SettingsDialog::editorPathBrowse()
|
Chris@175
|
168 {
|
Chris@175
|
169 }
|
Chris@175
|
170
|
Chris@175
|
171 void
|
Chris@175
|
172 SettingsDialog::accept()
|
Chris@175
|
173 {
|
Chris@175
|
174 QSettings settings;
|
Chris@175
|
175 settings.beginGroup("User Information");
|
Chris@175
|
176 settings.setValue("name", m_nameEdit->text());
|
Chris@175
|
177 settings.setValue("email", m_emailEdit->text());
|
Chris@175
|
178 settings.endGroup();
|
Chris@175
|
179 settings.beginGroup("Locations");
|
Chris@175
|
180 settings.setValue("hgbinary", m_hgPathEdit->text());
|
Chris@175
|
181 settings.setValue("extdiffbinary", m_diffPathEdit->text());
|
Chris@175
|
182 settings.setValue("mergebinary", m_mergePathEdit->text());
|
Chris@175
|
183 settings.endGroup();
|
Chris@175
|
184 QDialog::accept();
|
Chris@175
|
185 }
|
Chris@175
|
186
|
Chris@175
|
187
|