+HeaderTrack::HeaderTrack(int index, TrackInfo info, int height, QWidget *parent) :
+ QWidget(parent),
+ m_index(index),
+ m_type(info.type)
+{
+ setFixedHeight(height);
+ m_view.setupUi(this);
+ m_view.track_number->setText(info.trackName.isEmpty() ? QString::number(m_index) : info.trackName);
+
+ m_view.buttonVideo->setChecked(info.isBlind);
+ m_view.buttonVideo->setToolTip(i18n("Hide track"));
+ m_view.buttonAudio->setChecked(info.isMute);
+ m_view.buttonAudio->setToolTip(i18n("Mute track"));
+ m_view.buttonLock->setChecked(info.isLocked);
+ m_view.buttonLock->setToolTip(i18n("Lock track"));
+
+ if (m_type == VIDEOTRACK) {
+ setBackgroundRole(QPalette::AlternateBase);
+ setAutoFillBackground(true);
+ if (!info.isBlind) m_view.buttonVideo->setIcon(KIcon("kdenlive-show-video"));
+ else m_view.buttonVideo->setIcon(KIcon("kdenlive-hide-video"));
+ } else {
+ m_view.buttonVideo->setHidden(true);
+ }
+ if (!info.isMute) m_view.buttonAudio->setIcon(KIcon("kdenlive-show-audio"));
+ else m_view.buttonAudio->setIcon(KIcon("kdenlive-hide-audio"));
+
+ if (!info.isLocked) m_view.buttonLock->setIcon(KIcon("kdenlive-unlock"));
+ else m_view.buttonLock->setIcon(KIcon("kdenlive-lock"));
+
+ connect(m_view.buttonVideo, SIGNAL(clicked()), this, SLOT(switchVideo()));
+ connect(m_view.buttonAudio, SIGNAL(clicked()), this, SLOT(switchAudio()));
+ connect(m_view.buttonLock, SIGNAL(clicked()), this, SLOT(switchLock()));
+
+ // Don't show track buttons if size is too small
+ if (height < 40) {
+ m_view.buttonVideo->setHidden(true);
+ m_view.buttonAudio->setHidden(true);
+ m_view.buttonLock->setHidden(true);
+ //m_view.horizontalSpacer;
+ }
+
+ setContextMenuPolicy(Qt::ActionsContextMenu);
+ QAction *insertAction = new QAction(i18n("Insert Track"), this);
+ addAction(insertAction);
+ connect(insertAction, SIGNAL(triggered()), this, SLOT(slotAddTrack()));
+
+ QAction *removeAction = new QAction(KIcon("edit-delete"), i18n("Delete Track"), this);
+ addAction(removeAction);
+ connect(removeAction, SIGNAL(triggered()), this, SLOT(slotDeleteTrack()));
+
+ QAction *changeAction = new QAction(i18n("Change Track Type"), this);
+ addAction(changeAction);
+ connect(changeAction, SIGNAL(triggered()), this, SLOT(slotChangeTrack()));
+
+ QAction *renameAction = new QAction(i18n("Rename Track"), this);
+ addAction(renameAction);
+ connect(renameAction, SIGNAL(triggered()), this, SLOT(slotRenameTrack()));
+
+}
+
+/*HeaderTrack::~HeaderTrack()
+{
+}*/
+
+void HeaderTrack::adjustSize(int height)
+{
+ // Don't show track buttons if size is too small
+ bool smallTracks = height < 40;
+ if (m_type == VIDEOTRACK) m_view.buttonVideo->setHidden(smallTracks);
+ m_view.buttonAudio->setHidden(smallTracks);
+ m_view.buttonLock->setHidden(smallTracks);
+ setFixedHeight(height);
+}
+
+void HeaderTrack::switchVideo()
+{
+ if (m_view.buttonVideo->isChecked()) {
+ m_view.buttonVideo->setIcon(KIcon("kdenlive-hide-video"));
+ } else {
+ m_view.buttonVideo->setIcon(KIcon("kdenlive-show-video"));
+ }
+ emit switchTrackVideo(m_index);
+}
+
+void HeaderTrack::switchAudio()
+{
+ if (m_view.buttonAudio->isChecked()) {
+ m_view.buttonAudio->setIcon(KIcon("kdenlive-hide-audio"));
+ } else {
+ m_view.buttonAudio->setIcon(KIcon("kdenlive-show-audio"));
+ }
+ emit switchTrackAudio(m_index);
+}
+
+void HeaderTrack::switchLock(bool emitSignal)
+{
+ if (m_view.buttonLock->isChecked()) {
+ m_view.buttonLock->setIcon(KIcon("kdenlive-lock"));
+ } else {
+ m_view.buttonLock->setIcon(KIcon("kdenlive-unlock"));
+ }
+ if (emitSignal) emit switchTrackLock(m_index);
+}
+
+
+void HeaderTrack::setLock(bool lock)
+{
+ m_view.buttonLock->setChecked(lock);
+ switchLock(false);
+}
+
+void HeaderTrack::slotDeleteTrack()
+{
+ QTimer::singleShot(500, this, SLOT(deleteTrack()));
+}
+
+void HeaderTrack::deleteTrack()
+{
+ emit deleteTrack(m_index);
+}
+
+void HeaderTrack::slotAddTrack()
+{
+ emit insertTrack(m_index);
+}
+
+void HeaderTrack::slotChangeTrack()
+{
+ emit changeTrack(m_index);
+}