Add files via upload

This commit is contained in:
Andrey 2022-02-18 17:32:14 +04:00 committed by GitHub
parent 96c00d6819
commit 32db1c1e43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 1904 additions and 0 deletions

32
QuteSample/QuteSample.pro Normal file
View file

@ -0,0 +1,32 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
TRANSLATIONS += \
QuteSample_ru_RU.ts
CONFIG += lrelease
CONFIG += embed_translations
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
pictures.qrc

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ru_RU">
<context>
<name>MainWindow</name>
<message>
<location filename="mainwindow.ui" line="14"/>
<source>MainWindow</source>
<translation>Окошечко</translation>
</message>
<message>
<location filename="mainwindow.ui" line="63"/>
<source>Name</source>
<translation>Имя</translation>
</message>
<message>
<location filename="mainwindow.ui" line="76"/>
<source>Birthday:</source>
<translation>Дата рождения:</translation>
</message>
<message>
<location filename="mainwindow.ui" line="102"/>
<source>I&apos;m a developer</source>
<translation>Я - разработчик</translation>
</message>
<message>
<location filename="mainwindow.ui" line="119"/>
<source>Start</source>
<translation>Старт</translation>
</message>
<message>
<location filename="mainwindow.ui" line="135"/>
<source>Wait: %p%</source>
<oldsource>Ждите: %p%</oldsource>
<translation>Ждите: %p%</translation>
</message>
<message>
<location filename="mainwindow.ui" line="146"/>
<source>Text result</source>
<translation>Текст</translation>
</message>
<message>
<location filename="mainwindow.ui" line="158"/>
<location filename="mainwindow.ui" line="196"/>
<source>TextLabel</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="202"/>
<source>Picture</source>
<translation>Картинка</translation>
</message>
<message>
<location filename="mainwindow.ui" line="234"/>
<source>File</source>
<translation>Файл</translation>
</message>
<message>
<location filename="mainwindow.ui" line="242"/>
<source>Options</source>
<translation>Опции</translation>
</message>
<message>
<location filename="mainwindow.ui" line="248"/>
<source>About</source>
<translation>Справка</translation>
</message>
<message>
<location filename="mainwindow.ui" line="259"/>
<source>Choose a config</source>
<translation>Выбрать конфиг</translation>
</message>
<message>
<location filename="mainwindow.ui" line="264"/>
<source>Exit</source>
<translation>Выход</translation>
</message>
<message>
<location filename="mainwindow.ui" line="267"/>
<source>Ctrl+Q</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="272"/>
<source>Application</source>
<translation>Приложение</translation>
</message>
<message>
<location filename="mainwindow.ui" line="277"/>
<source>Developer&apos;s GitHub</source>
<translation>GitHub разработчика</translation>
</message>
<message>
<location filename="mainwindow.ui" line="288"/>
<source>Random Picture</source>
<translation>Случайная картинка</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="35"/>
<source>Hello %1!</source>
<translation>Привет, %1!</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="36"/>
<source>Your next birthday is on: %2</source>
<oldsource>NextBirthday</oldsource>
<translation>Следующий др: %2</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="62"/>
<source>Just debug</source>
<translation>Просто отладка</translation>
</message>
</context>
</TS>

23
QuteSample/main.cpp Normal file
View file

@ -0,0 +1,23 @@
#include "mainwindow.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "QuteSample_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
app.installTranslator(&translator);
break;
}
}
MainWindow win;
win.show();
return app.exec();
}

98
QuteSample/mainwindow.cpp Normal file
View file

