QTfrontend/ui/widget/hatprompt.cpp
changeset 8488 e72f3398a28b
parent 8453 06541556df53
child 8731 924840dad6a0
equal deleted inserted replaced
8487:ec8391680132 8488:e72f3398a28b
    26 #include <QModelIndex>
    26 #include <QModelIndex>
    27 #include <QListView>
    27 #include <QListView>
    28 #include <QLineEdit>
    28 #include <QLineEdit>
    29 #include <QLabel>
    29 #include <QLabel>
    30 #include <QSortFilterProxyModel>
    30 #include <QSortFilterProxyModel>
    31 #include <QFontMetrics>
       
    32 #include <QDebug>
    31 #include <QDebug>
    33 
    32 
    34 #include "DataManager.h"
    33 #include "DataManager.h"
    35 #include "lineeditcursor.h"
    34 #include "lineeditcursor.h"
    36 #include "HatModel.h"
    35 #include "HatModel.h"
    59     dialogLayout->setColumnStretch(1, 1);
    58     dialogLayout->setColumnStretch(1, 1);
    60 
    59 
    61     QHBoxLayout * topLayout = new QHBoxLayout();
    60     QHBoxLayout * topLayout = new QHBoxLayout();
    62 
    61 
    63     // Help/prompt message at top
    62     // Help/prompt message at top
    64     QLabel * lblDesc = new QLabel(tr("Select a hat"));
    63     QLabel * lblDesc = new QLabel(tr("Search for a hat:"));
    65     lblDesc->setObjectName("lblDesc");
    64     lblDesc->setObjectName("lblDesc");
    66     lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-top-left-radius: 10px; padding: 4px 10px;}");
    65     lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-top-left-radius: 10px; padding: 4px 10px;}");
    67     lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    66     lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    68     lblDesc->setFixedHeight(24);
    67     lblDesc->setFixedHeight(24);
    69     lblDesc->setMinimumWidth(0);
    68     lblDesc->setMinimumWidth(0);
    71     // Filter text box
    70     // Filter text box
    72     QWidget * filterContainer = new QWidget();
    71     QWidget * filterContainer = new QWidget();
    73     filterContainer->setFixedHeight(24);
    72     filterContainer->setFixedHeight(24);
    74     filterContainer->setObjectName("filterContainer");
    73     filterContainer->setObjectName("filterContainer");
    75     filterContainer->setStyleSheet("#filterContainer { background: #F6CB1C; border-top-right-radius: 10px; padding: 3px; }");
    74     filterContainer->setStyleSheet("#filterContainer { background: #F6CB1C; border-top-right-radius: 10px; padding: 3px; }");
    76     filterContainer->setFixedWidth(250);
    75     filterContainer->setFixedWidth(150);
    77     txtFilter = new LineEditCursor(filterContainer);
    76     txtFilter = new LineEditCursor(filterContainer);
    78     txtFilter->setFixedWidth(250);
    77     txtFilter->setFixedWidth(150);
    79     txtFilter->setFocus();
    78     txtFilter->setFocus();
    80     txtFilter->setFixedHeight(22);
    79     txtFilter->setFixedHeight(22);
       
    80     txtFilter->setStyleSheet("LineEditCursor { border-width: 0px; border-radius: 6px; margin-top: 3px; margin-right: 3px; padding-left: 4px; padding-bottom: 2px; background-color: rgb(23, 11, 54); } LineEditCursor:hover, LineEditCursor:focus { background-color: rgb(13, 5, 68); }");
    81     connect(txtFilter, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged(const QString &)));
    81     connect(txtFilter, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged(const QString &)));
    82     connect(txtFilter, SIGNAL(moveUp()), this, SLOT(moveUp()));
    82     connect(txtFilter, SIGNAL(moveUp()), this, SLOT(moveUp()));
    83     connect(txtFilter, SIGNAL(moveDown()), this, SLOT(moveDown()));
    83     connect(txtFilter, SIGNAL(moveDown()), this, SLOT(moveDown()));
    84     connect(txtFilter, SIGNAL(moveLeft()), this, SLOT(moveLeft()));
    84     connect(txtFilter, SIGNAL(moveLeft()), this, SLOT(moveLeft()));
    85     connect(txtFilter, SIGNAL(moveRight()), this, SLOT(moveRight()));
    85     connect(txtFilter, SIGNAL(moveRight()), this, SLOT(moveRight()));
    86 
       
    87     // Filter label
       
    88     QLabel * lblFilter = new QLabel(tr("Filter: "), txtFilter);
       
    89     QFontMetrics lblMetrics(lblFilter->font());
       
    90     int lblFilterWidth = lblMetrics.width(lblFilter->text());
       
    91     lblFilter->setStyleSheet(QString("background: none; margin-left: -%1px; margin-top: 4px;").arg(lblFilterWidth + 5));
       
    92     txtFilter->setStyleSheet(QString("LineEditCursor, QLabel { border-width: 0px; border-radius: 6px; margin-top: 3px; margin-right: 3px; padding-left: %1px; padding-bottom: 2px; background-color: rgb(23, 11, 54); } LineEditCursor:hover, LineEditCursor:focus { background-color: rgb(13, 5, 68); }").arg(lblFilterWidth + 5));
       
    93 
    86 
    94     // Corner widget
    87     // Corner widget
    95     QLabel * corner = new QLabel();
    88     QLabel * corner = new QLabel();
    96     corner->setPixmap(QPixmap(QString::fromUtf8(":/res/inverse-corner-bl.png")));
    89     corner->setPixmap(QPixmap(QString::fromUtf8(":/res/inverse-corner-bl.png")));
    97     corner->setFixedSize(10, 10);
    90     corner->setFixedSize(10, 10);