comparison mainwindow.cpp @ 103:0bd32aedc6f6

* Start to use the confirm-comment dialog for commits; much work still needed
author Chris Cannam
date Wed, 24 Nov 2010 22:44:40 +0000
parents a5a2d74a83a7
children af314dd436d5
comparison
equal deleted inserted replaced
102:f70ccc15c9d0 103:0bd32aedc6f6
35 #include "multichoicedialog.h" 35 #include "multichoicedialog.h"
36 #include "startupdialog.h" 36 #include "startupdialog.h"
37 #include "colourset.h" 37 #include "colourset.h"
38 #include "debug.h" 38 #include "debug.h"
39 #include "logparser.h" 39 #include "logparser.h"
40 #include "confirmcommentdialog.h"
40 41
41 42
42 MainWindow::MainWindow() 43 MainWindow::MainWindow()
43 { 44 {
44 QString wndTitle; 45 QString wndTitle;
314 } 315 }
315 */ 316 */
316 } 317 }
317 } 318 }
318 319
319
320 bool MainWindow::getCommentOrTag(QString& commentOrTag,
321 QString question,
322 QString dlgTitle)
323 {
324 bool ok = false;
325 QString text = QInputDialog::getText(this, dlgTitle, question, QLineEdit::Normal, commentOrTag, &ok);
326 commentOrTag = text;
327 return ok;
328 }
329
330 void MainWindow::hgCommit() 320 void MainWindow::hgCommit()
331 { 321 {
332 //!!! Now that hg actions can be fired asynchronously (e.g. from 322 //!!! Now that hg actions can be fired asynchronously (e.g. from
333 // the filesystem modified callback) we _really_ need to be able to 323 // the filesystem modified callback) we _really_ need to be able to
334 // queue important actions rather than just ignore them if busy! 324 // queue important actions rather than just ignore them if busy!
335 325
336 if (runningAction == ACT_NONE) 326 if (runningAction == ACT_NONE)
337 { 327 {
338 QStringList params; 328 QStringList params;
339 QString comment; 329 QString comment;
340 330
341 if (getCommentOrTag(comment, tr("Comment:"), tr("Save (commit)"))) 331 QStringList files = hgTabs->getSelectedCommittableFiles();
342 { 332 if (files.empty()) files = hgTabs->getAllCommittableFiles();
333
334 if (ConfirmCommentDialog::confirmAndComment(this,
335 tr("Commit files"),
336 tr("About to commit the following files:"),
337 tr("About to commit %1 files."),
338 files,
339 comment)) {
340
343 //!!! do something more sensible when the comment is empty 341 //!!! do something more sensible when the comment is empty
344 // (i.e. tell the user about it?) 342 // (i.e. tell the user about it?)
345
346 QStringList files = hgTabs->getSelectedCommittableFiles();
347 343
348 if ((justMerged == false) && //!!! review usage of justMerged 344 if ((justMerged == false) && //!!! review usage of justMerged
349 !files.empty()) { 345 !files.empty()) {
350 // User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files) 346 // User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files)
351 params << "commit" << "--message" << comment << "--user" << getUserInfo() << "--" << files; 347 params << "commit" << "--message" << comment << "--user" << getUserInfo() << "--" << files;
382 if (runningAction == ACT_NONE) 378 if (runningAction == ACT_NONE)
383 { 379 {
384 QStringList params; 380 QStringList params;
385 QString tag; 381 QString tag;
386 382
387 if (getCommentOrTag(tag, tr("Tag:"), tr("Tag"))) 383 if (ConfirmCommentDialog::confirmAndComment(this,
388 { 384 tr("Tag"),
389 if (!tag.isEmpty()) 385 tr("Enter tag:"),
386 tag)) {
387 if (!tag.isEmpty()) //!!! do something better if it is empty
390 { 388 {
391 params << "tag" << "--user" << getUserInfo() << filterTag(tag); 389 params << "tag" << "--user" << getUserInfo() << filterTag(tag);
392 390
393 runner -> startHgCommand(workFolderPath, params); 391 runner -> startHgCommand(workFolderPath, params);
394 runningAction = ACT_TAG; 392 runningAction = ACT_TAG;