Commit f8573e52 authored by faenil's avatar faenil

[port] WIP more work on QtQuick2 port + disables clipboard support

parent 24efd650
......@@ -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"))
{
......
......@@ -32,7 +32,6 @@
MainWindow::MainWindow()
{
// setResizeMode(SizeRootObjectToView);
}
MainWindow::~MainWindow()
......
......@@ -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
......
......@@ -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
......
......@@ -19,6 +19,7 @@
#include <QGuiApplication>
#include <QClipboard>
#include <QDebug>
#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)
......
......@@ -24,6 +24,7 @@
#include <QDBusInterface>
#include <QGuiApplication>
#include <QQuickView>
#include <QDebug>
#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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment