Add possibility of peeking primary screen

Good explanation from Tomaz (he's better with words than me):
    I think he wants to quick swap the text from primary and secondary screens:
        ls folder
        vim somefile.txt
        - mmm, what's the name of the file I need, I just did the LS for that reason -
        peek into primary screen, note the file name, go back to secondary screen

Merge request:
!210
parent 0db7875a
......@@ -43,7 +43,9 @@ Emulation::Emulation() :
_bracketedPasteMode(false),
_bulkTimer1(new QTimer(this)),
_bulkTimer2(new QTimer(this)),
_imageSizeInitialized(false)
_imageSizeInitialized(false),
_peekingPrimary(false),
_activeScreenIndex(0)
{
// create screens with a default size
_screen[0] = new Screen(40, 80);
......@@ -118,7 +120,24 @@ Emulation::~Emulation()
delete _decoder;
}
void Emulation::setPeekPrimary(const bool doPeek)
{
if (doPeek == _peekingPrimary) {
return;
}
_peekingPrimary = doPeek;
setScreenInternal(doPeek ? 0 : _activeScreenIndex);
emit outputChanged();
}
void Emulation::setScreen(int index)
{
_activeScreenIndex = index;
_peekingPrimary = false;
setScreenInternal(_activeScreenIndex);
}
void Emulation::setScreenInternal(int index)
{
Screen *oldScreen = _currentScreen;
_currentScreen = _screen[index & 1];
......
......@@ -246,6 +246,8 @@ public Q_SLOTS:
*/
virtual void focusChanged(bool focused) = 0;
void setPeekPrimary(const bool doPeek);
Q_SIGNALS:
/**
......@@ -480,6 +482,7 @@ private Q_SLOTS:
void bracketedPasteModeChanged(bool bracketedPasteMode);
private:
void setScreenInternal(int index);
Q_DISABLE_COPY(Emulation)
bool _usesMouseTracking;
......@@ -487,6 +490,8 @@ private:
QTimer _bulkTimer1;
QTimer _bulkTimer2;
bool _imageSizeInitialized;
bool _peekingPrimary;
int _activeScreenIndex;
};
}
......
......@@ -107,6 +107,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
, { BellMode , "BellMode" , TERMINAL_GROUP , QVariant::Int }
, { VerticalLine, "VerticalLine", TERMINAL_GROUP, QVariant::Bool }
, { VerticalLineAtChar, "VerticalLineAtChar", TERMINAL_GROUP, QVariant::Int }
, { PeekPrimaryKeySequence, "PeekPrimaryKeySequence", TERMINAL_GROUP, QVariant::String }
// Cursor
, { UseCustomCursorColor , "UseCustomCursorColor" , CURSOR_GROUP , QVariant::Bool}
, { CursorShape , "CursorShape" , CURSOR_GROUP , QVariant::Int}
......@@ -236,6 +237,7 @@ void Profile::useFallback()
setProperty(EscapedLinksSchema, QStringLiteral("http://;https://;file://"));
setProperty(VerticalLine, false);
setProperty(VerticalLineAtChar, 80);
setProperty(PeekPrimaryKeySequence, QString());
// Fallback should not be shown in menus
setHidden(true);
}
......
......@@ -28,6 +28,7 @@
#include <QVariant>
#include <QFont>
#include <QColor>
#include <QKeySequence>
// Konsole
#include "konsoleprofile_export.h"
......@@ -322,7 +323,10 @@ public:
/** Use Vertical Line At */
VerticalLine,
/** Vertical Line Pixel at */
VerticalLineAtChar
VerticalLineAtChar,
/** Shortcut for peeking primary screen */
PeekPrimaryKeySequence
};
Q_ENUM(Property)
......@@ -683,6 +687,11 @@ public:
return property<int>(Profile::VerticalLineAtChar);
}
QKeySequence peekPrimaryKeySequence() const
{
return QKeySequence::fromString(property<QString>(Profile::PeekPrimaryKeySequence));
}
int menuIndexAsInt() const;
/** Return a list of all properties names and their type
......
......@@ -329,6 +329,7 @@ void Session::addView(TerminalDisplay* widget)
connect(widget, &Konsole::TerminalDisplay::keyPressedSignal, _emulation, &Konsole::Emulation::sendKeyEvent);
connect(widget, &Konsole::TerminalDisplay::mouseSignal, _emulation, &Konsole::Emulation::sendMouseEvent);
connect(widget, &Konsole::TerminalDisplay::sendStringToEmu, _emulation, &Konsole::Emulation::sendString);
connect(widget, &Konsole::TerminalDisplay::peekPrimaryRequested, _emulation, &Konsole::Emulation::setPeekPrimary);
// allow emulation to notify the view when the foreground process
// indicates whether or not it is interested in Mouse Tracking events
......
......@@ -270,6 +270,20 @@
</property>
</widget>
</item>
<item row="8" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="peekPrimaryLabel">
<property name="text">
<string>Shortcut for peeking the primary screen:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1" alignment="Qt::AlignRight">
<widget class="QKeySequenceEdit" name="peekPrimaryWidget">
</widget>
</item>
</layout>
</item>
<item>
......
......@@ -1740,6 +1740,9 @@ void EditProfileDialog::setupAdvancedPage(const Profile::Ptr &profile)
&Konsole::EditProfileDialog::setDefaultCodec);
_advancedUi->selectEncodingButton->setText(profile->defaultEncoding());
_advancedUi->peekPrimaryWidget->setKeySequence(profile->peekPrimaryKeySequence());
connect(_advancedUi->peekPrimaryWidget, &QKeySequenceEdit::editingFinished, this, &EditProfileDialog::peekPrimaryKeySequenceChanged);
}
int EditProfileDialog::maxSpinBoxWidth(const KPluralHandlingSpinBox *spinBox, const KLocalizedString &suffix)
......@@ -1890,3 +1893,8 @@ void EditProfileDialog::toggleFlowControl(bool enable)
{
updateTempProfileProperty(Profile::FlowControlEnabled, enable);
}
void EditProfileDialog::peekPrimaryKeySequenceChanged()
{
updateTempProfileProperty(Profile::PeekPrimaryKeySequence, _advancedUi->peekPrimaryWidget->keySequence().toString());
}
......@@ -217,6 +217,8 @@ private Q_SLOTS:
void toggleAllowLinkEscapeSequence(bool);
void linkEscapeSequenceTextsChanged();
void peekPrimaryKeySequenceChanged();
private:
Q_DISABLE_COPY(EditProfileDialog)
......
......@@ -3497,6 +3497,10 @@ void TerminalDisplay::keyPressEvent(QKeyEvent* event)
_filterChain->keyPressEvent(this, event, charLine, charColumn);
}
if (!_peekPrimaryShortcut.isEmpty() && _peekPrimaryShortcut.matches(QKeySequence(event->key() | event->modifiers()))) {
peekPrimaryRequested(true);
}
_screenWindow->screen()->setCurrentTerminalDisplay(this);
if (!_readOnly) {
......@@ -3543,6 +3547,8 @@ void TerminalDisplay::keyReleaseEvent(QKeyEvent *event)
_filterChain->keyReleaseEvent(this, event, charLine, charColumn);
}
peekPrimaryRequested(false);
QWidget::keyReleaseEvent(event);
}
......@@ -3915,6 +3921,7 @@ void TerminalDisplay::applyProfile(const Profile::Ptr &profile)
_filterChain->setUrlHintsModifiers(Qt::KeyboardModifiers(profile->property<int>(Profile::UrlHintsModifiers)));
_filterChain->setReverseUrlHints(profile->property<bool>(Profile::ReverseUrlHints));
_peekPrimaryShortcut = profile->peekPrimaryKeySequence();
}
void TerminalDisplay::printScreen()
......
......@@ -575,6 +575,8 @@ Q_SIGNALS:
void compositeFocusChanged(bool focused);
void peekPrimaryRequested(bool doPeek);
protected:
// events
bool event(QEvent *event) override;
......@@ -917,6 +919,8 @@ private:
bool _hasCompositeFocus;
bool _displayVerticalLine;
int _displayVerticalLineAtChar;
QKeySequence _peekPrimaryShortcut;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment