Fixed Inputboxes and Design

Todo pls merge me.
This commit is contained in:
Jan Schuffenhauer
2020-01-16 00:00:27 +01:00
parent 5f76f74cd5
commit b695a25128
7 changed files with 92 additions and 83 deletions

View File

@@ -2,18 +2,21 @@
#include <QFile> #include <QFile>
IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step) IntelliInputDialog::IntelliInputDialog(QString Title, QString Label, int value, int minValue, int maxValue, int step, bool* ok)
{ {
this->valueInt = value; this->valueInt = value;
this->notClosed = ok;
if(notClosed != nullptr){
*notClosed = false;
}
createInputBox(Title, Label, value, minValue, maxValue, step); createInputBox(Title, Label, value, minValue, maxValue, step);
createConnections(Loop); createConnections();
setValuesOfPalette();
setInputBoxStyle(); setInputBoxStyle();
Loop->exec(); this->exec();
} }
int IntelliInputDialog::getInt(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step){ int IntelliInputDialog::getInt(QString Title, QString Label, int value, int minValue, int maxValue, int step, bool* ok){
IntelliInputDialog dialog(Loop, Title, Label, value, minValue, maxValue, step); IntelliInputDialog dialog(Title, Label, value, minValue, maxValue, step, ok);
return dialog.valueInt; return dialog.valueInt;
} }
@@ -40,6 +43,7 @@ void IntelliInputDialog::createInputBox(QString Title, QString Label, int value,
this->Input = new QSpinBox(); this->Input = new QSpinBox();
this->Input->setFixedSize(Linesize); this->Input->setFixedSize(Linesize);
this->Input->setRange(minValue,maxValue); this->Input->setRange(minValue,maxValue);
this->Input->setSingleStep(step);
this->Input->setValue(value); this->Input->setValue(value);
this->okButton = ButtonBox->button(QDialogButtonBox::Ok); this->okButton = ButtonBox->button(QDialogButtonBox::Ok);
@@ -60,31 +64,13 @@ void IntelliInputDialog::createInputBox(QString Title, QString Label, int value,
this->show(); this->show();
} }
void IntelliInputDialog::createConnections(QEventLoop* Loop){ void IntelliInputDialog::createConnections(){
connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe())); connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe()));
connect(okButton, SIGNAL(clicked()), Loop, SLOT(quit()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCloseEvent())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCloseEvent()));
connect(cancelButton, SIGNAL(clicked()), Loop, SLOT(quit()));
} }
void IntelliInputDialog::setInputBoxStyle(){ void IntelliInputDialog::setInputBoxStyle(){
InputLabel->setPalette(Palette); this->setStyleSheet("color: white;" "background-color: rgb(64, 64, 64);" "selection-color: rgb(200, 10, 10);" "selection-background-color: rgb(64, 64, 64);");
Input->setPalette(Palette);
okButton->setPalette(Palette);
cancelButton->setPalette(Palette);
this->setStyleSheet("background-color:rgb(64,64,64)");
}
void IntelliInputDialog::setValuesOfPalette(){
Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10));
Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5));
Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255));
Palette.setBrush(QPalette::Button, QColor(64, 64, 64));
Palette.setBrush(QPalette::Window, QColor(64, 64, 64));
Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255));
Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255));
Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255));
Palette.setBrush(QPalette::Text, QColor(255, 255, 255));
} }
void IntelliInputDialog::slotCloseEvent(){ void IntelliInputDialog::slotCloseEvent(){
@@ -93,4 +79,8 @@ void IntelliInputDialog::slotCloseEvent(){
void IntelliInputDialog::slotEingabe(){ void IntelliInputDialog::slotEingabe(){
valueInt = QString("%1").arg(Input->value()).toInt(); valueInt = QString("%1").arg(Input->value()).toInt();
if(notClosed != nullptr){
*notClosed = true;
}
this->close();
} }

View File

@@ -7,10 +7,10 @@ class IntelliInputDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
IntelliInputDialog(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); IntelliInputDialog(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool* ok = nullptr);
static int getInt(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); static int getInt(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool* ok = nullptr);
public slots: public slots:
void slotCloseEvent(); void slotCloseEvent();
@@ -18,8 +18,7 @@ void slotEingabe();
private: private:
void createInputBox(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); void createInputBox(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1);
void createConnections(QEventLoop* Loop = nullptr); void createConnections();
void setValuesOfPalette();
void setInputBoxStyle(); void setInputBoxStyle();
int valueInt; int valueInt;
@@ -27,10 +26,10 @@ int valueInt;
QGridLayout* Layout; QGridLayout* Layout;
QDialogButtonBox* ButtonBox; QDialogButtonBox* ButtonBox;
QEventLoop loop; QEventLoop loop;
bool* notClosed;
const QSize Linesize = QSize(150,20); const QSize Linesize = QSize(150,20);
const QSize Buttonsize = QSize(72,20); const QSize Buttonsize = QSize(72,20);
QPalette Palette;
QLabel* InputLabel; QLabel* InputLabel;
QSpinBox* Input; QSpinBox* Input;
QPushButton* okButton; QPushButton* okButton;

View File

@@ -67,41 +67,54 @@ void IntelliPhotoGui::slotSave(){
// Opens a dialog that allows the user to create a New Layer // Opens a dialog that allows the user to create a New Layer
void IntelliPhotoGui::slotCreateNewLayer(){ void IntelliPhotoGui::slotCreateNewLayer(){
bool ok1, ok2;
// "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
int width = IntelliInputDialog::getInt(&Loop, "New Layer", "Width:", 200, 0, 5000, 1); int width = IntelliInputDialog::getInt("New Layer", "Width:", 200, 1, paintingArea->getMaxWidth(), 1, &ok1);
int height = IntelliInputDialog::getInt(&Loop, "New Layer", "Height:", 200, 0, 5000, 1); int height = IntelliInputDialog::getInt("New Layer", "Height:", 200, 1, paintingArea->getMaxHeight(), 1, &ok2);
// Create New Layer // Create New Layer
paintingArea->addLayer(width,height,0,0); if(ok1&&ok2){
UpdateGui(); paintingArea->addLayer(width,height,0,0);
UpdateGui();
}
} }
// Opens a dialog that allows the user to delete a Layer // Opens a dialog that allows the user to delete a Layer
void IntelliPhotoGui::slotDeleteLayer(){ void IntelliPhotoGui::slotDeleteLayer(){
bool ok1;
// "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
int layerNumber = IntelliInputDialog::getInt(&Loop, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); int layerNumber = IntelliInputDialog::getInt("Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, static_cast<int>(paintingArea->layerBundle.size()), 1, &ok1);
// Create New Layer // Create New Layer
paintingArea->deleteLayer(layerNumber-1); if(ok1){
UpdateGui(); paintingArea->deleteLayer(layerNumber-1);
UpdateGui();
}
} }
void IntelliPhotoGui::slotSetActiveAlpha(){ void IntelliPhotoGui::slotSetActiveAlpha(){
bool ok1, ok2;
// "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
int layer = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); int layer = IntelliInputDialog::getInt("Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, static_cast<int>(paintingArea->layerBundle.size()), 1, &ok1);
// "New Alpha" is the title of the window // "New Alpha" is the title of the window
int alpha = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); int alpha = IntelliInputDialog::getInt("Layer to set on", "Alpha:", 255, 0, 255, 1, &ok2);
paintingArea->setLayerAlpha(layer-1,alpha);
UpdateGui(); if(ok1&&ok2){
paintingArea->setLayerAlpha(layer-1,alpha);
UpdateGui();
}
} }
void IntelliPhotoGui::slotPositionMoveUp(){ void IntelliPhotoGui::slotPositionMoveUp(){
@@ -140,28 +153,31 @@ void IntelliPhotoGui::slotClearActiveLayer(){
// 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 // "Red Input" is the title of the window
int red = IntelliInputDialog::getInt(&Loop, "Green Input", "Green:", 255, 0, 255, 1); int red = IntelliInputDialog::getInt("Green Input", "Green:", 255, 0, 255, 1);
// "Green Input" is the title of the window // "Green Input" is the title of the window
int green = IntelliInputDialog::getInt(&Loop, "Green Input", "Green:", 255, 0, 255, 1); int green = IntelliInputDialog::getInt("Green Input", "Green:", 255, 0, 255, 1);
// "Blue Input" is the title of the window // "Blue Input" is the title of the window
int blue = IntelliInputDialog::getInt(&Loop, "Blue Input", "Blue:", 255, 0, 255, 1); int blue = IntelliInputDialog::getInt("Blue Input", "Blue:", 255, 0, 255, 1);
// "Alpha Input" is the title of the window // "Alpha Input" is the title of the window
int alpha = IntelliInputDialog::getInt(&Loop, "Alpha Input", "Alpha:", 255, 0, 255, 1); int alpha = IntelliInputDialog::getInt("Alpha Input", "Alpha:", 255, 0, 255, 1);
paintingArea->floodFill(red, green, blue, alpha); paintingArea->floodFill(red, green, blue, alpha);
UpdateGui(); UpdateGui();
} }
void IntelliPhotoGui::slotSetActiveLayer(){ void IntelliPhotoGui::slotSetActiveLayer(){
bool ok1;
// "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
int layer = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", 1, 1, 501, 1); int layer = IntelliInputDialog::getInt("Layer to set on", "Layer:", 1, 1, static_cast<int>(paintingArea->layerBundle.size()), 1, &ok1);
paintingArea->setLayerActive(layer-1); if(ok1){
UpdateGui(); paintingArea->setLayerActive(layer-1);
UpdateGui();
}
} }
void IntelliPhotoGui::slotUpdateRenderSettingsOn(){ void IntelliPhotoGui::slotUpdateRenderSettingsOn(){
@@ -255,13 +271,21 @@ void IntelliPhotoGui::slotResetTools(){
} }
void IntelliPhotoGui::slotSetWidth(){ void IntelliPhotoGui::slotSetWidth(){
paintingArea->Toolsettings.setLineWidth(IntelliInputDialog::getInt(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1)); bool ok1;
EditLineWidth->setText(QString("%1").arg(paintingArea->Toolsettings.getLineWidth())); int temp = IntelliInputDialog::getInt("Toolsettings", "Width:", 5, 1, 50, 1, &ok1);
if(ok1){
paintingArea->Toolsettings.setLineWidth(temp);
EditLineWidth->setText(QString("%1").arg(temp));
}
} }
void IntelliPhotoGui::slotSetInnerAlpha(){ void IntelliPhotoGui::slotSetInnerAlpha(){
paintingArea->Toolsettings.setInnerAlpha(IntelliInputDialog::getInt(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1)); bool ok1;
EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha())); int temp = IntelliInputDialog::getInt("Toolsettings", "Width:", 5, 1, 50, 1, &ok1);
if(ok1){
paintingArea->Toolsettings.setInnerAlpha(temp);
EditLineInnerAlpha->setText(QString("%1").arg(temp));
}
} }
// Define menu actions that call functions // Define menu actions that call functions
@@ -670,34 +694,8 @@ void IntelliPhotoGui::createGui(){
void IntelliPhotoGui::setIntelliStyle(){ void IntelliPhotoGui::setIntelliStyle(){
// Set the title // Set the title
setWindowTitle("IntelliPhoto Prototype"); setWindowTitle("IntelliPhoto Prototype");
Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10));
Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5));
Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255));
Palette.setBrush(QPalette::Button, QColor(64, 64, 64));
Palette.setBrush(QPalette::Window, QColor(64, 64, 64));
Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255));
Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255));
Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255));
Palette.setBrush(QPalette::Text, QColor(255, 255, 255));
// Set style sheet // Set style sheet
this->setStyleSheet("background-color:rgb(64,64,64)"); this->setStyleSheet("color: white;" "background-color: rgb(64, 64, 64);" "selection-color: rgb(200, 10, 10);" "selection-background-color: rgb(64, 64, 64);");
this->menuBar()->setPalette(Palette);
this->fileMenu->setPalette(Palette);
this->saveAsMenu->setPalette(Palette);
this->optionMenu->setPalette(Palette);
this->helpMenu->setPalette(Palette);
this->renderMenu->setPalette(Palette);
this->toolMenu->setPalette(Palette);
this->layerMenu->setPalette(Palette);
this->colorMenu->setPalette(Palette);
this->toolCreationMenu->setPalette(Palette);
this->toolSettingsMenu->setPalette(Palette);
this->WidthLine->setPalette(Palette);
this->EditLineWidth->setPalette(Palette);
this->innerAlphaLine->setPalette(Palette);
this->EditLineInnerAlpha->setPalette(Palette);
this->ActiveLayerLine->setPalette(Palette);
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name()); QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string); FirstColorButton->setStyleSheet(string);

View File

@@ -107,7 +107,6 @@ void setDefaultToolValue();
// What we'll draw on // What we'll draw on
PaintingArea* paintingArea; PaintingArea* paintingArea;
QEventLoop Loop;
const QSize Buttonsize = QSize(35,35); const QSize Buttonsize = QSize(35,35);
QPixmap preview; QPixmap preview;
@@ -132,8 +131,6 @@ QPushButton* SwitchColorButton;
QLabel* ActiveLayerLine; QLabel* ActiveLayerLine;
QLabel* ActiveLayerImageLabel; QLabel* ActiveLayerImageLabel;
QPalette Palette;
// The menu widgets // The menu widgets
QMenu*saveAsMenu; QMenu*saveAsMenu;
QMenu*fileMenu; QMenu*fileMenu;

View File

@@ -17,6 +17,12 @@ int IntelliToolsettings::getLineWidth(){
} }
void IntelliToolsettings::setLineWidth(int LineWidth){ void IntelliToolsettings::setLineWidth(int LineWidth){
if(LineWidth < 1){
LineWidth = 1;
}
else if(LineWidth > 50){
LineWidth = 50;
}
lineWidth = LineWidth; lineWidth = LineWidth;
} }
@@ -25,6 +31,12 @@ int IntelliToolsettings::getInnerAlpha(){
} }
void IntelliToolsettings::setInnerAlpha(int innerAlpha){ void IntelliToolsettings::setInnerAlpha(int innerAlpha){
if(innerAlpha < 0){
innerAlpha = 0;
}
else if(innerAlpha > 255){
innerAlpha = 255;
}
this->innerAlpha = innerAlpha; this->innerAlpha = innerAlpha;
} }

