Chris@175: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@175: Chris@175: /* Chris@175: EasyMercurial Chris@175: Chris@175: Based on HgExplorer by Jari Korhonen Chris@175: Copyright (c) 2010 Jari Korhonen Chris@175: Copyright (c) 2010 Chris Cannam Chris@175: Copyright (c) 2010 Queen Mary, University of London Chris@175: Chris@175: This program is free software; you can redistribute it and/or Chris@175: modify it under the terms of the GNU General Public License as Chris@175: published by the Free Software Foundation; either version 2 of the Chris@175: License, or (at your option) any later version. See the file Chris@175: COPYING included with this distribution for more information. Chris@175: */ Chris@175: Chris@175: #include "settingsdialog.h" Chris@175: #include "common.h" Chris@177: #include "debug.h" Chris@175: Chris@175: #include Chris@175: #include Chris@175: #include Chris@175: #include Chris@175: Chris@175: SettingsDialog::SettingsDialog(QWidget *parent) : Chris@175: QDialog(parent) Chris@175: { Chris@175: setModal(true); Chris@175: setWindowTitle(tr("Settings")); Chris@175: Chris@175: QSettings settings; Chris@175: Chris@175: QGridLayout *mainLayout = new QGridLayout; Chris@175: setLayout(mainLayout); Chris@175: Chris@175: QGroupBox *meBox = new QGroupBox(tr("About me")); Chris@175: mainLayout->addWidget(meBox, 0, 0); Chris@175: QGridLayout *meLayout = new QGridLayout; Chris@175: meBox->setLayout(meLayout); Chris@175: Chris@175: settings.beginGroup("User Information"); Chris@175: Chris@175: int row = 0; Chris@175: Chris@175: meLayout->addWidget(new QLabel(tr("Name:")), row, 0); Chris@175: Chris@175: m_nameEdit = new QLineEdit(); Chris@175: m_nameEdit->setText(settings.value("name", getUserRealName()).toString()); Chris@175: connect(m_nameEdit, SIGNAL(textChanged(const QString &)), Chris@175: this, SLOT(realNameChanged(const QString &))); Chris@175: meLayout->addWidget(m_nameEdit, row++, 1); Chris@175: Chris@175: meLayout->addWidget(new QLabel(tr("Email address:")), row, 0); Chris@175: Chris@175: m_emailEdit = new QLineEdit(); Chris@175: m_emailEdit->setText(settings.value("email").toString()); Chris@175: connect(m_emailEdit, SIGNAL(textChanged(const QString &)), Chris@175: this, SLOT(emailChanged(const QString &))); Chris@175: meLayout->addWidget(m_emailEdit, row++, 1); Chris@175: Chris@175: settings.endGroup(); Chris@175: Chris@175: QGroupBox *pathsBox = new QGroupBox(tr("System application locations")); Chris@175: mainLayout->addWidget(pathsBox, 1, 0); Chris@175: QGridLayout *pathsLayout = new QGridLayout; Chris@175: pathsBox->setLayout(pathsLayout); Chris@175: Chris@175: settings.beginGroup("Locations"); Chris@175: Chris@175: row = 0; Chris@175: Chris@175: pathsLayout->addWidget(new QLabel(tr("Mercurial (hg) program:")), row, 0); Chris@175: Chris@175: m_hgPathEdit = new QLineEdit(); Chris@175: m_hgPathEdit->setText(settings.value("hgbinary").toString()); Chris@175: connect(m_hgPathEdit, SIGNAL(textChanged(const QString &)), Chris@175: this, SLOT(hgPathChanged(const QString &))); Chris@175: pathsLayout->addWidget(m_hgPathEdit, row, 1); Chris@175: Chris@175: QPushButton *browse = new QPushButton(tr("Browse...")); Chris@175: pathsLayout->addWidget(browse, row++, 2); Chris@175: connect(browse, SIGNAL(clicked()), this, SLOT(hgPathBrowse())); Chris@175: Chris@175: pathsLayout->addWidget(new QLabel(tr("External diff program:")), row, 0); Chris@175: Chris@175: m_diffPathEdit = new QLineEdit(); Chris@175: m_diffPathEdit->setText(settings.value("extdiffbinary").toString()); Chris@175: connect(m_diffPathEdit, SIGNAL(textChanged(const QString &)), Chris@175: this, SLOT(diffPathChanged(const QString &))); Chris@175: pathsLayout->addWidget(m_diffPathEdit, row, 1); Chris@175: Chris@175: browse = new QPushButton(tr("Browse...")); Chris@175: pathsLayout->addWidget(browse, row++, 2); Chris@175: connect(browse, SIGNAL(clicked()), this, SLOT(diffPathBrowse())); Chris@178: Chris@175: pathsLayout->addWidget(new QLabel(tr("External file-merge program:")), row, 0); Chris@175: Chris@175: m_mergePathEdit = new QLineEdit(); Chris@175: m_mergePathEdit->setText(settings.value("mergebinary").toString()); Chris@175: connect(m_mergePathEdit, SIGNAL(textChanged(const QString &)), Chris@175: this, SLOT(mergePathChanged(const QString &))); Chris@175: pathsLayout->addWidget(m_mergePathEdit, row, 1); Chris@175: Chris@175: browse = new QPushButton(tr("Browse...")); Chris@175: pathsLayout->addWidget(browse, row++, 2); Chris@175: connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse())); Chris@175: Chris@178: pathsLayout->addWidget(new QLabel(tr("External text editor:")), row, 0); Chris@178: Chris@178: m_editPathEdit = new QLineEdit(); Chris@178: m_editPathEdit->setText(settings.value("editorbinary").toString()); Chris@178: connect(m_editPathEdit, SIGNAL(textChanged(const QString &)), Chris@178: this, SLOT(editPathChanged(const QString &))); Chris@178: pathsLayout->addWidget(m_editPathEdit, row, 1); Chris@178: Chris@178: browse = new QPushButton(tr("Browse...")); Chris@178: pathsLayout->addWidget(browse, row++, 2); Chris@178: connect(browse, SIGNAL(clicked()), this, SLOT(editPathBrowse())); Chris@178: Chris@175: settings.endGroup(); Chris@176: Chris@176: settings.beginGroup("Locations"); Chris@176: Chris@176: pathsLayout->addWidget(new QLabel(tr("EasyHg Mercurial extension:")), row, 0); Chris@176: Chris@176: m_extensionPathEdit = new QLineEdit(); Chris@176: m_extensionPathEdit->setText(settings.value("extensionpath").toString()); Chris@176: connect(m_extensionPathEdit, SIGNAL(textChanged(const QString &)), Chris@176: this, SLOT(extensionPathChanged(const QString &))); Chris@176: pathsLayout->addWidget(m_extensionPathEdit, row, 1); Chris@176: Chris@176: browse = new QPushButton(tr("Browse...")); Chris@176: pathsLayout->addWidget(browse, row++, 2); Chris@176: connect(browse, SIGNAL(clicked()), this, SLOT(extensionPathBrowse())); Chris@176: Chris@176: settings.endGroup(); Chris@176: Chris@176: settings.beginGroup("General"); Chris@176: Chris@176: //!!! more info plz Chris@176: m_useExtension = new QCheckBox(tr("Use EasyHg Mercurial extension")); Chris@176: m_useExtension->setChecked(settings.value("useextension", true).toBool()); Chris@176: pathsLayout->addWidget(m_useExtension, row++, 1); Chris@176: Chris@176: settings.endGroup(); Chris@176: Chris@175: Chris@175: QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok); Chris@175: connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); Chris@175: mainLayout->addWidget(bbox, 2, 0); Chris@175: m_ok = bbox->button(QDialogButtonBox::Ok); Chris@175: // m_ok->setEnabled(false); Chris@175: Chris@175: //!!! m_ok->setEnabled(m_name != ""); Chris@175: // updateExample(); Chris@175: } Chris@175: Chris@175: void Chris@175: SettingsDialog::realNameChanged(const QString &s) Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@175: SettingsDialog::emailChanged(const QString &s) Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@175: SettingsDialog::hgPathChanged(const QString &s) Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@175: SettingsDialog::hgPathBrowse() Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@175: SettingsDialog::diffPathChanged(const QString &s) Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@175: SettingsDialog::diffPathBrowse() Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@175: SettingsDialog::mergePathChanged(const QString &s) Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@175: SettingsDialog::mergePathBrowse() Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@178: SettingsDialog::editPathChanged(const QString &s) Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@178: SettingsDialog::editPathBrowse() Chris@175: { Chris@175: } Chris@175: Chris@175: void Chris@176: SettingsDialog::extensionPathChanged(const QString &s) Chris@176: { Chris@176: } Chris@176: Chris@176: void Chris@176: SettingsDialog::extensionPathBrowse() Chris@176: { Chris@176: } Chris@176: Chris@176: void Chris@175: SettingsDialog::accept() Chris@175: { Chris@177: DEBUG << "SettingsDialog::accept" << endl; Chris@175: QSettings settings; Chris@175: settings.beginGroup("User Information"); Chris@175: settings.setValue("name", m_nameEdit->text()); Chris@175: settings.setValue("email", m_emailEdit->text()); Chris@175: settings.endGroup(); Chris@175: settings.beginGroup("Locations"); Chris@175: settings.setValue("hgbinary", m_hgPathEdit->text()); Chris@175: settings.setValue("extdiffbinary", m_diffPathEdit->text()); Chris@175: settings.setValue("mergebinary", m_mergePathEdit->text()); Chris@176: settings.setValue("extensionpath", m_extensionPathEdit->text()); Chris@176: settings.endGroup(); Chris@176: settings.beginGroup("General"); Chris@176: settings.setValue("useextension", m_useExtension->isChecked()); Chris@175: settings.endGroup(); Chris@175: QDialog::accept(); Chris@175: } Chris@175: Chris@175: