File indexing completed on 2024-05-05 04:49:25

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Casey Link <unnamedrambler@gmail.com>                             *
0003  * Copyright (c) 2009 Mark Kretschmann <kretschmann@kde.org                             *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef BOOKMARKTRIANGLE_H
0019 #define BOOKMARKTRIANGLE_H
0020 
0021 #include "BookmarkPopup.h"
0022 
0023 #include <QEvent>
0024 #include <QMouseEvent>
0025 #include <QPaintEvent>
0026 #include <QWidget>
0027 #include <QPoint>
0028 
0029 class QSize;
0030 class QSizePolicy;
0031 
0032 
0033 class BookmarkTriangle : public QWidget
0034 {
0035     Q_OBJECT
0036 public:
0037     BookmarkTriangle( QWidget *parent, int milliseconds, const QString &name, int sliderwidth,
0038                       bool showPopup = false );
0039     ~BookmarkTriangle() override;
0040     QSize sizeHint() const override;
0041     virtual QSizePolicy sizePolicy() const;
0042     QSize minimumSizeHint() const override;
0043 
0044     void showEvent ( QShowEvent * event ) override;
0045     void mousePressEvent ( QMouseEvent * event ) override;
0046     void mouseMoveEvent ( QMouseEvent * event ) override;
0047     void mouseReleaseEvent  (QMouseEvent *) override;
0048     void enterEvent ( QEvent * event ) override;
0049     void leaveEvent ( QEvent * event ) override;
0050     void paintEvent ( QPaintEvent* ) override;
0051 
0052     virtual void hidePopup();
0053 
0054     /**
0055      * Updates the position of the bookmark named @p name to @p newMilliseconds.
0056      *
0057      * The name should be a valid existing bookmark name and should include the trailing
0058      * "- m:ss"
0059      * @param name the name
0060      * @param newMilliseconds the new position in milliseconds
0061      */
0062     virtual void moveBookmark( qint64 newMilliseconds, const QString &name );
0063 
0064     virtual void deleteBookmark();
0065     virtual int getTimeValue();
0066 
0067 Q_SIGNALS:
0068     void clicked ( int );
0069     void focused ( int );
0070 
0071 private:
0072     void initPopup();
0073 
0074     int m_mseconds; /// position of the bookmark on the slider in terms of milliseconds
0075     QString m_name; /// name of the bookmark
0076     int m_sliderwidth; /// width of the slider on which the bookmark will appear
0077     bool m_showPopup; /// used to determine whether to show the Pop-up on focusing the bookmark
0078     BookmarkPopup* m_tooltip; /// the tooltip that appears on focusing the bookmark
0079     QPoint m_offset; /// used while moving the bookmark, holds the position of the bookmark before moving
0080     int m_pos; /// used while moving the bookmark, holds the x co-ordinate of the bookmark after moving
0081 };
0082 #endif // BOOKMARKTRIANGLE_H