Skip to content

Instantly share code, notes, and snippets.

@chee
Created August 5, 2020 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chee/4fc430af8d0e6aaad5f24676033a4d84 to your computer and use it in GitHub Desktop.
Save chee/4fc430af8d0e6aaad5f24676033a4d84 to your computer and use it in GitHub Desktop.
diff -ruN yakuake-20.04.3/app/mainwindow.cpp ../yakuake-20.04.3/app/mainwindow.cpp
--- yakuake-20.04.3/app/mainwindow.cpp 2020-06-24 16:34:00.000000000 +0100
+++ ../yakuake-20.04.3/app/mainwindow.cpp 2020-08-05 15:14:33.607164071 +0100
@@ -280,6 +280,16 @@
connect(action, SIGNAL(triggered()), this, SLOT(handleContextDependentAction()));
m_contextDependentActions << action;
+ action = actionCollection()->addAction(QStringLiteral("terminal-copy"));
+ action->setText(QStringLiteral("Copy"));
+ actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::META + Qt::Key_C));
+ connect(action, SIGNAL(triggered()), m_sessionStack, SLOT(copy()));
+
+ action = actionCollection()->addAction(QStringLiteral("terminal-paste"));
+ action->setText(QStringLiteral("Paste"));
+ actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::META + Qt::Key_V));
+ connect(action, SIGNAL(triggered()), m_sessionStack, SLOT(paste()));
+
action = actionCollection()->addAction(QStringLiteral("increase-window-width"));
action->setText(xi18nc("@action", "Increase Window Width"));
actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Right));
diff -ruN yakuake-20.04.3/app/sessionstack.cpp ../yakuake-20.04.3/app/sessionstack.cpp
--- yakuake-20.04.3/app/sessionstack.cpp 2020-06-24 16:34:00.000000000 +0100
+++ ../yakuake-20.04.3/app/sessionstack.cpp 2020-08-05 15:11:59.921660088 +0100
@@ -287,6 +287,19 @@
}
}
+void SessionStack::copy()
+{
+ Terminal *terminal = m_sessions.value(m_activeSessionId)->getTerminal(activeTerminalId());
+ terminal->copy();
+}
+
+void SessionStack::paste()
+{
+ Terminal *terminal = m_sessions.value(m_activeSessionId)->getTerminal(activeTerminalId());
+ terminal->paste();
+}
+
+
bool SessionStack::isSessionClosable(int sessionId)
{
if (sessionId == -1) sessionId = m_activeSessionId;
diff -ruN yakuake-20.04.3/app/sessionstack.h ../yakuake-20.04.3/app/sessionstack.h
--- yakuake-20.04.3/app/sessionstack.h 2020-06-24 16:34:00.000000000 +0100
+++ ../yakuake-20.04.3/app/sessionstack.h 2020-08-05 15:03:52.812701336 +0100
@@ -83,6 +83,9 @@
Q_SCRIPTABLE const QString terminalIdsForSessionId(int sessionId);
Q_SCRIPTABLE int sessionIdForTerminalId(int terminalId);
+ void copy();
+ void paste();
+
#if defined(REMOVE_SENDTEXT_RUNCOMMAND_DBUS_METHODS)
void runCommand(const QString& command);
void runCommandInTerminal(int terminalId, const QString& command);
diff -ruN yakuake-20.04.3/app/terminal.cpp ../yakuake-20.04.3/app/terminal.cpp
--- yakuake-20.04.3/app/terminal.cpp 2020-06-24 16:34:00.000000000 +0100
+++ ../yakuake-20.04.3/app/terminal.cpp 2020-08-05 14:59:41.410782651 +0100
@@ -119,6 +119,16 @@
deleteLater();
}
+void Terminal::paste()
+{
+ QApplication::postEvent(m_terminalWidget, new QKeyEvent(QEvent::KeyPress, Qt::Key_V, Qt::ShiftModifier|Qt::ControlModifier));
+}
+
+void Terminal::copy()
+{
+ QApplication::postEvent(m_terminalWidget, new QKeyEvent(QEvent::KeyPress, Qt::Key_C, Qt::ShiftModifier|Qt::ControlModifier));
+}
+
bool Terminal::eventFilter(QObject* /* watched */, QEvent* event)
{
if (event->type() == QEvent::FocusIn)
diff -ruN yakuake-20.04.3/app/terminal.h ../yakuake-20.04.3/app/terminal.h
--- yakuake-20.04.3/app/terminal.h 2020-06-24 16:34:00.000000000 +0100
+++ ../yakuake-20.04.3/app/terminal.h 2020-08-05 14:50:01.347733455 +0100
@@ -69,6 +69,8 @@
QString currentWorkingDirectory() const;
void deletePart();
+ void paste();
+ void copy();
Q_SIGNALS:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment