# HG changeset patch # User Chris Cannam # Date 1308231155 -3600 # Node ID 6d7dad48b13c3c200bf88aa582da1c729c3e23c7 # Parent 939701b848e50feffffbc29adc773b7de4e67443 Make HgIgnoreDialog _look_ plausible (still doesn't do anything though!) diff -r 939701b848e5 -r 6d7dad48b13c src/hgignoredialog.cpp --- a/src/hgignoredialog.cpp Wed Jun 15 16:32:21 2011 +0100 +++ b/src/hgignoredialog.cpp Thu Jun 16 14:32:35 2011 +0100 @@ -19,34 +19,112 @@ #include "common.h" #include "debug.h" +#include +#include +#include +#include +#include + +HgIgnoreDialog::HgIgnoreDialog(QWidget *parent, + QString title, + QString introText, + QString question, + QStringList options, + QString okButtonText) : + QDialog(parent) +{ + setWindowTitle(title); + + QGridLayout *layout = new QGridLayout; + setLayout(layout); + + int row = 0; + + QLabel *label = new QLabel(QString("%1%2").arg(introText).arg(question)); + label->setWordWrap(true); + layout->addWidget(label, row++, 0, 1, 2); + + if (!options.empty()) { + layout->addWidget(new QLabel(" "), row, 0); + layout->setColumnStretch(1, 10); + bool first = true; + foreach (QString option, options) { + QRadioButton *b = new QRadioButton(option); + layout->addWidget(b, row++, 1); + b->setChecked(first); + first = false; + } + } + + QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | + QDialogButtonBox::Cancel); + layout->addWidget(bbox, row++, 0, 1, 2); + bbox->button(QDialogButtonBox::Ok)->setDefault(true); + bbox->button(QDialogButtonBox::Ok)->setText(okButtonText); + bbox->button(QDialogButtonBox::Cancel)->setAutoDefault(false); + + connect(bbox, SIGNAL(accepted()), this, SLOT(accept())); + connect(bbox, SIGNAL(rejected()), this, SLOT(reject())); +} + HgIgnoreDialog::IgnoreType -HgIgnoreDialog::confirmIgnore(QStringList files, QStringList suffixes) +HgIgnoreDialog::confirmIgnore(QWidget *parent, + QStringList files, QStringList suffixes) { - QString text = ""; + QString intro = "

"; + intro += tr("Ignore files"); + intro += "

"; if (files.size() < 10) { - text += tr("You have asked to ignore the following files:"); - text += "

"; - foreach (QString f, files) { - text += "   " + xmlEncode(f) + "
"; - } - text += "
"; + intro += tr("You have asked to ignore the following files:

"); + intro += "   " + + files.join("
   ") + "
"; } else { - text += "

"; - text += tr("You have asked to ignore %1 file(s).", "", files.size()); - text += "

"; + intro += tr("You have asked to ignore %n file(s).", "", files.size()); } + intro += "

"; + if (suffixes.size() > 0) { - text += "

"; - text += tr("Would you like to:"); - text += "

    "; + QStringList options; + options << tr("Ignore these files only"); + options << tr("Ignore files with these names in any subdirectory"); + if (suffixes.size() > 1) { + options << tr("Ignore all files with these extensions:\n%1") + .arg(suffixes.join(", ")); + } else { + options << tr("Ignore all files with the extension \"%1\"") + .arg(suffixes[0]); + } - //... + HgIgnoreDialog d(parent, tr("Ignore files"), + intro, tr("

    Please choose whether to:

    "), + options, tr("Ignore")); + + if (d.exec() == QDialog::Accepted) { + + //... + + } - } + } else { + + QStringList options; + options << tr("Ignore these files only"); + options << tr("Ignore files with these names in any subdirectory"); + + HgIgnoreDialog d(parent, tr("Ignore files"), + intro, tr("

    Please choose whether to:

    "), + options, tr("Ignore")); + + if (d.exec() == QDialog::Accepted) { + + //... + + } + } return IgnoreNothing; diff -r 939701b848e5 -r 6d7dad48b13c src/hgignoredialog.h --- a/src/hgignoredialog.h Wed Jun 15 16:32:21 2011 +0100 +++ b/src/hgignoredialog.h Thu Jun 16 14:32:35 2011 +0100 @@ -32,8 +32,18 @@ IgnoreAllFilesOfGivenSuffixes }; - static IgnoreType confirmIgnore(QStringList files, QStringList suffixes); + static IgnoreType confirmIgnore(QWidget *parent, + QStringList files, QStringList suffixes); +private: + HgIgnoreDialog(QWidget *parent, + QString title, + QString introText, + QString question, + QStringList options, + QString okButtonText); + + }; #endif diff -r 939701b848e5 -r 6d7dad48b13c src/mainwindow.cpp --- a/src/mainwindow.cpp Wed Jun 15 16:32:21 2011 +0100 +++ b/src/mainwindow.cpp Thu Jun 16 14:32:35 2011 +0100 @@ -614,7 +614,8 @@ } HgIgnoreDialog::IgnoreType itype = - HgIgnoreDialog::confirmIgnore(files, QStringList::fromSet(suffixes)); + HgIgnoreDialog::confirmIgnore + (this, files, QStringList::fromSet(suffixes));