From ff81d5f08dc7e7069418b906dbdc0ac3052a6402 Mon Sep 17 00:00:00 2001 From: ian geiser Date: Thu, 6 Aug 2015 10:32:14 -0400 Subject: [PATCH] Added a few more properties as well as removing some of the warnings about missing READ members. --- lib/TerminalDisplay.cpp | 72 ++++++++++++++++++++++++++++++----------- lib/TerminalDisplay.h | 32 +++++++++++------- src/ksession.cpp | 28 ++++++++++++---- src/ksession.h | 9 ++++-- 4 files changed, 102 insertions(+), 39 deletions(-) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index b5efbf5..189a609 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -280,13 +280,22 @@ void TerminalDisplay::setVTFont(const QFont& f) m_font = font; fontChange(font); + emit vtFontChanged(); //} } +void TerminalDisplay::setBoldIntense(bool value) +{ + if ( _boldIntense != value ) { + _boldIntense = value; + emit boldIntenseChanged(); + } +} + void TerminalDisplay::setFont(const QFont &f) { - Q_UNUSED(f); - // ignore font change request if not coming from konsole itself + Q_UNUSED(f); + // ignore font change request if not coming from konsole itself } /* ------------------------------------------------------------------------- */ @@ -3086,8 +3095,11 @@ uint TerminalDisplay::lineSpacing() const void TerminalDisplay::setLineSpacing(uint i) { - _lineSpacing = i; - setVTFont(font()); // Trigger an update. + if ( i != _lineSpacing ) { + _lineSpacing = i; + setVTFont(font()); // Trigger an update. + emit lineSpacingChanged(); + } } AutoScrollHandler::AutoScrollHandler(QWidget* parent) @@ -3228,24 +3240,33 @@ QStringList TerminalDisplay::availableColorSchemes() void TerminalDisplay::setColorScheme(const QString &name) { - const ColorScheme *cs; - // avoid legacy (int) solution - if (!availableColorSchemes().contains(name)) - cs = ColorSchemeManager::instance()->defaultColorScheme(); - else - cs = ColorSchemeManager::instance()->findColorScheme(name); + if ( name != _colorScheme ) { + const ColorScheme *cs; + // avoid legacy (int) solution + if (!availableColorSchemes().contains(name)) + cs = ColorSchemeManager::instance()->defaultColorScheme(); + else + cs = ColorSchemeManager::instance()->findColorScheme(name); - if (! cs) - { - qDebug() << "Cannot load color scheme: " << name; - return; + if (! cs) + { + qDebug() << "Cannot load color scheme: " << name; + return; + } + + ColorEntry table[TABLE_COLORS]; + cs->getColorTable(table); + setColorTable(table); + + setFillColor(cs->backgroundColor()); + _colorScheme = name; + emit colorSchemeChanged(); } +} - ColorEntry table[TABLE_COLORS]; - cs->getColorTable(table); - setColorTable(table); - - setFillColor(cs->backgroundColor()); +QString TerminalDisplay::colorScheme() const +{ + return _colorScheme; } void TerminalDisplay::simulateKeyPress(int key, int modifiers, bool pressed, quint32 nativeScanCode, const QString &text) @@ -3311,6 +3332,19 @@ QSize TerminalDisplay::getFontMetrics() return QSize(_fontWidth, _fontHeight); } +void TerminalDisplay::setFullCursorHeight(bool val) +{ + if ( m_full_cursor_height != val ) { + m_full_cursor_height = val; + emit fullCursorHeightChanged(); + } +} + +bool TerminalDisplay::fullCursorHeight() const +{ + return m_full_cursor_height; +} + void TerminalDisplay::itemChange(ItemChange change, const ItemChangeData & value) { switch (change) { diff --git a/lib/TerminalDisplay.h b/lib/TerminalDisplay.h index d5e268e..79357d1 100644 --- a/lib/TerminalDisplay.h +++ b/lib/TerminalDisplay.h @@ -84,10 +84,10 @@ 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(QFont font READ getVTFont WRITE setVTFont NOTIFY vtFontChanged ) + Q_PROPERTY(QString colorScheme READ colorScheme WRITE setColorScheme NOTIFY colorSchemeChanged ) Q_PROPERTY(QSize terminalSize READ getTerminalSize NOTIFY changedContentSizeSignal) - Q_PROPERTY(int lineSpacing WRITE setLineSpacing ) + Q_PROPERTY(int lineSpacing READ lineSpacing WRITE setLineSpacing NOTIFY lineSpacingChanged ) Q_PROPERTY(bool terminalUsesMouse READ getUsesMouse NOTIFY usesMouseChanged ) Q_PROPERTY(int lines READ lines NOTIFY changedContentSizeSignal) Q_PROPERTY(int columns READ columns NOTIFY changedContentSizeSignal) @@ -96,9 +96,10 @@ class KONSOLEPRIVATE_EXPORT TerminalDisplay : public QQuickPaintedItem Q_PROPERTY(int scrollbarMinimum READ getScrollbarMinimum NOTIFY scrollbarParamsChanged ) Q_PROPERTY(QSize fontMetrics READ getFontMetrics NOTIFY changedFontMetricSignal ) - Q_PROPERTY(bool enableBold WRITE setBoldIntense) - Q_PROPERTY(bool fullCursorHeight WRITE setFullCursorHeight) + Q_PROPERTY(bool enableBold READ getBoldIntense WRITE setBoldIntense NOTIFY boldIntenseChanged ) + Q_PROPERTY(bool fullCursorHeight READ fullCursorHeight WRITE setFullCursorHeight NOTIFY fullCursorHeightChanged) Q_PROPERTY(bool antialiasText READ antialias WRITE setAntialias) + Q_PROPERTY(QStringList availableColorSchemes READ availableColorSchemes NOTIFY availableColorSchemesChanged) public: /** Constructs a new terminal display widget with the specified parent. */ @@ -123,6 +124,7 @@ public: /** Sets the opacity of the terminal display. */ void setOpacity(qreal opacity); + /** * This enum describes the location where the scroll bar is positioned in the display widget. */ @@ -397,7 +399,7 @@ public: * Specifies whether characters with intense colors should be rendered * as bold. Defaults to true. */ - void setBoldIntense(bool value) { _boldIntense = value; } + void setBoldIntense(bool value); /** * Returns true if characters with intense colors are rendered in bold. */ @@ -548,6 +550,7 @@ public slots: // QMLTermWidget void setColorScheme(const QString &name); + QString colorScheme() const; QStringList availableColorSchemes(); void simulateKeyPress(int key, int modifiers, bool pressed, quint32 nativeScanCode, const QString &text); @@ -594,15 +597,15 @@ signals: */ void overrideShortcutCheck(QKeyEvent* keyEvent,bool& override); - void isBusySelecting(bool); + void isBusySelecting(bool busy); void sendStringToEmu(const char*); // qtermwidget signals - void copyAvailable(bool); + void copyAvailable(bool available); void termGetFocus(); void termLostFocus(); - void notifyBell(const QString&); + void notifyBell(const QString& bell); // QMLTermWidget void sessionChanged(); @@ -611,6 +614,12 @@ signals: void imagePainted(); void scrollbarValueChanged(); void scrollbarParamsChanged(int value); + void vtFontChanged(); + void lineSpacingChanged(); + void availableColorSchemesChanged(); + void colorSchemeChanged(); + void fullCursorHeightChanged(); + void boldIntenseChanged(); protected: virtual bool event( QEvent * ); @@ -842,7 +851,7 @@ private: QLabel* _outputSuspendedLabel; uint _lineSpacing; - + QString _colorScheme; bool _colorsInverted; // true during visual bell QSize _size; @@ -911,13 +920,14 @@ private: QSize getFontMetrics(); - void setFullCursorHeight(bool val) { m_full_cursor_height = val; } + void setFullCursorHeight(bool val); public: static void setTransparencyEnabled(bool enable) { HAVE_TRANSPARENCY = enable; } + bool fullCursorHeight() const; }; class AutoScrollHandler : public QObject diff --git a/src/ksession.cpp b/src/ksession.cpp index 3e0dfcb..65c687c 100644 --- a/src/ksession.cpp +++ b/src/ksession.cpp @@ -166,9 +166,11 @@ void KSession::setShellProgram(const QString &progname) void KSession::setInitialWorkingDirectory(const QString &dir) { - _initialWorkingDirectory = dir; - m_session->setInitialWorkingDirectory(dir); -} + if ( _initialWorkingDirectory == dir ) { + _initialWorkingDirectory = dir; + m_session->setInitialWorkingDirectory(dir); + emit initialWorkingDirectoryChanged(); +} } QString KSession::getInitialWorkingDirectory() { @@ -187,10 +189,22 @@ void KSession::setTextCodec(QTextCodec *codec) void KSession::setHistorySize(int lines) { - if (lines < 0) - m_session->setHistoryType(HistoryTypeFile()); - else - m_session->setHistoryType(HistoryTypeBuffer(lines)); + if ( historySize() != lines ) { + if (lines < 0) + m_session->setHistoryType(HistoryTypeFile()); + else + m_session->setHistoryType(HistoryTypeBuffer(lines)); + emit historySizeChanged(); + } +} + +int KSession::historySize() const +{ + if ( m_session->historyType().isUnlimited() ) { + return -1; + } else { + return m_session->historyType().maximumLineCount(); + } } void KSession::sendText(QString text) diff --git a/src/ksession.h b/src/ksession.h index 8d1f18b..19290d8 100644 --- a/src/ksession.h +++ b/src/ksession.h @@ -35,8 +35,8 @@ class KSession : public QObject { Q_OBJECT Q_PROPERTY(QString kbScheme READ getKeyBindings WRITE setKeyBindings NOTIFY changedKeyBindings) - Q_PROPERTY(QString initialWorkingDirectory READ getInitialWorkingDirectory WRITE setInitialWorkingDirectory) - Q_PROPERTY(QString title READ getTitle NOTIFY titleChanged) + Q_PROPERTY(QString initialWorkingDirectory READ getInitialWorkingDirectory WRITE setInitialWorkingDirectory NOTIFY initialWorkingDirectoryChanged) + Q_PROPERTY(QString title READ getTitle WRITE setTitle NOTIFY titleChanged) Q_PROPERTY(QString shellProgram WRITE setShellProgram) public: @@ -65,6 +65,7 @@ public: // History size for scrolling void setHistorySize(int lines); //infinite if lines < 0 + int historySize() const; // Sets whether flow control is enabled void setFlowControlEnabled(bool enabled); @@ -100,6 +101,10 @@ signals: void titleChanged(); + void historySizeChanged(); + + void initialWorkingDirectoryChanged(); + public slots: /*! Set named key binding for given widget