#include "searchparams.h"
#include "ytsuggester.h"
#include "channelsuggest.h"
-#ifdef APP_MAC
+#ifdef APP_MAC_SEARCHFIELD
#include "searchlineedit_mac.h"
#else
#include "searchlineedit.h"
SearchView::SearchView(QWidget *parent) : QWidget(parent) {
- QFont biggerFont = FontUtils::big();
- QFont smallerFont = FontUtils::smallBold();
-
#if defined(APP_MAC) | defined(APP_WIN)
// speedup painting since we'll paint the whole background
// by ourselves anyway in paintEvent()
setAttribute(Qt::WA_OpaquePaintEvent);
#endif
- setAutoFillBackground(true);
-
QBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(PADDING);
mainLayout->setSpacing(0);
new QLabel("<h1 style='font-weight:100'>" +
tr("Welcome to <a href='%1'>%2</a>,")
// .replace("<a ", "<a style='color:palette(text)'")
- .replace("<a ", "<a style='text-decoration:none; color:palette(text);font-weight:"
- #if defined(APP_UBUNTU) || defined(APP_WIN)
- "normal"
- #else
- "normal"
- #endif
- "' ")
+ .replace("<a ", "<a style='text-decoration:none; color:palette(text);font-weight:normal' ")
.arg(Constants::WEBSITE, Constants::NAME)
+ "</h1>", this);
welcomeLabel->setOpenExternalLinks(true);
-#ifdef APP_WIN
+ welcomeLabel->setProperty("heading", true);
+#ifdef APP_MAC
+ QFont f = welcomeLabel->font();
+ f.setFamily("Helvetica Neue");
+ f.setStyleName("Thin");
+ welcomeLabel->setFont(f);
+#elif APP_WIN
QFont f = welcomeLabel->font();
- f.setHintingPreference(QFont::PreferNoHinting);
f.setFamily("Segoe UI Light");
welcomeLabel->setFont(f);
#endif
//: "Enter", as in "type". The whole phrase says: "Enter a keyword to start watching videos"
QLabel *tipLabel = new QLabel(tr("Enter"), this);
+#ifndef APP_MAC
+ const QFont &biggerFont = FontUtils::big();
tipLabel->setFont(biggerFont);
+#endif
tipLayout->addWidget(tipLabel);
typeCombo = new QComboBox(this);
typeCombo->addItem(tr("a keyword"));
typeCombo->addItem(tr("a channel"));
+#ifndef APP_MAC
typeCombo->setFont(biggerFont);
+#endif
connect(typeCombo, SIGNAL(currentIndexChanged(int)), SLOT(searchTypeChanged(int)));
tipLayout->addWidget(typeCombo);
tipLabel = new QLabel(tr("to start watching videos."), this);
+#ifndef APP_MAC
tipLabel->setFont(biggerFont);
+#endif
tipLayout->addWidget(tipLabel);
layout->addLayout(tipLayout);
searchLayout->setAlignment(Qt::AlignVCenter);
queryEdit = new SearchLineEdit(this);
-#ifndef APP_MAC
+#ifndef APP_MAC_SEARCHFIELD
queryEdit->setFont(biggerFont);
#endif
connect(queryEdit, SIGNAL(search(const QString&)), SLOT(watch(const QString&)));
recentKeywordsLayout = new QVBoxLayout();
recentKeywordsLayout->setSpacing(5);
recentKeywordsLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
- recentKeywordsLabel = new QLabel(tr("Recent keywords").toUpper(), this);
+ recentKeywordsLabel = new QLabel(tr("Recent keywords"), this);
recentKeywordsLabel->setProperty("recentHeader", true);
recentKeywordsLabel->setForegroundRole(QPalette::Dark);
recentKeywordsLabel->hide();
- recentKeywordsLabel->setFont(smallerFont);
recentKeywordsLayout->addWidget(recentKeywordsLabel);
otherLayout->addLayout(recentKeywordsLayout);
recentChannelsLayout = new QVBoxLayout();
recentChannelsLayout->setSpacing(5);
recentChannelsLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
- recentChannelsLabel = new QLabel(tr("Recent channels").toUpper(), this);
+ recentChannelsLabel = new QLabel(tr("Recent channels"), this);
recentChannelsLabel->setProperty("recentHeader", true);
recentChannelsLabel->setForegroundRole(QPalette::Dark);
recentChannelsLabel->hide();
- recentChannelsLabel->setFont(smallerFont);
recentChannelsLayout->addWidget(recentChannelsLabel);
otherLayout->addLayout(recentChannelsLayout);
}
void SearchView::appear() {
- setUpdatesEnabled(false);
+ MainWindow::instance()->showActionInStatusBar(The::globalActions()->value("definition"), true);
+
updateRecentKeywords();
updateRecentChannels();
queryEdit->selectAll();
queryEdit->enableSuggest();
- if (!queryEdit->hasFocus())
- QTimer::singleShot(10, queryEdit, SLOT(setFocus()));
- setUpdatesEnabled(true);
+
+ if (!queryEdit->hasFocus()) queryEdit->setFocus();
+}
+
+void SearchView::disappear() {
+ MainWindow::instance()->showActionInStatusBar(The::globalActions()->value("definition"), false);
}
void SearchView::updateRecentKeywords() {
+ // load
+ QSettings settings;
+ QStringList keywords = settings.value(recentKeywordsKey).toStringList();
+ if (keywords == recentKeywords) return;
+ recentKeywords = keywords;
// cleanup
QLayoutItem *item;
delete item;
}
- // load
- QSettings settings;
- QStringList keywords = settings.value(recentKeywordsKey).toStringList();
recentKeywordsLabel->setVisible(!keywords.isEmpty());
The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty());
}
void SearchView::updateRecentChannels() {
+ // load
+ QSettings settings;
+ QStringList keywords = settings.value(recentChannelsKey).toStringList();
+ if (keywords == recentChannels) return;
+ recentChannels = keywords;
// cleanup
QLayoutItem *item;
delete item;
}
- // load
- QSettings settings;
- QStringList keywords = settings.value(recentChannelsKey).toStringList();
recentChannelsLabel->setVisible(!keywords.isEmpty());
// TODO The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty());
#if defined(APP_MAC) | defined(APP_WIN)
QBrush brush;
if (window()->isActiveWindow()) {
- brush = QBrush(QColor(0xdd, 0xe4, 0xeb));
+ brush = Qt::white;
} else {
brush = palette().window();
}
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
#endif
- PainterUtils::topShadow(this);
}
void SearchView::searchTypeChanged(int index) {