Advance Wayland and KDE package bring-up
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
if (TARGET Qt6::Widgets)
|
||||
add_executable(spinbox spinbox.cpp)
|
||||
target_link_libraries(spinbox PRIVATE Qt6::Widgets KF6::I18n)
|
||||
endif()
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Controls 2.15 as QQC2
|
||||
import org.kde.i18n.localeData 1.0
|
||||
|
||||
QQC2.ApplicationWindow {
|
||||
visible: true
|
||||
width: 480
|
||||
height: 720
|
||||
|
||||
property var currentCountry
|
||||
property var currentSubdiv
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 20
|
||||
QQC2.ComboBox {
|
||||
id: countrySelector
|
||||
Layout.fillWidth: true
|
||||
model: Country.allCountries
|
||||
delegate: QQC2.ItemDelegate {
|
||||
text: modelData.emojiFlag + " " + modelData.name + " (" + modelData.alpha2 + ")"
|
||||
onClicked: {
|
||||
countrySelector.currentIndex = index
|
||||
currentCountry = modelData
|
||||
}
|
||||
}
|
||||
displayText: currentValue.emojiFlag + " " + currentValue.name + " (" + currentValue.alpha2 + ")"
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: "Localized name: " + (currentCountry ? currentCountry.name : "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "ISO 3166-1 alpha2: " + (currentCountry ? currentCountry.alpha2 : "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "ISO 3166-2 aplha3: " + (currentCountry ? currentCountry.alpha3 : "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "Flag: " + (currentCountry ? currentCountry.emojiFlag : "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "Currency: " + (currentCountry ? currentCountry.currencyCode : "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "Timezones: " + (currentCountry ? currentCountry.timeZoneIds.join(', '): "N/A")
|
||||
}
|
||||
|
||||
QQC2.TextField {
|
||||
Layout.fillWidth: true
|
||||
placeholderText: "search country by name or ISO code"
|
||||
onEditingFinished: currentCountry = Country.fromName(text)
|
||||
}
|
||||
|
||||
QQC2.ComboBox {
|
||||
Layout.fillWidth: true
|
||||
model: currentCountry ? currentCountry.subdivisions : undefined
|
||||
delegate: QQC2.ItemDelegate {
|
||||
text: modelData.name + " (" + modelData.code + ")"
|
||||
onClicked: {
|
||||
countrySelector.currentIndex = index
|
||||
currentSubdiv = modelData
|
||||
}
|
||||
}
|
||||
displayText: currentValue.name + " (" + currentValue.code + ")"
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
text: "Localized name: " + (currentSubdiv ? currentSubdiv.name : "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "ISO 3166-2: " + (currentSubdiv ? currentSubdiv.code: "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "Parent: " + (currentSubdiv ? currentSubdiv.parent.code : "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "Country: " + (currentSubdiv ? currentSubdiv.country.alpha2 : "N/A")
|
||||
}
|
||||
QQC2.Label {
|
||||
text: "Timezones: " + (currentSubdiv ? currentSubdiv.timeZoneIds.join(', '): "N/A")
|
||||
}
|
||||
QQC2.ComboBox {
|
||||
Layout.fillWidth: true
|
||||
visible: currentSubdiv != undefined && currentSubdiv.subdivisions.length > 0
|
||||
model: currentSubdiv ? currentSubdiv.subdivisions : undefined
|
||||
delegate: QQC2.ItemDelegate {
|
||||
text: modelData.name + " (" + modelData.code + ")"
|
||||
onClicked: {
|
||||
countrySelector.currentIndex = index
|
||||
currentSubdiv = modelData
|
||||
}
|
||||
}
|
||||
displayText: currentValue.name + " (" + currentValue.code + ")"
|
||||
}
|
||||
|
||||
QQC2.TextField {
|
||||
Layout.fillWidth: true
|
||||
placeholderText: "search country subdivision by ISO code"
|
||||
onEditingFinished: {
|
||||
currentSubdiv = CountrySubdivision.fromCode(text)
|
||||
currentCountry = currentSubdiv ? currentSubdiv.country : undefined
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
function searchByLocation() {
|
||||
currentSubdiv = CountrySubdivision.fromLocation(latitude.text, longitude.text);
|
||||
if (currentSubdiv) {
|
||||
currentCountry = currentSubdiv.country;
|
||||
} else {
|
||||
currentCountry = Country.fromLocation(latitude.text, longitude.text);
|
||||
}
|
||||
timezoneAtLocationLabel.text = TimeZone.fromLocation(latitude.text, longitude.text);
|
||||
}
|
||||
|
||||
QQC2.TextField {
|
||||
id: latitude
|
||||
placeholderText: "latitude"
|
||||
onEditingFinished: parent.searchByLocation()
|
||||
}
|
||||
QQC2.TextField {
|
||||
id: longitude
|
||||
placeholderText: "longitude"
|
||||
onEditingFinished: parent.searchByLocation()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QQC2.Label {
|
||||
id: timezoneAtLocationLabel
|
||||
}
|
||||
|
||||
Item { Layout.fillHeight: true }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <KLocalization>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QSpinBox>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QSpinBox spinBox;
|
||||
KLocalization::setupSpinBoxFormatString(&spinBox, ki18np("Baking %v pizza", "Baking %v pizzas"));
|
||||
KLocalization::setupSpinBoxFormatString(&spinBox, ki18np("Baking %v cake", "Baking %v cakes"));
|
||||
KLocalization::retranslateSpinBoxFormatString(&spinBox);
|
||||
spinBox.show();
|
||||
|
||||
QDoubleSpinBox doubleSpinBox;
|
||||
KLocalization::setupSpinBoxFormatString(&doubleSpinBox, ki18n("%v%"));
|
||||
KLocalization::retranslateSpinBoxFormatString(&doubleSpinBox);
|
||||
doubleSpinBox.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user