Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show First 20 Lines • Show All 419 Lines • ▼ Show 20 Line(s) | 411 | { | |||
---|---|---|---|---|---|
420 | listWidget->setMinimumWidth(fontMetrics().height() / 2 * padding); | 420 | listWidget->setMinimumWidth(fontMetrics().height() / 2 * padding); | ||
421 | for (const auto &url : fileList) { | 421 | for (const auto &url : fileList) { | ||
422 | listWidget->addItem(url.toLocalFile() + " [*]"); | 422 | listWidget->addItem(url.toLocalFile() + " [*]"); | ||
423 | } | 423 | } | ||
424 | 424 | | |||
425 | auto hLayout = new QHBoxLayout(); | 425 | auto hLayout = new QHBoxLayout(); | ||
426 | auto saveBtn = new QPushButton(QIcon::fromTheme("document-save", QIcon(QStringLiteral(":/%1/save").arg(m_theme))), i18n("Save Selected")); | 426 | auto saveBtn = new QPushButton(QIcon::fromTheme("document-save", QIcon(QStringLiteral(":/%1/save").arg(m_theme))), i18n("Save Selected")); | ||
427 | saveBtn->setIconSize(iconSize); | 427 | saveBtn->setIconSize(iconSize); | ||
428 | saveBtn->setEnabled(false); | ||||
429 | | ||||
430 | connect(listWidget, &QListWidget::currentRowChanged, this, [saveBtn](const int currentRow) { | ||||
431 | if (currentRow < 0) { | ||||
432 | saveBtn->setEnabled(false); | ||||
433 | } else { | ||||
434 | saveBtn->setEnabled(true); | ||||
435 | } | ||||
tcanabrava: sabeBtn->setEnabled(currentRow >= 0); ? | |||||
436 | }); | ||||
437 | | ||||
428 | connect(saveBtn, &QPushButton::clicked, this, [this, &listWidget, &fileList, &dialog] { | 438 | connect(saveBtn, &QPushButton::clicked, this, [this, &listWidget, &fileList, &dialog] { | ||
429 | if (!m_gcodeEditor->saveFile(fileList.at(listWidget->currentRow()))) | 439 | if (!m_gcodeEditor->saveFile(fileList.at(listWidget->currentRow()))) | ||
430 | { | 440 | { | ||
431 | QMessageBox::information(this, i18n("Save Failed"), i18n("Failed to save file: %1").arg(fileList.at(listWidget->currentRow()).toLocalFile())); | 441 | QMessageBox::information(this, i18n("Save Failed"), i18n("Failed to save file: %1").arg(fileList.at(listWidget->currentRow()).toLocalFile())); | ||
432 | } else | 442 | } else | ||
433 | { | 443 | { | ||
434 | QString txt = listWidget->item(listWidget->currentRow())->text(); | 444 | QString txt = listWidget->item(listWidget->currentRow())->text(); | ||
435 | txt.remove(" [*]"); | 445 | txt.remove(" [*]"); | ||
Show All 29 Lines | |||||
465 | 475 | | |||
466 | auto cancelBtn = new QPushButton(QIcon::fromTheme("dialog-cancel", QIcon(QStringLiteral(":/%1/cancel").arg(m_theme))), i18n("Cancel")); | 476 | auto cancelBtn = new QPushButton(QIcon::fromTheme("dialog-cancel", QIcon(QStringLiteral(":/%1/cancel").arg(m_theme))), i18n("Cancel")); | ||
467 | cancelBtn->setIconSize(iconSize); | 477 | cancelBtn->setIconSize(iconSize); | ||
468 | connect(cancelBtn, &QPushButton::clicked, this, [&dialog] { | 478 | connect(cancelBtn, &QPushButton::clicked, this, [&dialog] { | ||
469 | dialog->reject(); | 479 | dialog->reject(); | ||
470 | }); | 480 | }); | ||
471 | hLayout->addWidget(cancelBtn); | 481 | hLayout->addWidget(cancelBtn); | ||
472 | 482 | | |||
473 | auto ignoreBtn = new QPushButton(QIcon::fromTheme("window-close", QIcon(QStringLiteral(":/icon/close"))), i18n("Ignore")); | 483 | auto ignoreBtn = new QPushButton(QIcon::fromTheme("edit-delete", QIcon(QStringLiteral(":/icon/delete"))), i18n("Discard Changes"), dialog); | ||
474 | ignoreBtn->setIconSize(iconSize); | 484 | ignoreBtn->setIconSize(iconSize); | ||
475 | connect(ignoreBtn, &QPushButton::clicked, this, [&dialog] { | 485 | connect(ignoreBtn, &QPushButton::clicked, this, [&dialog] { | ||
476 | dialog->accept(); | 486 | dialog->accept(); | ||
477 | }); | 487 | }); | ||
478 | hLayout->addWidget(ignoreBtn); | 488 | hLayout->addWidget(ignoreBtn); | ||
479 | 489 | | |||
480 | auto layout = new QVBoxLayout; | 490 | auto layout = new QVBoxLayout; | ||
481 | auto label = new QLabel(i18n("Files with Unsaved Changes.")); | 491 | auto label = new QLabel(i18n("Files with Unsaved Changes.")); | ||
Show All 12 Lines |
sabeBtn->setEnabled(currentRow >= 0); ?