#include #include #include #include #include "indexerdialog.h" #include "indexerwidget.h" IndexerDialog::IndexerDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ //indexer mIndexer = new IndexerWidget; connect(mIndexer, &IndexerWidget::indexingDone, this, &IndexerDialog::indexingCanceled); //buttons mStartBtn = new QPushButton(tr("Start")); connect(mStartBtn, &QPushButton::clicked, mIndexer, &IndexerWidget::startIndexing); connect(mStartBtn, &QPushButton::clicked, this, &IndexerDialog::indexingStarted); mCancelBtn = new QPushButton(tr("Cancel")); mCancelBtn->setEnabled(false); connect(mCancelBtn, &QPushButton::clicked, mIndexer, &IndexerWidget::stopIndexing); connect(mCancelBtn, &QPushButton::clicked, this, &IndexerDialog::indexingCanceled); mCloseBtn = new QPushButton(tr("Close")); connect(mCloseBtn, &QPushButton::clicked, this, &IndexerDialog::close); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addStretch(); buttonLayout->addWidget(mStartBtn); buttonLayout->addWidget(mCancelBtn); buttonLayout->addWidget(mCloseBtn); buttonLayout->addStretch(); //mainlayout QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(mIndexer); mainLayout->addLayout(buttonLayout); setLayout(mainLayout); setWindowTitle(QString(tr("%1 - Indexer")).arg(qApp->applicationName())); setMinimumWidth(768); } void IndexerDialog::indexingStarted(){ mStartBtn->setEnabled(false); mCancelBtn->setEnabled(true); mCloseBtn->setEnabled(false); } void IndexerDialog::indexingCanceled(){ mStartBtn->setEnabled(true); mCancelBtn->setEnabled(false); mCloseBtn->setEnabled(true); }