// Copyright 2017 Alejandro Sirgo Rica // // This file is part of Flameshot. // // Flameshot is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Flameshot 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Flameshot. If not, see . // Based on Lightscreen areadialog.h, Copyright 2017 Christian Kaiser // released under the GNU GPL2 // Based on KDE's KSnapshot regiongrabber.cpp, revision 796531, Copyright 2007 Luca Gugelmann // released under the GNU LGPL #ifndef CAPTUREWIDGET_H #define CAPTUREWIDGET_H #include "capturebutton.h" #include "src/capture/tools/capturetool.h" #include "buttonhandler.h" #include #include class QPaintEvent; class QResizeEvent; class QMouseEvent; class CaptureModification; class QNetworkAccessManager; class QNetworkReply; class ColorPicker; class Screenshot; class NotifierBox; class CaptureWidget : public QWidget { Q_OBJECT public: explicit CaptureWidget(const QString &forcedSavePath = QString(), QWidget *parent = nullptr); ~CaptureWidget(); void updateButtons(); QPixmap pixmap(); private slots: void copyScreenshot(); void saveScreenshot(); void uploadToImgur(); bool undo(); void leftResize(); void rightResize(); void upResize(); void downResize(); void setState(CaptureButton *); void handleButtonSignal(CaptureTool::Request r); protected: void paintEvent(QPaintEvent *); void mousePressEvent(QMouseEvent *); void mouseMoveEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); void keyPressEvent(QKeyEvent *); void wheelEvent(QWheelEvent *); QRegion handleMask() const; // pixel map of the screen Screenshot* m_screenshot; QPoint m_dragStartPoint; QPoint m_mousePos; // pointer to the handlers under the mouse QRect *m_mouseOverHandle; QRect m_selection; QRect m_selectionBeforeDrag; // utility flags bool m_mouseIsClicked; bool m_rightClick; bool m_newSelection; bool m_grabbing; bool m_showInitialMsg; const QString m_forcedSavePath; int m_thickness; NotifierBox *m_notifierBox; // naming convention for handles // T top, B bottom, R Right, L left // 2 letters: a corner // 1 letter: the handle on the middle of the corresponding side QRect m_TLHandle, m_TRHandle, m_BLHandle, m_BRHandle; QRect m_LHandle, m_THandle, m_RHandle, m_BHandle; // list containing the active habdlers QVector m_Handles; private: void initShortcuts(); void updateHandles(); void updateSizeIndicator(); void updateCursor(); QRect extendedSelection() const; QVector m_modifications; QPointer m_sizeIndButton; QPointer m_lastPressedButton; CaptureButton::ButtonType m_state; ButtonHandler *m_buttonHandler; QColor m_uiColor; QColor m_contrastUiColor; ColorPicker *m_colorPicker; }; #endif // CAPTUREWIDGET_H