feat: add shortcutlineedit

This commit is contained in:
august-alt 2024-03-05 15:52:34 +04:00
parent 0e57883d1d
commit 3f8a21d360
3 changed files with 96 additions and 0 deletions

View File

@ -31,6 +31,7 @@ set(HEADERS
common/propertieswidget.h
common/propertieswidgetdelegate.h
common/selectvariabledialog.h
common/shortcutlineedit.h
common/tabledetailswidget.h
common/variablesmodel.h
common/widgetfactory.h
@ -215,6 +216,7 @@ set(SOURCES
common/propertieswidget.cpp
common/propertieswidgetdelegate.cpp
common/selectvariabledialog.cpp
common/shortcutlineedit.cpp
common/tabledetailswidget.cpp
common/variablesmodel.cpp
common/widgetfactory.cpp

View File

@ -0,0 +1,54 @@
/***********************************************************************************************************************
**
** Copyright (C) 2024 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#include "shortcutlineedit.h"
#include <QEvent>
#include <QKeyEvent>
#include "selectvariabledialog.h"
namespace preferences
{
bool ShortcutLineEdit::event(QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_F3)
{
auto dialog = new SelectVariableDialog();
QObject::connect(dialog, &SelectVariableDialog::variableSelected, [&](QString variable)
{
this->setText(variable);
});
dialog->exec();
return true;
}
}
return QWidget::event(event);
}
}

View File

@ -0,0 +1,40 @@
/***********************************************************************************************************************
**
** Copyright (C) 2024 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef GPUI_SHORTUCT_LINEEIDT_H
#define GPUI_SHORTUCT_LINEEIDT_H
#include <QLineEdit>
namespace preferences
{
class ShortcutLineEdit final : public QLineEdit
{
public:
Q_OBJECT
public:
bool event(QEvent *event) override;
};
}
#endif//GPUI_SHORTUCT_LINEEIDT_H