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 73 additions and 36 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
16 changes: 16 additions & 0 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,13 +1144,21 @@ void Terminal::resetTabs()
void Terminal::pasteFromClipboard()
{
QClipboard *cb = QGuiApplication::clipboard();

//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());
}
}
}
}

const QStringList Terminal::grabURLsFromBuffer()
{
Expand Down Expand Up @@ -1275,7 +1284,13 @@ 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();
if(!cb->mimeData())
qDebug() << "FIXME: QClipboard::mimeData() returned NULL, the clipboard functionality will not be used";
else {
cb->clear();

QString text;
Expand Down Expand Up @@ -1328,6 +1343,7 @@ void Terminal::copySelectionToClipboard()

cb->setText(text.trimmed());
}
}

void Terminal::adjustSelectionPosition(int lines)
{
Expand Down
19 changes: 19 additions & 0 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,9 +374,16 @@ void Util::notifyText(QString text)
void Util::copyTextToClipboard(QString str)
{
QClipboard *cb = QGuiApplication::clipboard();
//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();

//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.