Commit 1d0fc679 authored by pvuorela's avatar pvuorela

Merge branch 'noresources' into 'master'

[fingerterm] Install QML files, icons and data under /usr/share/fingerterm instead of using resources.

See merge request !22
parents e28ec34b 02f08cac
......@@ -15,6 +15,8 @@ isEmpty(DEFAULT_FONT) {
DEFAULT_FONT = monospace
}
DEPLOYMENT_PATH = /usr/share/$$TARGET
DEFINES += DEPLOYMENT_PATH=\\\"$$DEPLOYMENT_PATH\\\"
DEFINES += DEFAULT_FONTFAMILY=\\\"$$DEFAULT_FONT\\\"
TEMPLATE = app
......@@ -40,8 +42,7 @@ SOURCES += \
util.cpp \
keyloader.cpp
OTHER_FILES += \
qml/Main.qml \
qml.files = qml/Main.qml \
qml/Keyboard.qml \
qml/Key.qml \
qml/Lineview.qml \
......@@ -51,10 +52,34 @@ OTHER_FILES += \
qml/UrlWindow.qml \
qml/LayoutWindow.qml \
qml/PopupWindow.qml
qml.path = $$DEPLOYMENT_PATH
INSTALLS += qml
RESOURCES += \
resources.qrc
icons.files = icons/backspace.png \
icons/down.png \
icons/enter.png \
icons/left.png \
icons/menu.png \
icons/right.png \
icons/scroll-indicator.png \
icons/shift.png \
icons/tab.png \
icons/up.png
icons.path = $$DEPLOYMENT_PATH/icons
INSTALLS += icons
userdata.files = data/menu.xml \
data/english.layout \
data/finnish.layout \
data/french.layout \
data/german.layout \
data/qwertz.layout
userdata.path = $$DEPLOYMENT_PATH/data
INSTALLS += userdata
target.path = /usr/bin
INSTALLS += target
......
......@@ -49,6 +49,8 @@ bool KeyLoader::loadLayout(QString layout)
}
else { // load from file
QFile f(iUtil->configPath() + "/" + layout + ".layout");
if (!f.exists()) // fallback to installation directory
f.setFileName(QStringLiteral(DEPLOYMENT_PATH) + "/data/" + layout + ".layout");
ret = loadLayoutInternal(f);
}
......@@ -197,6 +199,15 @@ const QStringList KeyLoader::availableLayouts()
ret << s.left(s.lastIndexOf('.'));
}
// Add also layouts from installation path.
QDir dataDir(QStringLiteral(DEPLOYMENT_PATH) + "/data");
results = dataDir.entryList(filter, QDir::Files|QDir::Readable, QDir::Name);
foreach(QString s, results) {
QString layout = s.left(s.lastIndexOf('.'));
if (!ret.contains(layout))
ret << layout;
}
return ret;
}
......
......@@ -40,8 +40,6 @@ extern "C" {
#include "version.h"
#include "keyloader.h"
static void copyFileFromResources(QString from, QString to);
int main(int argc, char *argv[])
{
QString settings_path(QDir::homePath() + "/.config/FingerTerm");
......@@ -131,14 +129,6 @@ int main(int argc, char *argv[])
QString startupErrorMsg;
// copy the default config files to the config dir if they don't already exist
copyFileFromResources(":/data/menu.xml", util.configPath()+"/menu.xml");
copyFileFromResources(":/data/english.layout", util.configPath()+"/english.layout");
copyFileFromResources(":/data/finnish.layout", util.configPath()+"/finnish.layout");
copyFileFromResources(":/data/french.layout", util.configPath()+"/french.layout");
copyFileFromResources(":/data/german.layout", util.configPath()+"/german.layout");
copyFileFromResources(":/data/qwertz.layout", util.configPath()+"/qwertz.layout");
KeyLoader keyLoader;
keyLoader.setUtil(&util);
bool ret = keyLoader.loadLayout(util.keyboardLayout());
......@@ -164,7 +154,8 @@ int main(int argc, char *argv[])
QObject::connect(view.engine(),SIGNAL(quit()),&app,SLOT(quit()));
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setSource(QUrl("qrc:/qml/Main.qml"));
view.engine()->addImportPath(QStringLiteral(DEPLOYMENT_PATH));
view.setSource(QUrl::fromLocalFile(QStringLiteral(DEPLOYMENT_PATH) + QDir::separator() + QStringLiteral("Main.qml")));
QObject *root = view.rootObject();
if(!root)
......@@ -183,19 +174,3 @@ int main(int argc, char *argv[])
return app.exec();
}
static void copyFileFromResources(QString from, QString to)
{
// copy a file from resources to the config dir if it does not exist there
QFileInfo toFile(to);
if(!toFile.exists()) {
QFile newToFile(toFile.absoluteFilePath());
QResource res(from);
if (newToFile.open(QIODevice::WriteOnly)) {
newToFile.write( reinterpret_cast<const char*>(res.data()) );
newToFile.close();
} else {
qWarning() << "Failed to copy default config from resources to" << toFile.filePath();
}
}
}
......@@ -48,7 +48,7 @@ Rectangle {
id: keyImage
anchors.centerIn: parent
opacity: key.labelOpacity
source: { if(key.label.length>1 && key.label.charAt(0)==':') return "qrc:/icons/"+key.label.substring(1)+".png"; else return ""; }
source: { if(key.label.length>1 && key.label.charAt(0)==':') return "icons/"+key.label.substring(1)+".png"; else return ""; }
scale: window.pixelRatio
}
......
......@@ -184,14 +184,14 @@ Item {
id: menuImg
anchors.centerIn: parent
source: "qrc:/icons/menu.png"
source: "icons/menu.png"
scale: window.pixelRatio
}
}
Image {
// terminal buffer scroll indicator
source: "qrc:/icons/scroll-indicator.png"
source: "icons/scroll-indicator.png"
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
visible: textrender.showBufferScrollIndicator
......
<RCC>
<qresource prefix="/">
<file>qml/Main.qml</file>
<file>qml/Key.qml</file>
<file>qml/Keyboard.qml</file>
<file>qml/Lineview.qml</file>
<file>qml/Button.qml</file>
<file>qml/MenuFingerterm.qml</file>
<file>qml/NotifyWin.qml</file>
<file>qml/PopupWindow.qml</file>
<file>icons/backspace.png</file>
<file>icons/down.png</file>
<file>icons/enter.png</file>
<file>icons/left.png</file>
<file>icons/menu.png</file>
<file>icons/right.png</file>
<file>icons/shift.png</file>
<file>icons/tab.png</file>
<file>icons/up.png</file>
<file>qml/UrlWindow.qml</file>
<file>data/menu.xml</file>
<file>icons/scroll-indicator.png</file>
<file>data/english.layout</file>
<file>data/finnish.layout</file>
<file>data/french.layout</file>
<file>data/german.layout</file>
<file>data/qwertz.layout</file>
<file>qml/LayoutWindow.qml</file>
</qresource>
</RCC>
Name: fingerterm
Version: 1.3.2
Version: 1.3.5
Release: 1
Summary: A terminal emulator with a custom virtual keyboard
Group: System/Base
......@@ -24,7 +24,9 @@ Provides: meego-terminal > 0.2.2
%defattr(-,root,root,-)
%{_bindir}/*
%{_datadir}/applications/*.desktop
%{_datadir}/%{name}/*.qml
%{_datadir}/%{name}/data/*
%{_datadir}/%{name}/icons/*
%prep
%setup -q -n %{name}-%{version}
......
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