Support blur

pull/2/head
reionwong 4 years ago
parent 529de3b437
commit 8ef31807de

@ -336,6 +336,7 @@ TerminalDisplay::TerminalDisplay(QQuickItem *parent)
, m_font("Monospace", 12)
, m_colorRole(QPalette::Background)
, m_full_cursor_height(false)
, m_backgroundOpacity(1.0)
{
// terminal applications are not designed with Right-To-Left in mind,
// so the layout is forced to Left-To-Right
@ -2843,11 +2844,37 @@ bool TerminalDisplay::handleShortcutOverrideEvent(QKeyEvent* keyEvent)
return false;
}
qreal TerminalDisplay::backgroundOpacity() const
{
return m_backgroundOpacity;
}
void TerminalDisplay::setBackgroundOpacity(const qreal &backgroundOpacity)
{
if (m_backgroundOpacity != backgroundOpacity) {
m_backgroundOpacity = backgroundOpacity;
const ColorScheme *cs;
if (!availableColorSchemes().contains(_colorScheme))
cs = ColorSchemeManager::instance()->defaultColorScheme();
else
cs = ColorSchemeManager::instance()->findColorScheme(_colorScheme);
if (cs) {
QColor color = cs->backgroundColor();
color.setAlphaF(m_backgroundOpacity);
setFillColor(color);
}
emit backgroundOpacityChanged();
}
}
bool TerminalDisplay::event(QEvent* event)
{
bool eventHandled = false;
switch (event->type())
{
bool eventHandled = false;
switch (event->type())
{
case QEvent::ShortcutOverride:
eventHandled = handleShortcutOverrideEvent((QKeyEvent*)event);
break;
@ -3259,7 +3286,9 @@ void TerminalDisplay::setColorScheme(const QString &name)
cs->getColorTable(table);
setColorTable(table);
setFillColor(cs->backgroundColor());
QColor bgColor = cs->backgroundColor();
bgColor.setAlphaF(m_backgroundOpacity);
setFillColor(bgColor);
_colorScheme = name;
emit colorSchemeChanged();
}

@ -97,6 +97,8 @@ class TerminalDisplay : public QQuickPaintedItem
Q_PROPERTY(bool selectedText READ selectedText CONSTANT)
Q_PROPERTY(qreal backgroundOpacity READ backgroundOpacity WRITE setBackgroundOpacity NOTIFY backgroundOpacityChanged)
public:
/** Constructs a new terminal display widget with the specified parent. */
explicit TerminalDisplay(QQuickItem *parent = nullptr);
@ -120,6 +122,9 @@ public:
/** Sets the opacity of the terminal display. */
void setOpacity(qreal opacity);
qreal backgroundOpacity() const;
void setBackgroundOpacity(const qreal &backgroundOpacity);
/**
* This enum describes the location where the scroll bar is positioned in the display widget.
*/
@ -553,6 +558,7 @@ public slots:
void simulateMouseDoubleClick(int x, int y, int button, int buttons, int modifiers);
signals:
void backgroundOpacityChanged();
/**
* Emitted when the user presses a key whilst the terminal widget has focus.
@ -888,6 +894,8 @@ private:
KSession *m_session;
bool m_full_cursor_height;
qreal m_backgroundOpacity;
QFont font() const { return m_font; }
const QPalette palette() { return m_palette; }

@ -25,4 +25,7 @@ Settings {
property int height: 500
property int fontPointSize: 10
property bool blinkingCursor: true
property real opacity: 0.8
property bool blur: true
}

@ -33,7 +33,12 @@ Page {
focus: true
// Drop effect
opacity: _dropArea.containsDrag ? 0.8 : 1
// opacity: _dropArea.containsDrag ? 0.8 : 1
// opacity: 0.5
background: Rectangle {
color: "transparent"
}
signal urlsDropped(var urls)
signal keyPressed(var event)
@ -106,6 +111,7 @@ Page {
font.pointSize: settings.fontPointSize
blinkingCursor: settings.blinkingCursor
fullCursorHeight: true
backgroundOpacity: 0
Keys.enabled: true
Keys.onPressed: control.keyPressed(event)

@ -34,7 +34,8 @@ FishUI.Window {
height: settings.height
title: currentItem && currentItem.terminal ? currentItem.terminal.session.title : ""
background.color: FishUI.Theme.secondBackgroundColor
background.color: FishUI.Theme.backgroundColor
background.opacity: settings.opacity
header.height: 45
property int currentIndex: -1
@ -49,6 +50,13 @@ FishUI.Window {
onOkBtnClicked: Qt.quit()
}
FishUI.WindowBlur {
view: root
geometry: Qt.rect(root.x, root.y, root.width, root.height)
windowRadius: root.background.radius
enabled: settings.blur
}
onClosing: {
if (!root.isMaximized) {
settings.width = root.width
@ -92,7 +100,7 @@ FishUI.Window {
highlight: Rectangle {
color: FishUI.Theme.highlightColor
opacity: FishUI.Theme.darkMode ? 0.2 : 0.1
opacity: 1
border.width: 0
radius: FishUI.Theme.smallRadius
}
@ -136,7 +144,7 @@ FishUI.Window {
elide: Label.ElideRight
font.pointSize: 9
font.family: "Noto Sans Mono"
color: isCurrent ? FishUI.Theme.highlightColor : FishUI.Theme.textColor
color: isCurrent ? FishUI.Theme.highlightedTextColor : FishUI.Theme.textColor
}
Item {
@ -147,7 +155,7 @@ FishUI.Window {
Layout.preferredHeight: 24
Layout.preferredWidth: 24
size: 24
source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark/" : "light/") + "close.svg"
source: "qrc:/images/" + (FishUI.Theme.darkMode || isCurrent ? "dark/" : "light/") + "close.svg"
onClicked: closeTab(index)
}
}

Loading…
Cancel
Save