IntelliPhoto  0.5
IntelliInputDialog.cpp
Go to the documentation of this file.
1 #include "IntelliInputDialog.h"
2 #include <QFile>
3 
4 
5 IntelliInputDialog::IntelliInputDialog(QString Title, QString Label, int value, int minValue, int maxValue, int step, bool* ok)
6 {
7  this->valueInt = value;
8  this->notClosed = ok;
9  if(notClosed != nullptr) {
10  *notClosed = false;
11  }
12  createInputBox(Title, Label, value, minValue, maxValue, step);
13  createConnections();
14  setInputBoxStyle();
15  this->exec();
16 }
17 
18 int IntelliInputDialog::getInt(QString Title, QString Label, int value, int minValue, int maxValue, int step, bool* ok){
19  IntelliInputDialog dialog(Title, Label, value, minValue, maxValue, step, ok);
20  return dialog.valueInt;
21 }
22 
23 void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, int minValue, int maxValue, int step){
24  this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
25  if(Title == nullptr) {
26  this->setWindowTitle("Input Box");
27  }
28  else{
29  this->setWindowTitle(Title);
30  }
31  this->Layout = new QGridLayout();
32  this->ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
33 
34  this->InputLabel = new QLabel();
35  if(Label == nullptr) {
36  this->InputLabel->setText("Width:");
37  }
38  else{
39  this->InputLabel->setText(Label);
40  }
41  this->InputLabel->setFixedSize(Linesize);
42 
43  this->Input = new QSpinBox();
44  this->Input->setFixedSize(Linesize);
45  this->Input->setRange(minValue,maxValue);
46  this->Input->setSingleStep(step);
47  this->Input->setValue(value);
48 
49  this->okButton = ButtonBox->button(QDialogButtonBox::Ok);
50  this->okButton->setFixedSize(Buttonsize);
51  this->okButton->setAutoDefault(false);
52  this->okButton->setDefault(false);
53 
54  this->cancelButton = ButtonBox->button(QDialogButtonBox::Cancel);
55  this->cancelButton->setFixedSize(Buttonsize);
56  this->cancelButton->setAutoDefault(false);
57  this->cancelButton->setDefault(false);
58 
59  Layout->addWidget(InputLabel,1,1,1,1);
60  Layout->addWidget(Input,2,1,1,1);
61  Layout->addWidget(ButtonBox,3,1,1,1);
62  this->setLayout(Layout);
63  this->resize(172,94);
64  this->show();
65 }
66 
67 void IntelliInputDialog::createConnections(){
68  connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe()));
69  connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCloseEvent()));
70 }
71 
72 void IntelliInputDialog::setInputBoxStyle(){
73  this->setStyleSheet("color: white;" "background-color: rgb(64, 64, 64);" "selection-color: rgb(200, 10, 10);" "selection-background-color: rgb(64, 64, 64);");
74 }
75 
77  this->close();
78 }
79 
81  valueInt = QString("%1").arg(Input->value()).toInt();
82  if(notClosed != nullptr) {
83  *notClosed = true;
84  }
85  this->close();
86 }
IntelliInputDialog::slotCloseEvent
void slotCloseEvent()
Definition: IntelliInputDialog.cpp:76
IntelliInputDialog.h
IntelliInputDialog
Definition: IntelliInputDialog.h:6
IntelliInputDialog::IntelliInputDialog
IntelliInputDialog(QString Title=nullptr, QString Label=nullptr, int value=5, int minValue=-2147483647, int maxValue=2147483647, int step=1, bool *ok=nullptr)
Definition: IntelliInputDialog.cpp:5
IntelliInputDialog::getInt
static int getInt(QString Title=nullptr, QString Label=nullptr, int value=5, int minValue=-2147483647, int maxValue=2147483647, int step=1, bool *ok=nullptr)
Definition: IntelliInputDialog.cpp:18
IntelliInputDialog::slotEingabe
void slotEingabe()
Definition: IntelliInputDialog.cpp:80