diff --git a/kcms/formats/CMakeLists.txt b/kcms/formats/CMakeLists.txt --- a/kcms/formats/CMakeLists.txt +++ b/kcms/formats/CMakeLists.txt @@ -1,21 +1,27 @@ -# KI18N Translation Domain for this library -add_definitions(-DTRANSLATION_DOMAIN=\"kcmformats\") +add_definitions(-DTRANSLATION_DOMAIN=\"kcm5_formats\") -set(kcm_formats_PART_SRCS - kcmformats.cpp +set(SRCS_formats + kcm.cpp + formatsettings_impl.cpp + localemodel.cpp ) +kconfig_add_kcfg_files(SRCS_formats formatssettings.kcfgc GENERATE_MOC) -ki18n_wrap_ui(kcm_formats_PART_SRCS kcmformatswidget.ui ) +add_library(kcm_formats MODULE ${SRCS_formats}) -add_library(kcm_formats MODULE ${kcm_formats_PART_SRCS}) - -kcoreaddons_desktop_to_json(kcm_formats formats.desktop SERVICE_TYPES kcmodule.desktop) - -target_link_libraries(kcm_formats Qt5::Core Qt5::DBus Qt5::Widgets KF5::I18n KF5::ConfigCore KF5::KCMUtils) - -install(TARGETS kcm_formats DESTINATION ${KDE_INSTALL_PLUGINDIR} ) +target_link_libraries(kcm_formats + KF5::CoreAddons + KF5::KCMUtils + KF5::I18n + KF5::QuickAddons + Qt5::DBus + Qt5::Widgets +) +kcoreaddons_desktop_to_json(kcm_formats "kcm_formats.desktop") -########### install files ############### +install(FILES formatssettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) +install(FILES kcm_formats.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) +install(TARGETS kcm_formats DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms) -install( FILES formats.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) +kpackage_install_package(package kcm_formats kcms) diff --git a/kcms/formats/Messages.sh b/kcms/formats/Messages.sh --- a/kcms/formats/Messages.sh +++ b/kcms/formats/Messages.sh @@ -1,5 +1,4 @@ #! /usr/bin/env bash -$EXTRACTRC *.ui >> rc.cpp -$XGETTEXT *.cpp -o $podir/kcmformats.pot -rm -f rc.cpp - +$EXTRACTRC `find . -name "*.qml"` >> rc.qml || exit 11 +$XGETTEXT `find . -name "*.qml"` -o $podir/kcm5_formats.pot +rm -f rc.qml diff --git a/kcms/formats/README b/kcms/formats/README new file mode 100644 --- /dev/null +++ b/kcms/formats/README @@ -0,0 +1,4 @@ +Locale KCM +---------------------- + +Configures the Locale of the System based on the LC_* variables \ No newline at end of file diff --git a/kcms/formats/formats.desktop b/kcms/formats/formats.desktop deleted file mode 100644 --- a/kcms/formats/formats.desktop +++ /dev/null @@ -1,166 +0,0 @@ -[Desktop Entry] -Exec=kcmshell5 formats -Icon=preferences-desktop-locale -Type=Service -X-KDE-ServiceTypes=KCModule -X-DocPath=kcontrol/formats/index.html - -X-KDE-Library=kcm_formats -X-KDE-ParentApp=kcontrol - -X-KDE-System-Settings-Parent-Category=regionalsettings -X-KDE-Weight=50 - -Name=Formats -Name[ar]=التّنسيقات -Name[ast]=Formatos -Name[bs]=Formati -Name[ca]=Formats -Name[ca@valencia]=Formats -Name[cs]=Formáty -Name[da]=Formater -Name[de]=Formate -Name[el]=Μορφές -Name[en_GB]=Formats -Name[es]=Formatos -Name[et]=Vormingud -Name[eu]=Formatuak -Name[fi]=Muotoilu -Name[fr]=Formats -Name[gl]=Formatos -Name[he]=תבניות -Name[hu]=Formátumok -Name[id]=Format -Name[is]=Snið -Name[it]=Formati -Name[ja]=フォーマット -Name[ko]=형식 -Name[lt]=Formatai -Name[nb]=Formater -Name[nds]=Formaten -Name[nl]=Formaten -Name[nn]=Format -Name[pa]=ਫਾਰਮੈਟ -Name[pl]=Formaty -Name[pt]=Formatos -Name[pt_BR]=Formatos -Name[ru]=Форматы -Name[sk]=Formáty -Name[sl]=Oblike -Name[sr]=Формати -Name[sr@ijekavian]=Формати -Name[sr@ijekavianlatin]=Formati -Name[sr@latin]=Formati -Name[sv]=Format -Name[tg]=Форматҳо -Name[tr]=Biçimler -Name[uk]=Формати -Name[x-test]=xxFormatsxx -Name[zh_CN]=格式 -Name[zh_TW]=格式 -Comment=Numeric, Currency and Time Formats -Comment[ar]=التّنسيقات الرّقميّة، والعملة والوقت -Comment[bs]=Brojčani,valutni i vremenski formati -Comment[ca]=Format numèric, monetari i horari -Comment[ca@valencia]=Format numèric, monetari i horari -Comment[cs]=Formáty čísel, měny a času -Comment[da]=Formater for tal, valuta og tid -Comment[de]=Formate für Zahlen, Währung und Zeitangaben -Comment[el]=Αριθμητικές, νομισματικές και ωρολογιακές μορφές -Comment[en_GB]=Numeric, Currency and Time Formats -Comment[es]=Formatos numéricos, de moneda y de hora -Comment[et]=Arvude, vääringu ja aja vormingud -Comment[eu]=Zenbaki, moneta eta ordu formatuak -Comment[fi]=Lukujen, rahasummien ja ajanilmausten muotoilu -Comment[fr]=Format numérique, de monnaie et d'heure -Comment[gl]=Formatos de números, moeda e hora -Comment[he]=תבניות של מספרים, מטבעות וזמנים -Comment[hu]=Szám-, pénznem- és időformátumok -Comment[id]=Numerik, Mata Uang dan Format Waktu -Comment[is]=Tölu-, gjaldmiðla- og tímasnið -Comment[it]=Formati numerici, delle valute e dell'orario -Comment[ja]=数字と通貨、時刻のフォーマット -Comment[ko]=숫자, 통화, 시간 형식 -Comment[lt]=Skaitmenų, valiutos ir laiko formatai -Comment[nb]=Formater for tall, valuta og tid -Comment[nds]=Tallen-, Geld- un Tietformaten -Comment[nl]=Indeling voor numerieke getallen, valuta en tijd -Comment[nn]=Format for tal, valuta og tid -Comment[pa]=ਅੰਕੀ, ਕਰੰਸੀ ਅਤੇ ਸਮੇਂ ਦੇ ਫਾਰਮੈਟ -Comment[pl]=Formaty liczb, waluty i czasu -Comment[pt]=Formatos Numéricos, Monetários e de Datas -Comment[pt_BR]=Formatos de data/hora, numérico e monetário -Comment[ru]=Форматы записи чисел, времени и денежных сумм -Comment[sk]=Číselné, menové a časové formáty -Comment[sl]=Oblike števil, valut in časa -Comment[sr]=Формати бројева, времена и валуте -Comment[sr@ijekavian]=Формати бројева, времена и валуте -Comment[sr@ijekavianlatin]=Formati brojeva, vremena i valute -Comment[sr@latin]=Formati brojeva, vremena i valute -Comment[sv]=Numeriska format, valutaformat och tidsformat -Comment[tr]=Sayısal, Para Birimi ve Zaman Biçimleri -Comment[uk]=Формати запису чисел, грошових сум та часу -Comment[vi]=Định dạng số, tiền tệ và thời gian -Comment[x-test]=xxNumeric, Currency and Time Formatsxx -Comment[zh_CN]=数字,货币和时间格式 -Comment[zh_TW]=數值、貨幣與時間格式 - -X-KDE-Keywords=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial -X-KDE-Keywords[bg]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,език,превод,числа,формат,страна, държава,кодова таблица,кодировка,десетичен знак,разделител,валута,пари,календар,време,дата, седмица,работен ден,мерна единица,печат,размер -X-KDE-Keywords[bn]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial -X-KDE-Keywords[bs]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,jezik,prevođenje,format brojeva,lokalizacija,skup znakova,decimalni simboli,separator hiljada,predznak,valuta,razlomak,kalendat,vrijem,datum,papir.,mjere -X-KDE-Keywords[ca]=idioma,traducció,format numèric,configuració regional,país,jocs de caràcters,joc de caràcters,símbol decimal,separador de milers,símbol,separador,signe,positiu,negatiu,moneda,diners,dígits fraccionaris,calendari,hora,data,formats,setmana,inici de setmana,primer,paper,mida,carta,A4,mesura,mètric,Anglès,Imperial -X-KDE-Keywords[ca@valencia]=idioma,traducció,format numèric,configuració regional,país,jocs de caràcters,joc de caràcters,símbol decimal,separador de milers,símbol,separador,signe,positiu,negatiu,moneda,diners,dígits fraccionaris,calendari,hora,data,formats,setmana,inici de setmana,primer,paper,mida,carta,A4,mesura,mètric,Anglés,Imperial -X-KDE-Keywords[cs]=jazyk,překlad,formát čísel,locale,Země,znakové sady,sady znaků,Decimální symbol,Oddělovač tisíců,symbol,oddělovač,znaménko,kladné,záporné,měna, peníze,zlomky, kalendář,čas,datum,formáty,týden,začátek týdne,první,papír,velikost,dopis,A4,míry,metrické,Anglické,Imperiální -X-KDE-Keywords[da]=sprog,oversættelse,talformat,locale,lokalitet,land,tegnsæt,decimalsymbol,tusindtalsseparator,symbol,separator,positive,negative,valuta,penge,brøktal,kalender,tid,klokkeslæt,dato,formater,uge,ugestart,første,papir,størrelse,letter,A4,måleenhed,metrisk,Engelsk,Imperial -X-KDE-Keywords[de]=Sprachen,Übersetzung,Zahlenformat,Währung,Zeit,Datum,Formate,Regionales,Land,Zeichensätze,Dezimalzeichen,Tausendertrennzeichen,Symbole,Zeichen,Vorzeichen,Positiv,Negativ,Bruchzahlen,Wochenanfang,Papierformat,A4,Letter,Metrisch,Imperial,Maßeinheiten -X-KDE-Keywords[el]=γλώσσα,μετάφραση,μορφή αριθμού,εντοπιότητα,χώρα,charsets,σύνολα χαρακτήρων,δεκαδικό σύμβολο,διαχωριστικό χιλιάδων,σύμβολο,διαχωριστικό,πρόσημο,θετικό,αρνητικό,νόμισμα,χρήμα,δεκαδικά ψηφία,ημερολόγιο,ώρα,ημερομηνία,μορφές,εβδομάδα,αρχή εβδομάδας,πρώτη,χαρτί,μέγεθος,letter,A4,μέτρηση,μετρικό,Αγγλικό,Αγγλοσαξονικό -X-KDE-Keywords[en_GB]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial -X-KDE-Keywords[es]=idioma,traducción,formato de número,local,País,codificación,separador de decimales,separador de miles,símbolo,separador,signo,positivo,negativo,moneda,divisa,dígitos decimales,calendario,hora,fecha,formatos,semana,primer día de la semana,primero,papel,tamaño,carta,A4,medida,métrico,Inglés,Imperial -X-KDE-Keywords[et]=keel,tõlkimine,arvuvorming,lokaat,riik,kodeering,kooditabel,kümnendkoht,tuhandete eraldaja,sümbol,eraldaja,märk,positiivne,negatiivne,raha,valuuta,murdarvud,kalender,kellaaeg,aeg,kuupäev,vormingud,nädal,nadala algus,paber,suurus,letter,A4,mõõtühikud,meetersüsteem,inglise süsteem -X-KDE-Keywords[eu]=hizkuntza,itzulpena,zenbaki-formatua,eskualde-ezarpenak,Herrialdea,karaktere-jokoak,karaktere-jokoak,Ikur dezimala,Milakoen bereizlea,ikurra,bereizlea,zeinua,positiboa,negatiboa,moneta,dirua,zatikizko zifrak,egutegia,ordua,data,formatuak,astea,aste-hasiera,lehena,papera,tamaina,gutuna,A4,neurria,metrikoa,Ingelesa,Inperiala -X-KDE-Keywords[fa]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial -X-KDE-Keywords[fi]=kieli,käännös,kääntäminen,lukujen muotoilu,numeroiden muotoilu,locale,alue,alueasetukset,maa,merkistöt,desimaalierotin,tuhaterotin,symboli,erotin,merkki,positiivinen,negatiivinen,valuutta,raha,desimaalipaikkoja,desimaalipaikat,kalenteri,aika,kellonaika,päiväys,päivämäärä,muodot,viikko,viikon alku,viikon ensimmäinen päivä,ensimmäinen,paperi,koko,letter,A4,mittajärjestelmä,mittaaminen,metrinen,Anglosaksinen -X-KDE-Keywords[fr]=langue, traduction, format numérique, paramètres réginaux, pays, jeu de caractères, jeux de caractères, symbole décimal, séparateur des milliers, symbole, séparateur, signe, positif, négatif, devise, monnaie, chiffres après la virgule, calendrier, heure, date, formats, semaine, début de semaine, premier, papier, taille, lettre, A4, mesure, métrique, Français, Impérial -X-KDE-Keywords[ga]=teanga,aistriúchán,formáid uimhreacha,logchaighdeán,Tír,tacair carachtar,siombail dheachúlach,deighilteoir mílte,siombail,deighilteoir,comhartha,deimhneach,diúltach,airgeadra,airgead,digití,féilire,am,dáta,formáidí,seachtain,tús na seachtaine,tús,páipéar,méid,litir,A4,tomhas,méadrach,Béarla,Impiriúil -X-KDE-Keywords[gl]=idioma,lingua,linguaxe, tradución, formato numérico, local, País, caracteres, carácter, símbolo decimal, separador de milleiros, separador, signo, positivo, negativo, divisa, cartos, moeda, díxitos fraccionarios, calendario, almanaque, hora, data, formato, semana, primeiro día, papel, tamaño, A4, medida, métrico, inglés, imperial -X-KDE-Keywords[gu]=ભાષા,ભાષાંતર,આંકડાનું બંધારણ,લિપિ,દેશ,અક્ષરસમૂહ,અક્ષર સમૂહો,દશાંશ ચિહ્ન,હજારને જુદું પાડનાર,ચિહ્ન,જુદું પાડનાર,નિશાની,ધન,ઋણ,ચલણ,પૈસા,અપૂર્ણાંક સંખ્યાઓ,તારિખીયું,સમય,તારીખ,બંધારણો,અઠવાડિયું,અઠવાડિયાંની શરુઆત,પહેલું,કાગળ,માપ,પત્ર,A4,માપ,મેટ્રિક,અંગ્રેજી,ઇમ્પિરીઅલ -X-KDE-Keywords[hi]=भाषा, अनुवाद, संख्या स्वरूप, स्थान, देश, charsets, वर्ण सेट्स,दशमलव प्रतीक, हजारों विभाजक, प्रतीक, विभाजक, हस्ताक्षर, सकारात्मक, नकारात्मक,मुद्रा, पैसा, भिन्नात्मक अंक, पंचांग, समय, तिथि, स्वरूप, सप्ताह, सप्ताह प्रारंभ,पहले, कागज, आकार, पत्र, A4, उपाय, मैट्रिक, अंग्रेजी, इम्पीरियल -X-KDE-Keywords[hu]=nyelv,fordítás,számformátum,területi beállítás,Ország,karakterkészletek,karakterkészletek,tizedesjel,ezres elválasztó,szimbólum,elválasztó,jel,pozitív,negatív,pénznem,pénz,tört számjegyek,naptár,idő,dátum,formátumok,hét,hét kezdete,első,papír,méret,letter,A4,measure,metrikus,Angol,Birodalmi -X-KDE-Keywords[ia]=linguage,traduction,formato de numero,locale,Pais,charsets,insimul de characteres, Symbolo decimal,separator de milles,symbolo,separator,signo,positive,negative,numerario,moneta,cifras fractional,calendario,tempore,data,formatos,septimana,initio de septimana, prime,papiro,grandor,littera,A4,me -X-KDE-Keywords[id]=bahasa,terjemahan,format angka,locale,Negara,set karakter,set karakter,Simbol desimal,Pemisah ribuan,simbol,pemisah,tanda,positif,negatif,mata uang,uang,digit fraksi,kalender,waktu,tanggal,format,minggu,awal minggu,pertama,kertas,ukuran,surat,A4,satuan,metrik,Inggris,Imperial -X-KDE-Keywords[is]=tungumál,þýðing,talnasnið,staðfærsla,Land,stafasett,stafatafla,tugatákn,þúsund,tákn,aðgreinir,merki,jákvætt,neikvætt,gjaldmiðill,peningar,tugabrot,dagatal,tími,dagsetning,snið,vika,upphafsdagur,fyrst,pappír,size,bréf,A4,mál,metra,Enskt,Imperial -X-KDE-Keywords[it]=lingua,traduzione,formato dei numeri,localizzazione,nazione,codifica,insieme dei caratteri,simbolo decimale,separatore delle migliaia,simbolo,separatore,segno,positivo,negativo,moneta,cifre decimali,calendario,ora,data,formati,settimana,inizio settimana,primo,carta,dimensione,lettera,A4,misura,metrico,inglese,imperiale -X-KDE-Keywords[kk]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial -X-KDE-Keywords[km]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial -X-KDE-Keywords[ko]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,언어,번역,숫자,로캘,로케일,국가,나라,지역,문자셋,문자 인코딩,인코딩,소숫점,기호,구분자,양수,음수,통화,화폐,돈,달력,시간,시각,날짜,주,시작 요일,요일,종이,크기,미터법 -X-KDE-Keywords[lt]=kalba,vertimas,skaičių formatas,skaiciu formatas,lokalė,lokale,šalis,salis,simbolių rinkinys,simboliu rinkinys,dešimtainis simbolis,desimtainis simbolis,tūkstančių skirtukas,tukstanciu skirtukas,simbolis,simbolių,simboliu,skirtukas,skyriklis,ženklas,zenklas,teigiamas,neigiamas,valiuta,pinigai,trupmeniniai skaitmenys,trupmenų skaitmenys,trupmenu skaitmenys,kalendorius,laikas,data,formatai,savaitė,savaite,savaitės pradžia,savaites pradzia,pirmas,pirma,popierius,popieriaus,dydis,letter,A4,matavimai,matavimo vienetai,metrinė,metrine,metriniai,anglų,anglu,imperiniai,imperinė,imperine -X-KDE-Keywords[lv]=valoda,tulkojums,skaitļu formāts,lokāle,valsts,rakstzīmju kopas,decimālais simbols,tūkstošu atdalītājs,simbols,atdalītājs,zīme,pozitīvs,negatīvs,valūta, nauda,daļskaitļi,kalendārs,laiks,datums,formāti,nedēļa,nedēļas sākums, pirmais,papīrs,izmērs,vēstule,A4,mērvienības,metriskā,angļu,imperiālā -X-KDE-Keywords[mr]=भाषा, भाषांतर, संख्या पद्धत, स्थानिक, देश, अक्षर संच, दशमान चिन्ह, सहस्त्र विभाजक, चिन्ह, विभाजक, निशाणी, पैसा, अपूर्णांक संख्या, दिनदर्शिका, वेळ, दिनांक, पद्धत, आठवडा, प्रथम, पान, आकार, A4, दशमान, इंग्रजी, शाही -X-KDE-Keywords[nb]=språk,oversettelse,tallformat,lokale,Land,tegnsett,desimalsymbol,tusenseparator,symbol,separator,fortegn,positivt,negativt,valuta.penger,brøktall, tid,dato,formater,uke,ukestart,først,papir,letter,A4,mål.metrisk,engelsk,imperial -X-KDE-Keywords[nds]=Spraak,Översetten,Tallenformaat,Spraakkoderen,Regiooninstellen,Land,Tekensett,Tekensetten,Dezimaalteken,Trennteken för Dusend,Trenner,Vörteken,positiv,negativ,positiev,negatiev,Geldsort,Geld,Brooktallen,Nakommasteden,Kalenner,Tiet,Datum,Formaten,Week,Wekenanfang,eerst,Papeer,Papeergrött,A4,Meten,Maat,metersch,Eenheit,engelsch -X-KDE-Keywords[nl]=taal,vertaling,getalformaat,locale,land,tekensets,decimaalsymbool,duizendscheidingsteken,symbool,scheidingsteken,teken,positief,negatief,valuta,geld,decimale cijfers,agenda,tijd,datum,formaten,week,weekbegin,eerst,papier,grootte,letter,A4,afmeting,metrisch,Engels,Imperiaal -X-KDE-Keywords[nn]=språk,omsetjing,talformat,lokale,locale,land,teiknkodingar,teiknsett,desimalskiljeteikn,tusenskiljeteikn,symbol,skiljeteikn,tein,positiv,negativ,valuta,pengar,siffer,kalender,tid,dato,klokkeslett,format,veke,vekestart,første,papir,storleik,letter,A4,mål,metrisk,engelsk -X-KDE-Keywords[pa]=ਭਾਸ਼ਾ,ਅਨੁਵਾਦ,ਨੰਬਰ ਫਾਰਮੈਟ,ਅੰਕ,ਲੋਕੇਲ,ਦੇਸ਼,ਅੱਖਰਸੈੱਟ,ਅੱਖਰ-ਸੈੱਟ,ਦਸ਼ਮਵਲ ਨਿਸ਼ਾਨ,ਹਜ਼ਾਰ,ਨਿਸ਼ਾਨ,ਵੱਖਰੇਵਾਂ,ਸਾਈਨ,ਧਨਾਤਮਕ,ਰਿਣਾਤਮਕ,ਮੁਦਰਾ,ਪੈਸਾ,ਧਨ,ਭਿੰਨ ਅੰਕ,ਕੈਲੰਡਰ,ਸਮਾਂ,ਮਿਤੀ,ਤਿਥੀ,ਤਾਰੀਖ,ਹਫ਼ਤਾ,ਹਫ਼ਤਾ ਸ਼ੁਰੂ,ਪਹਿਲਾਂ,ਪੇਪਰ,ਸਫ਼ਾ,ਆਕਾਰ,ਸਾਈਜ਼,ਪੱਤਰ,ਲੈਟਰ,A4,ਏ4,ਮਾਪ,ਮਾਪਕ,ਅੰਗਰੇਜ਼ੀ,ਮੀਟਰ -X-KDE-Keywords[pl]=język,tłumaczenie,format liczb,regionalność,kraj,zestaw znaków,symbol dziesiętny,separator tysięcy,symbol,separator,znak,dodatni,ujemny,waluta,pieniądze,ułamkowe cyfry,kalendarz,czas,data,formaty,tydzień,początek tygodnia,pierwszy,papier,rozmiar,list,A4,miara,metryczna,Angielski,Cesarskie -X-KDE-Keywords[pt]=língua,tradução,formato de números,localização,país,codificações,codificações de caracteres,símbolo decimal,separador de milhares,símbolo,separador,sinal,positivo,negativo,moeda,monetário,casas decimais,hora,data,formatos,semana,início da semana,primeiro,papel,tamanho,carta,A4,medida,medir,Inglês,Imperial -X-KDE-Keywords[pt_BR]=idioma,tradução,formato de números,localização,país,codificações,codificações de caracteres,símbolo decimal,separador de milhares,símbolo,separador,sinal,positivo,negativo,moeda,monetário,casas decimais,calendário,hora,data,formatos,semana,início da semana,primeiro,papel,tamanho,carta,A4,medida,medir,Inglês,Imperial -X-KDE-Keywords[ro]=limbă,traducere,format număr,localizare,țară,set de caractere,seturi de caractere,simbol decimal, separator de mii,simbol,separator,semn,pozitiv,negativ,monedă,bani,zecimale,calendar,timp,dată,formate, început,săptămână,prima,hârtie,dimensiune,A4,măsură,metric,unități,Imperial -X-KDE-Keywords[ru]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,язык,перевод,формат чисел,локаль,страна,кодировка,наборы символов,десятичный разделитель,тысячный разделитель,символ,разделитель,подпись,положительный, отрицательный,валюта, деньги, дробные цифры, календарь, время, дата,формат, неделя,начало недели,бумага,размер, буквы,измерение,система мера,метрика -X-KDE-Keywords[sk]=jazyk,preklad,number format,locale,Krajina,charsets,character sets,Decimal symbol,Thousands separator,symbol,oddeľovač,znamienko,kladný,záporný,mena,peniaze,fractional digits,kalendár,čas,dátum,formáty,týždeň,week start,prvý,papier,veľkosť,letter,A4,measure,metric,English,Imperial -X-KDE-Keywords[sl]=jezik,jeziki,prevod,prevodi,oblika števil,krajevne nastavitve,država,znaki,nabori znakov,decimalno ločilo,ločilo skupin,simbol,ločilo,ločilnik,negativno,pozitivno,oznaka,valuta,denar,decimalke,decimalna mesta,koledar,datum,oblike,teden,začetek tedna,prvi,papir,velikost,letter,a4,mere,mera,metrika,merski sistem,enote,enota -X-KDE-Keywords[sr]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,језик,превод,формат бројева,локалитет,држава,кодирање,децимални симбол,раздвајач хиљада,раздвајач,симбол,знак,позитивно,негативно,валута,новац,разломак,календар,време,датум,формати,седмица,почетак седмице,недеља,папир,величина,А4,летер,метрички,империјални -X-KDE-Keywords[sr@ijekavian]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,језик,превод,формат бројева,локалитет,држава,кодирање,децимални симбол,раздвајач хиљада,раздвајач,симбол,знак,позитивно,негативно,валута,новац,разломак,календар,време,датум,формати,седмица,почетак седмице,недеља,папир,величина,А4,летер,метрички,империјални -X-KDE-Keywords[sr@ijekavianlatin]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,jezik,prevod,format brojeva,lokalitet,država,kodiranje,decimalni simbol,razdvajač hiljada,razdvajač,simbol,znak,pozitivno,negativno,valuta,novac,razlomak,kalendar,vreme,datum,formati,sedmica,početak sedmice,nedelja,papir,veličina,A4,leter,metrički,imperijalni -X-KDE-Keywords[sr@latin]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,jezik,prevod,format brojeva,lokalitet,država,kodiranje,decimalni simbol,razdvajač hiljada,razdvajač,simbol,znak,pozitivno,negativno,valuta,novac,razlomak,kalendar,vreme,datum,formati,sedmica,početak sedmice,nedelja,papir,veličina,A4,leter,metrički,imperijalni -X-KDE-Keywords[sv]=språk,översättning,nummerformat,plats,Land,teckenuppsättningar,decimalsymbol,tusentalsavgränsare,symbol,avgränsare,tecken,positivt,negativt,valuta,pengar,bråkdelssiffror,kalender,tid,datum,format,vecka, veckostart,först,papper,storlek,letter,A4,mått,meter,engelska -X-KDE-Keywords[tr]=dil,çeviri,sayısal biçim,yerel,Ülke,karakter seti,karakter setleri,Ondalık sembolü,binler basamağı ayırıcı,sembol,ayırıcı,işaret,pozitif,negatif,para birimi,para,kesir,takvim,saat,tarih,biçimler,hafta,hafta başı,ilk,kağıt,boyut,A4,mektup,ölçü,metrik,İngiliz -X-KDE-Keywords[ug]=تىل،تەرجىمە،سانلارنىڭ يېزىلىشى،يەرلەشمە،دۆلەت،ھەرپ توپى، ھەرپ توپى،ئونلۇق بەلگىلەر،مىڭلار خانە ئايرىغۇچ، بەلگە،ئايرىغۇچ،ئالامەت،مۇسبەت،مەنپىي،پۇل،كەسىرسان،يىلنامە،ۋاقىت،چېسلا،پىچىملار،ھەپتە،ھەپتە بېشى،تۇنجى،قەغەز،چوڭلۇق،خەت،A4،ئۆلچەش،ئۇزۇنلۇق بىرلىكى،English، خانلىق -X-KDE-Keywords[uk]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,мова,мови,переклад,переклади,числа,формат,число,локаль,країна,набір,символ,кодування,розряд,тисяч,дробовий,дробова частина,роздільник,символ,знак,додатне,додатний,додатній,від’ємний,від’ємне,валюта,гроші,грошова одиниця,календар,час,дата,формати,тиждень,робочий тиждень,початок тижня,перший,папір,аркуш,вимір,виміри,вимірювання,одиниці вимірювання,метричний,метричні,метр,англійські,імперські -X-KDE-Keywords[vi]=ngôn ngữ,dịch,định dạng số,tiền tệ,thời gian,ngày,định dạng,miền địa phương,Nước,quốc gia,bộ ký tự,bảng mã,ký hiệu thập phân,dấu cách hàng nghìn,ký hiệu,dấu phân cách,dấu,dương,âm,phân số,tuần,bắt đầu tuần,language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial -X-KDE-Keywords[wa]=lingaedje,ratournaedje,cogne des nombes,locåle,Payi,payis,djeus d' caracteres,djeus di caracteres,simbole des decimåles,separateu des meyes,simbole,separateu,sene,pôzitif,negatif,manoye,cwårs,çanses,liårds,liyårds,caracteres di fraccions,calindrî,eure,date,cognes,samwinne,cominçmint del samwinne,prumî djoû del samwinne,kimince del samwinne,prumî,papî,grandeu,grandeur,lete,A4,mezeure,muzeure,metrike,Inglès,Imperiå -X-KDE-Keywords[x-test]=xxlanguagexx,xxtranslationxx,xxnumber formatxx,xxlocalexx,xxCountryxx,xxcharsetsxx,xxcharacter setsxx,xxDecimal symbolxx,xxThousands separatorxx,xxsymbolxx,xxseparatorxx,xxsignxx,xxpositivexx,xxnegativexx,xxcurrencyxx,xxmoneyxx,xxfractional digitsxx,xxcalendarxx,xxtimexx,xxdatexx,xxformatsxx,xxweekxx,xxweek startxx,xxfirstxx,xxpaperxx,xxsizexx,xxletterxx,xxA4xx,xxmeasurexx,xxmetricxx,xxEnglishxx,xxImperialxx -X-KDE-Keywords[zh_CN]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial,语言,翻译,数字格式,语系,国家,字符集,千分符,十进制符号,符号,分隔符,正数,负数,现金,钱,日历,分号,时间,日期,星期,周,第一,纸张,大小,信件,度量,度量衡,英制,公制 -X-KDE-Keywords[zh_TW]=language,translation,number format,locale,Country,charsets,character sets,Decimal symbol,Thousands separator,symbol,separator,sign,positive,negative,currency,money,fractional digits,calendar,time,date,formats,week,week start,first,paper,size,letter,A4,measure,metric,English,Imperial - -Categories=Qt;KDE;X-KDE-settings-translations; diff --git a/kcms/formats/formatsettings_impl.h b/kcms/formats/formatsettings_impl.h new file mode 100644 --- /dev/null +++ b/kcms/formats/formatsettings_impl.h @@ -0,0 +1,32 @@ +/* This file is part of the KDE Project + * Copyright (C) 2019 by Tomaz Canabrava + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef FORMATSETTINGS_IMPL_H +#define FORMATSETTINGS_IMPL_H + +#include "formatssettings.h" + +class FormatsSettings : public FormatsSettingsAutogen +{ + Q_OBJECT + public: + FormatsSettings(QObject *parent); + bool usrSave() override; +}; + +#endif \ No newline at end of file diff --git a/kcms/formats/formatsettings_impl.cpp b/kcms/formats/formatsettings_impl.cpp new file mode 100644 --- /dev/null +++ b/kcms/formats/formatsettings_impl.cpp @@ -0,0 +1,78 @@ +/* This file is part of the KDE Project + * Copyright (C) 2019 by Tomaz Canabrava + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "formatsettings_impl.h" +#include "writeexports.h" + +FormatsSettings::FormatsSettings(QObject *parent) + : FormatsSettingsAutogen(parent) +{ + +} + +bool FormatsSettings::usrSave() +{ + // I don't know how to do this `save` within the KConfigXT + auto config = KConfigGroup(KSharedConfig::openConfig("plasma-localerc"), "Formats"); + + const QString global = defaultLanguage(); + + if (!useDetailed()) { + config.deleteEntry("useDetailed"); + if (global.isEmpty()) { + config.deleteEntry("LC_LANG"); + } + config.deleteEntry("LC_NUMERIC"); + config.deleteEntry("LC_TIME"); + config.deleteEntry("LC_MONETARY"); + config.deleteEntry("LC_MEASUREMENT"); + config.deleteEntry("LC_COLLATE"); + config.deleteEntry("LC_TYPE"); + } else { + if (global.isEmpty()) { + config.deleteEntry("LC_LANG"); + } + + if (numeric().isEmpty()) { + config.deleteEntry("LC_NUMERIC"); + } + + if (time().isEmpty()) { + config.deleteEntry("LC_TIME"); + } + + if (monetary().isEmpty()) { + config.deleteEntry("LC_MONETARY"); + } + + if (measurement().isEmpty()) { + config.deleteEntry("LC_MEASUREMENT"); + } + + if (collate().isEmpty()) { + config.deleteEntry("LC_COLLATE"); + } + } + + config.sync(); + + // As we touched the settings outside the settings file. + load(); + writeExports(); + return true; +} diff --git a/kcms/formats/formatssettings.kcfg b/kcms/formats/formatssettings.kcfg new file mode 100644 --- /dev/null +++ b/kcms/formats/formatssettings.kcfg @@ -0,0 +1,60 @@ + + + + + + + QString defaultLang = qgetenv("LANG"); + + defaultLang + + + + QString lcNumeric = qgetenv("LC_NUMERIC"); + + lcNumeric + + + + QString lcTime = qgetenv("LC_TIME"); + + lcTime + + + + QString lcMonetary = qgetenv("LC_MONETARY"); + + lcMonetary + + + + QString lcMeasurement = qgetenv("LC_MEASUREMENT"); + + lcMeasurement + + + + QString lcCollate = qgetenv("LC_COLLATE"); + + lcCollate + + + + QString lcCType = qgetenv("LC_CTYPE"); + + lcCType + + + + QString language = qgetenv("LANGUAGE"); + + language + + + false + + + diff --git a/kcms/formats/formatssettings.kcfgc b/kcms/formats/formatssettings.kcfgc new file mode 100644 --- /dev/null +++ b/kcms/formats/formatssettings.kcfgc @@ -0,0 +1,6 @@ +File=formatssettings.kcfg +ClassName=FormatsSettingsAutogen +Mutators=true +DefaultValueGetters=true +GenerateProperties=true +ParentInConstructor=true diff --git a/kcms/formats/kcm.h b/kcms/formats/kcm.h new file mode 100644 --- /dev/null +++ b/kcms/formats/kcm.h @@ -0,0 +1,61 @@ +/* This file is part of the KDE Project + * Copyright (C) 2019 by Tomaz Canabrava + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef FORMATS_H +#define FORMATS_H + +#include + +class FormatsSettings; +class LocaleModel; + +class Formats : public KQuickAddons::ManagedConfigModule +{ + Q_OBJECT + Q_PROPERTY(FormatsSettings *settings MEMBER m_settings CONSTANT) + + //TODO: Exposed those example strings in the UI. + Q_PROPERTY(QString numberExample MEMBER m_numberExample NOTIFY exampleStringsChanged) + Q_PROPERTY(QString timeExample MEMBER m_timeExample NOTIFY exampleStringsChanged) + Q_PROPERTY(QString measurementExample MEMBER m_measurementExample NOTIFY exampleStringsChanged) + Q_PROPERTY(QString currencyExample MEMBER m_currencyExample NOTIFY exampleStringsChanged) + Q_PROPERTY(QSortFilterProxyModel *sortModel MEMBER m_filterModel CONSTANT) + Q_PROPERTY(LocaleModel *model MEMBER m_model CONSTANT) + +public: + Formats(QObject* parent, const QVariantList& args); + ~Formats() override; + + /* creates example strings with the specified Locale. */ + void updateStringsExample(); + +signals: + void exampleStringsChanged(); + +private: + + FormatsSettings *m_settings; + LocaleModel *m_model; + QSortFilterProxyModel *m_filterModel; + QString m_numberExample; + QString m_timeExample; + QString m_measurementExample; + QString m_currencyExample; +}; + +#endif diff --git a/kcms/formats/kcm.cpp b/kcms/formats/kcm.cpp new file mode 100644 --- /dev/null +++ b/kcms/formats/kcm.cpp @@ -0,0 +1,109 @@ +/* This file is part of the KDE Project + Copyright (C) 2019 by Tomaz Canabrava + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kcm.h" + +#include +#include +#include +#include + +#include "formatsettings_impl.h" +#include "localemodel.h" +#include +#include + +K_PLUGIN_FACTORY_WITH_JSON(KCMFormatsFactory, "kcm_formats.json", registerPlugin();) + +Formats::Formats(QObject *parent, const QVariantList &args) + : KQuickAddons::ManagedConfigModule(parent, args) + , m_settings(new FormatsSettings(this)) + , m_model(new LocaleModel(this)) + , m_filterModel(new QSortFilterProxyModel(this)) +{ + qmlRegisterType(); + qmlRegisterUncreatableType("org.internal.kcm.formats", 1, 0, "LocaleModel", QStringLiteral("Model to access the data")); + qmlRegisterType(); + + m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + m_filterModel->setSourceModel(m_model); + + auto *about = new KAboutData( + QStringLiteral("kcm_formats"), i18n("Formats Configuration Module"), + QStringLiteral("0.1"), QString(), KAboutLicense::GPL, + i18n("Copyright 2019 Tomaz Canabrava")); + + about->addAuthor(i18n("Tomaz Canabrava"), QString(), QStringLiteral("tomaz.canabrava@gmail.com")); + + setAboutData(about); + setButtons(Help | Apply | Default); + +} + +Formats::~Formats() +{ +} + +void Formats::updateStringsExample() +{ + const bool useDetailed = m_settings->useDetailed(); + + QLocale nloc; + QLocale tloc; + QLocale cloc; + QLocale mloc; + + QString str; + QString glob = m_settings->defaultLanguage(); + + if (useDetailed) { + str = m_settings->numeric(); + nloc = str.isEmpty() ? QLocale(glob) : QLocale(str); + + str = m_settings->time(); + tloc = str.isEmpty() ? QLocale(glob) : QLocale(str); + + str = m_settings->monetary(); + cloc = str.isEmpty() ? QLocale(glob) : QLocale(str); + + str = m_settings->measurement(); + mloc = str.isEmpty() ? QLocale(glob) : QLocale(str); + } else { + nloc = QLocale(glob); + tloc = QLocale(glob); + cloc = QLocale(glob); + mloc = QLocale(glob); + } + + m_numberExample = nloc.toString(1000.01); + m_timeExample = i18n("%1 (long format)", tloc.toString(QDateTime::currentDateTime())) + QLatin1Char('\n') + + i18n("%1 (short format)", tloc.toString(QDateTime::currentDateTime(), QLocale::ShortFormat)); + m_currencyExample = cloc.toCurrencyString(24.00); + + m_measurementExample.clear(); + if (mloc.measurementSystem() == QLocale::ImperialUKSystem) { + m_measurementExample = i18nc("Measurement combobox", "Imperial UK"); + } else if (mloc.measurementSystem() == QLocale::ImperialUSSystem || mloc.measurementSystem() == QLocale::ImperialSystem) { + m_measurementExample = i18nc("Measurement combobox", "Imperial US"); + } else { + m_measurementExample = i18nc("Measurement combobox", "Metric"); + } + emit exampleStringsChanged(); +} + +#include "kcm.moc" diff --git a/kcms/formats/kcm_formats.desktop b/kcms/formats/kcm_formats.desktop new file mode 100644 --- /dev/null +++ b/kcms/formats/kcm_formats.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Exec=kcmshell5 kcm_formats +Icon=plasma +Type=Service + +X-KDE-ServiceTypes=KCModule +X-KDE-Library=kcm_formats +X-KDE-ParentApp=kcontrol + +X-KDE-System-Settings-Parent-Category=Regional Settings +X-KDE-Weight=10 + +Name=Formats +Comment=Modifies the locale of the system for numbers, currency and measurement +X-KDE-Keywords=Locale diff --git a/kcms/formats/kcmformats.h b/kcms/formats/kcmformats.h deleted file mode 100644 --- a/kcms/formats/kcmformats.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * kcmformats.h - * Copyright 2014 Sebastian Kügler - * - * 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 2 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, write to the Free Software - */ -#ifndef __kcmformats_h__ -#define __kcmformats_h__ - -#include -#include - -#include -#include - -namespace Ui -{ -class KCMFormatsWidget; -} -class QComboBox; - -class KCMFormats : public KCModule -{ - Q_OBJECT - -public: - explicit KCMFormats(QWidget *parent = nullptr, const QVariantList &list = QVariantList()); - ~KCMFormats() override; - - void load() override; - void save() override; - void defaults() override; - -private: - void addLocaleToCombo(QComboBox *combo, const QLocale &locale); - void initCombo(QComboBox *combo, const QList &allLocales); - void connectCombo(QComboBox *combo); - QList m_combos; - - QIcon loadFlagIcon(const QString &flagCode); - QHash m_cachedFlags; - QIcon m_cachedUnknown; - - void readConfig(); - void writeConfig(); - - void updateExample(); - void updateEnabled(); - - Ui::KCMFormatsWidget *m_ui; - KConfigGroup m_config; -}; - -#endif diff --git a/kcms/formats/kcmformats.cpp b/kcms/formats/kcmformats.cpp deleted file mode 100644 --- a/kcms/formats/kcmformats.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* - * kcmformats.cpp - * Copyright 2014 Sebastian Kügler - * - * 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 2 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, write to the Free Software - */ - -// own -#include "kcmformats.h" -#include "ui_kcmformatswidget.h" - -// Qt -#include -#include -#include -#include -#include -#include -#include -#include - -// Frameworks -#include -#include -#include -#include - -K_PLUGIN_FACTORY_WITH_JSON(KCMFormatsFactory, "formats.json", registerPlugin();) - -KCMFormats::KCMFormats(QWidget *parent, const QVariantList &args) - : KCModule(parent, args) -{ - setQuickHelp(i18n("

