3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Minitube. If not, see <http://www.gnu.org/licenses/>.
22 #include "segmentedcontrol.h"
23 #include "searchview.h"
24 #include "standardfeedsview.h"
25 #include "channelview.h"
26 #include "mainwindow.h"
27 #include "mediaview.h"
28 #include "ytstandardfeed.h"
30 #include "channelaggregator.h"
35 HomeView::HomeView(QWidget *parent) : QWidget(parent),
39 QBoxLayout *layout = new QVBoxLayout(this);
41 layout->setSpacing(0);
44 layout->addWidget(bar);
46 stackedWidget = new QStackedWidget();
47 layout->addWidget(stackedWidget);
49 searchView = new SearchView();
50 connect(searchView, SIGNAL(search(SearchParams*)),
51 MainWindow::instance(), SLOT(showMedia(SearchParams*)));
52 stackedWidget->addWidget(searchView);
55 void HomeView::setupBar() {
56 bar = new SegmentedControl();
58 QAction *action = new QAction(tr("Search"), this);
59 action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1));
60 action->setStatusTip(tr("Find videos and channels by keyword"));
61 connect(action, SIGNAL(triggered()), SLOT(showSearch()));
62 bar->addAction(action);
63 bar->setCheckedAction(action);
65 action = new QAction(tr("Browse"), this);
66 action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_2));
67 action->setStatusTip(tr("Browse videos by category"));
68 connect(action, SIGNAL(triggered()), SLOT(showStandardFeeds()));
69 bar->addAction(action);
71 subscriptionsAction = new QAction(tr("Subscriptions"), this);
72 subscriptionsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_3));
73 subscriptionsAction->setStatusTip(tr("Channel subscriptions"));
74 connect(subscriptionsAction, SIGNAL(triggered()), SLOT(showChannels()));
75 bar->addAction(subscriptionsAction);
76 connect(ChannelAggregator::instance(), SIGNAL(unwatchedCountChanged(int)),
77 SLOT(unwatchedCountChanged(int)));
79 foreach (QAction* action, bar->actions()) {
81 Utils::setupAction(action);
85 void HomeView::showWidget(QWidget *widget) {
86 QWidget* currentWidget = stackedWidget->currentWidget();
87 if (currentWidget == widget) return;
88 QMetaObject::invokeMethod(currentWidget, "disappear");
89 currentWidget->setEnabled(false);
90 stackedWidget->setCurrentWidget(widget);
91 widget->setEnabled(true);
92 QMetaObject::invokeMethod(widget, "appear");
96 void HomeView::appear() {
97 QMetaObject::invokeMethod(stackedWidget->currentWidget(), "appear");
100 void HomeView::disappear() {
101 QMetaObject::invokeMethod(stackedWidget->currentWidget(), "disappear");
104 void HomeView::showSearch() {
105 showWidget(searchView);
106 bar->setCheckedAction(0);
109 void HomeView::showStandardFeeds() {
110 if (!standardFeedsView) {
111 standardFeedsView = new StandardFeedsView();
112 connect(standardFeedsView, SIGNAL(activated(VideoSource*)),
113 MainWindow::instance(),
114 SLOT(showMedia(VideoSource*)));
115 stackedWidget->addWidget(standardFeedsView);
117 showWidget(standardFeedsView);
118 bar->setCheckedAction(1);
121 void HomeView::showChannels() {
123 channelsView = new ChannelView();
124 connect(channelsView, SIGNAL(activated(VideoSource*)),
125 MainWindow::instance(),
126 SLOT(showMedia(VideoSource*)));
127 stackedWidget->addWidget(channelsView);
129 showWidget(channelsView);
130 bar->setCheckedAction(2);
133 void HomeView::unwatchedCountChanged(int count) {
137 s = QString::number(count);
140 subscriptionsAction->setProperty("notifyCount", v);