diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,7 @@ widgets/ksaneoptionwidget.cpp ksaneviewer.cpp selectionitem.cpp + hiderectitem.cpp ksanedevicedialog.cpp ksanefinddevicesthread.cpp ksanewidget.cpp diff --git a/src/hiderectitem.h b/src/hiderectitem.h new file mode 100644 --- /dev/null +++ b/src/hiderectitem.h @@ -0,0 +1,43 @@ +/* ============================================================ +* +* This file is part of the KDE project +* +* Description: QGraphicsItem for hiding rects in the image viewer. +* +* Copyright (C) 2019 by Alexander Volkov +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) version 3, or any +* later version accepted by the membership of KDE e.V. (or its +* successor approved by the membership of KDE e.V.), which shall +* act as a proxy defined in Section 6 of version 3 of the license. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program. If not, see . +* +* ============================================================ */ + +#ifndef HIDERECTITEM_H +#define HIDERECTITEM_H + +#include + +namespace KSaneIface +{ + +class HideRectItem : public QGraphicsRectItem +{ +public: + HideRectItem(); +}; + +} // NameSpace KSaneIface + +#endif // HIDERECTITEM_H diff --git a/src/hiderectitem.cpp b/src/hiderectitem.cpp new file mode 100644 --- /dev/null +++ b/src/hiderectitem.cpp @@ -0,0 +1,41 @@ +/* ============================================================ +* +* This file is part of the KDE project +* +* Description: QGraphicsItem for hiding rects in the image viewer. +* +* Copyright (C) 2019 by Alexander Volkov +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) version 3, or any +* later version accepted by the membership of KDE e.V. (or its +* successor approved by the membership of KDE e.V.), which shall +* act as a proxy defined in Section 6 of version 3 of the license. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program. If not, see . +* +* ============================================================ */ + +#include "hiderectitem.h" + +#include + +namespace KSaneIface +{ + +HideRectItem::HideRectItem() +{ + setOpacity(0.4); + setPen(Qt::NoPen); + setBrush(Qt::black); +} + +} // NameSpace KSaneIface diff --git a/src/ksaneviewer.cpp b/src/ksaneviewer.cpp --- a/src/ksaneviewer.cpp +++ b/src/ksaneviewer.cpp @@ -29,6 +29,7 @@ #include "ksaneviewer.h" #include "selectionitem.h" +#include "hiderectitem.h" #include #include @@ -65,11 +66,11 @@ QAction *zoom2FitAction; QAction *clrSelAction; - QGraphicsRectItem *hideLeft; - QGraphicsRectItem *hideRight; - QGraphicsRectItem *hideTop; - QGraphicsRectItem *hideBottom; - QGraphicsRectItem *hideArea; + HideRectItem *hideLeft; + HideRectItem *hideRight; + HideRectItem *hideTop; + HideRectItem *hideBottom; + HideRectItem *hideArea; int wheelDelta = 0; }; @@ -95,29 +96,13 @@ d->selection->setRect(d->scene->sceneRect()); d->selection->setVisible(false); - d->hideTop = new QGraphicsRectItem; - d->hideBottom = new QGraphicsRectItem; - d->hideRight = new QGraphicsRectItem; - d->hideLeft = new QGraphicsRectItem; - d->hideArea = new QGraphicsRectItem; - - d->hideTop->setOpacity(0.4); - d->hideBottom->setOpacity(0.4); - d->hideRight->setOpacity(0.4); - d->hideLeft->setOpacity(0.4); + d->hideTop = new HideRectItem; + d->hideBottom = new HideRectItem; + d->hideRight = new HideRectItem; + d->hideLeft = new HideRectItem; + d->hideArea = new HideRectItem; d->hideArea->setOpacity(0.6); - d->hideTop->setPen(Qt::NoPen); - d->hideBottom->setPen(Qt::NoPen); - d->hideRight->setPen(Qt::NoPen); - d->hideLeft->setPen(Qt::NoPen); - d->hideArea->setPen(Qt::NoPen); - - d->hideTop->setBrush(QBrush(Qt::black)); - d->hideBottom->setBrush(QBrush(Qt::black)); - d->hideRight->setBrush(QBrush(Qt::black)); - d->hideLeft->setBrush(QBrush(Qt::black)); - d->scene->addItem(d->selection); d->scene->addItem(d->hideLeft); d->scene->addItem(d->hideRight);