MauiKit Terminal

terminal_plugin.cpp
1#include "terminal_plugin.h"
2
3#include "TerminalDisplay.h"
4#include "ksession.h"
5#include "customcolorscheme.h"
6
7#include "colorschemesmodel.h"
8
9#include <qqml.h>
10#include <QQmlEngine>
11#include <QDir>
12
13using namespace Konsole;
14
15void TerminalPlugin::registerTypes(const char *uri)
16{
17 // @uri org.qterminal.qmlterminal
18 qmlRegisterType<TerminalDisplay>(uri, 1, 0, "QMLTermWidget");
19 qmlRegisterType<KSession>(uri, 1, 0, "QMLTermSession");
20 qmlRegisterType<ColorSchemesModel>(uri, 1, 0, "ColorSchemesModel");
21 qmlRegisterAnonymousType<CustomColorScheme>(uri, 1);
22
23 qmlRegisterType(componentUrl(QStringLiteral("Terminal.qml")), uri, 1, 0, "Terminal");
24 qmlRegisterType(componentUrl(QStringLiteral("ColorSchemesPage.qml")), uri, 1, 0, "ColorSchemesPage");
25}
26
27void TerminalPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
28{
30
31 QStringList pwds = engine->importPathList();
32
33 if (!pwds.empty()){
34
35
36 QString cs, kbl;
37
38 for (const QString &pwd : pwds) {
39 cs = pwd + "/org/mauikit/terminal/color-schemes";
40 kbl = pwd + "/org/mauikit/terminal/kb-layouts";
41 if (QDir(cs).exists()) break;
42 }
43
44 qDebug() << "MAUIKIT TERMINAL IMPORT PATH LISTS" << pwds << cs << kbl;
45
46 setenv("KB_LAYOUT_DIR",kbl.toUtf8().constData(),1);
47 setenv("COLORSCHEMES_DIR",cs.toUtf8().constData(),1);
48 }
49}
50
51QUrl TerminalPlugin::componentUrl(const QString &fileName) const
52{
53 return QUrl(resolveFileUrl(fileName));
54}
const char * constData() const const
bool empty() const const
QStringList importPathList() const const
virtual void initializeEngine(QQmlEngine *engine, const char *uri) override
QByteArray toUtf8() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:55:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.