ui: basic search view
- Added a basic SearchView (+ controller and qt implementation) - SearchView can set the active element of other views by dispatching a message. - SearchView adjusts its text when the active element is changed by other views. - Added wrappers for Button and EditBox that allow the usage of simple callback functions.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#include "qt/element/QtButton.h"
|
||||
|
||||
QtButton::QtButton(QWidget *parent)
|
||||
: QPushButton(parent)
|
||||
, m_onClick(nullptr)
|
||||
{
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(slotOnClick()));
|
||||
}
|
||||
|
||||
QtButton::~QtButton()
|
||||
{
|
||||
}
|
||||
|
||||
void QtButton::setCallbackOnClick(std::function<void(void)> callback)
|
||||
{
|
||||
m_onClick = callback;
|
||||
}
|
||||
|
||||
void QtButton::slotOnClick()
|
||||
{
|
||||
if (m_onClick)
|
||||
m_onClick();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef QT_BUTTON_H
|
||||
#define QT_BUTTON_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
class QtButton: public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtButton(QWidget *parent);
|
||||
~QtButton();
|
||||
|
||||
void setCallbackOnClick(std::function<void(void)> callback);
|
||||
|
||||
private slots:
|
||||
void slotOnClick();
|
||||
|
||||
private:
|
||||
std::function<void(void)> m_onClick;
|
||||
};
|
||||
|
||||
#endif // QT_BUTTON_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "qt/element/QtEditBox.h"
|
||||
|
||||
QtEditBox::QtEditBox(QWidget *parent)
|
||||
: QLineEdit(parent)
|
||||
, m_onReturnPressed(nullptr)
|
||||
{
|
||||
connect(this, SIGNAL(returnPressed()), this, SLOT(slotOnReturnPressed()));
|
||||
}
|
||||
|
||||
QtEditBox::~QtEditBox()
|
||||
{
|
||||
}
|
||||
|
||||
void QtEditBox::setCallbackOnReturnPressed(std::function<void(void)> callback)
|
||||
{
|
||||
m_onReturnPressed = callback;
|
||||
}
|
||||
|
||||
void QtEditBox::slotOnReturnPressed()
|
||||
{
|
||||
if (m_onReturnPressed)
|
||||
m_onReturnPressed();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef QT_EDIT_BOX_H
|
||||
#define QT_EDIT_BOX_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class QtEditBox: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtEditBox(QWidget *parent);
|
||||
~QtEditBox();
|
||||
|
||||
void setCallbackOnReturnPressed(std::function<void(void)> callback);
|
||||
|
||||
private slots:
|
||||
void slotOnReturnPressed();
|
||||
|
||||
private:
|
||||
std::function<void(void)> m_onReturnPressed;
|
||||
};
|
||||
|
||||
#endif // QT_EDIT_BOX_H
|
||||
Reference in New Issue
Block a user