Formats

" - "You can configure the formats used for time, dates, money and other numbers here.")); - - m_ui = new Ui::KCMFormatsWidget; - m_ui->setupUi(this); - m_combos << m_ui->comboGlobal - << m_ui->comboNumbers - << m_ui->comboTime - << m_ui->comboCurrency - << m_ui->comboMeasurement - << m_ui->comboCollate; -} - -KCMFormats::~KCMFormats() -{ - delete m_ui; -} - -bool countryLessThan(const QLocale & c1, const QLocale & c2) -{ - // Ensure that the "Default (C)" locale always appears at the top - if (c1.name()== QLatin1Char('C') && c2.name()!=QLatin1String("C")) return true; - if (c2.name()== QLatin1Char('C')) return false; - - const QString ncn1 = !c1.nativeCountryName().isEmpty() ? c1.nativeCountryName() : QLocale::countryToString(c1.country()); - const QString ncn2 = !c2.nativeCountryName().isEmpty() ? c2.nativeCountryName() : QLocale::countryToString(c2.country()); - return QString::localeAwareCompare(ncn1, ncn2) < 0; -} - -void KCMFormats::load() -{ - QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - std::sort(allLocales.begin(), allLocales.end(), countryLessThan); - foreach(QComboBox * combo, m_combos) { - initCombo(combo, allLocales); - } - - readConfig(); - - foreach(QComboBox * combo, m_combos) { - connectCombo(combo); - } - - connect(m_ui->checkDetailed, &QAbstractButton::toggled, [ = ]() { - updateExample(); - updateEnabled(); - emit changed(true); - }); - - updateEnabled(); - updateExample(); - emit changed(false); -} - -void KCMFormats::initCombo(QComboBox *combo, const QList & allLocales) -{ - combo->clear(); - const QString clabel = i18n("No change"); - combo->addItem(clabel, QString()); - foreach(const QLocale & l, allLocales) { - addLocaleToCombo(combo, l); - } -} - -void KCMFormats::connectCombo(QComboBox *combo) -{ - connect(combo, &QComboBox::currentTextChanged, [ = ]() { - emit changed(true); - updateExample(); - }); -} - -void KCMFormats::addLocaleToCombo(QComboBox *combo, const QLocale &locale) -{ - const QString clabel = !locale.nativeCountryName().isEmpty() ? locale.nativeCountryName() : QLocale::countryToString(locale.country()); - // This needs to use name() rather than bcp47name() or later on the export will generate a non-sense locale (e.g. "it" instead of - // "it_IT") - // TODO: Properly handle scripts (@foo) - QString cvalue = locale.name(); - if (!cvalue.contains(QLatin1Char('.')) && cvalue != QLatin1Char('C')) { - // explicitly add the encoding, - // otherwise Qt doesn't accept dead keys and garbles the output as well - cvalue.append(QLatin1Char('.') + QTextCodec::codecForLocale()->name()); - } - - QString flagcode; - const QStringList split = locale.name().split(QLatin1Char('_')); - if (split.count() > 1) { - flagcode = split[1].toLower(); - } - QIcon flagIcon = loadFlagIcon(flagcode); - - const QString nativeLangName = locale.nativeLanguageName(); - if (!nativeLangName.isEmpty()) { - combo->addItem(flagIcon, i18n("%1 - %2 (%3)", clabel, nativeLangName, locale.name()), cvalue); - } else { - combo->addItem(flagIcon, i18n("%1 (%2)", clabel, locale.name()), cvalue); - } -} - -void setCombo(QComboBox *combo, const QString &key) -{ - const int ix = combo->findData(key); - if (ix > -1) { - combo->setCurrentIndex(ix); - } -} - -QIcon KCMFormats::loadFlagIcon(const QString &flagCode) -{ - QIcon icon = m_cachedFlags.value(flagCode); - if (!icon.isNull()) { - return icon; - } - - QString flag(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kf5/locale/countries/%1/flag.png").arg(flagCode))); - if (!flag.isEmpty()) { - icon = QIcon(flag); - } else { - if (m_cachedUnknown.isNull()) { - m_cachedUnknown = QIcon::fromTheme("unknown"); - } - icon = m_cachedUnknown; - } - m_cachedFlags.insert(flagCode, icon); - - return icon; -} - -const static QString configFile = QStringLiteral("plasma-localerc"); -const static QString exportFile = QStringLiteral("plasma-locale-settings.sh"); - -const static QString lcLang = QStringLiteral("LANG"); -const static QString lcNumeric = QStringLiteral("LC_NUMERIC"); -const static QString lcTime = QStringLiteral("LC_TIME"); -const static QString lcMonetary = QStringLiteral("LC_MONETARY"); -const static QString lcMeasurement = QStringLiteral("LC_MEASUREMENT"); -const static QString lcCollate = QStringLiteral("LC_COLLATE"); -const static QString lcCtype = QStringLiteral("LC_CTYPE"); - -const static QString lcLanguage = QStringLiteral("LANGUAGE"); - - - -void KCMFormats::readConfig() -{ - m_config = KConfigGroup(KSharedConfig::openConfig(configFile), "Formats"); - - bool useDetailed = m_config.readEntry("useDetailed", false); - m_ui->checkDetailed->setChecked(useDetailed); - - setCombo(m_ui->comboGlobal, m_config.readEntry(lcLang, qgetenv(lcLang.toLatin1()))); - - setCombo(m_ui->comboNumbers, m_config.readEntry(lcNumeric, qgetenv(lcNumeric.toLatin1()))); - setCombo(m_ui->comboTime, m_config.readEntry(lcTime, qgetenv(lcTime.toLatin1()))); - setCombo(m_ui->comboCollate, m_config.readEntry(lcCollate, qgetenv(lcCollate.toLatin1()))); - setCombo(m_ui->comboCurrency, m_config.readEntry(lcMonetary, qgetenv(lcMonetary.toLatin1()))); - setCombo(m_ui->comboMeasurement, m_config.readEntry(lcMeasurement, qgetenv(lcMeasurement.toLatin1()))); - - updateEnabled(); -} - -void KCMFormats::writeConfig() -{ - m_config = KConfigGroup(KSharedConfig::openConfig(configFile), "Formats"); - - // global ends up empty here when OK button is clicked from kcmshell5, - // apparently the data in the combo is gone by the time save() is called. - // This might be a problem in KCModule, but does not directly affect us - // since within systemsettings, it works fine. - // See https://bugs.kde.org/show_bug.cgi?id=334624 - if (m_ui->comboGlobal->count() == 0) { - qWarning() << "Couldn't read data from UI, writing configuration failed."; - return; - } - const QString global = m_ui->comboGlobal->currentData().toString(); - - if (!m_ui->checkDetailed->isChecked()) { - // Global setting, clean up config - m_config.deleteEntry("useDetailed"); - if (global.isEmpty()) { - m_config.deleteEntry(lcLang); - } else { - m_config.writeEntry(lcLang, global); - } - m_config.deleteEntry(lcNumeric); - m_config.deleteEntry(lcTime); - m_config.deleteEntry(lcMonetary); - m_config.deleteEntry(lcMeasurement); - m_config.deleteEntry(lcCollate); - m_config.deleteEntry(lcCtype); - } else { - // Save detailed settings - m_config.writeEntry("useDetailed", true); - - if (global.isEmpty()) { - m_config.deleteEntry(lcLang); - } else { - m_config.writeEntry(lcLang, global); - } - - const QString numeric = m_ui->comboNumbers->currentData().toString(); - if (numeric.isEmpty()) { - m_config.deleteEntry(lcNumeric); - } else { - m_config.writeEntry(lcNumeric, numeric); - } - - const QString time = m_ui->comboTime->currentData().toString(); - if (time.isEmpty()) { - m_config.deleteEntry(lcTime); - } else { - m_config.writeEntry(lcTime, time); - } - - const QString monetary = m_ui->comboCurrency->currentData().toString(); - if (monetary.isEmpty()) { - m_config.deleteEntry(lcMonetary); - } else { - m_config.writeEntry(lcMonetary, monetary); - } - - const QString measurement = m_ui->comboMeasurement->currentData().toString(); - if (measurement.isEmpty()) { - m_config.deleteEntry(lcMeasurement); - } else { - m_config.writeEntry(lcMeasurement, measurement); - } - - const QString collate = m_ui->comboCollate->currentData().toString(); - if (collate.isEmpty()) { - m_config.deleteEntry(lcCollate); - } else { - m_config.writeEntry(lcCollate, collate); - } - } - - m_config.sync(); -} - -void KCMFormats::save() -{ - writeConfig(); - KMessageBox::information(this, i18n("Your changes will take effect the next time you log in."), - i18n("Format Settings Changed"), QStringLiteral("FormatSettingsChanged")); -} - -void KCMFormats::defaults() -{ - m_ui->checkDetailed->setChecked(false); - - // restore user defaults from env vars - setCombo(m_ui->comboGlobal, qgetenv(lcLang.toLatin1())); - setCombo(m_ui->comboNumbers, qgetenv(lcNumeric.toLatin1())); - setCombo(m_ui->comboTime, qgetenv(lcTime.toLatin1())); - setCombo(m_ui->comboCollate, qgetenv(lcCollate.toLatin1())); - setCombo(m_ui->comboCurrency, qgetenv(lcMonetary.toLatin1())); - setCombo(m_ui->comboMeasurement, qgetenv(lcMeasurement.toLatin1())); - - updateEnabled(); -} - -void KCMFormats::updateEnabled() -{ - const bool enabled = m_ui->checkDetailed->isChecked(); - - m_ui->labelNumbers->setEnabled(enabled); - m_ui->labelTime->setEnabled(enabled); - m_ui->labelCurrency->setEnabled(enabled); - m_ui->labelMeasurement->setEnabled(enabled); - m_ui->labelCollate->setEnabled(enabled); - m_ui->comboNumbers->setEnabled(enabled); - m_ui->comboTime->setEnabled(enabled); - m_ui->comboCurrency->setEnabled(enabled); - m_ui->comboMeasurement->setEnabled(enabled); - m_ui->comboCollate->setEnabled(enabled); -} - -void KCMFormats::updateExample() -{ - const bool useDetailed = m_ui->checkDetailed->isChecked(); - - QLocale nloc; - QLocale tloc; - QLocale cloc; - QLocale mloc; - - QString str; - QString glob = m_ui->comboGlobal->currentData().toString(); - - if (useDetailed) { - str = m_ui->comboNumbers->currentData().toString(); - nloc = str.isEmpty() ? QLocale(glob) : QLocale(str); - - str = m_ui->comboTime->currentData().toString(); - tloc = str.isEmpty() ? QLocale(glob) : QLocale(str); - - str = m_ui->comboCurrency->currentData().toString(); - cloc = str.isEmpty() ? QLocale(glob) : QLocale(str); - - str = m_ui->comboMeasurement->currentData().toString(); - mloc = str.isEmpty() ? QLocale(glob) : QLocale(str); - } else { - nloc = QLocale(glob); - tloc = QLocale(glob); - cloc = QLocale(glob); - mloc = QLocale(glob); - } - - const QString numberExample = nloc.toString(1000.01); - const QString timeExample = i18n("%1 (long format)", tloc.toString(QDateTime::currentDateTime())) + QLatin1Char('\n') + - i18n("%1 (short format)", tloc.toString(QDateTime::currentDateTime(), QLocale::ShortFormat)); - const QString currencyExample = cloc.toCurrencyString(24.00); - - QString measurementSetting; - if (mloc.measurementSystem() == QLocale::ImperialUKSystem) { - measurementSetting = i18nc("Measurement combobox", "Imperial UK"); - } else if (mloc.measurementSystem() == QLocale::ImperialUSSystem || mloc.measurementSystem() == QLocale::ImperialSystem) { - measurementSetting = i18nc("Measurement combobox", "Imperial US"); - } else { - measurementSetting = i18nc("Measurement combobox", "Metric"); - } - - m_ui->exampleNumbers->setText(numberExample); - m_ui->exampleTime->setText(timeExample); - m_ui->exampleCurrency->setText(currencyExample); - m_ui->exampleMeasurement->setText(measurementSetting); -} - -#include "kcmformats.moc" diff --git a/kcms/formats/kcmformatswidget.ui b/kcms/formats/kcmformatswidget.ui deleted file mode 100644 --- a/kcms/formats/kcmformatswidget.ui +++ /dev/null @@ -1,385 +0,0 @@ - - - Sebastian Kuegler - KCMFormatsWidget - - - - 0 - 0 - 755 - 585 - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - - - - - - - QFormLayout::ExpandingFieldsGrow - - - 6 - - - 6 - - - - - Re&gion: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - comboGlobal - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - - - - De&tailed Settings - - - - - - - &Numbers: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - comboNumbers - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - - - - &Time: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - comboTime - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - - - - Currenc&y: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - comboCurrency - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - - - - Measurement &Units: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - comboMeasurement - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - - - - Co&llation and Sorting: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - comboCollate - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - <b>Description</b> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Numbers: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Time: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Currency: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Measurement Units: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 16 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 16 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 32 - - - - - - - - - - - - - - - - diff --git a/kcms/formats/localemodel.h b/kcms/formats/localemodel.h new file mode 100644 --- /dev/null +++ b/kcms/formats/localemodel.h @@ -0,0 +1,43 @@ +#ifndef LOCALEMODEL_H +#define LOCALEMODEL_H + +#include +#include +#include +#include +#include +#include +#include + +struct LocaleItem +{ + QIcon flag; + QString humanReadableName; + QString systemName; +}; + +Q_DECLARE_TYPEINFO(LocaleItem, Q_MOVABLE_TYPE); + +class LocaleModel : public QAbstractListModel +{ + Q_OBJECT +public: + enum LocaleModelRoles {Flag = Qt::UserRole + 1, LocaleSystemName}; + Q_ENUM(LocaleModelRoles) + + explicit LocaleModel(QObject *parent = nullptr); + + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &idx, int role) const override; + QHash roleNames() const override; + QIcon loadFlagIcon(const QString &localeStr); + + Q_INVOKABLE int indexFor(const QString &value) const; + Q_INVOKABLE QString localeNameFor(const QString &localeStr) const; + Q_INVOKABLE QString flagFor(const QString &localeStr) const; + +private: + QVector m_data; +}; + +#endif diff --git a/kcms/formats/localemodel.cpp b/kcms/formats/localemodel.cpp new file mode 100644 --- /dev/null +++ b/kcms/formats/localemodel.cpp @@ -0,0 +1,140 @@ +#include "localemodel.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace { +bool countryLessThan(const QLocale &c1, const QLocale &c2) +{ + // Ensure that the "Default (C)" locale always appears at the top + if (c1 == QLocale::c() && c2 != QLocale::c()) return true; + if (c2 == QLocale::c()) return false; + + auto ncn = [](const QLocale& locale) -> QString { + return !locale.nativeCountryName().isEmpty() ? locale.nativeCountryName() : QLocale::countryToString(locale.country()); + }; + + return QString::localeAwareCompare(ncn(c1), ncn(c2)) < 0; +} + +QString getFlagCode(const QString &localeSystemName) +{ + const QStringList split = localeSystemName.split(QLatin1Char('_')); + if (split.count() > 1) { + return split[1].toLower(); + } + return {}; +} + + +QString getCountryLocale(const QString &localeSystemName) +{ + // This needs to use name() rather than bcp47name() or later on the export will generate a non-sense locale (e.g. "it" instead of + // "it_IT") + // TODO: Properly handle scripts (@foo) + + if (!localeSystemName.contains(QLatin1Char('.')) && localeSystemName != QLatin1Char('C')) { + // explicitly add the encoding, + // otherwise Qt doesn't accept dead keys and garbles the output as well + return localeSystemName + QLatin1Char('.') + QTextCodec::codecForLocale()->name(); + } + + return localeSystemName; +} + +} + +LocaleModel::LocaleModel(QObject *parent) : QAbstractListModel(parent) +{ + auto allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); + std::sort(allLocales.begin(), allLocales.end(), countryLessThan); + + m_data.reserve(allLocales.size()); + + for(auto locale : qAsConst(allLocales)) { + const QString clabel = !locale.nativeCountryName().isEmpty() ? locale.nativeCountryName() : QLocale::countryToString(locale.country()); + const QString cvalue = getCountryLocale(locale.name()); + const QIcon flagIcon = loadFlagIcon(locale.name()); + const QString nativeLangName = locale.nativeLanguageName(); + const QString visibleString = nativeLangName.isEmpty() + ? i18n("%1 (%2)", clabel, locale.name()) + : i18n("%1 - %2 (%3)", clabel, nativeLangName, locale.name()); + + m_data.append({flagIcon, visibleString, cvalue}); + } +} + +int LocaleModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) { + return 0; + } + return m_data.count(); +} + +QVariant LocaleModel::data(const QModelIndex &idx, int role) const +{ + if (!idx.isValid()) { + return {}; + } + + switch(role) { + case Qt::DisplayRole: return m_data.at(idx.row()).humanReadableName; + case Flag: return m_data.at(idx.row()).flag; + case LocaleSystemName: return m_data.at(idx.row()).systemName; + } + + return {}; +} + +int LocaleModel::indexFor(const QString &value) const +{ + for(int i = 0; i < m_data.size(); i++) { + if (m_data.at(i).systemName == value) { + return i; + } + } + return -1; +} + +QString LocaleModel::localeNameFor(const QString &localeStr) const +{ + for(const auto &locale : qAsConst(m_data)) { + if (locale.systemName == localeStr) { + return locale.humanReadableName; + } + } + return {}; +} + +QString LocaleModel::flagFor(const QString &localeStr) const +{ + const QString flagCode = getFlagCode(localeStr); + return QStandardPaths::locate( + QStandardPaths::GenericDataLocation, + QStringLiteral("kf5/locale/countries/%1/flag.png").arg(flagCode)); +} + + +QIcon LocaleModel::loadFlagIcon(const QString &localeStr) +{ + QString flag = flagFor(localeStr); + return flag.isEmpty() + ? QIcon::fromTheme("unknown") + : QIcon(flag); +} + +QHash LocaleModel::roleNames() const +{ + return { + { Flag, "flag" }, + { Qt::DisplayRole, "humanReadableName" }, + { LocaleSystemName, "systemName" } + }; +} + diff --git a/kcms/formats/package/contents/ui/CountryList.qml b/kcms/formats/package/contents/ui/CountryList.qml new file mode 100644 --- /dev/null +++ b/kcms/formats/package/contents/ui/CountryList.qml @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (C) 2019 by Tomaz Canabrava * + * * + * 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 2 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.11 as QQC2 +import QtQuick.Dialogs 1.2 as QtDialogs +import org.kde.kirigami 2.4 as Kirigami +import org.kde.kcm 1.1 as KCM +import org.internal.kcm.formats 1.0 + +ColumnLayout { + signal localeSelected(var locale) + QQC2.TextField { + id: filter + placeholderText: i18n("Filter...") + onTextChanged: kcm.sortModel.setFilterWildcard(text) + focus: visible + Layout.fillWidth: true + + Keys.onEscapePressed: { + drawer.close() + } + + Keys.onDownPressed: { + listView.incrementCurrentIndex() + } + + Keys.onUpPressed: { + listView.decrementCurrentIndex() + } + + Keys.onReturnPressed: { + var idx = kcm.model.index(listView.currentIndex, 0); + var value = kcm.model.data(idx, LocaleModel.LocaleSystemName); + localeSelected(value) + drawer.close() + } + } + + ListView { + id: listView + model: kcm.sortModel + Layout.fillHeight: true + Layout.fillWidth: true + delegate: Kirigami.BasicListItem { + icon: model.flag + text: model.humanReadableName + onClicked: { + localeSelected(model.systemName) + drawer.close() + } + } + } +} diff --git a/kcms/formats/package/contents/ui/LocaleInput.qml b/kcms/formats/package/contents/ui/LocaleInput.qml new file mode 100644 --- /dev/null +++ b/kcms/formats/package/contents/ui/LocaleInput.qml @@ -0,0 +1,30 @@ +/*************************************************************************** + * Copyright (C) 2019 by Tomaz Canabrava * + * * + * 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 2 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.11 as QQC2 +import org.kde.kcm 1.1 as KCM + +QQC2.Button { + id: root + property var localeType + property var localeName: kcm.model.localeNameFor(localeType) + text: localeName !== "" ? localeName : i18n("Choose...") + onClicked: drawer.open() +} diff --git a/kcms/formats/package/contents/ui/main.qml b/kcms/formats/package/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/kcms/formats/package/contents/ui/main.qml @@ -0,0 +1,122 @@ +/*************************************************************************** + * Copyright (C) 2019 by Tomaz Canabrava * + * * + * 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 2 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, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * + ***************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.11 as QQC2 +import QtQuick.Dialogs 1.2 as QtDialogs +import org.kde.kirigami 2.4 as Kirigami +import org.kde.kcm 1.1 as KCM + +KCM.SimpleKCM { + id: root + property var editingLocale: null + + KCM.ConfigModule.quickHelp: i18n("

Formats

You can configure the formats used for time, dates, money and other numbers here.") + + Kirigami.OverlaySheet { + id: drawer + + parent: root.parent + + topPadding: 0 + leftPadding: 0 + rightPadding: 0 + bottomPadding: 0 + + CountryList { + id: countryList + height: root.height + implicitWidth: 18 * Kirigami.Units.gridUnit + + onLocaleSelected: { + editingLocale.localeType = locale + } + } + } + + Kirigami.FormLayout { + LocaleInput { + id: global + Kirigami.FormData.label: i18n("Global Language: ") + localeType: kcm.settings.defaultLanguage + onLocaleTypeChanged: kcm.settings.defaultLanguage = global.localeType + onClicked: editingLocale = global + } + + QQC2.CheckBox { + id: detailedSettings + Kirigami.FormData.label: i18n("Detailed Settings:") + } + + LocaleInput { + id: numeric + Kirigami.FormData.label: i18n("Numbers: ") + localeType: kcm.settings.numeric + enabled: detailedSettings.checked + onLocaleTypeChanged: kcm.settings.numeric = numeric.localeType + onClicked: editingLocale = numeric + } + + LocaleInput { + id: time + Kirigami.FormData.label: i18n("Time: ") + localeType: kcm.settings.time + enabled: detailedSettings.checked + onLocaleTypeChanged: kcm.settings.time = time.localeType + onClicked: editingLocale = time + } + + LocaleInput { + id: currency + Kirigami.FormData.label: i18n("Currency: ") + localeType: kcm.settings.monetary + enabled: detailedSettings.checked + onLocaleTypeChanged: kcm.settings.currency = time.localeType + onClicked: editingLocale = currency + } + + LocaleInput { + id: measurement + Kirigami.FormData.label: i18n("Measurement: ") + localeType: kcm.settings.measurement + enabled: detailedSettings.checked + onLocaleTypeChanged: kcm.settings.measurement = time.localeType + onClicked: editingLocale = measurement + } + + LocaleInput { + id: collate + Kirigami.FormData.label: i18n("Collate: ") + localeType: kcm.settings.collate + enabled: detailedSettings.checked + onLocaleTypeChanged: kcm.settings.collate = time.localeType + onClicked: editingLocale = collate + } + + LocaleInput { + id: region + Kirigami.FormData.label: i18n("Region: ") + localeType: kcm.settings.region + enabled: detailedSettings.checked + onLocaleTypeChanged: kcm.settings.region = time.localeType + onClicked: editingLocale = region + } + } +} diff --git a/kcms/formats/package/metadata.desktop b/kcms/formats/package/metadata.desktop new file mode 100644 --- /dev/null +++ b/kcms/formats/package/metadata.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Name=Formats +Comment=what your app does in a few words +Icon=Plasma +Type=Service +X-KDE-PluginInfo-Author=Tomaz Canabrava +X-KDE-PluginInfo-Email=tomaz.canabrava@gmail.com +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=kcm_formats +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website= +X-KDE-ServiceTypes=Plasma/Generic +X-Plasma-API=declarativeappletscript + +X-Plasma-MainScript=ui/main.qml + diff --git a/kcms/formats/writeexports.h b/kcms/formats/writeexports.h new file mode 100644 --- /dev/null +++ b/kcms/formats/writeexports.h @@ -0,0 +1,108 @@ +/* + * Copyright 2014 Sebastian Kügler + * + * 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 2 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, write to the Free Software + */ + +#ifndef WRITEEXPORTS_H +#define WRITEEXPORTS_H + +#include +#include +#include + +#include + +const static QString configFile = QStringLiteral("plasma-localerc"); +const static QString exportFile = QStringLiteral("plasma-locale-settings.sh"); + +const static QString lcLang = QStringLiteral("LANG"); + +const static QString lcNumeric = QStringLiteral("LC_NUMERIC"); +const static QString lcTime = QStringLiteral("LC_TIME"); +const static QString lcMonetary = QStringLiteral("LC_MONETARY"); +const static QString lcMeasurement = QStringLiteral("LC_MEASUREMENT"); +const static QString lcCollate = QStringLiteral("LC_COLLATE"); +const static QString lcCtype = QStringLiteral("LC_CTYPE"); + +const static QString lcLanguage = QStringLiteral("LANGUAGE"); + + +void writeExports() +{ + const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + exportFile; + + QString script(QStringLiteral("# Generated script, do not edit\n")); + script.append(QLatin1String("# Exports language-format specific env vars from startkde.\n")); + script.append(QLatin1String("# This script has been generated from kcmshell5 formats.\n")); + script.append(QLatin1String("# It will automatically be overwritten from there.\n")); + KConfigGroup formatsConfig = KConfigGroup(KSharedConfig::openConfig(configFile), "Formats"); + KConfigGroup languageConfig = KConfigGroup(KSharedConfig::openConfig(configFile), "Translations"); + + const QString _export = QStringLiteral("export "); + + // Formats, uses LC_* and LANG variables + const QString lang = formatsConfig.readEntry(lcLang, QString()); + if (!lang.isEmpty()) { + script.append(_export + lcLang + QLatin1Char('=') + lang + QLatin1Char('\n')); + } + + const QString numeric = formatsConfig.readEntry(lcNumeric, QString()); + if (!numeric.isEmpty()) { + script.append(_export + lcNumeric + QLatin1Char('=') + numeric + QLatin1Char('\n')); + } + + const QString time = formatsConfig.readEntry(lcTime, QString()); + if (!time.isEmpty()) { + script.append(_export + lcTime + QLatin1Char('=') + time + QLatin1Char('\n')); + } + + const QString monetary = formatsConfig.readEntry(lcMonetary, QString()); + if (!monetary.isEmpty()) { + script.append(_export + lcMonetary + QLatin1Char('=') + monetary + QLatin1Char('\n')); + } + + const QString measurement = formatsConfig.readEntry(lcMeasurement, QString()); + if (!measurement.isEmpty()) { + script.append(_export + lcMeasurement + QLatin1Char('=') + measurement + QLatin1Char('\n')); + } + + const QString collate = formatsConfig.readEntry(lcCollate, QString()); + if (!collate.isEmpty()) { + script.append(_export + lcCollate + QLatin1Char('=') + collate + QLatin1Char('\n')); + } + + const QString ctype = formatsConfig.readEntry(lcCtype, QString()); + if (!ctype.isEmpty()) { + script.append(_export + lcCtype + QLatin1Char('=') + ctype + QLatin1Char('\n')); + } + + // Translations, uses LANGUAGE variable + const QString language = languageConfig.readEntry(lcLanguage, QString()); + if (!language.isEmpty()) { + script.append(_export + lcLanguage + QLatin1Char('=') + language + QLatin1Char('\n')); + } + + + + QFile file(configPath); + file.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream out(&file); + + qDebug() << "Wrote script: " << configPath << "\n" << script; + out << script; + file.close(); +} + +#endif