Added optional purely QML scrollbar.
This commit is contained in:
@@ -387,6 +387,8 @@ TerminalDisplay::TerminalDisplay(QQuickItem *parent)
|
||||
|
||||
setFlags(ItemHasContents | ItemAcceptsInputMethod);
|
||||
|
||||
connect(_scrollBar, SIGNAL(valueChanged(int)), this, SIGNAL(scrollbarParamsChanged(int)));
|
||||
|
||||
// TODO Forcing rendering to Framebuffer. We need to determine if this is ok
|
||||
// always or if we need to make this customizable.
|
||||
setRenderTarget(QQuickPaintedItem::FramebufferObject);
|
||||
@@ -1713,6 +1715,9 @@ void TerminalDisplay::scrollBarPositionChanged(int)
|
||||
_screenWindow->setTrackOutput( atEndOfOutput );
|
||||
|
||||
updateImage();
|
||||
|
||||
// QMLTermWidget: notify qml side of the change only when needed.
|
||||
emit scrollbarValueChanged();
|
||||
}
|
||||
|
||||
void TerminalDisplay::setScroll(int cursor, int slines)
|
||||
@@ -3282,4 +3287,19 @@ bool TerminalDisplay::getUsesMouse()
|
||||
return !usesMouse();
|
||||
}
|
||||
|
||||
int TerminalDisplay::getScrollbarValue()
|
||||
{
|
||||
return _scrollBar->value();
|
||||
}
|
||||
|
||||
int TerminalDisplay::getScrollbarMaximum()
|
||||
{
|
||||
return _scrollBar->maximum();
|
||||
}
|
||||
|
||||
int TerminalDisplay::getScrollbarMinimum()
|
||||
{
|
||||
return _scrollBar->minimum();
|
||||
}
|
||||
|
||||
//#include "TerminalDisplay.moc"
|
||||
|
||||
+17
-6
@@ -83,12 +83,17 @@ class ScreenWindow;
|
||||
class KONSOLEPRIVATE_EXPORT TerminalDisplay : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(KSession* session READ getSession WRITE setSession NOTIFY sessionChanged)
|
||||
Q_PROPERTY(QFont font READ getVTFont WRITE setVTFont )
|
||||
Q_PROPERTY(QString colorScheme WRITE setColorScheme )
|
||||
Q_PROPERTY(QSize terminalSize READ getTerminalSize NOTIFY changedContentSizeSignal)
|
||||
Q_PROPERTY(int lineSpacing WRITE setLineSpacing)
|
||||
Q_PROPERTY(bool terminalUsesMouse READ getUsesMouse NOTIFY usesMouseChanged)
|
||||
Q_PROPERTY(KSession* session READ getSession WRITE setSession NOTIFY sessionChanged )
|
||||
Q_PROPERTY(QFont font READ getVTFont WRITE setVTFont )
|
||||
Q_PROPERTY(QString colorScheme WRITE setColorScheme )
|
||||
Q_PROPERTY(QSize terminalSize READ getTerminalSize NOTIFY changedContentSizeSignal)
|
||||
Q_PROPERTY(int lineSpacing WRITE setLineSpacing )
|
||||
Q_PROPERTY(bool terminalUsesMouse READ getUsesMouse NOTIFY usesMouseChanged )
|
||||
Q_PROPERTY(int lines READ lines NOTIFY changedContentSizeSignal)
|
||||
Q_PROPERTY(int columns READ columns NOTIFY changedContentSizeSignal)
|
||||
Q_PROPERTY(int scrollbarCurrentValue READ getScrollbarValue NOTIFY scrollbarParamsChanged )
|
||||
Q_PROPERTY(int scrollbarMaximum READ getScrollbarMaximum NOTIFY scrollbarParamsChanged )
|
||||
Q_PROPERTY(int scrollbarMinimum READ getScrollbarMinimum NOTIFY scrollbarParamsChanged )
|
||||
|
||||
public:
|
||||
/** Constructs a new terminal display widget with the specified parent. */
|
||||
@@ -599,6 +604,8 @@ signals:
|
||||
void sizeChanged();
|
||||
void usesMouseChanged();
|
||||
void imagePainted();
|
||||
void scrollbarValueChanged();
|
||||
void scrollbarParamsChanged(int value);
|
||||
|
||||
protected:
|
||||
virtual bool event( QEvent * );
|
||||
@@ -891,6 +898,10 @@ private:
|
||||
|
||||
bool getUsesMouse();
|
||||
|
||||
int getScrollbarValue();
|
||||
int getScrollbarMaximum();
|
||||
int getScrollbarMinimum();
|
||||
|
||||
public:
|
||||
static void setTransparencyEnabled(bool enable)
|
||||
{
|
||||
|
||||
+7
-1
@@ -20,7 +20,13 @@ HEADERS += $$PWD/src/qmltermwidget_plugin.h \
|
||||
SOURCES += $$PWD/src/qmltermwidget_plugin.cpp \
|
||||
$$PWD/src/ksession.cpp
|
||||
|
||||
OTHER_FILES += \
|
||||
src/QMLTermScrollbar.qml \
|
||||
test-app/test-app.qml \
|
||||
src/qmldir
|
||||
|
||||
# Copy the files useful to the plugin in DESTDIR
|
||||
QMAKE_POST_LINK = $(COPY_DIR) $$PWD/lib/color-schemes $$DESTDIR && \
|
||||
$(COPY_DIR) $$PWD/lib/kb-layouts $$DESTDIR && \
|
||||
$$QMAKE_COPY $$PWD/src/qmldir $$DESTDIR
|
||||
$$QMAKE_COPY $$PWD/src/qmldir $$DESTDIR && \
|
||||
$$QMAKE_COPY $$PWD/src/QMLTermScrollbar.qml $$DESTDIR
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import QtQuick 2.0
|
||||
import QMLTermWidget 1.0
|
||||
|
||||
Item {
|
||||
property QMLTermWidget terminal
|
||||
|
||||
property int value: terminal.scrollbarCurrentValue
|
||||
property int minimum: terminal.scrollbarMinimum
|
||||
property int maximum: terminal.scrollbarMaximum
|
||||
property int lines: terminal.lines
|
||||
property int totalLines: lines + maximum
|
||||
|
||||
anchors.right: terminal.right
|
||||
|
||||
opacity: 0.0
|
||||
|
||||
height: terminal.height * (lines / (totalLines - minimum))
|
||||
y: (terminal.height / (totalLines)) * (value - minimum)
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: 300; easing.type: Easing.OutCubic }
|
||||
}
|
||||
|
||||
function showScrollbar() {
|
||||
opacity = 1.0;
|
||||
hideTimer.restart();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: terminal
|
||||
onScrollbarValueChanged: showScrollbar();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: hideTimer
|
||||
onTriggered: parent.opacity = 0;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
module QMLTermWidget
|
||||
plugin qmltermwidget
|
||||
plugin qmltermwidget
|
||||
QMLTermScrollbar 1.0 QMLTermScrollbar.qml
|
||||
|
||||
|
||||
@@ -29,6 +29,17 @@ Rectangle {
|
||||
onTerminalUsesMouseChanged: console.log(terminalUsesMouse);
|
||||
onTerminalSizeChanged: console.log(terminalSize);
|
||||
Component.onCompleted: mainsession.startShellProgram();
|
||||
|
||||
QMLTermScrollbar {
|
||||
terminal: terminal
|
||||
width: 20
|
||||
Rectangle {
|
||||
opacity: 0.4
|
||||
anchors.margins: 5
|
||||
radius: width * 0.5
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
}
|
||||
Component.onCompleted: terminal.forceActiveFocus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user