This forum has been archived. All content is frozen. Please use KDE Discuss instead.

kdialog checkboxes?

Tags: kdialog, kde, checkbox kdialog, kde, checkbox kdialog, kde, checkbox
(comma "," separated)
OCD
Registered Member
Posts
4
Karma
0
OS

kdialog checkboxes?

Tue Jul 26, 2016 3:41 am
Hello,

I'm trying to create a kdialog box with a text input box and a couple of check boxes below this. I've been unable to find any examples showing how to generate check boxes.

What I'm looking for is like that presented when requesting '--dontagain'. A small box that will show a tick (or cross) and a text message to its right explaining the check box:

Image

Does anyone know if this is possible with kdialog?

Thank you.
User avatar
Rog131
Registered Member
Posts
828
Karma
10

Re: kdialog checkboxes?

Tue Aug 02, 2016 2:06 pm
KDE Dialogs

By my knowledge you are seeing all options with the ' kdialog --help'. No radio buttons other than: https://techbase.kde.org/Development/Tu ... -dontagain

Tutorials

Shell Scripting with KDE Dialogs: https://techbase.kde.org/Development/Tu ... DE_Dialogs
Little Girl's Mostly Linux Blog - KDialog: https://mostlylinux.wordpress.com/bashs ... g/kdialog/

Alternatives with the Qt5

- PyDialog (PyQt5): https://www.linux-apps.com/p/1149912/
Description:

My problem was that the kdialog code is still not ported to Qt5 and it depends on various Qt4/KDE4 components. The kdialog has big dependency sizes so we made an alternate dialogs like kdialog switches, options. We would still like full compatibility with kdialog but a few options are still not finished and although this release provides many important functions.


- Mixing: 'bash' + qmlscene + qml = check buttons from the script files

Simple qml dialogs can be used from the scripts with the help of the qmlscene: http://doc.qt.io/qt-5/qtquick-qmlscene.html

An example:

Making example.sh:
Code: Select all
#!/bin/sh

status=$(qmlscene checkBox.qml 2>&1)
echo "Status is" ${status##*:}


and checkBox.qml:
Code: Select all
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import org.kde.plasma.core 2.0 as PlasmaCore

ColumnLayout {
   
    Row {
        PlasmaCore.IconItem {
            source: "dialog-information"
        }

        Text {
            text: "File not found"
        }
    }
   
    CheckBox {
        text: qsTr("Do not show this message again")
        checked: false
        onCheckedChanged: {
            if (checked)
                { console.log("true") }
            else
                { console.log("false") }
            }
    }
   
    Button {
        Layout.alignment: Qt.AlignRight
        text: "OK"
        onClicked: {
            Qt.quit()
        }
    }
}


Executing the example.sh...

Image


More: CheckBox QML Type - http://doc.qt.io/qt-5/qml-qtquick-contr ... ckbox.html
OCD
Registered Member
Posts
4
Karma
0
OS

Re: kdialog checkboxes?

Tue Aug 02, 2016 5:23 pm
Thanks Rog131, that looks like a great answer. 8)

Unfortunately, qmlscene is not available to me. I'm still on QT 4.8.6 and appears that I can't install QT5 without some major breakages.

If I'm ever able to upgrade, I'll try your solution.

Thank you.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]