Mercurial > hg > easyhg
comparison src/incomingdialog.cpp @ 370:b9c153e00e84
Move source files to src/
author | Chris Cannam |
---|---|
date | Thu, 24 Mar 2011 10:27:51 +0000 |
parents | incomingdialog.cpp@5e4a10af7945 |
children | 533519ebc0cb |
comparison
equal
deleted
inserted
replaced
369:19cce6d2c470 | 370:b9c153e00e84 |
---|---|
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) 2011 Chris Cannam | |
9 Copyright (c) 2011 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 "incomingdialog.h" | |
19 #include "changeset.h" | |
20 #include "common.h" | |
21 | |
22 #include <QScrollArea> | |
23 #include <QApplication> | |
24 #include <QDialogButtonBox> | |
25 #include <QLabel> | |
26 #include <QGridLayout> | |
27 #include <QStyle> | |
28 | |
29 IncomingDialog::IncomingDialog(QWidget *w, QString text) : | |
30 QDialog(w) | |
31 { | |
32 QString head; | |
33 QString body; | |
34 bool scroll; | |
35 | |
36 Changesets csets = Changeset::parseChangesets(text); | |
37 if (csets.empty()) { | |
38 head = tr("No changes waiting to pull"); | |
39 if (text.trimmed() != "") { | |
40 body = QString("<p>%1</p><code>%2</code>") | |
41 .arg(tr("The command output was:")) | |
42 .arg(xmlEncode(text).replace("\n", "<br>")); | |
43 } else { | |
44 body = tr("<qt>Your local repository already contains all changes found in the remote repository.</qt>"); | |
45 } | |
46 scroll = false; | |
47 } else { | |
48 head = tr("There are %n change(s) ready to pull", "", csets.size()); | |
49 foreach (Changeset *cs, csets) { | |
50 body += cs->formatHtml() + "<p>"; | |
51 delete cs; | |
52 } | |
53 scroll = true; | |
54 } | |
55 | |
56 QGridLayout *layout = new QGridLayout; | |
57 setLayout(layout); | |
58 | |
59 QLabel *info = new QLabel; | |
60 QStyle *style = qApp->style(); | |
61 int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, this); | |
62 info->setPixmap(style->standardIcon(QStyle::SP_MessageBoxInformation, 0, this) | |
63 .pixmap(iconSize, iconSize)); | |
64 layout->addWidget(info, 0, 0, 2, 1); | |
65 | |
66 QLabel *headLabel = new QLabel(QString("<qt><h3>%1</h3></qt>").arg(head)); | |
67 layout->addWidget(headLabel, 0, 1); | |
68 | |
69 QLabel *textLabel = new QLabel(body); | |
70 if (csets.empty()) textLabel->setWordWrap(true); | |
71 | |
72 if (scroll) { | |
73 QScrollArea *sa = new QScrollArea; | |
74 layout->addWidget(sa, 1, 1); | |
75 layout->setRowStretch(1, 20); | |
76 sa->setWidget(textLabel); | |
77 } else { | |
78 layout->addWidget(textLabel, 1, 1); | |
79 } | |
80 | |
81 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok); | |
82 connect(bb, SIGNAL(accepted()), this, SLOT(accept())); | |
83 layout->addWidget(bb, 2, 0, 1, 2); | |
84 | |
85 layout->setColumnStretch(1, 20); | |
86 setMinimumWidth(400); | |
87 } | |
88 | |
89 |