Changeset View
Changeset View
Standalone View
Standalone View
krusader/Dialogs/checksumdlg.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
67 | namespace CHECKSUM_ { | 67 | namespace CHECKSUM_ { | ||
68 | 68 | | |||
69 | bool stopListFiles; | 69 | bool stopListFiles; | ||
70 | // async operation invoked by QtConcurrent::run in creation wizard | 70 | // async operation invoked by QtConcurrent::run in creation wizard | ||
71 | QStringList listFiles(const QString &path, const QStringList &fileNames) | 71 | QStringList listFiles(const QString &path, const QStringList &fileNames) | ||
72 | { | 72 | { | ||
73 | const QDir baseDir(path); | 73 | const QDir baseDir(path); | ||
74 | QStringList allFiles; | 74 | QStringList allFiles; | ||
75 | for (const QString fileName : fileNames) { | 75 | for (const QString& fileName : fileNames) { | ||
76 | if (stopListFiles) | 76 | if (stopListFiles) | ||
77 | return QStringList(); | 77 | return QStringList(); | ||
78 | 78 | | |||
79 | QDir subDir = QDir(baseDir.filePath(fileName)); | 79 | QDir subDir = QDir(baseDir.filePath(fileName)); | ||
80 | if (subDir.exists()) { | 80 | if (subDir.exists()) { | ||
81 | subDir.setFilter(QDir::Files); | 81 | subDir.setFilter(QDir::Files); | ||
82 | QDirIterator it(subDir, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks); | 82 | QDirIterator it(subDir, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks); | ||
83 | while (it.hasNext()) { | 83 | while (it.hasNext()) { | ||
Show All 27 Lines | 110 | #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) | |||
111 | connect(this, &ChecksumProcess::errorOccurred, this, &ChecksumProcess::slotError); | 111 | connect(this, &ChecksumProcess::errorOccurred, this, &ChecksumProcess::slotError); | ||
112 | #endif | 112 | #endif | ||
113 | connect(this, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), | 113 | connect(this, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), | ||
114 | this, &ChecksumProcess::slotFinished); | 114 | this, &ChecksumProcess::slotFinished); | ||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | ChecksumProcess::~ChecksumProcess() | 117 | ChecksumProcess::~ChecksumProcess() | ||
118 | { | 118 | { | ||
119 | disconnect(this, 0, this, 0); // QProcess emits finished() on destruction | 119 | disconnect(this, nullptr, this, nullptr); // QProcess emits finished() on destruction | ||
120 | close(); | 120 | close(); | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | void ChecksumProcess::slotError(QProcess::ProcessError error) | 123 | void ChecksumProcess::slotError(QProcess::ProcessError error) | ||
124 | { | 124 | { | ||
125 | if (error == QProcess::FailedToStart) { | 125 | if (error == QProcess::FailedToStart) { | ||
126 | KMessageBox::error(0, i18n("<qt>Could not start <b>%1</b>.</qt>", program().join(" "))); | 126 | KMessageBox::error(nullptr, i18n("<qt>Could not start <b>%1</b>.</qt>", program().join(" "))); | ||
127 | } | 127 | } | ||
128 | } | 128 | } | ||
129 | 129 | | |||
130 | void ChecksumProcess::slotFinished(int, QProcess::ExitStatus exitStatus) | 130 | void ChecksumProcess::slotFinished(int, QProcess::ExitStatus exitStatus) | ||
131 | { | 131 | { | ||
132 | if (exitStatus != QProcess::NormalExit) { | 132 | if (exitStatus != QProcess::NormalExit) { | ||
133 | KMessageBox::error(0, i18n("<qt>There was an error while running <b>%1</b>.</qt>", | 133 | KMessageBox::error(nullptr, i18n("<qt>There was an error while running <b>%1</b>.</qt>", | ||
134 | program().join(" "))); | 134 | program().join(" "))); | ||
135 | return; | 135 | return; | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | // parse result files | 138 | // parse result files | ||
139 | if (!KrServices::fileToStringList(&m_tmpOutFile, m_outputLines) || | 139 | if (!KrServices::fileToStringList(&m_tmpOutFile, m_outputLines) || | ||
140 | !KrServices::fileToStringList(&m_tmpErrFile, m_errorLines)) { | 140 | !KrServices::fileToStringList(&m_tmpErrFile, m_errorLines)) { | ||
141 | KMessageBox::error(0, i18n("Error reading stdout or stderr")); | 141 | KMessageBox::error(nullptr, i18n("Error reading stdout or stderr")); | ||
142 | return; | 142 | return; | ||
143 | } | 143 | } | ||
144 | emit resultReady(); | 144 | emit resultReady(); | ||
145 | } | 145 | } | ||
146 | 146 | | |||
147 | // ------------- Generic Checksum Wizard | 147 | // ------------- Generic Checksum Wizard | ||
148 | 148 | | |||
149 | ChecksumWizard::ChecksumWizard(const QString &path) : QWizard(krApp), m_path(path), m_process(0) | 149 | ChecksumWizard::ChecksumWizard(const QString &path) : QWizard(krApp), m_path(path), m_process(nullptr) | ||
150 | { | 150 | { | ||
151 | setAttribute(Qt::WA_DeleteOnClose); | 151 | setAttribute(Qt::WA_DeleteOnClose); | ||
152 | 152 | | |||
153 | // init the dictionary - pity it has to be manually | 153 | // init the dictionary - pity it has to be manually | ||
154 | m_checksumTools.insert("md5", "md5sum"); | 154 | m_checksumTools.insert("md5", "md5sum"); | ||
155 | m_checksumTools.insert("sha1", "sha1sum"); | 155 | m_checksumTools.insert("sha1", "sha1sum"); | ||
156 | m_checksumTools.insert("sha256", "sha256sum"); | 156 | m_checksumTools.insert("sha256", "sha256sum"); | ||
157 | m_checksumTools.insert("sha224", "sha224sum"); | 157 | m_checksumTools.insert("sha224", "sha224sum"); | ||
Show All 13 Lines | |||||
171 | void ChecksumWizard::slotCurrentIdChanged(int id) | 171 | void ChecksumWizard::slotCurrentIdChanged(int id) | ||
172 | { | 172 | { | ||
173 | if (id == m_introId) { | 173 | if (id == m_introId) { | ||
174 | onIntroPage(); | 174 | onIntroPage(); | ||
175 | } else if (id == m_progressId) { | 175 | } else if (id == m_progressId) { | ||
176 | if (m_process) { | 176 | if (m_process) { | ||
177 | // we are coming from the result page; | 177 | // we are coming from the result page; | ||
178 | delete m_process; | 178 | delete m_process; | ||
179 | m_process = 0; | 179 | m_process = nullptr; | ||
180 | restart(); | 180 | restart(); | ||
181 | } else { | 181 | } else { | ||
182 | button(QWizard::BackButton)->hide(); | 182 | button(QWizard::BackButton)->hide(); | ||
183 | button(QWizard::NextButton)->hide(); | 183 | button(QWizard::NextButton)->hide(); | ||
184 | onProgressPage(); | 184 | onProgressPage(); | ||
185 | } | 185 | } | ||
186 | } else if (id == m_resultId) { | 186 | } else if (id == m_resultId) { | ||
187 | onResultPage(); | 187 | onResultPage(); | ||
188 | } | 188 | } | ||
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 | auto *page = new QWizardPage; | ||
194 | 194 | | |||
195 | page->setTitle(title); | 195 | page->setTitle(title); | ||
196 | page->setPixmap(QWizard::LogoPixmap, | 196 | page->setPixmap(QWizard::LogoPixmap, | ||
197 | Icon("process-working").pixmap(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 | auto *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 | auto *bar = new QProgressBar(); | ||
205 | bar->setRange(0,0); | 205 | bar->setRange(0,0); | ||
206 | 206 | | |||
207 | mainLayout->addWidget(bar); | 207 | mainLayout->addWidget(bar); | ||
208 | 208 | | |||
209 | return page; | 209 | return page; | ||
210 | } | 210 | } | ||
211 | 211 | | |||
212 | bool ChecksumWizard::checkExists(const QString type) | 212 | bool ChecksumWizard::checkExists(const QString& type) | ||
213 | { | 213 | { | ||
214 | if (!KrServices::cmdExist(m_checksumTools[type])) { | 214 | if (!KrServices::cmdExist(m_checksumTools[type])) { | ||
215 | KMessageBox::error( | 215 | KMessageBox::error( | ||
216 | this, i18n("<qt>Krusader cannot find a checksum tool that handles %1 on your system. " | 216 | this, i18n("<qt>Krusader cannot find a checksum tool that handles %1 on your system. " | ||
217 | "Please check the <b>Dependencies</b> page in Krusader's settings.</qt>", | 217 | "Please check the <b>Dependencies</b> page in Krusader's settings.</qt>", | ||
218 | type)); | 218 | type)); | ||
219 | return false; | 219 | return false; | ||
220 | } | 220 | } | ||
221 | return true; | 221 | return true; | ||
222 | } | 222 | } | ||
223 | 223 | | |||
224 | void ChecksumWizard::runProcess(const QString &type, const QStringList &args) | 224 | void ChecksumWizard::runProcess(const QString &type, const QStringList &args) | ||
225 | { | 225 | { | ||
226 | Q_ASSERT(m_process == 0); | 226 | Q_ASSERT(m_process == nullptr); | ||
227 | 227 | | |||
228 | m_process = new ChecksumProcess(this, m_path); | 228 | m_process = new ChecksumProcess(this, m_path); | ||
229 | m_process->setProgram(KrServices::fullPathName(m_checksumTools[type]), args); | 229 | m_process->setProgram(KrServices::fullPathName(m_checksumTools[type]), args); | ||
230 | // show next page (with results) (only) when process is done | 230 | // show next page (with results) (only) when process is done | ||
231 | connect(m_process, &ChecksumProcess::resultReady, this, &QWizard::next); | 231 | connect(m_process, &ChecksumProcess::resultReady, this, &QWizard::next); | ||
232 | // run the process | 232 | // run the process | ||
233 | m_process->start(); | 233 | m_process->start(); | ||
234 | } | 234 | } | ||
235 | 235 | | |||
236 | void ChecksumWizard::addChecksumLine(KrTreeWidget *tree, const QString &line) | 236 | void ChecksumWizard::addChecksumLine(KrTreeWidget *tree, const QString &line) | ||
237 | { | 237 | { | ||
238 | QTreeWidgetItem *item = new QTreeWidgetItem(tree); | 238 | auto *item = new QTreeWidgetItem(tree); | ||
239 | const int hashLength = line.indexOf(' '); // delimiter is either " " or " *" | 239 | const int hashLength = line.indexOf(' '); // delimiter is either " " or " *" | ||
240 | item->setText(0, line.left(hashLength)); | 240 | item->setText(0, line.left(hashLength)); | ||
241 | QString fileName = line.mid(hashLength + 2); | 241 | QString fileName = line.mid(hashLength + 2); | ||
242 | if (fileName.endsWith('\n')) | 242 | if (fileName.endsWith('\n')) | ||
243 | fileName.chop(1); | 243 | fileName.chop(1); | ||
244 | item->setText(1, fileName); | 244 | item->setText(1, fileName); | ||
245 | } | 245 | } | ||
246 | 246 | | |||
247 | // ------------- Create Wizard | 247 | // ------------- Create Wizard | ||
248 | 248 | | |||
249 | CreateWizard::CreateWizard(const QString &path, const QStringList &_files) : ChecksumWizard(path), | 249 | CreateWizard::CreateWizard(const QString &path, const QStringList &_files) : ChecksumWizard(path), | ||
250 | m_fileNames(_files), m_listFilesWatcher() | 250 | m_fileNames(_files) | ||
251 | { | 251 | { | ||
252 | 252 | | |||
253 | m_introId = addPage(createIntroPage()); | 253 | m_introId = addPage(createIntroPage()); | ||
254 | m_progressId = addPage(createProgressPage(i18n("Creating Checksums"))); | 254 | m_progressId = addPage(createProgressPage(i18n("Creating Checksums"))); | ||
255 | m_resultId = addPage(createResultPage()); | 255 | m_resultId = addPage(createResultPage()); | ||
256 | 256 | | |||
257 | setButton(QWizard::FinishButton, | 257 | setButton(QWizard::FinishButton, | ||
258 | QDialogButtonBox(QDialogButtonBox::Save).button(QDialogButtonBox::Save)); | 258 | QDialogButtonBox(QDialogButtonBox::Save).button(QDialogButtonBox::Save)); | ||
259 | 259 | | |||
260 | connect(&m_listFilesWatcher, &QFutureWatcher<QStringList>::resultReadyAt, | 260 | connect(&m_listFilesWatcher, &QFutureWatcher<QStringList>::resultReadyAt, | ||
261 | this, &CreateWizard::createChecksums); | 261 | this, &CreateWizard::createChecksums); | ||
262 | } | 262 | } | ||
263 | 263 | | |||
264 | QWizardPage *CreateWizard::createIntroPage() | 264 | QWizardPage *CreateWizard::createIntroPage() | ||
265 | { | 265 | { | ||
266 | QWizardPage *page = new QWizardPage; | 266 | auto *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 | Icon("document-edit-sign").pixmap(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 | auto *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 | auto *listWidget = new KrListWidget; | ||
278 | listWidget->addItems(m_fileNames); | 278 | listWidget->addItems(m_fileNames); | ||
279 | mainLayout->addWidget(listWidget); | 279 | mainLayout->addWidget(listWidget); | ||
280 | 280 | | |||
281 | // checksum method | 281 | // checksum method | ||
282 | QHBoxLayout *hLayout = new QHBoxLayout; | 282 | auto *hLayout = new QHBoxLayout; | ||
283 | 283 | | |||
284 | QLabel *methodLabel = new QLabel(i18n("Select the checksum method:")); | 284 | QLabel *methodLabel = new QLabel(i18n("Select the checksum method:")); | ||
285 | hLayout->addWidget(methodLabel); | 285 | hLayout->addWidget(methodLabel); | ||
286 | 286 | | |||
287 | m_methodBox = new KComboBox; | 287 | m_methodBox = new KComboBox; | ||
288 | // -- fill the combo with available methods | 288 | // -- fill the combo with available methods | ||
289 | for (const QString type: m_checksumTools.keys()) | 289 | for (const QString& type: m_checksumTools.keys()) | ||
290 | m_methodBox->addItem(type); | 290 | m_methodBox->addItem(type); | ||
291 | m_methodBox->setFocus(); | 291 | m_methodBox->setFocus(); | ||
292 | hLayout->addWidget(m_methodBox); | 292 | hLayout->addWidget(m_methodBox); | ||
293 | 293 | | |||
294 | mainLayout->addLayout(hLayout); | 294 | mainLayout->addLayout(hLayout); | ||
295 | 295 | | |||
296 | return page; | 296 | return page; | ||
297 | } | 297 | } | ||
298 | 298 | | |||
299 | QWizardPage *CreateWizard::createResultPage() | 299 | QWizardPage *CreateWizard::createResultPage() | ||
300 | { | 300 | { | ||
301 | QWizardPage *page = new QWizardPage; | 301 | auto *page = new QWizardPage; | ||
302 | 302 | | |||
303 | page->setTitle(i18n("Checksum Results")); | 303 | page->setTitle(i18n("Checksum Results")); | ||
304 | 304 | | |||
305 | QVBoxLayout *mainLayout = new QVBoxLayout; | 305 | auto *mainLayout = new QVBoxLayout; | ||
306 | page->setLayout(mainLayout); | 306 | page->setLayout(mainLayout); | ||
307 | 307 | | |||
308 | m_hashesTreeWidget = new KrTreeWidget(this); | 308 | m_hashesTreeWidget = new KrTreeWidget(this); | ||
309 | m_hashesTreeWidget->setAllColumnsShowFocus(true); | 309 | m_hashesTreeWidget->setAllColumnsShowFocus(true); | ||
310 | m_hashesTreeWidget->setHeaderLabels(QStringList() << i18n("Hash") << i18n("File")); | 310 | m_hashesTreeWidget->setHeaderLabels(QStringList() << i18n("Hash") << i18n("File")); | ||
311 | mainLayout->addWidget(m_hashesTreeWidget); | 311 | mainLayout->addWidget(m_hashesTreeWidget); | ||
312 | 312 | | |||
313 | m_errorLabel = new QLabel(i18n("Errors received:")); | 313 | m_errorLabel = new QLabel(i18n("Errors received:")); | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 367 | page->setPixmap(QWizard::LogoPixmap, | |||
368 | Icon(errors || !successes ? "dialog-error" : "dialog-information").pixmap(32)); | 368 | Icon(errors || !successes ? "dialog-error" : "dialog-information").pixmap(32)); | ||
369 | page->setSubTitle(errors || !successes ? | 369 | page->setSubTitle(errors || !successes ? | ||
370 | i18n("Errors were detected while creating the checksums") : | 370 | i18n("Errors were detected while creating the checksums") : | ||
371 | i18n("Checksums were created successfully")); | 371 | i18n("Checksums were created successfully")); | ||
372 | 372 | | |||
373 | m_hashesTreeWidget->clear(); | 373 | m_hashesTreeWidget->clear(); | ||
374 | m_hashesTreeWidget->setVisible(successes); | 374 | m_hashesTreeWidget->setVisible(successes); | ||
375 | if (successes) { | 375 | if (successes) { | ||
376 | for (const QString line : outputLines) | 376 | for (const QString& line : outputLines) | ||
377 | addChecksumLine(m_hashesTreeWidget, line); | 377 | addChecksumLine(m_hashesTreeWidget, line); | ||
378 | //m_hashesTreeWidget->sortItems(1, Qt::AscendingOrder); | 378 | //m_hashesTreeWidget->sortItems(1, Qt::AscendingOrder); | ||
379 | } | 379 | } | ||
380 | 380 | | |||
381 | m_errorLabel->setVisible(errors); | 381 | m_errorLabel->setVisible(errors); | ||
382 | m_errorListWidget->setVisible(errors); | 382 | m_errorListWidget->setVisible(errors); | ||
383 | m_errorListWidget->clear(); | 383 | m_errorListWidget->clear(); | ||
384 | m_errorListWidget->addItems(errorLines); | 384 | m_errorListWidget->addItems(errorLines); | ||
385 | 385 | | |||
386 | m_onePerFileBox->setEnabled(outputLines.size() > 1); | 386 | m_onePerFileBox->setEnabled(outputLines.size() > 1); | ||
387 | 387 | | |||
388 | button(QWizard::FinishButton)->setEnabled(successes); | 388 | button(QWizard::FinishButton)->setEnabled(successes); | ||
389 | } | 389 | } | ||
390 | 390 | | |||
391 | bool CreateWizard::savePerFile() | 391 | bool CreateWizard::savePerFile() | ||
392 | { | 392 | { | ||
393 | const QString type = m_suggestedFilePath.mid(m_suggestedFilePath.lastIndexOf('.')); | 393 | const QString type = m_suggestedFilePath.mid(m_suggestedFilePath.lastIndexOf('.')); | ||
394 | 394 | | |||
395 | krApp->startWaiting(i18n("Saving checksum files..."), 0); | 395 | krApp->startWaiting(i18n("Saving checksum files..."), 0); | ||
396 | for (const QString line : m_process->stdOutput()) { | 396 | for (const QString& line : m_process->stdOutput()) { | ||
397 | const QString filename = line.mid(line.indexOf(' ') + 2) + type; | 397 | const QString filename = line.mid(line.indexOf(' ') + 2) + type; | ||
398 | if (!saveChecksumFile(QStringList() << line, filename)) { | 398 | if (!saveChecksumFile(QStringList() << line, filename)) { | ||
399 | KMessageBox::error(this, i18n("Errors occurred while saving multiple checksums. Stopping")); | 399 | KMessageBox::error(this, i18n("Errors occurred while saving multiple checksums. Stopping")); | ||
400 | krApp->stopWait(); | 400 | krApp->stopWait(); | ||
401 | return false; | 401 | return false; | ||
402 | } | 402 | } | ||
403 | } | 403 | } | ||
404 | krApp->stopWait(); | 404 | krApp->stopWait(); | ||
405 | 405 | | |||
406 | return true; | 406 | return true; | ||
407 | } | 407 | } | ||
408 | 408 | | |||
409 | bool CreateWizard::saveChecksumFile(const QStringList &data, const QString &filename) | 409 | bool CreateWizard::saveChecksumFile(const QStringList &data, const QString &filename) | ||
410 | { | 410 | { | ||
411 | QString filePath = filename.isEmpty() ? m_suggestedFilePath : filename; | 411 | QString filePath = filename.isEmpty() ? m_suggestedFilePath : filename; | ||
412 | if (filename.isEmpty() || QFile::exists(filePath)) { | 412 | if (filename.isEmpty() || QFile::exists(filePath)) { | ||
413 | filePath = QFileDialog::getSaveFileName(this, QString(), filePath); | 413 | filePath = QFileDialog::getSaveFileName(this, QString(), filePath); | ||
414 | if (filePath.isEmpty()) | 414 | if (filePath.isEmpty()) | ||
415 | return false; // user pressed cancel | 415 | return false; // user pressed cancel | ||
416 | } | 416 | } | ||
417 | 417 | | |||
418 | QFile file(filePath); | 418 | QFile file(filePath); | ||
419 | if (file.open(QIODevice::WriteOnly)) { | 419 | if (file.open(QIODevice::WriteOnly)) { | ||
420 | QTextStream stream(&file); | 420 | QTextStream stream(&file); | ||
421 | for (const QString line : data) | 421 | for (const QString& line : data) | ||
422 | stream << line << "\n"; | 422 | stream << line << "\n"; | ||
423 | file.close(); | 423 | file.close(); | ||
424 | } | 424 | } | ||
425 | 425 | | |||
426 | if (file.error() != QFile::NoError) { | 426 | if (file.error() != QFile::NoError) { | ||
427 | KMessageBox::detailedError(this, i18n("Error saving file %1", filePath), file.errorString()); | 427 | KMessageBox::detailedError(this, i18n("Error saving file %1", filePath), file.errorString()); | ||
428 | return false; | 428 | return false; | ||
429 | } | 429 | } | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 454 | { | |||
471 | } | 471 | } | ||
472 | file.close(); | 472 | file.close(); | ||
473 | 473 | | |||
474 | button(QWizard::NextButton)->setEnabled(true); | 474 | button(QWizard::NextButton)->setEnabled(true); | ||
475 | } | 475 | } | ||
476 | 476 | | |||
477 | QWizardPage *VerifyWizard::createIntroPage() | 477 | QWizardPage *VerifyWizard::createIntroPage() | ||
478 | { | 478 | { | ||
479 | QWizardPage *page = new QWizardPage; | 479 | auto *page = new QWizardPage; | ||
480 | 480 | | |||
481 | page->setTitle(i18n("Verify Checksum File")); | 481 | page->setTitle(i18n("Verify Checksum File")); | ||
482 | page->setPixmap(QWizard::LogoPixmap, | 482 | page->setPixmap(QWizard::LogoPixmap, | ||
483 | Icon("document-edit-verify").pixmap(32)); | 483 | Icon("document-edit-verify").pixmap(32)); | ||
484 | page->setSubTitle(i18n("About to verify the following checksum file")); | 484 | page->setSubTitle(i18n("About to verify the following checksum file")); | ||
485 | 485 | | |||
486 | QVBoxLayout *mainLayout = new QVBoxLayout; | 486 | auto *mainLayout = new QVBoxLayout; | ||
487 | page->setLayout(mainLayout); | 487 | page->setLayout(mainLayout); | ||
488 | 488 | | |||
489 | // checksum file | 489 | // checksum file | ||
490 | QHBoxLayout *hLayout = new QHBoxLayout; | 490 | auto *hLayout = new QHBoxLayout; | ||
491 | QLabel *checksumFileLabel = new QLabel(i18n("Checksum file:")); | 491 | QLabel *checksumFileLabel = new QLabel(i18n("Checksum file:")); | ||
492 | hLayout->addWidget(checksumFileLabel); | 492 | hLayout->addWidget(checksumFileLabel); | ||
493 | 493 | | |||
494 | KUrlRequester *checksumFileReq = new KUrlRequester; | 494 | auto *checksumFileReq = new KUrlRequester; | ||
495 | QString typesFilter; | 495 | QString typesFilter; | ||
496 | for (const QString ext: m_checksumTools.keys()) | 496 | for (const QString& ext: m_checksumTools.keys()) | ||
497 | typesFilter += ("*." + ext + ' '); | 497 | typesFilter += ("*." + ext + ' '); | ||
498 | checksumFileReq->setFilter(typesFilter); | 498 | checksumFileReq->setFilter(typesFilter); | ||
499 | checksumFileReq->setText(m_checksumFile); | 499 | checksumFileReq->setText(m_checksumFile); | ||
500 | checksumFileReq->setFocus(); | 500 | checksumFileReq->setFocus(); | ||
501 | connect(checksumFileReq, &KUrlRequester::textChanged, this, | 501 | connect(checksumFileReq, &KUrlRequester::textChanged, this, | ||
502 | &VerifyWizard::slotChecksumPathChanged); | 502 | &VerifyWizard::slotChecksumPathChanged); | ||
503 | hLayout->addWidget(checksumFileReq); | 503 | hLayout->addWidget(checksumFileReq); | ||
504 | 504 | | |||
505 | mainLayout->addLayout(hLayout); | 505 | mainLayout->addLayout(hLayout); | ||
506 | 506 | | |||
507 | // content of checksum file | 507 | // content of checksum file | ||
508 | m_hashesTreeWidget = new KrTreeWidget(page); | 508 | m_hashesTreeWidget = new KrTreeWidget(page); | ||
509 | m_hashesTreeWidget->setAllColumnsShowFocus(true); | 509 | m_hashesTreeWidget->setAllColumnsShowFocus(true); | ||
510 | m_hashesTreeWidget->setHeaderLabels(QStringList() << i18n("Hash") << i18n("File")); | 510 | m_hashesTreeWidget->setHeaderLabels(QStringList() << i18n("Hash") << i18n("File")); | ||
511 | mainLayout->addWidget(m_hashesTreeWidget); | 511 | mainLayout->addWidget(m_hashesTreeWidget); | ||
512 | 512 | | |||
513 | return page; | 513 | return page; | ||
514 | } | 514 | } | ||
515 | 515 | | |||
516 | QWizardPage *VerifyWizard::createResultPage() | 516 | QWizardPage *VerifyWizard::createResultPage() | ||
517 | { | 517 | { | ||
518 | QWizardPage *page = new QWizardPage; | 518 | auto *page = new QWizardPage; | ||
519 | 519 | | |||
520 | page->setTitle(i18n("Verify Result")); | 520 | page->setTitle(i18n("Verify Result")); | ||
521 | 521 | | |||
522 | QVBoxLayout *mainLayout = new QVBoxLayout; | 522 | auto *mainLayout = new QVBoxLayout; | ||
523 | page->setLayout(mainLayout); | 523 | page->setLayout(mainLayout); | ||
524 | 524 | | |||
525 | m_outputLabel = new QLabel(i18n("Result output:")); | 525 | m_outputLabel = new QLabel(i18n("Result output:")); | ||
526 | mainLayout->addWidget(m_outputLabel); | 526 | mainLayout->addWidget(m_outputLabel); | ||
527 | 527 | | |||
528 | m_outputListWidget = new KrListWidget; | 528 | m_outputListWidget = new KrListWidget; | ||
529 | mainLayout->addWidget(m_outputListWidget); | 529 | mainLayout->addWidget(m_outputListWidget); | ||
530 | 530 | | |||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |