mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #661, added a label/icon to context order menu as proposed in the meeting
This commit is contained in:
@@ -69,6 +69,12 @@ namespace BlackGui
|
||||
return this->m_path.isEmpty() || this->m_path == pathNone();
|
||||
}
|
||||
|
||||
QPixmap CMenuAction::getPixmap() const
|
||||
{
|
||||
if (this->m_icon.isNull()) { return QPixmap(); }
|
||||
return this->m_icon.pixmap(this->m_icon.actualSize(QSize(16, 16)));
|
||||
}
|
||||
|
||||
QString CMenuAction::getLastPathPart() const
|
||||
{
|
||||
if (this->m_path.contains('/'))
|
||||
|
||||
@@ -93,6 +93,9 @@ namespace BlackGui
|
||||
//! Icon
|
||||
const QIcon &getIcon() const { return m_icon; }
|
||||
|
||||
//! Icon as pixmap
|
||||
QPixmap getPixmap() const;
|
||||
|
||||
//! Has icon?
|
||||
bool hasIcon() const { return !m_icon.isNull(); }
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <QAction>
|
||||
#include <QIntValidator>
|
||||
#include <QLineEdit>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QWidgetAction>
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -125,6 +127,7 @@ namespace BlackGui
|
||||
if (this->m_menus.testFlag(CViewBaseNonTemplate::MenuOrderable) && this->hasSelection())
|
||||
{
|
||||
const int maxOrder = this->rowCount() - 1;
|
||||
CMenuAction menu = menuActions.addMenuViewOrder();
|
||||
if (this->m_menuActions.isEmpty())
|
||||
{
|
||||
// predefine menus
|
||||
@@ -132,21 +135,30 @@ namespace BlackGui
|
||||
|
||||
if (!this->m_menuActions[0])
|
||||
{
|
||||
this->m_leOrder = new QLineEdit(this);
|
||||
this->m_frame = new QFrame(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(this->m_frame);
|
||||
layout->setMargin(2);
|
||||
this->m_frame->setLayout(layout);
|
||||
this->m_leOrder = new QLineEdit(this->m_frame);
|
||||
QLabel *icon = new QLabel(this->m_frame);
|
||||
icon->setPixmap(menu.getPixmap());
|
||||
layout->addWidget(icon);
|
||||
QLabel *label = new QLabel(this->m_frame);
|
||||
label->setText("Order:");
|
||||
layout->addWidget(label);
|
||||
layout->addWidget(this->m_leOrder);
|
||||
this->m_validator = new QIntValidator(0, maxOrder, this);
|
||||
this->m_leOrder->setValidator(this->m_validator);
|
||||
QWidgetAction *orderAction = new QWidgetAction(this);
|
||||
orderAction->setDefaultWidget(this->m_leOrder);
|
||||
orderAction->setDefaultWidget(this->m_frame);
|
||||
QObject::connect(this->m_leOrder, &QLineEdit::returnPressed, this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_orderToLineEdit);
|
||||
this->m_menuActions[0] = orderAction;
|
||||
}
|
||||
}
|
||||
|
||||
this->m_validator->setRange(0, maxOrder);
|
||||
this->m_leOrder->setValidator(this->m_validator);
|
||||
this->m_leOrder->setPlaceholderText("New order 0-" + QString::number(maxOrder));
|
||||
|
||||
menuActions.addMenuViewOrder();
|
||||
menuActions.addAction(this->m_menuActions[0], CMenuAction::pathViewOrder());
|
||||
this->m_menuActions[1] = menuActions.addAction(CIcons::arrowMediumNorth16(), "To top", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_orderToTop });
|
||||
this->m_menuActions[2] = menuActions.addAction(CIcons::arrowMediumSouth16(), "To bottom", CMenuAction::pathViewOrder(), { this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_orderToBottom });
|
||||
|
||||
@@ -105,6 +105,7 @@ namespace BlackGui
|
||||
private:
|
||||
QList<QAction *> m_menuActions;
|
||||
QLineEdit *m_leOrder = nullptr;
|
||||
QFrame *m_frame = nullptr;
|
||||
QIntValidator *m_validator = nullptr;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user