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