mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
The new text input class of trigger pannel for windows
This commit is contained in:
parent
446badc69c
commit
e8eee13db6
@ -160,15 +160,20 @@ void PopupLineEditInput::Popup(QWidget *editline)
|
|||||||
PopupLineEdit::PopupLineEdit(QWidget *parent)
|
PopupLineEdit::PopupLineEdit(QWidget *parent)
|
||||||
:PopupLineEdit("", parent)
|
:PopupLineEdit("", parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PopupLineEdit::PopupLineEdit(const QString &text, QWidget *parent)
|
PopupLineEdit::PopupLineEdit(const QString &text, QWidget *parent)
|
||||||
:QLineEdit(text, parent)
|
:QLineEdit(text, parent)
|
||||||
{
|
{
|
||||||
|
_is_number_mode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PopupLineEdit::PopupLineEdit(bool isNumberMode, QWidget *parent)
|
||||||
|
:QLineEdit(parent)
|
||||||
|
{
|
||||||
|
_is_number_mode = isNumberMode;
|
||||||
|
}
|
||||||
|
|
||||||
void PopupLineEdit::mousePressEvent(QMouseEvent *event)
|
void PopupLineEdit::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
showPupopInput();
|
showPupopInput();
|
||||||
@ -194,6 +199,11 @@ void PopupLineEdit::showPupopInput()
|
|||||||
input->GetInput()->setText(this->text());
|
input->GetInput()->setText(this->text());
|
||||||
input->setFont(this->font());
|
input->setFont(this->font());
|
||||||
|
|
||||||
|
if (_is_number_mode){
|
||||||
|
QIntValidator *validator = new QIntValidator();
|
||||||
|
input->GetInput()->setValidator(validator);
|
||||||
|
}
|
||||||
|
|
||||||
_old_text = this->text();
|
_old_text = this->text();
|
||||||
|
|
||||||
connect(input, SIGNAL(sig_inputEnd(QString)), this, SLOT(onPopupInputEditEnd(QString)));
|
connect(input, SIGNAL(sig_inputEnd(QString)), this, SLOT(onPopupInputEditEnd(QString)));
|
||||||
@ -211,136 +221,19 @@ void PopupLineEdit::onPopupInputEditEnd(QString text)
|
|||||||
editingFinished();
|
editingFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------PopupSpinBoxInput
|
|
||||||
PopupSpinBoxInput::PopupSpinBoxInput(QWidget *parent)
|
|
||||||
:QDialog(parent)
|
|
||||||
{
|
|
||||||
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
|
||||||
|
|
||||||
_line = NULL;
|
int PopupLineEdit::value()
|
||||||
|
|
||||||
QHBoxLayout *lay = new QHBoxLayout();
|
|
||||||
lay->setContentsMargins(0,0,0,0);
|
|
||||||
_textInput = new QSpinBox(this);
|
|
||||||
lay->addWidget(_textInput);
|
|
||||||
this->setLayout(lay);
|
|
||||||
|
|
||||||
QFont font = this->font();
|
|
||||||
font.setPointSizeF(AppConfig::Instance().appOptions.fontSize);
|
|
||||||
_textInput->setFont(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopupSpinBoxInput::changeEvent(QEvent *event)
|
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::ActivationChange){
|
assert(_is_number_mode);
|
||||||
if (this->isActiveWindow() == false){
|
|
||||||
InputRelease();
|
QString text = this->text();
|
||||||
return;
|
if (text != ""){
|
||||||
}
|
return text.toInt();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
QWidget::changeEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupSpinBoxInput::InputRelease()
|
void PopupLineEdit::setValue(int value)
|
||||||
{
|
{
|
||||||
sig_inputEnd(_textInput->value());
|
this->setText(QString::number(value));
|
||||||
this->close();
|
|
||||||
this->deleteLater();
|
|
||||||
|
|
||||||
if (move_timer != NULL){
|
|
||||||
move_timer->stop();
|
|
||||||
delete move_timer;
|
|
||||||
move_timer = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopupSpinBoxInput::onCheckPostion()
|
|
||||||
{
|
|
||||||
if (_line != NULL){
|
|
||||||
QPoint p1 = _line->pos();
|
|
||||||
QPoint p2 = _line->mapToGlobal(p1);
|
|
||||||
int x = p2.x() - p1.x();
|
|
||||||
int y = p2.y() - p1.y();
|
|
||||||
|
|
||||||
QPoint p = this->pos();
|
|
||||||
if (p.x() != x || p.y() != y){
|
|
||||||
this->move(x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopupSpinBoxInput::Popup(QWidget *editline)
|
|
||||||
{
|
|
||||||
assert(editline);
|
|
||||||
_line = editline;
|
|
||||||
|
|
||||||
_textInput->setFixedSize(editline->size());
|
|
||||||
this->setFixedSize(editline->size());
|
|
||||||
|
|
||||||
QPoint pt = mapToGlobal(editline->rect().bottomLeft());
|
|
||||||
|
|
||||||
QPoint p1 = editline->pos();
|
|
||||||
QPoint p2 = editline->mapToGlobal(p1);
|
|
||||||
int x = p2.x() - p1.x();
|
|
||||||
int y = p2.y() - p1.y();
|
|
||||||
this->move(x, y);
|
|
||||||
|
|
||||||
_textInput->setFocus();
|
|
||||||
|
|
||||||
if (move_timer != NULL){
|
|
||||||
move_timer->stop();
|
|
||||||
delete move_timer;
|
|
||||||
move_timer = NULL;
|
|
||||||
}
|
|
||||||
move_timer = new QTimer(this);
|
|
||||||
move_timer->setInterval(100);
|
|
||||||
|
|
||||||
connect(move_timer, SIGNAL(timeout()), this, SLOT(onCheckPostion()));
|
|
||||||
move_timer->start();
|
|
||||||
|
|
||||||
this->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------PopupSpinBox
|
|
||||||
PopupSpinBox::PopupSpinBox(QWidget *parent)
|
|
||||||
:QSpinBox(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopupSpinBox::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
showPupopInput();
|
|
||||||
QSpinBox::mousePressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopupSpinBox::showPupopInput()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
PopupSpinBoxInput *input = new PopupSpinBoxInput(this);
|
|
||||||
input->GetInput()->setValue(this->value());
|
|
||||||
input->setFont(this->font());
|
|
||||||
input->GetInput()->setButtonSymbols(this->buttonSymbols());
|
|
||||||
|
|
||||||
int min = this->minimum();
|
|
||||||
int max = this->maximum();
|
|
||||||
input->GetInput()->setRange(min, max);
|
|
||||||
|
|
||||||
_old_value = this->value();
|
|
||||||
|
|
||||||
connect(input, SIGNAL(sig_inputEnd(int)), this, SLOT(onPopupInputEditEnd(int)));
|
|
||||||
input->Popup(this);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopupSpinBox::onPopupInputEditEnd(int value)
|
|
||||||
{
|
|
||||||
this->setFocus();
|
|
||||||
this->setValue(value);
|
|
||||||
|
|
||||||
if (value != _old_value){
|
|
||||||
valueChanged(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -90,6 +90,15 @@ class PopupLineEdit : public QLineEdit
|
|||||||
public:
|
public:
|
||||||
explicit PopupLineEdit(QWidget *parent = nullptr);
|
explicit PopupLineEdit(QWidget *parent = nullptr);
|
||||||
explicit PopupLineEdit(const QString &, QWidget *parent = nullptr);
|
explicit PopupLineEdit(const QString &, QWidget *parent = nullptr);
|
||||||
|
explicit PopupLineEdit(bool isNumberMode, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
inline bool is_number_mode(){
|
||||||
|
return _is_number_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
int value();
|
||||||
|
|
||||||
|
void setValue(int value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
@ -102,57 +111,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString _old_text;
|
QString _old_text;
|
||||||
};
|
bool _is_number_mode;
|
||||||
|
|
||||||
//---------PopupSpinBoxInput
|
|
||||||
class PopupSpinBoxInput : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit PopupSpinBoxInput(QWidget *parent = nullptr);
|
|
||||||
|
|
||||||
void Popup(QWidget *editline);
|
|
||||||
|
|
||||||
inline QSpinBox* GetInput(){
|
|
||||||
return _textInput;
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void sig_inputEnd(int value);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onCheckPostion();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void changeEvent(QEvent *event) override;
|
|
||||||
|
|
||||||
void InputRelease();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QSpinBox *_textInput;
|
|
||||||
QWidget *_line;
|
|
||||||
};
|
|
||||||
|
|
||||||
//---------PopupSpinBox
|
|
||||||
class PopupSpinBox : public QSpinBox
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit PopupSpinBox(QWidget *parent = nullptr);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onPopupInputEditEnd(int value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void showPupopInput();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int _old_value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -410,9 +410,6 @@ bool TriggerDock::commit_trigger()
|
|||||||
|
|
||||||
void TriggerDock::update_view()
|
void TriggerDock::update_view()
|
||||||
{
|
{
|
||||||
// TRIGGERPOS
|
|
||||||
//uint16_t pos = ds_trigger_get_pos();
|
|
||||||
//_position_slider->setValue(pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject TriggerDock::get_session()
|
QJsonObject TriggerDock::get_session()
|
||||||
@ -591,9 +588,9 @@ void TriggerDock::setup_adv_tab()
|
|||||||
_value0_lineEdit->setInputMask(mask);
|
_value0_lineEdit->setInputMask(mask);
|
||||||
_value0_lineEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
_value0_lineEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
_value0_lineEdit_list.push_back(_value0_lineEdit);
|
_value0_lineEdit_list.push_back(_value0_lineEdit);
|
||||||
QSpinBox *_count_spinBox = new PopupSpinBox(_stage_tabWidget);
|
PopupLineEdit *_count_spinBox = new PopupLineEdit(true, _stage_tabWidget);
|
||||||
_count_spinBox->setRange(1, INT32_MAX);
|
// _count_spinBox->setRange(1, INT32_MAX);
|
||||||
_count_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
//_count_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
_count_spinBox_list.push_back(_count_spinBox);
|
_count_spinBox_list.push_back(_count_spinBox);
|
||||||
DsComboBox *_inv0_comboBox = new DsComboBox(_stage_tabWidget);
|
DsComboBox *_inv0_comboBox = new DsComboBox(_stage_tabWidget);
|
||||||
//tr
|
//tr
|
||||||
|
@ -121,7 +121,7 @@ private:
|
|||||||
QVector <DsComboBox *> _logic_comboBox_list;
|
QVector <DsComboBox *> _logic_comboBox_list;
|
||||||
QVector <PopupLineEdit *> _value0_lineEdit_list;
|
QVector <PopupLineEdit *> _value0_lineEdit_list;
|
||||||
QVector <PopupLineEdit *> _value0_ext32_lineEdit_list;
|
QVector <PopupLineEdit *> _value0_ext32_lineEdit_list;
|
||||||
QVector <QSpinBox *> _count_spinBox_list;
|
QVector <PopupLineEdit *> _count_spinBox_list;
|
||||||
QVector <DsComboBox *> _inv0_comboBox_list;
|
QVector <DsComboBox *> _inv0_comboBox_list;
|
||||||
QVector <PopupLineEdit *> _value1_lineEdit_list;
|
QVector <PopupLineEdit *> _value1_lineEdit_list;
|
||||||
QVector <PopupLineEdit *> _value1_ext32_lineEdit_list;
|
QVector <PopupLineEdit *> _value1_ext32_lineEdit_list;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user