File indexing completed on 2024-05-05 04:49:23
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Thomas Luebking <thomas.luebking@web.de> * 0003 * Copyright (c) 2010 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 MAINTOOLBAR3G_H 0019 #define MAINTOOLBAR3G_H 0020 0021 class AnimatedLabelStack; 0022 class PlayPauseButton; 0023 class QLabel; 0024 class QSpacerItem; 0025 class VolumeDial; 0026 0027 namespace Amarok { class TimeSlider; } 0028 0029 #include "core/meta/forward_declarations.h" 0030 #include <QToolBar> 0031 0032 class MainToolbar : public QToolBar 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 explicit MainToolbar( QWidget *parent = nullptr ); 0038 0039 protected: 0040 bool eventFilter( QObject *o, QEvent *ev ) override; 0041 void showEvent( QShowEvent *ev ) override; 0042 void hideEvent( QHideEvent *ev ) override; 0043 void paintEvent( QPaintEvent *ev ) override; 0044 void resizeEvent( QResizeEvent *ev ) override; 0045 void timerEvent( QTimerEvent *ev ) override; 0046 0047 private: 0048 void animateTrackLabels(); 0049 void setCurrentTrackActionsVisible( bool ); 0050 void updateCurrentTrackActions(); 0051 0052 private Q_SLOTS: 0053 void stopped(); 0054 void paused(); 0055 void playing(); 0056 void trackChanged( Meta::TrackPtr track ); 0057 void trackLengthChanged( qint64 ms ); 0058 void trackPositionChanged( qint64 position, bool userSeek ); 0059 0060 void muteStateChanged( bool mute ); 0061 void volumeChanged( int percent ); 0062 void addBookmark( const QString &name, int milliSeconds ); 0063 void layoutProgressBar(); 0064 void layoutTrackBar(); 0065 void setLabelTime( int ms ); 0066 void updateBookmarks( const QString *BookmarkName ); 0067 void updatePrevAndNext(); 0068 0069 private: 0070 PlayPauseButton *m_playPause; 0071 0072 QSpacerItem *m_trackBarSpacer; 0073 QSpacerItem *m_progressBarSpacer; 0074 0075 QPixmap m_skip_left, m_skip_right; 0076 0077 struct Current 0078 { 0079 Current() : label(nullptr), key(nullptr), actionsVisible(false) {} 0080 AnimatedLabelStack *label; 0081 void* key; 0082 QString uidUrl; 0083 bool actionsVisible; 0084 QRect rect; 0085 } m_current; 0086 0087 struct Skip 0088 { 0089 Skip() : label(nullptr), key(nullptr) {} 0090 AnimatedLabelStack *label; 0091 void* key; 0092 QRect rect; 0093 }; 0094 0095 Skip m_next, m_prev; 0096 0097 struct Dummy 0098 { 0099 Dummy() : label(nullptr), targetX(0) {} 0100 AnimatedLabelStack *label; 0101 int targetX; 0102 } m_dummy; 0103 0104 QLabel *m_timeLabel, *m_remainingTimeLabel; 0105 Amarok::TimeSlider *m_slider; 0106 0107 VolumeDial *m_volume; 0108 0109 int m_lastTime; 0110 int m_lastRemainingTime; 0111 0112 struct 0113 { 0114 int startX; 0115 int lastX; 0116 int max; 0117 } m_drag; 0118 int m_trackBarAnimationTimer; 0119 0120 QString m_promoString; 0121 }; 0122 0123 #endif