#if defined(APP_UBUNTU) || defined(APP_WIN)
"normal"
#else
- "bold"
+ "normal"
#endif
"' ")
.arg(Constants::WEBSITE, Constants::NAME)
searchLayout->setAlignment(Qt::AlignVCenter);
queryEdit = new SearchLineEdit(this);
+#ifndef APP_MAC
queryEdit->setFont(biggerFont);
- queryEdit->setMinimumWidth(queryEdit->fontInfo().pixelSize()*15);
+#endif
connect(queryEdit, SIGNAL(search(const QString&)), SLOT(watch(const QString&)));
- connect(queryEdit, SIGNAL(textChanged(const QString &)), SLOT(textChanged(const QString &)));
- connect(queryEdit, SIGNAL(suggestionAccepted(const QString&)), SLOT(watch(const QString&)));
+ connect(queryEdit, SIGNAL(textEdited(const QString &)), SLOT(textChanged(const QString &)));
+ connect(queryEdit, SIGNAL(suggestionAccepted(Suggestion*)), SLOT(suggestionAccepted(Suggestion*)));
youtubeSuggest = new YTSuggester(this);
channelSuggest = new ChannelSuggest(this);
}
void SearchView::appear() {
+ setUpdatesEnabled(false);
updateRecentKeywords();
updateRecentChannels();
queryEdit->selectAll();
queryEdit->enableSuggest();
- QTimer::singleShot(0, queryEdit, SLOT(setFocus()));
+ if (!queryEdit->hasFocus())
+ QTimer::singleShot(10, queryEdit, SLOT(setFocus()));
+ setUpdatesEnabled(true);
}
void SearchView::updateRecentKeywords() {
else {
// remove spaces from channel name
query = query.simplified();
- searchParams->setAuthor(query);
+ query = query.remove(' ');
+ searchParams->setChannelId(query);
searchParams->setSortBy(SearchParams::SortByNewest);
}
emit search(searchParams);
}
-void SearchView::watchChannel(QString channel) {
-
- channel = channel.simplified();
-
- // check for empty query
- if (channel.length() == 0) {
+void SearchView::watchChannel(const QString &channelId) {
+ if (channelId.length() == 0) {
queryEdit->setFocus(Qt::OtherFocusReason);
return;
}
- // remove spaces from channel name
- channel = channel.remove(" ");
+ QString id = channelId;
+
+ // Fix old settings
+ if (!id.startsWith("UC")) id = "UC" + id;
SearchParams *searchParams = new SearchParams();
- searchParams->setAuthor(channel);
+ searchParams->setChannelId(id);
searchParams->setSortBy(SearchParams::SortByNewest);
// go!
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
#endif
- // PainterUtils::topShadow(this);
+ PainterUtils::topShadow(this);
}
void SearchView::searchTypeChanged(int index) {
queryEdit->selectAll();
queryEdit->setFocus();
}
+
+void SearchView::suggestionAccepted(Suggestion *suggestion) {
+ if (suggestion->type == QLatin1String("channel")) {
+ watchChannel(suggestion->userData);
+ } else watch(suggestion->value);
+}