Commit 24efd650 authored by jbrooks's avatar jbrooks

WIP Port to QtQuick2

parent fed2dfbc
......@@ -17,8 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QApplication>
#include <QWidget>
#include <QGuiApplication>
#include "dbusadaptor.h"
#include "mainwindow.h"
......
QT = core gui declarative opengl dbus
QT = core gui qml quick dbus
contains(MEEGO_EDITION,harmattan): {
CONFIG += meegotouch
......
......@@ -21,7 +21,6 @@
#define KEYLOADER_H
#include <QtCore>
#include <QtDeclarative>
class Util;
......
......@@ -20,8 +20,7 @@
#include "qplatformdefs.h"
#include <QtGui>
#include <QtDeclarative>
#include <QtOpenGL>
#include <QtQml>
extern "C" {
#include <pty.h>
......@@ -52,7 +51,7 @@ int main(int argc, char *argv[])
QSettings *settings = new QSettings(QDir::homePath()+"/.config/FingerTerm/settings.ini", QSettings::IniFormat);
defaultSettings(settings);
// fork the child process before creating QApplication
// fork the child process before creating QGuiApplication
int socketM;
int pid = forkpty(&socketM,NULL,NULL,NULL);
if( pid==-1 ) {
......@@ -94,7 +93,7 @@ int main(int argc, char *argv[])
exit(0);
}
QApplication app(argc, argv);
QGuiApplication app(argc, argv);
qmlRegisterType<TextRender>("TextRender",1,0,"TextRender");
MainWindow view;
......@@ -107,14 +106,6 @@ int main(int argc, char *argv[])
MComponentData::createInstance(argc, argv, "fingerterm", dba);
#endif
#ifdef MEEGO_EDITION_HARMATTAN
if(!app.arguments().contains("-nogl")) {
view.setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer)));
view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
}
#endif
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
Terminal term;
Util util(settings);
term.setUtil(&util);
......@@ -137,7 +128,7 @@ int main(int argc, char *argv[])
qFatal("failure loading keyboard layout");
}
QDeclarativeContext* context = view.rootContext();
QQmlContext *context = view.rootContext();
context->setContextProperty( "term", &term );
context->setContextProperty( "util", &util );
context->setContextProperty( "keyLoader", &keyLoader );
......@@ -159,7 +150,7 @@ int main(int argc, char *argv[])
util.setWindow(&view);
util.setTerm(&term);
util.setRenderer(tr);
view.scene()->installEventFilter(&util); //for grabbing mouse drags
view.installEventFilter(&util); //for grabbing mouse drags
QObject::connect(&term,SIGNAL(displayBufferChanged()),win,SLOT(displayBufferChanged()));
QObject::connect(view.engine(),SIGNAL(quit()),&app,SLOT(quit()));
......@@ -167,10 +158,14 @@ int main(int argc, char *argv[])
#ifdef MEEGO_EDITION_HARMATTAN
view.showFullScreen();
#else
if ((QApplication::desktop()->width() < 1024 || QApplication::desktop()->height() < 768 || app.arguments().contains("-fs"))
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"))
{
view.showFullScreen();
else
} else
view.show();
#endif
......
......@@ -30,8 +30,9 @@
#include <X11/Xatom.h>
#endif //MEEGO_EDITION_HARMATTAN
MainWindow::MainWindow(QWidget* parent): QDeclarativeView(parent)
MainWindow::MainWindow()
{
// setResizeMode(SizeRootObjectToView);
}
MainWindow::~MainWindow()
......@@ -40,19 +41,19 @@ MainWindow::~MainWindow()
void MainWindow::focusInEvent(QFocusEvent *event)
{
QDeclarativeView::focusInEvent(event);
QQuickView::focusInEvent(event);
emit focusChanged(true);
}
void MainWindow::focusOutEvent(QFocusEvent *event)
{
QDeclarativeView::focusOutEvent(event);
QQuickView::focusOutEvent(event);
emit focusChanged(false);
}
void MainWindow::minimize()
{
setWindowState(windowState() | Qt::WindowMinimized);
setWindowState(Qt::WindowMinimized);
}
void MainWindow::disableSwipe()
......
......@@ -20,13 +20,13 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QDeclarativeView>
#include <QQuickView>
class MainWindow : public QDeclarativeView
class MainWindow : public QQuickView
{
Q_OBJECT
public:
explicit MainWindow(QWidget* parent=0);
explicit MainWindow();
virtual ~MainWindow();
void minimize();
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
Rectangle {
id: button
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
Rectangle {
id: key
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
Rectangle {
id: keyboard
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
Rectangle {
id: layoutWindow
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
Rectangle {
id: lineView
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
import TextRender 1.0
Rectangle {
......@@ -32,8 +32,6 @@ Rectangle {
id: window
objectName: "window"
width: 854
height: 480
color: bgcolor
NotifyWin {
......
......@@ -17,7 +17,8 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
import QtQuick.XmlListModel 2.0
Rectangle {
id: menuWin
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
Rectangle {
id: notifyWin
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.0
Rectangle {
id: urlWindow
......
......@@ -9,8 +9,9 @@ URL: https://github.com/nemomobile/fingerterm
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Gui)
BuildRequires: pkgconfig(Qt5OpenGL)
BuildRequires: pkgconfig(Qt5Declarative)
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5Quick)
Requires: qt5-qtdeclarative-import-xmllistmodel
Obsoletes: meego-terminal <= 0.2.2
Provides: meego-terminal > 0.2.2
......
......@@ -17,7 +17,7 @@
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QApplication>
#include <QGuiApplication>
#include <QClipboard>
#include "terminal.h"
......@@ -1142,7 +1142,7 @@ void Terminal::resetTabs()
void Terminal::pasteFromClipboard()
{
QClipboard *cb = QApplication::clipboard();
QClipboard *cb = QGuiApplication::clipboard();
if(cb->mimeData()->hasText() && !cb->mimeData()->text().isEmpty()) {
if(iPtyIFace) {
resetBackBufferScrollPos();
......@@ -1275,7 +1275,7 @@ void Terminal::copySelectionToClipboard()
if (selection().isNull())
return;
QClipboard *cb = QApplication::clipboard();
QClipboard *cb = QGuiApplication::clipboard();
cb->clear();
QString text;
......
......@@ -21,11 +21,11 @@
#define TERMINAL_H
#include <QtCore>
#include <QWidget>
class TextRender;
class PtyIFace;
class Util;
class QQuickView;
struct TermChar {
QChar c;
......@@ -62,7 +62,7 @@ public:
virtual ~Terminal() {}
void setRenderer(TextRender* tr);
void setPtyIFace(PtyIFace* pty);
void setWindow(QWidget* win) { iWindow=win; }
void setWindow(QQuickView* win) { iWindow=win; }
void setUtil(Util* util) { iUtil = util; }
void insertInBuffer(const QString& chars);
......@@ -128,7 +128,7 @@ private:
TextRender* iRenderer;
PtyIFace* iPtyIFace;
QWidget* iWindow;
QQuickView* iWindow;
Util* iUtil;
QList<QList<TermChar> > iBuffer;
......
......@@ -22,15 +22,15 @@
#include "terminal.h"
#include "util.h"
TextRender::TextRender(QDeclarativeItem *parent) :
QDeclarativeItem(parent),
TextRender::TextRender(QQuickItem *parent) :
QQuickPaintedItem(parent),
iTerm(0),
iUtil(0)
{
setFlag(QGraphicsItem::ItemHasNoContents, false);
setFlag(ItemHasContents);
connect(this,SIGNAL(widthChanged(int)),this,SLOT(updateTermSize()));
connect(this,SIGNAL(heightChanged(int)),this,SLOT(updateTermSize()));
connect(this,SIGNAL(myWidthChanged(int)),this,SLOT(updateTermSize()));
connect(this,SIGNAL(myHeightChanged(int)),this,SLOT(updateTermSize()));
connect(this,SIGNAL(fontSizeChanged()),this,SLOT(updateTermSize()));
//normal
......@@ -56,16 +56,13 @@ TextRender::TextRender(QDeclarativeItem *parent) :
qFatal("invalid color table");
iShowBufferScrollIndicator = false;
// caching results in considerably faster redrawing during animations
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
}
TextRender::~TextRender()
{
}
void TextRender::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
void TextRender::paint(QPainter* painter)
{
if (!iTerm)
return;
......@@ -252,7 +249,7 @@ void TextRender::drawTextFragment(QPainter* painter, int x, int y, QString text,
void TextRender::redraw()
{
update(boundingRect());
update();
}
void TextRender::setTerminal(Terminal *term)
......
......@@ -20,18 +20,17 @@
#ifndef TEXTRENDER_H
#define TEXTRENDER_H
#include <QDeclarativeItem>
#include <QQuickPaintedItem>
#include <QPainter>
#include <QGraphicsScene>
#include "terminal.h"
class Util;
class TextRender : public QDeclarativeItem
class TextRender : public QQuickPaintedItem
{
Q_PROPERTY(int myWidth READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(int myHeight READ height WRITE setHeight NOTIFY heightChanged)
Q_PROPERTY(int myWidth READ myWidth WRITE setMyWidth NOTIFY myWidthChanged)
Q_PROPERTY(int myHeight READ myHeight WRITE setMyHeight NOTIFY myHeightChanged)
Q_PROPERTY(int fontWidth READ fontWidth NOTIFY fontSizeChanged)
Q_PROPERTY(int fontHeight READ fontHeight NOTIFY fontSizeChanged)
Q_PROPERTY(int fontPointSize READ fontPointSize WRITE setFontPointSize NOTIFY fontSizeChanged)
......@@ -39,17 +38,17 @@ class TextRender : public QDeclarativeItem
Q_OBJECT
public:
explicit TextRender(QDeclarativeItem *parent = 0);
explicit TextRender(QQuickItem *parent = 0);
virtual ~TextRender();
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
void paint(QPainter*);
void setTerminal(Terminal* term);
void setUtil(Util* util) { iUtil = util; }
int width() { return iWidth; }
int height() { return iHeight; }
void setWidth(int w) { if(iWidth!=w) { iWidth=w; emit widthChanged(w); } }
void setHeight(int h) { if(iHeight!=h) { iHeight=h; emit heightChanged(h); } }
int myWidth() { return iWidth; }
int myHeight() { return iHeight; }
void setMyWidth(int w) { if(iWidth!=w) { iWidth=w; emit myWidthChanged(w); } }
void setMyHeight(int h) { if(iHeight!=h) { iHeight=h; emit myHeightChanged(h); } }
int fontWidth() { return iFontWidth; }
int fontHeight() { return iFontHeight; }
int fontDescent() { return iFontDescent; }
......@@ -62,8 +61,8 @@ public:
Q_INVOKABLE QSize cursorPixelSize();
signals:
void widthChanged(int newWidth);
void heightChanged(int newHeight);
void myWidthChanged(int newWidth);
void myHeightChanged(int newHeight);
void fontSizeChanged();
void showBufferScrollIndicatorChanged();
......@@ -93,6 +92,4 @@ private:
QList<QColor> iColorTable;
};
QML_DECLARE_TYPE(TextRender)
#endif // TEXTRENDER_H
......@@ -22,7 +22,8 @@
#include <QtCore>
#include <QtGui>
#include <QDBusInterface>
#include <QApplication>
#include <QGuiApplication>
#include <QQuickView>
#include "mainwindow.h"
#include "terminal.h"
......@@ -48,7 +49,7 @@ Util::Util(QSettings *settings, QObject *parent) :
swipeModeSet = false;
swipeAllowed = true;
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SIGNAL(clipboardOrSelectionChanged()));
connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), this, SIGNAL(clipboardOrSelectionChanged()));
}
Util::~Util()
......@@ -57,7 +58,7 @@ Util::~Util()
clearNotifications();
}
void Util::setWindow(QWidget* win)
void Util::setWindow(QQuickView* win)
{
iWindow = dynamic_cast<MainWindow*>(win);
if(!iWindow)
......@@ -68,7 +69,7 @@ void Util::setWindow(QWidget* win)
void Util::setWindowTitle(QString title)
{
iCurrentWinTitle = title;
iWindow->setWindowTitle(title);
iWindow->setTitle(title);
emit windowTitleChanged();
}
......@@ -271,39 +272,40 @@ bool Util::eventFilter(QObject *, QEvent *ev)
if(!iAllowGestures)
return false;
if(ev->type()==QEvent::GraphicsSceneMousePress) {
QGraphicsSceneMouseEvent *mev = static_cast<QGraphicsSceneMouseEvent*>(ev);
dragOrigin = mev->scenePos();
if(ev->type()==QEvent::MouseButtonPress) {
QMouseEvent *mev = static_cast<QMouseEvent*>(ev);
dragOrigin = mev->pos();
newSelection = true;
}
else if(ev->type()==QEvent::GraphicsSceneMouseMove) {
QGraphicsSceneMouseEvent *mev = static_cast<QGraphicsSceneMouseEvent*>(ev);
else if(ev->type()==QEvent::MouseMove) {
QMouseEvent *mev = static_cast<QMouseEvent*>(ev);
if(settingsValue("ui/dragMode")=="scroll") {
scrollBackBuffer(mev->scenePos(), mev->lastScenePos());
scrollBackBuffer(mev->pos(), dragOrigin);
dragOrigin = mev->pos();
}
else if(settingsValue("ui/dragMode")=="select" && iRenderer) {
selectionHelper(mev->scenePos());
selectionHelper(mev->pos());
}
}
else if(ev->type()==QEvent::GraphicsSceneMouseRelease) {
QGraphicsSceneMouseEvent *mev = static_cast<QGraphicsSceneMouseEvent*>(ev);
if(settingsValue("ui/dragMode")=="gestures" && mev->lastScenePos() != dragOrigin) {
int xdist = qAbs(mev->scenePos().x() - dragOrigin.x());
int ydist = qAbs(mev->scenePos().y() - dragOrigin.y());
if(mev->scenePos().x() < dragOrigin.x()-reqDragLength && xdist > ydist*2)
else if(ev->type()==QEvent::MouseButtonRelease) {
QMouseEvent *mev = static_cast<QMouseEvent*>(ev);
if(settingsValue("ui/dragMode")=="gestures") {
int xdist = qAbs(mev->pos().x() - dragOrigin.x());
int ydist = qAbs(mev->pos().y() - dragOrigin.y());
if(mev->pos().x() < dragOrigin.x()-reqDragLength && xdist > ydist*2)
doGesture(PanLeft);
else if(mev->scenePos().x() > dragOrigin.x()+reqDragLength && xdist > ydist*2)
else if(mev->pos().x() > dragOrigin.x()+reqDragLength && xdist > ydist*2)
doGesture(PanRight);
else if(mev->scenePos().y() > dragOrigin.y()+reqDragLength && ydist > xdist*2)
else if(mev->pos().y() > dragOrigin.y()+reqDragLength && ydist > xdist*2)
doGesture(PanDown);
else if(mev->scenePos().y() < dragOrigin.y()-reqDragLength && ydist > xdist*2)
else if(mev->pos().y() < dragOrigin.y()-reqDragLength && ydist > xdist*2)
doGesture(PanUp);
}
else if(settingsValue("ui/dragMode")=="scroll") {
scrollBackBuffer(mev->scenePos(), mev->lastScenePos());
scrollBackBuffer(mev->pos(), dragOrigin);
}
else if(settingsValue("ui/dragMode")=="select" && iRenderer) {
selectionHelper(mev->scenePos());
selectionHelper(mev->pos());
selectionFinished();
}
}
......@@ -370,7 +372,7 @@ void Util::notifyText(QString text)
void Util::copyTextToClipboard(QString str)
{
QClipboard *cb = QApplication::clipboard();
QClipboard *cb = QGuiApplication::clipboard();
cb->clear();
cb->setText(str);
}
......@@ -382,7 +384,7 @@ bool Util::terminalHasSelection()
bool Util::canPaste()
{
QClipboard *cb = QApplication::clipboard();
QClipboard *cb = QGuiApplication::clipboard();
if(cb->mimeData()->hasText() && !cb->mimeData()->text().isEmpty())
return true;
......
......@@ -21,11 +21,11 @@
#define UTIL_H
#include <QtCore>
#include <QWidget>
class Terminal;
class MainWindow;
class TextRender;
class QQuickView;
class Util : public QObject
{
......@@ -33,7 +33,7 @@ class Util : public QObject
public:
explicit Util(QSettings* settings, QObject *parent = 0);
virtual ~Util();
void setWindow(QWidget* win);
void setWindow(QQuickView* win);
void setWindowTitle(QString title);
Q_INVOKABLE QString currentWindowTitle();
void setTerm(Terminal* term) { iTerm = term; }
......
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