ui: Fixed layout of QtBookmarkCreator
* fixed window size and resizing * fixed layout and spacing * removed focus rects on Mac * fixed category dropdown style for Mac * reuse button handling from QtWindow * updated QtBookmarkBar buttons to new icon creation
This commit is contained in:
@@ -63,29 +63,23 @@ QtBookmarkBar::QtBookmarkBar()
|
||||
|
||||
QtBookmarkBar::~QtBookmarkBar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtBookmarkBar::refreshStyle()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css").c_str());
|
||||
|
||||
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + 16, 30);
|
||||
|
||||
m_createBookmarkButton->setFixedHeight(height);
|
||||
m_showBookmarksButton->setFixedHeight(height);
|
||||
|
||||
std::string createImage = ResourcePaths::getGuiPath() + "bookmark_view/images/edit_bookmark_icon.png";
|
||||
std::string listImage = ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_list_icon.png";
|
||||
|
||||
m_createBookmarkButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(createImage.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_createBookmarkButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/edit_bookmark_icon.png",
|
||||
"search/button"
|
||||
));
|
||||
|
||||
m_showBookmarksButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(listImage.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_showBookmarksButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_list_icon.png",
|
||||
"search/button"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -223,11 +217,9 @@ void QtBookmarkBar::doSetCreateButtonState(const BookmarkView::CreateButtonState
|
||||
{
|
||||
m_createButtonState = state;
|
||||
|
||||
std::string createImage = ResourcePaths::getGuiPath() + "bookmark_view/images/edit_bookmark_icon.png";
|
||||
|
||||
m_createBookmarkButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(createImage.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_createBookmarkButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/edit_bookmark_icon.png",
|
||||
"search/button"
|
||||
));
|
||||
|
||||
if (state == BookmarkView::CreateButtonState::CAN_CREATE)
|
||||
@@ -242,11 +234,9 @@ void QtBookmarkBar::doSetCreateButtonState(const BookmarkView::CreateButtonState
|
||||
{
|
||||
m_createBookmarkButton->setEnabled(true);
|
||||
|
||||
std::string createImage = ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_active.png";
|
||||
|
||||
m_createBookmarkButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(createImage.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_createBookmarkButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_active.png",
|
||||
"search/button"
|
||||
));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -107,7 +107,7 @@ void QtBookmarkBrowser::setupBookmarkBrowser()
|
||||
m_bodyLayout->addWidget(m_bookmarkTree);
|
||||
|
||||
m_closeButton = new QPushButton(this);
|
||||
m_closeButton->setObjectName("close_button");
|
||||
m_closeButton->setObjectName("windowButton");
|
||||
m_closeButton->setToolTip("Close Window");
|
||||
m_closeButton->setText("Close");
|
||||
m_closeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
@@ -117,7 +117,11 @@ void QtBookmarkBrowser::setupBookmarkBrowser()
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
|
||||
|
||||
setFixedSize(QSize(790, 600));
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css").c_str());
|
||||
|
||||
setStyleSheet((
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css")
|
||||
).c_str());
|
||||
|
||||
m_headerBackground->setGeometry(0, 0, 247, size().height()-20);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "QtBookmarkCreator.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "data/bookmark/BookmarkCategory.h"
|
||||
|
||||
@@ -11,12 +13,6 @@
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QString QtBookmarkCreator::m_namePlaceholder = "Name";
|
||||
QString QtBookmarkCreator::m_commentPlaceholder = "Comment";
|
||||
QString QtBookmarkCreator::m_categoryPlaceholder = "Category";
|
||||
|
||||
QtBookmarkCreator::QtBookmarkCreator(QWidget* parent, bool edit, Id id)
|
||||
: QtWindow(parent)
|
||||
@@ -32,99 +28,94 @@ QtBookmarkCreator::~QtBookmarkCreator()
|
||||
|
||||
void QtBookmarkCreator::setupBookmarkCreator()
|
||||
{
|
||||
m_displayName = new QLineEdit(this);
|
||||
m_displayName->setObjectName("display_name_edit");
|
||||
m_commentBox = new QTextEdit(this);
|
||||
m_commentBox->setObjectName("comment_box");
|
||||
m_categoryBox = new QComboBox(this);
|
||||
m_categoryBox->setObjectName("category_box");
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(30, 33, 30, 40);
|
||||
|
||||
m_title = new QLabel();
|
||||
if (m_edit == true)
|
||||
{
|
||||
m_title->setText("Edit Bookmark");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_title->setText("Create Bookmark");
|
||||
}
|
||||
m_title->setObjectName("creator_title_label");
|
||||
m_nameLabel = new QLabel();
|
||||
m_nameLabel->setText("Bookmark:");
|
||||
m_nameLabel->setObjectName("creator_name_label");
|
||||
m_commentLabel = new QLabel();
|
||||
m_commentLabel->setText("Comment:");
|
||||
m_commentLabel->setObjectName("creator_comment_label");
|
||||
m_categoryLabel = new QLabel();
|
||||
m_categoryLabel->setText("Choose or Create Bookmark:");
|
||||
m_categoryLabel->setObjectName("category_label");
|
||||
// title
|
||||
QLabel* title = new QLabel(m_edit ? "Edit Bookmark" : "Create Bookmark");
|
||||
title->setObjectName("creator_title_label");
|
||||
layout->addWidget(title);
|
||||
|
||||
m_categoryBox->addItem("");
|
||||
m_categoryBox->setEditable(true);
|
||||
m_categoryBox->setInsertPolicy(QComboBox::InsertPolicy::InsertAtTop);
|
||||
|
||||
m_categoryCount = m_categoryBox->count();
|
||||
|
||||
m_cancelButton = new QPushButton(this);
|
||||
m_cancelButton->setObjectName("creator_cancel_button");
|
||||
m_cancelButton->setText("Cancel");
|
||||
m_createButton = new QPushButton(this);
|
||||
m_createButton->setObjectName("creator_create_button");
|
||||
if (m_edit)
|
||||
{
|
||||
m_createButton->setText("Save");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createButton->setText("Create");
|
||||
layout->addSpacing(30);
|
||||
}
|
||||
|
||||
m_commentBox->setPlaceholderText(m_commentPlaceholder);
|
||||
m_displayName->setPlaceholderText(m_namePlaceholder);
|
||||
m_categoryBox->lineEdit()->setPlaceholderText(m_categoryPlaceholder);
|
||||
{
|
||||
// name
|
||||
QLabel* nameLabel = new QLabel("Bookmark:");
|
||||
nameLabel->setObjectName("creator_label");
|
||||
layout->addWidget(nameLabel);
|
||||
|
||||
m_createButton->setEnabled(false);
|
||||
m_displayName = new QLineEdit();
|
||||
m_displayName->setObjectName("creator_name_edit");
|
||||
m_displayName->setPlaceholderText("Name");
|
||||
m_displayName->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
layout->addWidget(m_displayName);
|
||||
|
||||
connect(m_displayName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
|
||||
connect(m_commentBox, SIGNAL(textChanged()), this, SLOT(onCommentChanged()));
|
||||
connect(m_categoryBox, SIGNAL(currentTextChanged(const QString&)), this, SLOT(onCategoryChanged(const QString&)));
|
||||
connect(m_categoryBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxIndexChanged(int)));
|
||||
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
|
||||
connect(m_createButton, SIGNAL(clicked()), this, SLOT(create()));
|
||||
connect(m_displayName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
|
||||
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->addWidget(m_title);
|
||||
m_layout->addWidget(m_nameLabel);
|
||||
m_layout->addWidget(m_displayName);
|
||||
m_layout->addWidget(m_commentLabel);
|
||||
m_layout->addWidget(m_commentBox);
|
||||
m_layout->addWidget(m_categoryLabel);
|
||||
m_layout->addWidget(m_categoryBox);
|
||||
layout->addSpacing(15);
|
||||
}
|
||||
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout(this);
|
||||
{
|
||||
// comment
|
||||
QLabel* commentLabel = new QLabel("Comment:");
|
||||
commentLabel->setObjectName("creator_label");
|
||||
layout->addWidget(commentLabel);
|
||||
|
||||
buttonLayout->addWidget(m_cancelButton);
|
||||
buttonLayout->setAlignment(m_cancelButton, Qt::AlignLeft);
|
||||
buttonLayout->addWidget(m_createButton);
|
||||
buttonLayout->setAlignment(m_createButton, Qt::AlignRight);
|
||||
m_commentBox = new QTextEdit();
|
||||
m_commentBox->setObjectName("creator_comment_box");
|
||||
m_commentBox->setPlaceholderText("Comment");
|
||||
layout->addWidget(m_commentBox);
|
||||
|
||||
m_layout->addLayout(buttonLayout);
|
||||
layout->addSpacing(15);
|
||||
}
|
||||
|
||||
m_headerBackground = new QWidget(m_window);
|
||||
m_headerBackground->setObjectName("creator_header_background");
|
||||
m_headerBackground->setGeometry(0, 0, 0, 0);
|
||||
m_headerBackground->show();
|
||||
m_headerBackground->lower();
|
||||
{
|
||||
// category
|
||||
QLabel* categoryLabel = new QLabel("Choose or Create Category:");
|
||||
categoryLabel->setObjectName("creator_label");
|
||||
layout->addWidget(categoryLabel);
|
||||
|
||||
m_categoryBox = new QComboBox();
|
||||
m_categoryBox->setObjectName("creator_category_box");
|
||||
m_categoryBox->addItem("");
|
||||
m_categoryBox->setEditable(true);
|
||||
m_categoryBox->lineEdit()->setPlaceholderText("Category");
|
||||
m_categoryBox->setInsertPolicy(QComboBox::InsertPolicy::InsertAtTop);
|
||||
layout->addWidget(m_categoryBox);
|
||||
|
||||
connect(m_categoryBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxIndexChanged(int)));
|
||||
|
||||
m_categoryCount = m_categoryBox->count();
|
||||
|
||||
layout->addSpacing(20);
|
||||
}
|
||||
|
||||
{
|
||||
layout->addLayout(createButtons());
|
||||
setPreviousVisible(false);
|
||||
updateNextButton(m_edit ? "Save" : "Create");
|
||||
}
|
||||
|
||||
{
|
||||
// header
|
||||
m_headerBackground = new QWidget(m_window);
|
||||
m_headerBackground->setObjectName("creator_header_background");
|
||||
m_headerBackground->setGeometry(0, 0, 0, 0);
|
||||
m_headerBackground->show();
|
||||
m_headerBackground->lower();
|
||||
}
|
||||
|
||||
setFixedSize(QSize(500, 580));
|
||||
refreshStyle();
|
||||
|
||||
m_headerBackground->setGeometry(0, 0, size().width() - 10, 70);
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::refreshStyle()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css").c_str());
|
||||
setStyleSheet((
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath() + "window/window.css") +
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css")
|
||||
).c_str());
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::setDisplayName(const std::string& name)
|
||||
@@ -170,29 +161,42 @@ void QtBookmarkCreator::setIsEdge(const bool isEdge)
|
||||
m_isEdge = isEdge;
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::onNameChanged(const QString& text)
|
||||
void QtBookmarkCreator::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
if (text.length() > 0)
|
||||
QtWindow::resizeEvent(event);
|
||||
|
||||
m_headerBackground->setGeometry(0, 0, m_window->size().width(), 60);
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::handleNext()
|
||||
{
|
||||
QString qComment = m_commentBox->toPlainText();
|
||||
QString qDisplayName = m_displayName->text();
|
||||
QString qCategory = m_categoryBox->currentText();
|
||||
|
||||
if (m_edit)
|
||||
{
|
||||
m_createButton->setEnabled(true);
|
||||
MessageEditBookmark(
|
||||
m_bookmarkId, qComment.toStdString(), qDisplayName.toStdString(), qCategory.toStdString(), m_isEdge).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createButton->setEnabled(false);
|
||||
MessageCreateBookmark(qComment.toStdString(), qDisplayName.toStdString(), qCategory.toStdString()).dispatch();
|
||||
}
|
||||
|
||||
MessageStatus("Creating Bookmark for active Token").dispatch();
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::onCommentChanged()
|
||||
void QtBookmarkCreator::handleClose()
|
||||
{
|
||||
/*if (m_commentBox->toPlainText().size() <= 0)
|
||||
{
|
||||
m_commentBox->
|
||||
}*/
|
||||
close();
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::onCategoryChanged(const QString& text)
|
||||
void QtBookmarkCreator::onNameChanged(const QString& text)
|
||||
{
|
||||
|
||||
setNextEnabled(text.length() > 0);
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::onComboBoxIndexChanged(int index)
|
||||
@@ -206,28 +210,3 @@ void QtBookmarkCreator::onComboBoxIndexChanged(int index)
|
||||
m_categoryCount = m_categoryBox->count();
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::cancel()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::create()
|
||||
{
|
||||
QString qComment = m_commentBox->toPlainText();
|
||||
QString qDisplayName = m_displayName->text();
|
||||
QString qCategory = m_categoryBox->currentText();
|
||||
|
||||
if (m_edit)
|
||||
{
|
||||
MessageEditBookmark(m_bookmarkId, qComment.toStdString(), qDisplayName.toStdString(), qCategory.toStdString(), m_isEdge).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageCreateBookmark(qComment.toStdString(), qDisplayName.toStdString(), qCategory.toStdString()).dispatch();
|
||||
}
|
||||
|
||||
MessageStatus("Creating Bookmark for active Token").dispatch();
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
#include "utility/types.h"
|
||||
@@ -22,7 +18,7 @@ class QtBookmarkCreator
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtBookmarkCreator(QWidget* parent = nullptr, bool edit = false, Id id = -1);
|
||||
QtBookmarkCreator(QWidget* parent = nullptr, bool edit = false, Id id = 0);
|
||||
~QtBookmarkCreator();
|
||||
|
||||
void setupBookmarkCreator();
|
||||
@@ -31,49 +27,36 @@ public:
|
||||
|
||||
void setDisplayName(const std::string& name);
|
||||
void setComment(const std::string& comment);
|
||||
|
||||
|
||||
void setBookmarkCategories(const std::vector<BookmarkCategory>& categories);
|
||||
void setCurrentBookmarkCategory(const BookmarkCategory& category);
|
||||
|
||||
bool getIsEdge() const;
|
||||
void setIsEdge(const bool isEdge);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void handleNext() override;
|
||||
virtual void handleClose() override;
|
||||
|
||||
private slots:
|
||||
void onNameChanged(const QString& text);
|
||||
void onCommentChanged();
|
||||
void onCategoryChanged(const QString& text);
|
||||
void onComboBoxIndexChanged(int index);
|
||||
|
||||
void cancel();
|
||||
void create();
|
||||
|
||||
private:
|
||||
bool m_edit;
|
||||
Id m_bookmarkId; // important for editing
|
||||
|
||||
QLabel* m_title;
|
||||
QLabel* m_nameLabel;
|
||||
QLabel* m_commentLabel;
|
||||
QLabel* m_categoryLabel;
|
||||
|
||||
QLineEdit* m_displayName;
|
||||
QTextEdit* m_commentBox;
|
||||
QComboBox* m_categoryBox;
|
||||
|
||||
QPushButton* m_cancelButton;
|
||||
QPushButton* m_createButton;
|
||||
|
||||
QVBoxLayout* m_layout;
|
||||
|
||||
int m_categoryCount;
|
||||
|
||||
static QString m_namePlaceholder;
|
||||
static QString m_commentPlaceholder;
|
||||
static QString m_categoryPlaceholder;
|
||||
|
||||
bool m_isEdge;
|
||||
|
||||
QWidget* m_headerBackground;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_CREATOR_H
|
||||
#endif // QT_BOOKMARK_CREATOR_H
|
||||
|
||||
@@ -124,28 +124,8 @@ void QtWindow::setup()
|
||||
scrollArea->setObjectName("scrollArea");
|
||||
}
|
||||
|
||||
{
|
||||
m_nextButton = new QPushButton("Next");
|
||||
m_nextButton->setObjectName("windowButton");
|
||||
connect(m_nextButton, SIGNAL(clicked()), this, SLOT(handleNextPress()));
|
||||
|
||||
m_previousButton = new QPushButton("Previous");
|
||||
m_previousButton->setObjectName("windowButton");
|
||||
connect(m_previousButton, SIGNAL(clicked()), this, SLOT(handlePreviousPress()));
|
||||
|
||||
m_closeButton = new QPushButton("Cancel");
|
||||
m_closeButton->setObjectName("windowButton");
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(handleClosePress()));
|
||||
|
||||
QHBoxLayout* buttons = new QHBoxLayout();
|
||||
buttons->addWidget(m_closeButton);
|
||||
buttons->addStretch();
|
||||
buttons->addWidget(m_previousButton);
|
||||
buttons->addSpacing(3);
|
||||
buttons->addWidget(m_nextButton);
|
||||
|
||||
layout->addLayout(buttons);
|
||||
}
|
||||
QHBoxLayout* buttonLayout = createButtons();
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
m_content->setLayout(layout);
|
||||
|
||||
@@ -459,6 +439,29 @@ void QtWindow::addLogo()
|
||||
resize(sizeHint());
|
||||
}
|
||||
|
||||
QHBoxLayout* QtWindow::createButtons()
|
||||
{
|
||||
m_nextButton = new QPushButton("Next");
|
||||
m_nextButton->setObjectName("windowButton");
|
||||
connect(m_nextButton, SIGNAL(clicked()), this, SLOT(handleNextPress()));
|
||||
|
||||
m_previousButton = new QPushButton("Previous");
|
||||
m_previousButton->setObjectName("windowButton");
|
||||
connect(m_previousButton, SIGNAL(clicked()), this, SLOT(handlePreviousPress()));
|
||||
|
||||
m_closeButton = new QPushButton("Cancel");
|
||||
m_closeButton->setObjectName("windowButton");
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(handleClosePress()));
|
||||
|
||||
QHBoxLayout* buttons = new QHBoxLayout();
|
||||
buttons->addWidget(m_closeButton);
|
||||
buttons->addStretch();
|
||||
buttons->addWidget(m_previousButton);
|
||||
buttons->addSpacing(3);
|
||||
buttons->addWidget(m_nextButton);
|
||||
return buttons;
|
||||
}
|
||||
|
||||
void QtWindow::handleNextPress()
|
||||
{
|
||||
handleNext();
|
||||
|
||||
@@ -77,6 +77,7 @@ protected:
|
||||
|
||||
void setupDone();
|
||||
void addLogo();
|
||||
QHBoxLayout* createButtons();
|
||||
|
||||
QWidget* m_window;
|
||||
QWidget* m_content;
|
||||
|
||||
Reference in New Issue
Block a user