summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Gottfried <sebastiangottfried@web.de>2015-05-27 15:32:41 (GMT)
committerSebastian Gottfried <sebastiangottfried@web.de>2015-05-27 15:32:41 (GMT)
commit570d74cbf76da96e18ecc715acf4bbb8053a2bf7 (patch)
tree7fd4d8b562b6b1b6916d23406ab4ae0e9c9c3533
parent0a6cddf30daa20da9175f9ce42328e178d40e080 (diff)
Port to Qt5/KF5: It builds!
Only the C++ part is ported, no changes to the QML files yet. This means the app compiles, but is far from functional. In fact it just presents an empty windows so far. Porting was straight-forward, no earth-shattering changes. Just the usual stuff.
-rw-r--r--CMakeLists.txt58
-rw-r--r--data/CMakeLists.txt6
-rw-r--r--doc/CMakeLists.txt8
-rw-r--r--icons/CMakeLists.txt12
-rw-r--r--src/CMakeLists.txt93
-rw-r--r--src/application.cpp38
-rw-r--r--src/application.h17
-rw-r--r--src/bindings/utils.cpp93
-rw-r--r--src/bindings/utils.h20
-rw-r--r--src/core/course.cpp4
-rw-r--r--src/core/dbaccess.cpp59
-rw-r--r--src/core/keyboardlayout.cpp3
-rw-r--r--src/core/keychar.cpp2
-rw-r--r--src/core/profiledataaccess.cpp94
-rw-r--r--src/core/resource.h1
-rw-r--r--src/core/resourcedataaccess.cpp38
-rw-r--r--src/core/userdataaccess.cpp72
-rw-r--r--src/declarativeitems/applicationbackground.cpp40
-rw-r--r--src/declarativeitems/applicationbackground.h32
-rw-r--r--src/declarativeitems/cursorshapearea.cpp40
-rw-r--r--src/declarativeitems/cursorshapearea.h42
-rw-r--r--src/declarativeitems/griditem.cpp8
-rw-r--r--src/declarativeitems/griditem.h8
-rw-r--r--src/declarativeitems/lessonpainter.cpp9
-rw-r--r--src/declarativeitems/lessonpainter.h11
-rw-r--r--src/declarativeitems/preferencesproxy.cpp2
-rw-r--r--src/declarativeitems/scalebackgrounditem.cpp8
-rw-r--r--src/declarativeitems/scalebackgrounditem.h8
-rw-r--r--src/declarativeitems/traininglinecore.cpp12
-rw-r--r--src/declarativeitems/traininglinecore.h14
-rw-r--r--src/editor/charactersviewdelegate.cpp2
-rw-r--r--src/editor/courseeditor.cpp3
-rw-r--r--src/editor/keyboardlayouteditor.cpp12
-rw-r--r--src/editor/keyboardlayouteditorview.cpp5
-rw-r--r--src/editor/keyboardlayouteditorview.h4
-rw-r--r--src/editor/keyboardlayoutpropertieswidget.cpp12
-rw-r--r--src/editor/keyboardlayoutpropertieswidget.h1
-rw-r--r--src/editor/lessontexteditor.cpp6
-rw-r--r--src/editor/lessontexthighlighter.cpp1
-rw-r--r--src/editor/newkeyboardlayoutwidget.cpp2
-rw-r--r--src/editor/newresourceassistant.h1
-rw-r--r--src/editor/resourceeditor.cpp52
-rw-r--r--src/editor/resourceeditor.h12
-rw-r--r--src/editor/resourceeditorwidget.cpp10
-rw-r--r--src/editor/resourceeditorwidget.h6
-rw-r--r--src/editor/resourcetemplatewidget.cpp2
-rw-r--r--src/editor/resourcetypeswidget.cpp3
-rw-r--r--src/keyboardlayoutmenu.cpp7
-rw-r--r--src/main.cpp89
-rw-r--r--src/mainwindow.cpp72
-rw-r--r--src/mainwindow.h7
-rw-r--r--src/models/categorizedresourcesortfilterproxymodel.cpp7
-rw-r--r--src/models/charactersmodel.cpp2
-rw-r--r--src/models/lessonmodel.cpp2
-rw-r--r--src/models/resourcemodel.cpp22
-rw-r--r--src/models/resourcemodel.h1
-rw-r--r--src/ui/keyboardlayouteditor.ui51
-rw-r--r--src/ui/trainingconfigwidget.ui72
-rw-r--r--src/undocommands/coursecommands.cpp2
-rw-r--r--src/undocommands/keyboardlayoutcommands.cpp2
60 files changed, 551 insertions, 771 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 29960e8..82896fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,22 +3,56 @@
project(ktouch)
-find_package(KDE4 4.9.95 REQUIRED)
-include(KDE4Defaults)
+cmake_minimum_required(VERSION 2.8.12)
+find_package(ECM 1.0.0 REQUIRED NO_MODULE)
+find_package(KF5DocTools)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
-include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${QT4_INCLUDES})
-add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+include(KDEInstallDirs)
+include(ECMAddTests)
+include(KDECMakeSettings)
+include(KDECompilerSettings)
+include(ECMInstallIcons)
+include(ECMOptionalAddSubdirectory)
+include(ECMSetupVersion)
+include(FeatureSummary)
+
+find_package(Qt5 REQUIRED COMPONENTS
+ Widgets
+ Sql
+ Script
+ XmlPatterns
+ Qml
+ Quick
+ QuickWidgets
+ Test
+)
+
+find_package(KF5 REQUIRED COMPONENTS
+ Config
+ ConfigWidgets
+ CoreAddons
+ Declarative
+ I18n
+ KIO
+ NewStuff
+ WidgetsAddons
+ XmlGui
+ ItemViews
+ KCMUtils
+ TextEditor
+)
# subdirectories to build
-add_subdirectory(data)
-add_subdirectory(doc)
-add_subdirectory(src)
-# add_subdirectory(sounds) # excluded because of the lack of sound support
-add_subdirectory(images)
-add_subdirectory(icons)
+ecm_optional_add_subdirectory(data)
+ecm_optional_add_subdirectory(doc)
+ecm_optional_add_subdirectory(src)
+# ecm_optional_add_subdirectory(sounds)
+ecm_optional_add_subdirectory(images)
+ecm_optional_add_subdirectory(icons)
# files to install in the ktouch project root directory
-install( PROGRAMS ktouch.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
+install(PROGRAMS ktouch.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install(FILES ktouch.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/appdata/)
-macro_display_feature_log()
+feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index f2f808f..418f6af 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_subdirectory(keyboardlayouts)
-add_subdirectory(courses)
-install( FILES "data.xml" DESTINATION ${DATA_INSTALL_DIR}/ktouch )
+ecm_optional_add_subdirectory(keyboardlayouts)
+ecm_optional_add_subdirectory(courses)
+install( FILES "data.xml" DESTINATION ${DATA_INSTALL_DIR}/ktouch )
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 1a199a9..76e4e61 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,6 +1,2 @@
-########### install files ###############
-#
-
-#
-kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR ktouch)
-kde4_create_manpage(man-ktouch.1.docbook 1 INSTALL_DESTINATION ${MAN_INSTALL_DIR})
+kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR ktouch)
+kdoctools_create_manpage(man-ktouch.1.docbook 1 INSTALL_DESTINATION ${MAN_INSTALL_DIR})
diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt
index 7affd27..3d08a0f 100644
--- a/icons/CMakeLists.txt
+++ b/icons/CMakeLists.txt
@@ -1 +1,11 @@
-kde4_install_icons( ${ICON_INSTALL_DIR} )
+ecm_install_icons(
+ ICONS
+ hi16-app-ktouch.png
+ hi22-app-ktouch.png
+ hi32-app-ktouch.png
+ hi48-app-ktouch.png
+ hi128-app-ktouch.png
+ hisc-app-ktouch.svgz
+ DESTINATION ${ICON_INSTALL_DIR}
+ THEME hicolor
+)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a017e59..161c234 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,41 +1,25 @@
-# CMakeList.txt for the KTouch source directory
-
-include(MacroLogFeature)
-
-find_package(KDeclarative REQUIRED)
+ecm_setup_version(2.3.0
+ VARIABLE_PREFIX KTOUCH
+ VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/version.h"
+ PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KTouchConfigVersion.cmake"
+)
-# Currently it is called by FindQt4, but call it explicitly
find_package(X11)
-macro_log_feature(X11_Xkbfile_FOUND "libxkbfile" "X Keyboard Extension" "http://www.x.org/wiki/XKB" FALSE "" "Support for keyboard layout auto-detection in KTouch")
+# macro_log_feature(X11_Xkbfile_FOUND "libxkbfile" "X Keyboard Extension" "http://www.x.org/wiki/XKB" FALSE "" "Support for keyboard layout auto-detection in KTouch")
-add_subdirectory(qml)
-add_subdirectory(schemata)
+ecm_optional_add_subdirectory(qml)
+ecm_optional_add_subdirectory(schemata)
# set include directories
-include_directories(${QT_INCLUDE} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${ktouch_SOURCE_DIR}
+)
-# add compilation options
-option(KDEEDU_KTOUCH_BUILD_WITH_PHONON "Enables compilation of sound output using Phonon." ON)
-mark_as_advanced(KDEEDU_KTOUCH_BUILD_WITH_PHONON)
# configure the local configuration file
configure_file(ktouch_build_config.h.in ktouch_build_config.h)
-# add ui files, all files in directory ui are Qt4 only
-kde4_add_ui_files(ktouch_UIS
- ui/colorsconfigwidget.ui
- ui/trainingconfigwidget.ui
- ui/resourceeditorwidget.ui
- ui/resourcetypeswidget.ui
- ui/newcoursewidget.ui
- ui/newkeyboardlayoutwidget.ui
- ui/resourcetemplatewidget.ui
- ui/courseeditor.ui
- ui/lessontexteditor.ui
- ui/keyboardlayouteditor.ui
- ui/keyboardlayoutpropertieswidget.ui
- ui/customlessoneditorwidget.ui
-)
# set the source code files from which KTouch is compiled
set(ktouch_SRCS
@@ -44,8 +28,6 @@ set(ktouch_SRCS
mainwindow.cpp
bindings/utils.cpp
bindings/stringformatter.cpp
- declarativeitems/applicationbackground.cpp
- declarativeitems/cursorshapearea.cpp
declarativeitems/griditem.cpp
declarativeitems/lessonpainter.cpp
declarativeitems/preferencesproxy.cpp
@@ -98,6 +80,22 @@ set(ktouch_SRCS
customlessoneditorwidget.cpp
)
+# compile UI files
+qt5_wrap_ui(ktouch_SRCS
+ ui/colorsconfigwidget.ui
+ ui/trainingconfigwidget.ui
+ ui/resourceeditorwidget.ui
+ ui/resourcetypeswidget.ui
+ ui/newcoursewidget.ui
+ ui/newkeyboardlayoutwidget.ui
+ ui/resourcetemplatewidget.ui
+ ui/courseeditor.ui
+ ui/lessontexteditor.ui
+ ui/keyboardlayouteditor.ui
+ ui/keyboardlayoutpropertieswidget.ui
+ ui/customlessoneditorwidget.ui
+)
+
if (X11_Xkbfile_FOUND)
add_definitions(-DKTOUCH_BUILD_WITH_X11)
include_directories(${X11_Xkbfile_INCLUDE_PATH})
@@ -106,19 +104,36 @@ else (X11_Xkbfile_FOUND)
set(ktouch_SRCS ${ktouch_SRCS} keyboardlayoutmenu.cpp)
endif (X11_Xkbfile_FOUND)
-kde4_add_kcfg_files(ktouch_SRCS preferences.kcfgc )
-
-#uncomment this if oxygen icons for ktouch are available
-#kde4_add_app_icon(ktouch_SRCS "${KDE4_ICON_DIR}/oxygen/*/apps/ktouch.png")
-kde4_add_app_icon(ktouch_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../icons/hi*-app-ktouch.png")
-
-kde4_add_executable(ktouch ${ktouch_UIS} ${ktouch_SRCS})
-
-target_link_libraries(ktouch ${KDECLARATIVE_LIBRARIES} ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KCMUTILS_LIBS} ${QT_QTCORE_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTSCRIPT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${QT_QTXMLPATTERNS_LIBRARY} ${QT_QTSQL_LIBRARY})
+kconfig_add_kcfg_files(ktouch_SRCS preferences.kcfgc)
+
+add_executable(ktouch ${ktouch_SRCS})
+
+target_link_libraries(ktouch
+ LINK_PUBLIC
+ Qt5::Qml
+ Qt5::Quick
+ Qt5::QuickWidgets
+ Qt5::Script
+ Qt5::Sql
+ Qt5::XmlPatterns
+ KF5::ConfigWidgets
+ KF5::Declarative
+ KF5::KIOWidgets
+ KF5::ItemViews
+ KF5::NewStuff
+ KF5::XmlGui
+ KF5::I18n
+ KF5::KCMUtils
+ KF5::TextEditor
+)
if (X11_Xkbfile_FOUND)
target_link_libraries(ktouch ${X11_Xkbfile_LIB} ${X11_LIBRARIES})
endif (X11_Xkbfile_FOUND)
+#uncomment this if oxygen icons for ktouch are available
+#kde4_add_app_icon(ktouch_SRCS "${KDE4_ICON_DIR}/oxygen/*/apps/ktouch.png")
+#kde4_add_app_icon(ktouch_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../icons/hi*-app-ktouch.png")
+
install(TARGETS ktouch ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES ktouch.kcfg DESTINATION ${KCFG_INSTALL_DIR})
diff --git a/src/application.cpp b/src/application.cpp
index 3ffd4ba..533dad4 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -17,18 +17,13 @@
#include "application.h"
-#include <qdeclarative.h>
-#include <QGraphicsDropShadowEffect>
-#include <QScriptValue>
-#include <QScriptEngine>
-#include <QKeyEvent>
+#include <QQmlEngine>
+#include <QJSValue>
-#include <kdeclarative.h>
+#include <KDeclarative/KDeclarative>
#include "bindings/utils.h"
#include "bindings/stringformatter.h"
-#include "declarativeitems/applicationbackground.h"
-#include "declarativeitems/cursorshapearea.h"
#include "declarativeitems/griditem.h"
#include "declarativeitems/lessonpainter.h"
#include "declarativeitems/preferencesproxy.h"
@@ -51,8 +46,9 @@
#include "models/learningprogressmodel.h"
#include "models/errorsmodel.h"
-Application::Application() :
- KApplication(true),
+
+Application::Application(int& argc, char** argv, int flags):
+ QApplication(argc, argv, flags),
m_dataIndex(new DataIndex(this))
{
registerQmlTypes();
@@ -68,33 +64,27 @@ DataIndex* Application::dataIndex()
return app->m_dataIndex;
}
-QWeakPointer<ResourceEditor>& Application::resourceEditorRef()
+QSharedPointer<ResourceEditor>& Application::resourceEditorRef()
{
Application* app = qobject_cast<Application*>(QCoreApplication::instance());
return app->m_resourceEditorRef;
}
-void Application::setupDeclarativeBindings(QDeclarativeEngine* declarativeEngine)
+void Application::setupDeclarativeBindings(QQmlEngine* qmlEngine)
{
- KDeclarative kDeclarative;
- kDeclarative.setDeclarativeEngine(declarativeEngine);
- kDeclarative.initialize();
+ KDeclarative::KDeclarative kDeclarative;
+ kDeclarative.setDeclarativeEngine(qmlEngine);
kDeclarative.setupBindings();
- QScriptEngine* engine = kDeclarative.scriptEngine();
- QScriptValue globalObject = engine->globalObject();
+ QJSValue globalObject = qmlEngine->globalObject();
- globalObject.setProperty("findImage", engine->newFunction(findImage));
- globalObject.setProperty("getSecondsOfQTime", engine->newFunction(getSecondsOfQTime));
- globalObject.setProperty("getMinutesOfQTime", engine->newFunction(getMinutesOfQTime));
- globalObject.setProperty("uuid", engine->newFunction(uuid));
- globalObject.setProperty("strFormatter", engine->newQObject(new StringFormatter(), QScriptEngine::ScriptOwnership));
+ globalObject.setProperty("utils", qmlEngine->newQObject(new Utils()));
+ globalObject.setProperty("strFormatter", qmlEngine->newQObject(new StringFormatter()));
}
void Application::registerQmlTypes()
{
- qmlRegisterType<QGraphicsDropShadowEffect>("Effects",1,0,"DropShadow");
qmlRegisterType<KeyboardLayout>("ktouch", 1, 0, "KeyboardLayout");
qmlRegisterType<AbstractKey>("ktouch", 1, 0, "AbstractKey");
qmlRegisterType<Key>("ktouch", 1, 0, "Key");
@@ -117,8 +107,6 @@ void Application::registerQmlTypes()
qmlRegisterType<LearningProgressModel>("ktouch", 1, 0, "LearningProgressModel");
qmlRegisterType<ErrorsModel>("ktouch", 1, 0, "ErrorsModel");
- qmlRegisterType<ApplicationBackground>("ktouch", 1, 0, "ApplicationBackground");
- qmlRegisterType<CursorShapeArea>("ktouch", 1, 0 , "CursorShapeArea");
qmlRegisterType<GridItem>("ktouch", 1, 0 , "Grid");
qmlRegisterType<ScaleBackgroundItem>("ktouch", 1, 0, "ScaleBackgroundItem");
qmlRegisterType<LessonPainter>("ktouch", 1, 0, "LessonPainter");
diff --git a/src/application.h b/src/application.h
index d061192..4374784 100644
--- a/src/application.h
+++ b/src/application.h
@@ -18,27 +18,26 @@
#ifndef APPLICATION_H
#define APPLICATION_H
-#include <KApplication>
-
-#include <QWeakPointer>
+#include <QApplication>
+#include <QSharedPointer>
#include "editor/resourceeditor.h"
-class QDeclarativeEngine;
+class QQmlEngine;
class DataIndex;
-class Application : public KApplication
+class Application : public QApplication
{
Q_OBJECT
public:
- explicit Application();
+ Application(int& argc, char** argv, int flags = ApplicationFlags);
static DataIndex* dataIndex();
- static void setupDeclarativeBindings(QDeclarativeEngine* declarativeEngine);
- static QWeakPointer<ResourceEditor>& resourceEditorRef();
+ static void setupDeclarativeBindings(QQmlEngine* qmlEngine);
+ static QSharedPointer<ResourceEditor>& resourceEditorRef();
private:
void registerQmlTypes();
DataIndex* m_dataIndex;
- QWeakPointer<ResourceEditor> m_resourceEditorRef;
+ QSharedPointer<ResourceEditor> m_resourceEditorRef;
};
#endif // APPLICATION_H
diff --git a/src/bindings/utils.cpp b/src/bindings/utils.cpp
index 36d14d1..adf8ec5 100644
--- a/src/bindings/utils.cpp
+++ b/src/bindings/utils.cpp
@@ -17,103 +17,52 @@
#include "utils.h"
-#include <QScriptContext>
#include <QTime>
#include <QUuid>
+#include <QtDebug>
+#include <QStandardPaths>
-#include <KStandardDirs>
-#include <KDebug>
-
-QScriptValue findImage(QScriptContext *context, QScriptEngine *engine)
+Utils::Utils(QObject* parent):
+ QObject(parent)
{
- Q_UNUSED(engine);
-
- if (context->argumentCount() == 0)
- {
- kWarning() << "got no arguments, expected one";
- return QScriptValue("");
- }
-
- if (context->argumentCount() > 1)
- {
- kWarning() << "expected one argument, got more";
- }
+}
- const QString imageName = context->argument(0).toString();
- const QString relPath = QString("images/") + imageName;
- const QString path = KGlobal::dirs()->findResource("appdata", relPath);
+QString Utils::findImage(QString name)
+{
+ const QString relPath = QString("images/") + name;
+ const QString path = QStandardPaths::locate(QStandardPaths::DataLocation, relPath);
if (path.isNull())
{
- kWarning() << "can't find image resource:" << imageName;
+ qWarning() << "can't find image resource:" << name;
}
- return QScriptValue(path);
+ return path;
}
-
-QScriptValue getSecondsOfQTime(QScriptContext *context, QScriptEngine *engine)
+int Utils::getMinutesOfQTime(const QTime& time)
{
- Q_UNUSED(engine);
-
- if (context->argumentCount() == 0)
- {
- kWarning() << "got no arguments, expected one";
- return QScriptValue("");
- }
-
- if (context->argumentCount() > 1)
- {
- kWarning() << "expected one argument, got more";
- }
-
- const QTime time = context->argument(0).toVariant().toTime();
-
if (!time.isValid())
{
- kWarning() << "invalid QTime passed";
- return QScriptValue(0);
+ qWarning() << "invalid QTime passed";
+ return 0;
}
- return QScriptValue(time.second());
+ return time.minute();
}
-QScriptValue getMinutesOfQTime(QScriptContext *context, QScriptEngine *engine)
+int Utils::getSecondsOfQTime(const QTime& time)
{
- Q_UNUSED(engine);
-
- if (context->argumentCount() == 0)
- {
- kWarning() << "got no arguments, expected one";
- return QScriptValue("");
- }
-
- if (context->argumentCount() > 1)
- {
- kWarning() << "expected one argument, got more";
- }
-
- const QTime time = context->argument(0).toVariant().toTime();
-
if (!time.isValid())
{
- kWarning() << "invalid QTime passed";
- return QScriptValue(0);
+ qWarning() << "invalid QTime passed";
+ return 0;
}
- return QScriptValue(time.minute());
+ return time.second();
}
-QScriptValue uuid(QScriptContext *context, QScriptEngine *engine)
+QString Utils::uuid()
{
- Q_UNUSED(engine)
-
- if (context->argumentCount() > 0)
- {
- kWarning() << "uuid() expects no arguments, got more";
- }
-
- const QString uuid = QUuid::createUuid().toString();
-
- return QScriptValue(uuid);
+ return QUuid::createUuid().toString();
}
diff --git a/src/bindings/utils.h b/src/bindings/utils.h
index 1e340df..077ca32 100644
--- a/src/bindings/utils.h
+++ b/src/bindings/utils.h
@@ -18,16 +18,20 @@
#ifndef UTILS_H
#define UTILS_H
-#include <QScriptValue>
+#include <QObject>
+#include <QTime>
-class QScriptContext;
-class QScriptEngine;
+class Utils : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Utils(QObject* parent = 0);
+ Q_INVOKABLE QString findImage(QString name);
+ Q_INVOKABLE int getMinutesOfQTime(const QTime& time);
+ Q_INVOKABLE int getSecondsOfQTime(const QTime& time);
+ Q_INVOKABLE QString uuid();
-QScriptValue findImage(QScriptContext* context, QScriptEngine* engine);
+};
-QScriptValue getSecondsOfQTime(QScriptContext* context, QScriptEngine* engine);
-QScriptValue getMinutesOfQTime(QScriptContext* context, QScriptEngine* engine);
-
-QScriptValue uuid(QScriptContext* context, QScriptEngine* engine);
#endif // UTILS_H
diff --git a/src/core/course.cpp b/src/core/course.cpp
index 6c0d9ac..860ae86 100644
--- a/src/core/course.cpp
+++ b/src/core/course.cpp
@@ -19,10 +19,6 @@
#include <QSignalMapper>
-#include <kstandarddirs.h>
-#include <klocale.h>
-#include <kdebug.h>
-
#include "lesson.h"
#include "dataindex.h"
diff --git a/src/core/dbaccess.cpp b/src/core/dbaccess.cpp
index 36baa5f..f8b8e09 100644
--- a/src/core/dbaccess.cpp
+++ b/src/core/dbaccess.cpp
@@ -17,14 +17,15 @@
#include "dbaccess.h"
+#include <QDebug>
#include <QUuid>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
+#include <QStandardPaths>
+
+#include <KLocalizedString>
-#include <KStandardDirs>
-#include <KDebug>
-#include <KLocale>
DbAccess::DbAccess(QObject* parent) :
QObject(parent),
@@ -41,12 +42,12 @@ QSqlDatabase DbAccess::database()
{
if (!QSqlDatabase::contains(QSqlDatabase::defaultConnection))
{
- QString dbPath = KGlobal::dirs()->locateLocal("appdata", "profiles.db");
+ QString dbPath = QStandardPaths::locate(QStandardPaths::DataLocation, "profiles.db");
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(dbPath);
if (!db.open())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return db;
}
@@ -79,7 +80,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -88,7 +89,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -115,20 +116,20 @@ bool DbAccess::checkDbSchema()
{
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
db.exec("INSERT INTO metadata (key, value) VALUES ('version', '1.1')");
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
if (!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -143,7 +144,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -161,7 +162,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -175,7 +176,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -190,7 +191,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -204,7 +205,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -219,7 +220,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -234,7 +235,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -256,7 +257,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -271,7 +272,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -286,7 +287,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -300,7 +301,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -311,7 +312,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -327,7 +328,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -338,7 +339,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -348,7 +349,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -360,7 +361,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -386,7 +387,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (updateIdQuery.lastError().isValid())
{
- kWarning() << updateIdQuery.lastError().text();
+ qWarning() << updateIdQuery.lastError().text();
raiseError(updateIdQuery.lastError());
db.rollback();
return false;
@@ -397,7 +398,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -405,7 +406,7 @@ bool DbAccess::migrateFrom1_0To1_1()
if (!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
diff --git a/src/core/keyboardlayout.cpp b/src/core/keyboardlayout.cpp
index 65edf78..f16937a 100644
--- a/src/core/keyboardlayout.cpp
+++ b/src/core/keyboardlayout.cpp
@@ -26,9 +26,6 @@
#include <QXmlSchema>
#include <QXmlSchemaValidator>
-#include <kstandarddirs.h>
-#include <klocale.h>
-#include <kdebug.h>
#include "abstractkey.h"
#include "key.h"
diff --git a/src/core/keychar.cpp b/src/core/keychar.cpp
index 58e1ff5..5ba51c3 100644
--- a/src/core/keychar.cpp
+++ b/src/core/keychar.cpp
@@ -17,8 +17,6 @@
#include "keychar.h"
-#include <kdebug.h>
-
KeyChar::KeyChar(QObject *parent) :
QObject(parent),
m_value(QChar(32)),
diff --git a/src/core/profiledataaccess.cpp b/src/core/profiledataaccess.cpp
index ae6d042..e8088f1 100644
--- a/src/core/profiledataaccess.cpp
+++ b/src/core/profiledataaccess.cpp
@@ -17,12 +17,12 @@
#include "profiledataaccess.h"
+#include <QDebug>
#include <QVariant>
#include <QSqlDatabase>
#include <QSqlError>
-#include <KDebug>
-#include <KLocale>
+#include <KLocalizedString>
#include "core/profile.h"
#include "core/course.h"
@@ -52,7 +52,7 @@ void ProfileDataAccess::loadProfiles()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return;
}
@@ -96,7 +96,7 @@ void ProfileDataAccess::addProfile(Profile* profile)
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return;
}
@@ -105,7 +105,7 @@ void ProfileDataAccess::addProfile(Profile* profile)
if (!addQuery.prepare("INSERT INTO profiles (name, skill_level, last_used_course_id) VALUES (?, ?, ?)"))
{
- kWarning() << addQuery.lastError().text();
+ qWarning() << addQuery.lastError().text();
raiseError(addQuery.lastError());
db.rollback();
return;
@@ -116,7 +116,7 @@ void ProfileDataAccess::addProfile(Profile* profile)
if (!addQuery.exec())
{
- kWarning() << addQuery.lastError().text();
+ qWarning() << addQuery.lastError().text();
raiseError(addQuery.lastError());
db.rollback();
return;
@@ -126,7 +126,7 @@ void ProfileDataAccess::addProfile(Profile* profile)
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return;
@@ -137,7 +137,7 @@ void ProfileDataAccess::addProfile(Profile* profile)
if (!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return;
@@ -158,7 +158,7 @@ void ProfileDataAccess::updateProfile(int index)
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return;
}
@@ -167,7 +167,7 @@ void ProfileDataAccess::updateProfile(int index)
if (!updateQuery.prepare("UPDATE profiles SET name = ?, skill_level = ?, last_used_course_id = ? WHERE id = ?"))
{
- kWarning() << updateQuery.lastError().text();
+ qWarning() << updateQuery.lastError().text();
raiseError(updateQuery.lastError());
return;
}
@@ -179,7 +179,7 @@ void ProfileDataAccess::updateProfile(int index)
if (!updateQuery.exec())
{
- kWarning() << updateQuery.lastError().text();
+ qWarning() << updateQuery.lastError().text();
raiseError(updateQuery.lastError());
db.rollback();
return;
@@ -187,7 +187,7 @@ void ProfileDataAccess::updateProfile(int index)
if (!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return;
@@ -205,7 +205,7 @@ void ProfileDataAccess::removeProfile(int index)
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return;
@@ -215,7 +215,7 @@ void ProfileDataAccess::removeProfile(int index)
if (!removeQuery.prepare("DELETE FROM profiles WHERE id = ?"))
{
- kWarning() << removeQuery.lastError().text();
+ qWarning() << removeQuery.lastError().text();
raiseError(removeQuery.lastError());
db.rollback();
return;
@@ -226,7 +226,7 @@ void ProfileDataAccess::removeProfile(int index)
if (!removeQuery.exec())
{
- kWarning() << removeQuery.lastError().text();
+ qWarning() << removeQuery.lastError().text();
raiseError(removeQuery.lastError());
db.rollback();
return;
@@ -234,7 +234,7 @@ void ProfileDataAccess::removeProfile(int index)
if (!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return;
@@ -272,7 +272,7 @@ void ProfileDataAccess::loadReferenceTrainingStats(TrainingStats* stats, Profile
if (!selectQuery.prepare("SELECT id, characters_typed, error_count, elapsed_time FROM training_stats WHERE profile_id = ? AND course_id = ? AND lesson_id = ? ORDER BY date DESC LIMIT 1"))
{
- kWarning() << selectQuery.lastError().text();
+ qWarning() << selectQuery.lastError().text();
raiseError(selectQuery.lastError());
return;
}
@@ -283,7 +283,7 @@ void ProfileDataAccess::loadReferenceTrainingStats(TrainingStats* stats, Profile
if (!selectQuery.exec())
{
- kWarning() << selectQuery.lastError().text();
+ qWarning() << selectQuery.lastError().text();
raiseError(selectQuery.lastError());
return;
}
@@ -304,7 +304,7 @@ void ProfileDataAccess::loadReferenceTrainingStats(TrainingStats* stats, Profile
if (!errorSelectQuery.exec())
{
- kWarning() << errorSelectQuery.lastError().text();
+ qWarning() << errorSelectQuery.lastError().text();
raiseError(errorSelectQuery.lastError());
return;
}
@@ -331,7 +331,7 @@ void ProfileDataAccess::saveTrainingStats(TrainingStats* stats, Profile* profile
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return;
}
@@ -339,7 +339,7 @@ void ProfileDataAccess::saveTrainingStats(TrainingStats* stats, Profile* profile
if (!addQuery.prepare("INSERT INTO training_stats (profile_id, course_id, lesson_id, date, characters_typed, error_count, elapsed_time) VALUES (?, ?, ?, ?, ?, ?, ?)"))
{
- kWarning() << addQuery.lastError().text();
+ qWarning() << addQuery.lastError().text();
raiseError(addQuery.lastError());
db.rollback();
return;
@@ -355,7 +355,7 @@ void ProfileDataAccess::saveTrainingStats(TrainingStats* stats, Profile* profile
if (!addQuery.exec())
{
- kWarning() << addQuery.lastError().text();
+ qWarning() << addQuery.lastError().text();
raiseError(addQuery.lastError());
db.rollback();
return;
@@ -365,7 +365,7 @@ void ProfileDataAccess::saveTrainingStats(TrainingStats* stats, Profile* profile
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return;
@@ -378,7 +378,7 @@ void ProfileDataAccess::saveTrainingStats(TrainingStats* stats, Profile* profile
if (!addErrorsQuery.prepare("INSERT INTO training_stats_errors (stats_id, character, count) VALUES (?, ?, ?)"))
{
- kWarning() << addErrorsQuery.lastError().text();
+ qWarning() << addErrorsQuery.lastError().text();
raiseError(addErrorsQuery.lastError());
db.rollback();
return;
@@ -394,7 +394,7 @@ void ProfileDataAccess::saveTrainingStats(TrainingStats* stats, Profile* profile
if (!addErrorsQuery.exec())
{
- kWarning() << addErrorsQuery.lastError().text();
+ qWarning() << addErrorsQuery.lastError().text();
raiseError(addErrorsQuery.lastError());
db.rollback();
return;
@@ -403,7 +403,7 @@ void ProfileDataAccess::saveTrainingStats(TrainingStats* stats, Profile* profile
if(!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return;
@@ -431,7 +431,7 @@ QString ProfileDataAccess::courseProgress(Profile* profile, const QString& cours
if (!selectQuery.exec())
{
- kWarning() << selectQuery.lastError().text();
+ qWarning() << selectQuery.lastError().text();
raiseError(selectQuery.lastError());
return QString();
}
@@ -455,7 +455,7 @@ void ProfileDataAccess::saveCourseProgress(const QString& lessonId, Profile* pro
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return;
}
@@ -473,7 +473,7 @@ void ProfileDataAccess::saveCourseProgress(const QString& lessonId, Profile* pro
if (!insertQuery.exec())
{
- kWarning() << insertQuery.lastError().text();
+ qWarning() << insertQuery.lastError().text();
raiseError(insertQuery.lastError());
db.rollback();
return;
@@ -490,7 +490,7 @@ void ProfileDataAccess::saveCourseProgress(const QString& lessonId, Profile* pro
if (!updateQuery.exec())
{
- kWarning() << updateQuery.lastError().text();
+ qWarning() << updateQuery.lastError().text();
raiseError(updateQuery.lastError());
db.rollback();
return;
@@ -499,7 +499,7 @@ void ProfileDataAccess::saveCourseProgress(const QString& lessonId, Profile* pro
if(!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return;
@@ -522,7 +522,7 @@ int ProfileDataAccess::lessonsTrained(Profile* profile)
if (!query.exec())
{
- kWarning() << query.lastError().text();
+ qWarning() << query.lastError().text();
raiseError(query.lastError());
return 0;
}
@@ -547,7 +547,7 @@ quint64 ProfileDataAccess::totalTrainingTime(Profile* profile)
if (!query.exec())
{
- kWarning() << query.lastError().text();
+ qWarning() << query.lastError().text();
raiseError(query.lastError());
return 0;
}
@@ -572,7 +572,7 @@ QDateTime ProfileDataAccess::lastTrainingSession(Profile* profile)
if (!query.exec())
{
- kWarning() << query.lastError().text();
+ qWarning() << query.lastError().text();
raiseError(query.lastError());
return QDateTime();
}
@@ -615,7 +615,7 @@ bool ProfileDataAccess::loadCustomLessons(Profile* profile, const QString& keybo
if (!query.exec())
{
- kWarning() << query.lastError().text();
+ qWarning() << query.lastError().text();
raiseError(query.lastError());
return false;
}
@@ -669,7 +669,7 @@ bool ProfileDataAccess::storeCustomLesson(Lesson* lesson, Profile* profile, cons
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -682,7 +682,7 @@ bool ProfileDataAccess::storeCustomLesson(Lesson* lesson, Profile* profile, cons
if (idQuery.lastError().isValid())
{
- kWarning() << idQuery.lastError().text();
+ qWarning() << idQuery.lastError().text();
raiseError(idQuery.lastError());
db.rollback();
return false;
@@ -699,7 +699,7 @@ bool ProfileDataAccess::storeCustomLesson(Lesson* lesson, Profile* profile, cons
if (updateQuery.lastError().isValid())
{
- kWarning() << updateQuery.lastError().text();
+ qWarning() << updateQuery.lastError().text();
raiseError(updateQuery.lastError());
db.rollback();
return false;
@@ -715,7 +715,7 @@ bool ProfileDataAccess::storeCustomLesson(Lesson* lesson, Profile* profile, cons
if (updateQuery.lastError().isValid())
{
- kWarning() << updateQuery.lastError().text();
+ qWarning() << updateQuery.lastError().text();
raiseError(updateQuery.lastError());
db.rollback();
return false;
@@ -729,7 +729,7 @@ bool ProfileDataAccess::storeCustomLesson(Lesson* lesson, Profile* profile, cons
if (insertQuery.lastError().isValid())
{
- kWarning() << insertQuery.lastError().text();
+ qWarning() << insertQuery.lastError().text();
raiseError(insertQuery.lastError());
db.rollback();
return false;
@@ -745,7 +745,7 @@ bool ProfileDataAccess::storeCustomLesson(Lesson* lesson, Profile* profile, cons
if (insertQuery.lastError().isValid())
{
- kWarning() << insertQuery.lastError().text();
+ qWarning() << insertQuery.lastError().text();
raiseError(insertQuery.lastError());
db.rollback();
return false;
@@ -754,7 +754,7 @@ bool ProfileDataAccess::storeCustomLesson(Lesson* lesson, Profile* profile, cons
if(!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -772,7 +772,7 @@ bool ProfileDataAccess::deleteCustomLesson(const QString& id)
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -785,7 +785,7 @@ bool ProfileDataAccess::deleteCustomLesson(const QString& id)
if (deleteQuery.lastError().isValid())
{
- kWarning() << deleteQuery.lastError().text();
+ qWarning() << deleteQuery.lastError().text();
raiseError(deleteQuery.lastError());
db.rollback();
return false;
@@ -793,7 +793,7 @@ bool ProfileDataAccess::deleteCustomLesson(const QString& id)
if(!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -842,7 +842,7 @@ QSqlQuery ProfileDataAccess::learningProgressQuery(Profile* profile, Course* cou
if (!query.exec())
{
- kWarning() << query.lastError().text();
+ qWarning() << query.lastError().text();
raiseError(query.lastError());
return QSqlQuery();
}
@@ -869,7 +869,7 @@ int ProfileDataAccess::findCourseProgressId(Profile* profile, const QString& cou
if (!findQuery.exec())
{
- kWarning() << findQuery.lastError().text();
+ qWarning() << findQuery.lastError().text();
raiseError(findQuery.lastError());
return -1;
}
diff --git a/src/core/resource.h b/src/core/resource.h
index f25c0e2..8b01f42 100644
--- a/src/core/resource.h
+++ b/src/core/resource.h
@@ -25,6 +25,7 @@ class Resource : public QObject
Q_OBJECT
Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
Q_PROPERTY(bool isValid READ isValid WRITE setIsValid NOTIFY isValidChanged)
+
public:
explicit Resource(QObject* parent = 0);
QString id() const;
diff --git a/src/core/resourcedataaccess.cpp b/src/core/resourcedataaccess.cpp
index d8d49af..9bb8ff0 100644
--- a/src/core/resourcedataaccess.cpp
+++ b/src/core/resourcedataaccess.cpp
@@ -17,17 +17,17 @@
#include "resourcedataaccess.h"
-#include <QFile>
+#include <QDebug>
#include <QDir>
+#include <QFile>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNodeList>
+#include <QUrl>
+#include <QStandardPaths>
#include <QXmlSchema>
#include <QXmlSchemaValidator>
-#include <KUrl>
-#include <KStandardDirs>
-#include <KDebug>
#include "dataindex.h"
#include "keyboardlayout.h"
@@ -48,20 +48,20 @@ bool ResourceDataAccess::fillDataIndex(DataIndex* target)
if (!schema.isValid())
return false;
- foreach (const QString& path, KGlobal::dirs()->findAllResources("appdata", "data.xml"))
+ foreach (const QString& path, QStandardPaths::locateAll(QStandardPaths::DataLocation, "data.xml"))
{
QDir dir = QFileInfo(path).dir();
QFile dataIndexFile;
dataIndexFile.setFileName(path);
if (!dataIndexFile.open(QIODevice::ReadOnly))
{
- kWarning() << "can't open:" << path;
+ qWarning() << "can't open:" << path;
return false;
}
QDomDocument doc = getDomDocument(dataIndexFile, schema);
if (doc.isNull())
{
- kWarning() << "invalid doc:" << path;
+ qWarning() << "invalid doc:" << path;
return false;
}
QDomElement root(doc.documentElement());
@@ -106,7 +106,7 @@ bool ResourceDataAccess::loadKeyboardLayout(const QString &path, KeyboardLayout*
keyboardLayoutFile.setFileName(path);
if (!keyboardLayoutFile.open(QIODevice::ReadOnly))
{
- kWarning() << "can't open:" << path;
+ qWarning() << "can't open:" << path;
return false;
}
QXmlSchema schema = loadXmlSchema("keyboardlayout");
@@ -115,7 +115,7 @@ bool ResourceDataAccess::loadKeyboardLayout(const QString &path, KeyboardLayout*
QDomDocument doc = getDomDocument(keyboardLayoutFile, schema);
if (doc.isNull())
{
- kWarning() << "invalid doc:" << path;
+ qWarning() << "invalid doc:" << path;
return false;
}
QDomElement root(doc.documentElement());
@@ -272,7 +272,7 @@ bool ResourceDataAccess::storeKeyboardLayout(const QString& path, KeyboardLayout
if (!file.open(QIODevice::WriteOnly))
{
- kWarning() << "can't open:" << file.fileName();
+ qWarning() << "can't open:" << file.fileName();
return false;
}
@@ -288,7 +288,7 @@ bool ResourceDataAccess::loadCourse(const QString &path, Course* target)
courseFile.setFileName(path);
if (!courseFile.open(QIODevice::ReadOnly))
{
- kWarning() << "can't open:" << path;
+ qWarning() << "can't open:" << path;
return false;
}
QXmlSchema schema = loadXmlSchema("course");
@@ -297,7 +297,7 @@ bool ResourceDataAccess::loadCourse(const QString &path, Course* target)
QDomDocument doc = getDomDocument(courseFile, schema);
if (doc.isNull())
{
- kWarning() << "invalid doc:" << path;
+ qWarning() << "invalid doc:" << path;
return false;
}
QDomElement root(doc.documentElement());
@@ -382,7 +382,7 @@ bool ResourceDataAccess::storeCourse(const QString& path, Course* source)
if (!file.open(QIODevice::WriteOnly))
{
- kWarning() << "can't open:" << file.fileName();
+ qWarning() << "can't open:" << file.fileName();
return false;
}
@@ -399,10 +399,10 @@ QXmlSchema ResourceDataAccess::loadXmlSchema(const QString &name)
{
return schema;
}
- schema.load(&schemaFile, KUrl::fromLocalFile(schemaFile.fileName()));
+ schema.load(&schemaFile, QUrl::fromLocalFile(schemaFile.fileName()));
if (!schema.isValid())
{
- kWarning() << schemaFile.fileName() << "is invalid";
+ qWarning() << schemaFile.fileName() << "is invalid";
}
return schema;
}
@@ -419,23 +419,23 @@ QDomDocument ResourceDataAccess::getDomDocument(QFile &file, QXmlSchema &schema)
QString errorMsg;
if (!doc.setContent(&file, &errorMsg))
{
- kWarning() << errorMsg;
+ qWarning() << errorMsg;
}
return doc;
}
bool ResourceDataAccess::openResourceFile(const QString &relPath, QFile& file)
{
- QString path = KGlobal::dirs()->findResource("appdata", relPath);
+ QString path = QStandardPaths::locate(QStandardPaths::DataLocation, relPath);
if (path.isNull())
{
- kWarning() << "can't find resource:" << relPath;
+ qWarning() << "can't find resource:" << relPath;
return false;
}
file.setFileName(path);
if (!file.open(QIODevice::ReadOnly))
{
- kWarning() << "can't open" << path;
+ qWarning() << "can't open" << path;
return false;
}
return true;
diff --git a/src/core/userdataaccess.cpp b/src/core/userdataaccess.cpp
index bcfece7..b965a6a 100644
--- a/src/core/userdataaccess.cpp
+++ b/src/core/userdataaccess.cpp
@@ -17,13 +17,13 @@
#include "userdataaccess.h"
+#include <QDebug>
#include <QVariant>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
-#include <KLocale>
-#include <KDebug>
+#include <KLocalizedString>
#include "core/dataindex.h"
#include "core/course.h"
@@ -55,7 +55,7 @@ bool UserDataAccess::fillDataIndex(DataIndex* target)
if (courseQuery.lastError().isValid())
{
- kWarning() << courseQuery.lastError().text();
+ qWarning() << courseQuery.lastError().text();
raiseError(courseQuery.lastError());
return false;
}
@@ -77,7 +77,7 @@ bool UserDataAccess::fillDataIndex(DataIndex* target)
if (keyboardLayoutQuery.lastError().isValid())
{
- kWarning() << keyboardLayoutQuery.lastError().text();
+ qWarning() << keyboardLayoutQuery.lastError().text();
raiseError(keyboardLayoutQuery.lastError());
return false;
}
@@ -114,7 +114,7 @@ bool UserDataAccess::loadCourse(const QString& id, Course* target)
if (courseQuery.lastError().isValid())
{
- kWarning() << courseQuery.lastError().text();
+ qWarning() << courseQuery.lastError().text();
raiseError(courseQuery.lastError());
return false;
}
@@ -122,7 +122,7 @@ bool UserDataAccess::loadCourse(const QString& id, Course* target)
if (!courseQuery.next())
{
const QString warning = i18n("No course with ID %1", id);
- kWarning() << warning;
+ qWarning() << warning;
raiseError(warning);
}
@@ -140,7 +140,7 @@ bool UserDataAccess::loadCourse(const QString& id, Course* target)
if (lessonsQuery.lastError().isValid())
{
- kWarning() << lessonsQuery.lastError().text();
+ qWarning() << lessonsQuery.lastError().text();
raiseError(lessonsQuery.lastError());
return false;
}
@@ -171,7 +171,7 @@ bool UserDataAccess::storeCourse(Course* course)
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -184,7 +184,7 @@ bool UserDataAccess::storeCourse(Course* course)
if (cleanUpCourseQuery.lastError().isValid())
{
- kWarning() << cleanUpCourseQuery.lastError().text();
+ qWarning() << cleanUpCourseQuery.lastError().text();
raiseError(cleanUpCourseQuery.lastError());
db.rollback();
return false;
@@ -198,7 +198,7 @@ bool UserDataAccess::storeCourse(Course* course)
if (cleanUpLessonsQuery.lastError().isValid())
{
- kWarning() << cleanUpLessonsQuery.lastError().text();
+ qWarning() << cleanUpLessonsQuery.lastError().text();
raiseError(cleanUpLessonsQuery.lastError());
db.rollback();
return false;
@@ -215,7 +215,7 @@ bool UserDataAccess::storeCourse(Course* course)
if (insertCourseQuery.lastError().isValid())
{
- kWarning() << insertCourseQuery.lastError().text();
+ qWarning() << insertCourseQuery.lastError().text();
raiseError(insertCourseQuery.lastError());
db.rollback();
return false;
@@ -239,7 +239,7 @@ bool UserDataAccess::storeCourse(Course* course)
if (insertLessonsQuery.lastError().isValid())
{
- kWarning() << insertLessonsQuery.lastError().text();
+ qWarning() << insertLessonsQuery.lastError().text();
raiseError(insertLessonsQuery.lastError());
db.rollback();
return false;
@@ -248,7 +248,7 @@ bool UserDataAccess::storeCourse(Course* course)
if(!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -266,7 +266,7 @@ bool UserDataAccess::deleteCourse(Course* course)
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -279,7 +279,7 @@ bool UserDataAccess::deleteCourse(Course* course)
if (deleteCourseQuery.lastError().isValid())
{
- kWarning() << deleteCourseQuery.lastError().text();
+ qWarning() << deleteCourseQuery.lastError().text();
raiseError(deleteCourseQuery.lastError());
db.rollback();
return false;
@@ -293,7 +293,7 @@ bool UserDataAccess::deleteCourse(Course* course)
if (deleteLessonsQuery.lastError().isValid())
{
- kWarning() << deleteLessonsQuery.lastError().text();
+ qWarning() << deleteLessonsQuery.lastError().text();
raiseError(deleteLessonsQuery.lastError());
db.rollback();
return false;
@@ -301,7 +301,7 @@ bool UserDataAccess::deleteCourse(Course* course)
if(!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -328,7 +328,7 @@ bool UserDataAccess::loadKeyboardLayout(const QString& id, KeyboardLayout* targe
if (keyboardLayoutQuery.lastError().isValid())
{
- kWarning() << keyboardLayoutQuery.lastError().text();
+ qWarning() << keyboardLayoutQuery.lastError().text();
raiseError(keyboardLayoutQuery.lastError());
return false;
}
@@ -336,7 +336,7 @@ bool UserDataAccess::loadKeyboardLayout(const QString& id, KeyboardLayout* targe
if (!keyboardLayoutQuery.next())
{
const QString warning = i18n("No keyboard layout with ID %1", id);
- kWarning() << warning;
+ qWarning() << warning;
raiseError(warning);
}
@@ -359,7 +359,7 @@ bool UserDataAccess::loadKeyboardLayout(const QString& id, KeyboardLayout* targe
if (keysQuery.lastError().isValid())
{
- kWarning() << keysQuery.lastError().text();
+ qWarning() << keysQuery.lastError().text();
raiseError(keysQuery.lastError());
return false;
}
@@ -382,7 +382,7 @@ bool UserDataAccess::loadKeyboardLayout(const QString& id, KeyboardLayout* targe
if (keyCharsQuery.lastError().isValid())
{
- kWarning() << keyCharsQuery.lastError().text();
+ qWarning() << keyCharsQuery.lastError().text();
raiseError(keyCharsQuery.lastError());
return false;
}
@@ -433,7 +433,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -446,7 +446,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (cleanUpKeyCharsQuery.lastError().isValid())
{
- kWarning() << cleanUpKeyCharsQuery.lastError().text();
+ qWarning() << cleanUpKeyCharsQuery.lastError().text();
raiseError(cleanUpKeyCharsQuery.lastError());
db.rollback();
return false;
@@ -461,7 +461,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (cleanUpKeysQuery.lastError().isValid())
{
- kWarning() << cleanUpKeysQuery.lastError().text();
+ qWarning() << cleanUpKeysQuery.lastError().text();
raiseError(cleanUpKeysQuery.lastError());
db.rollback();
return false;
@@ -475,7 +475,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (cleanUpKeyboardLayoutQuery.lastError().isValid())
{
- kWarning() << cleanUpKeyboardLayoutQuery.lastError().text();
+ qWarning() << cleanUpKeyboardLayoutQuery.lastError().text();
raiseError(cleanUpKeyboardLayoutQuery.lastError());
db.rollback();
return false;
@@ -493,7 +493,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (insertKeyboardLayoutQuery.lastError().isValid())
{
- kWarning() << insertKeyboardLayoutQuery.lastError().text();
+ qWarning() << insertKeyboardLayoutQuery.lastError().text();
raiseError(insertKeyboardLayoutQuery.lastError());
db.rollback();
return false;
@@ -529,7 +529,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (insertKeyQuery.lastError().isValid())
{
- kWarning() << insertKeyQuery.lastError().text();
+ qWarning() << insertKeyQuery.lastError().text();
raiseError(insertKeyQuery.lastError());
db.rollback();
return false;
@@ -539,7 +539,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (idQuery.lastError().isValid())
{
- kWarning() << idQuery.lastError().text();
+ qWarning() << idQuery.lastError().text();
raiseError(idQuery.lastError());
db.rollback();
return false;
@@ -562,7 +562,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (insertKeyCharQuery.lastError().isValid())
{
- kWarning() << insertKeyCharQuery.lastError().text();
+ qWarning() << insertKeyCharQuery.lastError().text();
raiseError(insertKeyCharQuery.lastError());
db.rollback();
return false;
@@ -583,7 +583,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if (insertSpecialKeyQuery.lastError().isValid())
{
- kWarning() << insertSpecialKeyQuery.lastError().text();
+ qWarning() << insertSpecialKeyQuery.lastError().text();
raiseError(insertSpecialKeyQuery.lastError());
db.rollback();
return false;
@@ -593,7 +593,7 @@ bool UserDataAccess::storeKeyboardLayout(KeyboardLayout* keyboardLayout)
if(!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
@@ -611,7 +611,7 @@ bool UserDataAccess::deleteKeyboardLayout(KeyboardLayout* keyboardLayout)
if (!db.transaction())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -624,7 +624,7 @@ bool UserDataAccess::deleteKeyboardLayout(KeyboardLayout* keyboardLayout)
if (deleteKeyCharsQuery.lastError().isValid())
{
- kWarning() << deleteKeyCharsQuery.lastError().text();
+ qWarning() << deleteKeyCharsQuery.lastError().text();
raiseError(deleteKeyCharsQuery.lastError());
db.rollback();
return false;
@@ -639,7 +639,7 @@ bool UserDataAccess::deleteKeyboardLayout(KeyboardLayout* keyboardLayout)
if (deleteKeysQuery.lastError().isValid())
{
- kWarning() << deleteKeysQuery.lastError().text();
+ qWarning() << deleteKeysQuery.lastError().text();
raiseError(deleteKeysQuery.lastError());
db.rollback();
return false;
@@ -653,7 +653,7 @@ bool UserDataAccess::deleteKeyboardLayout(KeyboardLayout* keyboardLayout)
if (deleteKeyboardLayoutQuery.lastError().isValid())
{
- kWarning() << deleteKeyboardLayoutQuery.lastError().text();
+ qWarning() << deleteKeyboardLayoutQuery.lastError().text();
raiseError(deleteKeyboardLayoutQuery.lastError());
db.rollback();
return false;
@@ -661,7 +661,7 @@ bool UserDataAccess::deleteKeyboardLayout(KeyboardLayout* keyboardLayout)
if(!db.commit())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
db.rollback();
return false;
diff --git a/src/declarativeitems/applicationbackground.cpp b/src/declarativeitems/applicationbackground.cpp
deleted file mode 100644
index 0e2f433..0000000
--- a/src/declarativeitems/applicationbackground.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "applicationbackground.h"
-
-#include <QApplication>
-#include <QPainter>
-
-#include <plasma/theme.h>
-
-ApplicationBackground::ApplicationBackground(QDeclarativeItem *parent) :
- QDeclarativeItem(parent)
-{
- setFlag(QDeclarativeItem::ItemHasNoContents, false);
-}
-
-void ApplicationBackground::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
-{
- const QColor appBgColor = QApplication::palette().color(QPalette::Window);
- QColor color = Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor);
- const int similarity = qAbs(appBgColor.lightness() - color.lightness());
-
- color.setAlpha(qMax(0, similarity - 50));
-
- painter->fillRect(boundingRect(), color);
-}
diff --git a/src/declarativeitems/applicationbackground.h b/src/declarativeitems/applicationbackground.h
deleted file mode 100644
index 870662f..0000000
--- a/src/declarativeitems/applicationbackground.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef APPLICATIONBACKGROUND_H
-#define APPLICATIONBACKGROUND_H
-
-#include <QDeclarativeItem>
-
-class ApplicationBackground : public QDeclarativeItem
-{
- Q_OBJECT
-public:
- explicit ApplicationBackground(QDeclarativeItem *parent = 0);
-protected:
- void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
-};
-
-#endif // APPLICATIONBACKGROUND_H
diff --git a/src/declarativeitems/cursorshapearea.cpp b/src/declarativeitems/cursorshapearea.cpp
deleted file mode 100644
index 860a665..0000000
--- a/src/declarativeitems/cursorshapearea.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "cursorshapearea.h"
-
-CursorShapeArea::CursorShapeArea(QDeclarativeItem* parent) :
- QDeclarativeItem(parent),
- m_currentShape(-1)
-{
-}
-
-Qt::CursorShape CursorShapeArea::cursorShape() const
-{
- return cursor().shape();
-}
-
-void CursorShapeArea::setCursorShape(Qt::CursorShape cursorShape)
-{
- if (m_currentShape == (int) cursorShape)
- return;
-
- setCursor(cursorShape);
- emit cursorShapeChanged();
-
- m_currentShape = cursorShape;
-}
diff --git a/src/declarativeitems/cursorshapearea.h b/src/declarativeitems/cursorshapearea.h
deleted file mode 100644
index 36fc0ad..0000000
--- a/src/declarativeitems/cursorshapearea.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef CURSORSHAPEAREA_H
-#define CURSORSHAPEAREA_H
-
-#include <QDeclarativeItem>
-
-class CursorShapeArea : public QDeclarativeItem
-{
- Q_OBJECT
-
- Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape NOTIFY cursorShapeChanged)
-
-public:
- explicit CursorShapeArea(QDeclarativeItem* parent = 0);
-
- Qt::CursorShape cursorShape() const;
- Q_INVOKABLE void setCursorShape(Qt::CursorShape cursorShape);
-
-private:
- int m_currentShape;
-
-signals:
- void cursorShapeChanged();
-};
-
-#endif // CURSORSHAPEAREA_H
diff --git a/src/declarativeitems/griditem.cpp b/src/declarativeitems/griditem.cpp
index 3b55248..db865f5 100644
--- a/src/declarativeitems/griditem.cpp
+++ b/src/declarativeitems/griditem.cpp
@@ -19,13 +19,13 @@
#include <QPainter>
-GridItem::GridItem(QDeclarativeItem* parent) :
- QDeclarativeItem(parent),
+GridItem::GridItem(QQuickItem* parent) :
+ QQuickPaintedItem(parent),
m_lineDistance(10.0),
m_color(Qt::black),
m_backgroundColor(Qt::white)
{
- setFlag(QGraphicsItem::ItemHasNoContents, false);
+ setFlag(QQuickItem::QQuickItem::ItemHasContents, true);
}
qreal GridItem::lineDistance() const
@@ -71,7 +71,7 @@ void GridItem::setBackgroundColor(const QColor& backgroundColor)
}
}
-void GridItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget *)
+void GridItem::paint(QPainter* painter)
{
const QRect rect = boundingRect().toRect();
diff --git a/src/declarativeitems/griditem.h b/src/declarativeitems/griditem.h
index 6d7259f..1d70bd2 100644
--- a/src/declarativeitems/griditem.h
+++ b/src/declarativeitems/griditem.h
@@ -19,23 +19,23 @@
#ifndef GRIDITEM_H
#define GRIDITEM_H
-#include <QDeclarativeItem>
+#include <QQuickPaintedItem>
-class GridItem : public QDeclarativeItem
+class GridItem : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(qreal lineDistance READ lineDistance WRITE setLineDistance NOTIFY lineDistanceChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
public:
- explicit GridItem(QDeclarativeItem* parent = 0);
+ explicit GridItem(QQuickItem* parent = 0);
qreal lineDistance() const;
void setLineDistance(qreal distance);
QColor color() const;
void setColor(const QColor& color);
QColor backgroundColor() const;
void setBackgroundColor(const QColor& backgroundColor);
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* = 0);
+ virtual void paint(QPainter* painter);
signals:
void lineDistanceChanged();
void colorChanged();
diff --git a/src/declarativeitems/lessonpainter.cpp b/src/declarativeitems/lessonpainter.cpp
index dc8fc61..d1e4beb 100644
--- a/src/declarativeitems/lessonpainter.cpp
+++ b/src/declarativeitems/lessonpainter.cpp
@@ -20,7 +20,6 @@
#include <qmath.h>
#include <QAbstractTextDocumentLayout>
#include <QPainter>
-#include <QPixmap>
#include <QTextCharFormat>
#include <QTextCursor>
#include <QTextDocument>
@@ -64,8 +63,8 @@ struct LessonPainterPrivate
QTextCharFormat titleCharFormat;
};
-LessonPainter::LessonPainter(QDeclarativeItem* parent) :
- QDeclarativeItem(parent),
+LessonPainter::LessonPainter(QQuickItem* parent) :
+ QQuickPaintedItem(parent),
d(new LessonPainterPrivate()),
m_doc(new QTextDocument(this)),
m_textScale(1.0),
@@ -75,7 +74,7 @@ LessonPainter::LessonPainter(QDeclarativeItem* parent) :
m_trainingLineCore(0),
m_currentLine(0)
{
- this->setFlag(QDeclarativeItem::ItemHasNoContents, false);
+ this->setFlag(QQuickPaintedItem::ItemHasContents, true);
m_doc->setUseDesignMetrics(true);
}
@@ -180,7 +179,7 @@ void LessonPainter::reset()
resetTrainingStatus();
}
-void LessonPainter::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
+void LessonPainter::paint(QPainter* painter)
{
checkImageCache();
painter->drawPixmap(0, 0, m_imageCache);
diff --git a/src/declarativeitems/lessonpainter.h b/src/declarativeitems/lessonpainter.h
index e395331..82ba24c 100644
--- a/src/declarativeitems/lessonpainter.h
+++ b/src/declarativeitems/lessonpainter.h
@@ -18,7 +18,8 @@
#ifndef LESSONPAINTER_H
#define LESSONPAINTER_H
-#include <QDeclarativeItem>
+#include <QQuickPaintedItem>
+#include <QPixmap>
#include <QPointer>
@@ -29,7 +30,7 @@ class Lesson;
class TrainingLineCore;
struct LessonPainterPrivate;
-class LessonPainter : public QDeclarativeItem
+class LessonPainter : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(Lesson* lesson READ lesson WRITE setLesson NOTIFY lessonChanged)
@@ -38,7 +39,7 @@ class LessonPainter : public QDeclarativeItem
Q_PROPERTY(TrainingLineCore* trainingLineCore READ trainingLineCore WRITE setTrainingLineCore NOTIFY trainingLineCoreChanged)
Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
public:
- explicit LessonPainter(QDeclarativeItem* parent = 0);
+ explicit LessonPainter(QQuickItem* parent = 0);
~LessonPainter();
Lesson* lesson() const;
void setLesson(Lesson* lesson);
@@ -59,7 +60,7 @@ signals:
void cursorRectangleChanged();
void done();
protected:
- void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
+ void paint(QPainter* painter);
private slots:
void updateLayout();
void resetTrainingStatus();
@@ -81,7 +82,7 @@ private:
bool m_imageCacheDirty;
TrainingLineCore* m_trainingLineCore;
int m_currentLine;
- QPointer<QDeclarativeItem> m_cursorItem;
+ QPointer<QQuickItem> m_cursorItem;
QRectF m_cursorRectangle;
};
diff --git a/src/declarativeitems/preferencesproxy.cpp b/src/declarativeitems/preferencesproxy.cpp
index cdff652..7b88959 100644
--- a/src/declarativeitems/preferencesproxy.cpp
+++ b/src/declarativeitems/preferencesproxy.cpp
@@ -103,5 +103,5 @@ QColor PreferencesProxy::fingerColor(int index)
void PreferencesProxy::writeConfig()
{
- Preferences::self()->writeConfig();
+ Preferences::self()->save();
}
diff --git a/src/declarativeitems/scalebackgrounditem.cpp b/src/declarativeitems/scalebackgrounditem.cpp
index bc7ae72..65f7e82 100644
--- a/src/declarativeitems/scalebackgrounditem.cpp
+++ b/src/declarativeitems/scalebackgrounditem.cpp
@@ -20,13 +20,13 @@
#include <QPainter>
#include <QPainterPath>
-ScaleBackgroundItem::ScaleBackgroundItem(QDeclarativeItem* parent) :
- QDeclarativeItem(parent),
+ScaleBackgroundItem::ScaleBackgroundItem(QQuickItem* parent) :
+ QQuickPaintedItem(parent),
m_startAngle(0),
m_stopAngle(0),
m_scaleMarkHeight(0)
{
- setFlag(QGraphicsItem::ItemHasNoContents, false);
+ setFlag(QQuickItem::ItemHasContents, true);
}
qreal ScaleBackgroundItem::startAngle() const
@@ -89,7 +89,7 @@ void ScaleBackgroundItem::setColor(const QColor& color)
}
}
-void ScaleBackgroundItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
+void ScaleBackgroundItem::paint(QPainter* painter)
{
QBrush brush(m_color);
painter->setPen(Qt::NoPen);
diff --git a/src/declarativeitems/scalebackgrounditem.h b/src/declarativeitems/scalebackgrounditem.h
index a55b04a..fa3137f 100644
--- a/src/declarativeitems/scalebackgrounditem.h
+++ b/src/declarativeitems/scalebackgrounditem.h
@@ -18,9 +18,9 @@
#ifndef SCALEBACKGROUNDITEM_H
#define SCALEBACKGROUNDITEM_H
-#include <QDeclarativeItem>
+#include <QQuickPaintedItem>
-class ScaleBackgroundItem: public QDeclarativeItem
+class ScaleBackgroundItem: public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle NOTIFY startAngleChanged)
@@ -29,7 +29,7 @@ class ScaleBackgroundItem: public QDeclarativeItem
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
public:
- explicit ScaleBackgroundItem(QDeclarativeItem* parent = 0);
+ explicit ScaleBackgroundItem(QQuickItem* parent = 0);
qreal startAngle() const;
void setStartAngle(qreal angle);
qreal stopAngle() const;
@@ -38,7 +38,7 @@ public:
void setScaleMarkHeight(qreal height);
QColor color() const;
void setColor(const QColor& color);
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* , QWidget* = 0);
+ virtual void paint(QPainter* painter);
signals:
void startAngleChanged();
void stopAngleChanged();
diff --git a/src/declarativeitems/traininglinecore.cpp b/src/declarativeitems/traininglinecore.cpp
index 8dbf2de..7787e97 100644
--- a/src/declarativeitems/traininglinecore.cpp
+++ b/src/declarativeitems/traininglinecore.cpp
@@ -23,14 +23,14 @@
#include "core/trainingstats.h"
#include "preferences.h"
-TrainingLineCore::TrainingLineCore(QDeclarativeItem* parent) :
- QDeclarativeItem(parent),
+TrainingLineCore::TrainingLineCore(QQuickItem* parent) :
+ QQuickItem(parent),
m_active(false),
m_trainingStats(0),
m_hintKey(-1),
m_keyHintOccurrenceCount(0)
{
- setFlag(QDeclarativeItem::ItemAcceptsInputMethod);
+ setFlag(QQuickItem::ItemAcceptsInputMethod, true);
}
bool TrainingLineCore::active() const
@@ -47,12 +47,12 @@ void TrainingLineCore::setActive(bool active)
}
}
-QDeclarativeItem* TrainingLineCore::cursorItem() const
+QQuickItem* TrainingLineCore::cursorItem() const
{
return m_cursorItem;
}
-void TrainingLineCore::setCursorItem(QDeclarativeItem* cursorPosition)
+void TrainingLineCore::setCursorItem(QQuickItem* cursorPosition)
{
if (cursorPosition != m_cursorItem)
{
@@ -138,7 +138,7 @@ void TrainingLineCore::reset()
void TrainingLineCore::keyPressEvent(QKeyEvent* event)
{
- QDeclarativeItem::keyPressEvent(event);
+ QQuickItem::keyPressEvent(event);
if (!m_active)
{
diff --git a/src/declarativeitems/traininglinecore.h b/src/declarativeitems/traininglinecore.h
index ab5467d..e9d82d7 100644
--- a/src/declarativeitems/traininglinecore.h
+++ b/src/declarativeitems/traininglinecore.h
@@ -18,17 +18,17 @@
#ifndef TRAININGLINECORE_H
#define TRAININGLINECORE_H
-#include <QDeclarativeItem>
+#include <QQuickItem>
#include <QPointer>
class TrainingStats;
-class TrainingLineCore : public QDeclarativeItem
+class TrainingLineCore : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
- Q_PROPERTY(QDeclarativeItem* cursorItem READ cursorItem WRITE setCursorItem NOTIFY cursorItemChanged)
+ Q_PROPERTY(QQuickItem* cursorItem READ cursorItem WRITE setCursorItem NOTIFY cursorItemChanged)
Q_PROPERTY(TrainingStats* trainingStats READ trainingStats WRITE setTrainingStats NOTIFY trainingStatsChanged)
Q_PROPERTY(QString referenceLine READ referenceLine WRITE setReferenceLine NOTIFY referenceLineChanged)
Q_PROPERTY(QString actualLine READ actualLine NOTIFY actualLineChanged)
@@ -37,11 +37,11 @@ class TrainingLineCore : public QDeclarativeItem
Q_PROPERTY(QString nextCharacter READ nextCharacter NOTIFY actualLineChanged)
Q_PROPERTY(int hintKey READ hintKey NOTIFY hintKeyChanged)
public:
- explicit TrainingLineCore(QDeclarativeItem* parent = 0);
+ explicit TrainingLineCore(QQuickItem* parent = 0);
bool active() const;
void setActive(bool active);
- QDeclarativeItem* cursorItem() const;
- void setCursorItem(QDeclarativeItem* cursorItem);
+ QQuickItem* cursorItem() const;
+ void setCursorItem(QQuickItem* cursorItem);
TrainingStats* trainingStats() const;
void setTrainingStats(TrainingStats* trainingStats);
QString referenceLine() const;
@@ -80,7 +80,7 @@ private:
QString m_preeditString;
int m_hintKey;
int m_keyHintOccurrenceCount;
- QPointer<QDeclarativeItem> m_cursorItem;
+ QPointer<QQuickItem> m_cursorItem;
};
#endif // TRAININGLINECORE_H
diff --git a/src/editor/charactersviewdelegate.cpp b/src/editor/charactersviewdelegate.cpp
index 5584835..1173ec9 100644
--- a/src/editor/charactersviewdelegate.cpp
+++ b/src/editor/charactersviewdelegate.cpp
@@ -21,7 +21,7 @@
#include <KComboBox>
#include <KLineEdit>
-#include <KLocale>
+#include <KLocalizedString>
#include "core/keyboardlayout.h"
#include "core/keychar.h"
diff --git a/src/editor/courseeditor.cpp b/src/editor/courseeditor.cpp
index 6b5d04d..c2744db 100644
--- a/src/editor/courseeditor.cpp
+++ b/src/editor/courseeditor.cpp
@@ -20,6 +20,7 @@
#include <QUuid>
+#include <KLocalizedString>
#include <KMessageBox>
#include "core/course.h"
@@ -157,7 +158,7 @@ void CourseEditor::setDescription(const QString& newDescription)
void CourseEditor::addLesson()
{
const int newIndex = m_currentLessonIndex + 1;
- const QString id = QUuid::createUuid();
+ const QString id = QUuid::createUuid().toString();
QUndoCommand* command = new AddLessonCommand(m_course, newIndex, id);
currentUndoStack()->push(command);
diff --git a/src/editor/keyboardlayouteditor.cpp b/src/editor/keyboardlayouteditor.cpp
index 070f5b0..ce7b1a2 100644
--- a/src/editor/keyboardlayouteditor.cpp
+++ b/src/editor/keyboardlayouteditor.cpp
@@ -20,14 +20,12 @@
#include <math.h>
-#include <qdeclarative.h>
-
-#include <QDeclarativeContext>
#include <QUndoStack>
+#include <QStandardPaths>
+#include <QQmlContext>
-#include <KStandardDirs>
+#include <KLocalizedString>
#include <KMessageBox>
-#include <KDebug>
#include "core/dataindex.h"
#include "core/dataaccess.h"
@@ -53,8 +51,8 @@ KeyboardLayoutEditor::KeyboardLayoutEditor(QWidget* parent):
Application::setupDeclarativeBindings(m_view->engine());
- m_view->rootContext()->setContextObject(this);
- m_view->setSource(QUrl::fromLocalFile(KGlobal::dirs()->findResource("appdata", "qml/KeyboardLayoutEditor.qml")));
+ m_view->rootContext()->setContextProperty("keyboardLayoutEditor", this);
+ m_view->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, "qml/KeyboardLayoutEditor.qml")));
connect(m_newKeyToolButton, SIGNAL(clicked()), SLOT(createNewKey()));
connect(m_newSpecialKeyToolButton, SIGNAL(clicked()), SLOT(createNewSpecialKey()));
diff --git a/src/editor/keyboardlayouteditorview.cpp b/src/editor/keyboardlayouteditorview.cpp
index 835d168..cbef5a7 100644
--- a/src/editor/keyboardlayouteditorview.cpp
+++ b/src/editor/keyboardlayouteditorview.cpp
@@ -19,16 +19,15 @@
#include "keyboardlayouteditorview.h"
#include <QMouseEvent>
-#include <KDebug>
KeyboardLayoutEditorView::KeyboardLayoutEditorView(QWidget* parent) :
- QDeclarativeView(parent)
+ QQuickWidget(parent)
{
}
void KeyboardLayoutEditorView::mousePressEvent(QMouseEvent* event)
{
- QGraphicsView::mousePressEvent(event);
+ QQuickWidget::mousePressEvent(event);
if (!event->isAccepted() && event->button() == Qt::LeftButton)
{
diff --git a/src/editor/keyboardlayouteditorview.h b/src/editor/keyboardlayouteditorview.h
index 535ed20..e1bcf02 100644
--- a/src/editor/keyboardlayouteditorview.h
+++ b/src/editor/keyboardlayouteditorview.h
@@ -18,9 +18,9 @@
#ifndef KEYBOARDLAYOUTEDITORVIEW_H
#define KEYBOARDLAYOUTEDITORVIEW_H
-#include <QDeclarativeView>
+#include <QQuickWidget>
-class KeyboardLayoutEditorView : public QDeclarativeView
+class KeyboardLayoutEditorView : public QQuickWidget
{
Q_OBJECT
public:
diff --git a/src/editor/keyboardlayoutpropertieswidget.cpp b/src/editor/keyboardlayoutpropertieswidget.cpp
index 84d47d2..f922039 100644
--- a/src/editor/keyboardlayoutpropertieswidget.cpp
+++ b/src/editor/keyboardlayoutpropertieswidget.cpp
@@ -18,11 +18,9 @@
#include "keyboardlayoutpropertieswidget.h"
#include <QUndoStack>
+#include <QFontDatabase>
#include <QStyledItemDelegate>
-#include <KGlobalSettings>
-#include <KDebug>
-
#include "core/keyboardlayout.h"
#include "core/abstractkey.h"
#include "core/key.h"
@@ -42,8 +40,7 @@ KeyboardLayoutPropertiesWidget::KeyboardLayoutPropertiesWidget(QWidget* parent)
m_charactersViewDelegate(new CharactersViewDelegate(this))
{
setupUi(this);
- setFont(KGlobalSettings::smallestReadableFont());
- connect(KGlobalSettings::self(), SIGNAL(appearanceChanged()), SLOT(updateFont()));
+ setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
setSelectedKey(-1);
m_charactersView->setModel(m_charactersModel);
@@ -180,11 +177,6 @@ void KeyboardLayoutPropertiesWidget::setReadOnly(bool readOnly)
m_specialKeyModifierIdLineEdit->setReadOnly(readOnly);
}
-void KeyboardLayoutPropertiesWidget::updateFont()
-{
- setFont(KGlobalSettings::smallestReadableFont());
-}
-
void KeyboardLayoutPropertiesWidget::setKeyboardLayoutTitle(const QString& title)
{
QUndoCommand* command = new SetKeyboardLayoutTitleCommand(m_keyboardLayout, title);
diff --git a/src/editor/keyboardlayoutpropertieswidget.h b/src/editor/keyboardlayoutpropertieswidget.h
index 7480909..3a8778c 100644
--- a/src/editor/keyboardlayoutpropertieswidget.h
+++ b/src/editor/keyboardlayoutpropertieswidget.h
@@ -37,7 +37,6 @@ public:
void setSelectedKey(int index);
void setReadOnly(bool readOnly);
private slots:
- void updateFont();
void setKeyboardLayoutTitle(const QString& title);
void setKeyboardLayoutName(const QString& name);
void setKeyboardLayoutSize(const QSize& size);
diff --git a/src/editor/lessontexteditor.cpp b/src/editor/lessontexteditor.cpp
index 0316949..e9a3fd7 100644
--- a/src/editor/lessontexteditor.cpp
+++ b/src/editor/lessontexteditor.cpp
@@ -17,12 +17,12 @@
#include "lessontexteditor.h"
+#include <QFileDialog>
#include <QTextCursor>
#include <QTextDocumentFragment>
-#include <KFileDialog>
+#include <KLocalizedString>
#include <KMessageBox>
-#include <KDialog>
#include "editor/lessontexthighlighter.h"
@@ -76,7 +76,7 @@ void LessonTextEditor::onLessonTextChanged()
void LessonTextEditor::openTextFile()
{
- const QString path(KFileDialog::getOpenFileName(KUrl("kfiledialog:///text"), QString("text/plain"), this));
+ const QString path(QFileDialog::getOpenFileName(this, QString(), QString(), i18n("Text files (*.txt)")));
if (path.isNull())
return;
diff --git a/src/editor/lessontexthighlighter.cpp b/src/editor/lessontexthighlighter.cpp
index 1d438ba..c054c9a 100644
--- a/src/editor/lessontexthighlighter.cpp
+++ b/src/editor/lessontexthighlighter.cpp
@@ -18,7 +18,6 @@
#include "lessontexthighlighter.h"
#include <KColorScheme>
-#include <KDebug>
LessonTextHighlighter::LessonTextHighlighter(QObject* parent):
QSyntaxHighlighter(parent)
diff --git a/src/editor/newkeyboardlayoutwidget.cpp b/src/editor/newkeyboardlayoutwidget.cpp
index 854a756..72412cc 100644
--- a/src/editor/newkeyboardlayoutwidget.cpp
+++ b/src/editor/newkeyboardlayoutwidget.cpp
@@ -17,6 +17,8 @@
#include "newkeyboardlayoutwidget.h"
+#include <KLocalizedString>
+
#include "core/dataindex.h"
#include "models/resourcemodel.h"
diff --git a/src/editor/newresourceassistant.h b/src/editor/newresourceassistant.h
index c895131..9c31cec 100644
--- a/src/editor/newresourceassistant.h
+++ b/src/editor/newresourceassistant.h
@@ -19,6 +19,7 @@
#define NEWRESOURCEASSISTANT_H
#include <KAssistantDialog>
+#include <KLocalizedString>
#include "models/resourcemodel.h"
diff --git a/src/editor/resourceeditor.cpp b/src/editor/resourceeditor.cpp
index c809ff3..065a99e 100644
--- a/src/editor/resourceeditor.cpp
+++ b/src/editor/resourceeditor.cpp
@@ -19,22 +19,19 @@
#include <QUuid>
#include <QFile>
+#include <QFileDialog>
#include <QDir>
#include <QPointer>
#include <QTimer>
#include <QAbstractItemView>
+#include <QStandardPaths>
#include <QUndoGroup>
-#include <KGlobal>
-#include <KStandardDirs>
#include <KToolBar>
-#include <KAction>
#include <KActionCollection>
#include <KStandardAction>
-#include <KIcon>
-#include <KLocale>
+#include <KLocalizedString>
#include <KMessageBox>
-#include <KFileDialog>
#include "core/dataindex.h"
#include "core/dataaccess.h"
@@ -60,11 +57,11 @@ ResourceEditor::ResourceEditor(QWidget *parent) :
m_undoGroup(new QUndoGroup(this)),
m_actionCollection(new KActionCollection(this)),
m_newResourceAction(KStandardAction::openNew(this, SLOT(newResource()), m_actionCollection)),
- m_deleteResourceAction(new KAction(KIcon("edit-delete"), i18n("Delete"), this)),
+ m_deleteResourceAction(new QAction(QIcon::fromTheme("edit-delete"), i18n("Delete"), this)),
m_undoAction(KStandardAction::undo(m_undoGroup, SLOT(undo()), m_actionCollection)),
m_redoAction(KStandardAction::redo(m_undoGroup, SLOT(redo()), m_actionCollection)),
- m_importResourceAction(new KAction(KIcon("document-import"), i18n("Import"), this)),
- m_exportResourceAction(new KAction(KIcon("document-export"), i18n("Export"), this)),
+ m_importResourceAction(new QAction(QIcon::fromTheme("document-import"), i18n("Import"), this)),
+ m_exportResourceAction(new QAction(QIcon::fromTheme("document-export"), i18n("Export"), this)),
m_editorWidget(new ResourceEditorWidget(this)),
m_saveTimer(new QTimer(this))
@@ -221,7 +218,7 @@ void ResourceEditor::deleteResource()
void ResourceEditor::importResource()
{
- const QString path(KFileDialog::getOpenFileName(KUrl("kfiledialog:///importexport"), QString("text/xml"), this));
+ const QString path = QFileDialog::getOpenFileName(this, QString(), QString(), i18n("XML files (*.xml)"));
if (!path.isNull())
{
@@ -260,8 +257,8 @@ void ResourceEditor::exportResource()
return;
}
- const QString initialFileName(QString("filedialog:///importexport/%1.xml").arg(course->keyboardLayoutName()));
- const QString path(KFileDialog::getSaveFileName(KUrl(initialFileName), QString("text/xml"), this, QString(), KFileDialog::ConfirmOverwrite));
+ const QString initialFileName(QString("%1.xml").arg(course->keyboardLayoutName()));
+ const QString path(QFileDialog::getSaveFileName(this, QString(), initialFileName, i18n("XML files (*.xml)")));
if (!path.isNull())
{
@@ -288,8 +285,8 @@ void ResourceEditor::exportResource()
return;
}
- const QString initialFileName(QString("filedialog:///importexport/%1.xml").arg(keyboardlayout->name()));
- const QString path(KFileDialog::getSaveFileName(KUrl(initialFileName), QString("text/xml"), this, QString(), KFileDialog::ConfirmOverwrite));
+ const QString initialFileName(QString("%1.xml").arg(keyboardlayout->name()));
+ const QString path(QFileDialog::getSaveFileName(this, QString(), initialFileName, i18n("XML files (*.xml)")));
if (!path.isNull())
{
@@ -380,11 +377,11 @@ void ResourceEditor::prepareResourceRestore(Resource* backup)
if (Course* course = qobject_cast<Course*>(backup))
{
- msg = i18n("Course <b>%1</b> deleted", Qt::escape(course->title()));
+ msg = i18n("Course <b>%1</b> deleted", course->title().toHtmlEscaped());
}
else if (KeyboardLayout* keyboardLayout = qobject_cast<KeyboardLayout*>(backup))
{
- msg = i18n("Keyboard layout <b>%1</b> deleted", Qt::escape(keyboardLayout->title()));
+ msg = i18n("Keyboard layout <b>%1</b> deleted", keyboardLayout->title().toHtmlEscaped());
}
m_editorWidget->showMessage(ResourceEditorWidget::ResourceDeletedMsg, msg);
@@ -399,6 +396,7 @@ void ResourceEditor::prepareResourceRestore(Resource* backup)
Resource* ResourceEditor::storeResource(Resource* resource, Resource* dataIndexResource)
{
+ // FIXME: Is all this path mangling necessary?
UserDataAccess userDataAccess;
if (Course* course = qobject_cast<Course*>(resource))
@@ -407,7 +405,10 @@ Resource* ResourceEditor::storeResource(Resource* resource, Resource* dataIndexR
new DataIndexCourse():
dynamic_cast<DataIndexCourse*>(dataIndexResource);
- const QDir dir = QDir(KGlobal::dirs()->saveLocation("appdata", "courses", true));
+ QDir dir = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+ dir.mkpath(QStringLiteral("courses"));
+ dir.cd(QStringLiteral("courses"));
+
QString path = dataIndexResource == 0?
dir.filePath(QString("%1.xml").arg(course->id())):
dataIndexCourse->path();
@@ -438,7 +439,10 @@ Resource* ResourceEditor::storeResource(Resource* resource, Resource* dataIndexR
new DataIndexKeyboardLayout():
qobject_cast<DataIndexKeyboardLayout*>(dataIndexResource);
- const QDir dir = QDir(KGlobal::dirs()->saveLocation("appdata", "keyboardlayouts", true));
+ QDir dir = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+ dir.mkpath(QStringLiteral("keyboardlayouts"));
+ dir.cd(QStringLiteral("keyboardlayouts"));
+
QString path = dataIndexResource == 0?
dir.filePath(QString("%1.xml").arg(keyboardLayout->id())):
dataIndexKeyboardLayout->path();
@@ -520,11 +524,11 @@ bool ResourceEditor::importCourse(const QString& path)
))
{
case KMessageBox::Yes:
- course.setId(QUuid::createUuid());
+ course.setId(QUuid::createUuid().toString());
for (int j = 0; j < course.lessonCount(); j++)
{
Lesson* const lesson = course.lesson(j);
- lesson->setId(QUuid::createUuid());
+ lesson->setId(QUuid::createUuid().toString());
}
break;
default:
@@ -541,11 +545,11 @@ bool ResourceEditor::importCourse(const QString& path)
))
{
case KMessageBox::Yes:
- course.setId(QUuid::createUuid());
+ course.setId(QUuid::createUuid().toString());
for (int j = 0; j < course.lessonCount(); j++)
{
Lesson* const lesson = course.lesson(j);
- lesson->setId(QUuid::createUuid());
+ lesson->setId(QUuid::createUuid().toString());
}
break;
case KMessageBox::No:
@@ -588,7 +592,7 @@ bool ResourceEditor::importKeyboardLayout(const QString& path)
))
{
case KMessageBox::Yes:
- keyboardLayout.setId(QUuid::createUuid());
+ keyboardLayout.setId(QUuid::createUuid().toString());
break;
default:
return true;
@@ -604,7 +608,7 @@ bool ResourceEditor::importKeyboardLayout(const QString& path)
))
{
case KMessageBox::Yes:
- keyboardLayout.setId(QUuid::createUuid());
+ keyboardLayout.setId(QUuid::createUuid().toString());
break;
case KMessageBox::No:
overwriteDataIndexKeyboardLayout = testKeyboardLayout;
diff --git a/src/editor/resourceeditor.h b/src/editor/resourceeditor.h
index ab881ca..40c27d7 100644
--- a/src/editor/resourceeditor.h
+++ b/src/editor/resourceeditor.h
@@ -67,12 +67,12 @@ private:
Resource* m_backupResource;
QUndoGroup* m_undoGroup;
KActionCollection* m_actionCollection;
- KAction* m_newResourceAction;
- KAction* m_deleteResourceAction;
- KAction* m_undoAction;
- KAction* m_redoAction;
- KAction* m_importResourceAction;
- KAction* m_exportResourceAction;
+ QAction* m_newResourceAction;
+ QAction* m_deleteResourceAction;
+ QAction* m_undoAction;
+ QAction* m_redoAction;
+ QAction* m_importResourceAction;
+ QAction* m_exportResourceAction;
ResourceEditorWidget* m_editorWidget;
QTimer* m_saveTimer;
};
diff --git a/src/editor/resourceeditorwidget.cpp b/src/editor/resourceeditorwidget.cpp
index 493120b..4ffa5f9 100644
--- a/src/editor/resourceeditorwidget.cpp
+++ b/src/editor/resourceeditorwidget.cpp
@@ -17,8 +17,10 @@
#include "resourceeditorwidget.h"
+#include <QAction>
+
#include <KCategoryDrawer>
-#include <KAction>
+#include <KLocalizedString>
#include <KStandardAction>
#include "core/dataindex.h"
@@ -26,8 +28,8 @@
ResourceEditorWidget::ResourceEditorWidget(QWidget* parent) :
QWidget(parent),
Ui::ResourceEditorWidget(),
- m_undeleteAction(new KAction(KIcon("edit-undo"), i18n("Restore"), this)),
- m_clearMsgAction(new KAction(KIcon("window-close"), i18n("Dismiss"), this))
+ m_undeleteAction(new QAction(QIcon::fromTheme("edit-undo"), i18n("Restore"), this)),
+ m_clearMsgAction(new QAction(QIcon::fromTheme("window-close"), i18n("Dismiss"), this))
{
setupUi(this);
@@ -35,7 +37,7 @@ ResourceEditorWidget::ResourceEditorWidget(QWidget* parent) :
m_messageWidget->setCloseButtonVisible(false);
m_resourceView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
- m_resourceView->setCategoryDrawer(new KCategoryDrawerV3(m_resourceView));
+ m_resourceView->setCategoryDrawer(new KCategoryDrawer(m_resourceView));
m_resourceView->setMouseTracking(true);
m_resourceView->setVerticalScrollMode(QListView::ScrollPerPixel);
m_resourceView->setMinimumWidth(200);
diff --git a/src/editor/resourceeditorwidget.h b/src/editor/resourceeditorwidget.h
index 22f3400..06c590c 100644
--- a/src/editor/resourceeditorwidget.h
+++ b/src/editor/resourceeditorwidget.h
@@ -23,8 +23,8 @@
#include "ui_resourceeditorwidget.h"
class QAbstractItemView;
+class QAction;
class QUndoGroup;
-class KAction;
class KMessageWidget;
class Resource;
class ResourceModel;
@@ -52,8 +52,8 @@ private slots:
void requestResourceRestoration();
void clearMessage();
private:
- KAction* m_undeleteAction;
- KAction* m_clearMsgAction;
+ QAction* m_undeleteAction;
+ QAction* m_clearMsgAction;
MessageType m_currentMessageType;
};
diff --git a/src/editor/resourcetemplatewidget.cpp b/src/editor/resourcetemplatewidget.cpp
index c317728..5f53b54 100644
--- a/src/editor/resourcetemplatewidget.cpp
+++ b/src/editor/resourcetemplatewidget.cpp
@@ -18,6 +18,8 @@
#include "resourcetemplatewidget.h"
+#include <KLocalizedString>
+
#include "core/resource.h"
#include "models/categorizedresourcesortfilterproxymodel.h"
diff --git a/src/editor/resourcetypeswidget.cpp b/src/editor/resourcetypeswidget.cpp
index 96f19d6..4afcc00 100644
--- a/src/editor/resourcetypeswidget.cpp
+++ b/src/editor/resourcetypeswidget.cpp
@@ -17,8 +17,11 @@
#include "resourcetypeswidget.h"
+#include <QFileDialog>
#include <QStandardItemModel>
+#include <KLocalizedString>
+
ResourceTypesWidget::ResourceTypesWidget(QWidget* parent) :
QWidget(parent),
Ui::ResourceTypesWidget(),
diff --git a/src/keyboardlayoutmenu.cpp b/src/keyboardlayoutmenu.cpp
index 7c16929..c5d26b8 100644
--- a/src/keyboardlayoutmenu.cpp
+++ b/src/keyboardlayoutmenu.cpp
@@ -17,8 +17,9 @@
#include "keyboardlayoutmenu.h"
-#include <KAction>
-#include <KLocale>
+#include <QAction>
+
+#include <KLocalizedString>
#include "core/dataindex.h"
#include "preferences.h"
@@ -68,7 +69,7 @@ void KeyboardLayoutMenu::populate()
for (int i = 0; i < m_dataIndex->keyboardLayoutCount(); i++)
{
DataIndexKeyboardLayout* layout = m_dataIndex->keyboardLayout(i);
- KAction* action = new KAction(layout->title(), this);
+ QAction* action = new QAction(layout->title(), this);
action->setData(layout->name());
action->setCheckable(true);
diff --git a/src/main.cpp b/src/main.cpp
index d6d3be1..a1e946c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,52 +15,63 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <QCommandLineParser>
+
#include <KAboutData>
-#include <KCmdLineArgs>
-#include <KLocale>
+#include <KLocalizedString>
#include "application.h"
#include "mainwindow.h"
-
-#include "KDebug"
-
-static const char description[] =
- I18N_NOOP("Learn and practice typewriting");
-
-static const char version[] = "2.3.0";
+#include "version.h"
int main(int argc, char **argv)
{
- KAboutData about("ktouch", 0,
- ki18n("Typewriting Trainer"),
- version,
- ki18n(description),
- KAboutData::License_GPL,
- ki18n(
- "Copyright (C) 2011-2012 by Sebastian Gottfried\n"
+ Application app(argc, argv);
+
+ KLocalizedString::setApplicationDomain("ktouch");
+
+ KAboutData about(QStringLiteral("ktouch"),
+ i18n("Typewriting Trainer"),
+ QStringLiteral(KTOUCH_VERSION_STRING),
+ i18n("Learn and practice typewriting"),
+ KAboutLicense::GPL,
+ i18n(
+ "Copyright (C) 2011-2015 by Sebastian Gottfried\n"
"Copyright (C) 2000-2007 by Håvard Frøiland and Andreas Nicolai"
),
- KLocalizedString(),
- "http://edu.kde.org/ktouch",
- "submit@bugs.kde.org");
+ QString(),
+ QStringLiteral("http://edu.kde.org/ktouch"),
+ QStringLiteral("submit@bugs.kde.org"));
+
+ about.addAuthor(i18n("Sebastian Gottfried"), i18n("Current maintainer"), "sebastiangottfried@web.de");
+ about.addAuthor(i18n("Andreas Nicolai"), i18n("Former maintainer and programmer"), "Andreas.Nicolai@gmx.net");
+ about.addAuthor(i18n("Håvard Frøiland"), i18n("Original author"), "haavard@users.sourceforge.net");
- about.addAuthor(ki18n("Sebastian Gottfried"), ki18n("Current maintainer"), "sebastiangottfried@web.de");
- about.addAuthor(ki18n("Andreas Nicolai"), ki18n("Former maintainer and programmer"), "Andreas.Nicolai@gmx.net");
- about.addAuthor(ki18n("Håvard Frøiland"), ki18n("Original author"), "haavard@users.sourceforge.net");
+ about.addCredit(i18n("David Vignoni"), i18n("Creator of the SVG icon"), "david80v@tin.it");
+ about.addCredit(i18n("Anne-Marie Mahfouf"), i18n("Lots of patches, fixes and updates"), "annma@kde.org");
+ about.addCredit(i18n("All the creators of training and keyboard files"));
- about.addCredit(ki18n("David Vignoni"), ki18n("Creator of the SVG icon"), "david80v@tin.it");
- about.addCredit(ki18n("Anne-Marie Mahfouf"), ki18n("Lots of patches, fixes and updates"), "annma@kde.org");
- about.addCredit(ki18n("All the creators of training and keyboard files"));
+ about.setOrganizationDomain(QByteArray("kde.org"));
- KCmdLineArgs::init(argc, argv, &about);
- KCmdLineOptions options;
- options.add("opengl", ki18n("Use OpenGL for rendering (experimental)"));
- options.add("resource-editor", ki18n("Launch the course and keyboard layout editor"));
- KCmdLineArgs::addCmdLineOptions(options);
+ KAboutData::setApplicationData(about);
- KApplication::setGraphicsSystem("raster");
+ app.setApplicationName(about.componentName());
+ app.setApplicationDisplayName(about.displayName());
+ app.setOrganizationDomain(about.organizationDomain());
+ app.setApplicationVersion(about.version());
+
+ QApplication::setWindowIcon(QIcon::fromTheme(QLatin1String("ktouch")));
+
+
+ QCommandLineParser parser;
+ about.setupCommandLine(&parser);
+
+ parser.addOption(QCommandLineOption(QStringLiteral("resource-editor"), i18n("Launch the course and keyboard layout editor"), QStringLiteral("resource-editor")));
+
+ parser.process(app);
+
+ about.processCommandLine(&parser);
- Application app;
if (app.isSessionRestored())
{
@@ -74,11 +85,11 @@ int main(int argc, char **argv)
}
else if (name == "ResourceEditor")
{
- QWeakPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
+ QSharedPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
if (resourceEditorRef.isNull())
{
- resourceEditorRef = new ResourceEditor();
+ resourceEditorRef = QSharedPointer<ResourceEditor>(new ResourceEditor());
resourceEditorRef.data()->restore(i);
}
}
@@ -86,14 +97,12 @@ int main(int argc, char **argv)
}
else
{
- KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
-
- if (args->isSet("resource-editor"))
+ if (parser.isSet("resource-editor"))
{
- QWeakPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
+ QSharedPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
if (resourceEditorRef.isNull())
{
- resourceEditorRef = new ResourceEditor();
+ resourceEditorRef = QSharedPointer<ResourceEditor>(new ResourceEditor());
}
ResourceEditor* resourceEditor = resourceEditorRef.data();
@@ -104,10 +113,8 @@ int main(int argc, char **argv)
{
MainWindow *mainWin = 0;
mainWin = new MainWindow();
- mainWin->setUseOpenGLViewport(args->isSet("opengl"));
mainWin->show();
}
- args->clear();
}
return app.exec();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 72b0e89..606a724 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -17,17 +17,15 @@
#include "mainwindow.h"
-#include <QDeclarativeView>
-#include <QDeclarativeContext>
-#include <QGLWidget>
+#include <QQuickWidget>
#include <QMenu>
#include <QPointer>
#include <QVariant>
+#include <QDialogButtonBox>
+#include <QStandardPaths>
+#include <QMenu>
+#include <QQmlContext>
-#include <KDialog>
-#include <KStandardDirs>
-#include <KMenu>
-#include <KCmdLineArgs>
#include <KActionCollection>
#include <KStandardAction>
#include <KHelpMenu>
@@ -35,6 +33,7 @@
#include <KShortcutsDialog>
#include <KConfigDialog>
#include <KCMultiDialog>
+#include <KLocalizedString>
#include "editor/resourceeditor.h"
#include "application.h"
@@ -49,18 +48,14 @@
#include "keyboardlayoutmenu.h"
#endif
-#ifdef KTOUCH_BUILD_WITH_X11
-#else
-#endif
const QString keyboardKCMName = "kcm_keyboard";
MainWindow::MainWindow(QWidget* parent):
KMainWindow(parent),
- m_view(new QDeclarativeView(this)),
+ m_view(new QQuickWidget(this)),
m_actionCollection(new KActionCollection(this)),
- m_menu(new QMenu(this)),
- m_useOpenGLViewport(false)
+ m_menu(new QMenu(this))
{
#ifdef KTOUCH_BUILD_WITH_X11
m_XEventNotifier = new XEventNotifier();
@@ -96,20 +91,6 @@ DataIndex *MainWindow::dataIndex()
return Application::dataIndex();
}
-bool MainWindow::useOpenGLViewport() const
-{
- return m_useOpenGLViewport;
-}
-
-void MainWindow::setUseOpenGLViewport(bool useOpenGLViewport)
-{
- if (useOpenGLViewport != m_useOpenGLViewport)
- {
- m_useOpenGLViewport = useOpenGLViewport;
- m_view->setViewport(useOpenGLViewport? new QGLWidget(): new QWidget());
- }
-}
-
void MainWindow::showMenu(int xPos, int yPos)
{
m_menu->popup(m_view->mapToGlobal(QPoint(xPos, yPos)));
@@ -117,10 +98,10 @@ void MainWindow::showMenu(int xPos, int yPos)
void MainWindow::showResourceEditor()
{
- QWeakPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
+ QSharedPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
if (resourceEditorRef.isNull())
{
- resourceEditorRef = new ResourceEditor();
+ resourceEditorRef = QSharedPointer<ResourceEditor>(new ResourceEditor());
}
ResourceEditor* resourceEditor = resourceEditorRef.data();
@@ -131,19 +112,21 @@ void MainWindow::showResourceEditor()
bool MainWindow::showCustomLessonDialog(Lesson* lesson, KeyboardLayout* keyboardLayout)
{
- KDialog* dialog = new KDialog(this);
- CustomLessonEditorWidget* editor = new CustomLessonEditorWidget(dialog);
+ QDialog* dialog = new QDialog(this);
+ QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, dialog);
+ CustomLessonEditorWidget* editor = new CustomLessonEditorWidget(buttonBox);
- dialog->setWindowTitle(i18n("Edit Custom Lesson"));
- dialog->setButtons(KDialog::Ok | KDialog::Cancel);
- dialog->setMainWidget(editor);
+ buttonBox->setWindowTitle(i18n("Edit Custom Lesson"));
+
+
+ connect(editor, &CustomLessonEditorWidget::validChanged, buttonBox->button(QDialogButtonBox::Ok), &QPushButton::setEnabled);
- connect(editor, SIGNAL(validChanged(bool)), dialog, SLOT(enableButtonOk(bool)));
editor->setLesson(lesson);
editor->setKeyboardLayout(keyboardLayout);
- bool result = dialog->exec() == KDialog::Accepted;
+
+ bool result = dialog->exec() == QDialog::Accepted;
delete dialog;
@@ -191,8 +174,8 @@ void MainWindow::init()
m_actionCollection->addAssociatedWidget(this);
m_menu->addAction(KStandardAction::fullScreen(this, SLOT(setFullscreen(bool)), this, m_actionCollection));
m_menu->addSeparator();
- KAction* editorAction = new KAction(i18n("Course and Keyboard Layout Editor..."), this);
- connect(editorAction, SIGNAL(triggered()), SLOT(showResourceEditor()));
+ QAction* editorAction = new QAction(i18n("Course and Keyboard Layout Editor..."), this);
+ connect(editorAction, &QAction::triggered, this, &MainWindow::showResourceEditor);
m_actionCollection->addAction("editor", editorAction);
m_menu->addAction(editorAction);
m_menu->addSeparator();
@@ -203,16 +186,16 @@ void MainWindow::init()
#ifdef KTOUCH_BUILD_WITH_X11
if (testKCMAvailibility(keyboardKCMName))
{
- KAction* configureKeyboardAction = new KAction(i18n("Configure Keyboard..."), this);
+ QAction* configureKeyboardAction = new QAction(i18n("Configure Keyboard..."), this);
m_menu->addAction(configureKeyboardAction);
- connect(configureKeyboardAction, SIGNAL(triggered()), SLOT(configureKeyboard()));
+ connect(configureKeyboardAction, &QAction::triggered, this, &MainWindow::configureKeyboard);
}
#else
m_menu->addMenu(m_keyboardLayoutMenu);
#endif
m_menu->addSeparator();
- KHelpMenu* helpMenu = new KHelpMenu(m_menu, KCmdLineArgs::aboutData(), false, m_actionCollection);
+ KHelpMenu* helpMenu = new KHelpMenu(this);
m_menu->addMenu(helpMenu->menu());
setCentralWidget(m_view);
@@ -220,10 +203,9 @@ void MainWindow::init()
Application::setupDeclarativeBindings(m_view->engine());
m_view->setMinimumSize(1000, 700);
- m_view->setStyleSheet("background-color: transparent;");
- m_view->rootContext()->setContextObject(this);
- m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- m_view->setSource(QUrl::fromLocalFile(KGlobal::dirs()->findResource("appdata", "qml/main.qml")));
+ m_view->rootContext()->setContextProperty(QStringLiteral("ktouch"), this);
+ m_view->setResizeMode(QQuickWidget::SizeRootObjectToView);
+ m_view->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, "qml/main.qml")));
}
bool MainWindow::testKCMAvailibility(const QString& name)
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 509b371..feccd96 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -22,7 +22,7 @@
#include <QWeakPointer>
-class QDeclarativeView;
+class QQuickWidget;
class QMenu;
class KActionCollection;
class DataIndex;
@@ -46,8 +46,6 @@ public:
~MainWindow();
QString keyboardLayoutName() const;
DataIndex* dataIndex();
- bool useOpenGLViewport() const;
- void setUseOpenGLViewport(bool useOpenGLViewport);
Q_INVOKABLE void showMenu(int xPos, int yPos);
public slots:
void showResourceEditor();
@@ -62,10 +60,9 @@ private slots:
private:
void init();
bool testKCMAvailibility(const QString& name);
- QDeclarativeView* m_view;
+ QQuickWidget* m_view;
KActionCollection* m_actionCollection;
QMenu* m_menu;
- bool m_useOpenGLViewport;
#ifdef KTOUCH_BUILD_WITH_X11
XEventNotifier* m_XEventNotifier;
#else
diff --git a/src/models/categorizedresourcesortfilterproxymodel.cpp b/src/models/categorizedresourcesortfilterproxymodel.cpp
index 418ba64..ff3ad03 100644
--- a/src/models/categorizedresourcesortfilterproxymodel.cpp
+++ b/src/models/categorizedresourcesortfilterproxymodel.cpp
@@ -18,7 +18,7 @@
#include "categorizedresourcesortfilterproxymodel.h"
-#include "KStringHandler"
+#include <QCollator>
CategorizedResourceSortFilterProxyModel::CategorizedResourceSortFilterProxyModel(QObject *parent) :
KCategorizedSortFilterProxyModel(parent),
@@ -81,7 +81,10 @@ bool CategorizedResourceSortFilterProxyModel::subSortLessThan(const QModelIndex&
{
const QString leftStr = sourceModel()->data(left, Qt::DisplayRole).toString();
const QString rightStr = sourceModel()->data(right, Qt::DisplayRole).toString();
- const int difference = KStringHandler::naturalCompare(leftStr, rightStr, Qt::CaseInsensitive);
+ QCollator locater;
+ locater.setCaseSensitivity(Qt::CaseInsensitive);
+
+ const int difference = locater.compare(leftStr, rightStr);
if (difference == 0)
{
diff --git a/src/models/charactersmodel.cpp b/src/models/charactersmodel.cpp
index 275537b..231488e 100644
--- a/src/models/charactersmodel.cpp
+++ b/src/models/charactersmodel.cpp
@@ -19,7 +19,7 @@
#include <QSignalMapper>
-#include <KLocale>
+#include <KLocalizedString>
#include "core/keyboardlayout.h"
#include "core/key.h"
diff --git a/src/models/lessonmodel.cpp b/src/models/lessonmodel.cpp
index 3da2fef..b35fb84 100644
--- a/src/models/lessonmodel.cpp
+++ b/src/models/lessonmodel.cpp
@@ -20,7 +20,7 @@
#include <QSignalMapper>
-#include <KLocale>
+#include <KLocalizedString>
#include <core/course.h>
#include <core/lesson.h>
diff --git a/src/models/resourcemodel.cpp b/src/models/resourcemodel.cpp
index 6e34a6f..90fdf5d 100644
--- a/src/models/resourcemodel.cpp
+++ b/src/models/resourcemodel.cpp
@@ -17,10 +17,10 @@
#include "resourcemodel.h"
+#include <QIcon>
#include <QSignalMapper>
-#include <KLocale>
-#include <KIcon>
+#include <KLocalizedString>
#include <KCategorizedSortFilterProxyModel>
ResourceModel::ResourceModel(QObject* parent) :
@@ -29,11 +29,6 @@ ResourceModel::ResourceModel(QObject* parent) :
m_signalMapper(new QSignalMapper(this))
{
connect(m_signalMapper, SIGNAL(mapped(int)), SLOT(emitDataChanged(int)));
- QHash<int,QByteArray> roleNames = this->roleNames();
- roleNames.insert(ResourceModel::KeyboardLayoutNameRole, "keyboardLayoutName");
- roleNames.insert(ResourceModel::PathRole, "path");
- roleNames.insert(ResourceModel::DataRole, "dataRole");
- setRoleNames(roleNames);
}
DataIndex* ResourceModel::dataIndex() const
@@ -120,6 +115,15 @@ int ResourceModel::rowCount(const QModelIndex &parent) const
return m_dataIndex->courseCount() + m_dataIndex->keyboardLayoutCount();
}
+QHash<int, QByteArray> ResourceModel::roleNames() const
+{
+ QHash<int, QByteArray> names = QAbstractItemModel::roleNames();
+ names.insert(ResourceModel::KeyboardLayoutNameRole, "keyboardLayoutName");
+ names.insert(ResourceModel::PathRole, "path");
+ names.insert(ResourceModel::DataRole, "dataRole");
+ return names;
+}
+
void ResourceModel::onCourseAboutToBeAdded(DataIndexCourse* course, int index)
{
connectToCourse(course);
@@ -258,7 +262,7 @@ void ResourceModel::updateMappings()
QIcon ResourceModel::resourceIcon(DataIndex::Source source) const
{
- static QIcon systemIcon = KIcon("computer");
- static QIcon userIcon = KIcon("user-identity");
+ static QIcon systemIcon = QIcon::fromTheme("computer");
+ static QIcon userIcon = QIcon::fromTheme("user-identity");
return source == DataIndex::BuiltInResource? systemIcon: userIcon;
}
diff --git a/src/models/resourcemodel.h b/src/models/resourcemodel.h
index 85f9648..0008fc2 100644
--- a/src/models/resourcemodel.h
+++ b/src/models/resourcemodel.h
@@ -53,6 +53,7 @@ public:
QVariant data(const QModelIndex& index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
int rowCount(const QModelIndex &parent) const;
+ QHash<int, QByteArray> roleNames() const;
signals:
void dataIndexChanged();
diff --git a/src/ui/keyboardlayouteditor.ui b/src/ui/keyboardlayouteditor.ui
index d9ab3dc..e9663b9 100644
--- a/src/ui/keyboardlayouteditor.ui
+++ b/src/ui/keyboardlayouteditor.ui
@@ -10,19 +10,7 @@
<height>480</height>
</rect>
</property>
- <layout class="QVBoxLayout" name="m_verticalLayout">
- <property name="spacing">
- <number>2</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="KMessageWidget" name="m_messageWidget"/>
</item>
@@ -176,28 +164,20 @@
</layout>
</item>
<item>
- <widget class="KeyboardLayoutEditorView" name="m_view">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="verticalScrollBarPolicy">
- <enum>Qt::ScrollBarAsNeeded</enum>
- </property>
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAsNeeded</enum>
- </property>
- <property name="backgroundBrush">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>88</red>
- <green>88</green>
- <blue>88</blue>
- </color>
- </brush>
+ <widget class="QScrollArea" name="m_scrollArea">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
</property>
+ <widget class="KeyboardLayoutEditorView" name="m_view">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>517</width>
+ <height>287</height>
+ </rect>
+ </property>
+ </widget>
</widget>
</item>
<item>
@@ -221,7 +201,7 @@
</customwidget>
<customwidget>
<class>KeyboardLayoutEditorView</class>
- <extends>QGraphicsView</extends>
+ <extends>QWidget</extends>
<header>editor/keyboardlayouteditorview.h</header>
</customwidget>
<customwidget>
@@ -232,7 +212,6 @@
</customwidget>
</customwidgets>
<tabstops>
- <tabstop>m_view</tabstop>
<tabstop>m_newKeyToolButton</tabstop>
<tabstop>m_newSpecialKeyToolButton</tabstop>
<tabstop>m_deleteKeyToolButton</tabstop>
diff --git a/src/ui/trainingconfigwidget.ui b/src/ui/trainingconfigwidget.ui
index 68d7eab..d3d6c4d 100644
--- a/src/ui/trainingconfigwidget.ui
+++ b/src/ui/trainingconfigwidget.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>344</width>
- <height>267</height>
+ <width>374</width>
+ <height>299</height>
</rect>
</property>
<property name="sizePolicy">
@@ -79,14 +79,14 @@
<item row="4" column="1">
<widget class="QRadioButton" name="kcfg_NextLineWithReturn">
<property name="text">
- <string>Return</string>
+ <string>Ret&amp;urn</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QRadioButton" name="kcfg_NextLineWithSpace">
<property name="text">
- <string>Space</string>
+ <string>Spa&amp;ce</string>
</property>
</widget>
</item>
@@ -120,13 +120,10 @@
<string>Lesson unlocking limits</string>
</property>
<layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
<item row="0" column="0">
<widget class="QLabel" name="requiredStrokesPerMinuteLabel">
<property name="text">
- <string>Minimum strokes per minute:</string>
+ <string>Minimum strokes &amp;per minute:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -137,25 +134,13 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="KIntNumInput" name="kcfg_RequiredStrokesPerMinute">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimum">
- <number>0</number>
- </property>
+ <widget class="QSpinBox" name="kcfg_RequiredStrokesPerMinute">
<property name="maximum">
<number>360</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
- <property name="sliderEnabled">
- <bool>true</bool>
- </property>
</widget>
</item>
<item row="1" column="0">
@@ -172,31 +157,19 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="KDoubleNumInput" name="kcfg_RequiredAccuracy">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <widget class="QDoubleSpinBox" name="kcfg_RequiredAccuracy">
+ <property name="suffix">
+ <string> %</string>
+ </property>
+ <property name="decimals">
+ <number>1</number>
</property>
<property name="minimum">
<double>90.000000000000000</double>
</property>
- <property name="maximum">
- <double>100.000000000000000</double>
- </property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
- <property name="suffix">
- <string>%</string>
- </property>
- <property name="decimals">
- <number>1</number>
- </property>
- <property name="sliderEnabled">
- <bool>true</bool>
- </property>
</widget>
</item>
</layout>
@@ -217,18 +190,15 @@
</item>
</layout>
</widget>
- <customwidgets>
- <customwidget>
- <class>KDoubleNumInput</class>
- <extends>QWidget</extends>
- <header>knuminput.h</header>
- </customwidget>
- <customwidget>
- <class>KIntNumInput</class>
- <extends>QWidget</extends>
- <header>knuminput.h</header>
- </customwidget>
- </customwidgets>
+ <tabstops>
+ <tabstop>kcfg_EnforceTypingErrorCorrection</tabstop>
+ <tabstop>kcfg_ShowKeyboard</tabstop>
+ <tabstop>kcfg_ShowStatistics</tabstop>
+ <tabstop>kcfg_NextLineWithReturn</tabstop>
+ <tabstop>kcfg_NextLineWithSpace</tabstop>
+ <tabstop>kcfg_RequiredStrokesPerMinute</tabstop>
+ <tabstop>kcfg_RequiredAccuracy</tabstop>
+ </tabstops>
<resources/>
<connections/>
</ui>
diff --git a/src/undocommands/coursecommands.cpp b/src/undocommands/coursecommands.cpp
index 5f43c0b..919400e 100644
--- a/src/undocommands/coursecommands.cpp
+++ b/src/undocommands/coursecommands.cpp
@@ -18,7 +18,7 @@
#include "coursecommands.h"
-#include <KLocale>
+#include <KLocalizedString>
#include "core/course.h"
#include "core/lesson.h"
diff --git a/src/undocommands/keyboardlayoutcommands.cpp b/src/undocommands/keyboardlayoutcommands.cpp
index 85f954c..2154dbc 100644
--- a/src/undocommands/keyboardlayoutcommands.cpp
+++ b/src/undocommands/keyboardlayoutcommands.cpp
@@ -17,7 +17,7 @@
#include "keyboardlayoutcommands.h"
-#include "KLocale"
+#include <KLocalizedString>
#include <core/keyboardlayout.h>
#include <core/abstractkey.h>