40 void IntelliPhotoGui::slotOpen(){
48 QString fileName = QFileDialog::getOpenFileName(
this,
49 tr(
"Open File"), QDir::currentPath(),
nullptr,
nullptr, QFileDialog::DontUseNativeDialog);
53 if (!fileName.isEmpty()) {
54 bool rightFileType =
true;
55 if(fileName.size()>=4) {
56 QString endung(
".idf");
57 int length = fileName.size();
58 for(
int i = 0; i<4; i++) {
59 if(endung[i]!=fileName[length - 4 + i]) {
60 rightFileType =
false;
72 paintingArea->
open(fileName);
79 void IntelliPhotoGui::slotSave(){
81 QAction*action = qobject_cast<QAction*>(sender());
84 QByteArray fileFormat = action->data().toByteArray();
91 void IntelliPhotoGui::slotCreateNewRasterLayer(){
110 void IntelliPhotoGui::slotCreateNewShapedLayer(){
129 void IntelliPhotoGui::slotChangeDim(){
149 void IntelliPhotoGui::slotDeleteLayer(){
164 void IntelliPhotoGui::slotSetActiveAlpha(){
183 void IntelliPhotoGui::slotSetPolygon(){
199 void IntelliPhotoGui::slotPositionMoveUp(){
204 void IntelliPhotoGui::slotPositionMoveDown(){
209 void IntelliPhotoGui::slotPositionMoveLeft(){
214 void IntelliPhotoGui::slotPositionMoveRight(){
219 void IntelliPhotoGui::slotMoveLayerUp(){
224 void IntelliPhotoGui::slotMoveLayerDown(){
229 void IntelliPhotoGui::slotSetActiveLayer(){
234 int layer =
IntelliInputDialog::getInt(
"Layer to set on",
"Layer:", 1, 1,
static_cast<int>(paintingArea->layerBundle.size()), 1, &ok1);
242 void IntelliPhotoGui::slotUpdateRenderSettingsOn(){
247 void IntelliPhotoGui::slotUpdateRenderSettingsOff(){
252 void IntelliPhotoGui::slotSetFirstColor(){
257 void IntelliPhotoGui::slotSetSecondColor(){
262 void IntelliPhotoGui::slotSwapColor(){
267 void IntelliPhotoGui::slotCreatePenTool(){
268 PenButton->setChecked(
true);
272 void IntelliPhotoGui::slotCreatePlainTool(){
273 PlainButton->setChecked(
true);
277 void IntelliPhotoGui::slotCreateLineTool(){
278 LineButton->setChecked(
true);
282 void IntelliPhotoGui::slotCreateRectangleTool(){
283 RectangleButton->setChecked(
true);
287 void IntelliPhotoGui::slotCreateCircleTool(){
288 CircleButton->setChecked(
true);
292 void IntelliPhotoGui::slotCreatePolygonTool(){
293 PolygonButton->setChecked(
true);
297 void IntelliPhotoGui::slotCreateFloodFillTool(){
298 FloodFillButton->setChecked(
true);
303 void IntelliPhotoGui::slotAboutDialog(){
305 QMessageBox::about(
this, tr(
"About Painting"),
306 tr(
"<p><b>IntelliPhoto - </b>A Pretty basic editor.</p> <br>Developed by Team 7."));
309 void IntelliPhotoGui::slotEnterPressed(){
310 QString
string = EditLineWidth->text();
311 if(
string.toInt() > 50) {
312 EditLineWidth->setText(
"50");
315 string = EditLineInnerAlpha->text();
316 if(
string.toInt() > 255) {
317 EditLineInnerAlpha->setText(
"255");
322 void IntelliPhotoGui::slotResetTools(){
323 CircleButton->setChecked(
false);
324 FloodFillButton->setChecked(
false);
325 LineButton->setChecked(
false);
326 PenButton->setChecked(
false);
327 PlainButton->setChecked(
false);
328 PolygonButton->setChecked(
false);
329 RectangleButton->setChecked(
false);
332 void IntelliPhotoGui::slotSetWidth(){
337 EditLineWidth->setText(QString(
"%1").arg(temp));
341 void IntelliPhotoGui::slotSetInnerAlpha(){
346 EditLineInnerAlpha->setText(QString(
"%1").arg(temp));
350 void IntelliPhotoGui::slotGoBack(){
354 void IntelliPhotoGui::slotGoForward(){
359 void IntelliPhotoGui::createActions(){
362 foreach (QByteArray format, QImageWriter::supportedImageFormats()) {
363 QString text = tr(
"%1...").arg(QString(format).toUpper());
366 QAction*action =
new QAction(text,
this);
369 action->setData(format);
372 connect(action, SIGNAL(triggered()),
this, SLOT(slotSave()));
375 actionSaveAs.append(action);
379 QAction*pngSaveAction =
new QAction(
"PNG-8",
this);
380 pngSaveAction->setData(
"PNG");
382 connect(pngSaveAction, SIGNAL(triggered()),
this, SLOT(slotSave()));
384 actionSaveAs.append(pngSaveAction);
385 pngSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
387 QAction*projectSaveAction =
new QAction(
"Projekt",
this);
388 projectSaveAction->setData(
"idf");
390 connect(projectSaveAction, SIGNAL(triggered()),
this, SLOT(slotSave()));
392 actionSaveAs.append(projectSaveAction);
393 projectSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
396 actionExit =
new QAction(tr(
"&Exit"),
this);
397 actionExit->setShortcuts(QKeySequence::Quit);
398 connect(actionExit, SIGNAL(triggered()),
this, SLOT(close()));
400 actionOpen =
new QAction(tr(
"&Open"),
this);
401 actionOpen->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
402 connect(actionOpen, SIGNAL(triggered()),
this, SLOT(slotOpen()));
405 actionCreateNewRasterLayer =
new QAction(tr(
"&Raster Image"),
this);
406 actionCreateNewRasterLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
407 connect(actionCreateNewRasterLayer, SIGNAL(triggered()),
this, SLOT(slotCreateNewRasterLayer()));
411 actionCreateNewShapedLayer =
new QAction(tr(
"&Shaped Image"),
this);
412 actionCreateNewShapedLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N + Qt::ALT));
413 connect(actionCreateNewShapedLayer, SIGNAL(triggered()),
this, SLOT(slotCreateNewShapedLayer()));
416 actionDeleteLayer =
new QAction(tr(
"&Delete Layer..."),
this);
417 actionDeleteLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_D));
418 connect(actionDeleteLayer, SIGNAL(triggered()),
this, SLOT(slotDeleteLayer()));
420 actionChangeDim =
new QAction(tr(
"&Change Dimension"),
this);
421 actionChangeDim->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_X));
422 connect(actionChangeDim, SIGNAL(triggered()),
this, SLOT(slotChangeDim()));
423 connect(dimCanvas, SIGNAL(clicked()),
this, SLOT(slotChangeDim()));
425 actionSetActiveLayer =
new QAction(tr(
"&set Active"),
this);
426 actionSetActiveLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
427 connect(actionSetActiveLayer, SIGNAL(triggered()),
this, SLOT(slotSetActiveLayer()));
429 actionSetActiveAlpha =
new QAction(tr(
"&set Alpha"),
this);
430 actionSetActiveAlpha->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_A));
431 connect(actionSetActiveAlpha, SIGNAL(triggered()),
this, SLOT(slotSetActiveAlpha()));
433 actionSetPolygon =
new QAction(tr(
"&set new Polygondata"),
this);
434 actionSetPolygon->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_P));
435 connect(actionSetPolygon, SIGNAL(triggered()),
this, SLOT(slotSetPolygon()));
437 actionMovePositionUp =
new QAction(tr(
"&move Up"),
this);
438 actionMovePositionUp->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up));
439 connect(actionMovePositionUp, SIGNAL(triggered()),
this, SLOT(slotPositionMoveUp()));
441 actionMovePositionDown =
new QAction(tr(
"&move Down"),
this);
442 actionMovePositionDown->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Down));
443 connect(actionMovePositionDown, SIGNAL(triggered()),
this, SLOT(slotPositionMoveDown()));
445 actionMovePositionLeft =
new QAction(tr(
"&move Left"),
this);
446 actionMovePositionLeft->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Left));
447 connect(actionMovePositionLeft, SIGNAL(triggered()),
this, SLOT(slotPositionMoveLeft()));
449 actionMovePositionRight =
new QAction(tr(
"&move Right"),
this);
450 actionMovePositionRight->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Right));
451 connect(actionMovePositionRight, SIGNAL(triggered()),
this, SLOT(slotPositionMoveRight()));
453 actionMoveLayerUp =
new QAction(tr(
"&move Layer Up"),
this);
454 actionMoveLayerUp->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Up));
455 connect(actionMoveLayerUp, SIGNAL(triggered()),
this, SLOT(slotMoveLayerUp()));
457 actionMoveLayerDown =
new QAction(tr(
"&move Layer Down"),
this);
458 actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
459 connect(actionMoveLayerDown, SIGNAL(triggered()),
this, SLOT(slotMoveLayerDown()));
462 actionUpdateRenderSettingsOn =
new QAction(tr(
"&On"),
this);
463 actionUpdateRenderSettingsOn->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + +Qt::Key_A));
464 connect(actionUpdateRenderSettingsOn, SIGNAL(triggered()),
this, SLOT(slotUpdateRenderSettingsOn()));
466 actionUpdateRenderSettingsOff =
new QAction(tr(
"&Off"),
this);
467 actionUpdateRenderSettingsOff->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + +Qt::Key_D));
468 connect(actionUpdateRenderSettingsOff, SIGNAL(triggered()),
this, SLOT(slotUpdateRenderSettingsOff()));
471 actionColorPickerFirstColor =
new QAction(tr(
"&Main"),
this);
472 actionColorPickerFirstColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_N));
473 connect(actionColorPickerFirstColor, SIGNAL(triggered()),
this, SLOT(slotSetFirstColor()));
474 connect(FirstColorButton, SIGNAL(clicked()),
this, SLOT(slotSetFirstColor()));
476 actionColorPickerSecondColor =
new QAction(tr(
"&Secondary"),
this);
477 actionColorPickerSecondColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_M));
478 connect(actionColorPickerSecondColor, SIGNAL(triggered()),
this, SLOT(slotSetSecondColor()));
479 connect(SecondColorButton, SIGNAL(clicked()),
this, SLOT(slotSetSecondColor()));
481 actionColorSwap =
new QAction(tr(
"&Switch"),
this);
482 actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S));
483 connect(actionColorSwap, SIGNAL(triggered()),
this, SLOT(slotSwapColor()));
484 connect(SwitchColorButton, SIGNAL(clicked()),
this, SLOT(slotSwapColor()));
487 actionCreatePlainTool =
new QAction(tr(
"&Plain"),
this);
488 actionCreatePlainTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_P));
489 connect(actionCreatePlainTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
490 connect(actionCreatePlainTool, SIGNAL(triggered()),
this, SLOT(slotCreatePlainTool()));
493 actionCreatePenTool =
new QAction(tr(
"&Pen"),
this);
494 actionCreatePenTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_S));
495 connect(actionCreatePenTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
496 connect(actionCreatePenTool, SIGNAL(triggered()),
this, SLOT(slotCreatePenTool()));
498 actionCreateLineTool =
new QAction(tr(
"&Line"),
this);
499 actionCreateLineTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_L));
500 connect(actionCreateLineTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
501 connect(actionCreateLineTool, SIGNAL(triggered()),
this, SLOT(slotCreateLineTool()));
503 actionCreateCircleTool =
new QAction(tr(
"&Circle"),
this);
504 actionCreateCircleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_C));
505 connect(actionCreateCircleTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
506 connect(actionCreateCircleTool, SIGNAL(triggered()),
this, SLOT(slotCreateCircleTool()));
508 actionCreateRectangleTool =
new QAction(tr(
"&Rectangle"),
this);
509 actionCreateRectangleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_R));
510 connect(actionCreateRectangleTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
511 connect(actionCreateRectangleTool, SIGNAL(triggered()),
this, SLOT(slotCreateRectangleTool()));
513 actionCreatePolygonTool =
new QAction(tr(
"&Polygon"),
this);
514 actionCreatePolygonTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_V));
515 connect(actionCreatePolygonTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
516 connect(actionCreatePolygonTool, SIGNAL(triggered()),
this, SLOT(slotCreatePolygonTool()));
518 actionCreateFloodFillTool =
new QAction(tr(
"&FloodFill"),
this);
519 actionCreateFloodFillTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_F));
520 connect(actionCreateFloodFillTool, SIGNAL(triggered()),
this, SLOT(slotResetTools()));
521 connect(actionCreateFloodFillTool, SIGNAL(triggered()),
this, SLOT(slotCreateFloodFillTool()));
524 actionAboutDialog =
new QAction(tr(
"&About"),
this);
525 actionAboutDialog->setShortcut(Qt::Key_F2);
526 connect(actionAboutDialog, SIGNAL(triggered()),
this, SLOT(slotAboutDialog()));
529 actionAboutQtDialog =
new QAction(tr(
"About &Qt"),
this);
530 actionAboutQtDialog->setShortcut(Qt::Key_F3);
531 connect(actionAboutQtDialog, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
533 connect(EditLineWidth, SIGNAL(returnPressed()),
this, SLOT(slotEnterPressed()));
534 connect(EditLineInnerAlpha, SIGNAL(returnPressed()),
this, SLOT(slotEnterPressed()));
536 connect(CircleButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
537 connect(CircleButton, SIGNAL(clicked()),
this, SLOT(slotCreateCircleTool()));
539 connect(FloodFillButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
540 connect(FloodFillButton, SIGNAL(clicked()),
this, SLOT(slotCreateFloodFillTool()));
542 connect(LineButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
543 connect(LineButton, SIGNAL(clicked()),
this, SLOT(slotCreateLineTool()));
545 connect(PenButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
546 connect(PenButton, SIGNAL(clicked()),
this, SLOT(slotCreatePenTool()));
548 connect(PlainButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
549 connect(PlainButton, SIGNAL(clicked()),
this, SLOT(slotCreatePlainTool()));
551 connect(PolygonButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
552 connect(PolygonButton, SIGNAL(clicked()),
this, SLOT(slotCreatePolygonTool()));
554 connect(RectangleButton,SIGNAL(pressed()),
this, SLOT(slotResetTools()));
555 connect(RectangleButton, SIGNAL(clicked()),
this, SLOT(slotCreateRectangleTool()));
557 actionSetWidth =
new QAction(tr(
"&Set Width"),
this);
558 actionSetWidth->setShortcut(QKeySequence(Qt::ALT + Qt::Key_W));
559 connect(actionSetWidth, SIGNAL(triggered()),
this, SLOT(slotSetWidth()));
561 actionSetInnerAlpha =
new QAction(tr(
"&Set Inner Alpha"),
this);
562 actionSetInnerAlpha->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A));
563 connect(actionSetInnerAlpha, SIGNAL(triggered()),
this, SLOT(slotSetInnerAlpha()));
565 actionGoBack =
new QAction(tr(
"&Go back"),
this);
566 actionGoBack->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
567 connect(actionGoBack, SIGNAL(triggered()),
this, SLOT(slotGoBack()));
569 actionGoForward =
new QAction(tr(
"&Go forward"),
this);
570 actionGoForward->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y));
571 connect(actionGoForward, SIGNAL(triggered()),
this, SLOT(slotGoForward()));
575 void IntelliPhotoGui::createMenus(){
577 saveAsMenu =
new QMenu(tr(
"&Save As"),
this);
578 foreach (QAction * action, actionSaveAs)
579 saveAsMenu->addAction(action);
582 fileMenu =
new QMenu(tr(
"&File"),
this);
583 fileMenu->addAction(actionOpen);
584 fileMenu->addMenu(saveAsMenu);
585 fileMenu->addSeparator();
586 fileMenu->addAction(actionExit);
589 renderMenu =
new QMenu(tr(
"&Fast Renderer"),
this);
590 renderMenu->addAction(actionUpdateRenderSettingsOn);
591 renderMenu->addAction(actionUpdateRenderSettingsOff);
594 layerCreationMenu =
new QMenu(tr(
"&Create new Layer"),
this);
595 layerCreationMenu->addAction(actionCreateNewRasterLayer);
596 layerCreationMenu->addAction(actionCreateNewShapedLayer);
599 layerMenu =
new QMenu(tr(
"&Layer"),
this);
600 layerMenu->addMenu(layerCreationMenu);
601 layerMenu->addSeparator();
602 layerMenu->addAction(actionSetActiveAlpha);
603 layerMenu->addAction(actionSetActiveLayer);
604 layerMenu->addAction(actionSetPolygon);
605 layerMenu->addSeparator();
606 layerMenu->addAction(actionMovePositionUp);
607 layerMenu->addAction(actionMovePositionDown);
608 layerMenu->addAction(actionMovePositionLeft);
609 layerMenu->addAction(actionMovePositionRight);
610 layerMenu->addAction(actionMoveLayerUp);
611 layerMenu->addAction(actionMoveLayerDown);
612 layerMenu->addSeparator();
613 layerMenu->addAction(actionDeleteLayer);
616 colorMenu =
new QMenu(tr(
"&Color"),
this);
617 colorMenu->addAction(actionColorPickerFirstColor);
618 colorMenu->addAction(actionColorPickerSecondColor);
619 colorMenu->addAction(actionColorSwap);
622 toolCreationMenu =
new QMenu(tr(
"&Drawingtools"),
this);
623 toolCreationMenu->addAction(actionCreateCircleTool);
624 toolCreationMenu->addAction(actionCreateFloodFillTool);
625 toolCreationMenu->addAction(actionCreateLineTool);
626 toolCreationMenu->addAction(actionCreatePenTool);
627 toolCreationMenu->addAction(actionCreatePlainTool);
628 toolCreationMenu->addAction(actionCreatePolygonTool);
629 toolCreationMenu->addAction(actionCreateRectangleTool);
632 toolSettingsMenu =
new QMenu(tr(
"&Toolsettings"),
this);
633 toolSettingsMenu->addAction(actionSetWidth);
634 toolSettingsMenu->addAction(actionSetInnerAlpha);
637 toolMenu =
new QMenu(tr(
"&Tools"),
this);
638 toolMenu->addMenu(toolCreationMenu);
639 toolMenu->addMenu(toolSettingsMenu);
640 toolMenu->addSeparator();
641 toolMenu->addMenu(colorMenu);
644 optionMenu =
new QMenu(tr(
"&Options"),
this);
645 optionMenu->addAction(actionGoBack);
646 optionMenu->addAction(actionGoForward);
647 optionMenu->addMenu(layerMenu);
648 optionMenu->addMenu(toolMenu);
649 optionMenu->addSeparator();
650 optionMenu->addMenu(renderMenu);
651 optionMenu->addAction(actionChangeDim);
654 helpMenu =
new QMenu(tr(
"&Help"),
this);
655 helpMenu->addAction(actionAboutDialog);
656 helpMenu->addAction(actionAboutQtDialog);
659 menuBar()->addMenu(fileMenu);
660 menuBar()->addMenu(optionMenu);
661 menuBar()->addMenu(helpMenu);
664 void IntelliPhotoGui::createGui(){
666 centralGuiWidget =
new QWidget(
this);
667 setCentralWidget(centralGuiWidget);
670 mainLayout =
new QGridLayout(centralGuiWidget);
671 centralGuiWidget->setLayout(mainLayout);
676 paintingArea->guiReference =
this;
678 preview = QPixmap(
":/Icons/Buttons/icons/circle-tool.svg");
679 CircleButton =
new QPushButton();
680 CircleButton->setFixedSize(Buttonsize);
681 CircleButton->setIcon(preview);
682 CircleButton->setIconSize(Buttonsize);
683 CircleButton->setCheckable(
true);
685 preview = QPixmap(
":/Icons/Buttons/icons/flood-fill-tool.svg");
686 FloodFillButton =
new QPushButton();
687 FloodFillButton->setFixedSize(Buttonsize);
688 FloodFillButton->setIcon(preview);
689 FloodFillButton->setIconSize(Buttonsize);
690 FloodFillButton->setCheckable(
true);
692 preview = QPixmap(
":/Icons/Buttons/icons/line-tool.svg");
693 LineButton =
new QPushButton();
694 LineButton->setFixedSize(Buttonsize);
695 LineButton->setIcon(preview);
696 LineButton->setIconSize(Buttonsize);
697 LineButton->setCheckable(
true);
699 preview = QPixmap(
":/Icons/Buttons/icons/pen-tool.svg");
700 PenButton =
new QPushButton();
701 PenButton->setFixedSize(Buttonsize);
702 PenButton->setIcon(preview);
703 PenButton->setIconSize(Buttonsize);
704 PenButton->setCheckable(
true);
706 preview = QPixmap(
":/Icons/Buttons/icons/plain-tool.svg");
707 PlainButton =
new QPushButton();
708 PlainButton->setFixedSize(Buttonsize);
709 PlainButton->setIcon(preview);
710 PlainButton->setIconSize(Buttonsize);
711 PlainButton->setCheckable(
true);
713 preview = QPixmap(
":/Icons/Buttons/icons/polygon-tool.svg");
714 PolygonButton =
new QPushButton();
715 PolygonButton->setFixedSize(Buttonsize);
716 PolygonButton->setIcon(preview);
717 PolygonButton->setIconSize(Buttonsize);
718 PolygonButton->setCheckable(
true);
720 preview = QPixmap(
":/Icons/Buttons/icons/rectangle-tool.svg");
721 RectangleButton =
new QPushButton();
722 RectangleButton->setFixedSize(Buttonsize);
723 RectangleButton->setIcon(preview);
724 RectangleButton->setIconSize(Buttonsize);
725 RectangleButton->setCheckable(
true);
727 WidthLine =
new QLabel();
728 WidthLine->setText(
"Width");
729 WidthLine->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
731 EditLineWidth =
new QLineEdit();
732 EditLineWidth->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
733 EditLineWidth->setText(
"5");
734 ValidatorLineWidth =
new QIntValidator();
735 ValidatorLineWidth->setTop(99);
736 ValidatorLineWidth->setBottom(1);
737 EditLineWidth->setValidator(ValidatorLineWidth);
739 innerAlphaLine =
new QLabel();
740 innerAlphaLine->setText(
"Inner Alpha");
741 innerAlphaLine->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
743 EditLineInnerAlpha =
new QLineEdit();
744 EditLineInnerAlpha->setFixedSize(Buttonsize.width() * 2,(Buttonsize.height() * 2) / 3);
745 EditLineInnerAlpha->setText(
"255");
746 ValidatorInnerAlpha =
new QIntValidator();
747 ValidatorInnerAlpha->setTop(999);
748 ValidatorInnerAlpha->setBottom(0);
749 EditLineInnerAlpha->setValidator(ValidatorInnerAlpha);
751 FirstColorButton =
new QPushButton();
752 FirstColorButton->setFixedSize(Buttonsize);
754 SecondColorButton =
new QPushButton();
755 SecondColorButton->setFixedSize(Buttonsize);
757 preview = QPixmap(
":/Icons/Buttons/icons/Wechselpfeile.png");
758 SwitchColorButton =
new QPushButton();
759 SwitchColorButton->setFixedSize(Buttonsize.width() * 2,Buttonsize.height());
760 SwitchColorButton->setIcon(preview);
761 SwitchColorButton->setIconSize(QSize(Buttonsize.width() * 2,Buttonsize.height()));
763 ActiveLayerLine =
new QLabel();
765 ActiveLayerLine->setText(
string);
766 ActiveLayerLine->setFixedSize(Buttonsize.width() * 2 + 10,(Buttonsize.height() * 2) / 3);
770 preview = preview.fromImage(activePicture->
getImageData());
772 QImage tmp(1,1,QImage::Format_ARGB32);
773 tmp.fill(Qt::transparent);
774 preview = preview.fromImage(tmp);
777 ActiveLayerImageLabel =
new QLabel();
778 ActiveLayerImageLabel->setFixedSize(Buttonsize * 2);
779 ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2));
781 dimActive =
new QPushButton();
782 dimActive->setFixedSize(Buttonsize.width() * 2,Buttonsize.height() / 2);
783 dimActive->setText(
"0x0");
785 dimCanvas =
new QPushButton();
786 dimCanvas->setFixedSize(Buttonsize.width() * 2,Buttonsize.height() / 2);
787 QString String = QString(
"%1x%2").arg(paintingArea->Canvas->width()).arg(paintingArea->Canvas->height());
788 dimCanvas->setText(String);
790 ScrollArea =
new QScrollArea(
this);
791 ScrollArea->setBackgroundRole(QPalette::Dark);
792 ScrollArea->setWidget(paintingArea);
793 ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
794 ScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
797 mainLayout->addWidget(ScrollArea,1,1,20,1);
798 mainLayout->addWidget(CircleButton,1,2,1,1);
799 mainLayout->addWidget(FloodFillButton,1,3,1,1);
800 mainLayout->addWidget(LineButton,2,2,1,1);
801 mainLayout->addWidget(PenButton,2,3,1,1);
802 mainLayout->addWidget(PlainButton,3,2,1,1);
803 mainLayout->addWidget(PolygonButton,3,3,1,1);
804 mainLayout->addWidget(RectangleButton,4,2,1,1);
805 mainLayout->addWidget(WidthLine,5,2,1,2);
806 mainLayout->addWidget(EditLineWidth,6,2,1,2);
807 mainLayout->addWidget(innerAlphaLine,7,2,1,2);
808 mainLayout->addWidget(EditLineInnerAlpha,8,2,1,2);
809 mainLayout->addWidget(FirstColorButton,9,2,1,1);
810 mainLayout->addWidget(SecondColorButton,9,3,1,1);
811 mainLayout->addWidget(SwitchColorButton,10,2,1,2);
812 mainLayout->addWidget(ActiveLayerLine,11,2,1,2);
813 mainLayout->addWidget(ActiveLayerImageLabel,12,2,1,2);
814 mainLayout->addWidget(dimActive,13,2,1,2);
815 mainLayout->addWidget(dimCanvas,14,2,1,2);
816 mainLayout->setHorizontalSpacing(0);
820 void IntelliPhotoGui::setIntelliStyle(){
822 setWindowTitle(
"IntelliPhoto Prototype");
824 this->setStyleSheet(
"color: white;" "background-color: rgb(64, 64, 64);" "selection-color: rgb(200, 10, 10);" "selection-background-color: rgb(64, 64, 64);");
827 FirstColorButton->setStyleSheet(
string);
829 SecondColorButton->setStyleSheet(
string);
832 bool IntelliPhotoGui::maybeSave(){
835 QMessageBox::StandardButton ret;
839 ret = QMessageBox::warning(
this, tr(
"Painting"),
840 tr(
"The image has been modified.\n"
841 "Do you want to save your changes?"),
842 QMessageBox::Save | QMessageBox::Discard
843 | QMessageBox::Cancel);
846 if (ret == QMessageBox::Save) {
847 return saveFile(
"png");
850 }
else if (ret == QMessageBox::Cancel) {
857 bool IntelliPhotoGui::saveFile(
const QByteArray &fileFormat){
859 QString initialPath = QDir::currentPath() +
"/untitled." + fileFormat;
863 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save As"),
865 tr(
"%1 Files (*.%2);;All Files (*)")
866 .arg(QString::fromLatin1(fileFormat.toUpper()))
867 .arg(QString::fromLatin1(fileFormat)),
nullptr, QFileDialog::DontUseNativeDialog);
870 if (fileName.isEmpty()) {
874 if(fileFormat ==
"idf") {
878 return paintingArea->
save(fileName, fileFormat.constData());
882 void IntelliPhotoGui::setDefaultValues(){
889 }
else if(value > 50) {
892 EditLineWidth->setText(QString(
"%1").arg(value));
897 ActiveLayerLine->setText(
string);
901 preview = preview.fromImage(activePicture->
getImageData());
903 QImage tmp(1,1,QImage::Format_ARGB32);
904 tmp.fill(Qt::transparent);
905 preview = preview.fromImage(tmp);
909 ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2));
912 FirstColorButton->setStyleSheet(
string);
914 SecondColorButton->setStyleSheet(
string);
916 string = QString(
"%1x%2").arg(paintingArea->Canvas->width()).arg(paintingArea->Canvas->height());
917 dimCanvas->setText(
string);
919 if(paintingArea->layerBundle.size() != 0) {
920 string = QString(
"%1x%2").arg(paintingArea->layerBundle[
static_cast<size_t>
923 dimActive->setText(
string);
926 dimActive->setText(
"0x0");