delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / phonon / tests / guitest / chapterwidget.cpp
blob5f756ed391185c5869afe7eea9285c9af834e75f
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 "chapterwidget.h"
21 #include <QtGui/QHBoxLayout>
22 #include <QtGui/QVBoxLayout>
24 ChapterWidget::ChapterWidget(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 chapter:", this);
33 m_currentChapter = new QSpinBox(this);
34 hlayout->addWidget(l);
35 hlayout->addWidget(m_currentChapter);
36 l->setBuddy(m_currentChapter);
37 m_currentChapter->setRange(1, 1);
39 hlayout = new QHBoxLayout(this);
40 topLayout->addLayout(hlayout);
41 l = new QLabel("available chapters:", this);
42 m_availableChapters = new QLabel("0", this);
43 hlayout->addWidget(l);
44 hlayout->addWidget(m_availableChapters);
47 ChapterWidget::~ChapterWidget()
51 void ChapterWidget::setInterface(MediaController *i)
53 if (m_iface) {
54 disconnect(m_iface, 0, m_currentChapter, 0);
55 disconnect(m_currentChapter, 0, m_iface, 0);
56 disconnect(m_iface, 0, m_availableChapters, 0);
58 m_iface = i;
59 if (m_iface) {
60 connect(m_iface, SIGNAL(availableChaptersChanged(int)), SLOT(availableChaptersChanged(int)));
61 connect(m_iface, SIGNAL(availableChaptersChanged(int)), m_availableChapters, SLOT(setNum(int)));
62 connect(m_iface, SIGNAL(chapterChanged(int)), m_currentChapter, SLOT(setValue(int)));
63 connect(m_currentChapter, SIGNAL(valueChanged(int)), m_iface, SLOT(setCurrentChapter(int)));
67 void ChapterWidget::availableChaptersChanged(int x) { m_currentChapter->setMaximum(x); }