@ -0,0 +1,98 @@
#include <thread>
#include <chrono>
#include "QRandomGenerator"
#include "QDesktopServices"
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_plainTextEdit_2_textChanged()
{
//
}
void MainWindow::on_pushButton_clicked()
{
std::thread t1([&]()
{
ui->progressBar->setValue(25);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
ui->progressBar->setValue(50);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
ui->progressBar->setValue(75);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
ui->progressBar->setValue(100);
});
std::thread t2([&]()
{
// read
QString name = ui->plainTextEdit_2->toPlainText();
QDate birth = ui->dateEdit_2->date();
// compute
QDate next = QDate::currentDate();
next.setDate(next.year(), birth.month(), birth.day());
// strings
QString hello = tr("Hello %1!").arg(name);
QString nextb = tr("Your next birthday is on: %2").arg(next.toString());
// check if there are my data
bool namedev = (name.contains("Andre") or name.contains("Андрей"));
bool datedev = (birth.year() == 2009 and
birth.month() == 7 and
birth.day() == 13);
if (namedev and datedev)
ui->checkBox_2->setEnabled(true);
// print
ui->label_greeting->setText(hello);
ui->label_birthday->setText(nextb);
ui->lcdNumber->display(next.year() - birth.year());
// picture
if (ui->actionRandom_Picture->isChecked())
{
int randpic = -1;
if (!ui->checkBox_2->isChecked())
{
QRandomGenerator gen(random());
randpic = gen.bounded(1, 6);
}
QString tmpl = ":/prefix/pics/%1.jpg";
QString file = tmpl.arg(randpic);
QPixmap pixmap(file);
ui->label_image->setPixmap(pixmap.scaled(
ui->label_image->width(),
ui->label_image->height(),
Qt::KeepAspectRatio
)
);
}
});
t1.join();
t2.join();
}
void MainWindow::on_actionExit_triggered()
{
QApplication::exit(0);
}
void MainWindow::on_actionDeveloper_s_GitHub_triggered()
{
QDesktopServices::openUrl(QUrl("https://github.com/DarkCat09"));
}

30
QuteSample/mainwindow.h Normal file
View file

@ -0,0 +1,30 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
void on_plainTextEdit_2_textChanged();
void on_pushButton_clicked();
void on_actionExit_triggered();
void on_actionDeveloper_s_GitHub_triggered();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

300
QuteSample/mainwindow.ui Normal file
View file

@ -0,0 +1,300 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>626</width>
<height>451</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>611</width>
<height>411</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>572</width>
<height>51</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>15</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="placeholderText">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Birthday:</string>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="dateEdit_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>I'm a developer</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="value">
<number>0</number>
</property>
<property name="format">
<string>Wait: %p%</string>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Text result</string>
</attribute>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>561</width>
<height>73</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_greeting">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_birthday">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLCDNumber" name="lcdNumber">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="digitCount">
<number>3</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Picture</string>
</attribute>
<widget class="QLabel" name="label_image">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>321</width>
<height>241</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>626</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionChoose_a_config"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuOptions">
<property name="title">
<string>Options</string>
</property>
<addaction name="actionRandom_Picture"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
<string>About</string>
</property>
<addaction name="actionApplication"/>
<addaction name="actionDeveloper_s_GitHub"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuOptions"/>
<addaction name="menuAbout"/>
</widget>
<action name="actionChoose_a_config">
<property name="text">
<string>Choose a config</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionApplication">
<property name="text">
<string>Application</string>
</property>
</action>
<action name="actionDeveloper_s_GitHub">
<property name="text">
<string>Developer's GitHub</string>
</property>
</action>
<action name="actionRandom_Picture">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Random Picture</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

11
QuteSample/mythread.cpp Normal file
View file

@ -0,0 +1,11 @@
#include "mythread.h"
MyThread::MyThread()
: name(threadName)
{
}
void MyThread::run()
{
//
}

19
QuteSample/mythread.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include "QThread"
#include "QProgressBar"
class MyThread : public QThread
{
Q_OBJECT
public:
explicit MyThread(QObject *parent);
void run();
signals:
void progressChanged(int progress);
};
#endif // MYTHREAD_H

BIN
QuteSample/pics/-1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
QuteSample/pics/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

BIN
QuteSample/pics/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

BIN
QuteSample/pics/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
QuteSample/pics/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
QuteSample/pics/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

10
QuteSample/pictures.qrc Normal file
View file

@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/prefix">
<file>pics/1.jpg</file>
<file>pics/2.jpg</file>
<file>pics/3.jpg</file>
<file>pics/4.jpg</file>
<file>pics/5.jpg</file>
<file>pics/-1.jpg</file>
</qresource>
</RCC>