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