Its fullscreen again and it works on i3 too

This commit is contained in:
ArsenArsen 2017-06-29 19:09:39 +02:00
parent 53a21bb2f1
commit f5d8ef6885
5 changed files with 35 additions and 6 deletions

View File

@ -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);
}

View File

@ -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<DrawItem *()> 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) {

View File

@ -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<DrawItem *()> item);
void done();
bool fullscreen;
std::function<DrawItem *()> drawingSelectionMaker;
QFlags<Qt::MouseButton> prevButtons;
QPixmap *_pixmap;

View File

@ -2,9 +2,11 @@
#include <QInputDialog>
#include <QtMath>
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;
}

View File

@ -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;