ui: Added close button to tabbed view
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
@@ -42,16 +43,16 @@ QtScreenSearchBox::QtScreenSearchBox(ControllerProxy<ScreenSearchController>* co
|
||||
|
||||
// search field
|
||||
{
|
||||
m_searchButton = new QPushButton();
|
||||
m_searchButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_searchButton = new QtSelfRefreshIconButton(
|
||||
"", ResourcePaths::getGuiPath().concatenate(L"search_view/images/search.png"), "screen_search/button");
|
||||
m_searchButton->setObjectName("search_button");
|
||||
m_searchButton->setIconSize(QSize(12, 12));
|
||||
layout->addWidget(m_searchButton);
|
||||
|
||||
connect(m_searchButton, &QPushButton::clicked, this, &QtScreenSearchBox::setFocus);
|
||||
|
||||
m_searchBox = new QLineEdit(this);
|
||||
m_searchBox->setObjectName("search_box");
|
||||
m_searchBox->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_searchBox->setAttribute(Qt::WA_MacShowFocusRect, 0); // remove blue focus box on Mac
|
||||
layout->addWidget(m_searchBox);
|
||||
|
||||
@@ -75,15 +76,17 @@ QtScreenSearchBox::QtScreenSearchBox(ControllerProxy<ScreenSearchController>* co
|
||||
|
||||
// buttons
|
||||
{
|
||||
m_prevButton = new QPushButton();
|
||||
m_nextButton = new QPushButton();
|
||||
|
||||
m_prevButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_nextButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_prevButton = new QtSelfRefreshIconButton(
|
||||
"", ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_left.png"), "screen_search/button");
|
||||
m_nextButton = new QtSelfRefreshIconButton(
|
||||
"", ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_right.png"), "screen_search/button");
|
||||
|
||||
m_prevButton->setObjectName("prev_button");
|
||||
m_nextButton->setObjectName("next_button");
|
||||
|
||||
m_prevButton->setIconSize(QSize(12, 12));
|
||||
m_nextButton->setIconSize(QSize(12, 12));
|
||||
|
||||
layout->addWidget(m_prevButton);
|
||||
layout->addWidget(m_nextButton);
|
||||
|
||||
@@ -100,9 +103,10 @@ QtScreenSearchBox::QtScreenSearchBox(ControllerProxy<ScreenSearchController>* co
|
||||
|
||||
// buttons
|
||||
{
|
||||
m_closeButton = new QPushButton();
|
||||
m_closeButton = new QtSelfRefreshIconButton(
|
||||
"", ResourcePaths::getGuiPath().concatenate(L"screen_search_view/images/close.png"), "screen_search/button");
|
||||
m_closeButton->setObjectName("close_button");
|
||||
m_closeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_closeButton->setIconSize(QSize(15, 15));
|
||||
layout->addWidget(m_closeButton);
|
||||
|
||||
connect(m_closeButton, &QPushButton::clicked, [this](){ emit closePressed(); });
|
||||
@@ -112,7 +116,6 @@ QtScreenSearchBox::QtScreenSearchBox(ControllerProxy<ScreenSearchController>* co
|
||||
m_timer->setSingleShot(true);
|
||||
connect(m_timer, &QTimer::timeout, this, &QtScreenSearchBox::findMatches);
|
||||
|
||||
refreshStyle();
|
||||
setMatchCount(0);
|
||||
}
|
||||
|
||||
@@ -120,34 +123,6 @@ QtScreenSearchBox::~QtScreenSearchBox()
|
||||
{
|
||||
}
|
||||
|
||||
void QtScreenSearchBox::refreshStyle()
|
||||
{
|
||||
m_searchButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath().concatenate(L"search_view/images/search.png"),
|
||||
"screen_search/button"
|
||||
));
|
||||
|
||||
m_prevButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_left.png"),
|
||||
"screen_search/button"
|
||||
));
|
||||
|
||||
m_nextButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_right.png"),
|
||||
"screen_search/button"
|
||||
));
|
||||
|
||||
m_closeButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath().concatenate(L"screen_search_view/images/close.png"),
|
||||
"screen_search/button"
|
||||
));
|
||||
|
||||
m_searchButton->setIconSize(QSize(12, 12));
|
||||
m_prevButton->setIconSize(QSize(12, 12));
|
||||
m_nextButton->setIconSize(QSize(12, 12));
|
||||
m_closeButton->setIconSize(QSize(15, 15));
|
||||
}
|
||||
|
||||
void QtScreenSearchBox::setMatchCount(size_t matchCount)
|
||||
{
|
||||
m_matchCount = matchCount;
|
||||
|
||||
@@ -10,6 +10,7 @@ class QCheckBox;
|
||||
class QHBoxLayout;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class QtSelfRefreshIconButton;
|
||||
class QTimer;
|
||||
|
||||
|
||||
@@ -38,8 +39,6 @@ public:
|
||||
QtScreenSearchBox(ControllerProxy<ScreenSearchController>* controllerProxy, QWidget* parent = nullptr);
|
||||
virtual ~QtScreenSearchBox();
|
||||
|
||||
void refreshStyle();
|
||||
|
||||
void setMatchCount(size_t matchCount);
|
||||
void setMatchIndex(size_t matchIndex);
|
||||
|
||||
@@ -69,10 +68,10 @@ private:
|
||||
QLineEdit* m_searchBox;
|
||||
QPushButton* m_matchLabel;
|
||||
|
||||
QPushButton* m_searchButton;
|
||||
QPushButton* m_prevButton;
|
||||
QPushButton* m_nextButton;
|
||||
QPushButton* m_closeButton;
|
||||
QtSelfRefreshIconButton* m_searchButton;
|
||||
QtSelfRefreshIconButton* m_prevButton;
|
||||
QtSelfRefreshIconButton* m_nextButton;
|
||||
QtSelfRefreshIconButton* m_closeButton;
|
||||
|
||||
QHBoxLayout* m_checkboxLayout;
|
||||
std::vector<QCheckBox*> m_checkBoxes;
|
||||
|
||||
@@ -51,8 +51,6 @@ void QtScreenSearchView::refreshView()
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
m_widget->refreshStyle();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "qt/view/QtTabbedView.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QFrame>
|
||||
#include <QTabBar>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
@@ -28,13 +30,22 @@ void QtTabbedView::initView()
|
||||
{
|
||||
QWidget* widget = QtViewWidgetWrapper::getWidgetOfView(this);
|
||||
|
||||
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
widget->setLayout(layout);
|
||||
|
||||
m_widget = new QTabWidget(widget);
|
||||
layout->addWidget(m_widget);
|
||||
|
||||
m_closeButton = new QtSelfRefreshIconButton("",
|
||||
ResourcePaths::getGuiPath().concatenate(L"screen_search_view/images/close.png"), "screen_search/button", widget);
|
||||
m_closeButton->setIconSize(QSize(15, 15));
|
||||
m_closeButton->setStyleSheet("background: transparent; border: none;");
|
||||
|
||||
widget->connect(m_closeButton, &QPushButton::clicked, [this](){ hideView(this); });
|
||||
m_widget->tabBar()->installEventFilter(this);
|
||||
widget->installEventFilter(this);
|
||||
}
|
||||
|
||||
void QtTabbedView::refreshView()
|
||||
@@ -70,3 +81,13 @@ void QtTabbedView::setStyleSheet()
|
||||
utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(L"tabbed_view/tabbed_view.css")).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
bool QtTabbedView::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Resize)
|
||||
{
|
||||
m_closeButton->setGeometry(m_widget->width() - 23, (m_widget->tabBar()->height() - 15) / 2 + 1, 15, 15);
|
||||
m_closeButton->show();
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
#ifndef QT_TABBED_VIEW
|
||||
#define QT_TABBED_VIEW
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "component/view/TabbedView.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
class QTabWidget;
|
||||
class QtSelfRefreshIconButton;
|
||||
|
||||
class QtTabbedView
|
||||
: public TabbedView
|
||||
: public QObject
|
||||
, public TabbedView
|
||||
{
|
||||
public:
|
||||
QtTabbedView(ViewLayout* viewLayout, const std::string& name);
|
||||
@@ -24,9 +28,11 @@ public:
|
||||
|
||||
private:
|
||||
void setStyleSheet();
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
QTabWidget* m_widget;
|
||||
QtSelfRefreshIconButton* m_closeButton;
|
||||
};
|
||||
|
||||
#endif // QT_TABBED_VIEW
|
||||
|
||||
Reference in New Issue
Block a user