View File

@@ -182,6 +182,7 @@ void PaintingArea::moveActiveLayer(int idx){
}else if(idx==-1) { }else if(idx==-1) {
this->selectLayerDown(); this->selectLayerDown();
} }
DummyGui->UpdateGui();
} }
void PaintingArea::slotActivateLayer(int a){ void PaintingArea::slotActivateLayer(int a){
@@ -253,6 +254,14 @@ int PaintingArea::getHeightOfActive(){
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].height; return this->layerBundle[static_cast<unsigned long long>(activeLayer)].height;
} }
int PaintingArea::getMaxWidth(){
return this->maxWidth;
}
int PaintingArea::getMaxHeight(){
return this->maxHeight;
}
IntelliImage::ImageType PaintingArea::getTypeOfImageRealLayer(){ IntelliImage::ImageType PaintingArea::getTypeOfImageRealLayer(){
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].image->getTypeOfImage(); return this->layerBundle[static_cast<unsigned long long>(activeLayer)].image->getTypeOfImage();
} }

View File

@@ -169,6 +169,10 @@ int getWidthOfActive();
*/ */
int getHeightOfActive(); int getHeightOfActive();
int getMaxWidth();
int getMaxHeight();
IntelliImage::ImageType getTypeOfImageRealLayer(); IntelliImage::ImageType getTypeOfImageRealLayer();
std::vector<QPoint> getPolygonDataOfRealLayer(); std::vector<QPoint> getPolygonDataOfRealLayer();