Changeset View
Changeset View
Standalone View
Standalone View
krusader/Dialogs/checksumdlg.cpp
Show All 17 Lines | |||||
18 | * * | 18 | * * | ||
19 | * You should have received a copy of the GNU General Public License * | 19 | * You should have received a copy of the GNU General Public License * | ||
20 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 20 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
21 | *****************************************************************************/ | 21 | *****************************************************************************/ | ||
22 | 22 | | |||
23 | #include "checksumdlg.h" | 23 | #include "checksumdlg.h" | ||
24 | 24 | | |||
25 | #include "../krglobal.h" | 25 | #include "../krglobal.h" | ||
26 | #include "../icon.h" | ||||
26 | #include "../krservices.h" | 27 | #include "../krservices.h" | ||
27 | #include "../krusader.h" | 28 | #include "../krusader.h" | ||
28 | #include "../GUI/krlistwidget.h" | 29 | #include "../GUI/krlistwidget.h" | ||
29 | #include "../GUI/krtreewidget.h" | 30 | #include "../GUI/krtreewidget.h" | ||
30 | 31 | | |||
31 | // QtCore | 32 | // QtCore | ||
32 | #include <QDirIterator> | 33 | #include <QDirIterator> | ||
33 | #include <QFile> | 34 | #include <QFile> | ||
34 | #include <QFileInfo> | 35 | #include <QFileInfo> | ||
35 | #include <QList> | 36 | #include <QList> | ||
36 | #include <QMap> | 37 | #include <QMap> | ||
37 | #include <QTextStream> | 38 | #include <QTextStream> | ||
38 | // QtWidgets | 39 | // QtWidgets | ||
39 | #include <QDialogButtonBox> | 40 | #include <QDialogButtonBox> | ||
40 | #include <QFileDialog> | 41 | #include <QFileDialog> | ||
41 | #include <QGridLayout> | 42 | #include <QGridLayout> | ||
42 | #include <QHBoxLayout> | 43 | #include <QHBoxLayout> | ||
43 | #include <QProgressBar> | 44 | #include <QProgressBar> | ||
44 | 45 | | |||
45 | #include <QtConcurrent/QtConcurrentRun> | 46 | #include <QtConcurrent/QtConcurrentRun> | ||
46 | 47 | | |||
47 | #include <KI18n/KLocalizedString> | 48 | #include <KI18n/KLocalizedString> | ||
48 | #include <KIOWidgets/KUrlRequester> | 49 | #include <KIOWidgets/KUrlRequester> | ||
49 | #include <KIconThemes/KIconLoader> | | |||
50 | #include <KWidgetsAddons/KMessageBox> | 50 | #include <KWidgetsAddons/KMessageBox> | ||
51 | 51 | | |||
52 | void Checksum::startCreationWizard(const QString &path, const QStringList &files) | 52 | void Checksum::startCreationWizard(const QString &path, const QStringList &files) | ||
53 | { | 53 | { | ||
54 | if (files.isEmpty()) | 54 | if (files.isEmpty()) | ||
55 | return; | 55 | return; | ||
56 | 56 | | |||
57 | QDialog *dialog = new CHECKSUM_::CreateWizard(path, files); | 57 | QDialog *dialog = new CHECKSUM_::CreateWizard(path, files); | ||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | |||||
189 | } | 189 | } | ||
190 | 190 | | |||
191 | QWizardPage *ChecksumWizard::createProgressPage(const QString &title) | 191 | QWizardPage *ChecksumWizard::createProgressPage(const QString &title) | ||
192 | { | 192 | { | ||
193 | QWizardPage *page = new QWizardPage; | 193 | QWizardPage *page = new QWizardPage; | ||
194 | 194 | | |||
195 | page->setTitle(title); | 195 | page->setTitle(title); | ||
196 | page->setPixmap(QWizard::LogoPixmap, | 196 | page->setPixmap(QWizard::LogoPixmap, | ||
197 | krLoader->loadIcon("process-working", KIconLoader::Desktop, 32)); | 197 | Icon("process-working").pixmap(32)); | ||
198 | page->setSubTitle(i18n("Please wait...")); | 198 | page->setSubTitle(i18n("Please wait...")); | ||
199 | 199 | | |||
200 | QVBoxLayout *mainLayout = new QVBoxLayout; | 200 | QVBoxLayout *mainLayout = new QVBoxLayout; | ||
201 | page->setLayout(mainLayout); | 201 | page->setLayout(mainLayout); | ||
202 | 202 | | |||
203 | // "busy" indicator | 203 | // "busy" indicator | ||
204 | QProgressBar *bar = new QProgressBar(); | 204 | QProgressBar *bar = new QProgressBar(); | ||
205 | bar->setRange(0,0); | 205 | bar->setRange(0,0); | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
262 | } | 262 | } | ||
263 | 263 | | |||
264 | QWizardPage *CreateWizard::createIntroPage() | 264 | QWizardPage *CreateWizard::createIntroPage() | ||
265 | { | 265 | { | ||
266 | QWizardPage *page = new QWizardPage; | 266 | QWizardPage *page = new QWizardPage; | ||
267 | 267 | | |||
268 | page->setTitle(i18n("Create Checksums")); | 268 | page->setTitle(i18n("Create Checksums")); | ||
269 | page->setPixmap(QWizard::LogoPixmap, | 269 | page->setPixmap(QWizard::LogoPixmap, | ||
270 | krLoader->loadIcon("document-edit-sign", KIconLoader::Desktop, 32)); | 270 | Icon("document-edit-sign").pixmap(32)); | ||
271 | page->setSubTitle(i18n("About to calculate checksum for the following files or directories:")); | 271 | page->setSubTitle(i18n("About to calculate checksum for the following files or directories:")); | ||
272 | 272 | | |||
273 | QVBoxLayout *mainLayout = new QVBoxLayout; | 273 | QVBoxLayout *mainLayout = new QVBoxLayout; | ||
274 | page->setLayout(mainLayout); | 274 | page->setLayout(mainLayout); | ||
275 | 275 | | |||
276 | // file list | 276 | // file list | ||
277 | KrListWidget *listWidget = new KrListWidget; | 277 | KrListWidget *listWidget = new KrListWidget; | ||
278 | listWidget->addItems(m_fileNames); | 278 | listWidget->addItems(m_fileNames); | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 359 | { | |||
360 | // hash tools display errors into stderr, so we'll use that to determine the result of the job | 360 | // hash tools display errors into stderr, so we'll use that to determine the result of the job | ||
361 | const QStringList outputLines = m_process->stdOutput(); | 361 | const QStringList outputLines = m_process->stdOutput(); | ||
362 | const QStringList errorLines = m_process->errOutput(); | 362 | const QStringList errorLines = m_process->errOutput(); | ||
363 | bool errors = !errorLines.isEmpty(); | 363 | bool errors = !errorLines.isEmpty(); | ||
364 | bool successes = !outputLines.isEmpty(); | 364 | bool successes = !outputLines.isEmpty(); | ||
365 | 365 | | |||
366 | QWizardPage *page = currentPage(); | 366 | QWizardPage *page = currentPage(); | ||
367 | page->setPixmap(QWizard::LogoPixmap, | 367 | page->setPixmap(QWizard::LogoPixmap, | ||
368 | krLoader->loadIcon(errors || !successes ? "dialog-error" : "dialog-information", | 368 | Icon(errors || !successes ? "dialog-error" : "dialog-information").pixmap(32)); | ||
369 | KIconLoader::Desktop, 32)); | | |||
370 | page->setSubTitle(errors || !successes ? | 369 | page->setSubTitle(errors || !successes ? | ||
371 | i18n("Errors were detected while creating the checksums") : | 370 | i18n("Errors were detected while creating the checksums") : | ||
372 | i18n("Checksums were created successfully")); | 371 | i18n("Checksums were created successfully")); | ||
373 | 372 | | |||
374 | m_hashesTreeWidget->clear(); | 373 | m_hashesTreeWidget->clear(); | ||
375 | m_hashesTreeWidget->setVisible(successes); | 374 | m_hashesTreeWidget->setVisible(successes); | ||
376 | if (successes) { | 375 | if (successes) { | ||
377 | for (const QString line : outputLines) | 376 | for (const QString line : outputLines) | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
476 | } | 475 | } | ||
477 | 476 | | |||
478 | QWizardPage *VerifyWizard::createIntroPage() | 477 | QWizardPage *VerifyWizard::createIntroPage() | ||
479 | { | 478 | { | ||
480 | QWizardPage *page = new QWizardPage; | 479 | QWizardPage *page = new QWizardPage; | ||
481 | 480 | | |||
482 | page->setTitle(i18n("Verify Checksum File")); | 481 | page->setTitle(i18n("Verify Checksum File")); | ||
483 | page->setPixmap(QWizard::LogoPixmap, | 482 | page->setPixmap(QWizard::LogoPixmap, | ||
484 | krLoader->loadIcon("document-edit-verify", KIconLoader::Desktop, 32)); | 483 | Icon("document-edit-verify").pixmap(32)); | ||
485 | page->setSubTitle(i18n("About to verify the following checksum file")); | 484 | page->setSubTitle(i18n("About to verify the following checksum file")); | ||
486 | 485 | | |||
487 | QVBoxLayout *mainLayout = new QVBoxLayout; | 486 | QVBoxLayout *mainLayout = new QVBoxLayout; | ||
488 | page->setLayout(mainLayout); | 487 | page->setLayout(mainLayout); | ||
489 | 488 | | |||
490 | // checksum file | 489 | // checksum file | ||
491 | QHBoxLayout *hLayout = new QHBoxLayout; | 490 | QHBoxLayout *hLayout = new QHBoxLayout; | ||
492 | QLabel *checksumFileLabel = new QLabel(i18n("Checksum file:")); | 491 | QLabel *checksumFileLabel = new QLabel(i18n("Checksum file:")); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
552 | 551 | | |||
553 | void VerifyWizard::onResultPage() | 552 | void VerifyWizard::onResultPage() | ||
554 | { | 553 | { | ||
555 | // better not only trust error output | 554 | // better not only trust error output | ||
556 | const bool errors = m_process->exitCode() != 0 || !m_process->errOutput().isEmpty(); | 555 | const bool errors = m_process->exitCode() != 0 || !m_process->errOutput().isEmpty(); | ||
557 | 556 | | |||
558 | QWizardPage *page = currentPage(); | 557 | QWizardPage *page = currentPage(); | ||
559 | page->setPixmap(QWizard::LogoPixmap, | 558 | page->setPixmap(QWizard::LogoPixmap, | ||
560 | krLoader->loadIcon(errors ? "dialog-error" : "dialog-information", | 559 | Icon(errors ? "dialog-error" : "dialog-information").pixmap(32)); | ||
561 | KIconLoader::Desktop, 32)); | | |||
562 | page->setSubTitle(errors ? i18n("Errors were detected while verifying the checksums") : | 560 | page->setSubTitle(errors ? i18n("Errors were detected while verifying the checksums") : | ||
563 | i18n("Checksums were verified successfully")); | 561 | i18n("Checksums were verified successfully")); | ||
564 | 562 | | |||
565 | // print everything, errors first | 563 | // print everything, errors first | ||
566 | m_outputListWidget->clear(); | 564 | m_outputListWidget->clear(); | ||
567 | m_outputListWidget->addItems(m_process->errOutput() + m_process->stdOutput()); | 565 | m_outputListWidget->addItems(m_process->errOutput() + m_process->stdOutput()); | ||
568 | 566 | | |||
569 | button(QWizard::FinishButton)->setEnabled(!errors); | 567 | button(QWizard::FinishButton)->setEnabled(!errors); | ||
Show All 9 Lines |