Skip to content

Commit

Permalink
[port] WIP more work on QtQuick2 port + disables clipboard support
Browse files Browse the repository at this point in the history
  • Loading branch information
faenil committed Aug 7, 2013
1 parent 24efd65 commit f8573e5
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 80 deletions.
2 changes: 0 additions & 2 deletions main.cpp
Expand Up @@ -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"))
{
Expand Down
1 change: 0 additions & 1 deletion mainwindow.cpp
Expand Up @@ -32,7 +32,6 @@

MainWindow::MainWindow()
{
// setResizeMode(SizeRootObjectToView);
}

MainWindow::~MainWindow()
Expand Down
70 changes: 37 additions & 33 deletions qml/Main.qml
Expand Up @@ -19,6 +19,7 @@

import QtQuick 2.0
import TextRender 1.0
import QtQuick.Window 2.0

Rectangle {
property string fgcolor: "black"
Expand All @@ -30,6 +31,9 @@ Rectangle {

property string windowTitle: util.currentWindowTitle();

width: Screen.width
height: Screen.height

id: window
objectName: "window"
color: bgcolor
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions rpm/fingerterm.spec
Expand Up @@ -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

Expand Down
96 changes: 56 additions & 40 deletions terminal.cpp
Expand Up @@ -19,6 +19,7 @@

#include <QGuiApplication>
#include <QClipboard>
#include <QDebug>

#include "terminal.h"
#include "ptyiface.h"
Expand Down Expand Up @@ -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());
}
}
}
}
Expand Down Expand Up @@ -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)
Expand Down
27 changes: 23 additions & 4 deletions util.cpp
Expand Up @@ -24,6 +24,7 @@
#include <QDBusInterface>
#include <QGuiApplication>
#include <QQuickView>
#include <QDebug>

#include "mainwindow.h"
#include "terminal.h"
Expand Down Expand Up @@ -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()
Expand All @@ -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;
}
Expand Down

0 comments on commit f8573e5

Please sign in to comment.