1 /* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
20 #include "titlewidget.h"
21 #include <QtGui/QHBoxLayout>
22 #include <QtGui/QVBoxLayout>
24 TitleWidget::TitleWidget(QWidget
*parent
)
25 : QWidget(parent
), m_iface(0)
27 setAttribute(Qt::WA_QuitOnClose
, false);
28 QVBoxLayout
*topLayout
= new QVBoxLayout(this);
30 QHBoxLayout
*hlayout
= new QHBoxLayout(this);
31 topLayout
->addLayout(hlayout
);
32 QLabel
*l
= new QLabel("current title:", this);
33 m_currentTitle
= new QSpinBox(this);
34 hlayout
->addWidget(l
);
35 hlayout
->addWidget(m_currentTitle
);
36 l
->setBuddy(m_currentTitle
);
37 m_currentTitle
->setRange(1, 1);
39 hlayout
= new QHBoxLayout(this);
40 topLayout
->addLayout(hlayout
);
41 l
= new QLabel("available titles:", this);
42 m_availableTitles
= new QLabel("0", this);
43 hlayout
->addWidget(l
);
44 hlayout
->addWidget(m_availableTitles
);
46 hlayout
= new QHBoxLayout(this);
47 topLayout
->addLayout(hlayout
);
48 l
= new QLabel("autoplay:", this);
49 m_autoplay
= new QToolButton(this);
50 m_autoplay
->setCheckable(true);
51 hlayout
->addWidget(l
);
52 hlayout
->addWidget(m_autoplay
);
55 TitleWidget::~TitleWidget()
59 void TitleWidget::setInterface(MediaController
*i
)
62 disconnect(m_iface
, 0, m_currentTitle
, 0);
63 disconnect(m_currentTitle
, 0, m_iface
, 0);
64 disconnect(m_iface
, 0, m_availableTitles
, 0);
65 disconnect(m_autoplay
, 0, m_iface
, 0);
69 const int a
= m_iface
->availableTitles();
70 m_currentTitle
->setMaximum(a
);
71 m_availableTitles
->setNum(a
);
72 m_currentTitle
->setValue(m_iface
->currentTitle());
73 m_autoplay
->setChecked(m_iface
->autoplayTitles());
75 connect(m_iface
, SIGNAL(availableTitlesChanged(int)), SLOT(availableTitlesChanged(int)));
76 connect(m_iface
, SIGNAL(availableTitlesChanged(int)), m_availableTitles
, SLOT(setNum(int)));
77 connect(m_iface
, SIGNAL(titleChanged(int)), m_currentTitle
, SLOT(setValue(int)));
78 connect(m_currentTitle
, SIGNAL(valueChanged(int)), m_iface
, SLOT(setCurrentTitle(int)));
79 connect(m_autoplay
, SIGNAL(toggled(bool)), m_iface
, SLOT(setAutoplayTitles(bool)));
83 void TitleWidget::availableTitlesChanged(int x
) { m_currentTitle
->setMaximum(x
); }