mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
first Cleanup
This commit is contained in:
@@ -1,56 +1,57 @@
|
||||
#include "IntelliInputDialog.h"
|
||||
#include <QFile>
|
||||
IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step)
|
||||
|
||||
|
||||
IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step)
|
||||
{
|
||||
this->Dialog = Dialog;
|
||||
createInputBox(Title, Label, value, minValue, maxValue, step);
|
||||
createConnections(Loop);
|
||||
setValuesOfPalette();
|
||||
setInputBoxStyle();
|
||||
Loop->exec();
|
||||
}
|
||||
|
||||
void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, int minValue, int maxValue, int step){
|
||||
this->Dialog = new QDialog();
|
||||
Dialog->setWindowFlags(Dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
if(Title == nullptr) {
|
||||
Dialog->setWindowTitle("Input Box");
|
||||
this->setWindowTitle("Input Box");
|
||||
}
|
||||
else{
|
||||
Dialog->setWindowTitle(Title);
|
||||
this->setWindowTitle(Title);
|
||||
}
|
||||
Layout = new QGridLayout();
|
||||
ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
this->Layout = new QGridLayout();
|
||||
this->ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
InputLabel = new QLabel();
|
||||
this->InputLabel = new QLabel();
|
||||
if(Label == nullptr) {
|
||||
InputLabel->setText("Width:");
|
||||
this->InputLabel->setText("Width:");
|
||||
}
|
||||
else{
|
||||
InputLabel->setText(Label);
|
||||
this->InputLabel->setText(Label);
|
||||
}
|
||||
InputLabel->setFixedSize(Linesize);
|
||||
this->InputLabel->setFixedSize(Linesize);
|
||||
|
||||
Input = new QSpinBox();
|
||||
Input->setFixedSize(Linesize);
|
||||
Input->setRange(minValue,maxValue);
|
||||
Input->setValue(value);
|
||||
this->Input = new QSpinBox();
|
||||
this->Input->setFixedSize(Linesize);
|
||||
this->Input->setRange(minValue,maxValue);
|
||||
this->Input->setValue(value);
|
||||
|
||||
okButton = ButtonBox->button(QDialogButtonBox::Ok);
|
||||
okButton->setFixedSize(Buttonsize);
|
||||
okButton->setAutoDefault(false);
|
||||
okButton->setDefault(false);
|
||||
this->okButton = ButtonBox->button(QDialogButtonBox::Ok);
|
||||
this->okButton->setFixedSize(Buttonsize);
|
||||
this->okButton->setAutoDefault(false);
|
||||
this->okButton->setDefault(false);
|
||||
|
||||
cancelButton = ButtonBox->button(QDialogButtonBox::Cancel);
|
||||
cancelButton->setFixedSize(Buttonsize);
|
||||
cancelButton->setAutoDefault(false);
|
||||
cancelButton->setDefault(false);
|
||||
this->cancelButton = ButtonBox->button(QDialogButtonBox::Cancel);
|
||||
this->cancelButton->setFixedSize(Buttonsize);
|
||||
this->cancelButton->setAutoDefault(false);
|
||||
this->cancelButton->setDefault(false);
|
||||
|
||||
Layout->addWidget(InputLabel,1,1,1,1);
|
||||
Layout->addWidget(Input,2,1,1,1);
|
||||
Layout->addWidget(ButtonBox,3,1,1,1);
|
||||
Dialog->setLayout(Layout);
|
||||
Dialog->resize(172,94);
|
||||
Dialog->show();
|
||||
this->setLayout(Layout);
|
||||
this->resize(172,94);
|
||||
this->show();
|
||||
}
|
||||
|
||||
void IntelliInputDialog::createConnections(QEventLoop* Loop){
|
||||
@@ -65,7 +66,7 @@ void IntelliInputDialog::setInputBoxStyle(){
|
||||
Input->setPalette(Palette);
|
||||
okButton->setPalette(Palette);
|
||||
cancelButton->setPalette(Palette);
|
||||
Dialog->setStyleSheet("background-color:rgb(64,64,64)");
|
||||
this->setStyleSheet("background-color:rgb(64,64,64)");
|
||||
}
|
||||
|
||||
void IntelliInputDialog::setValuesOfPalette(){
|
||||
@@ -81,7 +82,7 @@ void IntelliInputDialog::setValuesOfPalette(){
|
||||
}
|
||||
|
||||
void IntelliInputDialog::slotCloseEvent(){
|
||||
Dialog->close();
|
||||
this->close();
|
||||
}
|
||||
|
||||
void IntelliInputDialog::slotEingabe(){
|
||||
@@ -95,10 +96,5 @@ void IntelliInputDialog::slotEingabe(){
|
||||
File.write(p);
|
||||
File.close();
|
||||
|
||||
Dialog->close();
|
||||
}
|
||||
|
||||
void IntelliInputDialog::getIntInput(QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step){
|
||||
this->Dialog = new IntelliInputDialog(Loop, Dialog, Title, Label, value, minValue, maxValue, step);
|
||||
Loop->exec();
|
||||
this->close();
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@ class IntelliInputDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IntelliInputDialog(QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1);
|
||||
IntelliInputDialog(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1);
|
||||
|
||||
void getIntInput(QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = "InputBox", QString Label = "Weight:", int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1);
|
||||
|
||||
public slots:
|
||||
void slotCloseEvent();
|
||||
@@ -21,8 +20,6 @@ void createConnections(QEventLoop* Loop = nullptr);
|
||||
void setValuesOfPalette();
|
||||
void setInputBoxStyle();
|
||||
|
||||
QDialog* Dialog;
|
||||
|
||||
QGridLayout* Layout;
|
||||
QDialogButtonBox* ButtonBox;
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "Layer/PaintingArea.h"
|
||||
|
||||
// IntelliPhotoGui constructor
|
||||
IntelliPhotoGui::IntelliPhotoGui(IntelliInputDialog* InputDialog){
|
||||
this->InputDialog = InputDialog;
|
||||
IntelliPhotoGui::IntelliPhotoGui(){
|
||||
// create Gui elements and lay them out
|
||||
createGui();
|
||||
// Create actions
|
||||
@@ -71,11 +70,11 @@ void IntelliPhotoGui::slotCreateNewLayer(){
|
||||
// "New Layer" is the title of the window
|
||||
// the next tr is the text to display
|
||||
// Define the standard Value, min, max, step and ok button
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Layer", "Width:", 200, 0, 5000, 1);
|
||||
IntelliInputDialog widthDialog(&Loop, "New Layer", "Width:", 200, 0, 5000, 1);
|
||||
|
||||
int width = getReturnValueOfDialog();
|
||||
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Layer", "Height:", 200, 0, 5000, 1);
|
||||
IntelliInputDialog heightDialog(&Loop, "New Layer", "Height:", 200, 0, 5000, 1);
|
||||
|
||||
int height = getReturnValueOfDialog();
|
||||
|
||||
@@ -89,7 +88,7 @@ void IntelliPhotoGui::slotDeleteLayer(){
|
||||
// "delete Layer" is the title of the window
|
||||
// the next tr is the text to display
|
||||
// Define the standard Value, min, max, step and ok button
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
||||
IntelliInputDialog dialog(&Loop, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
||||
int layerNumber = getReturnValueOfDialog();
|
||||
|
||||
// Create New Layer
|
||||
@@ -101,11 +100,12 @@ void IntelliPhotoGui::slotSetActiveAlpha(){
|
||||
// "Layer to set on" is the title of the window
|
||||
// the next tr is the text to display
|
||||
// Define the standard Value, min, max, step and ok button
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
||||
|
||||
IntelliInputDialog layerDialog(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
||||
int layer = getReturnValueOfDialog();
|
||||
|
||||
// "New Alpha" is the title of the window
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Alpha", "Alpha:", 255, 0, 255, 1);
|
||||
IntelliInputDialog alphaDialog;(&Loop, "New Alpha", "Alpha:", 255, 0, 255, 1);
|
||||
int alpha = getReturnValueOfDialog();
|
||||
paintingArea->setLayerAlpha(layer-1,alpha);
|
||||
UpdateGui();
|
||||
@@ -145,19 +145,21 @@ void IntelliPhotoGui::slotClearActiveLayer(){
|
||||
// "Red Input" is the title of the window
|
||||
// the next tr is the text to display
|
||||
// Define the standard Value, min, max, step and ok button
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Red Input", "Red:", 255, 0, 255, 1);
|
||||
|
||||
|
||||
IntelliInputDialog redDialog(&Loop, "Red Input", "Red:", 255, 0, 255, 1);
|
||||
int red = getReturnValueOfDialog();
|
||||
|
||||
// "Green Input" is the title of the window
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Green Input", "Green:", 255, 0, 255, 1);
|
||||
IntelliInputDialog greenDialog(&Loop, "Green Input", "Green:", 255, 0, 255, 1);
|
||||
int green = getReturnValueOfDialog();
|
||||
|
||||
// "Blue Input" is the title of the window
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Blue Input", "Blue:", 255, 0, 255, 1);
|
||||
IntelliInputDialog blueDialog(&Loop, "Blue Input", "Blue:", 255, 0, 255, 1);
|
||||
int blue = getReturnValueOfDialog();
|
||||
|
||||
// "Alpha Input" is the title of the window
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Alpha Input", "Alpha:", 255, 0, 255, 1);
|
||||
IntelliInputDialog alphaDialog(&Loop, "Alpha Input", "Alpha:", 255, 0, 255, 1);
|
||||
int alpha = getReturnValueOfDialog();
|
||||
|
||||
paintingArea->floodFill(red, green, blue, alpha);
|
||||
@@ -168,7 +170,7 @@ void IntelliPhotoGui::slotSetActiveLayer(){
|
||||
// "Layer to set on" is the title of the window
|
||||
// the next tr is the text to display
|
||||
// Define the standard Value, min, max, step and ok button
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Layer to set on", "Layer:", 1, 1, 501, 1);
|
||||
IntelliInputDialog dialog(&Loop, "Layer to set on", "Layer:", 1, 1, 501, 1);
|
||||
int layer = getReturnValueOfDialog();
|
||||
paintingArea->setLayerActive(layer-1);
|
||||
UpdateGui();
|
||||
@@ -265,13 +267,13 @@ void IntelliPhotoGui::slotResetTools(){
|
||||
}
|
||||
|
||||
void IntelliPhotoGui::slotSetWidth(){
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Toolsettings", "Width:", 5, 1, 50, 1);
|
||||
IntelliInputDialog dialog(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1);
|
||||
paintingArea->Toolsettings.setLineWidth(getReturnValueOfDialog());
|
||||
EditLineWidth->setText(QString("%1").arg(paintingArea->Toolsettings.getLineWidth()));
|
||||
}
|
||||
|
||||
void IntelliPhotoGui::slotSetInnerAlpha(){
|
||||
this->InputDialog->getIntInput(&Loop, this->InputDialog, "Toolsettings", "Inner Alpha:", 255, 0, 255, 1);
|
||||
IntelliInputDialog dialog(&Loop, "Toolsettings", "Inner Alpha:", 255, 0, 255, 1);
|
||||
paintingArea->Toolsettings.setInnerAlpha(getReturnValueOfDialog());
|
||||
EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha()));
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
/*!
|
||||
* \brief The IntelliPhotoGui method is the constructor and is used to create a new instance of the main program window
|
||||
*/
|
||||
IntelliPhotoGui(IntelliInputDialog* InputDialog);
|
||||
IntelliPhotoGui();
|
||||
|
||||
void UpdateGui();
|
||||
|
||||
@@ -109,7 +109,6 @@ int getReturnValueOfDialog();
|
||||
|
||||
// What we'll draw on
|
||||
PaintingArea* paintingArea;
|
||||
IntelliInputDialog* InputDialog;
|
||||
QEventLoop Loop;
|
||||
|
||||
const QSize Buttonsize = QSize(35,35);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "GUI/IntelliPhotoGui.h"
|
||||
#include "GUI/IntelliInputDialog.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <vector>
|
||||
@@ -8,10 +7,8 @@ int main(int argc, char*argv[]){
|
||||
// The main application
|
||||
QApplication app(argc, argv);
|
||||
|
||||
IntelliInputDialog* InputDialog;
|
||||
|
||||
// Create and open the main window
|
||||
IntelliPhotoGui window(InputDialog);
|
||||
IntelliPhotoGui window;
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
|
||||
Reference in New Issue
Block a user