diff --git a/main.cpp b/main.cpp index b122112..4ff75be 100644 --- a/main.cpp +++ b/main.cpp @@ -159,8 +159,6 @@ int main(int argc, char *argv[]) view.showFullScreen(); #else QSize screenSize = QGuiApplication::primaryScreen()->size(); - view.rootObject()->setWidth(screenSize.width()); - view.rootObject()->setHeight(screenSize.height()); if ((screenSize.width() < 1024 || screenSize.height() < 768 || app.arguments().contains("-fs")) && !app.arguments().contains("-nofs")) { diff --git a/mainwindow.cpp b/mainwindow.cpp index d4a498f..f50b2fc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -32,7 +32,6 @@ MainWindow::MainWindow() { -// setResizeMode(SizeRootObjectToView); } MainWindow::~MainWindow() diff --git a/qml/Main.qml b/qml/Main.qml index 0a82138..838a1eb 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -19,6 +19,7 @@ import QtQuick 2.0 import TextRender 1.0 +import QtQuick.Window 2.0 Rectangle { property string fgcolor: "black" @@ -30,6 +31,9 @@ Rectangle { property string windowTitle: util.currentWindowTitle(); + width: Screen.width + height: Screen.height + id: window objectName: "window" color: bgcolor @@ -77,39 +81,6 @@ Rectangle { z: 1000 } - TextRender { - id: textrender - objectName: "textrender" - x: 0 - y: 0 - height: parent.height - width: parent.width - myWidth: width - myHeight: height - opacity: 1.0 - property int duration: 0; - property int cutAfter: height - - Behavior on opacity { - NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } - } - Behavior on y { - NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } - } - - onFontSizeChanged: { - lineView.fontPointSize = textrender.fontPointSize; - } - - onCutAfterChanged: { - // this property is used in the paint function, so make sure that the element gets - // painted with the updated value (might not otherwise happen because of caching) - textrender.redraw(); - } - - z: 10 - } - Lineview { id: lineView @@ -189,6 +160,39 @@ Rectangle { vkbKeypress(event.key,event.modifiers); } + TextRender { + id: textrender + objectName: "textrender" + x: 0 + y: 0 + height: parent.height + width: parent.width + myWidth: width + myHeight: height + opacity: 1.0 + property int duration: 0; + property int cutAfter: height + + Behavior on opacity { + NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } + } + Behavior on y { + NumberAnimation { duration: textrender.duration; easing.type: Easing.InOutQuad } + } + + onFontSizeChanged: { + lineView.fontPointSize = textrender.fontPointSize; + } + + onCutAfterChanged: { + // this property is used in the paint function, so make sure that the element gets + // painted with the updated value (might not otherwise happen because of caching) + textrender.redraw(); + } + + z: 10 + } + Timer { id: fadeTimer running: false diff --git a/rpm/fingerterm.spec b/rpm/fingerterm.spec index 3236c76..c64f96d 100644 --- a/rpm/fingerterm.spec +++ b/rpm/fingerterm.spec @@ -12,6 +12,7 @@ BuildRequires: pkgconfig(Qt5Gui) BuildRequires: pkgconfig(Qt5Qml) BuildRequires: pkgconfig(Qt5Quick) Requires: qt5-qtdeclarative-import-xmllistmodel +Requires: qt5-qtdeclarative-import-window2 Obsoletes: meego-terminal <= 0.2.2 Provides: meego-terminal > 0.2.2 diff --git a/terminal.cpp b/terminal.cpp index 13a2ca7..5270d6d 100644 --- a/terminal.cpp +++ b/terminal.cpp @@ -19,6 +19,7 @@ #include #include +#include #include "terminal.h" #include "ptyiface.h" @@ -1143,10 +1144,18 @@ void Terminal::resetTabs() void Terminal::pasteFromClipboard() { QClipboard *cb = QGuiApplication::clipboard(); - if(cb->mimeData()->hasText() && !cb->mimeData()->text().isEmpty()) { - if(iPtyIFace) { - resetBackBufferScrollPos(); - iPtyIFace->writeTerm(cb->mimeData()->text()); + + //mimeData() could be null when the clipboard QPA plugin of the platform doesn't support QClipboard::Clipboard, or + //the plugin is bugged. + //In those cases, disable clipboard features. + if(!cb->mimeData()) + qDebug() << "FIXME: QClipboard::mimeData() returned NULL, the clipboard functionality will not be used"; + else { + if(cb->mimeData()->hasText() && !cb->mimeData()->text().isEmpty()) { + if(iPtyIFace) { + resetBackBufferScrollPos(); + iPtyIFace->writeTerm(cb->mimeData()->text()); + } } } } @@ -1275,58 +1284,65 @@ void Terminal::copySelectionToClipboard() if (selection().isNull()) return; + //mimeData() could be null when the clipboard QPA plugin of the platform doesn't support QClipboard::Clipboard, or + //the plugin is bugged. + //In those cases, disable clipboard features. QClipboard *cb = QGuiApplication::clipboard(); - cb->clear(); - - QString text; - QString line; - - // backbuffer - if (iBackBufferScrollPos > 0 && !iUseAltScreenBuffer) { - int lineFrom = iBackBuffer.size() - iBackBufferScrollPos + selection().top() - 1; - int lineTo = iBackBuffer.size() - iBackBufferScrollPos + selection().bottom() - 1; + if(!cb->mimeData()) + qDebug() << "FIXME: QClipboard::mimeData() returned NULL, the clipboard functionality will not be used"; + else { + cb->clear(); + + QString text; + QString line; + + // backbuffer + if (iBackBufferScrollPos > 0 && !iUseAltScreenBuffer) { + int lineFrom = iBackBuffer.size() - iBackBufferScrollPos + selection().top() - 1; + int lineTo = iBackBuffer.size() - iBackBufferScrollPos + selection().bottom() - 1; + + for (int i=lineFrom; i<=lineTo; i++) { + if (i >= 0 && i < iBackBuffer.size()) { + line.clear(); + int start = 0; + int end = iBackBuffer[i].size()-1; + if (i==lineFrom) + start = selection().left()-1; + if (i==lineTo) + end = selection().right()-1; + for (int j=start; j<=end; j++) { + if (j >= 0 && j < iBackBuffer[i].size() && iBackBuffer[i][j].c.isPrint()) + line += iBackBuffer[i][j].c; + } + text += line.trimmed() + "\n"; + } + } + } + // main buffer + int lineFrom = selection().top()-1-iBackBufferScrollPos; + int lineTo = selection().bottom()-1-iBackBufferScrollPos; for (int i=lineFrom; i<=lineTo; i++) { - if (i >= 0 && i < iBackBuffer.size()) { + if (i >= 0 && i < buffer().size()) { line.clear(); int start = 0; - int end = iBackBuffer[i].size()-1; + int end = buffer()[i].size()-1; if (i==lineFrom) start = selection().left()-1; if (i==lineTo) end = selection().right()-1; for (int j=start; j<=end; j++) { - if (j >= 0 && j < iBackBuffer[i].size() && iBackBuffer[i][j].c.isPrint()) - line += iBackBuffer[i][j].c; + if (j >= 0 && j < buffer()[i].size() && buffer()[i][j].c.isPrint()) + line += buffer()[i][j].c; } text += line.trimmed() + "\n"; } } - } - - // main buffer - int lineFrom = selection().top()-1-iBackBufferScrollPos; - int lineTo = selection().bottom()-1-iBackBufferScrollPos; - for (int i=lineFrom; i<=lineTo; i++) { - if (i >= 0 && i < buffer().size()) { - line.clear(); - int start = 0; - int end = buffer()[i].size()-1; - if (i==lineFrom) - start = selection().left()-1; - if (i==lineTo) - end = selection().right()-1; - for (int j=start; j<=end; j++) { - if (j >= 0 && j < buffer()[i].size() && buffer()[i][j].c.isPrint()) - line += buffer()[i][j].c; - } - text += line.trimmed() + "\n"; - } - } - //qDebug() << text.trimmed(); + //qDebug() << text.trimmed(); - cb->setText(text.trimmed()); + cb->setText(text.trimmed()); + } } void Terminal::adjustSelectionPosition(int lines) diff --git a/util.cpp b/util.cpp index c348b13..be4fcd4 100644 --- a/util.cpp +++ b/util.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "mainwindow.h" #include "terminal.h" @@ -373,8 +374,15 @@ void Util::notifyText(QString text) void Util::copyTextToClipboard(QString str) { QClipboard *cb = QGuiApplication::clipboard(); - cb->clear(); - cb->setText(str); + //mimeData() could be null when the clipboard QPA plugin of the platform doesn't support QClipboard::Clipboard, or + //the plugin is bugged. + //In those cases, disable clipboard features. + if(!cb->mimeData()) + qDebug() << "FIXME: QClipboard::mimeData() returned NULL, the clipboard functionality will not be used"; + else { + cb->clear(); + cb->setText(str); + } } bool Util::terminalHasSelection() @@ -384,9 +392,20 @@ bool Util::terminalHasSelection() bool Util::canPaste() { + QClipboard *cb = QGuiApplication::clipboard(); - if(cb->mimeData()->hasText() && !cb->mimeData()->text().isEmpty()) - return true; + + //mimeData() could be null when the clipboard QPA plugin of the platform doesn't support QClipboard::Clipboard, or + //the plugin is bugged. + //In those cases, disable clipboard features. + if(!cb->mimeData()) { + qDebug() << "FIXME: QClipboard::mimeData() returned NULL, the clipboard functionality will not be used"; + return false; + } + else { + if(cb->mimeData()->hasText() && !cb->mimeData()->text().isEmpty()) + return true; + } return false; }