]> git.sur5r.net Git - minitube/blobdiff - src/refinesearchwidget.cpp
Imported Upstream version 2.5.1
[minitube] / src / refinesearchwidget.cpp
index cba9079312d53ef4136476ecf19bd88f14c37955..d82a227c12e80b0f9d876e2a995bc7dadd315ea9 100644 (file)
@@ -19,11 +19,11 @@ along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
 $END_LICENSE */
 
 #include "refinesearchwidget.h"
-#include "fontutils.h"
 #include "searchparams.h"
 #ifdef APP_EXTRA
 #include "extra.h"
 #endif
+#include "iconutils.h"
 
 namespace The {
 QHash<QString, QAction*>* globalActions();
@@ -39,12 +39,11 @@ void RefineSearchWidget::setup() {
     if (isSetup) return;
     isSetup = true;
 
-    static const int spacing = 15;
-    setFont(FontUtils::medium());
+    const int spacing = 15;
 
     QBoxLayout *layout = new QVBoxLayout(this);
     layout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
-    layout->setMargin(spacing*2);
+    layout->setMargin(spacing);
     layout->setSpacing(spacing);
 
     QString paramName = "sortBy";
@@ -57,10 +56,9 @@ void RefineSearchWidget::setup() {
             << tr("View Count")
             << tr("Rating");
     int i = 0;
-    foreach (QString actionName, sortOptions) {
+    foreach (const QString &actionName, sortOptions) {
         QAction *action = new QAction(actionName, sortBar);
         action->setCheckable(true);
-        action->setFont(FontUtils::medium());
         action->setProperty("paramValue", i);
         sortGroup->addAction(action);
         sortBar->addAction(action);
@@ -78,10 +76,9 @@ void RefineSearchWidget::setup() {
             << tr("7 Days")
             << tr("30 Days");
     i = 0;
-    foreach (QString actionName, timeSpans) {
+    foreach (const QString &actionName, timeSpans) {
         QAction *action = new QAction(actionName, timeBar);
         action->setCheckable(true);
-        action->setFont(FontUtils::medium());
         action->setProperty("paramValue", i);
         timeGroup->addAction(action);
         timeBar->addAction(action);
@@ -104,11 +101,10 @@ void RefineSearchWidget::setup() {
             << tr("Between 4 and 20 minutes")
             << tr("Longer than 20 minutes");
     i = 0;
-    foreach (QString actionName, lengthOptions) {
+    foreach (const QString &actionName, lengthOptions) {
         QAction *action = new QAction(actionName, timeBar);
         action->setStatusTip(tips.at(i));
         action->setCheckable(true);
-        action->setFont(FontUtils::medium());
         action->setProperty("paramValue", i);
         lengthGroup->addAction(action);
         lengthBar->addAction(action);
@@ -127,11 +123,10 @@ void RefineSearchWidget::setup() {
             << ""
             << tr("720p or higher");
     i = 0;
-    foreach (QString actionName, qualityOptions) {
+    foreach (const QString &actionName, qualityOptions) {
         QAction *action = new QAction(actionName, timeBar);
         action->setStatusTip(tips.at(i));
         action->setCheckable(true);
-        action->setFont(FontUtils::medium());
         action->setProperty("paramValue", i);
         qualityGroup->addAction(action);
         qualityBar->addAction(action);
@@ -143,15 +138,16 @@ void RefineSearchWidget::setup() {
     doneButton->setDefault(true);
     doneButton->setAutoDefault(true);
     doneButton->setFocusPolicy(Qt::StrongFocus);
-    doneButton->setFont(FontUtils::medium());
+#ifndef APP_MAC
     doneButton->setProperty("custom", true);
     doneButton->setProperty("important", true);
     doneButton->setProperty("big", true);
+#endif
     connect(doneButton, SIGNAL(clicked()), SLOT(doneClicked()));
     layout->addWidget(doneButton, 0, Qt::AlignLeft);
 }
 
-void RefineSearchWidget::setupLabel(QString text, QBoxLayout *layout, QString paramName) {
+void RefineSearchWidget::setupLabel(const QString &text, QBoxLayout *layout, const QString &paramName) {
     QBoxLayout* hLayout = new QHBoxLayout();
     hLayout->setSpacing(8);
     hLayout->setMargin(0);
@@ -160,7 +156,8 @@ void RefineSearchWidget::setupLabel(QString text, QBoxLayout *layout, QString pa
     QLabel *icon = new QLabel(this);
     icon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     QString resource = paramName;
-    QPixmap pixmap = QPixmap(":/images/search-" + resource + ".png");
+    QPixmap pixmap = IconUtils::pixmap(":/images/search-" + resource + ".png");
+    /*
     QPixmap translucentPixmap(pixmap.size());
     translucentPixmap.fill(Qt::transparent);
     QPainter painter;
@@ -168,12 +165,11 @@ void RefineSearchWidget::setupLabel(QString text, QBoxLayout *layout, QString pa
     painter.setOpacity(0.5);
     painter.drawPixmap(0, 0, pixmap);
     painter.end();
-    icon->setPixmap(translucentPixmap);
+    */
+    icon->setPixmap(pixmap);
     hLayout->addWidget(icon);
 
-    QLabel *label = new QLabel(text.toUpper(), this);
-    label->setFont(FontUtils::mediumBold());
-    label->setStyleSheet("color: rgba(0, 0, 0, 128);");
+    QLabel *label = new QLabel(text, this);
     hLayout->addWidget(label);
 
     icon->setMaximumHeight(label->height());
@@ -181,32 +177,17 @@ void RefineSearchWidget::setupLabel(QString text, QBoxLayout *layout, QString pa
     layout->addLayout(hLayout);
 }
 
-QToolBar* RefineSearchWidget::setupBar(QString paramName) {
+QToolBar* RefineSearchWidget::setupBar(const QString &paramName) {
     QToolBar* bar = new QToolBar(this);
     bar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     // bar->setProperty("segmented", true);
-    bar->setFont(FontUtils::medium());
     bar->setProperty("paramName", paramName);
-    connect(bar, SIGNAL(actionTriggered(QAction*)),
-            SLOT(actionTriggered(QAction*)));
+    connect(bar, SIGNAL(actionTriggered(QAction*)), SLOT(actionTriggered(QAction*)));
     bars.insert(paramName, bar);
     layout()->addWidget(bar);
     return bar;
 }
 
-void RefineSearchWidget::paintEvent(QPaintEvent * /*event*/) {
-#if defined(APP_MAC) | defined(APP_WIN)
-    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
-}
-
 void RefineSearchWidget::actionTriggered(QAction *action) {
     QToolBar *bar = static_cast<QToolBar *>(sender());
     if (!bar) {