QTfrontend/ui/widget/hatprompt.cpp
branchwebgl
changeset 8833 c13ebed437cb
parent 8731 924840dad6a0
child 9080 9b42757d7e71
equal deleted inserted replaced
8450:404ddce27b23 8833:c13ebed437cb
    33 #include "DataManager.h"
    33 #include "DataManager.h"
    34 #include "lineeditcursor.h"
    34 #include "lineeditcursor.h"
    35 #include "HatModel.h"
    35 #include "HatModel.h"
    36 #include "hatprompt.h"
    36 #include "hatprompt.h"
    37 
    37 
       
    38 void HatListView::moveUp()
       
    39 {
       
    40     setCurrentIndex(moveCursor(QAbstractItemView::MoveUp, Qt::NoModifier));
       
    41 }
       
    42 
       
    43 void HatListView::moveDown()
       
    44 {
       
    45     setCurrentIndex(moveCursor(QAbstractItemView::MoveDown, Qt::NoModifier));
       
    46 }
       
    47 
       
    48 void HatListView::moveLeft()
       
    49 {
       
    50     setCurrentIndex(moveCursor(QAbstractItemView::MoveLeft, Qt::NoModifier));
       
    51 }
       
    52 
       
    53 void HatListView::moveRight()
       
    54 {
       
    55     setCurrentIndex(moveCursor(QAbstractItemView::MoveRight, Qt::NoModifier));
       
    56 }
       
    57 
    38 HatPrompt::HatPrompt(int currentIndex, QWidget* parent) : QDialog(parent)
    58 HatPrompt::HatPrompt(int currentIndex, QWidget* parent) : QDialog(parent)
    39 {
    59 {
    40     setModal(true);
    60     setModal(true);
    41     setWindowFlags(Qt::Sheet);
    61     setWindowFlags(Qt::Sheet);
    42     setWindowModality(Qt::WindowModal);
    62     setWindowModality(Qt::WindowModal);
    58     dialogLayout->setColumnStretch(1, 1);
    78     dialogLayout->setColumnStretch(1, 1);
    59 
    79 
    60     QHBoxLayout * topLayout = new QHBoxLayout();
    80     QHBoxLayout * topLayout = new QHBoxLayout();
    61 
    81 
    62     // Help/prompt message at top
    82     // Help/prompt message at top
    63     QLabel * lblDesc = new QLabel(tr("Select a hat"));
    83     QLabel * lblDesc = new QLabel(tr("Search for a hat:"));
    64     lblDesc->setObjectName("lblDesc");
    84     lblDesc->setObjectName("lblDesc");
    65     lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-top-left-radius: 10px; padding: 4px 10px;}");
    85     lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-top-left-radius: 10px; padding: 4px 10px;}");
    66     lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    86     lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    67     lblDesc->setFixedHeight(24);
    87     lblDesc->setFixedHeight(24);
    68     lblDesc->setMinimumWidth(0);
    88     lblDesc->setMinimumWidth(0);
    70     // Filter text box
    90     // Filter text box
    71     QWidget * filterContainer = new QWidget();
    91     QWidget * filterContainer = new QWidget();
    72     filterContainer->setFixedHeight(24);
    92     filterContainer->setFixedHeight(24);
    73     filterContainer->setObjectName("filterContainer");
    93     filterContainer->setObjectName("filterContainer");
    74     filterContainer->setStyleSheet("#filterContainer { background: #F6CB1C; border-top-right-radius: 10px; padding: 3px; }");
    94     filterContainer->setStyleSheet("#filterContainer { background: #F6CB1C; border-top-right-radius: 10px; padding: 3px; }");
    75     filterContainer->setFixedWidth(250);
    95     filterContainer->setFixedWidth(150);
    76     txtFilter = new LineEditCursor(filterContainer);
    96     txtFilter = new LineEditCursor(filterContainer);
    77     txtFilter->setFixedWidth(250);
    97     txtFilter->setFixedWidth(150);
    78     txtFilter->setFocus();
    98     txtFilter->setFocus();
    79     txtFilter->setFixedHeight(22);
    99     txtFilter->setFixedHeight(22);
       
   100     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); }");
    80     connect(txtFilter, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged(const QString &)));
   101     connect(txtFilter, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged(const QString &)));
    81     connect(txtFilter, SIGNAL(moveUp()), this, SLOT(moveUp()));
   102     connect(txtFilter, SIGNAL(moveUp()), this, SLOT(moveUp()));
    82     connect(txtFilter, SIGNAL(moveDown()), this, SLOT(moveDown()));
   103     connect(txtFilter, SIGNAL(moveDown()), this, SLOT(moveDown()));
    83     connect(txtFilter, SIGNAL(moveLeft()), this, SLOT(moveLeft()));
   104     connect(txtFilter, SIGNAL(moveLeft()), this, SLOT(moveLeft()));
    84     connect(txtFilter, SIGNAL(moveRight()), this, SLOT(moveRight()));
   105     connect(txtFilter, SIGNAL(moveRight()), this, SLOT(moveRight()));
    85 
       
    86     // Filter label
       
    87     QLabel * lblFilter = new QLabel(tr("Filter: "), txtFilter);
       
    88     lblFilter->setStyleSheet(QString("background: none; margin-left: -%1px; margin-top: 4px;").arg(lblFilter->width() / 2 - 3));
       
    89     txtFilter->setStyleSheet(QString("border-width: 0px; background-color: rgb(13, 5, 68); border-radius: 6px; margin-top: 3px; margin-right: 3px; padding-left: %1px; padding-bottom: 2px;").arg(lblFilter->width() / 2));
       
    90 
   106 
    91     // Corner widget
   107     // Corner widget
    92     QLabel * corner = new QLabel();
   108     QLabel * corner = new QLabel();
    93     corner->setPixmap(QPixmap(QString::fromUtf8(":/res/inverse-corner-bl.png")));
   109     corner->setPixmap(QPixmap(QString::fromUtf8(":/res/inverse-corner-bl.png")));
    94     corner->setFixedSize(10, 10);
   110     corner->setFixedSize(10, 10);
   130     dialogLayout->addWidget(btnSelect, 2, 2, 1, 1, Qt::AlignRight);
   146     dialogLayout->addWidget(btnSelect, 2, 2, 1, 1, Qt::AlignRight);
   131 }
   147 }
   132 
   148 
   133 void HatPrompt::moveUp()
   149 void HatPrompt::moveUp()
   134 {
   150 {
   135     list->setCurrentIndex(list->moveCursor(QAbstractItemView::MoveUp, Qt::NoModifier));
   151     list->moveUp();
   136 }
   152 }
   137 
   153 
   138 void HatPrompt::moveDown()
   154 void HatPrompt::moveDown()
   139 {
   155 {
   140     list->setCurrentIndex(list->moveCursor(QAbstractItemView::MoveDown, Qt::NoModifier));
   156     list->moveDown();
   141 }
   157 }
   142 
   158 
   143 void HatPrompt::moveLeft()
   159 void HatPrompt::moveLeft()
   144 {
   160 {
   145     list->setCurrentIndex(list->moveCursor(QAbstractItemView::MoveLeft, Qt::NoModifier));
   161     list->moveLeft();
   146 }
   162 }
   147 
   163 
   148 void HatPrompt::moveRight()
   164 void HatPrompt::moveRight()
   149 {
   165 {
   150     list->setCurrentIndex(list->moveCursor(QAbstractItemView::MoveRight, Qt::NoModifier));
   166     list->moveRight();
   151 }
   167 }
   152 
   168 
   153 void HatPrompt::onAccepted()
   169 void HatPrompt::onAccepted()
   154 {
   170 {
   155     hatChosen(list->currentIndex());
   171     hatChosen(list->currentIndex());