New custom TextInput widget (derived from QLineEdit) to use for text input fields. It currently just removes the default (theme-based) icons from context menu actions
This commit is contained in:
@@ -140,6 +140,7 @@ add_executable(Bloom
|
|||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/LabeledSeparator.cpp
|
||||||
|
src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "Widgets/PanelWidget.hpp"
|
#include "Widgets/PanelWidget.hpp"
|
||||||
#include "Widgets/RotatableLabel.hpp"
|
#include "Widgets/RotatableLabel.hpp"
|
||||||
#include "Widgets/LabeledSeparator.hpp"
|
#include "Widgets/LabeledSeparator.hpp"
|
||||||
|
#include "Widgets/TextInput.hpp"
|
||||||
#include "Widgets/SvgWidget.hpp"
|
#include "Widgets/SvgWidget.hpp"
|
||||||
#include "Widgets/SvgToolButton.hpp"
|
#include "Widgets/SvgToolButton.hpp"
|
||||||
#include "Widgets/ExpandingHeightScrollAreaWidget.hpp"
|
#include "Widgets/ExpandingHeightScrollAreaWidget.hpp"
|
||||||
@@ -43,6 +44,15 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
|||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"TextInput",
|
||||||
|
[this] (QWidget* parent, const QString& name) {
|
||||||
|
auto* widget = new TextInput(parent);
|
||||||
|
widget->setObjectName(name);
|
||||||
|
widget->setStyleSheet(parent->styleSheet());
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ExpandingHeightScrollAreaWidget",
|
"ExpandingHeightScrollAreaWidget",
|
||||||
[this] (QWidget* parent, const QString& name) {
|
[this] (QWidget* parent, const QString& name) {
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ TargetRegisterInspectorWindow::TargetRegisterInspectorWindow(
|
|||||||
);
|
);
|
||||||
|
|
||||||
this->registerValueTextInput->setFixedWidth(BitsetWidget::WIDTH * 2);
|
this->registerValueTextInput->setFixedWidth(BitsetWidget::WIDTH * 2);
|
||||||
this->registerValueTextInput->setContextMenuPolicy(Qt::NoContextMenu);
|
|
||||||
|
|
||||||
if (!this->registerDescriptor.writable) {
|
if (!this->registerDescriptor.writable) {
|
||||||
this->registerValueTextInput->setDisabled(true);
|
this->registerValueTextInput->setDisabled(true);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
<widget class="QLineEdit" name="register-details-name-input">
|
<widget class="TextInput" name="register-details-name-input">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
<widget class="QLineEdit" name="register-details-size-input">
|
<widget class="TextInput" name="register-details-size-input">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
<widget class="QLineEdit" name="register-details-start-address-input">
|
<widget class="TextInput" name="register-details-start-address-input">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@@ -157,7 +157,7 @@ Insight.</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
<widget class="QLineEdit" name="register-value-text-input"/>
|
<widget class="TextInput" name="register-value-text-input"/>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
<widget class="QWidget" name="register-value-bitset-widget-container">
|
<widget class="QWidget" name="register-value-bitset-widget-container">
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignLeft">
|
<item alignment="Qt::AlignLeft">
|
||||||
<widget class="QLineEdit" name="search-input">
|
<widget class="TextInput" name="search-input">
|
||||||
<property name="minimumHeight">
|
<property name="minimumHeight">
|
||||||
<number>25</number>
|
<number>25</number>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include "TextInput.hpp"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
using namespace Bloom::Widgets;
|
||||||
|
|
||||||
|
TextInput::TextInput(QWidget* parent): QLineEdit(parent) {}
|
||||||
|
|
||||||
|
void TextInput::contextMenuEvent(QContextMenuEvent* event) {
|
||||||
|
if (QMenu *menu = createStandardContextMenu()) {
|
||||||
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
// Remove default icons
|
||||||
|
for (auto& action : menu->actions()) {
|
||||||
|
action->setIcon(QIcon());
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->popup(event->globalPos());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
|
||||||
|
namespace Bloom::Widgets
|
||||||
|
{
|
||||||
|
class TextInput: public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit TextInput(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void contextMenuEvent(QContextMenuEvent* event) override;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user