]> git.sesse.net Git - kdenlive/blob - src/headertrack.cpp
Fix several warnings, cleanup effect settings layout
[kdenlive] / src / headertrack.cpp
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20 #include <QMouseEvent>
21 #include <QStylePainter>
22 #include <QFrame>
23 #include <QWidget>
24 #include <QPainter>
25 #include <QAction>
26
27 #include <KIcon>
28 #include <KLocale>
29 #include <KDebug>
30
31 #include "kdenlivesettings.h"
32 #include "headertrack.h"
33
34 HeaderTrack::HeaderTrack(int index, TrackInfo info, QWidget *parent)
35         : QWidget(parent), m_index(index), m_type(info.type) {
36     setFixedHeight(KdenliveSettings::trackheight());
37     view.setupUi(this);
38     view.track_number->setText(QString::number(m_index));
39     if (m_type == VIDEOTRACK) {
40         view.frame->setBackgroundRole(QPalette::AlternateBase);
41         view.frame->setAutoFillBackground(true);
42         view.buttonVideo->setIcon(KIcon("kdenlive-show-video"));
43     } else {
44         view.buttonVideo->setHidden(true);
45     }
46     view.buttonAudio->setIcon(KIcon("kdenlive-show-audio"));
47     view.buttonVideo->setChecked(!info.isBlind);
48     view.buttonAudio->setChecked(!info.isMute);
49     connect(view.buttonVideo, SIGNAL(clicked()), this, SLOT(switchVideo()));
50     connect(view.buttonAudio, SIGNAL(clicked()), this, SLOT(switchAudio()));
51
52     m_contextMenu = new QMenu(this);
53
54     //TODO: implement add/remove track
55     /*QAction *insertAction = new QAction(i18n("Insert track"), this);
56     m_contextMenu->addAction(insertAction);
57     connect(insertAction, SIGNAL(triggered()), this, SLOT(slotAddTrack()));
58
59     QAction *removeAction = new QAction(KIcon("edit-delete"), i18n("Delete track"), this);
60     m_contextMenu->addAction(removeAction);
61     connect(removeAction, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));*/
62 }
63
64 void HeaderTrack::switchVideo() {
65     emit switchTrackVideo(m_index);
66 }
67
68 void HeaderTrack::switchAudio() {
69     emit switchTrackAudio(m_index);
70 }
71
72 void HeaderTrack::slotDeleteTrack() {
73     emit deleteTrack(m_index);
74 }
75
76 void HeaderTrack::slotAddTrack() {
77     emit insertTrack(m_index);
78 }
79
80 // virtual
81 void HeaderTrack::contextMenuEvent(QContextMenuEvent * event) {
82     m_contextMenu->popup(event->globalPos());
83 }
84
85 // virtual
86 /*void HeaderTrack::paintEvent(QPaintEvent *e) {
87     QRect region = e->rect();
88     region.setTopLeft(QPoint(region.left() + 1, region.top() + 1));
89     region.setBottomRight(QPoint(region.right() - 1, region.bottom() - 1));
90     QPainter painter(this);
91     if (m_type == AUDIOTRACK) painter.fillRect(region, QBrush(QColor(240, 240, 255)));
92     else painter.fillRect(region, QBrush(QColor(255, 255, 255)));
93     painter.drawText(region, Qt::AlignCenter, m_label);
94 }*/
95
96
97 #include "headertrack.moc"