summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Fedoskin <afedoskin3@gmail.com>2016-10-22 10:23:23 (GMT)
committerArtem Fedoskin <afedoskin3@gmail.com>2016-10-22 10:23:23 (GMT)
commitabce52fc4b7605fb53afad1c03b59c8ff3c0fc9d (patch)
tree158672f36ec24da654f9318c9c48cc22659214bd
parent6f8ef3e2e46f510ebf85f3cb903f6a6deb5a811a (diff)
Added support for dark theme in KStars Lite
-rwxr-xr-xbuild_kstarslite/build-kstarslite.sh3
-rw-r--r--kstars/kstarsdata.cpp6
-rw-r--r--kstars/kstarslite.cpp7
-rw-r--r--kstars/kstarslite.h2
-rw-r--r--kstars/kstarslite/qml/dialogs/FindDialog.qml4
-rw-r--r--kstars/kstarslite/qml/main.qml1
-rw-r--r--kstars/kstarslite/qml/modules/KSButton.qml3
-rw-r--r--kstars/kstarslite/qml/modules/KSListView.qml2
-rw-r--r--kstars/kstarslite/qml/modules/KSTextField.qml9
-rw-r--r--kstars/kstarslite/qml/modules/helpers/TimeSpinBox.qml67
-rw-r--r--kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml29
-rw-r--r--kstars/kstarslite/qml/modules/popups/FOVPopup.qml1
-rw-r--r--kstars/kstarsliteinit.cpp3
13 files changed, 111 insertions, 26 deletions
diff --git a/build_kstarslite/build-kstarslite.sh b/build_kstarslite/build-kstarslite.sh
index bdda32b..3e4ab18 100755
--- a/build_kstarslite/build-kstarslite.sh
+++ b/build_kstarslite/build-kstarslite.sh
@@ -258,12 +258,11 @@ mkdir ${build_dir} -p
rm "${build_dir}/build/CMakeCache.txt"
mkdir "${build_dir}/build" -p
cd "${build_dir}/build"
-make clean
rm -rf "${build_dir}/export"
mkdir "${build_dir}/export" -p
-ccmake "${kstars_DIR}" -DCMAKE_TOOLCHAIN_FILE="${kstars_DIR}/build_kstarslite/android_libs_src/AndroidToolchain.cmake" \
+cmake "${kstars_DIR}" -DCMAKE_TOOLCHAIN_FILE="${kstars_DIR}/build_kstarslite/android_libs_src/AndroidToolchain.cmake" \
-DANDROID_ARCHITECTURE=${ANDROID_ARCHITECTURE} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=${qt_android_libs} \
diff --git a/kstars/kstarsdata.cpp b/kstars/kstarsdata.cpp
index c5a8061..3253873 100644
--- a/kstars/kstarsdata.cpp
+++ b/kstars/kstarsdata.cpp
@@ -174,8 +174,8 @@ bool KStarsData::initialize() {
emit progressText(i18n("Loading sky objects" ) );
m_SkyComposite = new SkyMapComposite(0);
//Load Image URLs//
-//#ifndef Q_OS_ANDROID
- //On Android these 2 calls produce segfault. FIX IT!
+ //#ifndef Q_OS_ANDROID
+ //On Android these 2 calls produce segfault. WARNING
emit progressText( i18n("Loading Image URLs" ) );
if( !readURLData( "image_url.dat", 0 ) && !nonFatalErrorMessage( "image_url.dat" ) )
return false;
@@ -184,7 +184,7 @@ bool KStarsData::initialize() {
emit progressText( i18n("Loading Information URLs" ) );
if( !readURLData( "info_url.dat", 1 ) && !nonFatalErrorMessage( "info_url.dat" ) )
return false;
-//#endif
+ //#endif
emit progressText( i18n("Loading Variable Stars" ) );
//Update supernovae list if enabled
diff --git a/kstars/kstarslite.cpp b/kstars/kstarslite.cpp
index cff418c..f1afcb7 100644
--- a/kstars/kstarslite.cpp
+++ b/kstars/kstarslite.cpp
@@ -156,9 +156,6 @@ KStarsLite::KStarsLite( bool doSplash, bool startClock, const QString &startDate
if( !m_KStarsData->initialize() ) return;
datainitFinished();
- //Set default options
-
-
#if ( __GLIBC__ >= 2 &&__GLIBC_MINOR__ >= 1 && !defined(__UCLIBC__) )
qDebug() << "glibc >= 2.1 detected. Using GNU extension sincos()";
#else
@@ -361,6 +358,10 @@ QColor KStarsLite::getColor(QString schemeColor) {
return KStarsData::Instance()->colorScheme()->colorNamed(schemeColor);
}
+QString KStarsLite::getConfigCScheme() {
+ return Options::colorSchemeFile();
+}
+
void KStarsLite::toggleObjects(ObjectsToToggle toToggle, bool toggle) {
switch(toToggle) {
case ObjectsToToggle::Stars:
diff --git a/kstars/kstarslite.h b/kstars/kstarslite.h
index 9ae6df2..b1ffbf5 100644
--- a/kstars/kstarslite.h
+++ b/kstars/kstarslite.h
@@ -152,6 +152,8 @@ public:
*/
Q_INVOKABLE QColor getColor(QString name);
+ Q_INVOKABLE QString getConfigCScheme();
+
/**
* @short toggles on/off objects of group toToggle
* @see ObjectsToToggle
diff --git a/kstars/kstarslite/qml/dialogs/FindDialog.qml b/kstars/kstarslite/qml/dialogs/FindDialog.qml
index ad83520..9c3c1c3 100644
--- a/kstars/kstarslite/qml/dialogs/FindDialog.qml
+++ b/kstars/kstarslite/qml/dialogs/FindDialog.qml
@@ -100,7 +100,7 @@ KSPage {
}
RowLayout {
- Button {
+ KSButton {
id: searchInInternet
enabled: searchQuery.text.length > 0 && FindDialogLite.isResolveEnabled
@@ -110,7 +110,7 @@ KSPage {
}
}
- Button {
+ KSButton {
text: "Cancel"
onClicked: {
stackView.pop()
diff --git a/kstars/kstarslite/qml/main.qml b/kstars/kstarslite/qml/main.qml
index d6af8ea..38cbc4a 100644
--- a/kstars/kstarslite/qml/main.qml
+++ b/kstars/kstarslite/qml/main.qml
@@ -12,7 +12,6 @@ import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
-import QtQuick.Controls.Universal 2.0
import QtQuick.Window 2.2 as Window
import QtQuick.Layouts 1.1
diff --git a/kstars/kstarslite/qml/modules/KSButton.qml b/kstars/kstarslite/qml/modules/KSButton.qml
index cecdb87..90368f0 100644
--- a/kstars/kstarslite/qml/modules/KSButton.qml
+++ b/kstars/kstarslite/qml/modules/KSButton.qml
@@ -1,7 +1,8 @@
import QtQuick 2.6
import QtQuick.Controls 2.0
import "../constants/" 1.0
+import QtQuick.Controls.Material 2.0
Button {
- id: button
+ id: control
}
diff --git a/kstars/kstarslite/qml/modules/KSListView.qml b/kstars/kstarslite/qml/modules/KSListView.qml
index 6869829..d6a6040 100644
--- a/kstars/kstarslite/qml/modules/KSListView.qml
+++ b/kstars/kstarslite/qml/modules/KSListView.qml
@@ -144,7 +144,7 @@ ListView {
Rectangle {
visible: (checkCurrent && listView.currentIndex == model.index) || (checkable && delegateRect.checked)
- color: num.sysPalette.base //"#2173f3"
+ color: objName.color //"#2173f3"
width: height
height: objName.font.pixelSize/2
radius: width * 0.5
diff --git a/kstars/kstarslite/qml/modules/KSTextField.qml b/kstars/kstarslite/qml/modules/KSTextField.qml
index bfb3795..ab58cb0 100644
--- a/kstars/kstarslite/qml/modules/KSTextField.qml
+++ b/kstars/kstarslite/qml/modules/KSTextField.qml
@@ -3,7 +3,16 @@ import QtQuick.Controls 2.0
import "../constants/" 1.0
TextField {
+ id: control
+
color: num.sysPalette.text
selectedTextColor: num.sysPalette.highlightedText
selectionColor: num.sysPalette.highlight
+
+ background: Rectangle {
+ y: control.height - height - control.bottomPadding / 2
+ implicitWidth: 120
+ height: control.activeFocus ? 2 : 1
+ color: control.activeFocus ? num.sysPalette.text : num.sysPalette.dark
+ }
}
diff --git a/kstars/kstarslite/qml/modules/helpers/TimeSpinBox.qml b/kstars/kstarslite/qml/modules/helpers/TimeSpinBox.qml
index 574a08a..8eef469 100644
--- a/kstars/kstarslite/qml/modules/helpers/TimeSpinBox.qml
+++ b/kstars/kstarslite/qml/modules/helpers/TimeSpinBox.qml
@@ -16,20 +16,75 @@ SpinBox {
id: control
from: -41
to: 41
+ anchors.verticalCenter: parent.verticalCenter
+ editable: false
- contentItem: TextInput {
+ background: Rectangle {
+ implicitWidth: 160
+ color: num.sysPalette.base
+ }
+
+ contentItem: Text {
z: 2
text: control.textFromValue(control.value, control.locale)
+ anchors.verticalCenter: parent.verticalCenter
font: control.font
- color: num.sysPalette.baseText
- selectionColor: num.sysPalette.highlight
- selectedTextColor: num.sysPalette.highlightedText
+ color: num.sysPalette.text
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
+ }
- readOnly: true
- validator: control.validator
+ property int spacingg: 0
+
+ Connections {
+ target: up
+ onPressed: {
+ console.log(up.pressed)
+ }
+ }
+
+ up.indicator: Rectangle {
+ z: 0
+ x: control.mirrored ? -spacingg : parent.width - width + spacingg
+ anchors.verticalCenter: parent.verticalCenter
+ implicitWidth: 37
+ implicitHeight: 37
+ color: up.pressed || !enabled ? num.sysPalette.light : num.sysPalette.base
+ border.color: up.pressed || !enabled ? num.sysPalette.base : num.sysPalette.light
+ radius: 5
+
+ Text {
+ z: 1
+ text: "+"
+ font.pixelSize: control.font.pixelSize * 2
+ color: up.pressed || !enabled ? num.sysPalette.dark : num.sysPalette.text
+ anchors.fill: parent
+ fontSizeMode: Text.Fit
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+
+ down.indicator: Rectangle {
+ z: 0
+ x: control.mirrored ? parent.width - width + spacingg : -spacingg
+ anchors.verticalCenter: parent.verticalCenter
+ implicitWidth: 37
+ implicitHeight: 37
+ color: down.pressed || !enabled ? num.sysPalette.light : num.sysPalette.base
+ border.color: down.pressed || !enabled ? num.sysPalette.base : num.sysPalette.light
+ radius: 5
+
+ Text {
+ text: "-"
+ font.pixelSize: control.font.pixelSize * 2
+ color: down.pressed || !enabled ? num.sysPalette.dark : num.sysPalette.text
+ anchors.fill: parent
+ fontSizeMode: Text.Fit
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
}
property bool daysOnly: false
diff --git a/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml b/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
index 909e977..168aced 100644
--- a/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
+++ b/kstars/kstarslite/qml/modules/popups/ColorSchemePopup.qml
@@ -13,6 +13,7 @@ import QtQuick 2.6
import QtQuick.Layouts 1.1
import "../../constants" 1.0
import "../../modules"
+import QtQuick.Controls.Material 2.0
Popup {
//Change it to Popup when it will become more stable
@@ -24,6 +25,22 @@ Popup {
property string currentCScheme: colorsModel.get(colorsList.currentIndex).scheme
+ onCurrentCSchemeChanged: {
+ updateTheme(currentCScheme)
+ }
+
+ function updateTheme(colorScheme) {
+ if ( Qt.platform.os == "android" ) {
+ if ( colorScheme == "cs_night") {
+ window.Material.theme = Material.Dark //On Android we want to have dark theme only for cs_night
+ } else {
+ window.Material.theme = Material.Light //Light theme for all other color schemes as on Android they are light
+ }
+ } else {
+ window.Material.theme = Material.Dark //Dark theme is suitable for all color themes
+ }
+ }
+
function formatColorScheme(schemeName) {
return schemeName.substring(3) + ".colors"
}
@@ -46,12 +63,18 @@ Popup {
append({ name: xi18n("Star Chart"), scheme: "cs_chart" });
append({ name: xi18n("Night Vision"), scheme: "cs_night" });
append({ name: xi18n("Moonless Night"), scheme: "cs_moonless-night" });
+ }
+ }
+ Connections {
+ target: KStarsLite
+ onDataLoadFinished: {
//Set current index to current scheme color
- var currentScheme = KStarsData.colorSchemeName()
+ var colorScheme = KStarsData.colorSchemeName()
for(var i = 0; i < colorsList.model.count; ++i) {
- if(formatColorScheme(colorsList.model.get(i).scheme) == currentScheme) {
- colorsList.currentIndex = i
+ if(formatColorScheme(colorsList.model.get(i).scheme) == colorScheme) {
+ colorsList.currentIndex = i
+ KStarsLite.loadColorScheme(colorScheme)
}
}
}
diff --git a/kstars/kstarslite/qml/modules/popups/FOVPopup.qml b/kstars/kstarslite/qml/modules/popups/FOVPopup.qml
index 131b5fe..a22b41c 100644
--- a/kstars/kstarslite/qml/modules/popups/FOVPopup.qml
+++ b/kstars/kstarslite/qml/modules/popups/FOVPopup.qml
@@ -26,7 +26,6 @@ Popup {
color: num.sysPalette.base
}
-
KSListView {
id: fovList
anchors {
diff --git a/kstars/kstarsliteinit.cpp b/kstars/kstarsliteinit.cpp
index fc12543..2c678f1 100644
--- a/kstars/kstarsliteinit.cpp
+++ b/kstars/kstarsliteinit.cpp
@@ -52,9 +52,6 @@ void KStarsLite::datainitFinished() {
Options::setShowHorizon(true);
Options::setShowEcliptic(true);
Options::setAutoSelectGrid(false);
-// Options::setHideGrids(false);
-// Options::setShowEquatorialGrid(true);
-// Options::setShowHorizontalGrid(true);
}
void KStarsLite::initFocus() {