Fix some warnings

pull/2/head
reionwong 4 years ago
parent 3fbb98876c
commit a8f62f6a64

@ -33,6 +33,7 @@ set(SRCS
src/main.cpp
src/processhelper.h
src/processhelper.cpp
src/utils.cpp
)
set(RESOURCES

@ -2677,6 +2677,11 @@ void TerminalDisplay::setSelection(const QString& t)
QApplication::clipboard()->setText(t, QClipboard::Selection);
}
bool TerminalDisplay::selectedText()
{
return !_screenWindow->selectedText(false).isEmpty();
}
void TerminalDisplay::copyClipboard()
{
if ( !_screenWindow )

@ -103,6 +103,8 @@ class KONSOLEPRIVATE_EXPORT TerminalDisplay : public QQuickPaintedItem
Q_PROPERTY(bool antialiasText READ antialias WRITE setAntialias)
Q_PROPERTY(QStringList availableColorSchemes READ availableColorSchemes NOTIFY availableColorSchemesChanged)
Q_PROPERTY(bool selectedText READ selectedText CONSTANT)
public:
/** Constructs a new terminal display widget with the specified parent. */
TerminalDisplay(QQuickItem *parent=0);
@ -362,6 +364,7 @@ public:
};
void setSelection(const QString &t);
bool selectedText();
/**
* Reimplemented. Has no effect. Use setVTFont() to change the font

@ -25,6 +25,7 @@
#include <QFile>
#include "processhelper.h"
#include "utils.h"
int main(int argc, char *argv[])
{
@ -47,6 +48,8 @@ int main(int argc, char *argv[])
}
engine.rootContext()->setContextProperty("Process", new ProcessHelper);
engine.rootContext()->setContextProperty("Utils", new Utils);
engine.addImportPath(QStringLiteral("qrc:/"));
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));

@ -122,6 +122,7 @@ Page {
onPressed: {
if ((!_terminal.terminalUsesMouse || mouse.modifiers & Qt.ShiftModifier)
&& mouse.button == Qt.RightButton) {
updateMenu()
terminalMenu.open()
} else {
var coord = correctDistortion(mouse.x, mouse.y)
@ -141,8 +142,8 @@ Page {
onClicked: {
if (mouse.button === Qt.RightButton) {
updateMenu()
terminalMenu.open()
} else if(mouse.button === Qt.LeftButton) {
_terminal.forceActiveFocus()
}
@ -216,4 +217,9 @@ Page {
return Qt.point((x - cc.width * (1 + distortion) * distortion) * _terminal.width,
(y - cc.height * (1 + distortion) * distortion) * _terminal.height)
}
function updateMenu() {
pasteAction.visible = Utils.text()
copyAction.visible = _terminal.selectedText
}
}

@ -38,7 +38,7 @@ FishUI.Window {
property int currentIndex: -1
property alias currentItem: _view.currentItem
readonly property QMLTermWidget currentTerminal: currentItem.terminal
readonly property QMLTermWidget currentTerminal: currentItem ? currentItem.terminal : null
GlobalSettings { id: settings }
ObjectModel { id: tabsModel }
@ -71,7 +71,7 @@ FishUI.Window {
anchors.leftMargin: FishUI.Units.smallSpacing
anchors.rightMargin: FishUI.Units.smallSpacing
anchors.topMargin: FishUI.Units.smallSpacing
anchors.bottomMargin: FishUI.Units.smallSpacing
anchors.bottomMargin: FishUI.Units.smallSpacing / 2
spacing: FishUI.Units.smallSpacing
ListView {
@ -90,7 +90,7 @@ FishUI.Window {
delegate: Item {
id: _tabItem
height: root.header.height - FishUI.Units.largeSpacing
height: root.header.height - FishUI.Units.largeSpacing + FishUI.Units.smallSpacing / 2
width: Math.min(_layout.implicitWidth + FishUI.Units.largeSpacing,
_tabView.width / _tabView.count - FishUI.Units.smallSpacing)
@ -106,7 +106,8 @@ FishUI.Window {
Rectangle {
anchors.fill: parent
color: isCurrent ? FishUI.Theme.secondBackgroundColor : "transparent"
color: isCurrent ? FishUI.Theme.highlightColor : "transparent"
opacity: 0.1
border.width: 0
radius: FishUI.Theme.smallRadius
}
@ -152,6 +153,7 @@ FishUI.Window {
}
}
ListView {
id: _view
anchors.fill: parent
@ -202,7 +204,6 @@ FishUI.Window {
_view.currentIndex = index
object.terminalClosed.connect(() => closeTab(index))
}
}
function closeTab(index) {

@ -0,0 +1,43 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: Reion Wong <reionwong@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "utils.h"
#include <QApplication>
#include <QClipboard>
static Utils *SELF = nullptr;
Utils *Utils::self()
{
if (!SELF)
SELF = new Utils;
return SELF;
}
Utils::Utils(QObject *parent)
: QObject(parent)
{
}
QString Utils::text() const
{
return qApp->clipboard()->text();
}

@ -0,0 +1,36 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: Reion Wong <reionwong@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTILS_H
#define UTILS_H
#include <QObject>
class Utils : public QObject
{
Q_OBJECT
public:
static Utils *self();
explicit Utils(QObject *parent = nullptr);
Q_INVOKABLE QString text() const;
};
#endif // UTILS_H
Loading…
Cancel
Save