Commit 57556f42 authored by Sebastian Gottfried's avatar Sebastian Gottfried

Install QML Files As Qt Resource

parent d41f3f91
......@@ -83,6 +83,8 @@ set(ktouch_SRCS
ktouchcontext.cpp
)
qt5_add_resources(ktouch_SRCS qml/qml.qrc)
# compile UI files
ki18n_wrap_ui(ktouch_SRCS
ui/colorsconfigwidget.ui
......@@ -149,4 +151,3 @@ target_link_libraries(ktouch
install(TARGETS ktouch ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ktouch.kcfg DESTINATION ${KCFG_INSTALL_DIR})
install(DIRECTORY qml/ DESTINATION ${DATA_INSTALL_DIR}/ktouch/qml FILES_MATCHING PATTERN "*.qml")
......@@ -27,7 +27,7 @@ Utils::Utils(QObject* parent):
{
}
QString Utils::findImage(QString name)
QUrl Utils::findImage(QString name)
{
const QString relPath = QString("images/") + name;
const QString path = QStandardPaths::locate(QStandardPaths::DataLocation, relPath);
......@@ -35,9 +35,10 @@ QString Utils::findImage(QString name)
if (path.isNull())
{
qWarning() << "can't find image resource:" << name;
return QUrl();
}
return path;
return QUrl::fromLocalFile(path);
}
int Utils::getMinutesOfQTime(const QTime& time)
......
......@@ -20,13 +20,14 @@
#include <QObject>
#include <QTime>
#include <QUrl>
class Utils : public QObject
{
Q_OBJECT
public:
explicit Utils(QObject* parent = 0);
Q_INVOKABLE QString findImage(QString name);
Q_INVOKABLE QUrl findImage(QString name);
Q_INVOKABLE int getMinutesOfQTime(const QTime& time);
Q_INVOKABLE int getSecondsOfQTime(const QTime& time);
Q_INVOKABLE QString uuid();
......
......@@ -52,7 +52,7 @@ KeyboardLayoutEditor::KeyboardLayoutEditor(QWidget* parent):
Application::setupDeclarativeBindings(m_view->engine());
m_view->rootContext()->setContextProperty("keyboardLayoutEditor", this);
m_view->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, "qml/keyboard/KeyboardLayoutEditor.qml")));
m_view->setSource(QUrl("qrc:/qml/keyboard/KeyboardLayoutEditor.qml"));
connect(m_newKeyToolButton, SIGNAL(clicked()), SLOT(createNewKey()));
connect(m_newSpecialKeyToolButton, SIGNAL(clicked()), SLOT(createNewSpecialKey()));
......
......@@ -54,7 +54,7 @@ void MainWindow::init()
m_view->connect(m_view, &QQuickView::statusChanged, this, &MainWindow::onViewStatusChanged);
m_view->rootContext()->setContextProperty(QStringLiteral("ktouch"), m_context);
m_view->setResizeMode(QQuickView::SizeRootObjectToView);
m_view->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, "qml/main.qml")));
m_view->setSource(QUrl("qrc:/qml/main.qml"));
}
void MainWindow::onViewStatusChanged(QQuickView::Status status)
......
<RCC>
<qresource prefix="/qml">
<file>main.qml</file>
<file>meters/AccuracyMeter.qml</file>
<file>meters/CharactersPerMinuteMeter.qml</file>
<file>meters/ElapsedTimeMeter.qml</file>
<file>meters/Meter.qml</file>
<file>meters/StatBox.qml</file>
<file>common/DetailedRadioButton.qml</file>
<file>common/InfoItem.qml</file>
<file>common/InformationTable.qml</file>
<file>common/InlineToolbar.qml</file>
<file>common/LearningProgressChart.qml</file>
<file>common/ListItem.qml</file>
<file>common/MessageBox.qml</file>
<file>common/SelectionGrip.qml</file>
<file>common/SelectionRectangle.qml</file>
<file>common/SheetDialog.qml</file>
<file>common/Balloon.qml</file>
<file>scorescreen/ScoreScreen.qml</file>
<file>trainingscreen/KeyboardUnavailableNotice.qml</file>
<file>trainingscreen/TrainingScreenMenuOverlay.qml</file>
<file>trainingscreen/TrainingScreen.qml</file>
<file>trainingscreen/TrainingScreenToolbar.qml</file>
<file>trainingscreen/TrainingWidget.qml</file>
<file>homescreen/CourseDescriptionItem.qml</file>
<file>homescreen/CoursePage.qml</file>
<file>homescreen/CourseSelector.qml</file>
<file>homescreen/InitialProfileForm.qml</file>
<file>homescreen/LessonLockedNotice.qml</file>
<file>homescreen/LessonPreview.qml</file>
<file>homescreen/LessonSelectorBase.qml</file>
<file>homescreen/HomeScreen.qml</file>
<file>homescreen/CustomLessonSelector.qml</file>
<file>homescreen/ProfileForm.qml</file>
<file>homescreen/LessonSelector.qml</file>
<file>homescreen/ProfileSelector.qml</file>
<file>homescreen/ProfileDetailsItem.qml</file>
<file>keyboard/Keyboard.qml</file>
<file>keyboard/KeyItem.qml</file>
<file>keyboard/KeyLabel.qml</file>
<file>keyboard/KeyboardLayoutEditor.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