summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Gottfried <sebastian.gottfried@posteo.de>2016-11-01 10:12:48 (GMT)
committerSebastian Gottfried <sebastian.gottfried@posteo.de>2016-11-01 10:12:48 (GMT)
commitf26c9dd5e1f89b132da4af26fa36f23203875d59 (patch)
tree5f3980471ce2b02c1533257a5417f47d48f9b021
parent5a0b0ff46aa2347c0a65d16109d1957998f0dec0 (diff)
parent3c9193c969cbcc4b8e58f1a25e3007e19f760df0 (diff)
Merge Branch 'frameworks'
-rw-r--r--CMakeLists.txt68
-rw-r--r--data/CMakeLists.txt6
-rw-r--r--doc/CMakeLists.txt8
-rw-r--r--doc/index.docbook20
-rw-r--r--doc/man-ktouch.1.docbook15
-rw-r--r--icons/128-apps-ktouch.png (renamed from icons/hi128-app-ktouch.png)bin7031 -> 7031 bytes
-rw-r--r--icons/16-apps-ktouch.png (renamed from icons/hi16-app-ktouch.png)bin656 -> 656 bytes
-rw-r--r--icons/22-apps-ktouch.png (renamed from icons/hi22-app-ktouch.png)bin947 -> 947 bytes
-rw-r--r--icons/32-apps-ktouch.png (renamed from icons/hi32-app-ktouch.png)bin1409 -> 1409 bytes
-rw-r--r--icons/48-apps-ktouch.png (renamed from icons/hi48-app-ktouch.png)bin2239 -> 2239 bytes
-rw-r--r--icons/CMakeLists.txt12
-rw-r--r--icons/sc-apps-ktouch.svgz (renamed from icons/hisc-app-ktouch.svgz)bin5344 -> 5344 bytes
-rw-r--r--images/CMakeLists.txt26
-rw-r--r--images/accuracymeter-background.pngbin0 -> 1611 bytes
-rw-r--r--images/accuracymeter-hand.pngbin0 -> 666 bytes
-rw-r--r--images/accuracymeter-scale.pngbin0 -> 892 bytes
-rw-r--r--images/accuracymeter.svgzbin3907 -> 3754 bytes
-rw-r--r--images/balloontip.svgzbin0 -> 1065 bytes
-rw-r--r--images/charactersperminutemeter-background.pngbin0 -> 1611 bytes
-rw-r--r--images/charactersperminutemeter-hand.pngbin0 -> 666 bytes
-rw-r--r--images/charactersperminutemeter-scale.pngbin0 -> 1063 bytes
-rw-r--r--images/charactersperminutemeter.svgzbin4128 -> 3954 bytes
-rw-r--r--images/elapsedtimemeter-background.pngbin0 -> 3838 bytes
-rw-r--r--images/elapsedtimemeter-minute-hand.pngbin0 -> 349 bytes
-rw-r--r--images/elapsedtimemeter-second-hand.pngbin0 -> 454 bytes
-rw-r--r--images/elapsedtimemeter.svgzbin4319 -> 4036 bytes
-rw-r--r--images/meterbox-left.pngbin0 -> 362 bytes
-rw-r--r--images/meterbox-right.pngbin0 -> 326 bytes
-rw-r--r--images/meterbox.svgzbin2374 -> 1528 bytes
-rw-r--r--images/resizegrip.svgzbin1535 -> 0 bytes
-rw-r--r--images/trainingscreen-footer.pngbin0 -> 80 bytes
-rw-r--r--images/trainingscreen-header.pngbin0 -> 80 bytes
-rw-r--r--images/trainingscreen-toolbar.pngbin0 -> 84 bytes
-rw-r--r--images/trainingscreen-viewport-shadow.pngbin0 -> 92 bytes
-rw-r--r--images/trainingscreen-viewport.pngbin0 -> 80 bytes
-rw-r--r--src/CMakeLists.txt114
-rw-r--r--src/application.cpp78
-rw-r--r--src/application.h20
-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.cpp65
-rw-r--r--src/core/keyboardlayout.cpp3
-rw-r--r--src/core/keychar.cpp2
-rw-r--r--src/core/profiledataaccess.cpp96
-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/customlessoneditordialog.cpp (renamed from src/customlessoneditorwidget.cpp)31
-rw-r--r--src/customlessoneditordialog.h (renamed from src/customlessoneditorwidget.h)14
-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.cpp12
-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.cpp5
-rw-r--r--src/editor/keyboardlayouteditor.cpp25
-rw-r--r--src/editor/keyboardlayouteditor.h1
-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/ktouchcontext.cpp202
-rw-r--r--src/ktouchcontext.h70
-rw-r--r--src/main.cpp99
-rw-r--r--src/mainwindow.cpp211
-rw-r--r--src/mainwindow.h39
-rw-r--r--src/models/categorizedresourcesortfilterproxymodel.cpp7
-rw-r--r--src/models/charactersmodel.cpp2
-rw-r--r--src/models/learningprogressmodel.cpp4
-rw-r--r--src/models/lessonmodel.cpp2
-rw-r--r--src/models/resourcemodel.cpp43
-rw-r--r--src/models/resourcemodel.h2
-rw-r--r--src/qml/AccuracyMeter.qml43
-rw-r--r--src/qml/Balloon.qml245
-rw-r--r--src/qml/CMakeLists.txt1
-rw-r--r--src/qml/CharactersPerMinuteMeter.qml41
-rw-r--r--src/qml/CourseDescriptionItem.qml19
-rw-r--r--src/qml/CoursePage.qml7
-rw-r--r--src/qml/CourseSelector.qml101
-rw-r--r--src/qml/CustomLessonSelector.qml95
-rw-r--r--src/qml/DetailedRadioButton.qml22
-rw-r--r--src/qml/ElapsedTimeMeter.qml56
-rw-r--r--src/qml/HomeScreen.qml55
-rw-r--r--src/qml/InfoItem.qml2
-rw-r--r--src/qml/InformationTable.qml12
-rw-r--r--src/qml/InitialProfileForm.qml84
-rw-r--r--src/qml/InlineToolbar.qml13
-rw-r--r--src/qml/KeyItem.qml51
-rw-r--r--src/qml/KeyLabel.qml19
-rw-r--r--src/qml/Keyboard.qml2
-rw-r--r--src/qml/KeyboardLayoutEditor.qml26
-rw-r--r--src/qml/KeyboardUnavailableNotice.qml18
-rw-r--r--src/qml/LearningProgressChart.qml8
-rw-r--r--src/qml/LessonLockedNotice.qml46
-rw-r--r--src/qml/LessonPreview.qml2
-rw-r--r--src/qml/LessonSelector.qml52
-rw-r--r--src/qml/LessonSelectorBase.qml30
-rw-r--r--src/qml/ListItem.qml107
-rw-r--r--src/qml/MessageBox.qml17
-rw-r--r--src/qml/Meter.qml56
-rw-r--r--src/qml/NoCoursesMessage.qml78
-rw-r--r--src/qml/ProfileDetailsItem.qml43
-rw-r--r--src/qml/ProfileForm.qml15
-rw-r--r--src/qml/ProfileSelector.qml94
-rw-r--r--src/qml/ScoreScreen.qml210
-rw-r--r--src/qml/SelectionGrip.qml33
-rw-r--r--src/qml/SelectionRectangle.qml2
-rw-r--r--src/qml/SheetDialog.qml40
-rw-r--r--src/qml/StatBox.qml12
-rw-r--r--src/qml/TrainingScreen.qml125
-rw-r--r--src/qml/TrainingScreenMenuOverlay.qml124
-rw-r--r--src/qml/TrainingScreenToolbar.qml17
-rw-r--r--src/qml/TrainingWidget.qml227
-rw-r--r--src/qml/main.qml58
-rw-r--r--src/ui/customlessoneditordialog.ui110
-rw-r--r--src/ui/keyboardlayouteditor.ui86
-rw-r--r--src/ui/trainingconfigwidget.ui72
-rw-r--r--src/undocommands/coursecommands.cpp2
-rw-r--r--src/undocommands/keyboardlayoutcommands.cpp2
-rw-r--r--src/x11_helper.cpp473
-rw-r--r--src/x11_helper.h315
142 files changed, 2610 insertions, 2639 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b594b44..72be887 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,22 +3,66 @@
project(ktouch)
-find_package(KDE4 4.9.95 REQUIRED)
-include(KDE4Defaults)
+# KDE Application Version, managed by release script
+set (KDE_APPLICATIONS_VERSION_MAJOR "16")
+set (KDE_APPLICATIONS_VERSION_MINOR "11")
+set (KDE_APPLICATIONS_VERSION_MICRO "70")
+set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
-include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${QT4_INCLUDES})
-add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+
+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(KDEInstallDirs)
+include(ECMAddTests)
+include(KDECMakeSettings)
+include(KDECompilerSettings NO_POLICY_SCOPE)
+include(ECMInstallIcons)
+include(ECMOptionalAddSubdirectory)
+include(ECMSetupVersion)
+include(FeatureSummary)
+
+find_package(Qt5 5.5 REQUIRED COMPONENTS
+ Widgets
+ Sql
+ Script
+ XmlPatterns
+ Qml
+ Quick
+ QuickWidgets
+ Test
+ X11Extras
+)
+
+find_package(KF5 REQUIRED COMPONENTS
+ Config
+ ConfigWidgets
+ CoreAddons
+ Declarative
+ DocTools
+ I18n
+ KIO
+ NewStuff
+ WidgetsAddons
+ XmlGui
+ ItemViews
+ KCMUtils
+ TextEditor
+ WindowSystem
+)
# 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 org.kde.ktouch.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
-install(FILES org.kde.ktouch.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/metainfo/)
+install(FILES org.kde.ktouch.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
-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/doc/index.docbook b/doc/index.docbook
index 3fc31c0..2fb59c8 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -1,9 +1,8 @@
<?xml version="1.0" ?>
-<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN"
- "dtd/kdex.dtd" [
+<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN"
+ "dtd/kdedbx45.dtd" [
<!ENTITY i18n-ktouch "<application>Typewriting Trainer</application>">
<!ENTITY kappname "&i18n-ktouch;"><!-- replace kapp here -->
-<!ENTITY package "kdeedu">
<!ENTITY % addindex "IGNORE">
<!ENTITY % English "INCLUDE"><!-- change language only here -->
]>
@@ -52,8 +51,8 @@
<legalnotice>&FDLNotice;</legalnotice>
-<date>2014-05-01</date>
-<releaseinfo>2.3.0</releaseinfo>
+<date>2015-09-27</date>
+<releaseinfo>&ktouch; 2.3.0 (Applications 15.12)</releaseinfo>
<abstract>
<para>&i18n-ktouch; is a program for learning to touch type. &i18n-ktouch;
@@ -1555,17 +1554,6 @@ contributors of keyboard and lesson files.</emphasis>
</chapter>
-<appendix id="installation">
-<title>How to obtain and install &i18n-ktouch;</title>
-
-&install.intro.documentation;
-
-<sect1 id="Compilation">
-<title>Compilation and Installation</title>
-&install.compile.documentation;
-</sect1>
-</appendix>
-
&documentation.index;
</book>
<!--
diff --git a/doc/man-ktouch.1.docbook b/doc/man-ktouch.1.docbook
index e34286b..dabfa5b 100644
--- a/doc/man-ktouch.1.docbook
+++ b/doc/man-ktouch.1.docbook
@@ -1,16 +1,17 @@
<?xml version="1.0" ?>
-<!DOCTYPE refentry PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [
+<!DOCTYPE refentry PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [
<!ENTITY % English "INCLUDE">
]>
<refentry lang="&language;">
<refentryinfo>
-<title>KDE User's Manual</title>
+<title>&ktouch; User's Manual</title>
<author><firstname>Ben</firstname><surname>Burton</surname>
<contrib>KTouch man page.</contrib>
<email>bab@debian.org</email></author>
-<date>2012-11-18</date>
-<productname>K Desktop Environment</productname>
+<date>2015-09-27</date>
+<releaseinfo>&ktouch; 2.3.0 (Applications 15.12)</releaseinfo>
+<productname>KDE Applications</productname>
</refentryinfo>
<refmeta>
@@ -20,16 +21,14 @@
<refnamediv>
<refname><command>ktouch</command></refname>
-<refpurpose>a typing tutor for KDE</refpurpose>
+<refpurpose>a typing tutor by KDE</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>ktouch</command>
<group choice="opt"><option>URL</option></group>
-<arg choice="opt">KDE Generic Options</arg>
-<arg choice="opt">Qt Generic Options</arg>
-<arg choice="opt">KTouch Options</arg>
+<arg choice="opt">options</arg>
</cmdsynopsis>
</refsynopsisdiv>
diff --git a/icons/hi128-app-ktouch.png b/icons/128-apps-ktouch.png
index 7d628af..7d628af 100644
--- a/icons/hi128-app-ktouch.png
+++ b/icons/128-apps-ktouch.png
Binary files differ
diff --git a/icons/hi16-app-ktouch.png b/icons/16-apps-ktouch.png
index 4f640cb..4f640cb 100644
--- a/icons/hi16-app-ktouch.png
+++ b/icons/16-apps-ktouch.png
Binary files differ
diff --git a/icons/hi22-app-ktouch.png b/icons/22-apps-ktouch.png
index 530d3df..530d3df 100644
--- a/icons/hi22-app-ktouch.png
+++ b/icons/22-apps-ktouch.png
Binary files differ
diff --git a/icons/hi32-app-ktouch.png b/icons/32-apps-ktouch.png
index 97e6602..97e6602 100644
--- a/icons/hi32-app-ktouch.png
+++ b/icons/32-apps-ktouch.png
Binary files differ
diff --git a/icons/hi48-app-ktouch.png b/icons/48-apps-ktouch.png
index c5666a4..c5666a4 100644
--- a/icons/hi48-app-ktouch.png
+++ b/icons/48-apps-ktouch.png
Binary files differ
diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt
index 7affd27..b5acb6c 100644
--- a/icons/CMakeLists.txt
+++ b/icons/CMakeLists.txt
@@ -1 +1,11 @@
-kde4_install_icons( ${ICON_INSTALL_DIR} )
+ecm_install_icons(
+ ICONS
+ 16-apps-ktouch.png
+ 22-apps-ktouch.png
+ 32-apps-ktouch.png
+ 48-apps-ktouch.png
+ 128-apps-ktouch.png
+ sc-apps-ktouch.svgz
+ DESTINATION ${ICON_INSTALL_DIR}
+ THEME hicolor
+)
diff --git a/icons/hisc-app-ktouch.svgz b/icons/sc-apps-ktouch.svgz
index 07dd8de..07dd8de 100644
--- a/icons/hisc-app-ktouch.svgz
+++ b/icons/sc-apps-ktouch.svgz
Binary files differ
diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt
index 20b89b1..4918ee9 100644
--- a/images/CMakeLists.txt
+++ b/images/CMakeLists.txt
@@ -1,11 +1,21 @@
set(image_files
- accuracymeter.svgz
- charactersperminutemeter.svgz
- elapsedtimemeter.svgz
- meterbox.svgz
- resizegrip.svgz
- statusled.svgz
- trainingscreen.svgz
+ accuracymeter-background.png
+ accuracymeter-scale.png
+ accuracymeter-hand.png
+ balloontip.svgz
+ charactersperminutemeter-background.png
+ charactersperminutemeter-scale.png
+ charactersperminutemeter-hand.png
+ elapsedtimemeter-background.png
+ elapsedtimemeter-minute-hand.png
+ elapsedtimemeter-second-hand.png
+ meterbox-left.png
+ meterbox-right.png
+ trainingscreen-footer.png
+ trainingscreen-header.png
+ trainingscreen-toolbar.png
+ trainingscreen-viewport.png
+ trainingscreen-viewport-shadow.png
)
-install( FILES ${image_files} DESTINATION ${DATA_INSTALL_DIR}/ktouch/images)
+install(FILES ${image_files} DESTINATION ${DATA_INSTALL_DIR}/ktouch/images)
diff --git a/images/accuracymeter-background.png b/images/accuracymeter-background.png
new file mode 100644
index 0000000..8beef10
--- /dev/null
+++ b/images/accuracymeter-background.png
Binary files differ
diff --git a/images/accuracymeter-hand.png b/images/accuracymeter-hand.png
new file mode 100644
index 0000000..7c43b8c
--- /dev/null
+++ b/images/accuracymeter-hand.png
Binary files differ
diff --git a/images/accuracymeter-scale.png b/images/accuracymeter-scale.png
new file mode 100644
index 0000000..f7d7738
--- /dev/null
+++ b/images/accuracymeter-scale.png
Binary files differ
diff --git a/images/accuracymeter.svgz b/images/accuracymeter.svgz
index 1644563..fa9f5ec 100644
--- a/images/accuracymeter.svgz
+++ b/images/accuracymeter.svgz
Binary files differ
diff --git a/images/balloontip.svgz b/images/balloontip.svgz
new file mode 100644
index 0000000..95dc239
--- /dev/null
+++ b/images/balloontip.svgz
Binary files differ
diff --git a/images/charactersperminutemeter-background.png b/images/charactersperminutemeter-background.png
new file mode 100644
index 0000000..8beef10
--- /dev/null
+++ b/images/charactersperminutemeter-background.png
Binary files differ
diff --git a/images/charactersperminutemeter-hand.png b/images/charactersperminutemeter-hand.png
new file mode 100644
index 0000000..7c43b8c
--- /dev/null
+++ b/images/charactersperminutemeter-hand.png
Binary files differ
diff --git a/images/charactersperminutemeter-scale.png b/images/charactersperminutemeter-scale.png
new file mode 100644
index 0000000..8027961
--- /dev/null
+++ b/images/charactersperminutemeter-scale.png
Binary files differ
diff --git a/images/charactersperminutemeter.svgz b/images/charactersperminutemeter.svgz
index c38cfde..3022909 100644
--- a/images/charactersperminutemeter.svgz
+++ b/images/charactersperminutemeter.svgz
Binary files differ
diff --git a/images/elapsedtimemeter-background.png b/images/elapsedtimemeter-background.png
new file mode 100644
index 0000000..446601b
--- /dev/null
+++ b/images/elapsedtimemeter-background.png
Binary files differ
diff --git a/images/elapsedtimemeter-minute-hand.png b/images/elapsedtimemeter-minute-hand.png
new file mode 100644
index 0000000..f97d436
--- /dev/null
+++ b/images/elapsedtimemeter-minute-hand.png
Binary files differ
diff --git a/images/elapsedtimemeter-second-hand.png b/images/elapsedtimemeter-second-hand.png
new file mode 100644
index 0000000..902ef9b
--- /dev/null
+++ b/images/elapsedtimemeter-second-hand.png
Binary files differ
diff --git a/images/elapsedtimemeter.svgz b/images/elapsedtimemeter.svgz
index da9d7fe..13809e5 100644
--- a/images/elapsedtimemeter.svgz
+++ b/images/elapsedtimemeter.svgz
Binary files differ
diff --git a/images/meterbox-left.png b/images/meterbox-left.png
new file mode 100644
index 0000000..fa315b6
--- /dev/null
+++ b/images/meterbox-left.png
Binary files differ
diff --git a/images/meterbox-right.png b/images/meterbox-right.png
new file mode 100644
index 0000000..eae2aeb
--- /dev/null
+++ b/images/meterbox-right.png
Binary files differ
diff --git a/images/meterbox.svgz b/images/meterbox.svgz
index ed63cdc..e41a303 100644
--- a/images/meterbox.svgz
+++ b/images/meterbox.svgz
Binary files differ
diff --git a/images/resizegrip.svgz b/images/resizegrip.svgz
deleted file mode 100644
index 4600f55..0000000
--- a/images/resizegrip.svgz
+++ /dev/null
Binary files differ
diff --git a/images/trainingscreen-footer.png b/images/trainingscreen-footer.png
new file mode 100644
index 0000000..bbd9b0d
--- /dev/null
+++ b/images/trainingscreen-footer.png
Binary files differ
diff --git a/images/trainingscreen-header.png b/images/trainingscreen-header.png
new file mode 100644
index 0000000..bbd9b0d
--- /dev/null
+++ b/images/trainingscreen-header.png
Binary files differ
diff --git a/images/trainingscreen-toolbar.png b/images/trainingscreen-toolbar.png
new file mode 100644
index 0000000..5e056e2
--- /dev/null
+++ b/images/trainingscreen-toolbar.png
Binary files differ
diff --git a/images/trainingscreen-viewport-shadow.png b/images/trainingscreen-viewport-shadow.png
new file mode 100644
index 0000000..15850ba
--- /dev/null
+++ b/images/trainingscreen-viewport-shadow.png
Binary files differ
diff --git a/images/trainingscreen-viewport.png b/images/trainingscreen-viewport.png
new file mode 100644
index 0000000..45bd642
--- /dev/null
+++ b/images/trainingscreen-viewport.png
Binary files differ
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a017e59..8cb3d39 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,41 +1,28 @@
-# CMakeList.txt for the KTouch source directory
-
-include(MacroLogFeature)
-
-find_package(KDeclarative REQUIRED)
+ecm_setup_version(${KDE_APPLICATIONS_VERSION}
+ 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")
+add_feature_info("X11-Xkbfile" X11_Xkbfile_FOUND "required for automatic keyboard layout detection")
-add_subdirectory(qml)
-add_subdirectory(schemata)
+find_package(XCB OPTIONAL_COMPONENTS XCB XKB)
+add_feature_info("XCB-XKB" XCB_XKB_FOUND "required for automatic keyboard layout detection")
+
+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 +31,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
@@ -95,30 +80,73 @@ set(ktouch_SRCS
editor/charactersviewdelegate.cpp
trainingconfigwidget.cpp
colorsconfigwidget.cpp
- customlessoneditorwidget.cpp
+ customlessoneditordialog.cpp
+ ktouchcontext.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/customlessoneditordialog.ui
)
-if (X11_Xkbfile_FOUND)
+set (KTOUCH_BUILD_WITH_X11 X11_Xkbfile_FOUND AND XCB_XKB_FOUND AND XCB_FOUND)
+
+if (KTOUCH_BUILD_WITH_X11)
add_definitions(-DKTOUCH_BUILD_WITH_X11)
include_directories(${X11_Xkbfile_INCLUDE_PATH})
set(ktouch_SRCS ${ktouch_SRCS} x11_helper.cpp)
-else (X11_Xkbfile_FOUND)
+else (KTOUCH_BUILD_WITH_X11)
set(ktouch_SRCS ${ktouch_SRCS} keyboardlayoutmenu.cpp)
-endif (X11_Xkbfile_FOUND)
+endif (KTOUCH_BUILD_WITH_X11)
-kde4_add_kcfg_files(ktouch_SRCS preferences.kcfgc )
+kconfig_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")
+add_executable(ktouch ${ktouch_SRCS})
+
+set(ktouch_X11_DEPS "")
-kde4_add_executable(ktouch ${ktouch_UIS} ${ktouch_SRCS})
+if (KTOUCH_BUILD_WITH_X11)
+ set(ktouch_X11_DEPS ${X11_Xkbfile_LIB} ${X11_LIBRARIES} XCB::XCB XCB::XKB)
+endif (KTOUCH_BUILD_WITH_X11)
-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})
-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
+target_link_libraries(ktouch
+ LINK_PUBLIC
+ Qt5::Qml
+ Qt5::Quick
+ Qt5::QuickWidgets
+ Qt5::Script
+ Qt5::Sql
+ Qt5::XmlPatterns
+ Qt5::X11Extras
+ KF5::ConfigWidgets
+ KF5::Declarative
+ KF5::KIOWidgets
+ KF5::ItemViews
+ KF5::NewStuff
+ KF5::XmlGui
+ KF5::I18n
+ KF5::KCMUtils
+ KF5::TextEditor
+ KF5::WindowSystem
+ KF5::CoreAddons
+ ${ktouch_X11_DEPS}
+)
+
+#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..4ef411e 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -17,18 +17,18 @@
#include "application.h"
-#include <qdeclarative.h>
-#include <QGraphicsDropShadowEffect>
-#include <QScriptValue>
-#include <QScriptEngine>
-#include <QKeyEvent>
+#include <QDir>
+#include <QFile>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QStandardPaths>
-#include <kdeclarative.h>
+#include <Kdelibs4ConfigMigrator>
+#include <Kdelibs4Migration>
+#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,11 +51,13 @@
#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();
+ migrateKde4Files();
DataAccess dataAccess;
dataAccess.loadDataIndex(m_dataIndex);
@@ -68,33 +70,38 @@ DataIndex* Application::dataIndex()
return app->m_dataIndex;
}
-QWeakPointer<ResourceEditor>& Application::resourceEditorRef()
+QPointer<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();
+ Application* app = static_cast<Application*>(Application::instance());
+ foreach (const QString& path, app->m_qmlImportPaths)
+ {
+ qmlEngine->addImportPath(path);
+ }
+
+ QQmlContext* rootContext = qmlEngine->rootContext();
- 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));
+ rootContext->setContextProperty("utils", new Utils());
+ rootContext->setContextProperty("strFormatter", new StringFormatter());
+}
+
+QStringList& Application::qmlImportPaths()
+{
+ return m_qmlImportPaths;
}
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,10 +124,31 @@ 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");
qmlRegisterType<TrainingLineCore>("ktouch", 1, 0, "TrainingLineCore");
}
+
+void Application::migrateKde4Files()
+{
+ QStringList configFiles;
+ configFiles << QLatin1String("ktouchrc");
+ Kdelibs4ConfigMigrator confMigrator(QLatin1String("ktouch"));
+ confMigrator.setConfigFiles(configFiles);
+ confMigrator.migrate();
+
+ Kdelibs4Migration migration;
+ const QDir dataDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+ if (!dataDir.exists())
+ {
+ dataDir.mkpath(dataDir.path());
+ }
+ const QString dbPath = dataDir.filePath("profiles.db");
+ const QString oldDbPath = migration.locateLocal("data", QStringLiteral("ktouch/profiles.db"));
+ if (!QFile(dbPath).exists() && !oldDbPath.isEmpty())
+ {
+ QFile(oldDbPath).copy(dbPath);
+ }
+
+}
diff --git a/src/application.h b/src/application.h
index d061192..0113eac 100644
--- a/src/application.h
+++ b/src/application.h
@@ -18,27 +18,29 @@
#ifndef APPLICATION_H
#define APPLICATION_H
-#include <KApplication>
-
-#include <QWeakPointer>
+#include <QApplication>
+#include <QPointer>
#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 QPointer<ResourceEditor>& resourceEditorRef();
+ QStringList& qmlImportPaths();
private:
void registerQmlTypes();
+ void migrateKde4Files();
DataIndex* m_dataIndex;
- QWeakPointer<ResourceEditor> m_resourceEditorRef;
+ QPointer<ResourceEditor> m_resourceEditorRef;
+ QStringList m_qmlImportPaths;
};
#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..4f4dae0 100644
--- a/src/core/dbaccess.cpp
+++ b/src/core/dbaccess.cpp
@@ -17,14 +17,16 @@
#include "dbaccess.h"
+#include <QDebug>
+#include <QDir>
#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 +43,17 @@ QSqlDatabase DbAccess::database()
{
if (!QSqlDatabase::contains(QSqlDatabase::defaultConnection))
{
- QString dbPath = KGlobal::dirs()->locateLocal("appdata", "profiles.db");
+ QDir dataDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+ if (!dataDir.exists())
+ {
+ dataDir.mkpath(dataDir.path());
+ }
+ QString dbPath = dataDir.filePath("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 +86,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -88,7 +95,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -115,20 +122,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 +150,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -161,7 +168,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -175,7 +182,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -190,7 +197,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -204,7 +211,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -219,7 +226,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -234,7 +241,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -256,7 +263,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -271,7 +278,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -286,7 +293,7 @@ bool DbAccess::checkDbSchema()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return false;
}
@@ -300,7 +307,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 +318,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 +334,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 +345,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 +355,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 +367,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 +393,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 +404,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 +412,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..25365a4 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,14 +52,14 @@ void ProfileDataAccess::loadProfiles()
if (db.lastError().isValid())
{
- kWarning() << db.lastError().text();
+ qWarning() << db.lastError().text();
raiseError(db.lastError());
return;
}
while(profileQuery.next())
{
- Profile* profile = new Profile();
+ Profile* profile = new Profile(this);
profile->setId(profileQuery.value(0).toInt());
profile->setName(profileQuery.value(1).toString());
int rawSkillLevel = profileQuery.value(2).toInt();
@@ -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/customlessoneditorwidget.cpp b/src/customlessoneditordialog.cpp
index e3cff95..8a9f8da 100644
--- a/src/customlessoneditorwidget.cpp
+++ b/src/customlessoneditordialog.cpp
@@ -15,7 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "customlessoneditorwidget.h"
+#include "customlessoneditordialog.h"
+
+#include <QPushButton>
#include "core/keyboardlayout.h"
#include "core/key.h"
@@ -23,9 +25,9 @@
#include "core/lesson.h"
#include "editor/lessontexthighlighter.h"
-CustomLessonEditorWidget::CustomLessonEditorWidget(QWidget* parent) :
- QWidget(parent),
- Ui::CustomLessonEditorWidget(),
+CustomLessonEditorDialog::CustomLessonEditorDialog(QWidget* parent) :
+ QDialog(parent),
+ Ui::CustomLessonEditorDialog(),
m_lesson(0),
m_keyboardLayout(0)
{
@@ -33,14 +35,15 @@ CustomLessonEditorWidget::CustomLessonEditorWidget(QWidget* parent) :
connect(m_titleLineEdit, SIGNAL(textChanged(QString)), SLOT(onTitleChanged()));
connect(m_lessonTextEditor->textEdit(), SIGNAL(textChanged()), SLOT(onTextChanged()));
+ connect(this, &CustomLessonEditorDialog::validChanged, m_buttonBox->button(QDialogButtonBox::Ok), &QPushButton::setEnabled);
}
-Lesson* CustomLessonEditorWidget::lesson() const
+Lesson* CustomLessonEditorDialog::lesson() const
{
return m_lesson;
}
-void CustomLessonEditorWidget::setLesson(Lesson* lesson)
+void CustomLessonEditorDialog::setLesson(Lesson* lesson)
{
if (lesson != m_lesson)
{
@@ -62,12 +65,12 @@ void CustomLessonEditorWidget::setLesson(Lesson* lesson)
}
}
-KeyboardLayout* CustomLessonEditorWidget::keyboardLayout() const
+KeyboardLayout* CustomLessonEditorDialog::keyboardLayout() const
{
return m_keyboardLayout;
}
-void CustomLessonEditorWidget::setKeyboardLayout(KeyboardLayout* keyboardLayout)
+void CustomLessonEditorDialog::setKeyboardLayout(KeyboardLayout* keyboardLayout)
{
if (keyboardLayout != m_keyboardLayout)
{
@@ -86,7 +89,7 @@ void CustomLessonEditorWidget::setKeyboardLayout(KeyboardLayout* keyboardLayout)
}
}
-void CustomLessonEditorWidget::updateTitle()
+void CustomLessonEditorDialog::updateTitle()
{
const QString title = m_lesson->title();
@@ -96,7 +99,7 @@ void CustomLessonEditorWidget::updateTitle()
}
}
-void CustomLessonEditorWidget::updateText()
+void CustomLessonEditorDialog::updateText()
{
const QString text = m_lesson->text();
@@ -106,7 +109,7 @@ void CustomLessonEditorWidget::updateText()
}
}
-void CustomLessonEditorWidget::updateAllowedCharacters()
+void CustomLessonEditorDialog::updateAllowedCharacters()
{
if (!m_keyboardLayout || !m_keyboardLayout->isValid())
{
@@ -134,7 +137,7 @@ void CustomLessonEditorWidget::updateAllowedCharacters()
m_lessonTextEditor->highlighter()->setAllowedCharacters(chars);
}
-void CustomLessonEditorWidget::onTitleChanged()
+void CustomLessonEditorDialog::onTitleChanged()
{
if (!m_lesson)
return;
@@ -144,7 +147,7 @@ void CustomLessonEditorWidget::onTitleChanged()
emitValidChanged();
}
-void CustomLessonEditorWidget::onTextChanged()
+void CustomLessonEditorDialog::onTextChanged()
{
if (!m_lesson)
return;
@@ -154,7 +157,7 @@ void CustomLessonEditorWidget::onTextChanged()
emitValidChanged();
}
-void CustomLessonEditorWidget::emitValidChanged()
+void CustomLessonEditorDialog::emitValidChanged()
{
const QString title = m_lesson->title();
const QString text = m_lesson->text();
diff --git a/src/customlessoneditorwidget.h b/src/customlessoneditordialog.h
index e871e21..9e564c4 100644
--- a/src/customlessoneditorwidget.h
+++ b/src/customlessoneditordialog.h
@@ -16,21 +16,21 @@
*/
-#ifndef CUSTOMLESSONEDITORWIDGET_H
-#define CUSTOMLESSONEDITORWIDGET_H
+#ifndef CUSTOMLESSONEDITORDIALOG_H
+#define CUSTOMLESSONEDITORDIALOG_H
-#include <QWidget>
+#include <QDialog>
-#include "ui_customlessoneditorwidget.h"
+#include "ui_customlessoneditordialog.h"
class Lesson;
class KeyboardLayout;
-class CustomLessonEditorWidget : public QWidget, private Ui::CustomLessonEditorWidget
+class CustomLessonEditorDialog : public QDialog, private Ui::CustomLessonEditorDialog
{
Q_OBJECT
public:
- explicit CustomLessonEditorWidget(QWidget* parent = 0);
+ explicit CustomLessonEditorDialog(QWidget* parent = 0);
Lesson* lesson() const;
void setLesson(Lesson* lesson);
KeyboardLayout* keyboardLayout() const;
@@ -49,4 +49,4 @@ private:
KeyboardLayout* m_keyboardLayout;
};
-#endif // CUSTOMLESSONEDITORWIDGET_H
+#endif // CUSTOMLESSONEDITORDIALOG_H
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..745d919 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);
@@ -263,6 +262,7 @@ void LessonPainter::updateTrainingStatus()
invalidateImageCache();
updateCursorRectangle();
+ update();
}
void LessonPainter::advanceToNextTrainingLine()
@@ -333,8 +333,6 @@ void LessonPainter::checkImageCache()
m_imageCache = img;
m_imageCacheDirty = false;
-
- update();
}
void LessonPainter::updateCursorRectangle()
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..b48135b 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"
@@ -56,7 +57,7 @@ CourseEditor::CourseEditor(QWidget* parent):
connect(m_descriptionTextEdit, SIGNAL(textChanged()), SLOT(onDescriptionChanged()));
connect(m_lessonModel, SIGNAL(lessonChanged(int)), SLOT(selectLesson(int)));
- connect(m_lessonView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(onLessonSelected()));
+ connect(m_lessonView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(onLessonSelected()));
connect(m_addLessonButton, SIGNAL(clicked(bool)), SLOT(addLesson()));
connect(m_removeLessonButton, SIGNAL(clicked(bool)), SLOT(removeLesson()));
@@ -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..b51e8f1 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,14 +51,27 @@ 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()));
connect(m_zoomSlider, SIGNAL(valueChanged(int)), SLOT(setZoomLevel(int)));
connect(m_deleteKeyToolButton, SIGNAL(clicked(bool)), SLOT(deleteSelectedKey()));
connect(m_view, SIGNAL(clicked()), SLOT(clearSelection()));
+
+ connect(m_zoomOutToolButton, &QToolButton::clicked, [=](){
+ m_zoomSlider->setValue(m_zoomSlider->value() - 1);
+ });
+ connect(m_zoomInToolButton, &QToolButton::clicked, [=](){
+ m_zoomSlider->setValue(m_zoomSlider->value() + 1);
+ });
+
+}
+
+KeyboardLayoutEditor::~KeyboardLayoutEditor()
+{
+ m_view->setSource(QUrl());
}
void KeyboardLayoutEditor::openKeyboardLayout(DataIndexKeyboardLayout* dataIndexKeyboardLayout)
diff --git a/src/editor/keyboardlayouteditor.h b/src/editor/keyboardlayouteditor.h
index 436581c..f713da6 100644
--- a/src/editor/keyboardlayouteditor.h
+++ b/src/editor/keyboardlayouteditor.h
@@ -34,6 +34,7 @@ class KeyboardLayoutEditor : public AbstractEditor, private Ui::KeyboardLayoutEd
Q_PROPERTY(int zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
public:
explicit KeyboardLayoutEditor(QWidget* parent = 0);
+ ~KeyboardLayoutEditor();
void openKeyboardLayout(DataIndexKeyboardLayout* dataIndexKeyboardLayout);
void clearUndoStackForKeyboardLayout(DataIndexKeyboardLayout* dataIndexKeyboardLayout);
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/ktouchcontext.cpp b/src/ktouchcontext.cpp
new file mode 100644
index 0000000..5d63816
--- /dev/null
+++ b/src/ktouchcontext.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2016 Sebastian Gottfried <sebastian.gottfried@posteo.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 "ktouchcontext.h"
+
+#include <QMenu>
+#include <QPointer>
+#include <QDialogButtonBox>
+#include <QMenu>
+#include <QQuickView>
+
+#include "application.h"
+#include "colorsconfigwidget.h"
+#include "editor/resourceeditor.h"
+#include "customlessoneditordialog.h"
+#include "preferences.h"
+#include "trainingconfigwidget.h"
+
+#include <KActionCollection>
+#include <KStandardAction>
+#include <KHelpMenu>
+#include <KToggleFullScreenAction>
+#include <KShortcutsDialog>
+#include <KConfigDialog>
+#include <KCMultiDialog>
+#include <KLocalizedString>
+
+#ifdef KTOUCH_BUILD_WITH_X11
+#include "x11_helper.h"
+#else
+#include "keyboardlayoutmenu.h"
+#endif
+
+
+
+const QString keyboardKCMName = "kcm_keyboard";
+
+KTouchContext::KTouchContext(KMainWindow* mainWindow, QQuickView* view, QObject *parent) :
+ QObject(parent),
+ m_actionCollection(new KActionCollection(this)),
+ m_menu(new QMenu(mainWindow)),
+ m_mainWindow(mainWindow),
+ m_view(view)
+{
+#ifdef KTOUCH_BUILD_WITH_X11
+ m_XEventNotifier = new XEventNotifier();
+ m_XEventNotifier->start();
+ connect(m_XEventNotifier, SIGNAL(layoutChanged()), SIGNAL(keyboardLayoutNameChanged()));
+#else
+ m_keyboardLayoutMenu = new KeyboardLayoutMenu(this);
+ m_keyboardLayoutMenu->setDataIndex(Application::dataIndex());
+ connect(m_keyboardLayoutMenu, SIGNAL(keyboardLayoutNameChanged()), SIGNAL(keyboardLayoutNameChanged()));
+#endif
+ init();
+}
+
+KTouchContext::~KTouchContext()
+{
+#ifdef KTOUCH_BUILD_WITH_X11
+ m_XEventNotifier->stop();
+ delete m_XEventNotifier;
+#endif
+}
+
+QString KTouchContext::keyboardLayoutName() const
+{
+#ifdef KTOUCH_BUILD_WITH_X11
+ return X11Helper::getCurrentLayout().toString();
+#else
+ return m_keyboardLayoutMenu->keyboardLayoutName();
+#endif
+}
+
+DataIndex* KTouchContext::dataIndex()
+{
+ return Application::dataIndex();
+}
+
+void KTouchContext::showMenu(int xPos, int yPos)
+{
+ m_menu->popup(m_view->mapToGlobal(QPoint(xPos, yPos)));
+}
+
+void KTouchContext::showResourceEditor()
+{
+ QPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
+ if (resourceEditorRef.isNull())
+ {
+ resourceEditorRef = QPointer<ResourceEditor>(new ResourceEditor());
+ }
+
+ ResourceEditor* resourceEditor = resourceEditorRef.data();
+
+ resourceEditor->show();
+ resourceEditor->activateWindow();
+}
+
+bool KTouchContext::showCustomLessonDialog(Lesson* lesson, KeyboardLayout* keyboardLayout)
+{
+ CustomLessonEditorDialog* dialog = new CustomLessonEditorDialog(m_mainWindow);
+
+ dialog->setLesson(lesson);
+ dialog->setKeyboardLayout(keyboardLayout);
+
+ bool result = dialog->exec() == QDialog::Accepted;
+
+ delete dialog;
+
+ return result;
+}
+
+void KTouchContext::showConfigDialog()
+{
+ if (KConfigDialog::showDialog("preferences"))
+ {
+ return;
+ }
+
+ KConfigDialog* dialog = new KConfigDialog(m_mainWindow, "preferences", Preferences::self());
+ dialog->setFaceType(KPageDialog::List);
+ dialog->setModal(true);
+ dialog->addPage(new TrainingConfigWidget(), i18n("Training"), "chronometer", i18n("Training Settings"));
+ dialog->addPage(new ColorsConfigWidget(), i18n("Colors"), "preferences-desktop-color", i18n("Color Settings"));
+ dialog->show();
+}
+
+void KTouchContext::configureShortcuts()
+{
+ KShortcutsDialog::configure(m_actionCollection, KShortcutsEditor::LetterShortcutsDisallowed, m_mainWindow);
+}
+
+void KTouchContext::configureKeyboard()
+{
+ QPointer<KCMultiDialog> kcm = new KCMultiDialog(m_mainWindow);
+
+ kcm->setWindowTitle(i18n("Configure Keyboard"));
+ kcm->addModule(keyboardKCMName);
+ kcm->exec();
+
+ delete kcm;
+}
+
+void KTouchContext::setFullscreen(bool fullScreen)
+{
+ KToggleFullScreenAction::setFullScreen(m_mainWindow, fullScreen);
+}
+
+void KTouchContext::init()
+{
+ m_actionCollection->addAssociatedWidget(m_mainWindow);
+ m_menu->addAction(KStandardAction::fullScreen(this, SLOT(setFullscreen(bool)), m_mainWindow, m_actionCollection));
+ m_menu->addSeparator();
+ QAction* editorAction = new QAction(i18n("Course and Keyboard Layout Editor..."), this);
+ connect(editorAction, &QAction::triggered, this, &KTouchContext::showResourceEditor);
+ m_actionCollection->addAction("editor", editorAction);
+ m_menu->addAction(editorAction);
+ m_menu->addSeparator();
+ m_menu->addAction(KStandardAction::preferences(this, SLOT(showConfigDialog()), m_actionCollection));
+ m_menu->addAction(KStandardAction::keyBindings(this, SLOT(configureShortcuts()), m_actionCollection));
+
+
+#ifdef KTOUCH_BUILD_WITH_X11
+ if (testKCMAvailibility(keyboardKCMName))
+ {
+ QAction* configureKeyboardAction = new QAction(i18n("Configure Keyboard..."), this);
+ m_menu->addAction(configureKeyboardAction);
+ connect(configureKeyboardAction, &QAction::triggered, this, &KTouchContext::configureKeyboard);
+ }
+#else
+ m_menu->addMenu(m_keyboardLayoutMenu);
+#endif
+
+ m_menu->addSeparator();
+ KHelpMenu* helpMenu = new KHelpMenu(m_mainWindow);
+ m_menu->addMenu(helpMenu->menu());
+}
+
+bool KTouchContext::testKCMAvailibility(const QString& name)
+{
+ KService::Ptr service = KService::serviceByStorageId(name + ".desktop");
+
+ if (!service)
+ {
+ return false;
+ }
+
+ return service->hasServiceType("KCModule") && !service->noDisplay();
+}
diff --git a/src/ktouchcontext.h b/src/ktouchcontext.h
new file mode 100644
index 0000000..74d9c16
--- /dev/null
+++ b/src/ktouchcontext.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016 Sebastian Gottfried <sebastian.gottfried@posteo.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 KTOUCHCONTEXT_H
+#define KTOUCHCONTEXT_H
+
+#include <QObject>
+
+class QMenu;
+class QQuickView;
+
+class KActionCollection;
+class KMainWindow;
+
+class DataIndex;
+class KeyboardLayout;
+class KeyboardLayoutMenu;
+class Lesson;
+class XEventNotifier;
+
+class KTouchContext : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString keyboardLayoutName READ keyboardLayoutName NOTIFY keyboardLayoutNameChanged)
+ Q_PROPERTY(DataIndex* globalDataIndex READ dataIndex CONSTANT)
+public:
+ explicit KTouchContext(KMainWindow* mainWindow, QQuickView* view, QObject* parent = 0);
+ ~KTouchContext();
+ QString keyboardLayoutName() const;
+ DataIndex* dataIndex();
+ Q_INVOKABLE void showMenu(int xPos, int yPos);
+public slots:
+ void showResourceEditor();
+ bool showCustomLessonDialog(Lesson* lesson, KeyboardLayout* keyboardLayout);
+private slots:
+ void showConfigDialog();
+ void configureShortcuts();
+ void configureKeyboard();
+ void setFullscreen(bool fullscreen);
+signals:
+ void keyboardLayoutNameChanged();
+private:
+ void init();
+ bool testKCMAvailibility(const QString& name);
+ KActionCollection* m_actionCollection;
+ QMenu* m_menu;
+ KMainWindow* m_mainWindow;
+ QQuickView* m_view;
+#ifdef KTOUCH_BUILD_WITH_X11
+ XEventNotifier* m_XEventNotifier;
+#else
+ KeyboardLayoutMenu* m_keyboardLayoutMenu;
+#endif
+};
+
+#endif // KTOUCHCONTEXT_H
diff --git a/src/main.cpp b/src/main.cpp
index d6d3be1..3b7739c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,52 +15,73 @@
* 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.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.setOrganizationDomain(QByteArray("kde.org"));
+
+ KAboutData::setApplicationData(about);
- 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");
+ app.setApplicationName(about.componentName());
+ app.setApplicationDisplayName(about.displayName());
+ app.setOrganizationDomain(about.organizationDomain());
+ app.setApplicationVersion(about.version());
- 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"));
+ QApplication::setWindowIcon(QIcon::fromTheme(QLatin1String("ktouch")));
- 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);
- KApplication::setGraphicsSystem("raster");
+ QCommandLineParser parser;
+ about.setupCommandLine(&parser);
+
+ parser.addOption(QCommandLineOption(QStringLiteral("resource-editor"), i18n("Launch the course and keyboard layout editor")));
+
+ parser.addOption({{"I", "import-path"}, i18n("Prepend the path to the list of QML import paths"), "path"});
+
+ parser.process(app);
+
+ about.processCommandLine(&parser);
+
+ if (parser.isSet("import-path"))
+ {
+ foreach (const QString& path, parser.values("import-path"))
+ {
+ app.qmlImportPaths().append(path);
+ }
+ }
- Application app;
if (app.isSessionRestored())
{
@@ -74,11 +95,11 @@ int main(int argc, char **argv)
}
else if (name == "ResourceEditor")
{
- QWeakPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
+ QPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
if (resourceEditorRef.isNull())
{
- resourceEditorRef = new ResourceEditor();
+ resourceEditorRef = QPointer<ResourceEditor>(new ResourceEditor());
resourceEditorRef.data()->restore(i);
}
}
@@ -86,14 +107,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();
+ QPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
if (resourceEditorRef.isNull())
{
- resourceEditorRef = new ResourceEditor();
+ resourceEditorRef = QPointer<ResourceEditor>(new ResourceEditor());
}
ResourceEditor* resourceEditor = resourceEditorRef.data();
@@ -104,10 +123,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..64c9332 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -17,223 +17,38 @@
#include "mainwindow.h"
-#include <QDeclarativeView>
-#include <QDeclarativeContext>
-#include <QGLWidget>
-#include <QMenu>
-#include <QPointer>
+#include <QQuickView>
#include <QVariant>
+#include <QStandardPaths>
+#include <QQmlContext>
-#include <KDialog>
-#include <KStandardDirs>
-#include <KMenu>
-#include <KCmdLineArgs>
-#include <KActionCollection>
-#include <KStandardAction>
-#include <KHelpMenu>
-#include <KToggleFullScreenAction>
-#include <KShortcutsDialog>
-#include <KConfigDialog>
-#include <KCMultiDialog>
+#include <KLocalizedString>
-#include "editor/resourceeditor.h"
#include "application.h"
-#include "preferences.h"
-#include "trainingconfigwidget.h"
-#include "colorsconfigwidget.h"
-#include "customlessoneditorwidget.h"
-
-#ifdef KTOUCH_BUILD_WITH_X11
-#include "x11_helper.h"
-#else
-#include "keyboardlayoutmenu.h"
-#endif
-
-#ifdef KTOUCH_BUILD_WITH_X11
-#else
-#endif
-
-const QString keyboardKCMName = "kcm_keyboard";
+#include "ktouchcontext.h"
MainWindow::MainWindow(QWidget* parent):
KMainWindow(parent),
- m_view(new QDeclarativeView(this)),
- m_actionCollection(new KActionCollection(this)),
- m_menu(new QMenu(this)),
- m_useOpenGLViewport(false)
+ m_view(new QQuickView()),
+ m_context(new KTouchContext(this, m_view, this))
{
-#ifdef KTOUCH_BUILD_WITH_X11
- m_XEventNotifier = new XEventNotifier();
- m_XEventNotifier->start();
- connect(m_XEventNotifier, SIGNAL(layoutChanged()), SIGNAL(keyboardLayoutNameChanged()));
-#else
- m_keyboardLayoutMenu = new KeyboardLayoutMenu(this);
- m_keyboardLayoutMenu->setDataIndex(Application::dataIndex());
- connect(m_keyboardLayoutMenu, SIGNAL(keyboardLayoutNameChanged()), SIGNAL(keyboardLayoutNameChanged()));
-#endif
init();
}
MainWindow::~MainWindow()
{
-#ifdef KTOUCH_BUILD_WITH_X11
- m_XEventNotifier->stop();
- delete m_XEventNotifier;
-#endif
-}
-
-QString MainWindow::keyboardLayoutName() const
-{
-#ifdef KTOUCH_BUILD_WITH_X11
- return X11Helper::getCurrentLayout().toString();
-#else
- return m_keyboardLayoutMenu->keyboardLayoutName();
-#endif
-}
-
-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)));
-}
-
-void MainWindow::showResourceEditor()
-{
- QWeakPointer<ResourceEditor>& resourceEditorRef = Application::resourceEditorRef();
- if (resourceEditorRef.isNull())
- {
- resourceEditorRef = new ResourceEditor();
- }
-
- ResourceEditor* resourceEditor = resourceEditorRef.data();
-
- resourceEditor->show();
- resourceEditor->activateWindow();
}
-bool MainWindow::showCustomLessonDialog(Lesson* lesson, KeyboardLayout* keyboardLayout)
-{
- KDialog* dialog = new KDialog(this);
- CustomLessonEditorWidget* editor = new CustomLessonEditorWidget(dialog);
-
- dialog->setWindowTitle(i18n("Edit Custom Lesson"));
- dialog->setButtons(KDialog::Ok | KDialog::Cancel);
- dialog->setMainWidget(editor);
-
- connect(editor, SIGNAL(validChanged(bool)), dialog, SLOT(enableButtonOk(bool)));
-
- editor->setLesson(lesson);
- editor->setKeyboardLayout(keyboardLayout);
-
- bool result = dialog->exec() == KDialog::Accepted;
-
- delete dialog;
-
- return result;
-}
-
-void MainWindow::showConfigDialog()
-{
- if (KConfigDialog::showDialog("preferences"))
- {
- return;
- }
-
- KConfigDialog* dialog = new KConfigDialog(this, "preferences", Preferences::self());
- dialog->setFaceType(KPageDialog::List);
- dialog->setModal(true);
- dialog->addPage(new TrainingConfigWidget(), i18n("Training"), "chronometer", i18n("Training Settings"));
- dialog->addPage(new ColorsConfigWidget(), i18n("Colors"), "preferences-desktop-color", i18n("Color Settings"));
- dialog->show();
-}
-
-void MainWindow::configureShortcuts()
-{
- KShortcutsDialog::configure(m_actionCollection, KShortcutsEditor::LetterShortcutsDisallowed, this);
-}
-
-void MainWindow::configureKeyboard()
-{
- QPointer<KCMultiDialog> kcm = new KCMultiDialog(this);
-
- kcm->setWindowTitle(i18n("Configure Keyboard"));
- kcm->addModule(keyboardKCMName);
- kcm->exec();
-
- delete kcm;
-}
-
-void MainWindow::setFullscreen(bool fullScreen)
-{
- KToggleFullScreenAction::setFullScreen(this, fullScreen);
-}
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()));
- m_actionCollection->addAction("editor", editorAction);
- m_menu->addAction(editorAction);
- m_menu->addSeparator();
- m_menu->addAction(KStandardAction::preferences(this, SLOT(showConfigDialog()), m_actionCollection));
- m_menu->addAction(KStandardAction::keyBindings(this, SLOT(configureShortcuts()), m_actionCollection));
-
-
-#ifdef KTOUCH_BUILD_WITH_X11
- if (testKCMAvailibility(keyboardKCMName))
- {
- KAction* configureKeyboardAction = new KAction(i18n("Configure Keyboard..."), this);
- m_menu->addAction(configureKeyboardAction);
- connect(configureKeyboardAction, SIGNAL(triggered()), SLOT(configureKeyboard()));
- }
-#else
- m_menu->addMenu(m_keyboardLayoutMenu);
-#endif
-
- m_menu->addSeparator();
- KHelpMenu* helpMenu = new KHelpMenu(m_menu, KCmdLineArgs::aboutData(), false, m_actionCollection);
- m_menu->addMenu(helpMenu->menu());
-
- setCentralWidget(m_view);
+ QWidget* viewWidget = QWidget::createWindowContainer(m_view, this);
+ viewWidget->setMinimumSize(1000, 700);
+ setCentralWidget(viewWidget);
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")));
-}
-
-bool MainWindow::testKCMAvailibility(const QString& name)
-{
- KService::Ptr service = KService::serviceByStorageId(name + ".desktop");
-
- if (!service)
- {
- return false;
- }
-
- return service->hasServiceType("KCModule") && !service->noDisplay();
+ m_view->rootContext()->setContextProperty(QStringLiteral("ktouch"), m_context);
+ m_view->setResizeMode(QQuickView::SizeRootObjectToView);
+ m_view->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, "qml/main.qml")));
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 509b371..d401698 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -22,13 +22,9 @@
#include <QWeakPointer>
-class QDeclarativeView;
-class QMenu;
-class KActionCollection;
-class DataIndex;
-class ResourceEditor;
-class KeyboardLayout;
-class Lesson;
+class QQuickView;
+
+class KTouchContext;
#ifdef KTOUCH_BUILD_WITH_X11
class XEventNotifier;
@@ -39,38 +35,13 @@ class KeyboardLayoutMenu;
class MainWindow : public KMainWindow
{
Q_OBJECT
- Q_PROPERTY(QString keyboardLayoutName READ keyboardLayoutName NOTIFY keyboardLayoutNameChanged)
- Q_PROPERTY(DataIndex* globalDataIndex READ dataIndex CONSTANT)
public:
explicit MainWindow(QWidget* parent = 0);
~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();
- bool showCustomLessonDialog(Lesson* lesson, KeyboardLayout* keyboardLayout);
-signals:
- void keyboardLayoutNameChanged();
-private slots:
- void showConfigDialog();
- void configureShortcuts();
- void configureKeyboard();
- void setFullscreen(bool fullscreen);
private:
void init();
- bool testKCMAvailibility(const QString& name);
- QDeclarativeView* m_view;
- KActionCollection* m_actionCollection;
- QMenu* m_menu;
- bool m_useOpenGLViewport;
-#ifdef KTOUCH_BUILD_WITH_X11
- XEventNotifier* m_XEventNotifier;
-#else
- KeyboardLayoutMenu* m_keyboardLayoutMenu;
-#endif
+ QQuickView* m_view;
+ KTouchContext* m_context;
};
#endif // MAINWINDOW_H
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/learningprogressmodel.cpp b/src/models/learningprogressmodel.cpp
index 455d313..1767ec6 100644
--- a/src/models/learningprogressmodel.cpp
+++ b/src/models/learningprogressmodel.cpp
@@ -26,7 +26,9 @@
LearningProgressModel::LearningProgressModel(QObject* parent) :
QSqlQueryModel(parent),
- m_profile(0)
+ m_profile(0),
+ m_courseFilter(0),
+ m_lessonFilter(0)
{
}
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..1ce0aa2 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
@@ -94,6 +89,9 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
+ if (!m_dataIndex)
+ return QVariant();
+
if (index.row() > m_dataIndex->courseCount() + m_dataIndex->keyboardLayoutCount())
return QVariant();
@@ -117,9 +115,21 @@ int ResourceModel::rowCount(const QModelIndex &parent) const
if (parent.isValid())
return 0;
+ if (!m_dataIndex)
+ return 0;
+
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);
@@ -133,6 +143,9 @@ void ResourceModel::onCoursesAboutToBeRemoved(int first, int last)
void ResourceModel::onKeyboardLayoutAboutToBeAdded(DataIndexKeyboardLayout* keyboardLayout, int index)
{
+ if (!m_dataIndex)
+ return;
+
const int offset = m_dataIndex->courseCount();
connectToKeyboardLayout(keyboardLayout);
beginInsertRows(QModelIndex(), index + offset, index + offset);
@@ -140,6 +153,9 @@ void ResourceModel::onKeyboardLayoutAboutToBeAdded(DataIndexKeyboardLayout* keyb
void ResourceModel::onKeyboardLayoutsAboutToBeRemoved(int first, int last)
{
+ if (!m_dataIndex)
+ return;
+
const int offset = m_dataIndex->courseCount();
beginRemoveRows(QModelIndex(), first + offset, last + offset);
}
@@ -164,6 +180,9 @@ void ResourceModel::emitDataChanged(int row)
QVariant ResourceModel::courseData(int row, int role) const
{
+ if (!m_dataIndex)
+ return QVariant();
+
switch(role)
{
case KCategorizedSortFilterProxyModel::CategorySortRole:
@@ -195,6 +214,9 @@ QVariant ResourceModel::courseData(int row, int role) const
QVariant ResourceModel::keyboardLayoutData(int row, int role) const
{
+ if (!m_dataIndex)
+ return QVariant();
+
switch(role)
{
case KCategorizedSortFilterProxyModel::CategorySortRole:
@@ -243,6 +265,9 @@ void ResourceModel::connectToKeyboardLayout(DataIndexKeyboardLayout *keyboardLay
void ResourceModel::updateMappings()
{
+ if (!m_dataIndex)
+ return;
+
for (int i = 0; i < m_dataIndex->courseCount(); i++)
{
m_signalMapper->setMapping(m_dataIndex->course(i), i);
@@ -258,7 +283,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..bf065d5 100644
--- a/src/models/resourcemodel.h
+++ b/src/models/resourcemodel.h
@@ -46,6 +46,7 @@ public:
IndexRole,
SourceRole
};
+ Q_ENUM(AdditionalRoles)
explicit ResourceModel( QObject* parent = 0);
DataIndex* dataIndex() const;
void setDataIndex(DataIndex* dataIndex);
@@ -53,6 +54,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/qml/AccuracyMeter.qml b/src/qml/AccuracyMeter.qml
index d4e7f44..e3658df 100644
--- a/src/qml/AccuracyMeter.qml
+++ b/src/qml/AccuracyMeter.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.0
-import org.kde.plasma.core 0.1 as PlasmaCore
-import Effects 1.0
+import QtQuick 2.4
import ktouch 1.0
Meter {
@@ -31,12 +30,10 @@ Meter {
referenceValue: strFormatter.formatAccuracyDiff(meter.referenceAccuracy, meter.accuracy)
valueStatus: Math.round(1000 * meter.accuracy) >= Math.round(10 * preferences.requiredAccuracy)? "good": "bad"
- analogPartContent: PlasmaCore.SvgItem {
+ analogPartContent: Image {
anchors.centerIn: parent
- svg: clockSvg
- elementId: "background"
- width: naturalSize.width
- height: naturalSize.height
+ source: utils.findImage("accuracymeter-background.png")
+
ScaleBackgroundItem {
anchors.centerIn: parent
anchors.verticalCenterOffset: 25
@@ -48,14 +45,11 @@ Meter {
color: "#88ff00";
}
- PlasmaCore.SvgItem {
+ Image {
id: scale
anchors.centerIn: parent
anchors.verticalCenterOffset: 25
- svg: clockSvg
- elementId: "scale"
- width: naturalSize.width
- height: naturalSize.height
+ source: utils.findImage("accuracymeter-scale.png")
}
Text {
@@ -78,24 +72,14 @@ Meter {
font.pixelSize: 10
}
- PlasmaCore.SvgItem {
+ Image {
id: hand
anchors.centerIn: parent
anchors.verticalCenterOffset: 25
- svg: clockSvg
- elementId: "hand"
- width: naturalSize.width
- height: naturalSize.height
- smooth: true
- effect: DropShadow {
- color: "#000000"
- blurRadius: 5
- xOffset: 0
- yOffset: 0
- }
+ source: utils.findImage("accuracymeter-hand.png")
transform: Rotation {
- origin.x: hand.naturalSize.width / 2
- origin.y: hand.naturalSize.height / 2
+ origin.x: hand.width / 2
+ origin.y: hand.height / 2
angle: Math.min(90, Math.max(0, accuracy - 0.9) * 900)
Behavior on angle {
SpringAnimation { spring: 2; damping: 0.2; modulus: 360; mass: 0.75}
@@ -103,9 +87,4 @@ Meter {
}
}
}
-
- PlasmaCore.Svg {
- id: clockSvg
- imagePath: findImage("accuracymeter.svgz")
- }
}
diff --git a/src/qml/Balloon.qml b/src/qml/Balloon.qml
index 0969c1f..c915f62 100644
--- a/src/qml/Balloon.qml
+++ b/src/qml/Balloon.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Marco Martin <mart@kde.org>
+ * Copyright 2015 Sebastian Gottfried <sebastiangottfried@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
@@ -17,156 +18,150 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.extras 0.1 as PlasmaExtras
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtGraphicalEffects 1.0
-Item {
+Loader {
id: root
property Item visualParent
- z: 9000
- property int status: PlasmaComponents.DialogStatus.Closed
- default property alias data: contentItem.data
+ property string status: 'closed'
+ default property Item data
+ active: status != 'closed'
function open()
{
- if (root.visualParent) {
- internal.parentPos = root.visualParent.mapToItem(dismissArea.parent, 0, 0)
- }
- root.status = PlasmaComponents.DialogStatus.Opening
- appearAnimation.restart()
+ root.status = 'loading'
}
function close()
{
- root.status = PlasmaComponents.DialogStatus.Closing
- appearAnimation.restart()
- }
-
- SequentialAnimation {
- id: appearAnimation
- NumberAnimation {
- duration: 250
- easing.type: Easing.InOutQuad
- target: dismissArea
- properties: "opacity"
- to: root.status == PlasmaComponents.DialogStatus.Opening ? 1 : 0
- }
- ScriptAction {
- script: root.status == PlasmaComponents.DialogStatus.Opening ? root.status = PlasmaComponents.DialogStatus.Open : PlasmaComponents.DialogStatus.Closed
- }
+ root.status = 'closing'
}
- MouseArea {
- id: dismissArea
- z: 9000
- anchors.fill: parent
- opacity: 0
-
- //FIXME: this is an hack: it's taking the dialog background making sure no opaque or transparent are selected
- //in Plasma2 we need to have the backingstore blur there as well
- PlasmaExtras.FallbackComponent {
- id: fallbackComponent
- basePath: "desktoptheme"
- candidates: [theme.themeName, "default"]
- property string svgPath: fallbackComponent.filePath("/dialogs/background.svgz")
- }
- Connections {
- target: theme
- //fallback if inline-background doesn't work
- onThemeChanged: {
- fallbackComponent.svgPath = fallbackComponent.filePath("/dialogs/background.svgz")
- shadowFrame.visible = backgroundSvg.hasElement("shadow-top")
- }
- }
- PlasmaCore.FrameSvgItem {
- id: shadowFrame
- imagePath: fallbackComponent.svgPath
- prefix: "shadow"
- anchors {
- fill: internal
- leftMargin: -margins.left
- topMargin: -margins.top
- rightMargin: -margins.right
- bottomMargin: -margins.bottom
+ sourceComponent: Component {
+ MouseArea {
+ id: dismissArea
+ anchors.fill: parent
+ opacity: root.active && (root.status == 'open' || root.status =='opening')? 1 : 0
+ layer.enabled: true
+ layer.effect: DropShadow {
+ anchors.fill: parent
+ source: internalWrapper
+ radius: 5
+ samples: 11
}
- Component.onCompleted: shadowFrame.visible = backgroundSvg.hasElement("shadow-top")
- }
- PlasmaCore.FrameSvgItem {
- id: internal
- property variant parentPos
- imagePath: fallbackComponent.svgPath
- property bool under: root.visualParent ? internal.parentPos.y + root.visualParent.height + height < dismissArea.height : true
- //bindings won't work inside anchers definition
- onUnderChanged: {
- if (under) {
- tipSvg.anchors.top = undefined
- tipSvg.anchors.bottom = tipSvg.parent.top
- } else {
- tipSvg.anchors.bottom = undefined
- tipSvg.anchors.top = tipSvg.parent.bottom
+
+ Behavior on opacity {
+ SequentialAnimation {
+ NumberAnimation {
+ duration: 250
+ easing.type: Easing.InOutQuad
+ properties: "opacity"
+ }
+ ScriptAction {
+ script: {
+ root.status = root.status == 'opening' ? 'open' : 'closed'
+ }
+
+ }
}
}
- property int preferedX: internal.parentPos.x - internal.width/2 + root.visualParent.width/2
- x: Math.max(shadowFrame.margins.left, Math.min(dismissArea.width - internal.width - shadowFrame.margins.right, preferedX))
- y: {
- if (root.visualParent) {
+ SystemPalette {
+ id: palette
+ colorGroup: SystemPalette.Active
+ }
+
+ Rectangle {
+ id: internal
+ color: palette.alternateBase
+ radius: 5
+
+ property variant parentPos: root.visualParent? root.visualParent.mapToItem(dismissArea, 0, 0): Qt.point(0, 0)
+ property bool under: root.visualParent ? internal.parentPos.y + root.visualParent.height + height < dismissArea.height : true
+
+ //bindings won't work inside anchors definition
+ onUnderChanged: {
if (under) {
- internal.parentPos.y + root.visualParent.height + tipSvg.height
+ balloonTip.anchors.top = undefined
+ balloonTip.anchors.bottom = balloonTip.parent.top
} else {
- internal.parentPos.y - internal.height - tipSvg.height
+ balloonTip.anchors.bottom = undefined
+ balloonTip.anchors.top = balloonTip.parent.bottom
}
- } else {
- dismissArea.height/2 - internal.height/2
}
- }
- width: contentItem.width + margins.left + margins.right
- height: contentItem.height + margins.top + margins.bottom
-
- PlasmaCore.SvgItem {
- id: tipSvg
- visible: root.visualParent != null
- svg: PlasmaCore.Svg {
- id: backgroundSvg
- imagePath: fallbackComponent.svgPath
+
+ property int preferedX: internal.parentPos.x - internal.width/2 + root.visualParent.width/2
+ x: Math.round(Math.max(radius, Math.min(dismissArea.width - internal.width - radius, preferedX)))
+ y: {
+ if (root.visualParent) {
+ if (under) {
+ Math.round(internal.parentPos.y + root.visualParent.height + balloonTip.height + radius)
+ } else {
+ Math.round(internal.parentPos.y - internal.height - balloonTip.height - radius)
+ }
+ } else {
+ Math.round(dismissArea.height/2 - internal.height/2)
+ }
}
- elementId: internal.under ? "balloon-tip-top" : "balloon-tip-bottom"
- anchors {
- horizontalCenter: parent.horizontalCenter
- horizontalCenterOffset: internal.preferedX - internal.x
- bottom: parent.top
- top: parent.bottom
- topMargin: -backgroundSvg.elementSize("hint-bottom-shadow").height - 1
- bottomMargin: -backgroundSvg.elementSize("hint-top-shadow").height - 1
+ width: contentItem.width + 2 * internal.radius
+ height: contentItem.height + 2 * internal.radius
+
+ Rectangle {
+ id: balloonTip
+ color: internal.color
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ horizontalCenterOffset: internal.preferedX - internal.x
+ top: parent.bottom
+ }
+ width: 10
+ height: 10
+ visible: false
+ }
+
+ Image {
+ id: balloonTipMask
+ anchors.fill: balloonTip
+ visible: false
+ source: utils.findImage("balloontip.svgz")
+ sourceSize: Qt.size(width, height)
+ }
+
+ OpacityMask {
+ anchors.fill: balloonTip
+ visible: root.visualParent != null
+ source: balloonTip
+ maskSource: balloonTipMask
+ rotation: internal.under? 0: 180
+ }
+
+ Item {
+ id: contentItem
+ x: internal.radius
+ y: internal.radius
+ width: childrenRect.width
+ height: childrenRect.height + 2
+ data: root.data
}
- width: naturalSize.width
- height: naturalSize.height
- }
- MouseArea {
- id: contentItem
- x: parent.margins.left
- y: parent.margins.top
- width: childrenRect.width
- height: childrenRect.height
- onClicked: mouse.accepted = true
}
- }
- onClicked: {
- root.close()
- }
- Component.onCompleted: {
- var candidate = root
- while (candidate.parent) {
- candidate = candidate.parent
+
+ onClicked: {
+ root.close()
}
- if (candidate) {
- dismissArea.parent = candidate
- } else {
- dismissArea.visible = false
+
+ Component.onCompleted: {
+ var candidate = root
+ while (candidate.parent.parent) {
+ candidate = candidate.parent
+ }
+ if (candidate) {
+ dismissArea.parent = candidate
+ }
+ root.status = 'opening'
}
- internal.parentPos = root.mapToItem(dismissArea.parent, 0, 0)
+
}
+
}
}
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index 7d5039b..0a6a444 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -5,7 +5,6 @@ set(ktouch_qml_files
CourseSelector.qml
CoursePage.qml
CourseDescriptionItem.qml
- NoCoursesMessage.qml
ProfileSelector.qml
ProfileForm.qml
ProfileDetailsItem.qml
diff --git a/src/qml/CharactersPerMinuteMeter.qml b/src/qml/CharactersPerMinuteMeter.qml
index 801cf9d..df01d41 100644
--- a/src/qml/CharactersPerMinuteMeter.qml
+++ b/src/qml/CharactersPerMinuteMeter.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.0
-import org.kde.plasma.core 0.1 as PlasmaCore
-import Effects 1.0
+import QtQuick 2.4
import ktouch 1.0
Meter {
@@ -34,12 +33,9 @@ Meter {
referenceValue: strFormatter.formatSign(diff) + " " + (diff > 0? diff: -diff)
valueStatus: meter.charactersPerMinute >= minimumCharactersPerMinute? "good": "bad"
- analogPartContent: PlasmaCore.SvgItem {
+ analogPartContent: Image {
anchors.centerIn: parent
- svg: meterSvg
- elementId: "background"
- width: naturalSize.width
- height: naturalSize.height
+ source: utils.findImage("charactersperminutemeter-background.png")
ScaleBackgroundItem {
anchors.centerIn: parent
@@ -52,14 +48,11 @@ Meter {
color: "#88ff00";
}
- PlasmaCore.SvgItem {
+ Image {
id: scale
anchors.centerIn: parent
anchors.verticalCenterOffset: 25
- svg: meterSvg
- elementId: "scale"
- width: naturalSize.width
- height: naturalSize.height
+ source: utils.findImage("charactersperminutemeter-scale.png")
}
Text {
@@ -82,24 +75,15 @@ Meter {
font.pixelSize: 10
}
- PlasmaCore.SvgItem {
+ Image {
id: hand
anchors.centerIn: parent
anchors.verticalCenterOffset: 25
- svg: meterSvg
- elementId: "hand"
- width: naturalSize.width
- height: naturalSize.height
+ source: utils.findImage("charactersperminutemeter-hand.png")
smooth: true
- effect: DropShadow {
- color: "#000000"
- blurRadius: 5
- xOffset: 0
- yOffset: 0
- }
transform: Rotation {
- origin.x: hand.naturalSize.width / 2
- origin.y: hand.naturalSize.height / 2
+ origin.x: hand.width / 2
+ origin.y: hand.height / 2
angle: Math.min(90, charactersPerMinute * 90 / 360)
Behavior on angle {
SpringAnimation { spring: 2; damping: 0.2; modulus: 360; mass: 0.75}
@@ -107,9 +91,4 @@ Meter {
}
}
}
-
- PlasmaCore.Svg {
- id: meterSvg
- imagePath: findImage("charactersperminutemeter.svgz")
- }
}
diff --git a/src/qml/CourseDescriptionItem.qml b/src/qml/CourseDescriptionItem.qml
index 7d3be36..1ac8a7c 100644
--- a/src/qml/CourseDescriptionItem.qml
+++ b/src/qml/CourseDescriptionItem.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
Rectangle {
@@ -26,9 +27,14 @@ Rectangle {
property string description
property bool active: false
- height: active || content.opacity > 0? childrenRect.height: 0
+ SystemPalette {
+ id: palette
+ colorGroup: SystemPalette.Active
+ }
+
+ height: active || content.opacity > 0? content.height: 0
visible: height > 0
- color: theme.backgroundColor
+ color: palette.base
Behavior on height {
NumberAnimation {
@@ -68,11 +74,10 @@ Rectangle {
}
}
- PlasmaComponents.Label {
+ Label {
id: descriptionLabel
anchors.centerIn: parent
width: parent.width - 10
- font.pointSize: theme.smallestFont.pointSize
}
}
diff --git a/src/qml/CoursePage.qml b/src/qml/CoursePage.qml
index c29c84d..8a0c82a 100644
--- a/src/qml/CoursePage.qml
+++ b/src/qml/CoursePage.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
diff --git a/src/qml/CourseSelector.qml b/src/qml/CourseSelector.qml
index 6d5413f..a8d6761 100644
--- a/src/qml/CourseSelector.qml
+++ b/src/qml/CourseSelector.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
@@ -31,17 +32,19 @@ Item {
signal lessonSelected(variant course, variant lesson)
function selectLastUsedCourse() {
- if (!profile)
+ if (!profile) {
return
+ }
+
var courseId = profile.lastUsedCourseId;
- if (courseId == "custom_lessons") {
+ if (courseId === "custom_lessons") {
selectCourse(courseRepeater.count, true)
return
}
- for (var i = 0; i < courseRepeater.count; i++) {
- var dataIndexCourse = courseRepeater.itemAt(i).dataIndexCourse
+ for (var i = 0; i < courseModel.rowCount(); i++) {
+ var dataIndexCourse = courseModel.data(courseModel.index(i, 0), ResourceModel.DataRole);
if (dataIndexCourse.id === courseId) {
selectCourse(i, true)
return
@@ -52,12 +55,14 @@ Item {
}
function selectCourse(index, automaticSelection) {
- if (index === priv.currentIndex)
+ if (index === priv.currentIndex) {
return
+ }
var direction = index > priv.currentIndex? Item.Left: Item.Right
- var dataIndexCourse = index < courseRepeater.count?
- courseRepeater.itemAt(index).dataIndexCourse: null
+ var dataIndexCourse = index < courseModel.rowCount()?
+ courseModel.data(courseModel.index(index, 0), ResourceModel.DataRole):
+ null;
var targetPage = automaticSelection? coursePageContainer.activePage: coursePageContainer.inactivePage
priv.currentIndex = index;
@@ -83,40 +88,39 @@ Item {
Connections {
target: courseModel
onRowsRemoved: {
+ nextButton.visible = previousButton.visible = courseModel.rowCount() > 1
priv.currentIndex = -1
selectLastUsedCourse()
}
onRowsInserted: {
+ nextButton.visible = previousButton.visible = courseModel.rowCount() > 1
priv.currentIndex = -1
selectLastUsedCourse()
}
}
- Repeater {
- id: courseRepeater
- model: courseModel
-
- delegate: Item {
- property DataIndexCourse dataIndexCourse: dataRole
- }
- }
-
QtObject {
id: priv
property int currentIndex: -1
}
- Column {
+ SystemPalette {
+ id: palette
+ colorGroup: SystemPalette.Active
+ }
+
+ ColumnLayout {
anchors.fill: parent
+ spacing: 0
Rectangle {
id: head
- width: parent.width
- height: Math.ceil(courseTitleLabel.height + 6)
- color: theme.backgroundColor
+ Layout.fillWidth: true
+ height: Math.ceil(Math.max(courseTitleLabel.height, courseDescriptionButton.height) + 6)
+ color: palette.base
- Row {
+ RowLayout {
anchors {
fill: parent
leftMargin: 5
@@ -125,10 +129,10 @@ Item {
bottomMargin: 3
}
- PlasmaComponents.Label {
+ Label {
+ anchors.verticalCenter: parent.verticalCenter
id: courseTitleLabel
- height: paintedHeight
- font.pointSize: 1.5 * theme.defaultFont.pointSize
+ font.pointSize: 1.5 * Qt.font({'family': 'sansserif'}).pointSize
text: coursePageContainer.activePage.course.title
}
@@ -138,46 +142,51 @@ Item {
width: 3
}
- PlasmaComponents.ToolButton {
+ ToolButton {
id: courseDescriptionButton
- iconSource: "dialog-information"
+ anchors.verticalCenter: parent.verticalCenter
+ iconName: "dialog-information"
checkable: true
}
Item {
- width: parent.width - courseTitleLabel.width - smallSpacer.width - courseDescriptionButton.width - previousButton.width - nextButton.width - (parent.children.length - 1) * parent.spacing
- height: parent.height
+ Layout.fillWidth: true
+ Layout.fillHeight: true
}
- PlasmaComponents.ToolButton {
+ ToolButton {
id: previousButton
- iconSource: "arrow-left"
+ anchors.verticalCenter: parent.verticalCenter
+ iconName: "arrow-left"
enabled: priv.currentIndex > 0
- visible: courseRepeater.count > 0
onClicked: {
var newIndex = priv.currentIndex - 1
root.selectCourse(newIndex, false)
}
}
- PlasmaComponents.ToolButton {
+ ToolButton {
id: nextButton
- iconSource: "arrow-right"
- enabled: priv.currentIndex < courseRepeater.count
- visible: courseRepeater.count > 0
+ iconName: "arrow-right"
+ enabled: priv.currentIndex < courseModel.rowCount()
onClicked: {
- var newIndex = (priv.currentIndex + 1) % (courseRepeater.count + 1)
+ var newIndex = (priv.currentIndex + 1) % (courseModel.rowCount() + 1)
root.selectCourse(newIndex, false)
}
}
}
}
- CourseDescriptionItem {
- id: courseDescriptionItem
- width: parent.width
- active: courseDescriptionButton.checked
- description: coursePageContainer.activePage.course.description
+ Item {
+ Layout.fillWidth: true
+ Layout.minimumHeight: courseDescriptionItem.height
+ Layout.maximumHeight: courseDescriptionItem.height
+ CourseDescriptionItem {
+ id: courseDescriptionItem
+ active: courseDescriptionButton.checked
+ description: coursePageContainer.activePage.course.description
+ width: parent.width
+ }
}
Item {
@@ -185,8 +194,8 @@ Item {
property CoursePage activePage: page0
property CoursePage inactivePage: page1
- width: parent.width
- height: parent.height - head.height - courseDescriptionItem.height
+ Layout.fillWidth: true
+ Layout.fillHeight: true
CoursePage {
id: page0
diff --git a/src/qml/CustomLessonSelector.qml b/src/qml/CustomLessonSelector.qml
index 3fd9eb0..750a16c 100644
--- a/src/qml/CustomLessonSelector.qml
+++ b/src/qml/CustomLessonSelector.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
@@ -54,10 +55,10 @@ Item {
}
function createNewLesson() {
- tmpLesson.id = uuid()
+ tmpLesson.id = utils.uuid()
tmpLesson.title = ""
tmpLesson.text = ""
- if (showCustomLessonDialog(tmpLesson, root.keyboardLayout)) {
+ if (ktouch.showCustomLessonDialog(tmpLesson, root.keyboardLayout)) {
profileDataAccess.storeCustomLesson(tmpLesson, root.profile, keyboardLayoutName)
update()
lessonList.currentIndex = lessonList.count - 2
@@ -66,7 +67,7 @@ Item {
function editLesson() {
tmpLesson.copyFrom(base.selectedLesson)
- if (showCustomLessonDialog(tmpLesson, root.keyboardLayout)) {
+ if (ktouch.showCustomLessonDialog(tmpLesson, root.keyboardLayout)) {
profileDataAccess.storeCustomLesson(tmpLesson, root.profile, keyboardLayoutName)
update()
}
@@ -122,41 +123,40 @@ Item {
anchors.fill: parent
- list: ListView {
- id: lessonList
- anchors.fill: parent
-
- model: course.isValid? course.lessonCount + 1: 0
-
- clip: true
-
- delegate: ListItem {
- property Lesson lesson: index < course.lessonCount? course.lesson(index): null
- property bool isNewButton: index == course.lessonCount
- width: lessonList.width - scrollBar.width
- onClicked: {
- lessonList.currentIndex = index
- if (isNewButton) {
- createNewLesson()
+ list: ScrollView {
+ width: 500
+ height: 500
+ ListView {
+ id: lessonList
+ anchors.fill: parent
+
+ model: course.isValid? course.lessonCount + 1: 0
+
+ clip: true
+
+ delegate: ListItem {
+ property Lesson lesson: index < course.lessonCount? course.lesson(index): null
+ property bool isNewButton: index == course.lessonCount
+ width: lessonList.width
+ onClicked: {
+ lessonList.currentIndex = index
+ if (isNewButton) {
+ createNewLesson()
+ }
}
- }
- onDoubleClicked: {
- if (!isNewButton) {
- lessonSelected(course, lesson)
+ onDoubleClicked: {
+ if (!isNewButton) {
+ lessonSelected(course, lesson)
+ }
}
+ title: isNewButton? i18n("Create New Custom Lesson"): (lesson? lesson.title: "")
+ iconSource: isNewButton? "list-add": ""
+ label.font.italic: isNewButton
}
- title: isNewButton? i18n("Create New Custom Lesson"): (lesson? lesson.title: "")
- iconSource: isNewButton? "list-add": ""
- label.font.italic: isNewButton
- }
-
- onCurrentIndexChanged: updateSelectedLesson()
- onModelChanged: selectLastLesson()
+ onCurrentIndexChanged: updateSelectedLesson()
- PlasmaComponents.ScrollBar {
- id: scrollBar
- flickableItem: lessonList
+ onModelChanged: selectLastLesson()
}
}
@@ -170,16 +170,14 @@ Item {
}
opacity: base.selectedLesson !== null? 1: 0
content: [
- PlasmaComponents.ToolButton {
- iconSource: "document-edit"
+ ToolButton {
+ iconName: "document-edit"
text: i18n("Edit")
onClicked: editLesson()
- width: minimumWidth
},
- PlasmaComponents.ToolButton {
- iconSource: "edit-delete"
+ ToolButton {
+ iconName: "edit-delete"
text: i18n("Delete")
- width: minimumWidth
onClicked: deleteLesson()
}
]
@@ -204,23 +202,22 @@ Item {
}
opacity: !!lastDeletedLesson? 1: 0
content: [
- PlasmaComponents.Label {
+ Label {
text: i18n("'%1' deleted.", undoToolbar.lastDeletedLessonTitle)
+ anchors.verticalCenter: parent.verticalCenter
},
Item {
width: 5
height: 1
},
- PlasmaComponents.ToolButton {
- iconSource: "edit-undo"
+ ToolButton {
+ iconName: "edit-undo"
text: i18n("Undo")
- width: minimumWidth
onClicked: undoLessonDeletion()
},
- PlasmaComponents.ToolButton {
- iconSource: "dialog-close"
+ ToolButton {
+ iconName: "dialog-close"
text: i18n("Dismiss")
- width: minimumWidth
onClicked: confirmLessonDeletion()
}
]
diff --git a/src/qml/DetailedRadioButton.qml b/src/qml/DetailedRadioButton.qml
index acfacd5..041d9dd 100644
--- a/src/qml/DetailedRadioButton.qml
+++ b/src/qml/DetailedRadioButton.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2014 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,11 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
-Column {
+ColumnLayout {
id: root
property alias checked: radioButton.checked
@@ -31,18 +32,17 @@ Column {
Row {
id: radioButtonRow
- width: parent.width
+ Layout.fillWidth: true
spacing: Math.round(label.height / 4)
- PlasmaComponents.RadioButton {
+ RadioButton {
id: radioButton
anchors.verticalCenter: parent.verticalCenter
}
- PlasmaComponents.Label {
+ Label {
id: label
anchors.verticalCenter: parent.verticalCenter
- height: paintedHeight
/*
* The text wrapping of the label doesn't work if it is invible
* (wrapped at every character), hence the following hack.
@@ -61,7 +61,7 @@ Column {
}
Row {
- width: parent.width
+ Layout.fillWidth: true
spacing: radioButtonRow.spacing
Item {
@@ -69,11 +69,9 @@ Column {
height: hint.height
}
- PlasmaComponents.Label {
+ Label {
id: hint
- font.pointSize: theme.smallestFont.pointSize
font.italic: true
- height: paintedHeight
width: visible? parent.width - radioButton.width - parent.spacing: 0
wrapMode: Text.Wrap
opacity: radioButton.opacity
diff --git a/src/qml/ElapsedTimeMeter.qml b/src/qml/ElapsedTimeMeter.qml
index 71c3fbd..052a717 100644
--- a/src/qml/ElapsedTimeMeter.qml
+++ b/src/qml/ElapsedTimeMeter.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import Effects 1.0
+import QtQuick 2.4
import ktouch 1.0
Meter {
@@ -31,64 +30,37 @@ Meter {
referenceValue: strFormatter.formatTimeDiff(meter.referenceElapsedTime, meter.elapsedTime)
positiveDiffIsGood: false
- analogPartContent: PlasmaCore.SvgItem {
+ analogPartContent: Image {
anchors.centerIn: parent
- svg: clockSvg
- elementId: "background"
- width: naturalSize.width
- height: naturalSize.height
+ source: utils.findImage("elapsedtimemeter-background.png")
- PlasmaCore.SvgItem {
+ Image {
id: minuteHand
anchors.centerIn: parent
- svg: clockSvg
- elementId: "minute-hand"
- width: naturalSize.width
- height: naturalSize.height
+ source: utils.findImage("elapsedtimemeter-minute-hand.png")
smooth: true
- effect: DropShadow {
- color: "#000000"
- blurRadius: 5
- xOffset: 0
- yOffset: 0
- }
transform: Rotation {
- origin.x: minuteHand.naturalSize.width / 2
- origin.y: minuteHand.naturalSize.height / 2
- angle: elapsedTime? 6 * getMinutesOfQTime(elapsedTime): 0
+ origin.x: minuteHand.width / 2
+ origin.y: minuteHand.height / 2
+ angle: elapsedTime? 6 * utils.getMinutesOfQTime(elapsedTime): 0
Behavior on angle {
SpringAnimation { spring: 2; damping: 0.2; modulus: 360; mass: 0.75}
}
}
}
- PlasmaCore.SvgItem {
+ Image {
id: secondHand
anchors.centerIn: parent
- svg: clockSvg
- elementId: "second-hand"
- width: naturalSize.width
- height: naturalSize.height
- smooth: true
- effect: DropShadow {
- color: "#000000"
- blurRadius: 5
- xOffset: 0
- yOffset: 0
- }
+ source: utils.findImage("elapsedtimemeter-second-hand.png")
transform: Rotation {
- origin.x: secondHand.naturalSize.width / 2
- origin.y: secondHand.naturalSize.height / 2
- angle: elapsedTime? 6 * getSecondsOfQTime(elapsedTime): 0
+ origin.x: secondHand.width / 2
+ origin.y: secondHand.height / 2
+ angle: elapsedTime? 6 * utils.getSecondsOfQTime(elapsedTime): 0
Behavior on angle {
SpringAnimation { spring: 2; damping: 0.2; modulus: 360; mass: 0.75}
}
}
}
}
-
- PlasmaCore.Svg {
- id: clockSvg
- imagePath: findImage("elapsedtimemeter.svgz")
- }
}
diff --git a/src/qml/HomeScreen.qml b/src/qml/HomeScreen.qml
index 3f8d498..c0c907e 100644
--- a/src/qml/HomeScreen.qml
+++ b/src/qml/HomeScreen.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
FocusScope {
@@ -68,46 +69,47 @@ FocusScope {
preferences.writeConfig()
}
- Column {
+ ColumnLayout {
anchors.fill: parent
- spacing: header.margins.bottom / 2
+ spacing: 0
- PlasmaComponents.ToolBar {
- visible: homeScreenAccordion.opacity > 0
+ ToolBar {
+ visible: courseSelector.opacity > 0
id: header
- width: parent.width
- tools: Row {
+ Layout.fillWidth: true
+
+ RowLayout {
+ anchors.fill: parent
anchors.leftMargin: 3
anchors.rightMargin: 3
spacing: 5
- PlasmaComponents.ToolButton {
+ Button {
+ // TODO: Find a better control here which supports both an icon and a label
id: profileButton
- iconSource: "user-identity"
+ iconName: "user-identity"
text: d.profile !== null? d.profile.name: ""
onClicked: {
- if (profileSelectorSheet.isOpen()) {
- profileSelectorSheet.close()
+ if (checked) {
+ profileSelectorSheet.open()
}
else {
- profileSelectorSheet.open()
+ profileSelectorSheet.close()
}
}
- checked: profileSelectorSheet.isOpen()
- width: minimumWidth
+ checkable: true
}
Item {
- height: parent.height
- width: parent.width - profileButton.width - configureButton.width - (parent.children.length - 1) * parent.spacing
+ Layout.fillWidth: true
}
- PlasmaComponents.ToolButton {
+ ToolButton {
id: configureButton
- iconSource: "configure"
+ iconName: "configure"
onClicked: {
var position = mapToItem(null, 0, height)
- showMenu(position.x, position.y)
+ ktouch.showMenu(position.x, position.y)
}
}
}
@@ -115,11 +117,11 @@ FocusScope {
Item {
id: content
- width: parent.width
- height: parent.height - header.height
+ Layout.fillWidth: true
+ Layout.fillHeight: true
CourseSelector {
- id: homeScreenAccordion
+ id: courseSelector
opacity: 1 - initialProfileForm.opacity
courseModel: screen.courseModel
profile: d.profile
@@ -146,12 +148,15 @@ FocusScope {
SheetDialog {
id: profileSelectorSheet
anchors.fill: parent
- onOpended: {
+ onOpened: {
if (d.profile) {
var index = profileDataAccess.indexOfProfile(d.profile)
profileSelector.selectProfile(index)
}
}
+ onClosed: {
+ profileButton.checked = false;
+ }
content: ProfileSelector {
id: profileSelector
anchors.fill: parent
diff --git a/src/qml/InfoItem.qml b/src/qml/InfoItem.qml
index bc2b81d..d61c4e5 100644
--- a/src/qml/InfoItem.qml
+++ b/src/qml/InfoItem.qml
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
QtObject {
property string title
diff --git a/src/qml/InformationTable.qml b/src/qml/InformationTable.qml
index 1f5b590..6538a78 100644
--- a/src/qml/InformationTable.qml
+++ b/src/qml/InformationTable.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
+import ktouch 1.0
Item {
property alias model: repeator.model
@@ -36,7 +38,7 @@ Item {
spacing: 5
height: Math.max(titleLabel.height, valueLabel.height)
width: column.width
- PlasmaComponents.Label {
+ Label {
id: titleLabel
width: Math.round((parent.width - parent.spacing) / 2)
horizontalAlignment: Text.AlignRight
@@ -46,7 +48,7 @@ Item {
wrapMode: Text.Wrap
height: Math.max(paintedHeight, valueLabel.paintedHeight)
}
- PlasmaComponents.Label {
+ Label {
id: valueLabel
width: parent.width - titleLabel.width - parent.spacing
horizontalAlignment: Text.AlignLeft
diff --git a/src/qml/InitialProfileForm.qml b/src/qml/InitialProfileForm.qml
index a410803..da1e609 100644
--- a/src/qml/InitialProfileForm.qml
+++ b/src/qml/InitialProfileForm.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,10 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.qtextracomponents 0.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
FocusScope {
@@ -32,74 +32,24 @@ FocusScope {
profileDataAccess.addProfile(profile)
}
- PlasmaCore.FrameSvgItem {
+ GroupBox {
id: frame
anchors.centerIn: parent
+ title: i18n("Welcome to Typewriting Trainer")
width: form.width + 150
height: form.height + 80
- imagePath: "widgets/frame"
- prefix: "raised"
- Column {
- id: layout
-
- anchors {
- fill: parent
- topMargin: frame.margins.top
- rightMargin: frame.margins.right
- bottomMargin: frame.margins.bottom
- leftMargin: frame.margins.left
- }
-
- spacing: 0
-
- Item {
- id: header
- height: 20
- width: parent.width
-
- Row {
- anchors.centerIn: parent
- spacing: 6
-
- QIconItem {
- icon: QIcon("ktouch")
- width: theme.smallIconSize
- height: theme.smallIconSize
- }
-
- PlasmaComponents.Label {
- id: titleLabel
- text: i18n("Welcome to Typewriting Trainer")
- height: paintedHeight
- }
-
- }
- }
-
- PlasmaCore.SvgItem {
- id: line
- width: parent.width
- height: naturalSize.height
- elementId: "horizontal-line"
- svg: PlasmaCore.Svg {
- imagePath: "widgets/line"
- }
- }
-
- Item {
- id: content
- width: parent.width
- height: parent.height - header.height - line.height
-
- ProfileForm {
- id: form
- width: 400
- anchors.centerIn: parent
- doneButtonIconSource: "go-next-view"
- doneButtonText: i18n("Start Training")
- onDone: save()
- }
+ Item {
+ id: content
+ anchors.fill: parent
+
+ ProfileForm {
+ id: form
+ width: 400
+ anchors.centerIn: parent
+ doneButtonIconSource: "go-next-view"
+ doneButtonText: i18n("Start Training")
+ onDone: save()
}
}
}
diff --git a/src/qml/InlineToolbar.qml b/src/qml/InlineToolbar.qml
index d456035..4202560 100644
--- a/src/qml/InlineToolbar.qml
+++ b/src/qml/InlineToolbar.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
Item {
@@ -29,12 +28,18 @@ Item {
width: contentArea.width + 6
height: contentArea.height + 6
+
Rectangle {
anchors.fill: parent
id: background
- color: "#888"
+ color: activePalette.mid
opacity: 0.7
radius: 3
+
+ SystemPalette {
+ id: activePalette
+ colorGroup: SystemPalette.Active
+ }
}
Behavior on opacity {
diff --git a/src/qml/KeyItem.qml b/src/qml/KeyItem.qml
index 04bff57..9404189 100644
--- a/src/qml/KeyItem.qml
+++ b/src/qml/KeyItem.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import Effects 1.0
+import QtQuick 2.4
+import QtGraphicalEffects 1.0
import ktouch 1.0
Item {
@@ -46,7 +47,7 @@ Item {
switch (key.keyType()) {
case "key":
for (var i = 0; i < key.keyCharCount; i++) {
- if (key.keyChar(i).value == eventText.charCodeAt(0)) {
+ if (key.keyChar(i).value == eventText) {
return true;
}
}
@@ -73,8 +74,7 @@ Item {
}
function getTint(color) {
- // stupid hack to set alpha because in Qt Quick 1.1 it's impossible to access color components
- color = "#20" + ("" + color).substr(1)
+ color.a = 0.125
return color
}
@@ -105,21 +105,6 @@ Item {
height: item.height + marginSize
smooth: true
radius: body.radius
- effect: DropShadow {
- color: shadow.color
- blurRadius: 5
- xOffset: 0
- yOffset: 0
-
- Behavior on blurRadius {
- enabled: animateHighlight
- NumberAnimation {
- duration: 150
- easing.type: Easing.InOutQuad
- }
- }
- }
-
state: "normal"
states: [
@@ -131,8 +116,8 @@ Item {
marginSize: 0
}
PropertyChanges {
- target: shadow.effect
- blurRadius: 10
+ target: shadowEffect
+ glowRadius: 10
}
},
State {
@@ -143,8 +128,8 @@ Item {
marginSize: 4
}
PropertyChanges {
- target: shadow.effect
- blurRadius: 15
+ target: shadowEffect
+ glowRadius: 15
}
},
State {
@@ -155,8 +140,8 @@ Item {
marginSize: 0
}
PropertyChanges {
- target: shadow.effect
- blurRadius: 15
+ target: shadowEffect
+ glowRadius: 15
}
}
]
@@ -193,7 +178,21 @@ Item {
}
PauseAnimation { duration: 150 }
}
+ }
+
+ RectangularGlow {
+ id: shadowEffect
+ anchors.fill: shadow
+ color: shadow.color
+ glowRadius: 5
+ Behavior on glowRadius {
+ enabled: animateHighlight
+ NumberAnimation {
+ duration: 150
+ easing.type: Easing.InOutQuad
+ }
+ }
}
Rectangle {
diff --git a/src/qml/KeyLabel.qml b/src/qml/KeyLabel.qml
index 73a0325..ed11262 100644
--- a/src/qml/KeyLabel.qml
+++ b/src/qml/KeyLabel.qml
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.0
+import QtQuick 2.4
import ktouch 1.0
Text {
@@ -49,28 +49,19 @@ Text {
if (position === keyChar.position) {
return keyChar
}
- else if (position === keyChar.position) {
- return keyChar
- }
- else if (position === keyChar.position) {
- return keyChar
- }
- else if (position === keyChar.position) {
- return keyChar
- }
}
return null;
}
function keyLabel(position, key) {
var keyChar = root.keyChar(position, key)
- return keyChar? String.fromCharCode(keyChar.value): ""
+ return keyChar? keyChar.value: ""
}
- color: key.state == "normal"? "#333": "#222"
+ color: key.state === "normal"? "#333": "#222"
smooth: true
font.pixelSize: referenceKey.height * Math.min(horizontalScaleFactor, verticalScaleFactor) / 3
- text: key.keyType() == "specialKey"?
- position == KeyChar.TopLeft? specialKeyLabel(key.type): "":
+ text: key.keyType() === "specialKey"?
+ position === KeyChar.TopLeft? specialKeyLabel(key.type): "":
keyLabel(position, key)
}
diff --git a/src/qml/Keyboard.qml b/src/qml/Keyboard.qml
index 469145b..295257a 100644
--- a/src/qml/Keyboard.qml
+++ b/src/qml/Keyboard.qml
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
import ktouch 1.0
Item {
diff --git a/src/qml/KeyboardLayoutEditor.qml b/src/qml/KeyboardLayoutEditor.qml
index c4b3797..ff65ecf 100644
--- a/src/qml/KeyboardLayoutEditor.qml
+++ b/src/qml/KeyboardLayoutEditor.qml
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
import ktouch 1.0
Item {
@@ -25,10 +25,10 @@ Item {
id: preferences
}
- property real scaleFactor: Math.pow(2, zoomLevel / 2)
+ property real scaleFactor: Math.pow(2, keyboardLayoutEditor.zoomLevel / 2)
property real horizontalScaleFactor: scaleFactor
property real verticalScaleFactor: scaleFactor
- property KeyboardLayout layout: keyboardLayout
+ property KeyboardLayout layout: keyboardLayoutEditor.keyboardLayout
property int lastZIndex: 0
width: keyContainer.width + 40
@@ -38,7 +38,7 @@ Item {
anchors.fill: parent
onPressed: {
if (mouse.button == Qt.LeftButton) {
- selectedKey = null
+ keyboardLayoutEditor.selectedKey = null
mouse.accepted = true
}
}
@@ -64,21 +64,22 @@ Item {
id: keyItem
keyboardLayout: layout;
keyIndex: index
- isHighlighted: keyItem.key == selectedKey
+ isHighlighted: keyItem.key == keyboardLayoutEditor.selectedKey
animateHighlight: false
opacity: manipulated? 0.7: 1.0
MouseArea {
anchors.fill: parent
+ cursorShape: keyItem.manipulated? Qt.SizeAllCursor: Qt.ArrowCursor
onPressed: {
if (mouse.button == Qt.LeftButton) {
- selectedKey = layout.key(index)
+ keyboardLayoutEditor.selectedKey = layout.key(index)
root.lastZIndex++
keyItem.z = root.lastZIndex
}
}
drag {
- target: !readOnly? keyItem: undefined
+ target: !keyboardLayoutEditor.readOnly? keyItem: undefined
axis: Drag.XandYAxis
minimumX: 0
maximumX: keyContainer.width - keyItem.width
@@ -89,17 +90,12 @@ Item {
if (!drag.active) {
var left = 10 * Math.round(keyItem.x / scaleFactor / 10)
var top = 10 * Math.round(keyItem.y / scaleFactor / 10)
- setKeyGeometry(keyIndex, left, top, keyItem.key.width, keyItem.key.height)
+ keyboardLayoutEditor.setKeyGeometry(keyIndex, left, top, keyItem.key.width, keyItem.key.height)
}
}
}
}
- CursorShapeArea {
- anchors.fill: parent
- cursorShape: manipulated? Qt.SizeAllCursor: Qt.ArrowCursor
- }
-
Behavior on opacity {
NumberAnimation { duration: 150 }
}
@@ -108,9 +104,9 @@ Item {
SelectionRectangle {
keyboardLayout: layout;
- target: selectedKey
+ target: keyboardLayoutEditor.selectedKey
z: root.lastZIndex + 1
- interactive: !readOnly
+ interactive: !keyboardLayoutEditor.readOnly
}
}
}
diff --git a/src/qml/KeyboardUnavailableNotice.qml b/src/qml/KeyboardUnavailableNotice.qml
index ae1cc9f..9e4f094 100644
--- a/src/qml/KeyboardUnavailableNotice.qml
+++ b/src/qml/KeyboardUnavailableNotice.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,10 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.qtextracomponents 0.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
+import org.kde.kquickcontrolsaddons 2.0
import ktouch 1.0
Item {
@@ -36,16 +37,15 @@ Item {
QIconItem {
id: icon
anchors.verticalCenter: parent.verticalCenter
- width: theme.smallIconSize
- height: theme.smallIconSize
- icon: QIcon("dialog-warning")
+ width: 22
+ height: 22
+ icon: "dialog-warning"
}
- PlasmaComponents.Label {
+ Label {
id: label
anchors.verticalCenter: parent.verticalCenter
width: parent.width - icon.width - parent.spacing
- height: paintedHeight
text: i18n("No visualization available for your keyboard layout.")
color: "white"
}
diff --git a/src/qml/LearningProgressChart.qml b/src/qml/LearningProgressChart.qml
index a2a05ed..99a03c0 100644
--- a/src/qml/LearningProgressChart.qml
+++ b/src/qml/LearningProgressChart.qml
@@ -15,9 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import org.kde.charts 0.1
import ktouch 1.0
@@ -40,7 +40,7 @@ LineChart {
return 0;
}
-
+
dimensions: [
Dimension {
id: accuracyDimension
diff --git a/src/qml/LessonLockedNotice.qml b/src/qml/LessonLockedNotice.qml
index 98f21a5..7bf65dc 100644
--- a/src/qml/LessonLockedNotice.qml
+++ b/src/qml/LessonLockedNotice.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.qtextracomponents 0.1
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
+import QtGraphicalEffects 1.0
+import org.kde.kquickcontrolsaddons 2.0
+import ktouch 1.0
+
Item {
id: root
@@ -25,11 +30,31 @@ Item {
width: content.width + 40
height: content.height + 40
- Rectangle {
+ property alias blurSource: effectSource.sourceItem
+
+ SystemPalette {
+ id: palette
+ colorGroup: SystemPalette.Active
+ }
+
+ ShaderEffectSource {
+ id: effectSource
+ anchors.fill: parent
+ hideSource: false
+ sourceRect: Qt.rect(root.x, root.y, root.width, root.height)
+ }
+
+ FastBlur {
anchors.fill: parent
+ source: effectSource
+ radius: 25
+ }
+
+ Rectangle {
id: background
- color: "#000"
- opacity: 0.7
+ anchors.fill: parent
+ color: palette.base
+ opacity: 0.3
radius: 15
}
@@ -49,17 +74,16 @@ Item {
QIconItem {
id: icon
anchors.horizontalCenter: parent.horizontalCenter
- icon: QIcon("object-locked")
- width: theme.enormousIconSize
- height: theme.enormousIconSize
+ icon: "object-locked"
+ width: 128
+ height: 128
}
- PlasmaComponents.Label {
+ Label {
id: text
text: i18n("Complete Previous Lessons to Unlock")
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
- color: "#fff"
font.weight: Font.Bold
wrapMode: Text.Wrap
}
diff --git a/src/qml/LessonPreview.qml b/src/qml/LessonPreview.qml
index d648c0a..034bd18 100644
--- a/src/qml/LessonPreview.qml
+++ b/src/qml/LessonPreview.qml
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
import ktouch 1.0
Item {
diff --git a/src/qml/LessonSelector.qml b/src/qml/LessonSelector.qml
index 9ca39ac..85976fd 100644
--- a/src/qml/LessonSelector.qml
+++ b/src/qml/LessonSelector.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
@@ -86,32 +87,31 @@ Item {
LessonSelectorBase {
anchors.fill: parent
- list: ListView {
- id: lessonList
- property int lastUnlockedIndex: 0
+ list:ScrollView {
anchors.fill: parent
- model: course.isValid? course.lessonCount: 0
- clip: true
- delegate: ListItem {
- property Lesson lesson: index < course.lessonCount? course.lesson(index): null
- property bool locked: index > lessonList.lastUnlockedIndex
- width: lessonList.width - scrollBar.width
- onClicked: lessonList.currentIndex = index
- onDoubleClicked: {
- if (!locked) {
- lessonSelected(course, lesson)
+ ListView {
+ anchors.fill: parent
+ id: lessonList
+ property int lastUnlockedIndex: 0
+ model: course.isValid? course.lessonCount: 0
+ spacing: 3
+ clip: true
+ delegate: ListItem {
+ property Lesson lesson: index < course.lessonCount? course.lesson(index): null
+ property bool locked: index > lessonList.lastUnlockedIndex
+ width: lessonList.width
+ onClicked: lessonList.currentIndex = index
+ onDoubleClicked: {
+ if (!locked) {
+ lessonSelected(course, lesson)
+ }
}
- }
- iconSource: locked? "object-locked": ""
- label.opacity: locked? 0.5: 1.0
- title: lesson? lesson.title: ""
-
- }
- onModelChanged: update()
+ iconSource: locked? "object-locked": ""
+ label.opacity: locked? 0.5: 1.0
+ title: lesson? lesson.title: ""
- PlasmaComponents.ScrollBar {
- id: scrollBar
- flickableItem: lessonList
+ }
+ onModelChanged: update()
}
}
diff --git a/src/qml/LessonSelectorBase.qml b/src/qml/LessonSelectorBase.qml
index e0cca1b..0cfe5f9 100644
--- a/src/qml/LessonSelectorBase.qml
+++ b/src/qml/LessonSelectorBase.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
@@ -39,9 +40,10 @@ Item {
id: listContainer
height: parent.height
width: Math.round((parent.width - parent.spacing) / 2)
+
}
- Column {
+ ColumnLayout {
id: column
width: parent.width - listContainer.width - parent.spacing
height: parent.height
@@ -49,27 +51,29 @@ Item {
LessonPreview {
id: lessonPreview
- width: parent.width
- height: parent.height - startButtonContainer.height
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
lesson: selectedLesson
+ }
- LessonLockedNotice {
- anchors.centerIn: parent
- opacity: selectedLessonLocked? 1: 0
- }
+ LessonLockedNotice {
+ anchors.centerIn: lessonPreview
+ blurSource: lessonPreview
+ opacity: selectedLessonLocked? 1: 0
}
Item {
id: startButtonContainer
- width: parent.width
+ Layout.fillWidth: true
height: Math.round(1.5 * startButton.height)
- PlasmaComponents.Button {
+ Button {
id: startButton
anchors.centerIn: parent
text: i18n("Start Training")
enabled: selectedLesson !== null && !selectedLessonLocked
- iconSource: "go-next-view"
+ iconName: "go-next-view"
onClicked: startButtonClicked()
}
}
diff --git a/src/qml/ListItem.qml b/src/qml/ListItem.qml
index b8a609b..2185b57 100644
--- a/src/qml/ListItem.qml
+++ b/src/qml/ListItem.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,41 +16,55 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.qtextracomponents 0.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
+import org.kde.kquickcontrolsaddons 2.0
+import ktouch 1.0
Item {
id: root
property alias title: label.text
property string iconSource
property alias label: label
+ property bool isCurrent: ListView.isCurrentItem;
signal clicked
signal doubleClicked
- height: padding.height + bg.margins.top + bg.margins.bottom
- state: ListView.isCurrentItem? "selected": mouseArea.containsMouse? "hover": "normal"
+ height: 2 * content.height
- PlasmaCore.FrameSvgItem {
+ SystemPalette {
+ id: listItemPallete
+ colorGroup: SystemPalette.Active
+ }
+
+ Rectangle {
id: bg
- imagePath: "widgets/viewitem"
- prefix: "hover"
- opacity: 0
anchors.fill: parent
+ color: Qt.rgba(listItemPallete.highlight.r, listItemPallete.highlight.g, listItemPallete.highlight.b, 0.3)
+ radius: 0.2 * height
+ border {
+ width: 1
+ color: listItemPallete.highlight
+ }
+ opacity: root.isCurrent || mouseArea.containsMouse? 1: 0
+ Behavior on opacity {
+ NumberAnimation {
+ duration: 150
+ }
+ }
}
Item {
- id: padding
+ id: content
anchors {
- fill: parent
- topMargin: bg.margins.top
- rightMargin: bg.margins.right
- bottomMargin: bg.margins.bottom
- leftMargin: bg.margins.left
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ right: parent.right
+ leftMargin: 5
+ rightMargin: 5
}
- width: parent.width
height: Math.max(label.height, label.height)
QIconItem {
@@ -59,12 +74,12 @@ Item {
left: parent.left
verticalCenter: parent.verticalCenter
}
- icon: QIcon(root.iconSource)
- width: theme.smallIconSize
- height: theme.smallIconSize
+ icon: root.iconSource
+ width: 22
+ height: 22
}
- PlasmaComponents.Label {
+ Label {
id: label
elide: Text.ElideRight
anchors {
@@ -72,7 +87,6 @@ Item {
right: parent.right
verticalCenter: parent.verticalCenter
}
- height: paintedHeight
}
}
@@ -83,53 +97,4 @@ Item {
onClicked: root.clicked()
onDoubleClicked: root.doubleClicked()
}
-
- states: [
- State {
- name: "normal"
- PropertyChanges {
- target: bg
- opacity: 0
- }
- },
- State {
- name: "hover"
- PropertyChanges {
- target: bg
- opacity: 1
- prefix: "hover"
- }
- },
- State {
- name: "selected"
- PropertyChanges {
- target: bg
- opacity: 1
- prefix: "selected"
- }
- }
- ]
-
- transitions: [
- Transition {
- from: "normal"
- to: "hover"
- NumberAnimation {
- target: bg
- property: "opacity"
- duration: 250
- easing.type: Easing.OutCubic
- }
- },
- Transition {
- from: "hover"
- to: "normal"
- NumberAnimation {
- target: bg
- property: "opacity"
- duration: 250
- easing.type: Easing.OutCubic
- }
- }
- ]
}
diff --git a/src/qml/MessageBox.qml b/src/qml/MessageBox.qml
index b340029..b3021aa 100644
--- a/src/qml/MessageBox.qml
+++ b/src/qml/MessageBox.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import org.kde.kquickcontrolsaddons 2.0
Rectangle {
id: item
@@ -31,7 +32,7 @@ Rectangle {
function showMessage(msg, iconSource) {
item.state = "hidden";
label.text = msg
- icon.source = iconSource || ""
+ icon.icon = iconSource || ""
item.state = "normal"
}
@@ -62,16 +63,14 @@ Rectangle {
width: icon.width + spacing + label.width
spacing: icon.valid? 3: 0
- PlasmaCore.IconItem {
+ QIconItem {
id: icon
width: height
- height: valid? label.height: 0
+ height: icon? label.height: 0
}
- PlasmaComponents.Label {
+ Label {
id: label
- height: paintedHeight
- smooth: true
color: "#000000"
}
}
diff --git a/src/qml/Meter.qml b/src/qml/Meter.qml
index ba5156e..5b197e1 100644
--- a/src/qml/Meter.qml
+++ b/src/qml/Meter.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,10 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
+import QtQuick 2.4
+import QtQuick.Layouts 1.1
-Row {
+RowLayout {
id: meter
property alias label: label.text
@@ -30,21 +31,32 @@ Row {
height: 112
width: 304
+ spacing: 0
- PlasmaCore.FrameSvgItem {
+ BorderImage {
id: analogPart
- width: height
- height: parent.height
- imagePath: findImage("meterbox.svgz")
- prefix: "analog"
+ Layout.preferredWidth: height
+ Layout.fillHeight: true
+ border {
+ left: 6
+ top: 6
+ right:6
+ bottom: 6
+ }
+ source: utils.findImage("meterbox-left.png")
}
- PlasmaCore.FrameSvgItem {
+ BorderImage {
id: digitalPart
- width: parent.width - analogPart.width
- height: parent.height
- imagePath: findImage("meterbox.svgz")
- prefix: "digital"
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ border {
+ left: 6
+ top: 6
+ right:6
+ bottom: 6
+ }
+ source: utils.findImage("meterbox-right.png")
Column {
anchors {
@@ -55,7 +67,7 @@ Row {
rightMargin: 12
}
- spacing: 8
+ spacing: 0
Row {
width: parent.width
@@ -69,19 +81,15 @@ Row {
elide: Text.ElideRight
}
- PlasmaCore.SvgItem {
+ Rectangle {
id: statusLed
- anchors.verticalCenter: parent.verticalCenter
- height: naturalSize.height
- width: naturalSize.width
+ height: 15
+ width: 15
+ radius: height / 2
visible: valueStatus !== "none"
- elementId: valueStatus === "good"? "led-good": "led-bad"
- svg: PlasmaCore.Svg {
- imagePath: findImage("statusled.svgz")
- }
- smooth: true
+ color: valueStatus === "good"? "#88ff00": "#424b35"
- onElementIdChanged: statusLedAnimaton.restart()
+ onColorChanged: statusLedAnimaton.restart()
SequentialAnimation {
id: statusLedAnimaton
diff --git a/src/qml/NoCoursesMessage.qml b/src/qml/NoCoursesMessage.qml
deleted file mode 100644
index 3ab742c..0000000
--- a/src/qml/NoCoursesMessage.qml
+++ /dev/null
@@ -1,78 +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/>.
- */
-
-import QtQuick 1.1
-import org.kde.qtextracomponents 0.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
-import ktouch 1.0
-
-Item {
- id: item
-
- PlasmaCore.FrameSvgItem {
- id: frame
- anchors.fill: parent
- anchors.margins: 40
- imagePath: "widgets/frame"
- prefix: "raised"
-
- Column {
- id: layout
- anchors {
- fill: parent
- topMargin: frame.margins.top + spacing
- rightMargin: frame.margins.right + spacing
- bottomMargin: frame.margins.bottom + spacing
- leftMargin: frame.margins.left + spacing
- }
-
- spacing: 20
-
- Rectangle {
- width: parent.width
- color: "#eee4be"
- height: 80
- radius: 15
- PlasmaComponents.Label {
- anchors.centerIn: parent
- text: i18n("No Courses Available")
- height: paintedHeight
- font.pointSize: 1.5 * theme.defaultFont.pointSize
- }
- }
-
- QIconItem {
- id: icon
- anchors.horizontalCenter: parent.horizontalCenter
- icon: QIcon("face-sad")
- width: theme.enormousIconSize
- height: theme.enormousIconSize
- }
-
- PlasmaComponents.Label {
- width: parent.width
- text: i18n("Typewriting Trainer has no courses for your keyboard layout. You may create your own course with the keyboard layout and course editor.")
- }
-
- PlasmaComponents.Button {
- text: i18n("Launch Editor")
- onClicked: showResourceEditor()
- }
- }
- }
-}
diff --git a/src/qml/ProfileDetailsItem.qml b/src/qml/ProfileDetailsItem.qml
index d173fb2..920626b 100644
--- a/src/qml/ProfileDetailsItem.qml
+++ b/src/qml/ProfileDetailsItem.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,10 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.locale 0.1 as Locale
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
+import org.kde.kcoreaddons 1.0
import org.kde.charts 0.1 as Charts
import ktouch 1.0
@@ -42,10 +43,12 @@ Item {
onProfileChanged: update()
- Locale.Locale {
- id: locale
+ SystemPalette {
+ id: activePalette
+ colorGroup: SystemPalette.Active
}
+
Item {
id: infoContainer
width: parent.width
@@ -68,11 +71,11 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 40
height: 250
- color: theme.backgroundColor
+ color: activePalette.base
border {
width: 1
- color: theme.textColor
+ color: activePalette.text
}
Column {
@@ -123,11 +126,11 @@ Item {
},
InfoItem {
title: i18n("Total training time:")
- text: profile && profile.id !== -1? locale.prettyFormatDuration(profileDataAccess.totalTrainingTime(profile)): ""
+ text: profile && profile.id !== -1? Format.formatDuration(profileDataAccess.totalTrainingTime(profile)): ""
},
InfoItem {
title: i18n("Last trained:")
- text: profile && profile.id !== -1 && profileInfoTable.trainedLessonCount > 0? locale.formatDateTime(profileDataAccess.lastTrainingSession(profile)): i18n("Never")
+ text: profile && profile.id !== -1 && profileInfoTable.trainedLessonCount > 0? profileDataAccess.lastTrainingSession(profile).toLocaleDateString(): i18n("Never")
}
]
@@ -142,18 +145,16 @@ Item {
topMargin: 5
}
content: [
- PlasmaComponents.ToolButton {
- iconSource: "document-edit"
+ ToolButton {
+ iconName: "document-edit"
text: i18n("Edit")
onClicked: root.state = "editor"
- width: minimumWidth
},
- PlasmaComponents.ToolButton {
- iconSource: "edit-delete"
+ ToolButton {
+ iconName: "edit-delete"
text: i18n("Delete")
enabled: profileDataAccess.profileCount > 1
onClicked: root.state = "deleteConfirmation"
- width: minimumWidth
}
]
}
@@ -194,7 +195,7 @@ Item {
height: childrenRect.height
spacing: 15
- PlasmaComponents.Label {
+ Label {
property string name
id: deleteConfirmationLabel
width: parent.width
@@ -207,16 +208,14 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
width: childrenRect.width
height: childrenRect.height
- PlasmaComponents.ToolButton {
- iconSource: "edit-delete"
+ ToolButton {
+ iconName: "edit-delete"
text: i18n("Delete")
onClicked: root.deletionRequest()
- width: minimumWidth
}
- PlasmaComponents.ToolButton {
+ ToolButton {
text: i18n("Cancel")
onClicked: root.state = "info"
- width: minimumWidth
}
}
}
diff --git a/src/qml/ProfileForm.qml b/src/qml/ProfileForm.qml
index a11d9c5..165208d 100644
--- a/src/qml/ProfileForm.qml
+++ b/src/qml/ProfileForm.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
Column {
@@ -39,13 +40,13 @@ Column {
spacing: 15
- PlasmaComponents.Label {
+ Label {
id: welcomeLabel
width: parent.width
text: i18n("Before you start training, please introduce yourself:")
}
- PlasmaComponents.TextField {
+ TextField {
id: nameTextField
width: parent.width
placeholderText: i18n("Name")
@@ -79,12 +80,12 @@ Column {
}
}
- PlasmaComponents.Button {
+ Button {
id: doneBtn
anchors.horizontalCenter: parent.horizontalCenter
text: i18n("Done")
enabled: nameTextField.text !== "" && (beginnerRadioButton.checked || advancedRadioButton.checked)
- iconSource: "dialog-ok"
+ iconName: "dialog-ok"
onClicked: done()
}
}
diff --git a/src/qml/ProfileSelector.qml b/src/qml/ProfileSelector.qml
index a1bc904..f6f78e9 100644
--- a/src/qml/ProfileSelector.qml
+++ b/src/qml/ProfileSelector.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
FocusScope {
@@ -35,70 +36,61 @@ FocusScope {
profileForm.profile = profileDataAccess.profile(index)
}
- Column {
+ ColumnLayout {
anchors.fill: parent
+ anchors.bottomMargin: 10
spacing: 10
- Row {
- height: parent.height - selectButton.height - parent.spacing
- width: parent.width
+ RowLayout {
+ Layout.fillWidth: true
+ Layout.fillHeight: true
spacing: 10
Item {
id: listContainer
- height: parent.height
- width: Math.round((parent.width - parent.spacing) / 2)
+ Layout.fillWidth: true
+ Layout.fillHeight: true
- ListView {
- id: list
+ ScrollView {
anchors.fill: parent
- model: profileDataAccess.profileCount + 1
- clip: true
- delegate: ListItem {
- property bool isNewButton: index >= profileDataAccess.profileCount
- width: list.width - scrollBar.width
- title: isNewButton?
- i18n("Create New Profile"):
- index < profileDataAccess.profileCount? profileDataAccess.profile(index).name: null
- label.font.italic: isNewButton
- iconSource: isNewButton? "list-add": "user-identity"
- onClicked: {
- list.currentIndex = index
- if (isNewButton) {
- createNewProfile()
+ ListView {
+ id: list
+ anchors.fill: parent
+ anchors.margins: 3
+ spacing: 3
+ model: profileDataAccess.profileCount + 1
+ clip: true
+ delegate: ListItem {
+ property bool isNewButton: index >= profileDataAccess.profileCount
+ width: list.width
+ title: isNewButton?
+ i18n("Create New Profile"):
+ index < profileDataAccess.profileCount? profileDataAccess.profile(index).name: null
+ label.font.italic: isNewButton
+ iconSource: isNewButton? "list-add": "user-identity"
+ onClicked: {
+ list.currentIndex = index
+ if (isNewButton) {
+ createNewProfile()
+ }
+ else {
+ selectProfile(index)
+ }
}
- else {
- selectProfile(index)
- }
- }
- onDoubleClicked: {
- if (!isNewButton) {
- root.profileChosen(profileDataAccess.profile(list.currentIndex))
+ onDoubleClicked: {
+ if (!isNewButton) {
+ root.profileChosen(profileDataAccess.profile(list.currentIndex))
+ }
}
}
}
}
-
- PlasmaComponents.ScrollBar {
- id: scrollBar
- flickableItem: list
- }
- }
-
- PlasmaCore.SvgItem {
- id: line
- width: naturalSize.width
- height: parent.height
- elementId: "vertical-line"
- svg: PlasmaCore.Svg {
- imagePath: "widgets/line"
- }
}
ProfileDetailsItem {
id: profileForm
- width: parent.width - listContainer.width - line.width - 2 * parent.spacing
- height: parent.height
+ Layout.fillWidth: true
+ Layout.fillHeight: true
onDeletionRequest: {
var index = profileDataAccess.indexOfProfile(profileForm.profile)
@@ -109,10 +101,10 @@ FocusScope {
}
}
- PlasmaComponents.Button {
+ Button {
id: selectButton
anchors.horizontalCenter: parent.horizontalCenter
- iconSource: "go-next-view"
+ iconName: "go-next-view"
text: i18n("Use Selected Profile")
enabled: list.currentIndex !== -1 && list.currentIndex < profileDataAccess.profileCount
onClicked: root.profileChosen(profileDataAccess.profile(list.currentIndex))
diff --git a/src/qml/ScoreScreen.qml b/src/qml/ScoreScreen.qml
index 8e8ff27..bf66ec9 100644
--- a/src/qml/ScoreScreen.qml
+++ b/src/qml/ScoreScreen.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2016 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
@@ -15,11 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
-import org.kde.qtextracomponents 0.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import org.kde.kquickcontrolsaddons 2.0
import org.kde.charts 0.1 as Charts
FocusScope {
@@ -91,6 +92,11 @@ FocusScope {
}
+ SystemPalette {
+ id: palette
+ colorGroup: SystemPalette.Active
+ }
+
LearningProgressModel {
property bool filterByLesson: false
id: learningProgressModel
@@ -111,26 +117,24 @@ FocusScope {
Column {
id: chartTypeDialogContents
- PlasmaComponents.ToolButton {
+ Button {
id: progressChartButton
- property Item tab: learningProgressTab
- width: Math.max(minimumWidth, errorsChartButton.minimumWidth)
- text: tab.title
- iconSource: tab.iconSource
+ width: Math.max(implicitWidth, errorsChartButton.implicitWidth)
+ text: i18n("Progress")
+ iconName: "office-chart-area"
onClicked: {
- tabGroup.currentTab = tab
chartTypeDialog.close()
+ tabGroup.currentIndex = 0
}
}
- PlasmaComponents.ToolButton {
+ Button {
id: errorsChartButton
- property Item tab: errorsTab
- width: Math.max(minimumWidth, progressChartButton.minimumWidth)
- text: tab.title
- iconSource: tab.iconSource
+ width: Math.max(implicitWidth, progressChartButton.implicitWidth)
+ text: i18n("Errors")
+ iconName: "office-chart-bar"
onClicked: {
- tabGroup.currentTab = tab
chartTypeDialog.close()
+ tabGroup.currentIndex = 1
}
}
}
@@ -143,27 +147,23 @@ FocusScope {
Column {
id: learningProgressDialogContents
- PlasmaComponents.ToolButton {
+ Button {
id: allLessonsButton
width: Math.max(implicitWidth, thisLessonButton.implicitWidth)
text: i18n("All Lessons")
- iconSource: "view-filter"
+ iconName: "view-filter"
onClicked: {
- if (learningProgressModel.filterByLesson) {
- toggleLearningProgressFilterAnimation.restart()
- }
+ learningProgressModel.filterByLesson = false
learningProgressDialog.close()
}
}
- PlasmaComponents.ToolButton {
+ Button {
id: thisLessonButton
width: Math.max(implicitWidth, allLessonsButton.implicitWidth)
text: i18n("This Lesson")
- iconSource: "view-filter"
+ iconName: "view-filter"
onClicked: {
- if (!learningProgressModel.filterByLesson) {
- toggleLearningProgressFilterAnimation.restart()
- }
+ learningProgressModel.filterByLesson = true
learningProgressDialog.close()
}
}
@@ -226,69 +226,45 @@ FocusScope {
}
}
- SequentialAnimation {
- id: toggleLearningProgressFilterAnimation
- NumberAnimation
- {
- target: learningProgressChart
- property: "opacity"
- to: 0
- duration: 250
- easing.type: Easing.InOutQuart
- }
- PropertyAction
- {
- target: learningProgressModel
- property: "filterByLesson"
- value: !learningProgressModel.filterByLesson
- }
- NumberAnimation
- {
- target: learningProgressChart
- property: "opacity"
- to: 1
- duration: 250
- easing.type: Easing.InOutQuart
- }
- }
-
- Column {
+ ColumnLayout {
anchors.fill: parent
- spacing: header.margins.bottom / 2
+ spacing: 0
- PlasmaComponents.ToolBar {
+ ToolBar {
id: header
- width: parent.width
+ Layout.fillWidth: true
- tools: Row {
+ RowLayout {
+ anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10
spacing: anchors.leftMargin
- PlasmaComponents.ToolButton {
+ Button {
id: homeScreenButton
+ anchors.verticalCenter: parent.verticalCenter
text: i18n("Return to Home Screen")
- iconSource: "go-home"
+ iconName: "go-home"
onClicked: screen.homeScreenRequested()
}
Item {
- height: parent.height
- width: parent.width - homeScreenButton.width - repeatLessonButton.width - nextLessonButton.width - (parent.children.length - 1) * parent.spacing
+ Layout.fillHeight: true
+ Layout.fillWidth: true
}
- PlasmaComponents.ToolButton {
+ Button {
id: repeatLessonButton
- iconSource: "view-refresh"
+ iconName: "view-refresh"
text: i18n("Repeat Lesson")
onClicked: screen.lessonRepetionRequested()
}
- PlasmaComponents.ToolButton {
+ Button {
id: nextLessonButton
- iconSource: "go-next-view"
+ iconName: "go-next-view"
text: i18n("Next Lesson")
enabled: !!internal.nextLesson
onClicked: screen.nextLessonRequested(internal.nextLesson)
@@ -297,11 +273,11 @@ FocusScope {
}
Rectangle {
- width: parent.width
- height: parent.height - ((parent.children.length - 1) * parent.spacing) - header.height
- color: theme.backgroundColor
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ color: palette.base
- Column {
+ ColumnLayout {
id: content
anchors.fill: parent
anchors.margins: 20
@@ -309,10 +285,10 @@ FocusScope {
Rectangle {
id: caption
- width: parent.width
- color: "#eee4be"
- height: captionContent.height + 30
+ Layout.fillWidth: true
+ Layout.preferredHeight: captionContent.height + 30
radius: 15
+ color: "#eee4be"
Item {
id: captionContent
@@ -329,23 +305,22 @@ FocusScope {
id: captionIcon
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- icon: QIcon(internal.lessonPassed? "dialog-ok-apply": "dialog-cancel")
+ icon: internal.lessonPassed? "dialog-ok-apply": "dialog-cancel"
width: height
height: captionLabel.height
}
- PlasmaComponents.Label {
+ Label {
id: captionLabel
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: internal.lessonPassed?
i18n("Congratulations! You have passed the lesson."):
i18n("You have not passed the lesson.")
- height: paintedHeight
- font.pointSize: 1.5 * theme.defaultFont.pointSize
+ font.pointSize: 1.5 * Qt.font({'family': 'sansserif'}).pointSize
color: "#000000"
}
}
- PlasmaComponents.Label {
+ Label {
id: subCaption
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
@@ -357,7 +332,6 @@ FocusScope {
return i18n("Next lesson unlocked")
return ""
}
- height: paintedHeight
color: "#000000"
}
}
@@ -365,10 +339,10 @@ FocusScope {
Rectangle {
id: statsBox
- width: parent.width
- height: 140
- color: "#cccccc"
+ Layout.fillWidth: true
+ Layout.preferredHeight: 140
radius: 15
+ color: "#cccccc"
StatBox {
anchors.centerIn: parent
@@ -380,30 +354,29 @@ FocusScope {
Item {
id: contentSpacer
- height: 10
- width: parent.width
+ Layout.preferredHeight: 10
+ Layout.fillWidth: true
}
- Row {
+ RowLayout {
id: chartControls
spacing: 5
- width: parent.width
+ Layout.fillWidth: true
- PlasmaComponents.Label {
+ Label {
id: showLabel
color: "#888"
anchors.verticalCenter: parent.verticalCenter
text: i18nc("Show a specific type of statistic", "Show")
- height: paintedHeight
}
- PlasmaComponents.ToolButton {
+ Button {
id: chartTypeButton
anchors.verticalCenter: parent.verticalCenter
text: tabGroup.currentTab.title
- iconSource: tabGroup.currentTab.iconSource
- width: chartTypeDialogContents.width
- checked: chartTypeDialog.status === PlasmaComponents.DialogStatus.Open || chartTypeDialog.status === PlasmaComponents.DialogStatus.Opening
+ iconName: tabGroup.currentTab.iconName
+ Layout.preferredWidth: chartTypeDialogContents.width
+ checked: chartTypeDialog.status === 'open' || chartTypeDialog.status === 'opening'
onClicked: {
if (checked) {
chartTypeDialog.close()
@@ -415,24 +388,23 @@ FocusScope {
}
}
- PlasmaComponents.Label {
+ Label {
id: overLabel
color: "#888"
anchors.verticalCenter: parent.verticalCenter
text: i18nc("Show a statistic over one or more lessons", "Over")
- height: paintedHeight
opacity: tabGroup.currentTab === learningProgressTab? 1: 0
Behavior on opacity {
NumberAnimation {duration: 150}
}
}
- PlasmaComponents.ToolButton {
+ Button {
id: learningProgressFilterButton
anchors.verticalCenter: parent.verticalCenter
text: learningProgressModel.filterByLesson? thisLessonButton.text: allLessonsButton.text
- iconSource: "view-filter"
- checked: learningProgressDialog.status === PlasmaComponents.DialogStatus.Open || learningProgressDialog.status === PlasmaComponents.DialogStatus.Opening
+ iconName: "view-filter"
+ checked: chartTypeDialog.status === 'open' || chartTypeDialog.status === 'opening'
opacity: tabGroup.currentTab === learningProgressTab? 1: 0
onClicked: {
if (checked) {
@@ -448,45 +420,31 @@ FocusScope {
}
Item {
- height: parent.height
- width: parent.width - showLabel.width - chartTypeButton.width - overLabel.width - learningProgressFilterButton.width - accuracyLegend.width - charactersPerMinuteLegend.width - (parent.children.length - 1) * parent.spacing
+ Layout.fillHeight: true
+ Layout.fillWidth: true
}
- Charts.LegendItem {
- id: accuracyLegend
- anchors.verticalCenter: parent.verticalCenter
- dimension: learningProgressChart.accuracy
- opacity: tabGroup.currentTab === learningProgressTab? 1: 0
- Behavior on opacity {
- NumberAnimation {duration: 150}
- }
- }
- Charts.LegendItem {
- id: charactersPerMinuteLegend
- anchors.verticalCenter: parent.verticalCenter
- dimension: learningProgressChart.charactersPerMinute
- opacity: tabGroup.currentTab === learningProgressTab? 1: 0
- Behavior on opacity {
- NumberAnimation {duration: 150}
- }
- }
}
- PlasmaComponents.TabGroup {
+ TabView {
id: tabGroup
- width: parent.width
- height: content.height - caption.height - statsBox.height - contentSpacer.height - chartControls.height - (content.children.length - 1) * content.spacing
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ frameVisible: false
+ tabsVisible: false
+ property Tab currentTab: count > 0 && currentIndex != -1? getTab(currentIndex): null
- PlasmaComponents.Page {
+ Tab {
id: learningProgressTab
- property string title: i18n("Progress")
- property string iconSource: "office-chart-area"
+ title: i18n("Progress")
+ property string iconName: "office-chart-area"
LearningProgressChart {
id: learningProgressChart
anchors.fill: parent
model: learningProgressModel
+ backgroundColor: palette.base
onElemEntered: {
learningProgressPointTooltip.visualParent = elem
@@ -500,17 +458,17 @@ FocusScope {
}
}
- PlasmaComponents.Page {
+ Tab {
id: errorsTab
-
- property string title: i18n("Errors")
- property string iconSource: "office-chart-bar"
+ title: i18n("Errors")
+ property string iconName: "office-chart-bar"
Charts.BarChart{
anchors.fill: parent
model: errorsModel
pitch: 60
textRole: 3 // Qt::ToolTipRole
+ backgroundColor: palette.base
dimensions: [
Charts.Dimension {
diff --git a/src/qml/SelectionGrip.qml b/src/qml/SelectionGrip.qml
index e32ed5d..1ac3808 100644
--- a/src/qml/SelectionGrip.qml
+++ b/src/qml/SelectionGrip.qml
@@ -15,10 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
+import QtQuick 2.4
import ktouch 1.0
-import Effects 1.0
Item {
id: root
@@ -48,10 +46,10 @@ Item {
xLocked = true
var effX = Math.round(x / scaleFactor)
if (horizontalPosition == "left") {
- setKeyGeometry(targetItem.keyIndex, effX, target.top, target.width + target.left - effX, target.height)
+ keyboardLayoutEditor.setKeyGeometry(targetItem.keyIndex, effX, target.top, target.width + target.left - effX, target.height)
}
else {
- setKeyGeometry(targetItem.keyIndex, target.left, target.top, effX - target.left, target.height)
+ keyboardLayoutEditor.setKeyGeometry(targetItem.keyIndex, target.left, target.top, effX - target.left, target.height)
}
xLocked = false
}
@@ -62,10 +60,10 @@ Item {
yLocked = true
var effY = Math.round(y / scaleFactor)
if (verticalPosition == "top") {
- setKeyGeometry(targetItem.keyIndex, target.left, effY, target.width, target.height + target.top - effY)
+ keyboardLayoutEditor.setKeyGeometry(targetItem.keyIndex, target.left, effY, target.width, target.height + target.top - effY)
}
else {
- setKeyGeometry(targetItem.keyIndex, target.left, target.top, target.width, effY - target.top)
+ keyboardLayoutEditor.setKeyGeometry(targetItem.keyIndex, target.left, target.top, target.width, effY - target.top)
}
yLocked = false
}
@@ -74,7 +72,12 @@ Item {
width: 1
height: 1
- PlasmaCore.SvgItem {
+ SystemPalette {
+ id: palette
+ colorGroup: SystemPalette.Active
+ }
+
+ Rectangle {
anchors {
centerIn: parent
verticalCenterOffset: verticalPosition == "top"? -10: 10
@@ -82,16 +85,14 @@ Item {
}
width: 15
height: 15
- svg: PlasmaCore.Svg {
- imagePath: findImage("resizegrip.svgz")
- usingRenderingCache: false
- }
- elementId: "grip"
+ color: palette.highlight
visible: interactive
+
MouseArea {
id: mouseArea
anchors.fill: parent
+ cursorShape: ((horizontalPosition == "left") != (verticalPosition == "top"))? Qt.SizeBDiagCursor: Qt.SizeFDiagCursor
onClicked: {
mouse.accepted = true
}
@@ -109,14 +110,10 @@ Item {
var top = 10 * Math.round(target.top / 10)
var width = 10 * Math.round(target.width / 10)
var height = 10 * Math.round(target.height / 10)
- setKeyGeometry(targetItem.keyIndex, left, top, width, height)
+ keyboardLayoutEditor.setKeyGeometry(targetItem.keyIndex, left, top, width, height)
}
}
}
}
- CursorShapeArea {
- anchors.fill: parent
- cursorShape: ((horizontalPosition == "left") != (verticalPosition == "top"))? Qt.SizeBDiagCursor: Qt.SizeFDiagCursor
- }
}
}
diff --git a/src/qml/SelectionRectangle.qml b/src/qml/SelectionRectangle.qml
index 1be29a2..941289e 100644
--- a/src/qml/SelectionRectangle.qml
+++ b/src/qml/SelectionRectangle.qml
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
import ktouch 1.0
Item
diff --git a/src/qml/SheetDialog.qml b/src/qml/SheetDialog.qml
index c2b3b8c..babfffc 100644
--- a/src/qml/SheetDialog.qml
+++ b/src/qml/SheetDialog.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,20 +16,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
+import ktouch 1.0
Item {
id: root
+ SystemPalette {
+ id: activePalette
+ colorGroup: SystemPalette.Active
+ }
+
property alias content: contentArea.children
property int innerMargin: 20
- signal opended
+ signal opened
signal closed
function open() {
root.state = "open"
- opended()
+ opened()
}
function close() {
@@ -52,7 +60,7 @@ Item {
Rectangle {
id: bg
anchors.fill: parent
- color: theme.backgroundColor
+ color: activePalette.window
opacity: 1.0
Behavior on opacity {
@@ -62,30 +70,16 @@ Item {
}
}
- Item {
+ Rectangle {
id: slider
+ color: activePalette.window
width: parent.width
height: parent.height
- PlasmaCore.FrameSvgItem {
+ Item {
+ id: contentArea
anchors {
fill: parent
- leftMargin: 10
- rightMargin: 10
- bottomMargin: 10
- }
- imagePath: "dialogs/background"
- enabledBorders: PlasmaCore.FrameSvg.LeftBorder + PlasmaCore.FrameSvg.RightBorder + PlasmaCore.FrameSvg.BottomBorder
-
- Item {
- id: contentArea
- anchors {
- fill: parent
- leftMargin: parent.margins.left + innerMargin
- rightMargin: parent.margins.right + innerMargin
- topMargin: parent.margins.top + innerMargin
- bottomMargin: parent.margins.bottom + innerMargin
- }
}
}
}
diff --git a/src/qml/StatBox.qml b/src/qml/StatBox.qml
index e982733..d5277da 100644
--- a/src/qml/StatBox.qml
+++ b/src/qml/StatBox.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,10 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
+import QtQuick.Layouts 1.1
import ktouch 1.0
-Row {
+RowLayout {
property TrainingStats stats
property TrainingStats referenceStats
@@ -27,21 +29,21 @@ Row {
ElapsedTimeMeter {
id: elapsedTimeMeter
- width: Math.floor((parent.width - 2 * parent.spacing) / 3)
+ Layout.fillWidth: true
elapsedTime: stats.elapsedTime
referenceElapsedTime: referenceStats.isValid? referenceStats.elapsedTime: stats.elapsedTime
}
CharactersPerMinuteMeter {
id: charactersPerMinuteMeter
- width: elapsedTimeMeter.width
+ Layout.fillWidth: true
charactersPerMinute: stats.charactersPerMinute
referenceCharactersPerMinute: referenceStats.isValid? referenceStats.charactersPerMinute: stats.charactersPerMinute
}
AccuracyMeter {
id: accuracyMeter
- width: parent.width - 2 * (elapsedTimeMeter.width + parent.spacing)
+ Layout.fillWidth: true
accuracy: stats.accuracy
referenceAccuracy: referenceStats.isValid? referenceStats.accuracy: stats.accuracy
}
diff --git a/src/qml/TrainingScreen.qml b/src/qml/TrainingScreen.qml
index 8628dee..69b1a14 100644
--- a/src/qml/TrainingScreen.qml
+++ b/src/qml/TrainingScreen.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,8 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
+import QtQuick 2.5
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
FocusScope {
@@ -54,7 +56,7 @@ FocusScope {
keyItems[i].enabled = false;
for (var j = 0; j < key.keyCharCount; j++) {
var keyChar = key.keyChar(j)
- if (chars.indexOf(String.fromCharCode(keyChar.value)) != -1) {
+ if (chars.indexOf(keyChar.value) != -1) {
keyItems[i].enabled = true;
if (keyChar.modifier !== "") {
usedModifiers[keyChar.modifier] = true
@@ -110,8 +112,9 @@ FocusScope {
TrainingStats {
id: stats
onTimeIsRunningChanged: {
- if (timeIsRunning)
+ if (timeIsRunning) {
screen.trainingStarted = false
+ }
}
}
@@ -119,32 +122,58 @@ FocusScope {
id: referenceStats
}
- PlasmaCore.Svg {
- id: screenSvg
- imagePath: findImage("trainingscreen.svgz")
- usingRenderingCache: false
+ Shortcut {
+ sequence: "Escape"
+ enabled: screen.visible
+ onActivated: {
+ if (menuOverlay.opacity === 0) {
+ menuOverlay.show()
+ }
+ else {
+ menuOverlay.hide()
+ }
+ }
+
}
- Column {
+
+ ColumnLayout {
+ id: screenContent
anchors.fill: parent
+ spacing: 0
+ BorderImage {
+ Layout.fillWidth: true
+ Layout.preferredHeight: 41
+ border {
+ top: 1
+ bottom: 1
+ }
+ cache: false
+ source: utils.findImage("trainingscreen-toolbar.png")
+ horizontalTileMode: BorderImage.Repeat
+ verticalTileMode: BorderImage.Repeat
- TrainingScreenToolbar {
- id: toolbar
- height: 29
- width: parent.width
- trainingStarted: screen.trainingStarted
- trainingFinished: screen.trainingFinished
- stats: stats
- menuOverlayItem: menuOverlay
+ TrainingScreenToolbar {
+ id: toolbar
+ anchors.fill: parent
+ trainingStarted: screen.trainingStarted
+ trainingFinished: screen.trainingFinished
+ stats: stats
+ menuOverlayItem: menuOverlay
+ }
}
- PlasmaCore.SvgItem {
+ BorderImage {
id: header
- svg: screenSvg
- elementId: "header"
- width: parent.width
+ Layout.fillWidth: true
+ Layout.preferredHeight: visible? 130: 0
visible: preferences.showStatistics
- height: visible? 130: 0
+ border {
+ top: 1
+ bottom: 1
+ }
+ source: utils.findImage("trainingscreen-header.png")
+ cache: false
StatBox {
anchors.centerIn: parent
@@ -154,12 +183,17 @@ FocusScope {
}
}
- PlasmaCore.SvgItem {
+
+ BorderImage {
id: body
- width: parent.width
- height: parent.height - toolbar.height - header.height - footer.height
- svg: screenSvg
- elementId: "content"
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ border {
+ top: 1
+ bottom: 1
+ }
+ source: utils.findImage("trainingscreen-viewport.png")
+ cache: false
TrainingWidget {
id: trainingWidget
@@ -179,25 +213,34 @@ FocusScope {
}
}
- PlasmaCore.FrameSvgItem {
+ BorderImage {
anchors.fill: parent
- imagePath: findImage("trainingscreen.svgz")
- prefix: "content-shadow"
+ border {
+ top: 3
+ bottom: 3
+ }
+ source: utils.findImage("trainingscreen-viewport-shadow.png")
+ cache: false
+
}
+
}
- PlasmaCore.SvgItem {
+ BorderImage {
id: footer
- width: parent.width
visible: preferences.showKeyboard
- height: visible?
+ Layout.fillWidth: true
+ Layout.preferredHeight: visible?
screen.keyboardLayout.isValid?
Math.round(Math.min((parent.height - toolbar.height - header.height) / 2, parent.width / keyboard.aspectRatio)):
keyboardUnavailableNotice.height:
0
- svg: screenSvg
- elementId: "footer"
-
+ border {
+ top: 1
+ bottom: 1
+ }
+ source: utils.findImage("trainingscreen-footer.png")
+ cache: false
Keyboard {
id: keyboard
@@ -213,10 +256,9 @@ FocusScope {
key.isHighlighted = true
newHighlightedKeys.push(key)
if (typeof which == "string") {
- var code = which.charCodeAt(0)
for (var i = 0; i < key.key.keyCharCount; i++) {
var keyChar = key.key.keyChar(i)
- if (keyChar.value == code && keyChar.modifier != "") {
+ if (keyChar.value == which && keyChar.modifier != "") {
var modifier = findModifierKeyItem(keyChar.modifier)
if (modifier) {
modifier.isHighlighted = true
@@ -277,12 +319,9 @@ FocusScope {
TrainingScreenMenuOverlay {
id: menuOverlay
+ blurSource: screenContent
anchors.fill: parent
- onVisibleChanged: {
- if (!visible) {
- trainingWidget.forceActiveFocus()
- }
- }
+ onClosed: trainingWidget.forceActiveFocus()
onRestartRequested: screen.restartRequested()
onAbortRequested: screen.abortRequested()
}
diff --git a/src/qml/TrainingScreenMenuOverlay.qml b/src/qml/TrainingScreenMenuOverlay.qml
index 2aaacfb..ae94fa2 100644
--- a/src/qml/TrainingScreenMenuOverlay.qml
+++ b/src/qml/TrainingScreenMenuOverlay.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,26 +16,59 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
+import QtGraphicalEffects 1.0
+import ktouch 1.0
-Item {
+FocusScope {
id: item
+ property alias blurSource: effectSource.sourceItem
+
+ signal closed()
signal restartRequested()
signal abortRequested()
- visible: false
opacity: 0
+ Behavior on opacity {
+ NumberAnimation {
+ duration: 300
+ easing.type: Easing.InOutQuad
+ }
+ }
+
function show() {
- focusScope.forceActiveFocus()
- fadeInAnimation.start()
+ item.opacity = 1
+ resumeButton.forceActiveFocus()
}
function hide() {
- fadeOutAnimation.start()
+ item.opacity = 0
+ closed()
+ }
+
+ ShaderEffectSource {
+ id: effectSource
+ anchors.fill: parent
+ hideSource: false
+ }
+
+ HueSaturation {
+ id: desaturatedBackground
+ source: effectSource
+ anchors.fill: parent
+ lightness: -0.3
+ saturation: -0.5
+ visible: false
+ }
+
+ FastBlur {
+ anchors.fill: parent
+ source: desaturatedBackground
+ radius: 50
}
Rectangle {
@@ -45,58 +79,62 @@ Item {
/* swallow all mouse events */
MouseArea {
anchors.fill: parent
+ enabled: item.opacity > 0
hoverEnabled: true
}
- FocusScope {
- id: focusScope
- anchors.centerIn: parent
- PlasmaCore.FrameSvgItem {
- id: frame
- anchors.centerIn: parent
- imagePath: "widgets/frame"
- prefix: "raised"
- width: column.width + frame.margins.left + frame.margins.right + 30
- height: column.height + frame.margins.top + frame.margins.bottom + 30
-
- }
+ GroupBox {
+ id: groupBox
+ anchors.centerIn: parent
+ width: column.width + 30
+ height: column.height + 30
Column {
id: column
+ focus: true
anchors.centerIn: parent
spacing: 15
width: Math.max(resumeButton.implicitWidth, restartButton.implicitWidth, returnButton.implicitWidth)
- PlasmaComponents.Button {
- focus: true
+ Button {
id: resumeButton
- iconSource: "go-next-view"
+ iconName: "go-next-view"
text: i18n("Resume Training")
width: parent.width
onClicked: hide()
+ KeyNavigation.backtab: returnButton
+ KeyNavigation.tab: restartButton
+ KeyNavigation.down: restartButton
}
- PlasmaComponents.Button {
+ Button {
id: restartButton
- iconSource: "view-refresh"
+ iconName: "view-refresh"
text: i18n("Restart Lesson")
width: parent.width
onClicked: {
restartRequested()
hide()
}
+ KeyNavigation.backtab: resumeButton
+ KeyNavigation.tab: returnButton
+ KeyNavigation.up: resumeButton
+ KeyNavigation.down: returnButton
}
- PlasmaComponents.Button {
+ Button {
id: returnButton
- iconSource: "go-home"
+ iconName: "go-home"
text: i18n("Return to Home Screen")
width: parent.width
onClicked: {
abortRequested()
hide()
}
+ KeyNavigation.backtab: restartButton
+ KeyNavigation.tab: resumeButton
+ KeyNavigation.up: restartButton
}
Keys.onDownPressed: {
@@ -118,36 +156,4 @@ Item {
}
}
}
-
- SequentialAnimation {
- id: fadeInAnimation
- PropertyAction {
- target: item
- property: "visible"
- value: true
- }
- NumberAnimation {
- target: item
- property: "opacity"
- to: 1
- duration: 300
- easing.type: Easing.InOutQuad
- }
- }
-
- SequentialAnimation {
- id: fadeOutAnimation
- NumberAnimation {
- target: item
- property: "opacity"
- to: 0
- duration: 300
- easing.type: Easing.InOutQuad
- }
- PropertyAction {
- target: item
- property: "visible"
- value: false
- }
- }
}
diff --git a/src/qml/TrainingScreenToolbar.qml b/src/qml/TrainingScreenToolbar.qml
index ddfb244..2bf30e5 100644
--- a/src/qml/TrainingScreenToolbar.qml
+++ b/src/qml/TrainingScreenToolbar.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
-import org.kde.plasma.core 0.1 as PlasmaCore
-import org.kde.plasma.components 0.1 as PlasmaComponents
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
@@ -52,12 +53,6 @@ Item {
onTimeIsRunningChanged: setMessage()
}
- PlasmaCore.FrameSvgItem {
- anchors.fill: parent
- imagePath: findImage("trainingscreen.svgz")
- prefix: "toolbar"
- }
-
Row {
anchors {
verticalCenter: parent.verticalCenter
@@ -71,9 +66,9 @@ Item {
spacing: 3
height: menuButton.height
- PlasmaComponents.ToolButton {
+ ToolButton {
id: menuButton
- iconSource: "go-home"
+ iconName: "go-home"
onClicked: item.menuOverlayItem.show()
}
diff --git a/src/qml/TrainingWidget.qml b/src/qml/TrainingWidget.qml
index bbe1258..cfe5605 100644
--- a/src/qml/TrainingWidget.qml
+++ b/src/qml/TrainingWidget.qml
@@ -15,9 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
+import QtQuick.Controls 1.3
import ktouch 1.0
-import org.kde.plasma.components 0.1 as PlasmaComponents
FocusScope {
id: trainingWidget
@@ -41,6 +41,10 @@ FocusScope {
trainingLine.active = true
}
+ function forceActiveFocus() {
+ trainingLine.forceActiveFocus()
+ }
+
Timer {
id: stopTimer
interval: 5000
@@ -49,137 +53,140 @@ FocusScope {
}
}
- Flickable
- {
- id: sheetFlick
+ ScrollView {
anchors.fill: parent
- contentWidth: parent.width
- contentHeight: sheet.height + 60
- clip: true
- flickableDirection: Flickable.VerticalFlick
-
- function currentLineY() {
- var cursorRect = lessonPainter.cursorRectangle
- var y = cursorRect.y + sheet.y + (cursorRect.height / 2)
- return Math.max(Math.min((y - (height / 2)), contentHeight - height), 0)
- }
-
- function scrollToCurrentLine() {
- scrollAnimation.to = currentLineY()
- scrollAnimation.start()
- }
-
- onHeightChanged: {
- contentY = currentLineY()
- }
+ Flickable
+ {
+ id: sheetFlick
+ anchors.fill: parent
+ contentWidth: parent.width
+ contentHeight: sheet.height + 60
+ clip: true
+ flickableDirection: Flickable.VerticalFlick
+
+ function currentLineY() {
+ var cursorRect = lessonPainter.cursorRectangle
+ var y = cursorRect.y + sheet.y + (cursorRect.height / 2)
+ return Math.max(Math.min((y - (height / 2)), contentHeight - height), 0)
+ }
- NumberAnimation {
- target: sheetFlick
- id: scrollAnimation
- duration: 150
- property: "contentY"
- }
+ function scrollToCurrentLine() {
+ scrollAnimation.to = currentLineY()
+ scrollAnimation.start()
+ }
- Rectangle {
- id: sheet
- color: "#fff"
- anchors.centerIn: parent
- width: parent.width - 60
- height: lessonPainter.height
+ onHeightChanged: {
+ contentY = currentLineY()
+ }
- border {
- width: 1
- color: "#000"
+ NumberAnimation {
+ target: sheetFlick
+ id: scrollAnimation
+ duration: 150
+ property: "contentY"
}
- LessonPainter {
- id: lessonPainter
- anchors.centerIn: sheet
- lesson: trainingWidget.lesson
- maximumWidth: parent.width
- trainingLineCore: trainingLine
-
- onDone: {
- trainingLine.active = false
- trainingWidget.finished();
- stats.stopTraining();
+ Rectangle {
+ id: sheet
+ color: "#fff"
+ anchors.centerIn: parent
+ width: parent.width - 60
+ height: lessonPainter.height
+
+ border {
+ width: 1
+ color: "#000"
}
- TrainingLineCore {
- id: trainingLine
- anchors.fill: parent
- focus: true
- trainingStats: stats
- cursorItem: cursor
+ LessonPainter {
+ id: lessonPainter
+ anchors.centerIn: sheet
+ lesson: trainingWidget.lesson
+ maximumWidth: parent.width
+ trainingLineCore: trainingLine
+
+ onDone: {
+ trainingLine.active = false
+ trainingWidget.finished();
+ stats.stopTraining();
+ }
- onFocusChanged: {
- if (!trainingLine.activeFocus) {
- trainingStats.stopTraining()
+ TrainingLineCore {
+ id: trainingLine
+ anchors.fill: parent
+ focus: true
+ trainingStats: stats
+ cursorItem: cursor
+
+ onActiveFocusChanged: {
+ if (!trainingLine.activeFocus) {
+ trainingStats.stopTraining()
+ }
}
- }
- Keys.onPressed: {
- if (!trainingLine.active)
- return
+ Keys.onPressed: {
+ if (!trainingLine.active)
+ return
- cursorAnimation.restart()
- trainingStats.startTraining()
- stopTimer.restart()
+ cursorAnimation.restart()
+ trainingStats.startTraining()
+ stopTimer.restart()
- if (!event.isAutoRepeat) {
- trainingWidget.keyPressed(event)
+ if (!event.isAutoRepeat) {
+ trainingWidget.keyPressed(event)
+ }
}
- }
- Keys.onReleased: {
- if (!trainingLine.active)
- return
+ Keys.onReleased: {
+ if (!trainingLine.active)
+ return
- if (!event.isAutoRepeat) {
- trainingWidget.keyReleased(event)
+ if (!event.isAutoRepeat) {
+ trainingWidget.keyReleased(event)
+ }
}
}
- }
- Rectangle {
- id: cursor
- color: "#000"
- x: Math.floor(lessonPainter.cursorRectangle.x)
- y: lessonPainter.cursorRectangle.y
- width: lessonPainter.cursorRectangle.width
- height: lessonPainter.cursorRectangle.height
-
- onYChanged: sheetFlick.scrollToCurrentLine()
-
- SequentialAnimation {
- id: cursorAnimation
- running: trainingLine.active && trainingLine.activeFocus && Qt.application.active
- loops: Animation.Infinite
- PropertyAction {
- target: cursor
- property: "opacity"
- value: 1
- }
- PauseAnimation {
- duration: 500
- }
- PropertyAction {
- target: cursor
- property: "opacity"
- value: 0
- }
- PauseAnimation {
- duration: 500
+ Rectangle {
+ id: cursor
+ color: "#000"
+ x: Math.floor(lessonPainter.cursorRectangle.x)
+ y: lessonPainter.cursorRectangle.y
+ width: lessonPainter.cursorRectangle.width
+ height: lessonPainter.cursorRectangle.height
+
+ onYChanged: sheetFlick.scrollToCurrentLine()
+
+ SequentialAnimation {
+ id: cursorAnimation
+ running: trainingLine.active && trainingLine.activeFocus && Qt.application.active
+ loops: Animation.Infinite
+ PropertyAction {
+ target: cursor
+ property: "opacity"
+ value: 1
+ }
+ PauseAnimation {
+ duration: 500
+ }
+ PropertyAction {
+ target: cursor
+ property: "opacity"
+ value: 0
+ }
+ PauseAnimation {
+ duration: 500
+ }
}
}
}
}
}
+ }
- MouseArea {
- anchors.fill: parent
- onClicked: trainingLine.forceActiveFocus()
- }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: trainingLine.forceActiveFocus()
}
KeyItem {
@@ -229,9 +236,5 @@ FocusScope {
NumberAnimation { duration: 150 }
}
}
-
- PlasmaComponents.ScrollBar {
- flickableItem: sheetFlick
- }
}
diff --git a/src/qml/main.qml b/src/qml/main.qml
index e326316..a0c29da 100644
--- a/src/qml/main.qml
+++ b/src/qml/main.qml
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Sebastian Gottfried <sebastiangottfried@web.de>
+ * Copyright 2015 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
@@ -15,11 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import QtQuick 1.1
+import QtQuick 2.4
import ktouch 1.0
-Item {
+Rectangle {
+ SystemPalette {
+ id: activePallete
+ colorGroup: SystemPalette.Active
+ }
+
id: main
+ color: activePallete.window
function switchScreen(from, to) {
switchScreenAnimation.from = from
@@ -31,25 +38,23 @@ Item {
id: dataAccess
}
- property DataIndex dataIndex: globalDataIndex
-
QtObject {
id: helper
- property string name: keyboardLayoutName
- property int keyboardLayoutCount: dataIndex.keyboardLayoutCount
- property int courseCount: dataIndex.courseCount
+ property string name: ktouch.keyboardLayoutName
+ property int keyboardLayoutCount: ktouch.globalDataIndex.keyboardLayoutCount
+ property int courseCount: ktouch.globalDataIndex.courseCount
onNameChanged: {
keyboardLayout.update()
}
onKeyboardLayoutCountChanged: {
- if (dataIndex.isValid)
+ if (ktouch.globalDataIndex.isValid)
keyboardLayout.update()
}
}
ResourceModel {
id: resourceModel
- dataIndex: main.dataIndex
+ dataIndex: ktouch.globalDataIndex
}
ProfileDataAccess {
@@ -64,20 +69,20 @@ Item {
id: keyboardLayout
Component.onCompleted: {
- if (dataIndex.isValid) {
+ if (ktouch.globalDataIndex.isValid) {
keyboardLayout.update()
}
}
function update() {
isValid = false
- var name = keyboardLayoutName;
+ var name = ktouch.keyboardLayoutName;
// first pass - exact match
- for (var i = 0; i < dataIndex.keyboardLayoutCount; i++)
+ for (var i = 0; i < ktouch.globalDataIndex.keyboardLayoutCount; i++)
{
- var dataIndexLayout = dataIndex.keyboardLayout(i)
+ var dataIndexLayout = ktouch.globalDataIndex.keyboardLayout(i)
if (dataIndexLayout.name === name) {
dataAccess.loadKeyboardLayout(dataIndexLayout, keyboardLayout)
@@ -87,9 +92,9 @@ Item {
// second pass - substring match
- for (var i = 0; i < dataIndex.keyboardLayoutCount; i++)
+ for (var i = 0; i < ktouch.globalDataIndex.keyboardLayoutCount; i++)
{
- var dataIndexLayout = dataIndex.keyboardLayout(i)
+ var dataIndexLayout = ktouch.globalDataIndex.keyboardLayout(i)
if (name.search(dataIndexLayout.name) === 0) {
dataAccess.loadKeyboardLayout(dataIndexLayout, keyboardLayout)
@@ -103,12 +108,16 @@ Item {
id: availableCourseModel
resourceModel: resourceModel
resourceTypeFilter: ResourceModel.CourseItem
- keyboardLayoutNameFilter: keyboardLayout.isValid? keyboardLayout.name: keyboardLayoutName
+ keyboardLayoutNameFilter: keyboardLayout.isValid? keyboardLayout.name: ktouch.keyboardLayoutName
}
- ApplicationBackground {
- id: background
- anchors.fill: parent
+ Course {
+ id: selectedCourse
+ property Lesson selectedLesson
+ }
+
+ Lesson {
+ id: customLessonCopy
}
HomeScreen {
@@ -121,7 +130,6 @@ Item {
focus: true
onLessonSelected: {
trainingScreen.profile = profile
- scoreScreen.profile = profile
var lessonIndex = -1;
for (var i = 0; i < course.lessonCount; i++) {
if (lesson === course.lesson(i)) {
@@ -147,15 +155,6 @@ Item {
}
}
- Course {
- id: selectedCourse
- property Lesson selectedLesson
- }
-
- Lesson {
- id: customLessonCopy
- }
-
TrainingScreen {
id: trainingScreen
anchors.fill: parent
@@ -175,6 +174,7 @@ Item {
course: trainingScreen.course
lesson: trainingScreen.lesson
stats: trainingScreen.stats
+ profile: trainingScreen.profile
referenceStats: trainingScreen.referenceStats
onHomeScreenRequested: main.switchScreen(scoreScreen, homeScreen)
onLessonRepetionRequested: main.switchScreen(scoreScreen, trainingScreen)
diff --git a/src/ui/customlessoneditordialog.ui b/src/ui/customlessoneditordialog.ui
new file mode 100644
index 0000000..204b255
--- /dev/null
+++ b/src/ui/customlessoneditordialog.ui
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CustomLessonEditorDialog</class>
+ <widget class="QDialog" name="CustomLessonEditorDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>601</width>
+ <height>400</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="m_titleLabel">
+ <property name="text">
+ <string>Title:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KLineEdit" name="m_titleLineEdit"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="m_verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>13</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="LessonTextEditor" name="m_lessonTextEditor" native="true"/>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="m_buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>klineedit.h</header>
+ </customwidget>
+ <customwidget>
+ <class>LessonTextEditor</class>
+ <extends>QWidget</extends>
+ <header>editor/lessontexteditor.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>m_buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>CustomLessonEditorDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>m_buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>CustomLessonEditorDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/ui/keyboardlayouteditor.ui b/src/ui/keyboardlayouteditor.ui
index d9ab3dc..1854ff8 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>
@@ -241,38 +220,5 @@
<tabstop>m_zoomInToolButton</tabstop>
</tabstops>
<resources/>
- <connections>
- <connection>
- <sender>m_zoomOutToolButton</sender>
- <signal>clicked()</signal>
- <receiver>m_zoomSlider</receiver>
- <slot>subtractStep()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>307</x>
- <y>28</y>
- </hint>
- <hint type="destinationlabel">
- <x>354</x>
- <y>26</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>m_zoomInToolButton</sender>
- <signal>clicked()</signal>
- <receiver>m_zoomSlider</receiver>
- <slot>addStep()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>470</x>
- <y>30</y>
- </hint>
- <hint type="destinationlabel">
- <x>411</x>
- <y>27</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
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>
diff --git a/src/x11_helper.cpp b/src/x11_helper.cpp
index 196988f..9e90136 100644
--- a/src/x11_helper.cpp
+++ b/src/x11_helper.cpp
@@ -18,26 +18,35 @@
#include "x11_helper.h"
-#include <kapplication.h>
-#include <kdebug.h>
+#define explicit explicit_is_keyword_in_cpp
+#include <xcb/xkb.h>
+#undef explicit
-#include <QtGui/QX11Info>
+
+#include <QX11Info>
+#include <QCoreApplication>
+#include <QDebug>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBrules.h>
+#include <xcb/xcb.h>
#include <fixx11h.h>
-
// more information about the limit https://bugs.freedesktop.org/show_bug.cgi?id=19501
-int X11Helper::MAX_GROUP_COUNT = 4;
-const char* X11Helper::LEFT_VARIANT_STR = "(";
-const char* X11Helper::RIGHT_VARIANT_STR = ")";
+const int X11Helper::MAX_GROUP_COUNT = 4;
+const int X11Helper::ARTIFICIAL_GROUP_LIMIT_COUNT = 8;
+
+const char X11Helper::LEFT_VARIANT_STR[] = "(";
+const char X11Helper::RIGHT_VARIANT_STR[] = ")";
bool X11Helper::xkbSupported(int* xkbOpcode)
{
+ if (!QX11Info::isPlatformX11()) {
+ return false;
+ }
// Verify the Xlib has matching XKB extension.
int major = XkbMajorVersion;
@@ -45,7 +54,7 @@ bool X11Helper::xkbSupported(int* xkbOpcode)
if (!XkbLibraryVersion(&major, &minor))
{
- kWarning() << "Xlib XKB extension " << major << '.' << minor <<
+ qWarning() << "Xlib XKB extension " << major << '.' << minor <<
" != " << XkbMajorVersion << '.' << XkbMinorVersion;
return false;
}
@@ -56,13 +65,13 @@ bool X11Helper::xkbSupported(int* xkbOpcode)
int error_rtrn;
int xkb_opcode;
if( ! XkbQueryExtension(QX11Info::display(), &opcode_rtrn, &xkb_opcode, &error_rtrn, &major, &minor)) {
- kWarning() << "X server XKB extension " << major << '.' << minor <<
+ qWarning() << "X server XKB extension " << major << '.' << minor <<
" != " << XkbMajorVersion << '.' << XkbMinorVersion;
return false;
}
if( xkbOpcode != NULL ) {
- *xkbOpcode = xkb_opcode;
+ *xkbOpcode = xkb_opcode;
}
return true;
@@ -70,79 +79,82 @@ bool X11Helper::xkbSupported(int* xkbOpcode)
void X11Helper::switchToNextLayout()
{
- int size = getLayoutsList().size(); //TODO: could optimize a bit as we don't need the layouts - just count
- int group = (X11Helper::getGroup() + 1) % size;
- X11Helper::setGroup(group);
+ int size = getLayoutsList().size(); //TODO: could optimize a bit as we don't need the layouts - just count
+ int group = (X11Helper::getGroup() + 1) % size;
+ X11Helper::setGroup(group);
}
void X11Helper::scrollLayouts(int delta)
{
- int size = getLayoutsList().size(); //TODO: could optimize a bit as we don't need the layouts - just count
- int group = X11Helper::getGroup() + delta;
- group = group < 0 ? size - ((-group) % size) : group % size;
+ int size = getLayoutsList().size(); //TODO: could optimize a bit as we don't need the layouts - just count
+ int group = X11Helper::getGroup() + delta;
+ group = group < 0 ? size - ((-group) % size) : group % size;
- X11Helper::setGroup(group);
+ X11Helper::setGroup(group);
}
QStringList X11Helper::getLayoutsListAsString(const QList<LayoutUnit>& layoutsList)
{
- QStringList stringList;
- foreach(const LayoutUnit& layoutUnit, layoutsList) {
- stringList << layoutUnit.toString();
- }
- return stringList;
+ QStringList stringList;
+ foreach(const LayoutUnit& layoutUnit, layoutsList) {
+ stringList << layoutUnit.toString();
+ }
+ return stringList;
}
bool X11Helper::setLayout(const LayoutUnit& layout)
{
- QList<LayoutUnit> currentLayouts = getLayoutsList();
- int idx = currentLayouts.indexOf(layout);
- if( idx == -1 || idx >= X11Helper::MAX_GROUP_COUNT ) {
- kWarning() << "Layout" << layout.toString() << "is not found in current layout list"
- << getLayoutsListAsString(currentLayouts);
- return false;
- }
-
- return X11Helper::setGroup((unsigned int)idx);
+ QList<LayoutUnit> currentLayouts = getLayoutsList();
+ int idx = currentLayouts.indexOf(layout);
+ if( idx == -1 || idx >= X11Helper::MAX_GROUP_COUNT ) {
+ qWarning() << "Layout" << layout.toString() << "is not found in current layout list"
+ << getLayoutsListAsString(currentLayouts);
+ return false;
+ }
+
+ return X11Helper::setGroup((unsigned int)idx);
}
bool X11Helper::setDefaultLayout() {
- return X11Helper::setGroup(0);
+ return X11Helper::setGroup(0);
}
bool X11Helper::isDefaultLayout() {
- return X11Helper::getGroup() == 0;
+ return X11Helper::getGroup() == 0;
}
LayoutUnit X11Helper::getCurrentLayout()
{
- QList<LayoutUnit> currentLayouts = getLayoutsList();
- unsigned int group = X11Helper::getGroup();
- if( group < (unsigned int)currentLayouts.size() )
- return currentLayouts[group];
-
- kWarning() << "Current group number" << group << "is outside of current layout list" <<
- getLayoutsListAsString(currentLayouts);
- return LayoutUnit();
+ if (!QX11Info::isPlatformX11()) {
+ return LayoutUnit();
+ }
+ QList<LayoutUnit> currentLayouts = getLayoutsList();
+ unsigned int group = X11Helper::getGroup();
+ if( group < (unsigned int)currentLayouts.size() )
+ return currentLayouts[group];
+
+ qWarning() << "Current group number" << group << "is outside of current layout list" <<
+ getLayoutsListAsString(currentLayouts);
+ return LayoutUnit();
}
LayoutSet X11Helper::getCurrentLayouts()
{
- LayoutSet layoutSet;
+ LayoutSet layoutSet;
- QList<LayoutUnit> currentLayouts = getLayoutsList();
- layoutSet.layouts = currentLayouts;
+ QList<LayoutUnit> currentLayouts = getLayoutsList();
+ layoutSet.layouts = currentLayouts;
- unsigned int group = X11Helper::getGroup();
- if( group < (unsigned int)currentLayouts.size() ) {
- layoutSet.currentLayout = currentLayouts[group];
- }
- else {
- kWarning() << "Current group number" << group << "is outside of current layout list" << getLayoutsListAsString(currentLayouts);
- layoutSet.currentLayout = LayoutUnit();
- }
+ unsigned int group = X11Helper::getGroup();
+ if( group < (unsigned int)currentLayouts.size() ) {
+ layoutSet.currentLayout = currentLayouts[group];
+ }
+ else {
+ qWarning() << "Current group number" << group << "is outside of current layout list" << getLayoutsListAsString(currentLayouts);
+ layoutSet.currentLayout = LayoutUnit();
+ }
- return layoutSet;
+ return layoutSet;
}
@@ -155,246 +167,285 @@ LayoutSet X11Helper::getCurrentLayouts()
QList<LayoutUnit> X11Helper::getLayoutsList()
{
- XkbConfig xkbConfig;
- QList<LayoutUnit> layouts;
- if( X11Helper::getGroupNames(QX11Info::display(), &xkbConfig, X11Helper::LAYOUTS_ONLY) ) {
- for(int i=0; i<xkbConfig.layouts.size(); i++) {
- QString layout(xkbConfig.layouts[i]);
- QString variant;
- if( i<xkbConfig.variants.size() && ! xkbConfig.variants[i].isEmpty() ) {
- variant = xkbConfig.variants[i];
- }
- layouts << LayoutUnit(layout, variant);
- }
- // if there are layouts with same map name add numbers to display name
+ if (!QX11Info::isPlatformX11()) {
+ return QList<LayoutUnit>();
+ }
+ XkbConfig xkbConfig;
+ QList<LayoutUnit> layouts;
+ if( X11Helper::getGroupNames(QX11Info::display(), &xkbConfig, X11Helper::LAYOUTS_ONLY) ) {
+ for(int i=0; i<xkbConfig.layouts.size(); i++) {
+ QString layout(xkbConfig.layouts[i]);
+ QString variant;
+ if( i<xkbConfig.variants.size() && ! xkbConfig.variants[i].isEmpty() ) {
+ variant = xkbConfig.variants[i];
+ }
+ layouts << LayoutUnit(layout, variant);
+ }
+ // if there are layouts with same map name add numbers to display name
// for(int i=0; i<layouts.length(); i++) {
// int n=1;
// for(int j=i+1; j<layouts.length(); j++) {
// if( layouts[i].layout == layouts[j].layout && layouts[i].getRawDisplayName().isEmpty() ) {
// layouts[i].setDisplayName( addNum(layouts[i].layout, 1) );
// layouts[j].setDisplayName( addNum(layouts[j].layout, ++n) );
-// qDebug() << "Adding" << 1 << "to" << layouts[i].toString();
-// qDebug() << "Adding" << n << "to" << layouts[j].toString();
+// qCDebug(KCM_KEYBOARD) << "Adding" << 1 << "to" << layouts[i].toString();
+// qCDebug(KCM_KEYBOARD) << "Adding" << n << "to" << layouts[j].toString();
// }
// }
// }
- }
- else {
- kWarning() << "Failed to get layout groups from X server";
- }
- return layouts;
+ }
+ else {
+ qWarning() << "Failed to get layout groups from X server";
+ }
+ return layouts;
}
bool X11Helper::setGroup(unsigned int group)
{
- return XkbLockGroup(QX11Info::display(), XkbUseCoreKbd, group);
+ qDebug() << group;
+ xcb_void_cookie_t cookie;
+ cookie = xcb_xkb_latch_lock_state(QX11Info::connection(),
+ XCB_XKB_ID_USE_CORE_KBD,
+ 0, 0,
+ 1,
+ group,
+ 0, 0, 0
+ );
+ xcb_generic_error_t *error = 0;
+ error = xcb_request_check(QX11Info::connection(), cookie);
+ if (error) {
+ qDebug() << "Couldn't change the group" << error->error_code;
+ return false;
+ }
+
+ return true;
}
unsigned int X11Helper::getGroup()
{
- XkbStateRec xkbState;
- XkbGetState( QX11Info::display(), XkbUseCoreKbd, &xkbState );
- return xkbState.group;
+ XkbStateRec xkbState;
+ XkbGetState( QX11Info::display(), XkbUseCoreKbd, &xkbState );
+ return xkbState.group;
}
bool X11Helper::getGroupNames(Display* display, XkbConfig* xkbConfig, FetchType fetchType)
{
- static const char* OPTIONS_SEPARATOR = ",";
-
- Atom real_prop_type;
- int fmt;
- unsigned long nitems, extra_bytes;
- char *prop_data = NULL;
- Status ret;
-
- Atom rules_atom = XInternAtom(display, _XKB_RF_NAMES_PROP_ATOM, False);
-
- /* no such atom! */
- if (rules_atom == None) { /* property cannot exist */
- kWarning() << "Failed to fetch layouts from server:" << "could not find the atom" << _XKB_RF_NAMES_PROP_ATOM;
- return false;
- }
-
- ret = XGetWindowProperty(display,
- DefaultRootWindow(display),
- rules_atom, 0L, _XKB_RF_NAMES_PROP_MAXLEN,
- False, XA_STRING, &real_prop_type, &fmt,
- &nitems, &extra_bytes,
- (unsigned char **) (void *) &prop_data);
-
- /* property not found! */
- if (ret != Success) {
- kWarning() << "Failed to fetch layouts from server:" << "Could not get the property";
- return false;
- }
-
- /* has to be array of strings */
- if ((extra_bytes > 0) || (real_prop_type != XA_STRING) || (fmt != 8)) {
- if (prop_data)
- XFree(prop_data);
- kWarning() << "Failed to fetch layouts from server:" << "Wrong property format";
- return false;
- }
-
-// qDebug() << "prop_data:" << nitems << prop_data;
- QStringList names;
- for(char* p=prop_data; p-prop_data < (long)nitems && p != NULL; p += strlen(p)+1) {
- names.append( p );
+ static const char OPTIONS_SEPARATOR[] = ",";
+
+ Atom real_prop_type;
+ int fmt;
+ unsigned long nitems, extra_bytes;
+ char *prop_data = NULL;
+ Status ret;
+
+ Atom rules_atom = XInternAtom(display, _XKB_RF_NAMES_PROP_ATOM, False);
+
+ /* no such atom! */
+ if (rules_atom == None) { /* property cannot exist */
+ qWarning() << "Failed to fetch layouts from server:" << "could not find the atom" << _XKB_RF_NAMES_PROP_ATOM;
+ return false;
+ }
+
+ ret = XGetWindowProperty(display,
+ DefaultRootWindow(display),
+ rules_atom, 0L, _XKB_RF_NAMES_PROP_MAXLEN,
+ False, XA_STRING, &real_prop_type, &fmt,
+ &nitems, &extra_bytes,
+ (unsigned char **) (void *) &prop_data);
+
+ /* property not found! */
+ if (ret != Success) {
+ qWarning() << "Failed to fetch layouts from server:" << "Could not get the property";
+ return false;
+ }
+
+ /* has to be array of strings */
+ if ((extra_bytes > 0) || (real_prop_type != XA_STRING) || (fmt != 8)) {
+ if (prop_data)
+ XFree(prop_data);
+ qWarning() << "Failed to fetch layouts from server:" << "Wrong property format";
+ return false;
+ }
+
+// qCDebug(KCM_KEYBOARD) << "prop_data:" << nitems << prop_data;
+ QStringList names;
+ for(char* p=prop_data; p-prop_data < (long)nitems && p != NULL; p += strlen(p)+1) {
+ names.append( p );
// kDebug() << " " << p;
- }
-
- if( names.count() < 4 ) { //{ rules, model, layouts, variants, options }
- XFree(prop_data);
- return false;
- }
-
- if( fetchType == ALL || fetchType == LAYOUTS_ONLY ) {
- QStringList layouts = names[2].split(OPTIONS_SEPARATOR);
- QStringList variants = names[3].split(OPTIONS_SEPARATOR);
-
- for(int ii=0; ii<layouts.count(); ii++) {
- xkbConfig->layouts << (layouts[ii] != NULL ? layouts[ii] : "");
- xkbConfig->variants << (ii < variants.count() && variants[ii] != NULL ? variants[ii] : "");
- }
-// kDebug() << "Fetched layout groups from X server:"
-// << "\tlayouts:" << xkbConfig->layouts
-// << "\tvariants:" << xkbConfig->variants;
- }
-
- if( fetchType == ALL || fetchType == MODEL_ONLY ) {
- xkbConfig->keyboardModel = (names[1] != NULL ? names[1] : "");
-// kDebug() << "Fetched keyboard model from X server:" << xkbConfig->keyboardModel;
- }
-
- if( fetchType == ALL ) {
- if( names.count() >= 5 ) {
- QString options = (names[4] != NULL ? names[4] : "");
- xkbConfig->options = options.split(OPTIONS_SEPARATOR);
-// kDebug() << "Fetched xkbOptions from X server:" << options;
- }
- }
-
- XFree(prop_data);
- return true;
+ }
+
+ if( names.count() < 4 ) { //{ rules, model, layouts, variants, options }
+ XFree(prop_data);
+ return false;
+ }
+
+ if( fetchType == ALL || fetchType == LAYOUTS_ONLY ) {
+ QStringList layouts = names[2].split(OPTIONS_SEPARATOR);
+ QStringList variants = names[3].split(OPTIONS_SEPARATOR);
+
+ for(int ii=0; ii<layouts.count(); ii++) {
+ xkbConfig->layouts << (layouts[ii] != NULL ? layouts[ii] : QLatin1String(""));
+ xkbConfig->variants << (ii < variants.count() && variants[ii] != NULL ? variants[ii] : QLatin1String(""));
+ }
+ qDebug() << "Fetched layout groups from X server:"
+ << "\tlayouts:" << xkbConfig->layouts
+ << "\tvariants:" << xkbConfig->variants;
+ }
+
+ if( fetchType == ALL || fetchType == MODEL_ONLY ) {
+ xkbConfig->keyboardModel = (names[1] != NULL ? names[1] : QLatin1String(""));
+ qDebug() << "Fetched keyboard model from X server:" << xkbConfig->keyboardModel;
+ }
+
+ if( fetchType == ALL ) {
+ if( names.count() >= 5 ) {
+ QString options = (names[4] != NULL ? names[4] : QLatin1String(""));
+ xkbConfig->options = options.split(OPTIONS_SEPARATOR);
+ qDebug() << "Fetched xkbOptions from X server:" << options;
+ }
+ }
+
+ XFree(prop_data);
+ return true;
}
-XEventNotifier::XEventNotifier(QWidget* parent):
- QWidget(parent),
- xkbOpcode(-1)
+XEventNotifier::XEventNotifier():
+ xkbOpcode(-1)
{
- if( KApplication::kApplication() == NULL ) {
- kWarning() << "Layout Widget won't work properly without KApplication instance";
- }
+ if( QCoreApplication::instance() == NULL ) {
+ qWarning() << "Layout Widget won't work properly without QCoreApplication instance";
+ }
}
void XEventNotifier::start()
{
- if( KApplication::kApplication() != NULL && X11Helper::xkbSupported(&xkbOpcode) ) {
- registerForXkbEvents(QX11Info::display());
+ qDebug() << "qCoreApp" << QCoreApplication::instance();
+ if( QCoreApplication::instance() != NULL && X11Helper::xkbSupported(&xkbOpcode) ) {
+ registerForXkbEvents(QX11Info::display());
- // start the event loop
- KApplication::kApplication()->installX11EventFilter(this);
- }
+ // start the event loop
+ QCoreApplication::instance()->installNativeEventFilter(this);
+ }
}
void XEventNotifier::stop()
{
- if( KApplication::kApplication() != NULL ) {
- //TODO: unregister
- // XEventNotifier::unregisterForXkbEvents(QX11Info::display());
+ if( QCoreApplication::instance() != NULL ) {
+ //TODO: unregister
+ // XEventNotifier::unregisterForXkbEvents(QX11Info::display());
- // stop the event loop
- KApplication::kApplication()->removeX11EventFilter(this);
- }
+ // stop the event loop
+ QCoreApplication::instance()->removeNativeEventFilter(this);
+ }
}
-bool XEventNotifier::isXkbEvent(XEvent* event)
+
+bool XEventNotifier::isXkbEvent(xcb_generic_event_t* event)
{
- return event->type == xkbOpcode;
+// kDebug() << "event response type:" << (event->response_type & ~0x80) << xkbOpcode << ((event->response_type & ~0x80) == xkbOpcode + XkbEventCode);
+ return (event->response_type & ~0x80) == xkbOpcode + XkbEventCode;
}
-bool XEventNotifier::processOtherEvents(XEvent* /*event*/)
+bool XEventNotifier::processOtherEvents(xcb_generic_event_t* /*event*/)
{
- return true;
+ return true;
}
-bool XEventNotifier::processXkbEvents(XEvent* event)
+bool XEventNotifier::processXkbEvents(xcb_generic_event_t* event)
{
- if( XEventNotifier::isGroupSwitchEvent(event) ) {
- emit(layoutChanged());
- }
- else if( XEventNotifier::isLayoutSwitchEvent(event) ) {
- emit(layoutMapChanged());
- }
- return true;
+ _xkb_event *xkbevt = reinterpret_cast<_xkb_event *>(event);
+ if( XEventNotifier::isGroupSwitchEvent(xkbevt) ) {
+// kDebug() << "group switch event";
+ emit(layoutChanged());
+ }
+ else if( XEventNotifier::isLayoutSwitchEvent(xkbevt) ) {
+// kDebug() << "layout switch event";
+ emit(layoutMapChanged());
+ }
+ return true;
}
-bool XEventNotifier::x11Event(XEvent * event)
+bool XEventNotifier::nativeEventFilter(const QByteArray &eventType, void *message, long *)
{
- // qApp->x11ProcessEvent ( event );
- if( isXkbEvent(event) ) {
- processXkbEvents(event);
- }
- else {
- processOtherEvents(event);
- }
- return QWidget::x11Event(event);
+// kDebug() << "event type:" << eventType;
+ if (eventType == "xcb_generic_event_t") {
+ xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message);
+ if( isXkbEvent(ev) ) {
+ processXkbEvents(ev);
+ }
+ else {
+ processOtherEvents(ev);
+ }
+ }
+ return false;
}
-bool XEventNotifier::isGroupSwitchEvent(XEvent* event)
+//bool XEventNotifier::x11Event(XEvent * event)
+//{
+// // qApp->x11ProcessEvent ( event );
+// if( isXkbEvent(event) ) {
+// processXkbEvents(event);
+// }
+// else {
+// processOtherEvents(event);
+// }
+// return QWidget::x11Event(event);
+//}
+
+bool XEventNotifier::isGroupSwitchEvent(_xkb_event* xkbEvent)
{
- XkbEvent *xkbEvent = (XkbEvent*) event;
+// XkbEvent *xkbEvent = (XkbEvent*) event;
#define GROUP_CHANGE_MASK \
( XkbGroupStateMask | XkbGroupBaseMask | XkbGroupLatchMask | XkbGroupLockMask )
- return xkbEvent->any.xkb_type == XkbStateNotify && xkbEvent->state.changed & GROUP_CHANGE_MASK;
+ return xkbEvent->any.xkbType == XkbStateNotify && (xkbEvent->state_notify.changed & GROUP_CHANGE_MASK);
}
-bool XEventNotifier::isLayoutSwitchEvent(XEvent* event)
+bool XEventNotifier::isLayoutSwitchEvent(_xkb_event* xkbEvent)
{
- XkbEvent *xkbEvent = (XkbEvent*) event;
+// XkbEvent *xkbEvent = (XkbEvent*) event;
return //( (xkbEvent->any.xkb_type == XkbMapNotify) && (xkbEvent->map.changed & XkbKeySymsMask) ) ||
/* || ( (xkbEvent->any.xkb_type == XkbNamesNotify) && (xkbEvent->names.changed & XkbGroupNamesMask) || )*/
- (xkbEvent->any.xkb_type == XkbNewKeyboardNotify);
+ (xkbEvent->any.xkbType == XkbNewKeyboardNotify);
}
int XEventNotifier::registerForXkbEvents(Display* display)
{
int eventMask = XkbNewKeyboardNotifyMask | XkbStateNotifyMask;
if( ! XkbSelectEvents(display, XkbUseCoreKbd, eventMask, eventMask) ) {
- kWarning() << "Couldn't select desired XKB events";
- return false;
+ qWarning() << "Couldn't select desired XKB events";
+ return false;
}
return true;
}
-static const char* LAYOUT_VARIANT_SEPARATOR_PREFIX = "(";
-static const char* LAYOUT_VARIANT_SEPARATOR_SUFFIX = ")";
+static const char LAYOUT_VARIANT_SEPARATOR_PREFIX[] = "(";
+static const char LAYOUT_VARIANT_SEPARATOR_SUFFIX[] = ")";
static QString& stripVariantName(QString& variant)
{
- if( variant.endsWith(LAYOUT_VARIANT_SEPARATOR_SUFFIX) ) {
- int suffixLen = strlen(LAYOUT_VARIANT_SEPARATOR_SUFFIX);
- return variant.remove(variant.length()-suffixLen, suffixLen);
- }
- return variant;
+ if( variant.endsWith(LAYOUT_VARIANT_SEPARATOR_SUFFIX) ) {
+ int suffixLen = strlen(LAYOUT_VARIANT_SEPARATOR_SUFFIX);
+ return variant.remove(variant.length()-suffixLen, suffixLen);
+ }
+ return variant;
}
LayoutUnit::LayoutUnit(const QString& fullLayoutName)
{
- QStringList lv = fullLayoutName.split(LAYOUT_VARIANT_SEPARATOR_PREFIX);
- layout = lv[0];
- variant = lv.size() > 1 ? stripVariantName(lv[1]) : "";
+ QStringList lv = fullLayoutName.split(LAYOUT_VARIANT_SEPARATOR_PREFIX);
+ layout = lv[0];
+ variant = lv.size() > 1 ? stripVariantName(lv[1]) : QLatin1String("");
}
QString LayoutUnit::toString() const
{
- if( variant.isEmpty() )
- return layout;
+ if( variant.isEmpty() )
+ return layout;
- return layout + LAYOUT_VARIANT_SEPARATOR_PREFIX+variant+LAYOUT_VARIANT_SEPARATOR_SUFFIX;
+ return layout + LAYOUT_VARIANT_SEPARATOR_PREFIX+variant+LAYOUT_VARIANT_SEPARATOR_SUFFIX;
}
const int LayoutUnit::MAX_LABEL_LENGTH = 3;
diff --git a/src/x11_helper.h b/src/x11_helper.h
index 38f90e9..a2408dd 100644
--- a/src/x11_helper.h
+++ b/src/x11_helper.h
@@ -20,161 +20,236 @@
#ifndef X11_HELPER_H_
#define X11_HELPER_H_
-#include <QtGui/QKeySequence>
-#include <QtCore/QString>
-#include <QtCore/QStringList>
-#include <QtGui/QWidget>
+#include <QKeySequence>
+#include <QString>
+#include <QStringList>
+#include <QWidget>
+#include <QX11Info>
+#include <QAbstractNativeEventFilter>
+#include <xcb/xcb.h>
-class XEventNotifier : public QWidget {
- Q_OBJECT
+namespace
+{
+typedef struct _xcb_xkb_map_notify_event_t {
+ uint8_t response_type;
+ uint8_t xkbType;
+ uint16_t sequence;
+ xcb_timestamp_t time;
+ uint8_t deviceID;
+ uint8_t ptrBtnActions;
+ uint16_t changed;
+ xcb_keycode_t minKeyCode;
+ xcb_keycode_t maxKeyCode;
+ uint8_t firstType;
+ uint8_t nTypes;
+ xcb_keycode_t firstKeySym;
+ uint8_t nKeySyms;
+ xcb_keycode_t firstKeyAct;
+ uint8_t nKeyActs;
+ xcb_keycode_t firstKeyBehavior;
+ uint8_t nKeyBehavior;
+ xcb_keycode_t firstKeyExplicit;
+ uint8_t nKeyExplicit;
+ xcb_keycode_t firstModMapKey;
+ uint8_t nModMapKeys;
+ xcb_keycode_t firstVModMapKey;
+ uint8_t nVModMapKeys;
+ uint16_t virtualMods;
+ uint8_t pad0[2];
+} _xcb_xkb_map_notify_event_t;
+typedef struct _xcb_xkb_state_notify_event_t {
+ uint8_t response_type;
+ uint8_t xkbType;
+ uint16_t sequence;
+ xcb_timestamp_t time;
+ uint8_t deviceID;
+ uint8_t mods;
+ uint8_t baseMods;
+ uint8_t latchedMods;
+ uint8_t lockedMods;
+ uint8_t group;
+ int16_t baseGroup;
+ int16_t latchedGroup;
+ uint8_t lockedGroup;
+ uint8_t compatState;
+ uint8_t grabMods;
+ uint8_t compatGrabMods;
+ uint8_t lookupMods;
+ uint8_t compatLoockupMods;
+ uint16_t ptrBtnState;
+ uint16_t changed;
+ xcb_keycode_t keycode;
+ uint8_t eventType;
+ uint8_t requestMajor;
+ uint8_t requestMinor;
+} _xcb_xkb_state_notify_event_t;
+typedef union {
+ /* All XKB events share these fields. */
+ struct {
+ uint8_t response_type;
+ uint8_t xkbType;
+ uint16_t sequence;
+ xcb_timestamp_t time;
+ uint8_t deviceID;
+ } any;
+ _xcb_xkb_map_notify_event_t map_notify;
+ _xcb_xkb_state_notify_event_t state_notify;
+} _xkb_event;
+}
+
+class XEventNotifier : public QObject, public QAbstractNativeEventFilter {
+ Q_OBJECT
Q_SIGNALS:
- void layoutChanged();
- void layoutMapChanged();
+ void layoutChanged();
+ void layoutMapChanged();
public:
- explicit XEventNotifier(QWidget* parent=NULL);
- virtual ~XEventNotifier() {}
+ XEventNotifier();
+ virtual ~XEventNotifier() {}
- virtual void start();
- virtual void stop();
+ virtual void start();
+ virtual void stop();
protected:
- bool x11Event(XEvent * e);
- virtual bool processOtherEvents(XEvent* e);
- virtual bool processXkbEvents(XEvent* e);
+// bool x11Event(XEvent * e);
+ virtual bool processOtherEvents(xcb_generic_event_t* e);
+ virtual bool processXkbEvents(xcb_generic_event_t* e);
+ virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE;
private:
- int registerForXkbEvents(Display* display);
- bool isXkbEvent(XEvent* event);
- bool isGroupSwitchEvent(XEvent* event);
- bool isLayoutSwitchEvent(XEvent* event);
+ int registerForXkbEvents(Display* display);
+ bool isXkbEvent(xcb_generic_event_t* event);
+ bool isGroupSwitchEvent(_xkb_event* event);
+ bool isLayoutSwitchEvent(_xkb_event* event);
- int xkbOpcode;
+ int xkbOpcode;
};
struct XkbConfig {
- QString keyboardModel;
- QStringList layouts;
- QStringList variants;
- QStringList options;
+ QString keyboardModel;
+ QStringList layouts;
+ QStringList variants;
+ QStringList options;
- bool isValid() { return ! layouts.empty(); }
+ bool isValid() { return ! layouts.empty(); }
};
struct LayoutUnit {
- static const int MAX_LABEL_LENGTH;
-
- //TODO: move these to private?
- QString layout;
- QString variant;
-
- LayoutUnit() {}
- explicit LayoutUnit(const QString& fullLayoutName);
- LayoutUnit(const QString& layout_, const QString& variant_) {
- layout = layout_;
- variant = variant_;
- }
- /*explicit*/ LayoutUnit(const LayoutUnit& layoutUnit) {
- layout = layoutUnit.layout;
- variant = layoutUnit.variant;
- displayName = layoutUnit.displayName;
- shortcut = layoutUnit.shortcut;
- }
-
- QString getRawDisplayName() const { return displayName; }
- QString getDisplayName() const { return !displayName.isEmpty() ? displayName : layout; }
- void setDisplayName(const QString& name) { displayName = name; }
-
- void setShortcut(const QKeySequence& shortcut) { this->shortcut = shortcut; }
- QKeySequence getShortcut() const { return shortcut; }
-
- bool isEmpty() const { return layout.isEmpty(); }
- bool isValid() const { return ! isEmpty(); }
- bool operator==(const LayoutUnit& layoutItem) const {
- return layout==layoutItem.layout && variant==layoutItem.variant;
- }
- bool operator!=(const LayoutUnit& layoutItem) const {
- return ! (*this == layoutItem);
- }
- QString toString() const;
+ static const int MAX_LABEL_LENGTH;
+
+ //TODO: move these to private?
+ QString layout;
+ QString variant;
+
+ LayoutUnit() {}
+ explicit LayoutUnit(const QString& fullLayoutName);
+ LayoutUnit(const QString& layout_, const QString& variant_) {
+ layout = layout_;
+ variant = variant_;
+ }
+ /*explicit*/ LayoutUnit(const LayoutUnit& layoutUnit) {
+ layout = layoutUnit.layout;
+ variant = layoutUnit.variant;
+ displayName = layoutUnit.displayName;
+ shortcut = layoutUnit.shortcut;
+ }
+
+ QString getRawDisplayName() const { return displayName; }
+ QString getDisplayName() const { return !displayName.isEmpty() ? displayName : layout; }
+ void setDisplayName(const QString& name) { displayName = name; }
+
+ void setShortcut(const QKeySequence& shortcut) { this->shortcut = shortcut; }
+ QKeySequence getShortcut() const { return shortcut; }
+
+ bool isEmpty() const { return layout.isEmpty(); }
+ bool isValid() const { return ! isEmpty(); }
+ bool operator==(const LayoutUnit& layoutItem) const {
+ return layout==layoutItem.layout && variant==layoutItem.variant;
+ }
+ bool operator!=(const LayoutUnit& layoutItem) const {
+ return ! (*this == layoutItem);
+ }
+ QString toString() const;
private:
- QString displayName;
- QKeySequence shortcut;
+ QString displayName;
+ QKeySequence shortcut;
};
struct LayoutSet {
- QList<LayoutUnit> layouts;
- LayoutUnit currentLayout;
-
- LayoutSet() {}
-
- LayoutSet(const LayoutSet& currentLayouts) {
- this->layouts = currentLayouts.layouts;
- this->currentLayout = currentLayouts.currentLayout;
- }
-
- bool isValid() const {
- return currentLayout.isValid() && layouts.contains(currentLayout);
- }
-
- bool operator == (const LayoutSet& currentLayouts) const {
- return this->layouts == currentLayouts.layouts
- && this->currentLayout == currentLayouts.currentLayout;
- }
-
- LayoutSet& operator = (const LayoutSet& currentLayouts) {
- this->layouts = currentLayouts.layouts;
- this->currentLayout = currentLayouts.currentLayout;
- return *this;
- }
-
- QString toString() const {
- QString str(currentLayout.toString());
- str += ": ";
- foreach(const LayoutUnit& layoutUnit, layouts) {
- str += layoutUnit.toString() + " ";
- }
- return str;
- }
-
- static QString toString(const QList<LayoutUnit>& layoutUnits) {
- QString str;
- foreach(const LayoutUnit& layoutUnit, layoutUnits) {
- str += layoutUnit.toString() + ",";
- }
- return str;
- }
+ QList<LayoutUnit> layouts;
+ LayoutUnit currentLayout;
+
+ LayoutSet() {}
+
+ LayoutSet(const LayoutSet& currentLayouts) {
+ this->layouts = currentLayouts.layouts;
+ this->currentLayout = currentLayouts.currentLayout;
+ }
+
+ bool isValid() const {
+ return currentLayout.isValid() && layouts.contains(currentLayout);
+ }
+
+ bool operator == (const LayoutSet& currentLayouts) const {
+ return this->layouts == currentLayouts.layouts
+ && this->currentLayout == currentLayouts.currentLayout;
+ }
+
+ LayoutSet& operator = (const LayoutSet& currentLayouts) {
+ this->layouts = currentLayouts.layouts;
+ this->currentLayout = currentLayouts.currentLayout;
+ return *this;
+ }
+
+ QString toString() const {
+ QString str(currentLayout.toString());
+ str += QLatin1String(": ");
+ foreach(const LayoutUnit& layoutUnit, layouts) {
+ str += layoutUnit.toString() + " ";
+ }
+ return str;
+ }
+
+ static QString toString(const QList<LayoutUnit>& layoutUnits) {
+ QString str;
+ foreach(const LayoutUnit& layoutUnit, layoutUnits) {
+ str += layoutUnit.toString() + ",";
+ }
+ return str;
+ }
};
class X11Helper
{
public:
- static int MAX_GROUP_COUNT;
- static const char* LEFT_VARIANT_STR;
- static const char* RIGHT_VARIANT_STR;
+ static const int MAX_GROUP_COUNT;
+ static const int ARTIFICIAL_GROUP_LIMIT_COUNT;
+
+ static const char LEFT_VARIANT_STR[];
+ static const char RIGHT_VARIANT_STR[];
- static bool xkbSupported(int* xkbOpcode);
+ static bool xkbSupported(int* xkbOpcode);
- static void switchToNextLayout();
- static void scrollLayouts(int delta);
- static bool isDefaultLayout();
- static bool setDefaultLayout();
- static bool setLayout(const LayoutUnit& layout);
- static LayoutUnit getCurrentLayout();
- static LayoutSet getCurrentLayouts();
- static QList<LayoutUnit> getLayoutsList();
- static QStringList getLayoutsListAsString(const QList<LayoutUnit>& layoutsList);
+ static void switchToNextLayout();
+ static void scrollLayouts(int delta);
+ static bool isDefaultLayout();
+ static bool setDefaultLayout();
+ static bool setLayout(const LayoutUnit& layout);
+ static LayoutUnit getCurrentLayout();
+ static LayoutSet getCurrentLayouts();
+ static QList<LayoutUnit> getLayoutsList();
+ static QStringList getLayoutsListAsString(const QList<LayoutUnit>& layoutsList);
- enum FetchType { ALL, LAYOUTS_ONLY, MODEL_ONLY };
- static bool getGroupNames(Display* dpy, XkbConfig* xkbConfig, FetchType fetchType);
+ enum FetchType { ALL, LAYOUTS_ONLY, MODEL_ONLY };
+ static bool getGroupNames(Display* dpy, XkbConfig* xkbConfig, FetchType fetchType);
private:
- static unsigned int getGroup();
- static bool setGroup(unsigned int group);
+ static unsigned int getGroup();
+ static bool setGroup(unsigned int group);
};
#endif /* X11_HELPER_H_ */