Showing the changes to interface/src/ui/AddressBarDialog.cpp (1 of 7 files). Show all
Unified · Split
| @@ -0,0 +1,91 @@ | |||
| 1 | // | ||
| 2 | // AddressBarDialog.cpp | ||
| 3 | // interface/src/ui | ||
| 4 | // | ||
| 5 | // Created by Stojce Slavkovski on 9/22/14. | ||
| 6 | // Copyright 2014 High Fidelity, Inc. | ||
| 7 | // | ||
| 8 | // Distributed under the Apache License, Version 2.0. | ||
| 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | ||
| 10 | // | ||
| 11 | |||
| 12 | #include "AddressBarDialog.h" | ||
| 13 | #include "AddressManager.h" | ||
| 14 | #include "Application.h" | ||
| 15 | |||
| 16 | AddressBarDialog::AddressBarDialog() : | ||
| 17 | FramelessDialog(Application::getInstance()->getWindow(), 0, FramelessDialog::POSITION_TOP){ | ||
| 18 | setupUI(); | ||
| 19 | } | ||
| 20 | |||
| 21 | void AddressBarDialog::setupUI() { | ||
| 22 | |||
| 23 | setModal(true); | ||
| 24 | setWindowModality(Qt::WindowModal); | ||
| 25 | setHideOnBlur(false); | ||
| 26 | |||
| 27 | QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | ||
| 28 | setSizePolicy(sizePolicy); | ||
| 29 | setMinimumSize(QSize(560, 100)); | ||
| 30 | setStyleSheet("font-family: Helvetica, Arial, sans-serif;"); | ||
| 31 | |||
| 32 | verticalLayout = new QVBoxLayout(this); | ||
| 33 | |||
| 34 | addressLayout = new QHBoxLayout(); | ||
| 35 | addressLayout->setContentsMargins(0, 0, 10, 0); | ||
| 36 | |||
| 37 | leftSpacer = new QSpacerItem(20, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); | ||
| 38 | addressLayout->addItem(leftSpacer); | ||
| 39 | |||
| 40 | addressLineEdit = new QLineEdit(this); | ||
| 41 | addressLineEdit->setPlaceholderText("Go to: domain, @user, #location"); | ||
| 42 | QSizePolicy sizePolicyLineEdit(QSizePolicy::Preferred, QSizePolicy::Fixed); | ||
| 43 | sizePolicyLineEdit.setHorizontalStretch(60); | ||
| 44 | addressLineEdit->setSizePolicy(sizePolicyLineEdit); | ||
| 45 | addressLineEdit->setMinimumSize(QSize(200, 50)); | ||
| 46 | addressLineEdit->setMaximumSize(QSize(615, 50)); | ||
| 47 | QFont font("Helvetica,Arial,sans-serif", 20); | ||
| 48 | addressLineEdit->setFont(font); | ||
| 49 | addressLineEdit->setStyleSheet("padding: 0 10px;"); | ||
| 50 | addressLayout->addWidget(addressLineEdit); | ||
| 51 | |||
| 52 | buttonSpacer = new QSpacerItem(10, 20, QSizePolicy::Fixed, QSizePolicy::Minimum); | ||
| 53 | addressLayout->addItem(buttonSpacer); | ||
| 54 | |||
| 55 | goButton = new QPushButton(this); | ||
| 56 | goButton->setSizePolicy(sizePolicy); | ||
| 57 | goButton->setMinimumSize(QSize(54, 54)); | ||
| 58 | goButton->setFont(font); | ||
| 59 | goButton->setText("➡"); | ||
| 60 | goButton->setStyleSheet("background: #0e7077; color: #e7eeee; border-radius: 4px;"); | ||
| 61 | goButton->setIconSize(QSize(32, 32)); | ||
| 62 | goButton->setDefault(true); | ||
| 63 | goButton->setFlat(true); | ||
| 64 | addressLayout->addWidget(goButton); | ||
| 65 | |||
| 66 | rightSpacer = new QSpacerItem(20, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); | ||
| 67 | addressLayout->addItem(rightSpacer); | ||
| 68 | |||
| 69 | closeButton = new QPushButton(this); | ||
| 70 | closeButton->setSizePolicy(sizePolicy); | ||
| 71 | closeButton->setMinimumSize(QSize(16, 16)); | ||
| 72 | closeButton->setMaximumSize(QSize(16, 16)); | ||
| 73 | closeButton->setStyleSheet("color: #333"); | ||
| 74 | QIcon icon(Application::resourcesPath() + "styles/close.svg"); | ||
| 75 | closeButton->setIcon(icon); | ||
| 76 | closeButton->setFlat(true); | ||
| 77 | addressLayout->addWidget(closeButton, 0, Qt::AlignRight); | ||
| 78 | |||
| 79 | verticalLayout->addLayout(addressLayout); | ||
| 80 | |||
| 81 | connect(addressLineEdit, &QLineEdit::returnPressed, this, &AddressBarDialog::accept); | ||
| 82 | connect(goButton, &QPushButton::clicked, this, &AddressBarDialog::accept); | ||
| 83 | connect(closeButton, &QPushButton::clicked, this, &QDialog::close); | ||
| 84 | } | ||
| 85 | |||
| 86 | void AddressBarDialog::accept() { | ||
| 87 | // let the AddressManger figure out what to do with this | ||
| 88 | if (AddressManager::getInstance().handleLookupString(addressLineEdit->text())) { | ||
| 89 | close(); | ||
| 90 | } | ||
| 91 | } | ||