Skip to content
Snippets Groups Projects
configGeneral.qml 7.29 KiB
Newer Older
  • Learn to ignore specific revisions
  • wwjjbb's avatar
    wwjjbb committed
    /**
    
    samuel's avatar
    samuel committed
        Copyright (C) 2024 Samuel Jimenez <therealsamueljimenez@gmail.com>
              Ported the Luna Plasmoid to Plasma 6.
    
    
    wwjjbb's avatar
    wwjjbb committed
        Copyright 2016 Bill Binder <dxtwjb@gmail.com>
    
        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 3 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/>.
    */
    
    
    samuel's avatar
    samuel committed
    import QtQuick 2.7
    import QtQuick.Controls as QtControls
    import QtQuick.Dialogs as QtDialogs
    import QtQuick.Layouts as QtLayouts
    import org.kde.kcmutils as KCM
    import org.kde.kirigami as Kirigami
    
    samuel's avatar
    samuel committed
    KCM.SimpleKCM {
    
    wwjjbb's avatar
    wwjjbb committed
        id: generalPage
    
    samuel's avatar
    samuel committed
        property alias cfg_latitude: latitude.value // 0=Equator, +90=North Pole, -90=South Pole
        property alias cfg_transparentShadow: transparentShadow.checked // boolean
        property alias cfg_showBackground: showBackground.checked // boolean
    
    dxtwjb's avatar
    dxtwjb committed
        property alias cfg_dateFormat: dateFormat.currentIndex // code: 0= 1= 2=...
    
    wwjjbb's avatar
    wwjjbb committed
        property alias cfg_dateFormatString: dateFormatString.text
    
    samuel's avatar
    samuel committed
        property alias cfg_diskColor: diskColor.color
        property int cfg_lunarIndex: 0 // index into imageChoices
        property string cfg_lunarImage: '' // filename (from imageChoices)
        property int cfg_lunarImageTweak: 0 // rotation angle adjustment for the image (from imageChoices)
    
    dxtwjb's avatar
    dxtwjb committed
        property alias cfg_showGrid: showGrid.checked
        property alias cfg_showTycho: showTycho.checked
        property alias cfg_showCopernicus: showCopernicus.checked
    
        onCfg_lunarIndexChanged: {
    
    samuel's avatar
    samuel committed
            cfg_lunarImage = imageChoices.get(cfg_lunarIndex).filename;
            cfg_lunarImageTweak = imageChoices.get(cfg_lunarIndex).tweak;
            if (cfg_lunarImage == '')
                cfg_transparentShadow = false;
     //transparentShadow does not work with diskColor
    
    dxtwjb's avatar
    dxtwjb committed
    
        ImageChoices {
            id: imageChoices
        }
    
    dxtwjb's avatar
    dxtwjb committed
        QtDialogs.ColorDialog {
            id: colorDialog
    
    
    samuel's avatar
    samuel committed
            title: i18n("Pick a color for the moon")
            visible: false
            selectedColor: diskColor.color
            onAccepted: diskColor.color = selectedColor
    
    dxtwjb's avatar
    dxtwjb committed
        }
    
    wwjjbb's avatar
    wwjjbb committed
        QtLayouts.GridLayout {
            columns: 2
            rowSpacing: 15
    
    dxtwjb's avatar
    dxtwjb committed
                text: i18n("Preview")
    
    samuel's avatar
    samuel committed
    
    
            QtLayouts.RowLayout {
                spacing: 20
    
    dxtwjb's avatar
    dxtwjb committed
    
    
    samuel's avatar
    samuel committed
                QtControls.Button {
    
    dxtwjb's avatar
    dxtwjb committed
                    id: previousButton
    
    samuel's avatar
    samuel committed
    
                    icon.source: "go-previous"
    
    dxtwjb's avatar
    dxtwjb committed
                    enabled: cfg_lunarIndex > 0
                    onClicked: {
    
    samuel's avatar
    samuel committed
                        cfg_lunarIndex -= 1;
    
    samuel's avatar
    samuel committed
                    id: lunaPreview
    
                    width: 200
                    height: 200
                    latitude: cfg_latitude
                    showShadow: false
                    transparentShadow: false
                    lunarImage: cfg_lunarImage
                    lunarImageTweak: cfg_lunarImageTweak
                    diskColor: cfg_diskColor
                    showGrid: cfg_showGrid
                    showTycho: cfg_showTycho
                    showCopernicus: cfg_showCopernicus
    
    samuel's avatar
    samuel committed
                QtControls.Button {
    
    dxtwjb's avatar
    dxtwjb committed
                    id: nextButton
    
    samuel's avatar
    samuel committed
    
                    icon.source: "go-next"
                    enabled: cfg_lunarIndex < imageChoices.count - 1
    
    dxtwjb's avatar
    dxtwjb committed
                    onClicked: {
    
    samuel's avatar
    samuel committed
                        cfg_lunarIndex += 1;
    
    dxtwjb's avatar
    dxtwjb committed
                    }
    
                QtLayouts.ColumnLayout {
    
    dxtwjb's avatar
    dxtwjb committed
                    spacing: 20
    
                    QtControls.CheckBox {
                        id: showGrid
    
    samuel's avatar
    samuel committed
    
    
    dxtwjb's avatar
    dxtwjb committed
                        text: i18n("Show grid")
                    }
    
                    QtControls.CheckBox {
                        id: showTycho
    
    samuel's avatar
    samuel committed
    
    
    dxtwjb's avatar
    dxtwjb committed
                        text: i18n("Tycho")
                    }
    
                    QtControls.CheckBox {
                        id: showCopernicus
    
    samuel's avatar
    samuel committed
    
    
    dxtwjb's avatar
    dxtwjb committed
                        text: i18n("Copernicus")
                    }
    
    
    samuel's avatar
    samuel committed
    
    
    dxtwjb's avatar
    dxtwjb committed
            }
    
            QtControls.Label {
    
    samuel's avatar
    samuel committed
                text: i18n("Disk Color")
    
    dxtwjb's avatar
    dxtwjb committed
                visible: cfg_lunarImage === ""
            }
    
    samuel's avatar
    samuel committed
    
    
    dxtwjb's avatar
    dxtwjb committed
            Rectangle {
    
    samuel's avatar
    samuel committed
                id: diskColor
    
    
    dxtwjb's avatar
    dxtwjb committed
                width: 50
                height: 50
                color: '#808040'
                border.color: '#000000'
    
    samuel's avatar
    samuel committed
                radius: height / 2
    
    dxtwjb's avatar
    dxtwjb committed
                visible: cfg_lunarImage === ""
    
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
    
    samuel's avatar
    samuel committed
                        colorDialog.selectedColor = diskColor.color;
                        colorDialog.visible = true;
    
    dxtwjb's avatar
    dxtwjb committed
                    }
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
            QtControls.Label {
    
                text: i18n("Latitude")
    
    wwjjbb's avatar
    wwjjbb committed
            }
    
    samuel's avatar
    samuel committed
    
    
            QtLayouts.RowLayout {
                spacing: 20
    
                QtControls.Label {
                    id: lbl_latitude
    
    samuel's avatar
    samuel committed
    
    
                    text: Math.abs(latitude.value) + "º " + (latitude.value < 0 ? "S" : "N")
                    QtLayouts.Layout.preferredWidth: 40
                    horizontalAlignment: Text.AlignRight
                }
    
                QtControls.Slider {
                    id: latitude
    
    samuel's avatar
    samuel committed
    
    
                    QtLayouts.Layout.fillWidth: true
    
    samuel's avatar
    samuel committed
                    from: -90
                    to: 90
                    stepSize: 5
    
    samuel's avatar
    samuel committed
    
    
    samuel's avatar
    samuel committed
    
    
    samuel's avatar
    samuel committed
    
    
            QtLayouts.RowLayout {
                spacing: 20
    
    samuel's avatar
    samuel committed
    
    
                QtControls.Label {
                    id: lbl_place
    
    samuel's avatar
    samuel committed
    
    
                    QtLayouts.Layout.fillWidth: true
                    horizontalAlignment: Text.AlignRight
    
    wwjjbb's avatar
    wwjjbb committed
                }
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
            }
    
    wwjjbb's avatar
    wwjjbb committed
            QtControls.Label {
                text: i18n("Date Format")
            }
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
            QtControls.ComboBox {
                id: dateFormat
    
    samuel's avatar
    samuel committed
    
    
    dxtwjb's avatar
    dxtwjb committed
                QtLayouts.Layout.fillWidth: true
    
    wwjjbb's avatar
    wwjjbb committed
                textRole: "key"
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
                model: ListModel {
    
                    dynamicRoles: true
                    Component.onCompleted: {
    
    samuel's avatar
    samuel committed
                        append({
                            "key": i18n("Text date"),
                            "value": 0
                        });
                        append({
                            "key": i18n("Short date"),
                            "value": 1
                        });
                        append({
                            "key": i18n("Long date"),
                            "value": 2
                        });
                        append({
                            "key": i18n("ISO date"),
                            "value": 3
                        });
                        append({
                            "key": i18n("Custom"),
                            "value": 4
                        });
    
    wwjjbb's avatar
    wwjjbb committed
                }
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
            }
    
    wwjjbb's avatar
    wwjjbb committed
            QtControls.Label {
                text: i18n("Date Format String")
                visible: dateFormat.currentIndex == 4
            }
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
            QtControls.TextField {
                id: dateFormatString
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
                maximumLength: 24
                visible: dateFormat.currentIndex == 4
            }
    
    samuel's avatar
    samuel committed
    
    
            QtControls.Label {
                text: i18n("Background")
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
            QtControls.CheckBox {
                id: showBackground
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
                text: i18n("Show background")
            }
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
            QtControls.Label {
                text: ""
            }
    
    samuel's avatar
    samuel committed
    
    
            QtControls.CheckBox {
                id: transparentShadow
    
    samuel's avatar
    samuel committed
    
    
                text: i18n("Transparent shadow")
    
                enabled: cfg_lunarImage != ""
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
        }
    
    samuel's avatar
    samuel committed
    
    
    wwjjbb's avatar
    wwjjbb committed
    }