#include "SearchView.h"
-#include "Constants.h"
+#include "constants.h"
+#include "fontutils.h"
namespace The {
QMap<QString, QAction*>* globalActions();
SearchView::SearchView(QWidget *parent) : QWidget(parent) {
- QFont biggerFont;
- biggerFont.setPointSize(biggerFont.pointSize()*1.5);
+ QFont biggerFont = FontUtils::big();
+ QFont smallerFont = FontUtils::smallBold();
- QFont smallerFont;
- smallerFont.setPointSize(smallerFont.pointSize()*.85);
- smallerFont.setBold(true);
+#ifdef APP_MAC
+ // speedup painting since we'll paint the whole background
+ // by ourselves anyway in paintEvent()
+ setAttribute(Qt::WA_OpaquePaintEvent);
+#endif
QBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->setMargin(0);
mainLayout->addWidget(message);
mainLayout->addStretch();
+ mainLayout->addSpacing(PADDING);
QBoxLayout *hLayout = new QHBoxLayout();
hLayout->setAlignment(Qt::AlignCenter);
hLayout->addLayout(layout);
QLabel *welcomeLabel =
- new QLabel("<h1>" +
+ new QLabel("<h1 style='font-weight:normal'>" +
tr("Welcome to <a href='%1'>%2</a>,")
- .replace("<a ", "<a style='color:palette(text)'")
+ // .replace("<a ", "<a style='color:palette(text)'")
+ .replace("<a href", "<a style='text-decoration:none; color:palette(text); font-weight:bold' href")
.arg(Constants::WEBSITE, Constants::APP_NAME)
+ "</h1>", this);
welcomeLabel->setOpenExternalLinks(true);
layout->addWidget(welcomeLabel);
- layout->addSpacing(PADDING);
+ layout->addSpacing(PADDING / 2);
QLabel *tipLabel = new QLabel(tr("Enter a keyword to start watching videos."), this);
tipLabel->setFont(biggerFont);
layout->addWidget(tipLabel);
- layout->addSpacing(10);
+ layout->addSpacing(PADDING / 2);
QHBoxLayout *searchLayout = new QHBoxLayout();
searchLayout->setAlignment(Qt::AlignVCenter);
layout->addItem(searchLayout);
- layout->addSpacing(PADDING);
+ layout->addSpacing(PADDING / 2);
QHBoxLayout *otherLayout = new QHBoxLayout();
+ otherLayout->setMargin(0);
recentKeywordsLayout = new QVBoxLayout();
recentKeywordsLayout->setSpacing(5);
recentKeywordsLayout->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
recentKeywordsLabel = new QLabel(tr("Recent keywords").toUpper(), this);
- recentKeywordsLabel->hide();
+#ifdef APP_MAC
+ QPalette palette = recentKeywordsLabel->palette();
+ palette.setColor(QPalette::WindowText, QColor(0x65, 0x71, 0x80));
+ recentKeywordsLabel->setPalette(palette);
+#else
recentKeywordsLabel->setForegroundRole(QPalette::Dark);
+#endif
+ recentKeywordsLabel->hide();
recentKeywordsLabel->setFont(smallerFont);
recentKeywordsLayout->addWidget(recentKeywordsLabel);
layout->addLayout(otherLayout);
+ mainLayout->addSpacing(PADDING);
mainLayout->addStretch();
setLayout(mainLayout);
The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty());
foreach (QString keyword, keywords) {
- QLabel *itemLabel = new QLabel("<a href=\"" + keyword
+ QString link = keyword;
+ QString display = keyword;
+ if (keyword.startsWith("http://")) {
+ int separator = keyword.indexOf("|");
+ if (separator > 0 && separator + 1 < keyword.length()) {
+ link = keyword.left(separator);
+ display = keyword.mid(separator+1);
+ }
+ }
+ QLabel *itemLabel = new QLabel("<a href=\"" + link
+ "\" style=\"color:palette(text); text-decoration:none\">"
- + keyword + "</a>", this);
+ + display + "</a>", this);
itemLabel->setMaximumWidth(queryEdit->width() + watchButton->width());
// itemLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
void SearchView::gotNewVersion(QString version) {
message->setText(
tr("A new version of %1 is available. Please <a href='%2'>update to version %3</a>")
+ .replace("<a href", "<a style='text-decoration:none; color:palette(text); font-weight:bold' href")
.arg(
Constants::APP_NAME,
QString(Constants::WEBSITE).append("#download"),
);
message->setOpenExternalLinks(true);
message->setMargin(10);
- message->setBackgroundRole(QPalette::ToolTipBase);
- message->setForegroundRole(QPalette::ToolTipText);
- message->setAutoFillBackground(true);
+ message->setAlignment(Qt::AlignCenter);
+ // message->setBackgroundRole(QPalette::ToolTipBase);
+ // message->setForegroundRole(QPalette::ToolTipText);
+ // message->setAutoFillBackground(true);
+ message->setStyleSheet("QLabel { border-bottom: 1px solid palette(mid); }");
message->show();
if (updateChecker) delete updateChecker;
}
+
+void SearchView::paintEvent(QPaintEvent * /*event*/) {
+#ifdef APP_MAC
+ QBrush brush;
+ if (window()->isActiveWindow()) {
+ brush = QBrush(QColor(0xdd, 0xe4, 0xeb));
+ } else {
+ brush = palette().window();
+ }
+ QPainter painter(this);
+ painter.fillRect(0, 0, width(), height(), brush);
+#endif
+}