From f5d8ef68858aea5f53c6b96bccaaf5afe01a113d Mon Sep 17 00:00:00 2001 From: ArsenArsen Date: Thu, 29 Jun 2017 19:09:39 +0200 Subject: [PATCH] Its fullscreen again and it works on i3 too --- cropeditor/cropeditor.cpp | 7 ++++--- cropeditor/cropscene.cpp | 24 +++++++++++++++++++++++- cropeditor/cropscene.hpp | 4 ++++ cropeditor/drawing/textitem.cpp | 4 +++- cropeditor/drawing/textitem.hpp | 2 +- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/cropeditor/cropeditor.cpp b/cropeditor/cropeditor.cpp index 1d95e05..852df46 100644 --- a/cropeditor/cropeditor.cpp +++ b/cropeditor/cropeditor.cpp @@ -18,9 +18,10 @@ CropEditor::CropEditor(QPixmap *image, QObject *parent) : QObject(parent) { pixmapItem->setScale(1 / ratio); scene->addItem(pixmapItem); scene->setSceneRect(image->rect()); - view->show(); - view->resize(pixmapItem->pixmap().width(), pixmapItem->pixmap().height()); - view->move(0, 0); + // view->show(); + // view->resize(pixmapItem->pixmap().width(), pixmapItem->pixmap().height()); + // view->move(0, 0); + view->showFullScreen(); connect(scene, &CropScene::closedWithRect, this, &CropEditor::crop); } diff --git a/cropeditor/cropscene.cpp b/cropeditor/cropscene.cpp index 3d45703..3b92f62 100644 --- a/cropeditor/cropscene.cpp +++ b/cropeditor/cropscene.cpp @@ -58,7 +58,11 @@ CropScene::CropScene(QObject *parent, QPixmap *pixmap) menu.addSeparator(); display = menu.addAction(drawingName); display->setDisabled(true); - connect(settings, &QAction::triggered, [&] { BrushPenSelection(this).exec(); }); + connect(settings, &QAction::triggered, [&] { + hide(); + BrushPenSelection(this).exec(); + show(); + }); menu.addAction(settings); magnifier = addPixmap(pixmap->copy(0, 0, 11, 11).scaled(110, 110)); @@ -118,10 +122,28 @@ void CropScene::setDrawingSelection(QString name, std::function dr if (!drawingSelection->init(this)) setDrawingSelection("None", [] { return nullptr; }); } +void CropScene::hide() { + setVisible(false); +} + +void CropScene::show() { + setVisible(true); +} + +void CropScene::setVisible(bool visible) { + for (auto view : views()) { + if (view->isVisible()) fullscreen |= view->isFullScreen(); + view->setVisible(visible); + if (visible && fullscreen) view->showFullScreen(); + } +} + void CropScene::fontAsk() { + hide(); bool ok = false; QFont font = QFontDialog::getFont(&ok, this->font(), nullptr, "Font to use"); if (ok) _font = font; + show(); } void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) { diff --git a/cropeditor/cropscene.hpp b/cropeditor/cropscene.hpp index 9e03d5d..dd12340 100644 --- a/cropeditor/cropscene.hpp +++ b/cropeditor/cropscene.hpp @@ -31,6 +31,9 @@ public: QGraphicsRectItem *selRect() { return rect; } + void hide(); + void show(); + void setVisible(bool visible); public slots: void fontAsk(); @@ -52,6 +55,7 @@ private: void initMagnifierGrid(); void addDrawingAction(QMenu &menu, QString name, std::function item); void done(); + bool fullscreen; std::function drawingSelectionMaker; QFlags prevButtons; QPixmap *_pixmap; diff --git a/cropeditor/drawing/textitem.cpp b/cropeditor/drawing/textitem.cpp index dd972fe..bf67849 100644 --- a/cropeditor/drawing/textitem.cpp +++ b/cropeditor/drawing/textitem.cpp @@ -2,9 +2,11 @@ #include #include -bool TextItem::init(CropScene *) { +bool TextItem::init(CropScene *s) { bool ok; + s->hide(); text = QInputDialog::getText(nullptr, "Text to add", "Input", QLineEdit::Normal, QString(), &ok); + s->show(); return ok; } diff --git a/cropeditor/drawing/textitem.hpp b/cropeditor/drawing/textitem.hpp index de469f7..b2660ef 100644 --- a/cropeditor/drawing/textitem.hpp +++ b/cropeditor/drawing/textitem.hpp @@ -7,7 +7,7 @@ class TextItem : public DrawItem { public: QString name() override; - bool init(CropScene *) override; + bool init(CropScene *s) override; void mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) override; void mouseDragEndEvent(QGraphicsSceneMouseEvent *, CropScene *) override;