mirror of
https://github.com/august-alt/gpui.git
synced 2025-03-13 08:58:39 +03:00
feat: add shortcutlineedit
This commit is contained in:
parent
0e57883d1d
commit
3f8a21d360
@ -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
|
||||
|
54
src/plugins/preferences/common/shortcutlineedit.cpp
Normal file
54
src/plugins/preferences/common/shortcutlineedit.cpp
Normal 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);
|
||||
}
|
||||
|
||||
}
|
40
src/plugins/preferences/common/shortcutlineedit.h
Normal file
40
src/plugins/preferences/common/shortcutlineedit.h
Normal 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
|
Loading…
x
Reference in New Issue
Block a user