Chris@125: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@125: Chris@125: /* Chris@125: EasyMercurial Chris@125: Chris@125: Based on hgExplorer by Jari Korhonen Chris@125: Copyright (c) 2010 Jari Korhonen Chris@244: Copyright (c) 2011 Chris Cannam Chris@244: Copyright (c) 2011 Queen Mary, University of London Chris@125: Chris@125: This program is free software; you can redistribute it and/or Chris@125: modify it under the terms of the GNU General Public License as Chris@125: published by the Free Software Foundation; either version 2 of the Chris@125: License, or (at your option) any later version. See the file Chris@125: COPYING included with this distribution for more information. Chris@125: */ Chris@125: Chris@125: #include "incomingdialog.h" Chris@125: #include "changeset.h" Chris@125: #include "common.h" Chris@125: Chris@125: #include Chris@125: #include Chris@125: #include Chris@125: #include Chris@125: #include Chris@125: #include Chris@125: Chris@125: IncomingDialog::IncomingDialog(QWidget *w, QString text) : Chris@125: QDialog(w) Chris@125: { Chris@125: QString head; Chris@125: QString body; Chris@125: bool scroll; Chris@125: Chris@125: Changesets csets = Changeset::parseChangesets(text); Chris@125: if (csets.empty()) { Chris@125: head = tr("No changes waiting to pull"); Chris@125: if (text.trimmed() != "") { Chris@125: body = QString("

%1

%2") Chris@125: .arg(tr("The command output was:")) Chris@125: .arg(xmlEncode(text).replace("\n", "
")); Chris@125: } Chris@125: scroll = false; Chris@125: } else { Chris@125: head = tr("There are %n change(s) ready to pull", "", csets.size()); Chris@125: foreach (Changeset *cs, csets) { Chris@125: body += cs->formatHtml() + "

"; Chris@125: delete cs; Chris@125: } Chris@125: scroll = true; Chris@125: } Chris@125: Chris@125: QGridLayout *layout = new QGridLayout; Chris@125: setLayout(layout); Chris@125: Chris@125: QLabel *info = new QLabel; Chris@125: QStyle *style = qApp->style(); Chris@125: int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, this); Chris@125: info->setPixmap(style->standardIcon(QStyle::SP_MessageBoxInformation, 0, this) Chris@125: .pixmap(iconSize, iconSize)); Chris@125: layout->addWidget(info, 0, 0); Chris@125: Chris@125: QLabel *headLabel = new QLabel(QString("

%1

").arg(head)); Chris@125: layout->addWidget(headLabel, 0, 1); Chris@125: Chris@125: QLabel *textLabel = new QLabel(body); Chris@125: Chris@125: if (scroll) { Chris@125: QScrollArea *sa = new QScrollArea; Chris@125: layout->addWidget(sa, 1, 1); Chris@125: layout->setRowStretch(1, 20); Chris@125: sa->setWidget(textLabel); Chris@125: } else { Chris@125: layout->addWidget(textLabel, 1, 1); Chris@125: } Chris@125: Chris@125: QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok); Chris@125: connect(bb, SIGNAL(accepted()), this, SLOT(accept())); Chris@125: layout->addWidget(bb, 2, 0, 1, 2); Chris@125: } Chris@125: Chris@125: