11 #include <QGuiApplication>
43 void IntelliPhotoGui::slotOpen(){
51 QString fileName = QFileDialog::getOpenFileName(
this,
52 tr(
"Open File"), QDir::currentPath(),
nullptr,
nullptr, QFileDialog::DontUseNativeDialog);
56 if (!fileName.isEmpty()) {
57 bool rightFileType =
true;
58 if(fileName.size()>=4) {
59 QString endung(
".idf");
60 int length = fileName.size();
61 for(
int i = 0; i<4; i++) {
62 if(endung[i]!=fileName[length - 4 + i]) {
63 rightFileType =
false;
75 paintingArea->
open(fileName);
82 void IntelliPhotoGui::slotSave(){
84 QAction*action = qobject_cast<QAction*>(sender());
87 QByteArray fileFormat = action->data().toByteArray();
94 void IntelliPhotoGui::slotCreateNewRasterLayer(){
114 void IntelliPhotoGui::slotCreateNewShapedLayer(){
134 void IntelliPhotoGui::slotChangeDim(){
154 void IntelliPhotoGui::slotDeleteLayer(){
170 void IntelliPhotoGui::slotSetActiveAlpha(){
189 void IntelliPhotoGui::slotSetPolygon(){
205 void IntelliPhotoGui::slotPositionMoveUp(){
210 void IntelliPhotoGui::slotPositionMoveDown(){
215 void IntelliPhotoGui::slotPositionMoveLeft(){
220 void IntelliPhotoGui::slotPositionMoveRight(){
225 void IntelliPhotoGui::slotMoveLayerUp(){
230 void IntelliPhotoGui::slotMoveLayerDown(){
235 void IntelliPhotoGui::slotSetActiveLayer(){
240 int layer =
IntelliInputDialog::getInt(
"Layer to set on",
"Layer:", 1, 1,
static_cast<int>(paintingArea->layerBundle.size()), 1, &ok1);
248 void IntelliPhotoGui::slotUpdateFastRenderSettingsOn(){
250 FastRendererLabel->setText(
"Fast Render: On");
254 void IntelliPhotoGui::slotUpdateFastRenderSettingsOff(){
256 FastRendererLabel->setText(
"Fast Render: Off");
260 void IntelliPhotoGui::slotSetFirstColor(){
265 void IntelliPhotoGui::slotSetSecondColor(){
270 void IntelliPhotoGui::slotSwapColor(){
275 void IntelliPhotoGui::slotCreatePenTool(){
276 PenButton->setChecked(
true);
280 void IntelliPhotoGui::slotCreatePlainTool(){
281 PlainButton->setChecked(
true);
285 void IntelliPhotoGui::slotCreateLineTool(){
286 LineButton->setChecked(
true);
290 void IntelliPhotoGui::slotCreateRectangleTool(){
291 RectangleButton->setChecked(
true);
295 void IntelliPhotoGui::slotCreateCircleTool(){
296 CircleButton->setChecked(
true);
300 void IntelliPhotoGui::slotCreatePolygonTool(){
301 PolygonButton->setChecked(
true);
305 void IntelliPhotoGui::slotCreateFloodFillTool(){
306 FloodFillButton->setChecked(
true);
310 void IntelliPhotoGui::slotCreateGradientTool(){
311 GradientButton->setChecked(
true);
316 void IntelliPhotoGui::slotAboutDialog(){
318 QMessageBox::about(
this, tr(
"About Us"),
319 tr(
"<h1>About IntelliPhoto</h1><p>Version: v1.0<br>Developed by: Team 7<br>Interactive painting tool with layering and drawing capabilities.</p>"));
322 void IntelliPhotoGui::slotEnterPressed(){
323 QString
string = EditLineWidth->text();
324 if(
string.toInt() > 50) {
325 EditLineWidth->setText(
"50");
328 string = EditLineInnerAlpha->text();
329 if(
string.toInt() > 255) {
330 EditLineInnerAlpha->setText(
"255");
335 void IntelliPhotoGui::slotResetToolButtons(){
336 CircleButton->setChecked(
false);
337 FloodFillButton->setChecked(
false);
338 GradientButton->setChecked(
false);
339 LineButton->setChecked(
false);
340 PenButton->setChecked(
false);
341 PlainButton->setChecked(
false);
342 PolygonButton->setChecked(
false);
343 RectangleButton->setChecked(
false);
346 void IntelliPhotoGui::slotSetWidth(){
351 EditLineWidth->setText(QString(
"%1").arg(temp));
355 void IntelliPhotoGui::slotSetInnerAlpha(){
360 EditLineInnerAlpha->setText(QString(
"%1").arg(temp));
364 void IntelliPhotoGui::slotGoBack(){
368 void IntelliPhotoGui::slotGoForward(){
373 void IntelliPhotoGui::createActions(){
376 foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
377 QString text = tr(
"%1...").arg(QString(format).toUpper());
380 QAction*action =
new QAction(text,
this);
383 action->setData(format);
386 connect(action, SIGNAL(triggered()),
this, SLOT(slotSave()));
389 actionSaveAs.append(action);
393 QAction*pngSaveAction =
new QAction(
"PNG-8...",
this);
394 pngSaveAction->setData(
"PNG");
396 connect(pngSaveAction, SIGNAL(triggered()),
this, SLOT(slotSave()));
398 actionSaveAs.append(pngSaveAction);
399 pngSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
402 actionExit =
new QAction(tr(
"&Exit"),
this);
403 actionExit->setShortcuts(QKeySequence::Quit);
404 connect(actionExit, SIGNAL(triggered()),
this, SLOT(close()));
406 actionOpen =
new QAction(tr(
"&Open"),
this);
407 actionOpen->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
408 connect(actionOpen, SIGNAL(triggered()),
this, SLOT(slotOpen()));
411 actionCreateNewRasterLayer =
new QAction(tr(
"&Raster Image"),
this);
412 actionCreateNewRasterLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
413 connect(actionCreateNewRasterLayer, SIGNAL(triggered()),
this, SLOT(slotCreateNewRasterLayer()));
417 actionCreateNewShapedLayer =
new QAction(tr(
"&Shaped Image"),
this);
418 actionCreateNewShapedLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N + Qt::ALT));
419 connect(actionCreateNewShapedLayer, SIGNAL(triggered()),
this, SLOT(slotCreateNewShapedLayer()));
422 actionDeleteLayer =
new QAction(tr(
"&Delete Layer"),
this);
423 actionDeleteLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_D));
424 connect(actionDeleteLayer, SIGNAL(triggered()),
this, SLOT(slotDeleteLayer()));
426 actionChangeDim =
new QAction(tr(
"&Change Dimension"),
this);
427 actionChangeDim->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_X));
428 connect(actionChangeDim, SIGNAL(triggered()),
this, SLOT(slotChangeDim()));
429 connect(dimCanvas, SIGNAL(clicked()),
this, SLOT(slotChangeDim()));
431 actionSetActiveLayer =
new QAction(tr(
"&Set Active"),
this);
432 actionSetActiveLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
433 connect(actionSetActiveLayer, SIGNAL(triggered()),
this, SLOT(slotSetActiveLayer()));
435 actionSetActiveAlpha =
new QAction(tr(
"&Set Alpha"),
this);
436 actionSetActiveAlpha->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_A));
437 connect(actionSetActiveAlpha, SIGNAL(triggered()),
this, SLOT(slotSetActiveAlpha()));
439 actionSetPolygon =
new QAction(tr(
"&Set Polygon Data"),
this);
440 actionSetPolygon->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_P));
441 connect(actionSetPolygon, SIGNAL(triggered()),
this, SLOT(slotSetPolygon()));
443 actionMovePositionUp =
new QAction(tr(
"&Move Up"),
this);
444 actionMovePositionUp->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up));
445 connect(actionMovePositionUp, SIGNAL(triggered()),
this, SLOT(slotPositionMoveUp()));
447 actionMovePositionDown =
new QAction(tr(
"&Move Down"),
this);
448 actionMovePositionDown->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down));
449 connect(actionMovePositionDown, SIGNAL(triggered()),
this, SLOT(slotPositionMoveDown()));
451 actionMovePositionLeft =
new QAction(tr(
"&Move Left"),
this);
452 actionMovePositionLeft->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left));
453 connect(actionMovePositionLeft, SIGNAL(triggered()),
this, SLOT(slotPositionMoveLeft()));
455 actionMovePositionRight =
new QAction(tr(
"&Move Right"),
this);
456 actionMovePositionRight->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right));
457 connect(actionMovePositionRight, SIGNAL(triggered()),
this, SLOT(slotPositionMoveRight()));
459 actionMoveLayerUp =
new QAction(tr(
"&Move Forth"),
this);
460 actionMoveLayerUp->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Up));
461 connect(actionMoveLayerUp, SIGNAL(triggered()),
this, SLOT(slotMoveLayerUp()));
463 actionMoveLayerDown =
new QAction(tr(
"&Move Back"),
this);
464 actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
465 connect(actionMoveLayerDown, SIGNAL(triggered()),
this, SLOT(slotMoveLayerDown()));
468 actionUpdateFastRenderSettingsOn =
new QAction(tr(
"&On"),
this);
469 actionUpdateFastRenderSettingsOn->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + +Qt::Key_A));
470 connect(actionUpdateFastRenderSettingsOn, SIGNAL(triggered()),
this, SLOT(slotUpdateFastRenderSettingsOn()));
472 actionUpdateFastRenderSettingsOff =
new QAction(tr(
"&Off"),
this);
473 actionUpdateFastRenderSettingsOff->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + +Qt::Key_D));
474 connect(actionUpdateFastRenderSettingsOff, SIGNAL(triggered()),
this, SLOT(slotUpdateFastRenderSettingsOff()));
477 actionColorPickerFirstColor =
new QAction(tr(
"&Main"),
this);
478 actionColorPickerFirstColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_N));
479 connect(actionColorPickerFirstColor, SIGNAL(triggered()),
this, SLOT(slotSetFirstColor()));
480 connect(FirstColorButton, SIGNAL(clicked()),
this, SLOT(slotSetFirstColor()));
482 actionColorPickerSecondColor =
new QAction(tr(
"&Secondary"),
this);
483 actionColorPickerSecondColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_M));
484 connect(actionColorPickerSecondColor, SIGNAL(triggered()),
this, SLOT(slotSetSecondColor()));
485 connect(SecondColorButton, SIGNAL(clicked()),
this, SLOT(slotSetSecondColor()));
487 actionColorSwap =
new QAction(tr(
"&Switch"),
this);
488 actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S));
489 connect(actionColorSwap, SIGNAL(triggered()),
this, SLOT(slotSwapColor()));
490 connect(SwitchColorButton, SIGNAL(clicked()),
this, SLOT(slotSwapColor()));
493 actionCreatePlainTool =
new QAction(tr(
"&Plain"),
this);
494 actionCreatePlainTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_P));
495 connect(actionCreatePlainTool, SIGNAL(triggered()),
this, SLOT(slotResetToolButtons()));
496 connect(actionCreatePlainTool, SIGNAL(triggered()),
this, SLOT(slotCreatePlainTool()));
499 actionCreatePenTool =
new QAction(tr(
"&Pen"),
this);
500 actionCreatePenTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_S));
501 connect(actionCreatePenTool, SIGNAL(triggered()),
this, SLOT(slotResetToolButtons()));
502 connect(actionCreatePenTool, SIGNAL(triggered()),
this, SLOT(slotCreatePenTool()));
504 actionCreateLineTool =
new QAction(tr(
"&Line"),
this);
505 actionCreateLineTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_L));
506 connect(actionCreateLineTool, SIGNAL(triggered()),
this, SLOT(slotResetToolButtons()));
507 connect(actionCreateLineTool, SIGNAL(triggered()),
this, SLOT(slotCreateLineTool()));
509 actionCreateCircleTool =
new QAction(tr(
"&Circle"),
this);
510 actionCreateCircleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_C));
511 connect(actionCreateCircleTool, SIGNAL(triggered()),
this, SLOT(slotResetToolButtons()));
512 connect(actionCreateCircleTool, SIGNAL(triggered()),
this, SLOT(slotCreateCircleTool()));
514 actionCreateRectangleTool =
new QAction(tr(
"&Rectangle"),
this);
515 actionCreateRectangleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_R));
516 connect(actionCreateRectangleTool, SIGNAL(triggered()),
this, SLOT(slotResetToolButtons()));
517 connect(actionCreateRectangleTool, SIGNAL(triggered()),
this, SLOT(slotCreateRectangleTool()));
519 actionCreatePolygonTool =
new QAction(tr(
"&Polygon"),
this);
520 actionCreatePolygonTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_V));
521 connect(actionCreatePolygonTool, SIGNAL(triggered()),
this, SLOT(slotResetToolButtons()));
522 connect(actionCreatePolygonTool, SIGNAL(triggered()),
this, SLOT(slotCreatePolygonTool()));
524 actionCreateFloodFillTool =
new QAction(tr(
"&FloodFill"),
this);
525 actionCreateFloodFillTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_F));
526 connect(actionCreateFloodFillTool, SIGNAL(triggered()),
this, SLOT(slotResetToolButtons()));
527 connect(actionCreateFloodFillTool, SIGNAL(triggered()),
this, SLOT(slotCreateFloodFillTool()));
529 actionCreateGradientTool =
new QAction(tr(
"&Gradient"),
this);
530 actionCreateGradientTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_G));
531 connect(actionCreateGradientTool, SIGNAL(triggered()),
this, SLOT(slotResetToolButtons()));
532 connect(actionCreateGradientTool, SIGNAL(triggered()),
this, SLOT(slotCreateGradientTool()));
535 actionAboutDialog =
new QAction(tr(
"&About"),
this);
536 connect(actionAboutDialog, SIGNAL(triggered()),
this, SLOT(slotAboutDialog()));
539 actionAboutQtDialog =
new QAction(tr(
"About &Qt"),
this);
540 connect(actionAboutQtDialog, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
542 connect(EditLineWidth, SIGNAL(returnPressed()),
this, SLOT(slotEnterPressed()));
543 connect(EditLineInnerAlpha, SIGNAL(returnPressed()),
this, SLOT(slotEnterPressed()));
545 connect(CircleButton,SIGNAL(pressed()),
this, SLOT(slotResetToolButtons()));
546 connect(CircleButton, SIGNAL(clicked()),
this, SLOT(slotCreateCircleTool()));
548 connect(FloodFillButton,SIGNAL(pressed()),
this, SLOT(slotResetToolButtons()));
549 connect(FloodFillButton, SIGNAL(clicked()),
this, SLOT(slotCreateFloodFillTool()));
551 connect(GradientButton, SIGNAL(pressed()),
this, SLOT(slotResetToolButtons()));
552 connect(GradientButton, SIGNAL(clicked()),
this, SLOT(slotCreateGradientTool()));
554 connect(LineButton,SIGNAL(pressed()),
this, SLOT(slotResetToolButtons()));
555 connect(LineButton, SIGNAL(clicked()),
this, SLOT(slotCreateLineTool()));
557 connect(PenButton,SIGNAL(pressed()),
this, SLOT(slotResetToolButtons()));
558 connect(PenButton, SIGNAL(clicked()),
this, SLOT(slotCreatePenTool()));
560 connect(PlainButton,SIGNAL(pressed()),
this, SLOT(slotResetToolButtons()));
561 connect(PlainButton, SIGNAL(clicked()),
this, SLOT(slotCreatePlainTool()));
563 connect(PolygonButton,SIGNAL(pressed()),
this, SLOT(slotResetToolButtons()));
564 connect(PolygonButton, SIGNAL(clicked()),
this, SLOT(slotCreatePolygonTool()));
566 connect(RectangleButton,SIGNAL(pressed()),
this, SLOT(slotResetToolButtons()));
567 connect(RectangleButton, SIGNAL(clicked()),
this, SLOT(slotCreateRectangleTool()));
569 actionSetWidth =
new QAction(tr(
"&Set Width"),
this);
570 actionSetWidth->setShortcut(QKeySequence(Qt::ALT + Qt::Key_W));
571 connect(actionSetWidth, SIGNAL(triggered()),
this, SLOT(slotSetWidth()));
573 actionSetInnerAlpha =
new QAction(tr(
"&Set Inner Alpha"),
this);
574 actionSetInnerAlpha->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A));
575 connect(actionSetInnerAlpha, SIGNAL(triggered()),
this, SLOT(slotSetInnerAlpha()));
577 actionGoBack =
new QAction(tr(
"&Undo"),
this);
578 actionGoBack->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
579 connect(actionGoBack, SIGNAL(triggered()),
this, SLOT(slotGoBack()));
581 actionGoForward =
new QAction(tr(
"&Redo"),
this);
582 actionGoForward->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y));
583 connect(actionGoForward, SIGNAL(triggered()),
this, SLOT(slotGoForward()));
587 void IntelliPhotoGui::createMenus(){
589 saveAsMenu =
new QMenu(tr(
"&Export As"),
this);
590 foreach (QAction * action, actionSaveAs)
591 saveAsMenu->addAction(action);
594 fileMenu =
new QMenu(tr(
"&File"),
this);
595 fileMenu->addAction(actionOpen);
596 fileMenu->addMenu(saveAsMenu);
597 fileMenu->addSeparator();
598 fileMenu->addAction(actionExit);
601 QAction*projectSaveAction =
new QAction(
"Save Project",
this);
602 projectSaveAction->setData(
"idf");
603 connect(projectSaveAction, SIGNAL(triggered()),
this, SLOT(slotSave()));
604 projectSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
605 fileMenu->addAction(projectSaveAction);
608 renderMenu =
new QMenu(tr(
"&Fast Renderer"),
this);
609 renderMenu->addAction(actionUpdateFastRenderSettingsOn);
610 renderMenu->addAction(actionUpdateFastRenderSettingsOff);
613 layerCreationMenu =
new QMenu(tr(
"&Create Layer"),
this);
614 layerCreationMenu->addAction(actionCreateNewRasterLayer);
615 layerCreationMenu->addAction(actionCreateNewShapedLayer);
618 layerMenu =
new QMenu(tr(
"&Layer"),
this);
619 layerMenu->addMenu(layerCreationMenu);
620 layerMenu->addSeparator();
621 layerMenu->addAction(actionSetActiveAlpha);
622 layerMenu->addAction(actionSetActiveLayer);
623 layerMenu->addAction(actionSetPolygon);
624 layerMenu->addSeparator();
625 layerMenu->addAction(actionMovePositionUp);
626 layerMenu->addAction(actionMovePositionDown);
627 layerMenu->addAction(actionMovePositionLeft);
628 layerMenu->addAction(actionMovePositionRight);
629 layerMenu->addAction(actionMoveLayerUp);
630 layerMenu->addAction(actionMoveLayerDown);
631 layerMenu->addSeparator();
632 layerMenu->addAction(actionDeleteLayer);
635 colorMenu =
new QMenu(tr(
"&Color"),
this);
636 colorMenu->addAction(actionColorPickerFirstColor);
637 colorMenu->addAction(actionColorPickerSecondColor);
638 colorMenu->addAction(actionColorSwap);
641 toolCreationMenu =
new QMenu(tr(
"&Tool Selection"),
this);
642 toolCreationMenu->addAction(actionCreateCircleTool);
643 toolCreationMenu->addAction(actionCreateFloodFillTool);
644 toolCreationMenu->addAction(actionCreateGradientTool);
645 toolCreationMenu->addAction(actionCreateLineTool);
646 toolCreationMenu->addAction(actionCreatePenTool);
647 toolCreationMenu->addAction(actionCreatePlainTool);
648 toolCreationMenu->addAction(actionCreatePolygonTool);
649 toolCreationMenu->addAction(actionCreateRectangleTool);
652 toolSettingsMenu =
new QMenu(tr(
"&Tool Settings"),
this);
653 toolSettingsMenu->addAction(actionSetWidth);
654 toolSettingsMenu->addAction(actionSetInnerAlpha);
657 toolMenu =
new QMenu(tr(
"&Tools"),
this);
658 toolMenu->addMenu(toolCreationMenu);
659 toolMenu->addMenu(toolSettingsMenu);
662 optionMenu =
new QMenu(tr(
"&Options"),
this);
663 optionMenu->addAction(actionGoBack);
664 optionMenu->addAction(actionGoForward);
665 optionMenu->addSeparator();
666 optionMenu->addMenu(renderMenu);
667 optionMenu->addAction(actionChangeDim);
670 helpMenu =
new QMenu(tr(
"&Help"),
this);
671 helpMenu->addAction(actionAboutDialog);
672 helpMenu->addAction(actionAboutQtDialog);
675 menuBar()->addMenu(fileMenu);
676 menuBar()->addMenu(optionMenu);
677 menuBar()->addMenu(layerMenu);
678 menuBar()->addMenu(toolMenu);
679 menuBar()->addMenu(colorMenu);
680 menuBar()->addMenu(helpMenu);
683 void IntelliPhotoGui::createGui(){
685 centralGuiWidget =
new QWidget(
this);
686 setCentralWidget(centralGuiWidget);
689 mainLayout =
new QGridLayout(centralGuiWidget);
690 centralGuiWidget->setLayout(mainLayout);
695 paintingArea->guiReference =
this;
697 QScreen*screen = QGuiApplication::primaryScreen();
698 QRect screenGeometry = screen->geometry();
699 Buttonsize.setWidth(screenGeometry.width() / 20);
700 Buttonsize.setHeight(screenGeometry.height() / 20);
702 preview = QPixmap(
":/Icons/Buttons/icons/circle-tool.svg");
703 CircleButton =
new QPushButton();
704 CircleButton->setFixedSize(Buttonsize);
705 CircleButton->setIcon(preview);
706 CircleButton->setIconSize(Buttonsize);
707 CircleButton->setCheckable(
true);
709 preview = QPixmap(
":/Icons/Buttons/icons/flood-fill-tool.svg");
710 FloodFillButton =
new QPushButton();
711 FloodFillButton->setFixedSize(Buttonsize);
712 FloodFillButton->setIcon(preview);
713 FloodFillButton->setIconSize(Buttonsize);
714 FloodFillButton->setCheckable(
true);
716 preview = QPixmap(
":/Icons/Buttons/icons/gradient-tool.svg");
717 GradientButton =
new QPushButton();
718 GradientButton->setFixedSize(Buttonsize);
719 GradientButton->setIcon(preview);
720 GradientButton->setIconSize(Buttonsize);
721 GradientButton->setCheckable(
true);
723 preview = QPixmap(
":/Icons/Buttons/icons/line-tool.svg");
724 LineButton =
new QPushButton();
725 LineButton->setFixedSize(Buttonsize);
726 LineButton->setIcon(preview);
727 LineButton->setIconSize(Buttonsize);
728 LineButton->setCheckable(
true);
730 preview = QPixmap(
":/Icons/Buttons/icons/pen-tool.svg");
731 PenButton =
new QPushButton();
732 PenButton->setFixedSize(Buttonsize);
733 PenButton->setIcon(preview);
734 PenButton->setIconSize(Buttonsize);
735 PenButton->setCheckable(
true);
737 preview = QPixmap(
":/Icons/Buttons/icons/plain-tool.svg");
738 PlainButton =
new QPushButton();
739 PlainButton->setFixedSize(Buttonsize);
740 PlainButton->setIcon(preview);
741 PlainButton->setIconSize(Buttonsize);
742 PlainButton->setCheckable(
true);
744 preview = QPixmap(
":/Icons/Buttons/icons/polygon-tool.svg");
745 PolygonButton =
new QPushButton();
746 PolygonButton->setFixedSize(Buttonsize);
747 PolygonButton->setIcon(preview);
748 PolygonButton->setIconSize(Buttonsize);
749 PolygonButton->setCheckable(
true);
751 preview = QPixmap(
":/Icons/Buttons/icons/rectangle-tool.svg");
752 RectangleButton =
new QPushButton();
753 RectangleButton->setFixedSize(Buttonsize);
754 RectangleButton->setIcon(preview);
755 RectangleButton->setIconSize(Buttonsize);
756 RectangleButton->setCheckable(
true);
758 WidthLine =
new QLabel();
759 WidthLine->setText(
"Width");
760 WidthLine->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
762 EditLineWidth =
new QLineEdit();
763 EditLineWidth->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
764 EditLineWidth->setText(
"5");
765 ValidatorLineWidth =
new QIntValidator();
766 ValidatorLineWidth->setTop(99);
767 ValidatorLineWidth->setBottom(1);
768 EditLineWidth->setValidator(ValidatorLineWidth);
770 innerAlphaLine =
new QLabel();
771 innerAlphaLine->setText(
"Inner Alpha");
772 innerAlphaLine->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
774 EditLineInnerAlpha =
new QLineEdit();
775 EditLineInnerAlpha->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
776 EditLineInnerAlpha->setText(
"255");
777 ValidatorInnerAlpha =
new QIntValidator();
778 ValidatorInnerAlpha->setTop(999);
779 ValidatorInnerAlpha->setBottom(0);
780 EditLineInnerAlpha->setValidator(ValidatorInnerAlpha);
782 FirstColorButton =
new QPushButton();
783 FirstColorButton->setFixedSize(Buttonsize);
785 SecondColorButton =
new QPushButton();
786 SecondColorButton->setFixedSize(Buttonsize);
788 preview = QPixmap(
":/Icons/Buttons/icons/Wechselpfeile.png");
789 SwitchColorButton =
new QPushButton();
790 SwitchColorButton->setFixedSize(Buttonsize.width() * 2,Buttonsize.height());
791 SwitchColorButton->setIcon(preview);
792 SwitchColorButton->setIconSize(QSize(Buttonsize.width() * 2,Buttonsize.height()));
794 ActiveLayerLabel =
new QLabel();
796 ActiveLayerLabel->setText(
string);
797 ActiveLayerLabel->setFixedSize(Buttonsize.width() * 2 + 10,(Buttonsize.height() * 2) / 3);
801 preview = preview.fromImage(activePicture->
getImageData());
803 QImage tmp(1,1,QImage::Format_ARGB32);
804 tmp.fill(Qt::transparent);
805 preview = preview.fromImage(tmp);
808 ActiveLayerImageLabel =
new QLabel();
809 ActiveLayerImageLabel->setFixedSize(Buttonsize * 2);
810 ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2));
812 dimActive =
new QPushButton();
813 dimActive->setFixedSize(Buttonsize.width() * 2,Buttonsize.height() / 2);
814 dimActive->setText(
"0x0");
816 dimCanvas =
new QPushButton();
817 dimCanvas->setFixedSize(Buttonsize.width() * 2,Buttonsize.height() / 2);
818 QString String = QString(
"%1x%2").arg(paintingArea->Canvas->width()).arg(paintingArea->Canvas->height());
819 dimCanvas->setText(String);
821 FastRendererLabel =
new QLabel();
822 FastRendererLabel->setFixedSize(Buttonsize.width() * 2 + 15,(Buttonsize.height() * 2) / 3);
823 FastRendererLabel->setText(
"Fast Render: On");
825 ScrollArea =
new QScrollArea(
this);
826 ScrollArea->setBackgroundRole(QPalette::Dark);
827 ScrollArea->setWidget(paintingArea);
828 ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
829 ScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
832 mainLayout->addWidget(ScrollArea,1,1,20,1);
833 mainLayout->addWidget(CircleButton,1,2,1,1);
834 mainLayout->addWidget(FloodFillButton,1,3,1,1);
835 mainLayout->addWidget(LineButton,2,2,1,1);
836 mainLayout->addWidget(PenButton,2,3,1,1);
837 mainLayout->addWidget(PlainButton,3,2,1,1);
838 mainLayout->addWidget(PolygonButton,3,3,1,1);
839 mainLayout->addWidget(RectangleButton,4,2,1,1);
840 mainLayout->addWidget(GradientButton,4,3,1,1);
841 mainLayout->addWidget(WidthLine,5,2,1,2);
842 mainLayout->addWidget(EditLineWidth,6,2,1,2);
843 mainLayout->addWidget(innerAlphaLine,7,2,1,2);
844 mainLayout->addWidget(EditLineInnerAlpha,8,2,1,2);
845 mainLayout->addWidget(FirstColorButton,9,2,1,1);
846 mainLayout->addWidget(SecondColorButton,9,3,1,1);
847 mainLayout->addWidget(SwitchColorButton,10,2,1,2);
848 mainLayout->addWidget(ActiveLayerLabel,11,2,1,2);
849 mainLayout->addWidget(ActiveLayerImageLabel,12,2,1,2);
850 mainLayout->addWidget(dimActive,13,2,1,2);
851 mainLayout->addWidget(dimCanvas,14,2,1,2);
852 mainLayout->addWidget(FastRendererLabel,15,2,1,2);
853 mainLayout->setHorizontalSpacing(0);
857 void IntelliPhotoGui::setIntelliStyle(){
859 setWindowTitle(
"IntelliPhoto v1.0");
861 this->setStyleSheet(
"color: white;" "background-color: rgb(64, 64, 64);" "selection-color: rgb(200, 10, 10);" "selection-background-color: rgb(64, 64, 64);");
864 FirstColorButton->setStyleSheet(
string);
866 SecondColorButton->setStyleSheet(
string);
869 bool IntelliPhotoGui::maybeSave(){
872 QMessageBox::StandardButton ret;
876 ret = QMessageBox::warning(
this, tr(
"Painting"),
877 tr(
"The image has been modified.\n"
878 "Do you want to save your changes?"),
879 QMessageBox::Save | QMessageBox::Discard
880 | QMessageBox::Cancel);
883 if (ret == QMessageBox::Save) {
884 return saveFile(
"png");
887 }
else if (ret == QMessageBox::Cancel) {
894 bool IntelliPhotoGui::saveFile(
const QByteArray &fileFormat){
896 QString initialPath = QDir::currentPath() +
"/untitled." + fileFormat;
900 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save As"),
902 tr(
"%1 Files (*.%2);;All Files (*)")
903 .arg(QString::fromLatin1(fileFormat.toUpper()))
904 .arg(QString::fromLatin1(fileFormat)),
nullptr, QFileDialog::DontUseNativeDialog);
907 if (fileName.isEmpty()) {
911 if(fileFormat ==
"idf") {
915 return paintingArea->
save(fileName, fileFormat.constData());
919 void IntelliPhotoGui::setDefaultValues(){
926 }
else if(value > 50) {
929 EditLineWidth->setText(QString(
"%1").arg(value));
934 ActiveLayerLabel->setText(
string);
938 preview = preview.fromImage(activePicture->
getImageData());
940 QImage tmp(1,1,QImage::Format_ARGB32);
941 tmp.fill(Qt::transparent);
942 preview = preview.fromImage(tmp);
946 ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2));
949 FirstColorButton->setStyleSheet(
string);
951 SecondColorButton->setStyleSheet(
string);
953 string = QString(
"%1x%2").arg(paintingArea->Canvas->width()).arg(paintingArea->Canvas->height());
954 dimCanvas->setText(
string);
956 if(paintingArea->layerBundle.size() != 0) {
957 string = QString(
"%1x%2").arg(paintingArea->layerBundle[
static_cast<size_t>
960 dimActive->setText(
string);
963 dimActive->setText(
"0x0");