#include <QChar>
#include "dialog.h"
+#include "utils.h"
#include <math.h>
#include <errno.h>
FileOperator::FileOperator(QWidget *parent) : QWidget(parent) {
QHBoxLayout *layout = new QHBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
- layout->setSpacing(0);
+ layout->setSpacing(1);
setLayout(layout);
qRegisterMetaType<QFileInfo>("QFileInfo");
+ loadOperationIcons(palette(), "delete_small", deleteIcon, inverseDeleteIcon);
+ loadOperationIcons(palette(), "copy_small", copyIcon, inverseCopyIcon);
+ loadOperationIcons(palette(), "move_small", moveIcon, inverseMoveIcon);
}
);
if(confirm == QMessageBox::Yes) {
- caterNewThread(new DeleteThread(files));
+ DeleteThread *t = new DeleteThread(files);
+ t->progressBar->setIcons(deleteIcon, inverseDeleteIcon);
+ caterNewThread(t);
}
}
);
if(confirm == QMessageBox::Yes) {
- caterNewThread(new CopyThread(files, destination));
+ CopyThread *t = new CopyThread(files, destination);
+ t->progressBar->setIcons(copyIcon, inverseCopyIcon);
+ t->progressBar->fromText = shortenPath(files[0].absolutePath());
+ t->progressBar->toText = FileOperator::shortenPath(destination.absolutePath());
+ caterNewThread(t);
}
}
);
if(confirm == QMessageBox::Yes) {
- caterNewThread(new MoveThread(files, destination));
+ MoveThread *t = new MoveThread(files, destination);
+ t->progressBar->setIcons(moveIcon, inverseMoveIcon);
+ t->progressBar->fromText = shortenPath(files[0].absolutePath());
+ t->progressBar->toText = shortenPath(destination.absolutePath());
+ caterNewThread(t);
}
}
}
+void FileOperator::updateMainText(FileManipulatorThread* manipulator, const QString &text) {
+ manipulator->progressBar->mainText = text;
+ manipulator->progressBar->mainText.remove(0, manipulator->progressBar->fromText.size() + 1);
+ manipulator->progressBar->repaint();
+}
+
+
void FileOperator::showPaused(FileManipulatorThread* manipulator) {
- manipulator->setText(0);
+ manipulator->progressBar->paused = true;
+ manipulator->progressBar->repaint();
}
void FileOperator::togglePauseOperation(FileManipulatorThread* manipulator) {
if (manipulator->pause) {
manipulator->pause = false;
+ manipulator->progressBar->paused = false;
+ manipulator->progressBar->repaint();
manipulator->wake();
} else {
manipulator->pause = true;
if(confirm == QMessageBox::Yes) {
manipulator->abort = true;
manipulator->pause = false;
- manipulator->setText(0);
manipulator->wake();
}
}
this, SLOT(setBarSize(FileManipulatorThread*, unsigned int)));
connect(thread, SIGNAL(updateProgress(FileManipulatorThread*, int)),
this, SLOT(updateProgress(FileManipulatorThread*, int)));
+ connect(thread, SIGNAL(updateFileName(FileManipulatorThread*, QString)),
+ this, SLOT(updateMainText(FileManipulatorThread*, QString)));
connect(thread, SIGNAL(operationPaused(FileManipulatorThread*)),
this, SLOT(showPaused(FileManipulatorThread*)));
connect(thread->progressBar, SIGNAL(abortOperation(FileManipulatorThread*)),
this, SLOT(abortOperation(FileManipulatorThread*)));
- thread->setText(0);
layout()->addWidget(thread->progressBar);
thread->start(QThread::LowestPriority);
}
void FileManipulatorThread::updateFile(const QString &name) {
fileValue = 0;
- fileName = FileOperator::shortenPath(name);
- emit updateProgress(this, 0);
+ emit updateFileName(this, FileOperator::shortenPath(name));
}
<< ") by " << value << std::endl;
}
- if (!fileName.size()) {
- if (pause) {
- progressBar->setFormat(tr("Gathering information...") + " (" + tr("paused") + ")");
- } else {
- progressBar->setFormat(tr("Gathering information..."));
- }
- return;
- }
-
time_t now = time(0);
if (lastTimeUpdate < now) {
lastTimeUpdate = now;
}
}
- QString newFormat = barText.arg(fileName) + "\n%p% ETA " + timeBuf;
- if (pause) newFormat += " (" + tr("paused") + ")";
- progressBar->setFormat(newFormat);
+ progressBar->setFormat(QString("%p% ") + timeBuf);
progressBar->setValue(progressBar->value() + value);
}