| 1 |
/* |
| 2 |
* Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd. |
| 3 |
* |
| 4 |
* Author: ZhangYong <[email protected]> |
| 5 |
* |
| 6 |
* Maintainer: ZhangYong <[email protected]> |
| 7 |
* |
| 8 |
* This program is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* This program is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU General Public License |
| 19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
#ifndef NAVIGATIONWIDGET_H |
| 22 |
#define NAVIGATIONWIDGET_H |
| 23 |
|
| 24 |
#include "controller/viewerthememanager.h" |
| 25 |
#include <QWidget> |
| 26 |
|
| 27 |
class NavigationWidget : public QWidget |
| 28 |
{ |
| 29 |
Q_OBJECT |
| 30 |
|
| 31 |
public: |
| 32 |
explicit NavigationWidget(QWidget *parent = nullptr); |
| 33 |
void setImage(const QImage &img); |
| 34 |
void setRectInImage(const QRect &r); |
| 35 |
void setAlwaysHidden(bool value); |
| 36 |
bool isAlwaysHidden() const; |
| 37 |
QPoint transImagePos(QPoint pos); |
| 38 |
|
| 39 |
Q_SIGNALS: |
| 40 |
void requestMove(int x, int y); |
| 41 |
protected: |
| 42 |
void paintEvent(QPaintEvent *); |
| 43 |
void mousePressEvent(QMouseEvent *e); |
| 44 |
void mouseMoveEvent(QMouseEvent *e); |
| 45 |
private: |
| 46 |
void tryMoveRect(const QPoint &p); |
| 47 |
void onThemeChanged(ViewerThemeManager::AppTheme theme); |
| 48 |
private: |
| 49 |
bool m_hide = false; |
| 50 |
qreal m_imageScale = 1.0; |
| 51 |
|
| 52 |
qreal m_widthScale {1.0}; |
| 53 |
qreal m_heightScale {1.0}; |
| 54 |
|
| 55 |
QImage m_img; |
| 56 |
QPixmap m_pix; |
| 57 |
QRectF m_r; // Image visible rect |
| 58 |
QRect m_mainRect; |
| 59 |
QRect m_originRect; |
| 60 |
|
| 61 |
QRect imageDrawRect; |
| 62 |
|
| 63 |
QString m_bgImgUrl; |
| 64 |
QColor m_BgColor; |
| 65 |
QColor m_mrBgColor; |
| 66 |
QColor m_mrBorderColor; |
| 67 |
QColor m_imgRBorderColor; |
| 68 |
}; |
| 69 |
|
| 70 |
#endif // NAVIGATIONWIDGET_H |