Merge pull request #6 from zballina/master
Add zoom in, out and reset. Option to choose an action after pasting the clipboard
This commit is contained in:
+27
-2
@@ -337,6 +337,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
|
||||
,_blendColor(qRgba(0,0,0,0xff))
|
||||
,_filterChain(new TerminalImageFilterChain())
|
||||
,_cursorShape(BlockCursor)
|
||||
,mMotionAfterPasting(NoMoveScreenWindow)
|
||||
{
|
||||
// terminal applications are not designed with Right-To-Left in mind,
|
||||
// so the layout is forced to Left-To-Right
|
||||
@@ -2512,6 +2513,16 @@ void TerminalDisplay::setFlowControlWarningEnabled( bool enable )
|
||||
outputSuspended(false);
|
||||
}
|
||||
|
||||
void TerminalDisplay::setMotionAfterPasting(MotionAfterPasting action)
|
||||
{
|
||||
mMotionAfterPasting = action;
|
||||
}
|
||||
|
||||
int TerminalDisplay::motionAfterPasting()
|
||||
{
|
||||
return mMotionAfterPasting;
|
||||
}
|
||||
|
||||
void TerminalDisplay::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
bool emitKeyPressSignal = true;
|
||||
@@ -2576,9 +2587,23 @@ void TerminalDisplay::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
emit keyPressedSignal(event);
|
||||
|
||||
if(!(event->modifiers().testFlag(Qt::ShiftModifier)
|
||||
if(event->modifiers().testFlag(Qt::ShiftModifier)
|
||||
|| event->modifiers().testFlag(Qt::ControlModifier)
|
||||
|| event->modifiers().testFlag(Qt::AltModifier)))
|
||||
|| event->modifiers().testFlag(Qt::AltModifier))
|
||||
{
|
||||
switch(mMotionAfterPasting)
|
||||
{
|
||||
case MoveStartScreenWindow:
|
||||
_screenWindow->scrollTo(0);
|
||||
break;
|
||||
case MoveEndScreenWindow:
|
||||
scrollToEnd();
|
||||
break;
|
||||
case NoMoveScreenWindow:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollToEnd();
|
||||
}
|
||||
|
||||
+17
-1
@@ -51,6 +51,17 @@ class QWidget;
|
||||
namespace Konsole
|
||||
{
|
||||
|
||||
enum MotionAfterPasting
|
||||
{
|
||||
// No move screenwindow after pasting
|
||||
NoMoveScreenWindow = 0,
|
||||
// Move start of screenwindow after pasting
|
||||
MoveStartScreenWindow = 1,
|
||||
// Move end of screenwindow after pasting
|
||||
MoveEndScreenWindow = 2
|
||||
};
|
||||
|
||||
|
||||
extern unsigned short vt100_graphics[32];
|
||||
|
||||
class ScreenWindow;
|
||||
@@ -414,7 +425,10 @@ public:
|
||||
ScreenWindow* screenWindow() const;
|
||||
|
||||
static bool HAVE_TRANSPARENCY;
|
||||
|
||||
|
||||
void setMotionAfterPasting(MotionAfterPasting action);
|
||||
int motionAfterPasting();
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
@@ -794,6 +808,8 @@ private:
|
||||
QColor _cursorColor;
|
||||
|
||||
|
||||
MotionAfterPasting mMotionAfterPasting;
|
||||
|
||||
struct InputMethodData
|
||||
{
|
||||
QString preeditString;
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "KeyboardTranslator.h"
|
||||
#include "ColorScheme.h"
|
||||
|
||||
#define STEP_ZOOM 3
|
||||
|
||||
using namespace Konsole;
|
||||
|
||||
void *createTermWidget(int startnow, void *parent)
|
||||
@@ -207,6 +209,13 @@ void QTermWidget::setTerminalFont(QFont &font)
|
||||
m_impl->m_terminalDisplay->setVTFont(font);
|
||||
}
|
||||
|
||||
QFont QTermWidget::getTerminalFont()
|
||||
{
|
||||
if (!m_impl->m_terminalDisplay)
|
||||
return QFont();
|
||||
return m_impl->m_terminalDisplay->getVTFont();
|
||||
}
|
||||
|
||||
void QTermWidget::setTerminalOpacity(qreal level)
|
||||
{
|
||||
if (!m_impl->m_terminalDisplay)
|
||||
@@ -329,6 +338,27 @@ void QTermWidget::pasteClipboard()
|
||||
m_impl->m_terminalDisplay->pasteClipboard();
|
||||
}
|
||||
|
||||
void QTermWidget::setZoom(int step)
|
||||
{
|
||||
if (!m_impl->m_terminalDisplay)
|
||||
return;
|
||||
|
||||
QFont font = m_impl->m_terminalDisplay->getVTFont();
|
||||
|
||||
font.setPointSize(font.pointSize() + step);
|
||||
setTerminalFont(font);
|
||||
}
|
||||
|
||||
void QTermWidget::zoomIn()
|
||||
{
|
||||
setZoom(STEP_ZOOM);
|
||||
}
|
||||
|
||||
void QTermWidget::zoomOut()
|
||||
{
|
||||
setZoom(-STEP_ZOOM);
|
||||
}
|
||||
|
||||
void QTermWidget::setKeyBindings(const QString & kb)
|
||||
{
|
||||
m_impl->m_session->setKeyBindings(kb);
|
||||
@@ -373,3 +403,8 @@ void QTermWidget::setEnvironment(const QStringList& environment)
|
||||
{
|
||||
m_impl->m_session->setEnvironment(environment);
|
||||
}
|
||||
|
||||
void QTermWidget::setMotionAfterPasting(int action)
|
||||
{
|
||||
m_impl->m_terminalDisplay->setMotionAfterPasting((Konsole::MotionAfterPasting) action);
|
||||
}
|
||||
|
||||
+8
-2
@@ -38,7 +38,6 @@ public:
|
||||
ScrollBarRight=2
|
||||
};
|
||||
|
||||
|
||||
//Creation of widget
|
||||
QTermWidget(int startnow, // 1 = start shell programm immediatelly
|
||||
QWidget * parent = 0);
|
||||
@@ -64,7 +63,7 @@ public:
|
||||
// USE ONLY FIXED-PITCH FONT!
|
||||
// otherwise symbols' position could be incorrect
|
||||
void setTerminalFont(QFont & font);
|
||||
|
||||
QFont getTerminalFont();
|
||||
void setTerminalOpacity(qreal level);
|
||||
|
||||
//environment
|
||||
@@ -119,6 +118,8 @@ public:
|
||||
|
||||
//! Return current key bindings
|
||||
QString keyBindings();
|
||||
|
||||
void setMotionAfterPasting(int);
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
@@ -136,6 +137,10 @@ public slots:
|
||||
// Copies selection to clipboard
|
||||
void pasteClipboard();
|
||||
|
||||
// Set zoom
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
/*! Set named key binding for given widget
|
||||
*/
|
||||
void setKeyBindings(const QString & kb);
|
||||
@@ -152,6 +157,7 @@ protected slots:
|
||||
void selectionChanged(bool textSelected);
|
||||
|
||||
private:
|
||||
void setZoom(int step);
|
||||
void init(int startnow);
|
||||
TermWidgetImpl * m_impl;
|
||||
};
|
||||
|
||||
+4
-2
@@ -21,12 +21,14 @@
|
||||
#include <QtGui>
|
||||
#include <QApplication>
|
||||
#include <QtDebug>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "qtermwidget.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
setenv("TERM", "xterm", 1);
|
||||
QApplication app(argc, argv);
|
||||
QMainWindow *mainWindow = new QMainWindow();
|
||||
|
||||
QTermWidget *console = new QTermWidget();
|
||||
@@ -41,7 +43,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
console->setTerminalFont(font);
|
||||
|
||||
//console->setColorScheme(COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW);
|
||||
// console->setColorScheme(COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW);
|
||||
console->setScrollBarPosition(QTermWidget::ScrollBarRight);
|
||||
|
||||
foreach (QString arg, QApplication::arguments())
|
||||
|
||||
Reference in New Issue
Block a user