mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 20:54:25 +02:00
CR fixes
This commit is contained in:
parent
6a3bc8f255
commit
5610cfeb34
3 changed files with 99 additions and 56 deletions
|
@ -1158,6 +1158,9 @@ void Menu::changePrivateKey() {
|
|||
void Menu::toggleAddressBar() {
|
||||
if (!_addressBarDialog) {
|
||||
_addressBarDialog = new AddressBarDialog();
|
||||
}
|
||||
|
||||
if (!_addressBarDialog->isVisible()) {
|
||||
_addressBarDialog->show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,79 +13,119 @@
|
|||
#include "AddressManager.h"
|
||||
#include "Application.h"
|
||||
|
||||
const QString ADDRESSBAR_GO_BUTTON_ICON = "images/address-bar-submit.svg";
|
||||
const QString ADDRESSBAR_GO_BUTTON_ACTIVE_ICON = "images/address-bar-submit-active.svg";
|
||||
|
||||
AddressBarDialog::AddressBarDialog() :
|
||||
FramelessDialog(Application::getInstance()->getWindow(), 0, FramelessDialog::POSITION_TOP){
|
||||
FramelessDialog(Application::getInstance()->getWindow(), 0, FramelessDialog::POSITION_TOP) {
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void AddressBarDialog::setupUI() {
|
||||
|
||||
const QString DIALOG_STYLESHEET = "font-family: Helvetica, Arial, sans-serif;";
|
||||
const QString ADDRESSBAR_PLACEHOLDER = "Go to: domain, @user, #location";
|
||||
const QString ADDRESSBAR_STYLESHEET = "padding: 0 10px;";
|
||||
const QString ADDRESSBAR_FONT_FAMILY = "Helvetica,Arial,sans-serif";
|
||||
const int ADDRESSBAR_FONT_SIZE = 20;
|
||||
|
||||
const int ADDRESSBAR_MIN_WIDTH = 200;
|
||||
const int ADDRESSBAR_MAX_WIDTH = 615;
|
||||
const int ADDRESSBAR_HEIGHT = 54;
|
||||
const int ADDRESSBAR_STRETCH = 60;
|
||||
|
||||
const int BUTTON_SPACER_SIZE = 10;
|
||||
const int DEFAULT_SPACER_SIZE = 20;
|
||||
const int ADDRESS_LAYOUT_RIGHT_MARGIN = 10;
|
||||
|
||||
const int GO_BUTTON_SIZE = 55;
|
||||
const int CLOSE_BUTTON_SIZE = 16;
|
||||
const QString CLOSE_BUTTON_ICON = "styles/close.svg";
|
||||
|
||||
const int DIALOG_HEIGHT = 100;
|
||||
const int DIALOG_INITIAL_WIDTH = 560;
|
||||
|
||||
setModal(true);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
setHideOnBlur(false);
|
||||
|
||||
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setSizePolicy(sizePolicy);
|
||||
setMinimumSize(QSize(560, 100));
|
||||
setStyleSheet("font-family: Helvetica, Arial, sans-serif;");
|
||||
setMinimumSize(QSize(DIALOG_INITIAL_WIDTH, DIALOG_HEIGHT));
|
||||
setStyleSheet(DIALOG_STYLESHEET);
|
||||
|
||||
verticalLayout = new QVBoxLayout(this);
|
||||
_verticalLayout = new QVBoxLayout(this);
|
||||
|
||||
addressLayout = new QHBoxLayout();
|
||||
addressLayout->setContentsMargins(0, 0, 10, 0);
|
||||
_addressLayout = new QHBoxLayout();
|
||||
_addressLayout->setContentsMargins(0, 0, ADDRESS_LAYOUT_RIGHT_MARGIN, 0);
|
||||
|
||||
leftSpacer = new QSpacerItem(20, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||
addressLayout->addItem(leftSpacer);
|
||||
_leftSpacer = new QSpacerItem(DEFAULT_SPACER_SIZE,
|
||||
DEFAULT_SPACER_SIZE,
|
||||
QSizePolicy::MinimumExpanding,
|
||||
QSizePolicy::Minimum);
|
||||
|
||||
addressLineEdit = new QLineEdit(this);
|
||||
addressLineEdit->setPlaceholderText("Go to: domain, @user, #location");
|
||||
_addressLayout->addItem(_leftSpacer);
|
||||
|
||||
_addressLineEdit = new QLineEdit(this);
|
||||
_addressLineEdit->setPlaceholderText(ADDRESSBAR_PLACEHOLDER);
|
||||
QSizePolicy sizePolicyLineEdit(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
sizePolicyLineEdit.setHorizontalStretch(60);
|
||||
addressLineEdit->setSizePolicy(sizePolicyLineEdit);
|
||||
addressLineEdit->setMinimumSize(QSize(200, 54));
|
||||
addressLineEdit->setMaximumSize(QSize(615, 54));
|
||||
QFont font("Helvetica,Arial,sans-serif", 20);
|
||||
addressLineEdit->setFont(font);
|
||||
addressLineEdit->setStyleSheet("padding: 0 10px;");
|
||||
addressLayout->addWidget(addressLineEdit);
|
||||
sizePolicyLineEdit.setHorizontalStretch(ADDRESSBAR_STRETCH);
|
||||
_addressLineEdit->setSizePolicy(sizePolicyLineEdit);
|
||||
_addressLineEdit->setMinimumSize(QSize(ADDRESSBAR_MIN_WIDTH, ADDRESSBAR_HEIGHT));
|
||||
_addressLineEdit->setMaximumSize(QSize(ADDRESSBAR_MAX_WIDTH, ADDRESSBAR_HEIGHT));
|
||||
QFont font(ADDRESSBAR_FONT_FAMILY, ADDRESSBAR_FONT_SIZE);
|
||||
_addressLineEdit->setFont(font);
|
||||
_addressLineEdit->setStyleSheet(ADDRESSBAR_STYLESHEET);
|
||||
_addressLayout->addWidget(_addressLineEdit);
|
||||
|
||||
buttonSpacer = new QSpacerItem(10, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
addressLayout->addItem(buttonSpacer);
|
||||
_buttonSpacer = new QSpacerItem(BUTTON_SPACER_SIZE, BUTTON_SPACER_SIZE, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
_addressLayout->addItem(_buttonSpacer);
|
||||
|
||||
goButton = new QPushButton(this);
|
||||
goButton->setSizePolicy(sizePolicy);
|
||||
goButton->setMinimumSize(QSize(55, 55));
|
||||
goButton->setMaximumSize(QSize(55, 55));
|
||||
goButton->setIcon(QIcon(Application::resourcesPath() + "images/address-bar-submit.svg"));
|
||||
goButton->setIconSize(QSize(55, 55));
|
||||
goButton->setDefault(true);
|
||||
goButton->setFlat(true);
|
||||
addressLayout->addWidget(goButton);
|
||||
_goButton = new QPushButton(this);
|
||||
_goButton->setSizePolicy(sizePolicy);
|
||||
_goButton->setMinimumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
|
||||
_goButton->setMaximumSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
|
||||
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON));
|
||||
_goButton->setIconSize(QSize(GO_BUTTON_SIZE, GO_BUTTON_SIZE));
|
||||
_goButton->setDefault(true);
|
||||
_goButton->setFlat(true);
|
||||
_addressLayout->addWidget(_goButton);
|
||||
|
||||
rightSpacer = new QSpacerItem(20, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||
addressLayout->addItem(rightSpacer);
|
||||
_rightSpacer = new QSpacerItem(DEFAULT_SPACER_SIZE,
|
||||
DEFAULT_SPACER_SIZE,
|
||||
QSizePolicy::MinimumExpanding,
|
||||
QSizePolicy::Minimum);
|
||||
|
||||
closeButton = new QPushButton(this);
|
||||
closeButton->setSizePolicy(sizePolicy);
|
||||
closeButton->setMinimumSize(QSize(16, 16));
|
||||
closeButton->setMaximumSize(QSize(16, 16));
|
||||
closeButton->setStyleSheet("color: #333");
|
||||
QIcon icon(Application::resourcesPath() + "styles/close.svg");
|
||||
closeButton->setIcon(icon);
|
||||
closeButton->setFlat(true);
|
||||
addressLayout->addWidget(closeButton, 0, Qt::AlignRight);
|
||||
_addressLayout->addItem(_rightSpacer);
|
||||
|
||||
verticalLayout->addLayout(addressLayout);
|
||||
_closeButton = new QPushButton(this);
|
||||
_closeButton->setSizePolicy(sizePolicy);
|
||||
_closeButton->setMinimumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE));
|
||||
_closeButton->setMaximumSize(QSize(CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE));
|
||||
QIcon icon(Application::resourcesPath() + CLOSE_BUTTON_ICON);
|
||||
_closeButton->setIcon(icon);
|
||||
_closeButton->setFlat(true);
|
||||
_addressLayout->addWidget(_closeButton, 0, Qt::AlignRight);
|
||||
|
||||
connect(goButton, &QPushButton::clicked, this, &AddressBarDialog::accept);
|
||||
connect(closeButton, &QPushButton::clicked, this, &QDialog::close);
|
||||
_verticalLayout->addLayout(_addressLayout);
|
||||
|
||||
connect(_goButton, &QPushButton::clicked, this, &AddressBarDialog::accept);
|
||||
connect(_closeButton, &QPushButton::clicked, this, &QDialog::close);
|
||||
}
|
||||
|
||||
void AddressBarDialog::showEvent(QShowEvent* event) {
|
||||
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ICON));
|
||||
_addressLineEdit->setText(QString());
|
||||
FramelessDialog::showEvent(event);
|
||||
}
|
||||
|
||||
void AddressBarDialog::accept() {
|
||||
if (!addressLineEdit->text().isEmpty()) {
|
||||
goButton->setIcon(QIcon(Application::resourcesPath() + "images/address-bar-submit-active.svg"));
|
||||
if (!_addressLineEdit->text().isEmpty()) {
|
||||
_goButton->setIcon(QIcon(Application::resourcesPath() + ADDRESSBAR_GO_BUTTON_ACTIVE_ICON));
|
||||
AddressManager& addressManager = AddressManager::getInstance();
|
||||
connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::close);
|
||||
addressManager.handleLookupString(addressLineEdit->text());
|
||||
connect(&addressManager, &AddressManager::lookupResultsFinished, this, &QDialog::hide);
|
||||
addressManager.handleLookupString(_addressLineEdit->text());
|
||||
}
|
||||
}
|
|
@ -19,7 +19,6 @@
|
|||
#include <QSpacerItem>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
class AddressBarDialog : public FramelessDialog {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -28,15 +27,16 @@ public:
|
|||
|
||||
private:
|
||||
void setupUI();
|
||||
void showEvent(QShowEvent* event);
|
||||
|
||||
QVBoxLayout *verticalLayout;
|
||||
QHBoxLayout *addressLayout;
|
||||
QSpacerItem *leftSpacer;
|
||||
QLineEdit *addressLineEdit;
|
||||
QSpacerItem *buttonSpacer;
|
||||
QPushButton *goButton;
|
||||
QSpacerItem *rightSpacer;
|
||||
QPushButton *closeButton;
|
||||
QVBoxLayout *_verticalLayout;
|
||||
QHBoxLayout *_addressLayout;
|
||||
QSpacerItem *_leftSpacer;
|
||||
QSpacerItem *_rightSpacer;
|
||||
QSpacerItem *_buttonSpacer;
|
||||
QPushButton *_goButton;
|
||||
QPushButton *_closeButton;
|
||||
QLineEdit *_addressLineEdit;
|
||||
|
||||
private slots:
|
||||
void accept();
|
||||
|
|
Loading…
Reference in a new issue