mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
LineEdit: Fix text edit shortcuts not working on non-latin keyboard layout
This fixes Ctrl+C/V/X/A shortcuts in LocationBar and WebSearchBar Followup to #1494
This commit is contained in:
parent
79ddfbafa2
commit
ada212bc59
60
src/lib/3rdparty/lineedit.cpp
vendored
60
src/lib/3rdparty/lineedit.cpp
vendored
|
@ -89,6 +89,61 @@ void LineEdit::init()
|
|||
|
||||
connect(m_leftWidget, SIGNAL(sizeHintChanged()), this, SLOT(updateTextMargins()));
|
||||
connect(m_rightWidget, SIGNAL(sizeHintChanged()), this, SLOT(updateTextMargins()));
|
||||
|
||||
QAction* undoAction = new QAction(QIcon::fromTheme(QSL("edit-undo")), tr("&Undo"), this);
|
||||
undoAction->setShortcut(QKeySequence(QSL("Ctrl+Z")));
|
||||
undoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
connect(undoAction, SIGNAL(triggered()), SLOT(undo()));
|
||||
|
||||
QAction* redoAction = new QAction(QIcon::fromTheme(QSL("edit-redo")), tr("&Redo"), this);
|
||||
redoAction->setShortcut(QKeySequence(QSL("Ctrl+Shift+Z")));
|
||||
redoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
connect(redoAction, SIGNAL(triggered()), SLOT(redo()));
|
||||
|
||||
QAction* cutAction = new QAction(QIcon::fromTheme(QSL("edit-cut")), tr("Cu&t"), this);
|
||||
cutAction->setShortcut(QKeySequence(QSL("Ctrl+X")));
|
||||
cutAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
connect(cutAction, SIGNAL(triggered()), SLOT(cut()));
|
||||
|
||||
QAction* copyAction = new QAction(QIcon::fromTheme(QSL("edit-copy")), tr("&Copy"), this);
|
||||
copyAction->setShortcut(QKeySequence(QSL("Ctrl+C")));
|
||||
copyAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
connect(copyAction, SIGNAL(triggered()), SLOT(copy()));
|
||||
|
||||
QAction* pasteAction = new QAction(QIcon::fromTheme(QSL("edit-paste")), tr("&Paste"), this);
|
||||
pasteAction->setShortcut(QKeySequence(QSL("Ctrl+V")));
|
||||
pasteAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
connect(pasteAction, SIGNAL(triggered()), SLOT(paste()));
|
||||
|
||||
QAction* deleteAction = new QAction(QIcon::fromTheme(QSL("edit-delete")), tr("Delete"), this);
|
||||
connect(deleteAction, SIGNAL(triggered()), SLOT(slotDelete()));
|
||||
|
||||
QAction* clearAllAction = new QAction(QIcon::fromTheme(QSL("edit-clear")), tr("Clear All"), this);
|
||||
connect(clearAllAction, SIGNAL(triggered()), SLOT(clear()));
|
||||
|
||||
QAction* selectAllAction = new QAction(QIcon::fromTheme(QSL("edit-select-all")), tr("Select All"), this);
|
||||
selectAllAction->setShortcut(QKeySequence(QSL("Ctrl+A")));
|
||||
selectAllAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
connect(selectAllAction, SIGNAL(triggered()), SLOT(selectAll()));
|
||||
|
||||
m_editActions[Undo] = undoAction;
|
||||
m_editActions[Redo] = redoAction;
|
||||
m_editActions[Cut] = cutAction;
|
||||
m_editActions[Copy] = copyAction;
|
||||
m_editActions[Paste] = pasteAction;
|
||||
m_editActions[Delete] = deleteAction;
|
||||
m_editActions[ClearAll] = clearAllAction;
|
||||
m_editActions[SelectAll] = selectAllAction;
|
||||
|
||||
// Make action shortcuts available for webview
|
||||
addAction(undoAction);
|
||||
addAction(redoAction);
|
||||
addAction(cutAction);
|
||||
addAction(copyAction);
|
||||
addAction(pasteAction);
|
||||
addAction(deleteAction);
|
||||
addAction(clearAllAction);
|
||||
addAction(selectAllAction);
|
||||
}
|
||||
|
||||
bool LineEdit::event(QEvent* event)
|
||||
|
@ -276,6 +331,11 @@ QSize LineEdit::sizeHint() const
|
|||
return s;
|
||||
}
|
||||
|
||||
QAction* LineEdit::editAction(EditAction action) const
|
||||
{
|
||||
return m_editActions[action];
|
||||
}
|
||||
|
||||
void LineEdit::updateTextMargins()
|
||||
{
|
||||
int left = m_leftWidget->sizeHint().width();
|
||||
|
|
13
src/lib/3rdparty/lineedit.h
vendored
13
src/lib/3rdparty/lineedit.h
vendored
|
@ -80,6 +80,17 @@ public:
|
|||
RightSide
|
||||
};
|
||||
|
||||
enum EditAction {
|
||||
Undo = 0,
|
||||
Redo = 1,
|
||||
Cut = 2,
|
||||
Copy = 3,
|
||||
Paste = 4,
|
||||
Delete = 5,
|
||||
ClearAll = 6,
|
||||
SelectAll = 7
|
||||
};
|
||||
|
||||
LineEdit(QWidget* parent = 0);
|
||||
|
||||
void addWidget(QWidget* widget, WidgetPosition position);
|
||||
|
@ -95,6 +106,7 @@ public:
|
|||
void setMinHeight(int height);
|
||||
|
||||
QSize sizeHint() const;
|
||||
QAction* editAction(EditAction action) const;
|
||||
|
||||
public slots:
|
||||
void setLeftMargin(int margin);
|
||||
|
@ -119,6 +131,7 @@ private:
|
|||
QHBoxLayout* m_leftLayout;
|
||||
QHBoxLayout* m_rightLayout;
|
||||
QHBoxLayout* mainLayout;
|
||||
QAction* m_editActions[8];
|
||||
|
||||
int m_minHeight;
|
||||
int m_leftMargin;
|
||||
|
|
|
@ -1209,31 +1209,37 @@ void WebView::initializeActions()
|
|||
QAction* undoAction = pageAction(QWebPage::Undo);
|
||||
undoAction->setText(tr("&Undo"));
|
||||
undoAction->setShortcut(QKeySequence("Ctrl+Z"));
|
||||
undoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
undoAction->setIcon(QIcon::fromTheme(QSL("edit-undo")));
|
||||
|
||||
QAction* redoAction = pageAction(QWebPage::Redo);
|
||||
redoAction->setText(tr("&Redo"));
|
||||
redoAction->setShortcut(QKeySequence("Ctrl+Shift+Z"));
|
||||
redoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
redoAction->setIcon(QIcon::fromTheme(QSL("edit-redo")));
|
||||
|
||||
QAction* cutAction = pageAction(QWebPage::Cut);
|
||||
cutAction->setText(tr("&Cut"));
|
||||
cutAction->setShortcut(QKeySequence("Ctrl+X"));
|
||||
cutAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
cutAction->setIcon(QIcon::fromTheme(QSL("edit-cut")));
|
||||
|
||||
QAction* copyAction = pageAction(QWebPage::Copy);
|
||||
copyAction->setText(tr("&Copy"));
|
||||
copyAction->setShortcut(QKeySequence("Ctrl+C"));
|
||||
copyAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
copyAction->setIcon(QIcon::fromTheme(QSL("edit-copy")));
|
||||
|
||||
QAction* pasteAction = pageAction(QWebPage::Paste);
|
||||
pasteAction->setText(tr("&Paste"));
|
||||
pasteAction->setShortcut(QKeySequence("Ctrl+V"));
|
||||
pasteAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
pasteAction->setIcon(QIcon::fromTheme(QSL("edit-paste")));
|
||||
|
||||
QAction* selectAllAction = pageAction(QWebPage::SelectAll);
|
||||
selectAllAction->setText(tr("Select All"));
|
||||
selectAllAction->setShortcut(QKeySequence("Ctrl+A"));
|
||||
selectAllAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||
selectAllAction->setIcon(QIcon::fromTheme(QSL("edit-select-all")));
|
||||
|
||||
QAction* reloadAction = pageAction(QWebPage::Reload);
|
||||
|
|
Loading…
Reference in New Issue
Block a user