Verified Commit 68f3d0a9 authored by Artem Sidyakin's avatar Artem Sidyakin
Browse files

Added 3 projects

- di
- commons
- api-opensource-org
parent 4c270263
# api-opensource-org
![api-opensource-org](/img/api-opensource-org.png "api-opensource-org screenshot")
<p>Application uses <a href='https://github.com/OpenSourceOrg/api/blob/master/doc/endpoints.md'>The Open Source API</a> to list all the licenses available and get information about each one.</p>
<p>Built with <a href='https://www.qt.io/ide/'>Qt Creator</a> 4.0.0 using <a href='https://www.qt.io/application-development/'>Qt</a> 5.6.0.</p>
\ No newline at end of file
TEMPLATE = app
QT += qml quick widgets
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
RC_ICONS = qt.ico
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
unix:!android {
isEmpty(target.path) {
qnx {
target.path = /tmp/$${TARGET}/bin
} else {
target.path = /opt/$${TARGET}/bin
}
export(target.path)
}
INSTALLS += target
}
export(INSTALLS)
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
ApplicationWindow {
visible: true
width: 640
minimumWidth: 500
height: 480
minimumHeight: 400
title: qsTr("api-opensource-org | Press F1 for help")
property string licensePlaceholder:
qsTr("Press <b>Refresh</b> to fill the licenses list and choose one.")
Component.onCompleted: {
console.log(qsTr("Application has started"));
}
// --- modal windows with progress bar ----------------------------------------------------------
Window {
id: progressBar
flags: Qt.FramelessWindowHint
modality: Qt.ApplicationModal
width: 200
height: 20
ProgressBar {
width: parent.width
height: parent.height
indeterminate: true
}
}
// ----------------------------------------------------------------------------------------------
// --- About window -----------------------------------------------------------------------------
Window {
id: aboutWindow
title: "About"
modality: Qt.ApplicationModal
width: 400
minimumWidth: 400
maximumWidth: 400
height: 250
minimumHeight: 250
maximumHeight: 250
ColumnLayout {
anchors.fill: parent
anchors.topMargin: 10
anchors.rightMargin: 10
anchors.leftMargin: 10
anchors.bottomMargin: 10
GridLayout {
id: gridInfo
anchors.fill: parent
rows: 3
columns: 2
Text { text: "Author:"; font.bold: true; }
Text {
id: email
text: "<a href=\"mailto:retifrav@gmail.com\">retifrav@gmail.com</a>";
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
cursorShape: email.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.NoButton
}
}
Text { text: "License:"; font.bold: true; }
Text {
id: license
text: "<a href='https://opensource.org/licenses/MIT'>MIT</a>"
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
cursorShape: license.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.NoButton
}
}
Text { text: "Source:"; font.bold: true; }
Text {
id: repository
text: "<a href='https://github.com/retifrav/api-opensource-org'>repository</a>"
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
cursorShape: repository.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.NoButton
}
}
}
Text {
id: aboutText
Layout.topMargin: 10
Layout.fillHeight: true
Layout.fillWidth: true
text: "<p>Application uses
<a href='https://github.com/OpenSourceOrg/api/blob/master/doc/endpoints.md'>The Open Source API</a>
to list all the licenses available and get information about each one.</p>
<p>Built with <a href='https://www.qt.io/ide/'>Qt Creator</a> 4.0.0 using
<a href='https://www.qt.io/application-development/'>Qt</a> 5.6.0.</p>"
wrapMode: Text.WordWrap
onLinkActivated: Qt.openUrlExternally(link)
MouseArea {
anchors.fill: parent
cursorShape: aboutText.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.NoButton
}
}
Button {
focus: true
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
text: "Ok"
onClicked: {
aboutWindow.close();
}
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
aboutWindow.close();
event.accepted = true;
}
}
}
}
}
// ----------------------------------------------------------------------------------------------
ColumnLayout {
anchors.fill: parent
anchors.margins: 5
focus: true
// show About window when F1 is pressed
Keys.onPressed: {
if (event.key === Qt.Key_F1) {
aboutWindow.show();
event.accepted = true;
}
}
RowLayout {
id: firstRow
anchors.top: parent.top
Label {
text: qsTr("License:")
// font.bold: true
}
ComboBox {
id: licensesList
Layout.fillWidth: true
textRole: "key"
model: ListModel {
id: licensesModel
}
signal selectionChanged(string id)
onCurrentIndexChanged: {
selectionChanged(licensesModel.get(currentIndex).value);
}
Component.onCompleted: {
licensesList.selectionChanged.connect(comboChanged)
}
}
Button {
text: qsTr("Refresh")
onClicked: {
licensesModel.clear();
request('https://api.opensource.org/licenses/', function (o) {
// log the json response
//console.log(o.responseText);
showBusy(false);
if (o.status === 200)
{
// translate response into object
var jsn = JSON.parse(o.responseText);
licensesModel.append({"key": ""});
for(var i = 0; i < jsn.length; i++) {
licensesModel.append({"key": jsn[i].name, "value": jsn[i].id});
}
}
else
{
licenseContent.text = "Some error while getting list of licences";
}
});
}
}
}
TextArea {
id: licenseContent
anchors.top: firstRow.bottom
anchors.topMargin: 5
Layout.fillWidth: true
Layout.fillHeight: true
text: licensePlaceholder
textFormat: Text.RichText
}
}
// --- functions --------------------------------------------------------------------------------
// HTTP-request to the URL
function request(url, callback) {
showBusy(true);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = (function(myxhr) {
return function() {
// if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED)
// {
// console.log("[Headers]");
// console.log(xhr.getAllResponseHeaders ());
// console.log("[Last modified]");
// console.log(xhr.getResponseHeader("Last-Modified"));
// console.log("---");
// }
if(myxhr.readyState === 4) { callback(myxhr); }
}
})(xhr);
xhr.open('GET', url);
xhr.send();
}
// when license from the list got selected
function comboChanged(id) {
if (id === "") {
licenseContent.text = licensePlaceholder;
return;
}
request('https://api.opensource.org/license/' + id, function (o) {
// var jsn = JSON.parse(o.responseText);
// for(var i = 0; i < jsn.length; i++) {
// licensesList.model.append({"text": jsn[i].name});
// }
if (o.readyState === 4)
{
showBusy(false);
if (o.status === 200)
{
licenseContent.text = o.responseText;
}
else
{
licenseContent.text = "Some error while getting info about license with ID " + id;
}
}
});
}
// show or hide progress bar window
function showBusy(is) {
if (is === true) {
progressBar.visible = true;
console.log("request started");
}
else {
progressBar.visible = false;
console.log("request done");
}
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/">
<file>fonts/Pacifico.ttf</file>
<file>fonts/TitilliumWeb-Regular.ttf</file>
</qresource>
</RCC>
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp \
trans.cpp
HEADERS += \
trans.h
FORMS = pages/*.ui.qml
RESOURCES += qml.qrc \
fonts.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
lupdate_only {
SOURCES = pages/*.qml
}
TRANSLATIONS = i18n/general-demos_de.ts \
i18n/general-demos_no.ts \
i18n/general-demos_ru.ts
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
<name>Translation</name>
<message>
<location filename="../pages/Translation.qml" line="206"/>
<source>A block of text to be translated into other languages. The actual strings are encapsulated into &lt;font color=&apos;blue&apos;&gt;qsTr()&lt;/font&gt; function, that marks them as targets for translation.</source>
<translation>Ein textblock, der in andere sprachen übersetzt werden soll. Die tatsächlichen Zeichenfolgen sind in die Funktion &lt;font color=&apos;blue&apos;&gt;qsTr()&lt;/font&gt; eingekapselt, die sie als Ziele für die Übersetzung markiert.</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="215"/>
<source>After running a special tool all that strings will form a translations file that can be openned in &lt;b&gt;Qt Linguist&lt;/b&gt; for creating translations.</source>
<translation>Nach dem ausführen eines speziellen tools werden alle diese zeichenfolgen eine übersetzungsdatei bilden, die in &lt;b&gt;Qt Linguist&lt;/b&gt; zum erstellen von übersetzungen.</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="223"/>
<source>Press any flag to &quot;&lt;i&gt;retranslate&lt;/i&gt;&quot; UI to the corresponding language.</source>
<translation>Drücken sie eine beliebige flagge, um UI in die entsprechende sprache zu &quot;&lt;i&gt;übersetzen&lt;/i&gt;&quot;.</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="228"/>
<source>Dummy button</source>
<translation>Dummy taste</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="229"/>
<source>Some output into console</source>
<translation>Einige ausgabe in die konsole</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="232"/>
<source>Some tooltip</source>
<translation>Einige tooltips</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="248"/>
<source>apple</source>
<translation>apfel</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="249"/>
<source>orange</source>
<translation>apfelsine</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="250"/>
<source>banana</source>
<translation>banane</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="251"/>
<source>watermelon</source>
<translation>wassermelone</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="252"/>
<source>lemon</source>
<translation>zitrone</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="253"/>
<source>raspberry</source>
<translation>himbeere</translation>
</message>
</context>
</TS>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="nb_NO">
<context>
<name>Translation</name>
<message>
<location filename="../pages/Translation.qml" line="206"/>
<source>A block of text to be translated into other languages. The actual strings are encapsulated into &lt;font color=&apos;blue&apos;&gt;qsTr()&lt;/font&gt; function, that marks them as targets for translation.</source>
<translation>En blokk med tekst som skal oversettes til andre språk. Selve strenger er innkapslet i &lt;font color=&apos;blue&apos;&gt;qsTr()&lt;/font&gt; funksjonen, som markerer dem som mål for oversettelse.</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="215"/>
<source>After running a special tool all that strings will form a translations file that can be openned in &lt;b&gt;Qt Linguist&lt;/b&gt; for creating translations.</source>
<translation>Etter å ha kjørt et spesielt verktøy alle som strenger vil danne et oversettelser fil som kan openned i &lt;b&gt;Qt Linguist&lt;/b&gt; for å lage oversettelser.</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="223"/>
<source>Press any flag to &quot;&lt;i&gt;retranslate&lt;/i&gt;&quot; UI to the corresponding language.</source>
<translation>Trykk en flagget for å &quot;&lt;i&gt;oversette&lt;/i&gt;&quot; UI til tilsvarende språk.</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="228"/>
<source>Dummy button</source>
<translation>Dummy knapp</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="229"/>
<source>Some output into console</source>
<translation>Noen utgang til konsollen</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="232"/>
<source>Some tooltip</source>
<translation>Noen verktøytips</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="248"/>
<source>apple</source>
<translation>eple</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="249"/>
<source>orange</source>
<translation>appelsin</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="250"/>
<source>banana</source>
<translation>banan</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="251"/>
<source>watermelon</source>
<translation type="unfinished">vannmelon</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="252"/>
<source>lemon</source>
<translation>sitron</translation>
</message>
<message>
<location filename="../pages/Translation.qml" line="253"/>
<source>raspberry</source>
<translation>bringebær</translation>
</message>
</context>
</TS>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ru_RU">
<context>
<name>Translation</name>
<message>
<location filename="pages/Translation.qml" line="206"/>
<source>A block of text to be translated into other languages. The actual strings are encapsulated into &lt;font color=&apos;blue&apos;&gt;qsTr()&lt;/font&gt; function, that marks them as targets for translation.</source>
<translation>Блок текста для перевода на другие языки. Эти строки находятся внутри функции &lt;font color=&apos;blue&apos;&gt;qsTr()&lt;/font&gt;, которая помечает их как цели для перевода.</translation>
</message>
<message>
<location filename="pages/Translation.qml" line="215"/>
<source>After running a special tool all that strings will form a translations file that can be openned in &lt;b&gt;Qt Linguist&lt;/b&gt; for creating translations.</source>
<translation>После запуска специальной программы, эти строки сформируют языковой файл, который может быть открыт в &lt;b&gt;Qt Linguist&lt;/b&gt; для перевода.</translation>
</message>
<message>
<location filename="pages/Translation.qml" line="223"/>
<source>Press any flag to &quot;&lt;i&gt;retranslate&lt;/i&gt;&quot; UI to the corresponding language.</source>
<translation>Нажмите на любой флаг, чтобы &quot;&lt;i&gt;перевести&lt;/i&gt;&quot; UI на соответствующий язык.</translation>
</message>
<message>
<location filename="pages/Translation.qml" line="228"/>
<source>Dummy button</source>
<translation>Простая кнопка</translation>
</message>
<message>
<location filename="pages/Translation.qml" line="229"/>
<source>Some output into console</source>
<translation>Такой-то вывод в консоль</translation>
</message>
<message>
<location filename="pages/Translation.qml" line="232"/>
<source>Some tooltip</source>
<translation>Такое-то всплывающее сообщение</translation>
</message>
<message>
<location filename="pages/Translation.qml" line="248"/>
<source>apple</source>
<translation>яблоко</translation>
</message>
<message>
<location filename="pages/Translation.qml" line="249"/>
<source>orange</source>
<translation>апельсин</translation>