mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 23:35:40 +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();
|
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
|
QString CMenuAction::getLastPathPart() const
|
||||||
{
|
{
|
||||||
if (this->m_path.contains('/'))
|
if (this->m_path.contains('/'))
|
||||||
|
|||||||
@@ -93,6 +93,9 @@ namespace BlackGui
|
|||||||
//! Icon
|
//! Icon
|
||||||
const QIcon &getIcon() const { return m_icon; }
|
const QIcon &getIcon() const { return m_icon; }
|
||||||
|
|
||||||
|
//! Icon as pixmap
|
||||||
|
QPixmap getPixmap() const;
|
||||||
|
|
||||||
//! Has icon?
|
//! Has icon?
|
||||||
bool hasIcon() const { return !m_icon.isNull(); }
|
bool hasIcon() const { return !m_icon.isNull(); }
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QIntValidator>
|
#include <QIntValidator>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
@@ -125,6 +127,7 @@ namespace BlackGui
|
|||||||
if (this->m_menus.testFlag(CViewBaseNonTemplate::MenuOrderable) && this->hasSelection())
|
if (this->m_menus.testFlag(CViewBaseNonTemplate::MenuOrderable) && this->hasSelection())
|
||||||
{
|
{
|
||||||
const int maxOrder = this->rowCount() - 1;
|
const int maxOrder = this->rowCount() - 1;
|
||||||
|
CMenuAction menu = menuActions.addMenuViewOrder();
|
||||||
if (this->m_menuActions.isEmpty())
|
if (this->m_menuActions.isEmpty())
|
||||||
{
|
{
|
||||||
// predefine menus
|
// predefine menus
|
||||||
@@ -132,21 +135,30 @@ namespace BlackGui
|
|||||||
|
|
||||||
if (!this->m_menuActions[0])
|
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_validator = new QIntValidator(0, maxOrder, this);
|
||||||
this->m_leOrder->setValidator(this->m_validator);
|
this->m_leOrder->setValidator(this->m_validator);
|
||||||
QWidgetAction *orderAction = new QWidgetAction(this);
|
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);
|
QObject::connect(this->m_leOrder, &QLineEdit::returnPressed, this, &COrderableViewWithDbObjects<ModelClass, ContainerType, ObjectType, KeyType>::ps_orderToLineEdit);
|
||||||
this->m_menuActions[0] = orderAction;
|
this->m_menuActions[0] = orderAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_validator->setRange(0, maxOrder);
|
this->m_validator->setRange(0, maxOrder);
|
||||||
this->m_leOrder->setValidator(this->m_validator);
|
|
||||||
this->m_leOrder->setPlaceholderText("New order 0-" + QString::number(maxOrder));
|
this->m_leOrder->setPlaceholderText("New order 0-" + QString::number(maxOrder));
|
||||||
|
|
||||||
menuActions.addMenuViewOrder();
|
|
||||||
menuActions.addAction(this->m_menuActions[0], CMenuAction::pathViewOrder());
|
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[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 });
|
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:
|
private:
|
||||||
QList<QAction *> m_menuActions;
|
QList<QAction *> m_menuActions;
|
||||||
QLineEdit *m_leOrder = nullptr;
|
QLineEdit *m_leOrder = nullptr;
|
||||||
|
QFrame *m_frame = nullptr;
|
||||||
QIntValidator *m_validator = nullptr;
|
QIntValidator *m_validator = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user