Verified Commit 1f497b4f authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Initial import and fixup of old terminal as a standalone app

parents
project(qmlkonsole)
cmake_minimum_required(VERSION 2.8.12)
set(KF5_MIN_VERSION "5.18.0")
set(QT_MIN_VERSION "5.5.0")
################# Disallow in-source build #################
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "This application requires an out of source build. Please create a separate build directory.")
endif()
# Make CPack available to easy generate binary packages
include(CPack)
include(FeatureSummary)
################# set KDE specific information #################
find_package(ECM 0.0.8 REQUIRED NO_MODULE)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(ECMPoQmTools)
include(KDECompilerSettings NO_POLICY_SCOPE)
set(KF5_VERSION "5.22.0")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2)
find_package(KF5Kirigami2 ${KF5_DEP_VERSION} "5.22.0")
################# Enable C++11 features for clang and gcc #################
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x")
endif()
################# now find all used packages #################
set (QT_MIN_VERSION "5.6.0")
find_package(PkgConfig)
#########################################################################
add_subdirectory(src)
install(PROGRAMS org.kde.qmlkonsole.desktop DESTINATION ${KDE_INSTALL_APPDIR})
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
[Desktop Entry]
Type=Application
TryExec=qmlkonsole
Exec=qmlkonsole
Icon=utilities-terminal
Terminal=false
Categories=Qt;KDE;System;TerminalEmulator;
Actions=NewWindow;NewTab;
StartupNotify=true
X-KDE-AuthorizeAction=shell_access
Name=Terminal
GenericName=Terminal
set(qmlkonsole_SRCS
main.cpp
)
qt5_add_resources(RESOURCES resources.qrc)
add_executable(qmlkonsole ${qmlkonsole_SRCS} ${RESOURCES})
target_link_libraries(qmlkonsole Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg)
install(TARGETS qmlkonsole ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
import QtQuick 2.0
import QtQuick.Layouts 1.1
import QMLTermWidget 1.0
import QtQuick.Controls 1.2
import org.kde.kirigami 2.3 as Kirigami
Kirigami.ApplicationWindow {
Action{
onTriggered: terminal.copyClipboard();
shortcut: "Ctrl+Shift+C"
}
Action{
onTriggered: terminal.pasteClipboard();
shortcut: "Ctrl+Shift+V"
}
ColumnLayout {
anchors.fill: parent
QMLTermWidget {
id: terminal
Layout.fillWidth: true
Layout.fillHeight: true
font.family: "Monospace"
font.pointSize: 7
colorScheme: "cool-retro-term"
session: QMLTermSession{
id: mainsession
initialWorkingDirectory: "$HOME"
onMatchFound: {
console.log("found at: %1 %2 %3 %4".arg(startColumn).arg(startLine).arg(endColumn).arg(endLine));
}
onNoMatchFound: {
console.log("not found");
}
}
onTerminalUsesMouseChanged: console.log(terminalUsesMouse);
onTerminalSizeChanged: console.log(terminalSize);
Component.onCompleted: mainsession.startShellProgram();
QMLTermScrollbar {
terminal: terminal
width: 20
Rectangle {
opacity: 0.4
anchors.margins: 5
radius: width * 0.5
anchors.fill: parent
}
}
MouseArea {
anchors.fill: parent
property real oldY
onPressed: oldY = mouse.y
onPositionChanged: {
terminal.simulateWheel(0, 0, 0, 0, Qt.point(0, (mouse.y - oldY)*2))
oldY = mouse.y
}
onClicked: {
Qt.inputMethod.show();
}
}
}
RowLayout {
ToolButton {
Layout.maximumWidth: height
text: "Tab"
onClicked: terminal.simulateKeyPress(Qt.Key_Tab, 0, true, 0, "")
}
ToolButton {
Layout.maximumWidth: height
text: "←"
onClicked: terminal.simulateKeyPress(Qt.Key_Left, 0, true, 0, "")
}
ToolButton {
Layout.maximumWidth: height
text: "↑"
onClicked: terminal.simulateKeyPress(Qt.Key_Up, 0, true, 0, "")
}
ToolButton {
Layout.maximumWidth: height
text: "→"
onClicked: terminal.simulateKeyPress(Qt.Key_Right, 0, true, 0, "")
}
ToolButton {
Layout.maximumWidth: height
text: "↓"
onClicked: terminal.simulateKeyPress(Qt.Key_Down, 0, true, 0, "")
}
ToolButton {
Layout.maximumWidth: height
text: "|"
onClicked: terminal.simulateKeyPress(Qt.Key_Bar, 0, true, 0, "|")
}
ToolButton {
Layout.maximumWidth: height
text: "~"
onClicked: terminal.simulateKeyPress(Qt.Key_AsciiTilde, 0, true, 0, "~")
}
}
Item {
Layout.minimumHeight: Qt.inputMethod.keyboardRectangle.height
Layout.fillWidth: true
}
}
Component.onCompleted: terminal.forceActiveFocus();
}
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QUrl>
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QCoreApplication::setOrganizationName("KDE");
QCoreApplication::setOrganizationDomain("kde.org");
QCoreApplication::setApplicationName("QMLKonsole");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
if (engine.rootObjects().isEmpty()) {
return -1;
}
int ret = app.exec();
return ret;
}
<RCC>
<qresource prefix="/">
<file alias="main.qml">contents/ui/main.qml</file>
</qresource>
</RCC>
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