mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
add possibility of peeking primary screen
This commit is contained in:
@@ -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 "konsoleprivate_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());
|
||||
}
|
||||
|
||||
@@ -216,6 +216,8 @@ private Q_SLOTS:
|
||||
void toggleAllowLinkEscapeSequence(bool);
|
||||
void linkEscapeSequenceTextsChanged();
|
||||
|
||||
void peekPrimaryKeySequenceChanged();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(EditProfileDialog)
|
||||
|
||||
|
||||
@@ -3739,11 +3739,14 @@ void TerminalDisplay::keyPressEvent(QKeyEvent* event)
|
||||
}
|
||||
|
||||
if (_currentlyHoveredHotspot != nullptr) {
|
||||
auto fileHotspot = _currentlyHoveredHotspot.dynamicCast<FileFilterHotSpot>();
|
||||
if (!fileHotspot) {
|
||||
return;
|
||||
QSharedPointer<Konsole::FileFilterHotSpot> fileHotspot = _currentlyHoveredHotspot.dynamicCast<FileFilterHotSpot>();
|
||||
if (fileHotspot) {
|
||||
fileHotspot->requestThumbnail(event->modifiers(), QCursor::pos());
|
||||
}
|
||||
fileHotspot->requestThumbnail(event->modifiers(), QCursor::pos());
|
||||
}
|
||||
|
||||
if (!_peekPrimaryShortcut.isEmpty() && _peekPrimaryShortcut.matches(QKeySequence(event->key() | event->modifiers()))) {
|
||||
peekPrimaryRequested(true);
|
||||
}
|
||||
|
||||
_screenWindow->screen()->setCurrentTerminalDisplay(this);
|
||||
@@ -3790,6 +3793,8 @@ void TerminalDisplay::keyReleaseEvent(QKeyEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
peekPrimaryRequested(false);
|
||||
|
||||
QWidget::keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
@@ -4160,6 +4165,7 @@ void TerminalDisplay::applyProfile(const Profile::Ptr &profile)
|
||||
_displayVerticalLineAtChar = profile->verticalLineAtChar();
|
||||
setAlternateScrolling(profile->property<bool>(Profile::AlternateScrolling));
|
||||
_dimValue = profile->dimValue();
|
||||
_peekPrimaryShortcut = profile->peekPrimaryKeySequence();
|
||||
}
|
||||
|
||||
void TerminalDisplay::printScreen()
|
||||
|
||||
@@ -560,6 +560,8 @@ Q_SIGNALS:
|
||||
|
||||
void compositeFocusChanged(bool focused);
|
||||
|
||||
void peekPrimaryRequested(bool doPeek);
|
||||
|
||||
protected:
|
||||
// events
|
||||
bool event(QEvent *event) override;
|
||||
@@ -919,6 +921,7 @@ private:
|
||||
int _displayVerticalLineAtChar;
|
||||
|
||||
QSharedPointer<HotSpot> _currentlyHoveredHotspot;
|
||||
QKeySequence _peekPrimaryShortcut;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user