summaryrefslogtreecommitdiffstats
path: root/smdialog.cpp
blob: 645d6d62be6969aa664ec992a8df681ba709e9e5 (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
51
52
53
54
55
56
57
58
59
60
/*
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version
  2 of the License, or (at your option) any later version.
*/

#include <QLineEdit>
#include <QSpinBox>
#include <QLabel>
#include <QPushButton>
#include <QFormLayout>
#include <QHBoxLayout>

#include "smdialog.h"
#include "helper.h"

SmDialog::SmDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {}

void SmDialog::showEvent(QShowEvent *){
	Helper::centerWidget(this);
}

SeriesPartsDialog::SeriesPartsDialog(QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f){
    QFormLayout *mainLayout = new QFormLayout;
    mSubtitle = new QLineEdit;
    mSubtitle->setMinimumWidth(300);
    mainLayout->addRow(tr("&Subtitle:"), mSubtitle);
    mPartno = new QSpinBox;
    mPartno->setValue(0);
    mPartno->setMinimum(0);
    mainLayout->addRow(tr("&Part no."), mPartno);
    mOk = new QPushButton(tr("Ok"));
    connect(mOk, SIGNAL(clicked()), this, SLOT(accept()));
    mCancel = new QPushButton(tr("Cancel"));
    connect(mCancel, SIGNAL(clicked()), this, SLOT(reject()));
    mCancel->setDefault(true);
    QHBoxLayout *buttonLayout = new QHBoxLayout;
    buttonLayout->addStretch();
    buttonLayout->addWidget(mOk);
    buttonLayout->addWidget(mCancel);
    mainLayout->addRow(buttonLayout);
    setLayout(mainLayout);
}

QString SeriesPartsDialog::subtitle() const {
    return mSubtitle->text();
}

void SeriesPartsDialog::setSubtitle(const QString &subtitle){
    mSubtitle->setText(subtitle);
}

int SeriesPartsDialog::partNo() const {
    return mPartno->value();
}

void SeriesPartsDialog::setPartno(int partNo){
    mPartno->setValue(partNo);
}