changeset 275:1244dc3107cb more_information_dialog

* Some work on separating out the "more information" component from dialog messages. Will need work on layouts
author Chris Cannam
date Mon, 31 Jan 2011 17:23:10 +0000
parents cc95394e2392
children c0c254f67346
files confirmcommentdialog.cpp easyhg.pro mainwindow.cpp mainwindow.h moreinformationdialog.cpp moreinformationdialog.h
diffstat 6 files changed, 127 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/confirmcommentdialog.cpp	Tue Jan 25 16:41:40 2011 +0000
+++ b/confirmcommentdialog.cpp	Mon Jan 31 17:23:10 2011 +0000
@@ -51,8 +51,10 @@
                                                   QDialogButtonBox::Cancel);
     layout->addWidget(bbox, 2, 0);
     m_ok = bbox->button(QDialogButtonBox::Ok);
+    m_ok->setDefault(true);
     m_ok->setEnabled(initialComment != "");
     m_ok->setText(okButtonText);
+    bbox->button(QDialogButtonBox::Cancel)->setAutoDefault(false);
 
     connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
     connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
@@ -93,6 +95,7 @@
 
     QPushButton *ok = box.addButton(QMessageBox::Ok);
     ok->setText(okButtonText);
+    box.setDefaultButton(QMessageBox::Ok);
     if (box.exec() == -1) return false;
     return box.standardButton(box.clickedButton()) == QMessageBox::Ok;
 }
@@ -110,6 +113,7 @@
 
     QPushButton *ok = box.addButton(QMessageBox::Ok);
     ok->setText(okButtonText);
+    box.setDefaultButton(QMessageBox::Cancel);
     if (box.exec() == -1) return false;
     return box.standardButton(box.clickedButton()) == QMessageBox::Ok;
 }
--- a/easyhg.pro	Tue Jan 25 16:41:40 2011 +0000
+++ b/easyhg.pro	Mon Jan 31 17:23:10 2011 +0000
@@ -49,7 +49,8 @@
     incomingdialog.h \
     uncommitteditem.h \
     settingsdialog.h \
-    clickablelabel.h
+    clickablelabel.h \
+    moreinformationdialog.h
 SOURCES = main.cpp \
     mainwindow.cpp \
     hgtabwidget.cpp \
@@ -79,7 +80,8 @@
     changesetscene.cpp \
     incomingdialog.cpp \
     uncommitteditem.cpp \
-    settingsdialog.cpp
+    settingsdialog.cpp \
+    moreinformationdialog.cpp
 
 macx-* {
     SOURCES += common_osx.mm
--- a/mainwindow.cpp	Tue Jan 25 16:41:40 2011 +0000
+++ b/mainwindow.cpp	Mon Jan 31 17:23:10 2011 +0000
@@ -43,6 +43,7 @@
 #include "confirmcommentdialog.h"
 #include "incomingdialog.h"
 #include "settingsdialog.h"
+#include "moreinformationdialog.h"
 #include "version.h"
 
 
@@ -1529,6 +1530,11 @@
     }
 }
 
+QString MainWindow::format1(QString head)
+{
+    return QString("<qt><h3>%1</h3></qt>").arg(head);
+}    
+
 QString MainWindow::format3(QString head, QString intro, QString code)
 {
     code = xmlEncode(code).replace("\n", "<br>")
@@ -1596,12 +1602,19 @@
     } else {
         report = tr("Pull complete");
     }
+
+    runner->hide();
+
+    MoreInformationDialog::information(this, tr("Pull complete"),
+                                       format1(report), output);
+
+/*!!!
     report = format3(report, tr("The pull command output was:"), output);
-    runner->hide();
-
-    //!!! and something about updating
+
+    //!!! and something about updating?
 
     QMessageBox::information(this, "Pull complete", report);
+*/
 }
 
 void MainWindow::reportNewRemoteHeads(QString output)
--- a/mainwindow.h	Tue Jan 25 16:41:40 2011 +0000
+++ b/mainwindow.h	Mon Jan 31 17:23:10 2011 +0000
@@ -154,6 +154,7 @@
     void showPullResult(QString);
     void showPushResult(QString);
     int extractChangeCount(QString);
+    QString format1(QString);
     QString format3(QString, QString, QString);
 
     void clearState();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/moreinformationdialog.cpp	Mon Jan 31 17:23:10 2011 +0000
@@ -0,0 +1,64 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    EasyMercurial
+
+    Based on hgExplorer by Jari Korhonen
+    Copyright (c) 2010 Jari Korhonen
+    Copyright (c) 2011 Chris Cannam
+    Copyright (c) 2011 Queen Mary, University of London
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "moreinformationdialog.h"
+
+#include <QMessageBox>
+
+void
+MoreInformationDialog::critical(QWidget *parent, QString title,
+				QString text, QString more)
+{
+    QMessageBox mb(QMessageBox::Critical,
+		   title,
+		   text,
+		   QMessageBox::Ok,
+		   parent,
+		   Qt::Dialog);
+    mb.setDetailedText(more);
+    mb.exec();
+}
+
+void
+MoreInformationDialog::information(QWidget *parent, QString title,
+				   QString text, QString more)
+{
+    QMessageBox mb(QMessageBox::Information,
+		   title,
+		   text,
+		   QMessageBox::Ok,
+		   parent,
+		   Qt::Dialog);
+    mb.setDefaultButton(QMessageBox::Ok);
+    mb.setDetailedText(more);
+    mb.exec();
+}
+
+void
+MoreInformationDialog::warning(QWidget *parent, QString title,
+			       QString text, QString more)
+{
+    QMessageBox mb(QMessageBox::Warning,
+		   title,
+		   text,
+		   QMessageBox::Ok,
+		   parent,
+		   Qt::Dialog);
+    mb.setDetailedText(more);
+    mb.exec();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/moreinformationdialog.h	Mon Jan 31 17:23:10 2011 +0000
@@ -0,0 +1,38 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    EasyMercurial
+
+    Based on hgExplorer by Jari Korhonen
+    Copyright (c) 2010 Jari Korhonen
+    Copyright (c) 2011 Chris Cannam
+    Copyright (c) 2011 Queen Mary, University of London
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef MORE_INFORMATION_DIALOG_H
+#define MORE_INFORMATION_DIALOG_H
+
+#include <QString>
+
+class QWidget;
+
+/**
+ * Provide methods like the QMessageBox static methods, to call up
+ * dialogs with "More information" buttons in them
+ */
+
+class MoreInformationDialog
+{
+public:
+    static void critical(QWidget *parent, QString title, QString text, QString more);
+    static void information(QWidget *parent, QString title, QString text, QString more);
+    static void warning(QWidget *parent, QString title, QString text, QString more);
+};
+
+#endif