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