Fixed wrong import

This commit is contained in:
Filippo Scognamiglio
2013-11-23 14:42:15 +01:00
parent 735d1e5dbb
commit d8581dc0c8
45 changed files with 0 additions and 11110 deletions

View File

@@ -1,43 +0,0 @@
/**************************************************************************************************
* Copyright (c) 2012 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
* OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
***************************************************************************************************/
#include <QtGui/QGuiApplication>
#include <QtCore/QResource>
#include <QtCore/QThread>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickItem>
#include "register_qml_types.h"
#include "terminal_screen.h"
#include "yat_pty.h"
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
register_qml_types();
QQuickView view(QUrl("qrc:/qml/yat_declarative/main.qml"));
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.show();
return app.exec();
}

View File

@@ -1,55 +0,0 @@
/*******************************************************************************
* Copyright (c) 2013 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
#include "object_destruct_item.h"
ObjectDestructItem::ObjectDestructItem(QQuickItem *parent)
: QQuickItem(parent)
, m_object(0)
{
}
QObject *ObjectDestructItem::objectHandle() const
{
return m_object;
}
void ObjectDestructItem::setObjectHandle(QObject *object)
{
bool emit_changed = m_object != object;
if (m_object) {
m_object->disconnect(this);
}
m_object = object;
connect(m_object, SIGNAL(destroyed()), this, SLOT(objectDestroyed()));
if (emit_changed)
emit objectHandleChanged();
}
void ObjectDestructItem::objectDestroyed()
{
delete this;
}

View File

@@ -1,52 +0,0 @@
/*******************************************************************************
* Copyright (c) 2013 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
#ifndef OBJECT_DESTRUCT_ITEM_H
#define OBJECT_DESTRUCT_ITEM_H
#include <QtQuick/QQuickItem>
#include <QtCore/QObject>
class ObjectDestructItem : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(QObject *objectHandle READ objectHandle WRITE setObjectHandle NOTIFY objectHandleChanged)
public:
ObjectDestructItem(QQuickItem *parent = 0);
QObject *objectHandle() const;
void setObjectHandle(QObject *line);
signals:
void objectHandleChanged();
private slots:
void objectDestroyed();
private:
QObject *m_object;
};
#endif //OBJECT_DESTRUCT_ITEM_H

View File

@@ -1,75 +0,0 @@
import QtQuick 2.0
Item {
id: highlightArea
property real characterWidth: 0
property real characterHeight: 0
property int screenWidth: width / characterWidth
property point start
property point end
property color color: "grey"
width: parent.width
height: parent.height
opacity: 0.8
Rectangle {
id: begginning_rectangle
color: parent.color
opacity: parent.opacity
y:0
height: characterHeight
}
Rectangle {
id: middle_rectangle
color: parent.color
opacity: parent.opacity
width: parent.width
x: 0
anchors.top: begginning_rectangle.bottom
}
Rectangle {
id: end_rectangle
color: parent.color
opacity: parent.opacity
x: 0
height: characterHeight
anchors.top: middle_rectangle.bottom
}
onCharacterWidthChanged: calculateRectangles();
onCharacterHeightChanged: calculateRectangles();
onScreenWidthChanged: calculateRectangles();
onStartChanged: calculateRectangles();
onEndChanged: calculateRectangles();
function calculateRectangles() {
highlightArea.y = start.y * characterHeight;
begginning_rectangle.x = start.x * characterWidth;
if (start.y === end.y) {
middle_rectangle.visible = false;
end_rectangle.visible = false
begginning_rectangle.width = (end.x - start.x) * characterWidth;
} else {
begginning_rectangle.width = (screenWidth - start.x) * characterWidth;
if (start.y === end.y - 1) {
middle_rectangle.height = 0;
middle_rectangle.visible = false;
}else {
middle_rectangle.visible = true;
middle_rectangle.height = (end.y - start.y - 1) * characterHeight;
}
end_rectangle.visible = true;
end_rectangle.width = end.x * characterWidth;
}
}
}

View File

@@ -1,34 +0,0 @@
import QtQuick 2.0
import org.yat 1.0
ObjectDestructItem {
id: textLine
property var textComponent : Qt.createComponent("TerminalText.qml")
property font font
property real fontHeight
property real fontWidth
height: fontHeight
width: parent.width
visible: objectHandle.visible
Connections {
target: objectHandle
onIndexChanged: {
y = objectHandle.index * fontHeight;
}
onTextCreated: {
var textSegment = textComponent.createObject(textLine,
{
"objectHandle" : text,
"font" : textLine.font,
"fontWidth" : textLine.fontWidth,
})
}
}
}

View File

@@ -1,194 +0,0 @@
import QtQuick 2.0
import org.yat 1.0
TerminalScreen {
id: screenItem
property font font
property real fontWidth: fontMetricText.paintedWidth
property real fontHeight: fontMetricText.paintedHeight
property var lineComponent : Qt.createComponent("TerminalLine.qml")
font.family: "courier"
Text {
id: fontMetricText
text: "B"
font: parent.font
visible: false
textFormat: Text.PlainText
}
Rectangle {
id: background
anchors.fill: parent
color: "black"
}
Connections {
id: connections
target: terminal.screen
onFlash: {
flashAnimation.start()
}
onCursorPositionChanged: {
cursor.x = x * fontWidth;
cursor.y = y * fontHeight;
}
onReset: {
resetScreenItems();
}
onLineCreated: {
var lineVariable = lineComponent.createObject(screenItem,
{
"objectHandle" : line,
"font": screenItem.font,
"fontWidth" : screenItem.fontWidth,
"fontHeight" : screenItem.fontHeight,
})
}
}
onFontChanged: {
setTerminalHeight();
setTerminalWidth();
}
onWidthChanged: {
setTerminalWidth();
}
onHeightChanged: {
setTerminalHeight();
}
Component.onCompleted: {
setTerminalWidth();
setTerminalHeight();
}
function setTerminalWidth() {
if (fontWidth > 0) {
var pty_width = Math.floor(width / fontWidth);
screen.width = pty_width;
}
}
function setTerminalHeight() {
if (fontHeight > 0) {
var pty_height = Math.floor(height / fontHeight);
screen.height = pty_height;
}
}
Item {
id: keyHandler
focus: true
Keys.onPressed: {
terminal.screen.sendKey(event.text, event.key, event.modifiers);
if (event.text === "?") {
terminal.screen.printScreen()
}
}
}
HighlightArea {
characterHeight: fontHeight
characterWidth: fontWidth
start: screen.selectionAreaStart
end: screen.selectionAreaEnd
visible: screen.selectionEnabled
}
Rectangle {
id: cursor
width: fontWidth
height: fontHeight
x: 0
y: 0
color: "grey"
}
Rectangle {
id: flash
anchors.fill: parent
color: "grey"
opacity: 0
SequentialAnimation {
id: flashAnimation
NumberAnimation {
target: flash
property: "opacity"
to: 1
duration: 75
}
NumberAnimation {
target: flash
property: "opacity"
to: 0
duration: 75
}
}
}
MouseArea {
id:mousArea
property point drag_start
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onPressed: {
if (mouse.button == Qt.LeftButton) {
hoverEnabled = true;
var character = Math.floor((mouse.x / screen.charWidth));
var line = Math.floor(mouse.y / screen.lineHeight);
var start = Qt.point(character,line);
drag_start = start;
screen.selectionAreaStart = start;
screen.selectionAreaEnd = start;
}
}
onPositionChanged: {
var character = Math.floor(mouse.x / screen.charWidth);
var line = Math.floor(mouse.y / screen.lineHeight);
var current_pos = Qt.point(character,line);
if (line < drag_start.y || (line === drag_start.y && character < drag_start.x)) {
screen.selectionAreaStart = current_pos;
screen.selectionAreaEnd = drag_start;
}else {
screen.selectionAreaEnd = current_pos;
screen.selectionAreaStart = drag_start;
}
}
onReleased: {
if (mouse.button == Qt.LeftButton) {
hoverEnabled = false;
screen.sendSelectionToSelection();
}
}
onClicked: {
if (mouse.button == Qt.MiddleButton) {
screen.pasteFromSelection();
}
}
onDoubleClicked: {
if (mouse.button == Qt.LeftButton) {
var character = Math.floor(mouse.x / screen.charWidth);
var line = Math.floor(mouse.y / screen.lineHeight);
screen.doubleClicked(Qt.point(character,line));
}
}
}
}

View File

@@ -1,78 +0,0 @@
/*******************************************************************************
* Copyright (c) 2013 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
import QtQuick 2.0
import org.yat 1.0
ObjectDestructItem {
id: textItem
property font font
property real fontWidth
y: 0
x: 0
width: textElement.paintedWidth
height: textElement.paintedHeight
visible: objectHandle.visible
Rectangle {
anchors.fill: parent
color: textItem.objectHandle.backgroundColor
}
Text {
id: textElement
anchors.fill: parent
text: objectHandle.text
color: objectHandle.foregroundColor
font: textItem.font
textFormat: Text.PlainText
}
Connections {
target: objectHandle
onIndexChanged: {
textItem.x = objectHandle.index * textItem.fontWidth;
}
}
//Component.onCompleted: {
// //color = randomBg();
//}
//function randomBg()
//{
// var hex1=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
// var hex2=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
// var hex3=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
// var hex4=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
// var hex5=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
// var hex6=new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
// var bg="#"+hex1[Math.floor(Math.random()*hex1.length)]+hex2[Math.floor(Math.random()*hex2.length)]+hex3[Math.floor(Math.random()*hex3.length)]+hex4[Math.floor(Math.random()*hex4.length)]+hex5[Math.floor(Math.random()*hex5.length)]+hex6[Math.floor(Math.random()*hex6.length)]
// return bg
//}
}

View File

@@ -1,7 +0,0 @@
import QtQuick 2.0
TerminalScreen {
id: terminal
width: 800
height: 600
}

View File

@@ -1,9 +0,0 @@
<RCC>
<qresource prefix="/">
<file>qml/yat_declarative/main.qml</file>
<file>qml/yat_declarative/TerminalLine.qml</file>
<file>qml/yat_declarative/TerminalScreen.qml</file>
<file>qml/yat_declarative/TerminalText.qml</file>
<file>qml/yat_declarative/HighlightArea.qml</file>
</qresource>
</RCC>

View File

@@ -1,18 +0,0 @@
#include "register_qml_types.h"
#include <QtQml>
#include "terminal_screen.h"
#include "object_destruct_item.h"
#include "screen.h"
#include "text.h"
#include "line.h"
void register_qml_types()
{
qmlRegisterType<TerminalScreen>("org.yat", 1, 0, "TerminalScreen");
qmlRegisterType<ObjectDestructItem>("org.yat", 1, 0, "ObjectDestructItem");
qmlRegisterType<Screen>();
qmlRegisterType<Text>();
qmlRegisterType<Line>();
}

View File

@@ -1,6 +0,0 @@
#ifndef REGISTER_QML_TYPES_H
#define REGISTER_QML_TYPES_H
void register_qml_types();
#endif // REGISTER_QML_TYPES_H

View File

@@ -1,32 +0,0 @@
/**************************************************************************************************
* Copyright (c) 2012 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
* OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
***************************************************************************************************/
#include "terminal_screen.h"
TerminalScreen::TerminalScreen(QQuickItem *parent)
: QQuickItem(parent)
, m_screen(new Screen(this))
{
}
Screen *TerminalScreen::screen() const
{
return m_screen;
}

View File

@@ -1,46 +0,0 @@
/******************************************************************************
* Copyright (c) 2012 Jørgen Lind
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
******************************************************************************/
#ifndef TERMINALITEM_H
#define TERMINALITEM_H
#include <QtCore/QObject>
#include <QtQuick/QQuickItem>
#include "screen.h"
class TerminalScreen : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(Screen *screen READ screen CONSTANT)
public:
TerminalScreen(QQuickItem *parent = 0);
Screen *screen() const;
private:
Screen *m_screen;
};
#endif // TERMINALITEM_H

View File

@@ -1,27 +0,0 @@
QT += gui quick
TARGET = yat
include(../backend/backend.pri)
SOURCES += main.cpp \
terminal_screen.cpp \
object_destruct_item.cpp \
register_qml_types.cpp \
HEADERS += \
terminal_screen.h \
object_destruct_item.h \
register_qml_types.h \
QML_IMPORT_PATH =
OTHER_FILES += \
qml/yat_declarative/main.qml \
qml/yat_declarative/TerminalLine.qml \
qml/yat_declarative/TerminalScreen.qml \
qml/yat_declarative/TerminalText.qml \
qml/yat_declarative/HighlightArea.qml
RESOURCES += \
qml_sources.qrc