|
| 1 | +#include "core_dialogreplace.h" |
| 2 | + |
| 3 | +#include <QVBoxLayout> |
| 4 | +#include <QGridLayout> |
| 5 | +#include <QLabel> |
| 6 | +#include <QPushButton> |
| 7 | + |
| 8 | +mbCoreDialogReplace::mbCoreDialogReplace(QWidget *parent) |
| 9 | +{ |
| 10 | + setWindowTitle("Replace Dialog"); |
| 11 | + |
| 12 | + auto *mainLayout = new QVBoxLayout(this); |
| 13 | + m_label = new QLabel("What would you like to do?", this); |
| 14 | + mainLayout->addWidget(m_label); |
| 15 | + |
| 16 | + QGridLayout *grid = new QGridLayout; |
| 17 | + mainLayout->addLayout(grid); |
| 18 | + |
| 19 | + m_buttonReplace = new QPushButton(tr("Replace"), this); |
| 20 | + connect(m_buttonReplace, &QPushButton::clicked, this, &mbCoreDialogReplace::slotReplaceClicked); |
| 21 | + grid->addWidget(m_buttonReplace, 0, 0); |
| 22 | + |
| 23 | + m_buttonRename = new QPushButton(tr("Rename"), this); |
| 24 | + connect(m_buttonRename, &QPushButton::clicked, this, &mbCoreDialogReplace::slotRenameClicked); |
| 25 | + grid->addWidget(m_buttonRename, 0, 1); |
| 26 | + |
| 27 | + m_buttonSkip = new QPushButton(tr("Skip"), this); |
| 28 | + connect(m_buttonSkip, &QPushButton::clicked, this, &mbCoreDialogReplace::slotSkipClicked); |
| 29 | + grid->addWidget(m_buttonSkip, 0, 2); |
| 30 | + |
| 31 | + m_buttonReplaceAll = new QPushButton(tr("Replace All"), this); |
| 32 | + connect(m_buttonReplaceAll, &QPushButton::clicked, this, &mbCoreDialogReplace::slotReplaceAllClicked); |
| 33 | + grid->addWidget(m_buttonReplaceAll, 1, 0); |
| 34 | + |
| 35 | + m_buttonRenameAll = new QPushButton(tr("Rename All"), this); |
| 36 | + connect(m_buttonRenameAll, &QPushButton::clicked, this, &mbCoreDialogReplace::slotRenameAllClicked); |
| 37 | + grid->addWidget(m_buttonRenameAll, 1, 1); |
| 38 | + |
| 39 | + m_buttonSkipAll = new QPushButton(tr("Skip All"), this); |
| 40 | + connect(m_buttonSkipAll, &QPushButton::clicked, this, &mbCoreDialogReplace::slotSkipAllClicked); |
| 41 | + grid->addWidget(m_buttonSkipAll, 1, 2); |
| 42 | + |
| 43 | + m_buttonCancel = new QPushButton(tr("Cancel"), this); |
| 44 | + connect(m_buttonCancel, &QPushButton::clicked, this, &mbCoreDialogReplace::slotCancelClicked); |
| 45 | + grid->addWidget(m_buttonCancel, 2, 2); |
| 46 | +} |
| 47 | + |
| 48 | +QString mbCoreDialogReplace::text() const |
| 49 | +{ |
| 50 | + return m_label->text(); |
| 51 | +} |
| 52 | + |
| 53 | +void mbCoreDialogReplace::setText(const QString &text) |
| 54 | +{ |
| 55 | + m_label->setText(text); |
| 56 | +} |
| 57 | + |
| 58 | +void mbCoreDialogReplace::setUseAllButtons(bool use) |
| 59 | +{ |
| 60 | + m_buttonReplaceAll->setVisible(use); |
| 61 | + m_buttonRenameAll->setVisible(use); |
| 62 | + m_buttonSkipAll->setVisible(use); |
| 63 | +} |
| 64 | + |
| 65 | +void mbCoreDialogReplace::slotReplaceClicked() |
| 66 | +{ |
| 67 | + QDialog::done(Replace); |
| 68 | +} |
| 69 | + |
| 70 | +void mbCoreDialogReplace::slotRenameClicked() |
| 71 | +{ |
| 72 | + QDialog::done(Rename); |
| 73 | +} |
| 74 | + |
| 75 | +void mbCoreDialogReplace::slotSkipClicked() |
| 76 | +{ |
| 77 | + QDialog::done(Skip); |
| 78 | +} |
| 79 | + |
| 80 | +void mbCoreDialogReplace::slotReplaceAllClicked() |
| 81 | +{ |
| 82 | + QDialog::done(ReplaceAll); |
| 83 | +} |
| 84 | + |
| 85 | +void mbCoreDialogReplace::slotRenameAllClicked() |
| 86 | +{ |
| 87 | + QDialog::done(RenameAll); |
| 88 | +} |
| 89 | + |
| 90 | +void mbCoreDialogReplace::slotSkipAllClicked() |
| 91 | +{ |
| 92 | + QDialog::done(SkipAll); |
| 93 | +} |
| 94 | + |
| 95 | +void mbCoreDialogReplace::slotCancelClicked() |
| 96 | +{ |
| 97 | + QDialog::reject(); |
| 98 | +} |
0 commit comments