display buttons in overwrite dialog in 2 columns
[case] / src / fileoperator.cpp
index 67c5204..fc826b9 100644 (file)
@@ -23,6 +23,8 @@
 #include <QHBoxLayout>
 #include <QChar>
 
+#include "dialog.h"
+
 #include <math.h>
 #include <errno.h>
 #include <iostream>
@@ -218,40 +220,40 @@ void FileOperator::showOverwritePrompt(
     const QString &fileName,
     const bool dirOverDir)
 {
-    QMessageBox msgBox;
-    msgBox.addButton(QMessageBox::Cancel);
-    QAbstractButton *yesButton = msgBox.addButton(QMessageBox::Yes);
-    QAbstractButton *yesToAllButton = msgBox.addButton(QMessageBox::YesToAll);
-    QAbstractButton *noButton = msgBox.addButton(QMessageBox::No);
-    QAbstractButton *noToAllButton = msgBox.addButton(QMessageBox::NoToAll);
-    QAbstractButton *abortButton = msgBox.addButton(tr("Abort"), QMessageBox::DestructiveRole);
+    Dialog msgBox;
+    msgBox.addButtonFirst(QDialogButtonBox::Cancel);
+    QAbstractButton *yesButton = msgBox.addButtonFirst(QDialogButtonBox::Yes);
+    QAbstractButton *yesToAllButton = msgBox.addButtonFirst(QDialogButtonBox::YesToAll);
+    QAbstractButton *noButton = msgBox.addButtonSecond(QDialogButtonBox::No);
+    QAbstractButton *noToAllButton = msgBox.addButtonSecond(QDialogButtonBox::NoToAll);
+    QAbstractButton *abortButton = msgBox.addButtonSecond(tr("Abort"), QDialogButtonBox::DestructiveRole);
     QAbstractButton *askButton = 0;
     QAbstractButton *skipDirButton = 0;
 
     if (dirOverDir) {
         msgBox.setText(tr("Directory %1 already exists. Overwrite the files inside?")
             .arg(FileOperator::shortenPath(fileName)));
-        askButton = msgBox.addButton(tr("Ask"), QMessageBox::AcceptRole);
-        skipDirButton = msgBox.addButton(tr("Skip"), QMessageBox::NoRole);
+        askButton = msgBox.addButtonFirst(tr("Ask"), QDialogButtonBox::AcceptRole);
+        skipDirButton = msgBox.addButtonSecond(tr("Skip"), QDialogButtonBox::NoRole);
     } else {
         msgBox.setText(tr("File %1 already exists. Overwrite?").arg(FileOperator::shortenPath(fileName)));
     }
 
     msgBox.exec();
 
-    if (msgBox.clickedButton() == abortButton) {
+    if (msgBox.clickedButton == abortButton) {
         manipulator->setResponse(ABORT);
-    } else if (msgBox.clickedButton() == yesButton) {
+    } else if (msgBox.clickedButton == yesButton) {
         manipulator->setResponse(OVERWRITE);
-    } else if (msgBox.clickedButton() == yesToAllButton) {
+    } else if (msgBox.clickedButton == yesToAllButton) {
         manipulator->setResponse(OVERWRITE, true);
-    } else if (msgBox.clickedButton() == noButton) {
+    } else if (msgBox.clickedButton == noButton) {
         manipulator->setResponse(KEEP);
-    } else if (msgBox.clickedButton() == noToAllButton) {
+    } else if (msgBox.clickedButton == noToAllButton) {
         manipulator->setResponse(KEEP, true);
-    } else if (msgBox.clickedButton() == askButton) {
+    } else if (msgBox.clickedButton == askButton) {
         manipulator->setResponse(NONE, true);
-    } else if (msgBox.clickedButton() == skipDirButton) {
+    } else if (msgBox.clickedButton == skipDirButton) {
         manipulator->setResponse(SKIP_DIR);
     }
 }
@@ -327,7 +329,7 @@ FileManipulatorThread::FileManipulatorThread(const QFileInfoList files, QDir des
 
 
 FileManipulatorThread::~FileManipulatorThread() {
-    if (progressBar->value() < progressBar->maximum()) {
+    if (!abort && progressBar->value() < progressBar->maximum()) {
         std::cout << "WARNING: deleting a progressbar which's value " << progressBar->value() <<
             " has not reached maximum of " << progressBar->maximum() << std::endl;
     }