$END_LICENSE */
#include "homeview.h"
-#include "segmentedcontrol.h"
-#include "searchview.h"
-#include "standardfeedsview.h"
+#include "channelaggregator.h"
#include "channelview.h"
+#include "iconutils.h"
#include "mainwindow.h"
#include "mediaview.h"
+#include "searchview.h"
+#include "segmentedcontrol.h"
+#include "standardfeedsview.h"
#include "ytstandardfeed.h"
-#include "utils.h"
-#include "channelaggregator.h"
#ifdef APP_MAC
#include "macutils.h"
#endif
-HomeView::HomeView(QWidget *parent) : QWidget(parent),
- standardFeedsView(0),
- channelsView(0) {
-
+HomeView::HomeView(QWidget *parent)
+ : View(parent), searchView(nullptr), standardFeedsView(nullptr), channelsView(nullptr) {
QBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
stackedWidget = new QStackedWidget();
layout->addWidget(stackedWidget);
-
- searchView = new SearchView();
- connect(searchView, SIGNAL(search(SearchParams*)),
- MainWindow::instance(), SLOT(showMedia(SearchParams*)));
- stackedWidget->addWidget(searchView);
}
void HomeView::setupBar() {
connect(ChannelAggregator::instance(), SIGNAL(unwatchedCountChanged(int)),
SLOT(unwatchedCountChanged(int)));
- foreach (QAction* action, bar->actions()) {
+ const auto &a = bar->actions();
+ for (QAction *action : a) {
addAction(action);
- Utils::setupAction(action);
+ MainWindow::instance()->setupAction(action);
}
}
void HomeView::showWidget(QWidget *widget) {
- QWidget* currentWidget = stackedWidget->currentWidget();
- if (currentWidget == widget) return;
- QMetaObject::invokeMethod(currentWidget, "disappear");
- currentWidget->setEnabled(false);
+ QWidget *currentWidget = stackedWidget->currentWidget();
+ if (currentWidget && currentWidget != widget) {
+ QMetaObject::invokeMethod(currentWidget, "disappear");
+ currentWidget->setEnabled(false);
+ }
stackedWidget->setCurrentWidget(widget);
widget->setEnabled(true);
- QMetaObject::invokeMethod(widget, "appear");
- widget->setFocus();
+ QMetaObject::invokeMethod(widget, "appear", Qt::QueuedConnection);
}
void HomeView::appear() {
- QMetaObject::invokeMethod(stackedWidget->currentWidget(), "appear");
+ if (stackedWidget->count() == 0)
+ showSearch();
+ else
+ QMetaObject::invokeMethod(stackedWidget->currentWidget(), "appear", Qt::QueuedConnection);
}
void HomeView::disappear() {
}
void HomeView::showSearch() {
+ if (!searchView) {
+ searchView = new SearchView(this);
+ connect(searchView, SIGNAL(search(SearchParams *)), MainWindow::instance(),
+ SLOT(showMedia(SearchParams *)));
+ stackedWidget->addWidget(searchView);
+ }
showWidget(searchView);
bar->setCheckedAction(0);
}
void HomeView::showStandardFeeds() {
if (!standardFeedsView) {
standardFeedsView = new StandardFeedsView();
- connect(standardFeedsView, SIGNAL(activated(VideoSource*)),
- MainWindow::instance(),
- SLOT(showMedia(VideoSource*)));
+ connect(standardFeedsView, SIGNAL(activated(VideoSource *)), MainWindow::instance(),
+ SLOT(showMedia(VideoSource *)));
stackedWidget->addWidget(standardFeedsView);
}
showWidget(standardFeedsView);
void HomeView::showChannels() {
if (!channelsView) {
channelsView = new ChannelView();
- connect(channelsView, SIGNAL(activated(VideoSource*)),
- MainWindow::instance(),
- SLOT(showMedia(VideoSource*)));
+ connect(channelsView, SIGNAL(activated(VideoSource *)), MainWindow::instance(),
+ SLOT(showMedia(VideoSource *)));
stackedWidget->addWidget(channelsView);
}
showWidget(channelsView);