summaryrefslogtreecommitdiffstats
path: root/indexerdialog.cpp
blob: 1909c9e1c2f8ceb8dd8f9697fbde1f571d4db9d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QApplication>

#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);
}