22 setDefaultToolValue();
39 void IntelliPhotoGui::slotOpen(){
47 QString fileName = QFileDialog::getOpenFileName(
this,
48 tr(
"Open File"), QDir::currentPath(),
nullptr,
nullptr, QFileDialog::DontUseNativeDialog);
52 if (!fileName.isEmpty()) {
53 paintingArea->
open(fileName);
60 void IntelliPhotoGui::slotSave(){
62 QAction*action = qobject_cast<QAction*>(sender());
65 QByteArray fileFormat = action->data().toByteArray();
72 void IntelliPhotoGui::slotCreateNewRasterLayer(){
91 void IntelliPhotoGui::slotCreateNewShapedLayer(){
110 void IntelliPhotoGui::slotChangeDim(){
123 paintingArea->setLayerDimensions(width,height);
129 void IntelliPhotoGui::slotDeleteLayer(){
144 void IntelliPhotoGui::slotSetActiveAlpha(){
163 void IntelliPhotoGui::slotSetPolygon(){
179 void IntelliPhotoGui::slotPositionMoveUp(){
184 void IntelliPhotoGui::slotPositionMoveDown(){
189 void IntelliPhotoGui::slotPositionMoveLeft(){
194 void IntelliPhotoGui::slotPositionMoveRight(){
199 void IntelliPhotoGui::slotMoveLayerUp(){
204 void IntelliPhotoGui::slotMoveLayerDown(){
209 void IntelliPhotoGui::slotSetActiveLayer(){
214 int layer =
IntelliInputDialog::getInt(
"Layer to set on",
"Layer:", 1, 1,
static_cast<int>(paintingArea->layerBundle.size()), 1, &ok1);
222 void IntelliPhotoGui::slotUpdateRenderSettingsOn(){
227 void IntelliPhotoGui::slotUpdateRenderSettingsOff(){
232 void IntelliPhotoGui::slotSetFirstColor(){
237 void IntelliPhotoGui::slotSetSecondColor(){
242 void IntelliPhotoGui::slotSwapColor(){
247 void IntelliPhotoGui::slotCreatePenTool(){
248 PenButton->setChecked(
true);
252 void IntelliPhotoGui::slotCreatePlainTool(){
253 PlainButton->setChecked(
true);
257 void IntelliPhotoGui::slotCreateLineTool(){
258 LineButton->setChecked(
true);
262 void IntelliPhotoGui::slotCreateRectangleTool(){
263 RectangleButton->setChecked(
true);
267 void IntelliPhotoGui::slotCreateCircleTool(){
268 CircleButton->setChecked(
true);
272 void IntelliPhotoGui::slotCreatePolygonTool(){
273 PolygonButton->setChecked(
true);
277 void IntelliPhotoGui::slotCreateFloodFillTool(){
278 FloodFillButton->setChecked(
true);
283 void IntelliPhotoGui::slotAboutDialog(){
285 QMessageBox::about(
this, tr(
"About Painting"),
286 tr(
"<p><b>IntelliPhoto - </b>A Pretty basic editor.</p> <br>Developed by Team 7."));
289 void IntelliPhotoGui::slotEnterPressed(){
290 QString
string = EditLineWidth->text();
291 if(
string.toInt() > 50) {
292 EditLineWidth->setText(
"50");
295 string = EditLineInnerAlpha->text();
296 if(
string.toInt() > 255) {
297 EditLineInnerAlpha->setText(
"255");
302 void IntelliPhotoGui::slotResetTools(){
303 CircleButton->setChecked(
false);
304 FloodFillButton->setChecked(
false);
305 LineButton->setChecked(
false);
306 PenButton->setChecked(
false);
307 PlainButton->setChecked(
false);
308 PolygonButton->setChecked(
false);
309 RectangleButton->setChecked(
false);
312 void IntelliPhotoGui::slotSetWidth(){
317 EditLineWidth->setText(QString(
"%1").arg(temp));
321 void IntelliPhotoGui::slotSetInnerAlpha(){
326 EditLineInnerAlpha->setText(QString(
"%1").arg(temp));
331 void IntelliPhotoGui::createActions(){
334 foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
335 QString text = tr(
"%1...").arg(QString(format).toUpper());
338 QAction*action =
new QAction(text,
this);
341 action->setData(format);
344 connect(action, SIGNAL(triggered()),
this, SLOT(slotSave()));
347 actionSaveAs.append(action);
351 QAction*pngSaveAction =
new QAction(
"PNG-8",
this);
352 pngSaveAction->setData(
"PNG");
354 connect(pngSaveAction, SIGNAL(triggered()),
this, SLOT(slotSave()));
356 actionSaveAs.append(pngSaveAction);
357 pngSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
360 actionExit =
new QAction(tr(
"&Exit"),
this);
361 actionExit->setShortcuts(QKeySequence::Quit);
362 connect(actionExit, SIGNAL(triggered()),
this, SLOT(close()));
364 actionOpen =
new QAction(tr(
"&Open"),
this);
365 actionOpen->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
366 connect(actionOpen, SIGNAL(triggered()),
this, SLOT(slotOpen()));
369 actionCreateNewRasterLayer =
new QAction(tr(
"&Raster Image"),
this);
370 actionCreateNewRasterLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
371 connect(actionCreateNewRasterLayer, SIGNAL(triggered()),
this, SLOT(slotCreateNewRasterLayer()));
375 actionCreateNewShapedLayer =
new QAction(tr(
"&Shaped Image"),
this);
376 actionCreateNewShapedLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N + Qt::ALT));
377 connect(actionCreateNewShapedLayer, SIGNAL(triggered()),
this, SLOT(slotCreateNewShapedLayer()));
380 actionDeleteLayer =
new QAction(tr(
"&Delete Layer..."),
this);
381 actionDeleteLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_D));
382 connect(actionDeleteLayer, SIGNAL(triggered()),
this, SLOT(slotDeleteLayer()));
384 actionChangeDim =
new QAction(tr(
"&Change Dimension"),
this);
385 actionChangeDim->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_X));
386 connect(actionChangeDim, SIGNAL(triggered()),
this, SLOT(slotChangeDim()));
387 connect(dimCanvas, SIGNAL(clicked()),
this, SLOT(slotChangeDim()));
389 actionSetActiveLayer =
new QAction(tr(
"&set Active"),
this);
390 actionSetActiveLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
391 connect(actionSetActiveLayer, SIGNAL(triggered()),
this, SLOT(slotSetActiveLayer()));
393 actionSetActiveAlpha =
new QAction(tr(
"&set Alpha"),
this);
394 actionSetActiveAlpha->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_A));
395 connect(actionSetActiveAlpha, SIGNAL(triggered()),
this, SLOT(slotSetActiveAlpha()));
397 actionSetPolygon =
new QAction(tr(
"&set new Polygondata"),
this);
398 actionSetPolygon->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_P));
399 connect(actionSetPolygon, SIGNAL(triggered()),
this, SLOT(slotSetPolygon()));
401 actionMovePositionUp =
new QAction(tr(
"&move Up"),
this);
402 actionMovePositionUp->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up));
403 connect(actionMovePositionUp, SIGNAL(triggered()),
this, SLOT(slotPositionMoveUp()));
405 actionMovePositionDown =
new QAction(tr(
"&move Down"),
this);
406 actionMovePositionDown->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down));
407 connect(actionMovePositionDown, SIGNAL(triggered()),
this, SLOT(slotPositionMoveDown()));
409 actionMovePositionLeft =
new QAction(tr(
"&move Left"),
this);
410 actionMovePositionLeft->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left));
411 connect(actionMovePositionLeft, SIGNAL(triggered()),
this, SLOT(slotPositionMoveLeft()));
413 actionMovePositionRight =
new QAction(tr(
"&move Right"),
this);
414 actionMovePositionRight->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right));
415 connect(actionMovePositionRight, SIGNAL(triggered()),
this, SLOT(slotPositionMoveRight()));
417 actionMoveLayerUp =
new QAction(tr(
"&move Layer Up"),
this);
418 actionMoveLayerUp->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Up));
419 connect(actionMoveLayerUp, SIGNAL(triggered()),
this, SLOT(slotMoveLayerUp()));
421 actionMoveLayerDown =
new QAction(tr(
"&move Layer Down"),
this);
422 actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
423 connect(actionMoveLayerDown, SIGNAL(triggered()),
this, SLOT(slotMoveLayerDown()));
426 actionUpdateRenderSettingsOn =
new QAction(tr(
"&On"),
this);
427 actionUpdateRenderSettingsOn->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + +Qt::Key_A));
428 connect(actionUpdateRenderSettingsOn, SIGNAL(triggered()),
this, SLOT(slotUpdateRenderSettingsOn()));
430 actionUpdateRenderSettingsOff =
new QAction(tr(
"&Off"),
this);
431 actionUpdateRenderSettingsOff->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + +Qt::Key_D));
432 connect(actionUpdateRenderSettingsOff, SIGNAL(triggered()),
this, SLOT(slotUpdateRenderSettingsOff()));
435 actionColorPickerFirstColor =
new QAction(tr(
"&Main"),
this);
436 actionColorPickerFirstColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_N));
437 connect(actionColorPickerFirstColor, SIGNAL(triggered()),
this, SLOT(slotSetFirstColor()));
438 connect(FirstColorButton, SIGNAL(clicked()),
this, SLOT(slotSetFirstColor()));
440 actionColorPickerSecondColor =
new QAction(tr(
"&Secondary"),
this);
441 actionColorPickerSecondColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_M));
442 connect(actionColorPickerSecondColor, SIGNAL(triggered()),
this, SLOT(slotSetSecondColor()));
443 connect(SecondColorButton, SIGNAL(clicked()),
this, SLOT(slotSetSecondColor()));
445 actionColorSwap =
new QAction(tr(
"&Switch"),
this);
446 actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S));
447 connect(actionColorSwap, SIGNAL(triggered()),
this, SLOT(slotSwapColor()));
448 connect(SwitchColorButton, SIGNAL(clicked()),
this, SLOT(slotSwapColor()));
451 actionCreatePlainTool =
new QAction(tr(
"&Plain"),
this);
452 actionCreatePlainTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_P));
453 connect(actionCreatePlainTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
454 connect(actionCreatePlainTool, SIGNAL(triggered()),
this, SLOT(slotCreatePlainTool()));
457 actionCreatePenTool =
new QAction(tr(
"&Pen"),
this);
458 actionCreatePenTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_S));
459 connect(actionCreatePenTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
460 connect(actionCreatePenTool, SIGNAL(triggered()),
this, SLOT(slotCreatePenTool()));
462 actionCreateLineTool =
new QAction(tr(
"&Line"),
this);
463 actionCreateLineTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_L));
464 connect(actionCreateLineTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
465 connect(actionCreateLineTool, SIGNAL(triggered()),
this, SLOT(slotCreateLineTool()));
467 actionCreateCircleTool =
new QAction(tr(
"&Circle"),
this);
468 actionCreateCircleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_C));
469 connect(actionCreateCircleTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
470 connect(actionCreateCircleTool, SIGNAL(triggered()),
this, SLOT(slotCreateCircleTool()));
472 actionCreateRectangleTool =
new QAction(tr(
"&Rectangle"),
this);
473 actionCreateRectangleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_R));
474 connect(actionCreateRectangleTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
475 connect(actionCreateRectangleTool, SIGNAL(triggered()),
this, SLOT(slotCreateRectangleTool()));
477 actionCreatePolygonTool =
new QAction(tr(
"&Polygon"),
this);
478 actionCreatePolygonTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_V));
479 connect(actionCreatePolygonTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
480 connect(actionCreatePolygonTool, SIGNAL(triggered()),
this, SLOT(slotCreatePolygonTool()));
482 actionCreateFloodFillTool =
new QAction(tr(
"&FloodFill"),
this);
483 actionCreateFloodFillTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_F));
484 connect(actionCreateFloodFillTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
485 connect(actionCreateFloodFillTool, SIGNAL(triggered()),
this, SLOT(slotCreateFloodFillTool()));
488 actionAboutDialog =
new QAction(tr(
"&About"),
this);
489 actionAboutDialog->setShortcut(Qt::Key_F2);
490 connect(actionAboutDialog, SIGNAL(triggered()),
this, SLOT(slotAboutDialog()));
493 actionAboutQtDialog =
new QAction(tr(
"About &Qt"),
this);
494 actionAboutQtDialog->setShortcut(Qt::Key_F3);
495 connect(actionAboutQtDialog, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
497 connect(EditLineWidth, SIGNAL(returnPressed()),
this, SLOT(slotEnterPressed()));
498 connect(EditLineInnerAlpha, SIGNAL(returnPressed()),
this, SLOT(slotEnterPressed()));
500 connect(CircleButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
501 connect(CircleButton, SIGNAL(clicked()),
this, SLOT(slotCreateCircleTool()));
503 connect(FloodFillButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
504 connect(FloodFillButton, SIGNAL(clicked()),
this, SLOT(slotCreateFloodFillTool()));
506 connect(LineButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
507 connect(LineButton, SIGNAL(clicked()),
this, SLOT(slotCreateLineTool()));
509 connect(PenButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
510 connect(PenButton, SIGNAL(clicked()),
this, SLOT(slotCreatePenTool()));
512 connect(PlainButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
513 connect(PlainButton, SIGNAL(clicked()),
this, SLOT(slotCreatePlainTool()));
515 connect(PolygonButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
516 connect(PolygonButton, SIGNAL(clicked()),
this, SLOT(slotCreatePolygonTool()));
518 connect(RectangleButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
519 connect(RectangleButton, SIGNAL(clicked()),
this, SLOT(slotCreateRectangleTool()));
521 actionSetWidth =
new QAction(tr(
"&Set Width"),
this);
522 actionSetWidth->setShortcut(QKeySequence(Qt::ALT + Qt::Key_W));
523 connect(actionSetWidth, SIGNAL(triggered()),
this, SLOT(slotSetWidth()));
525 actionSetInnerAlpha =
new QAction(tr(
"&Set Inner Alpha"),
this);
526 actionSetInnerAlpha->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A));
527 connect(actionSetInnerAlpha, SIGNAL(triggered()),
this, SLOT(slotSetInnerAlpha()));
531 void IntelliPhotoGui::createMenus(){
533 saveAsMenu =
new QMenu(tr(
"&Save As"),
this);
534 foreach (QAction * action, actionSaveAs)
535 saveAsMenu->addAction(action);
538 fileMenu =
new QMenu(tr(
"&File"),
this);
539 fileMenu->addAction(actionOpen);
540 fileMenu->addMenu(saveAsMenu);
541 fileMenu->addSeparator();
542 fileMenu->addAction(actionExit);
545 renderMenu =
new QMenu(tr(
"&Fast Renderer"),
this);
546 renderMenu->addAction(actionUpdateRenderSettingsOn);
547 renderMenu->addAction(actionUpdateRenderSettingsOff);
550 layerCreationMenu =
new QMenu(tr(
"&Create new Layer"),
this);
551 layerCreationMenu->addAction(actionCreateNewRasterLayer);
552 layerCreationMenu->addAction(actionCreateNewShapedLayer);
554 layerMenu =
new QMenu(tr(
"&Layer"),
this);
555 layerMenu->addMenu(layerCreationMenu);
556 layerMenu->addSeparator();
557 layerMenu->addAction(actionSetActiveAlpha);
558 layerMenu->addAction(actionSetActiveLayer);
559 layerMenu->addAction(actionSetPolygon);
560 layerMenu->addSeparator();
561 layerMenu->addAction(actionMovePositionUp);
562 layerMenu->addAction(actionMovePositionDown);
563 layerMenu->addAction(actionMovePositionLeft);
564 layerMenu->addAction(actionMovePositionRight);
565 layerMenu->addAction(actionMoveLayerUp);
566 layerMenu->addAction(actionMoveLayerDown);
567 layerMenu->addSeparator();
568 layerMenu->addAction(actionDeleteLayer);
571 colorMenu =
new QMenu(tr(
"&Color"),
this);
572 colorMenu->addAction(actionColorPickerFirstColor);
573 colorMenu->addAction(actionColorPickerSecondColor);
574 colorMenu->addAction(actionColorSwap);
577 toolCreationMenu =
new QMenu(tr(
"&Drawingtools"),
this);
578 toolCreationMenu->addAction(actionCreateCircleTool);
579 toolCreationMenu->addAction(actionCreateFloodFillTool);
580 toolCreationMenu->addAction(actionCreateLineTool);
581 toolCreationMenu->addAction(actionCreatePenTool);
582 toolCreationMenu->addAction(actionCreatePlainTool);
583 toolCreationMenu->addAction(actionCreatePolygonTool);
584 toolCreationMenu->addAction(actionCreateRectangleTool);
587 toolSettingsMenu =
new QMenu(tr(
"&Toolsettings"),
this);
588 toolSettingsMenu->addAction(actionSetWidth);
589 toolSettingsMenu->addAction(actionSetInnerAlpha);
592 toolMenu =
new QMenu(tr(
"&Tools"),
this);
593 toolMenu->addMenu(toolCreationMenu);
594 toolMenu->addMenu(toolSettingsMenu);
595 toolMenu->addSeparator();
596 toolMenu->addMenu(colorMenu);
599 optionMenu =
new QMenu(tr(
"&Options"),
this);
600 optionMenu->addMenu(layerMenu);
601 optionMenu->addMenu(toolMenu);
602 optionMenu->addSeparator();
603 optionMenu->addMenu(renderMenu);
604 optionMenu->addAction(actionChangeDim);
607 helpMenu =
new QMenu(tr(
"&Help"),
this);
608 helpMenu->addAction(actionAboutDialog);
609 helpMenu->addAction(actionAboutQtDialog);
612 menuBar()->addMenu(fileMenu);
613 menuBar()->addMenu(optionMenu);
614 menuBar()->addMenu(helpMenu);
617 void IntelliPhotoGui::createGui(){
619 centralGuiWidget =
new QWidget(
this);
620 setCentralWidget(centralGuiWidget);
623 mainLayout =
new QGridLayout(centralGuiWidget);
624 centralGuiWidget->setLayout(mainLayout);
629 paintingArea->DummyGui =
this;
631 preview = QPixmap(
":/Icons/Buttons/icons/circle-tool.svg");
632 CircleButton =
new QPushButton();
633 CircleButton->setFixedSize(Buttonsize);
634 CircleButton->setIcon(preview);
635 CircleButton->setIconSize(Buttonsize);
636 CircleButton->setCheckable(
true);
638 preview = QPixmap(
":/Icons/Buttons/icons/flood-fill-tool.svg");
639 FloodFillButton =
new QPushButton();
640 FloodFillButton->setFixedSize(Buttonsize);
641 FloodFillButton->setIcon(preview);
642 FloodFillButton->setIconSize(Buttonsize);
643 FloodFillButton->setCheckable(
true);
645 preview = QPixmap(
":/Icons/Buttons/icons/line-tool.svg");
646 LineButton =
new QPushButton();
647 LineButton->setFixedSize(Buttonsize);
648 LineButton->setIcon(preview);
649 LineButton->setIconSize(Buttonsize);
650 LineButton->setCheckable(
true);
652 preview = QPixmap(
":/Icons/Buttons/icons/pen-tool.svg");
653 PenButton =
new QPushButton();
654 PenButton->setFixedSize(Buttonsize);
655 PenButton->setIcon(preview);
656 PenButton->setIconSize(Buttonsize);
657 PenButton->setCheckable(
true);
659 preview = QPixmap(
":/Icons/Buttons/icons/plain-tool.svg");
660 PlainButton =
new QPushButton();
661 PlainButton->setFixedSize(Buttonsize);
662 PlainButton->setIcon(preview);
663 PlainButton->setIconSize(Buttonsize);
664 PlainButton->setCheckable(
true);
666 preview = QPixmap(
":/Icons/Buttons/icons/polygon-tool.svg");
667 PolygonButton =
new QPushButton();
668 PolygonButton->setFixedSize(Buttonsize);
669 PolygonButton->setIcon(preview);
670 PolygonButton->setIconSize(Buttonsize);
671 PolygonButton->setCheckable(
true);
673 preview = QPixmap(
":/Icons/Buttons/icons/rectangle-tool.svg");
674 RectangleButton =
new QPushButton();
675 RectangleButton->setFixedSize(Buttonsize);
676 RectangleButton->setIcon(preview);
677 RectangleButton->setIconSize(Buttonsize);
678 RectangleButton->setCheckable(
true);
680 WidthLine =
new QLabel();
681 WidthLine->setText(
"Width");
682 WidthLine->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
684 EditLineWidth =
new QLineEdit();
685 EditLineWidth->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
686 EditLineWidth->setText(
"5");
687 ValidatorLineWidth =
new QIntValidator();
688 ValidatorLineWidth->setTop(99);
689 ValidatorLineWidth->setBottom(1);
690 EditLineWidth->setValidator(ValidatorLineWidth);
692 innerAlphaLine =
new QLabel();
693 innerAlphaLine->setText(
"Inner Alpha");
694 innerAlphaLine->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
696 EditLineInnerAlpha =
new QLineEdit();
697 EditLineInnerAlpha->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
698 EditLineInnerAlpha->setText(
"255");
699 ValidatorInnerAlpha =
new QIntValidator();
700 ValidatorInnerAlpha->setTop(999);
701 ValidatorInnerAlpha->setBottom(0);
702 EditLineInnerAlpha->setValidator(ValidatorInnerAlpha);
704 FirstColorButton =
new QPushButton();
705 FirstColorButton->setFixedSize(Buttonsize);
707 SecondColorButton =
new QPushButton();
708 SecondColorButton->setFixedSize(Buttonsize);
710 preview = QPixmap(
":/Icons/Buttons/icons/Wechselpfeile.png");
711 SwitchColorButton =
new QPushButton();
712 SwitchColorButton->setFixedSize(Buttonsize.width() * 2,Buttonsize.height());
713 SwitchColorButton->setIcon(preview);
714 SwitchColorButton->setIconSize(QSize(Buttonsize.width() * 2,Buttonsize.height()));
716 ActiveLayerLine =
new QLabel();
718 ActiveLayerLine->setText(
string);
719 ActiveLayerLine->setFixedSize(Buttonsize.width() * 2 + 10,(Buttonsize.height() * 2) / 3);
723 preview = preview.fromImage(activePicture->
getImageData());
725 QImage tmp(1,1,QImage::Format_ARGB32);
726 tmp.fill(Qt::transparent);
727 preview = preview.fromImage(tmp);
730 ActiveLayerImageLabel =
new QLabel();
731 ActiveLayerImageLabel->setFixedSize(Buttonsize * 2);
732 ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2));
734 dimActive =
new QPushButton();
735 dimActive->setFixedSize(Buttonsize.width() * 2,Buttonsize.height() / 2);
736 dimActive->setText(
"0x0");
738 dimCanvas =
new QPushButton();
739 dimCanvas->setFixedSize(Buttonsize.width() * 2,Buttonsize.height() / 2);
740 QString String = QString(
"%1x%2").arg(paintingArea->Canvas->width()).arg(paintingArea->Canvas->height());
741 dimCanvas->setText(String);
744 mainLayout->addWidget(paintingArea,1,1,20,1);
745 mainLayout->addWidget(CircleButton,1,2,1,1);
746 mainLayout->addWidget(FloodFillButton,1,3,1,1);
747 mainLayout->addWidget(LineButton,2,2,1,1);
748 mainLayout->addWidget(PenButton,2,3,1,1);
749 mainLayout->addWidget(PlainButton,3,2,1,1);
750 mainLayout->addWidget(PolygonButton,3,3,1,1);
751 mainLayout->addWidget(RectangleButton,4,2,1,1);
752 mainLayout->addWidget(WidthLine,5,2,1,2);
753 mainLayout->addWidget(EditLineWidth,6,2,1,2);
754 mainLayout->addWidget(innerAlphaLine,7,2,1,2);
755 mainLayout->addWidget(EditLineInnerAlpha,8,2,1,2);
756 mainLayout->addWidget(FirstColorButton,9,2,1,1);
757 mainLayout->addWidget(SecondColorButton,9,3,1,1);
758 mainLayout->addWidget(SwitchColorButton,10,2,1,2);
759 mainLayout->addWidget(ActiveLayerLine,11,2,1,2);
760 mainLayout->addWidget(ActiveLayerImageLabel,12,2,1,2);
761 mainLayout->addWidget(dimActive,13,2,1,2);
762 mainLayout->addWidget(dimCanvas,14,2,1,2);
763 mainLayout->setHorizontalSpacing(0);
766 void IntelliPhotoGui::setIntelliStyle(){
768 setWindowTitle(
"IntelliPhoto Prototype");
770 this->setStyleSheet(
"color: white;" "background-color: rgb(64, 64, 64);" "selection-color: rgb(200, 10, 10);" "selection-background-color: rgb(64, 64, 64);");
773 FirstColorButton->setStyleSheet(
string);
775 SecondColorButton->setStyleSheet(
string);
778 bool IntelliPhotoGui::maybeSave(){
781 QMessageBox::StandardButton ret;
785 ret = QMessageBox::warning(
this, tr(
"Painting"),
786 tr(
"The image has been modified.\n"
787 "Do you want to save your changes?"),
788 QMessageBox::Save | QMessageBox::Discard
789 | QMessageBox::Cancel);
792 if (ret == QMessageBox::Save) {
793 return saveFile(
"png");
796 }
else if (ret == QMessageBox::Cancel) {
803 bool IntelliPhotoGui::saveFile(
const QByteArray &fileFormat){
805 QString initialPath = QDir::currentPath() +
"/untitled." + fileFormat;
809 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save As"),
811 tr(
"%1 Files (*.%2);;All Files (*)")
812 .arg(QString::fromLatin1(fileFormat.toUpper()))
813 .arg(QString::fromLatin1(fileFormat)),
nullptr, QFileDialog::DontUseNativeDialog);
816 if (fileName.isEmpty()) {
820 return paintingArea->
save(fileName, fileFormat.constData());
824 void IntelliPhotoGui::setDefaultToolValue(){
831 }
else if(value > 50) {
834 EditLineWidth->setText(QString(
"%1").arg(value));
839 ActiveLayerLine->setText(
string);
843 preview = preview.fromImage(activePicture->
getImageData());
845 QImage tmp(1,1,QImage::Format_ARGB32);
846 tmp.fill(Qt::transparent);
847 preview = preview.fromImage(tmp);
849 ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2));
852 FirstColorButton->setStyleSheet(
string);
854 SecondColorButton->setStyleSheet(
string);
856 string = QString(
"%1x%2").arg(paintingArea->Canvas->width()).arg(paintingArea->Canvas->height());
857 dimCanvas->setText(
string);
859 if(paintingArea->layerBundle.size() != 0) {
860 string = QString(
"%1x%2").arg(paintingArea->layerBundle[
static_cast<size_t>
863 dimActive->setText(
string);
866 dimActive->setText(
"0x0");