mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-15 04:40:37 +02:00
code cleanup #2
This commit is contained in:
@@ -11,6 +11,11 @@ IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, QString Title, QString
|
|||||||
Loop->exec();
|
Loop->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int IntelliInputDialog::getInt(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step){
|
||||||
|
IntelliInputDialog dialog(Loop, Title, Label, value, minValue, maxValue, step);
|
||||||
|
return dialog.valueInt;
|
||||||
|
}
|
||||||
|
|
||||||
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->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
if(Title == nullptr) {
|
if(Title == nullptr) {
|
||||||
@@ -86,15 +91,5 @@ void IntelliInputDialog::slotCloseEvent(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliInputDialog::slotEingabe(){
|
void IntelliInputDialog::slotEingabe(){
|
||||||
QFile File("test.txt");
|
valueInt= QString("%1").arg(Input->value()).toInt();
|
||||||
|
|
||||||
if(!File.open(QIODevice::WriteOnly | QIODevice::Text)){
|
|
||||||
qDebug() << "Error Write to File";
|
|
||||||
}
|
|
||||||
std::string test = QString("%1").arg(Input->value()).toStdString();
|
|
||||||
const char* p = test.c_str();
|
|
||||||
File.write(p);
|
|
||||||
File.close();
|
|
||||||
|
|
||||||
this->close();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ public:
|
|||||||
IntelliInputDialog(QEventLoop* Loop = 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);
|
||||||
|
|
||||||
|
|
||||||
|
static int getInt(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slotCloseEvent();
|
void slotCloseEvent();
|
||||||
void slotEingabe();
|
void slotEingabe();
|
||||||
@@ -20,8 +22,11 @@ void createConnections(QEventLoop* Loop = nullptr);
|
|||||||
void setValuesOfPalette();
|
void setValuesOfPalette();
|
||||||
void setInputBoxStyle();
|
void setInputBoxStyle();
|
||||||
|
|
||||||
|
int valueInt;
|
||||||
|
|
||||||
QGridLayout* Layout;
|
QGridLayout* Layout;
|
||||||
QDialogButtonBox* ButtonBox;
|
QDialogButtonBox* ButtonBox;
|
||||||
|
QEventLoop loop;
|
||||||
|
|
||||||
const QSize Linesize = QSize(150,20);
|
const QSize Linesize = QSize(150,20);
|
||||||
const QSize Buttonsize = QSize(72,20);
|
const QSize Buttonsize = QSize(72,20);
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ IntelliPhotoGui::IntelliPhotoGui(){
|
|||||||
setIntelliStyle();
|
setIntelliStyle();
|
||||||
// Size the app
|
// Size the app
|
||||||
resize(600,600);
|
resize(600,600);
|
||||||
//showMaximized();
|
//showMaximized();
|
||||||
setDefaultToolValue();
|
setDefaultToolValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// User tried to close the app
|
// User tried to close the app
|
||||||
@@ -70,13 +70,9 @@ 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
|
||||||
IntelliInputDialog widthDialog(&Loop, "New Layer", "Width:", 200, 0, 5000, 1);
|
int width = IntelliInputDialog::getInt(&Loop, "New Layer", "Width:", 200, 0, 5000, 1);
|
||||||
|
|
||||||
int width = getReturnValueOfDialog();
|
int height = IntelliInputDialog::getInt(&Loop, "New Layer", "Height:", 200, 0, 5000, 1);
|
||||||
|
|
||||||
IntelliInputDialog heightDialog(&Loop, "New Layer", "Height:", 200, 0, 5000, 1);
|
|
||||||
|
|
||||||
int height = getReturnValueOfDialog();
|
|
||||||
|
|
||||||
// Create New Layer
|
// Create New Layer
|
||||||
paintingArea->addLayer(width,height,0,0);
|
paintingArea->addLayer(width,height,0,0);
|
||||||
@@ -88,8 +84,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
|
||||||
IntelliInputDialog dialog(&Loop, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
int layerNumber = IntelliInputDialog::getInt(&Loop, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
||||||
int layerNumber = getReturnValueOfDialog();
|
|
||||||
|
|
||||||
// Create New Layer
|
// Create New Layer
|
||||||
paintingArea->deleteLayer(layerNumber-1);
|
paintingArea->deleteLayer(layerNumber-1);
|
||||||
@@ -101,12 +96,10 @@ void IntelliPhotoGui::slotSetActiveAlpha(){
|
|||||||
// 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
|
||||||
|
|
||||||
IntelliInputDialog layerDialog(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
int layer = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
||||||
int layer = getReturnValueOfDialog();
|
|
||||||
|
|
||||||
// "New Alpha" is the title of the window
|
// "New Alpha" is the title of the window
|
||||||
IntelliInputDialog alphaDialog;(&Loop, "New Alpha", "Alpha:", 255, 0, 255, 1);
|
int alpha = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1);
|
||||||
int alpha = getReturnValueOfDialog();
|
|
||||||
paintingArea->setLayerAlpha(layer-1,alpha);
|
paintingArea->setLayerAlpha(layer-1,alpha);
|
||||||
UpdateGui();
|
UpdateGui();
|
||||||
}
|
}
|
||||||
@@ -146,21 +139,17 @@ void IntelliPhotoGui::slotClearActiveLayer(){
|
|||||||
// 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
|
||||||
|
|
||||||
|
// "Red Input" is the title of the window
|
||||||
IntelliInputDialog redDialog(&Loop, "Red Input", "Red:", 255, 0, 255, 1);
|
int red = IntelliInputDialog::getInt(&Loop, "Green Input", "Green:", 255, 0, 255, 1);
|
||||||
int red = getReturnValueOfDialog();
|
|
||||||
|
|
||||||
// "Green Input" is the title of the window
|
// "Green Input" is the title of the window
|
||||||
IntelliInputDialog greenDialog(&Loop, "Green Input", "Green:", 255, 0, 255, 1);
|
int green = IntelliInputDialog::getInt(&Loop, "Green Input", "Green:", 255, 0, 255, 1);
|
||||||
int green = getReturnValueOfDialog();
|
|
||||||
|
|
||||||
// "Blue Input" is the title of the window
|
// "Blue Input" is the title of the window
|
||||||
IntelliInputDialog blueDialog(&Loop, "Blue Input", "Blue:", 255, 0, 255, 1);
|
int blue = IntelliInputDialog::getInt(&Loop, "Blue Input", "Blue:", 255, 0, 255, 1);
|
||||||
int blue = getReturnValueOfDialog();
|
|
||||||
|
|
||||||
// "Alpha Input" is the title of the window
|
// "Alpha Input" is the title of the window
|
||||||
IntelliInputDialog alphaDialog(&Loop, "Alpha Input", "Alpha:", 255, 0, 255, 1);
|
int alpha = IntelliInputDialog::getInt(&Loop, "Alpha Input", "Alpha:", 255, 0, 255, 1);
|
||||||
int alpha = getReturnValueOfDialog();
|
|
||||||
|
|
||||||
paintingArea->floodFill(red, green, blue, alpha);
|
paintingArea->floodFill(red, green, blue, alpha);
|
||||||
UpdateGui();
|
UpdateGui();
|
||||||
@@ -170,8 +159,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
|
||||||
IntelliInputDialog dialog(&Loop, "Layer to set on", "Layer:", 1, 1, 501, 1);
|
int layer = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", 1, 1, 501, 1);
|
||||||
int layer = getReturnValueOfDialog();
|
|
||||||
paintingArea->setLayerActive(layer-1);
|
paintingArea->setLayerActive(layer-1);
|
||||||
UpdateGui();
|
UpdateGui();
|
||||||
}
|
}
|
||||||
@@ -244,16 +232,16 @@ void IntelliPhotoGui::slotAboutDialog(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::slotEnterPressed(){
|
void IntelliPhotoGui::slotEnterPressed(){
|
||||||
QString string = EditLineWidth->text();
|
QString string = EditLineWidth->text();
|
||||||
if(string.toInt() > 50) {
|
if(string.toInt() > 50) {
|
||||||
EditLineWidth->setText("50");
|
EditLineWidth->setText("50");
|
||||||
}
|
}
|
||||||
paintingArea->Toolsettings.setLineWidth(string.toInt());
|
paintingArea->Toolsettings.setLineWidth(string.toInt());
|
||||||
string = EditLineInnerAlpha->text();
|
string = EditLineInnerAlpha->text();
|
||||||
if(string.toInt() > 255) {
|
if(string.toInt() > 255) {
|
||||||
EditLineInnerAlpha->setText("255");
|
EditLineInnerAlpha->setText("255");
|
||||||
}
|
}
|
||||||
paintingArea->Toolsettings.setInnerAlpha(string.toInt());
|
paintingArea->Toolsettings.setInnerAlpha(string.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::slotResetTools(){
|
void IntelliPhotoGui::slotResetTools(){
|
||||||
@@ -267,14 +255,12 @@ void IntelliPhotoGui::slotResetTools(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::slotSetWidth(){
|
void IntelliPhotoGui::slotSetWidth(){
|
||||||
IntelliInputDialog dialog(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1);
|
paintingArea->Toolsettings.setLineWidth(IntelliInputDialog::getInt(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1));
|
||||||
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(){
|
||||||
IntelliInputDialog dialog(&Loop, "Toolsettings", "Inner Alpha:", 255, 0, 255, 1);
|
paintingArea->Toolsettings.setInnerAlpha(IntelliInputDialog::getInt(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1));
|
||||||
paintingArea->Toolsettings.setInnerAlpha(getReturnValueOfDialog());
|
|
||||||
EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha()));
|
EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,7 +754,7 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::setDefaultToolValue(){
|
void IntelliPhotoGui::setDefaultToolValue(){
|
||||||
slotEnterPressed();
|
slotEnterPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::setToolWidth(int value){
|
void IntelliPhotoGui::setToolWidth(int value){
|
||||||
@@ -799,15 +785,3 @@ void IntelliPhotoGui::UpdateGui(){
|
|||||||
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
|
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
|
||||||
SecondColorButton->setStyleSheet(string);
|
SecondColorButton->setStyleSheet(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IntelliPhotoGui::getReturnValueOfDialog(){
|
|
||||||
QFile File("test.txt");
|
|
||||||
if(!File.open(QIODevice::ReadOnly | QIODevice::Text)){
|
|
||||||
qDebug() << "Error Read from File";
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray line = File.readLine();
|
|
||||||
File.close();
|
|
||||||
|
|
||||||
return line.toInt();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -105,8 +105,6 @@ bool saveFile(const QByteArray &fileFormat);
|
|||||||
|
|
||||||
void setDefaultToolValue();
|
void setDefaultToolValue();
|
||||||
|
|
||||||
int getReturnValueOfDialog();
|
|
||||||
|
|
||||||
// What we'll draw on
|
// What we'll draw on
|
||||||
PaintingArea* paintingArea;
|
PaintingArea* paintingArea;
|
||||||
QEventLoop Loop;
|
QEventLoop Loop;
|
||||||
|
|||||||
Reference in New Issue
Block a user