Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit abce52fc authored by Artem Fedoskin's avatar Artem Fedoskin

Added support for dark theme in KStars Lite

parent 6f8ef3e2
......@@ -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} \
......
......@@ -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
......
......@@ -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:
......
......@@ -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
......
......@@ -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()
......
......@@ -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
......
import QtQuick 2.6
import QtQuick.Controls 2.0
import "../constants/" 1.0
import QtQuick.Controls.Material 2.0
Button {
id: button
id: control
}
......@@ -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
......
......@@ -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
}
}
......@@ -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
......
......@@ -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) {
if(formatColorScheme(colorsList.model.get(i).scheme) == colorScheme) {
colorsList.currentIndex = i
KStarsLite.loadColorScheme(colorScheme)
}
}
}
......
......@@ -26,7 +26,6 @@ Popup {
color: num.sysPalette.base
}
KSListView {
id: fovList
anchors {
......
......@@ -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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment