text
stringlengths 9
39.2M
| dir
stringlengths 25
226
| lang
stringclasses 163
values | created_date
timestamp[s] | updated_date
timestamp[s] | repo_name
stringclasses 751
values | repo_full_name
stringclasses 752
values | star
int64 1.01k
183k
| len_tokens
int64 1
18.5M
|
|---|---|---|---|---|---|---|---|---|
```unknown
<RCC>
<qresource prefix="/FontToPng">
<file>FontToPng.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/MakeGroup/FontToPng/qml/FontToPng.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 36
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "fonttopng.h"
// Qt lib import
#include <QFontDatabase>
#include <QPainter>
#include <QFileDialog>
#include <QJsonObject>
#include <QEventLoop>
#include <QtConcurrent>
#include <QDebug>
// JQLibrary import
#include "JQFile.h"
using namespace FontToPng;
Manage::Manage():
QQuickImageProvider( QQuickImageProvider::Image )
{ }
void Manage::begin()
{
QEventLoop eventLoop;
// eventLoop.exec();
QtConcurrent::run( [ this ](){ this->loadFont( "Elusive" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "FontAwesome" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "Foundation" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "GlyphiconsHalflings" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "IcoMoon" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "IconFont" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "Icons8" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "IconWorks" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "JustVector" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "MaterialDesign" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "Metrize" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "Mfglabs" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "OpenIconic" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "Socicon" ); } );
QtConcurrent::run( [ this ](){ this->loadFont( "Typicons" ); } );
QThreadPool threadPool;
threadPool.setMaxThreadCount( 1 );
QtConcurrent::run( &threadPool, [ &eventLoop, this ]()
{
QThreadPool::globalInstance()->waitForDone();
this->mutex_.lock();
std::sort(
this->fontPackages_.begin(),
this->fontPackages_.end(),
[]( const FontPackage &a, const FontPackage &b )
{
return a.fontName < b.fontName;
}
);
this->mutex_.unlock();
QMetaObject::invokeMethod( &eventLoop, "quit" );
} );
eventLoop.exec();
}
QJsonArray Manage::getCharList(const QString &familieName, const QString &searchKey)
{
QJsonArray result;
for ( const auto &fontPackage: fontPackages_ )
{
if ( ( familieName != fontPackage.fontName ) && ( familieName != QStringLiteral("\u6240\u6709\u5B57\u4F53\u96C6") ) ) { continue; }
for ( const auto &charPackage: fontPackage.charPackages )
{
if ( ( searchKey.isEmpty() ) ? ( false ) : ( !charPackage.name.contains( searchKey ) ) ) { continue; }
result.push_back( QJsonObject( { {
{ "familieName", fontPackage.familieName },
{ "charCode", QString::number( charPackage.code, 16 ).toUpper() },
{ "charName", charPackage.name },
{ "charPreviewUrl", QString( "image://FontToPngManage/CharPreview/%1/%2" ).
arg( fontPackage.familieName ).
arg( charPackage.code ) }
} } ) );
}
}
return result;
}
QString Manage::saveIcon(const QString &familieName, const QString &charCodeHexString, const int &pixelSize, const QString &color)
{
auto filePath = QFileDialog::getSaveFileName(
nullptr,
QStringLiteral( "" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ),
"*.png"
);
if ( filePath.isEmpty() ) { return "cancel"; }
if ( !filePath.toLower().endsWith( ".png" ) )
{
filePath += ".png";
}
CharPackage charPackage;
for ( const auto &fontPackage: fontPackages_ )
{
if ( familieName != fontPackage.familieName ) { continue; }
const auto &&charCode = charCodeHexString.toInt( nullptr, 16 );
if ( !fontPackage.charPackages.contains( charCode ) ) { return "error"; }
charPackage = fontPackage.charPackages[ charCode ];
}
if ( !charPackage.code ) { return "error"; }
const auto &&image = this->paintChar( familieName, charPackage, QColor( color ), QSizeF( pixelSize, pixelSize ), QSizeF( pixelSize, pixelSize ), true );
const auto &&saveSucceed = image.save( filePath, "PNG" );
return ( saveSucceed ) ? ( "OK" ) : ( "error" );
}
void Manage::loadFont(const QString fontName)
{
FontPackage fontPackage;
fontPackage.fontName = fontName;
fontPackage.ttfFilePath = QString( ":/%1/%1.ttf" ).arg( fontName );
fontPackage.txtFilePath = QString( ":/%1/%1.txt" ).arg( fontName );
auto fontId = QFontDatabase::addApplicationFont( fontPackage.ttfFilePath );
fontPackage.fontId = fontId;
fontPackage.familieName = QFontDatabase::applicationFontFamilies( fontId ).first();
auto txtData = JQFile::readFile( fontPackage.txtFilePath );
if ( !txtData.first ) { return; }
auto txtLines = txtData.second.split( '\n' );
for ( const auto &line: txtLines )
{
CharPackage charPackage;
auto data = line.split( ':' );
if ( data.size() != 2 ) { continue; }
charPackage.code = data.first().toUShort( nullptr, 16 );
charPackage.name = data.last();
if ( !charPackage.code ) { continue; }
this->makeAdaptation( fontPackage.familieName, charPackage );
charPackage.preview = this->paintChar( fontPackage.familieName, charPackage, "#000000", { 60, 60 }, { 60, 60 }, false );
fontPackage.charPackages[ charPackage.code ] = charPackage;
}
mutex_.lock();
fontPackages_.push_back( fontPackage );
mutex_.unlock();
}
QImage Manage::paintChar(const QString &familieName, const CharPackage &charPackage, const QColor &color, const QSizeF &charSize, const QSizeF &backgroundSize, const bool &moreProcess)
{
QPainter patiner;
QImage image( backgroundSize.toSize(), QImage::Format_ARGB32 );
memset( image.bits(), 0x0, image.width() * image.height() * 4 );
if ( !patiner.begin( &image ) ) { return image; }
QFont font( familieName );
font.setPixelSize( qMin( charSize.width(), charSize.height() ) * charPackage.charAdaptation.scale );
QColor backgroundColor = color;
backgroundColor.setAlpha( 1 );
if ( moreProcess )
{
patiner.setBrush( QBrush( backgroundColor ) );
patiner.setPen( QPen( QColor( "#00000000" ) ) );
patiner.drawRect( 0, 0, image.width(), image.height() );
}
patiner.setFont( font );
patiner.setPen( QPen( color ) );
patiner.drawText(
image.width() * charPackage.charAdaptation.xOffset,
image.height() * charPackage.charAdaptation.yOffset,
image.width(),
image.height(),
Qt::AlignCenter,
QString( QChar( charPackage.code ) )
);
if ( moreProcess )
{
for ( auto y = 0; y < image.height(); ++y )
{
for ( auto x = 0; x < image.width(); ++x )
{
if ( image.pixelColor( x, y ) == backgroundColor )
{
image.setPixelColor( x, y, QColor( "#00000000" ) );
}
}
}
}
return image;
}
void Manage::makeAdaptation(const QString &familieName, CharPackage &charPackage)
{
QSizeF charSize( 400, 400 );
QSizeF backgroundSize( 500, 500 );
auto referenceImage = this->paintChar( familieName, charPackage, { "#000000" }, charSize, backgroundSize, false );
qreal xStart = -1;
qreal xEnd = backgroundSize.width();
qreal yStart = -1;
qreal yEnd = backgroundSize.height();
for ( auto x = 0; ( x < backgroundSize.width() ) && ( xStart == -1 ); ++x)
{
for ( auto y = 0; ( y < backgroundSize.height() ) && ( xStart == -1 ); ++y)
{
if ( referenceImage.pixel( x, y ) )
{
xStart = x;
break;
}
}
}
for ( auto x = backgroundSize.width() - 1; ( x >= 0 ) && ( xEnd == backgroundSize.width() ); --x)
{
for ( auto y = 0; ( y < backgroundSize.height() ) && ( xEnd == backgroundSize.width() ); ++y)
{
if ( referenceImage.pixel( x, y ) )
{
xEnd = x;
break;
}
}
}
for ( auto y = 0; ( y < backgroundSize.height() ) && ( yStart == -1 ); y++ )
{
for ( auto x = 0; ( x < backgroundSize.width() ) && ( yStart == -1 ); x++ )
{
if ( referenceImage.pixel( x, y ) )
{
yStart = y;
break;
}
}
}
for ( auto y = backgroundSize.height() - 1; ( y >= 0 ) && ( yEnd == backgroundSize.height() ); --y )
{
for ( auto x = 0; ( x < backgroundSize.width() ) && ( yEnd == backgroundSize.height() ); ++x )
{
if ( referenceImage.pixel( x, y ) )
{
yEnd = y;
break;
}
}
}
charPackage.charAdaptation.xOffset = ( backgroundSize.width() - xEnd - xStart ) / charSize.width() / 2.0;
charPackage.charAdaptation.yOffset = ( backgroundSize.height() - yEnd - yStart ) / charSize.width() / 2.0;
if ( ( xEnd - xStart ) > ( charSize.width() * 0.85 ) )
{
if ( ( ( yEnd - yStart ) > ( charSize.width() * 0.85 ) ) && ( ( yEnd - yStart ) > ( xEnd - xStart ) ) )
{
charPackage.charAdaptation.scale = ( charSize.width() * 0.85 ) / ( yEnd - yStart );
charPackage.charAdaptation.xOffset *= charPackage.charAdaptation.scale;
charPackage.charAdaptation.yOffset *= charPackage.charAdaptation.scale;
}
else
{
charPackage.charAdaptation.scale = ( charSize.width() * 0.85 ) / ( xEnd - xStart );
charPackage.charAdaptation.xOffset *= charPackage.charAdaptation.scale;
charPackage.charAdaptation.yOffset *= charPackage.charAdaptation.scale;
}
}
if ( ( charPackage.charAdaptation.xOffset >= -0.0015 ) && ( charPackage.charAdaptation.xOffset <= 0.0015 ) ) { charPackage.charAdaptation.xOffset = 0; }
if ( ( charPackage.charAdaptation.yOffset >= -0.0015 ) && ( charPackage.charAdaptation.yOffset <= 0.0015 ) ) { charPackage.charAdaptation.yOffset = 0; }
if ( charPackage.charAdaptation.xOffset >= 0.9985 ) { charPackage.charAdaptation.xOffset = 1; }
if ( charPackage.charAdaptation.xOffset <= -0.9985 ) { charPackage.charAdaptation.xOffset = -1; }
if ( charPackage.charAdaptation.yOffset >= 0.9985 ) { charPackage.charAdaptation.yOffset = 1; }
if ( charPackage.charAdaptation.yOffset <= -0.9985 ) { charPackage.charAdaptation.yOffset = -1; }
}
QImage Manage::requestImage(const QString &id, QSize *, const QSize &)
{
auto datas = id.split( '/' );
if ( datas.size() < 3 ) { return { }; }
auto mode = datas.first();
if ( mode == "CharPreview" )
{
auto familieName = datas.at( 1 );
for ( const auto &fontPackage: fontPackages_ )
{
if ( familieName != fontPackage.familieName ) { continue; }
auto charCode = datas.at( 2 ).toUShort();
if ( !fontPackage.charPackages.contains( charCode ) ) { return { }; }
return fontPackage.charPackages[ charCode ].preview;
}
}
return { };
}
```
|
/content/code_sandbox/components/MakeGroup/FontToPng/cpp/fonttopng.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 3,044
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/fonttopng.h
SOURCES *= \
$$PWD/cpp/fonttopng.cpp
RESOURCES *= \
$$PWD/qml/FontToPng.qrc \
$$PWD/Resource/Font/FontToPngFont.qrc
```
|
/content/code_sandbox/components/MakeGroup/FontToPng/FontToPng.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 114
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
include( $$PWD/library/JQLibrary/JQLibrary.pri )
include( $$PWD/library/JQLibrary/JQQRCodeReader.pri )
include( $$PWD/library/JQLibrary/JQQRCodeWriter.pri )
include( $$PWD/library/JQLibrary/JQZopfli.pri )
mac {
include( $$PWD/library/JQLibrary/JQGuetzli.pri )
}
```
|
/content/code_sandbox/JQLibraryImport.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 130
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef __CPP_JQTOOLS_MANAGE_HPP__
#define __CPP_JQTOOLS_MANAGE_HPP__
// Qt ib import
#include <QObject>
#include <QEventLoop>
// JQToolsLibrary import
#include <JQToolsLibrary>
class JQToolsManage: public AbstractTool
{
Q_OBJECT
public:
JQToolsManage() = default;
~JQToolsManage() = default;
};
#endif//__CPP_JQTOOLS_MANAGE_HPP__
```
|
/content/code_sandbox/cpp/jqtools_manage.hpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 135
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef MAKEGROUP_MAKEGROUP_H_
#define MAKEGROUP_MAKEGROUP_H_
// MakeGroup lib import
#include <IconMaker>
#include <FontToPng>
#include <QRCodeMaker>
#include <BarcodeMaker>
#include <WebPMaker>
#define MAKEGROUP_INITIALIZA \
ICONMAKER_INITIALIZA; \
FONTTOPNG_INITIALIZA; \
QRCODEMAKER_INITIALIZA; \
BARCODEMAKER_INITIALIZA; \
WEBPMAKER_INITIALIZA;
#endif//MAKEGROUP_MAKEGROUP_H_
```
|
/content/code_sandbox/components/MakeGroup/makegroup.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 144
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "fonttopng.h"
```
|
/content/code_sandbox/components/MakeGroup/FontToPng/cpp/FontToPng
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 45
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/iconmaker.h
SOURCES *= \
$$PWD/cpp/iconmaker.cpp
RESOURCES *= \
$$PWD/qml/IconMaker.qrc \
$$PWD/Image/IconMakerImage.qrc
```
|
/content/code_sandbox/components/MakeGroup/IconMaker/IconMaker.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 105
|
```unknown
<RCC>
<qresource prefix="/IconMaker">
<file>Background.jpg</file>
<file>DefaultIcon.png</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/MakeGroup/IconMaker/Image/IconMakerImage.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 41
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
Item {
id: fontToPng
width: 620
height: 540
clip: true
function refresh() {
var charList = FontToPngManage.getCharList( menuFieldForFamilieName.selectedText, textFieldForSearchKey.text );
listModel.clear();
for ( var index = 0; index < charList.length; ++index )
{
listModel.append( {
familieName: charList[ index ][ "familieName" ],
charCode: charList[ index ][ "charCode" ],
charName: charList[ index ][ "charName" ],
charPreviewUrl: charList[ index ][ "charPreviewUrl" ]
} );
}
labelForIconCount.iconCount = charList.length;
}
Component.onCompleted: {
timerForBegin.start();
}
Timer {
id: timerForBegin
interval: 50
repeat: false
onTriggered: {
materialUI.showLoading( "" );
FontToPngManage.begin();
fontToPng.refresh();
materialUI.hideLoading();
}
}
RectangularGlow {
z: -1
width: parent.width
height: 80
glowRadius: 5
spread: 0.22
color: "#30000000"
cornerRadius: 3
}
Rectangle {
z: 1
width: parent.width
height: 80
color: "#fafafa"
MaterialLabel {
x: 22
y: 34
text: ""
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignRight
}
MaterialMenuField {
id: menuFieldForFamilieName
x: 90
y: 15
width: 200
maxVisibleItems: 5
model: [
"",
"Elusive",
"FontAwesome",
"Foundation",
"GlyphiconsHalflings",
"IcoMoon",
"IconFont",
"Icons8",
"IconWorks",
"JustVector",
"MaterialDesign",
"Metrize",
"Mfglabs",
"OpenIconic",
"Socicon",
"Typicons"
]
onSelectedTextChanged: fontToPng.refresh();
}
MaterialTextField {
id: textFieldForSearchKey
x: 310
y: -7
width: 150
height: 56
placeholderText: ""
property bool isChenged: false
onTextChanged: {
isChenged = true;
}
onEditingFinished: {
if ( isChenged )
{
isChenged = false;
fontToPng.refresh();
}
}
}
MaterialLabel {
id: labelForIconCount
anchors.right: parent.right
anchors.rightMargin: 5
anchors.bottom: parent.bottom
anchors.bottomMargin: 5
color: "#a1a1a1"
text: "" + iconCount
property int iconCount: 0
}
}
GridView {
x: ( parent.width % 86 ) / 2
y: 80
width: parent.width
height: parent.height - y
cellWidth: 86
cellHeight: 106
clip: true
model: ListModel {
id: listModel
}
delegate: Rectangle {
id: rectanglrForChar
width: 86
height: 106
color: "#00000000"
Behavior on color { ColorAnimation { duration: 100 } }
Image {
id: imageForChar
x: 13
y: 2
width: 60
height: 60
source: charPreviewUrl
}
MaterialLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 25
width: parent.width - 4
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: charName
elide: Text.ElideRight
font.pixelSize: 14
}
MaterialLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: "(\\u" + charCode + ")"
font.pixelSize: 14
color: "#818181"
}
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 5
width: parent.width - 8
height: 1
color: "#a1a1a1"
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: true
onEntered: {
rectanglrForChar.color = "#33a1a1a1"
}
onExited: {
rectanglrForChar.color = "#00000000"
}
onClicked: {
if ( mouse.button & Qt.LeftButton )
{
backgroundForDialog.opacity = 1.0;
dialogForSaveIcon.familieName = familieName;
dialogForSaveIcon.charCode = charCode;
dialogForSaveIcon.charName = charName;
dialogForSaveIcon.open();
}
else if ( mouse.button & Qt.RightButton )
{
FontToPngManage.setClipboardText( "\\u" + charCode );
materialUI.showSnackbarMessage( "" );
}
}
}
}
header: Item {
width: 1
height: 10
}
}
Rectangle {
id: backgroundForDialog
z: 10
anchors.fill: parent
color: "#55000000"
visible: opacity !== 0
opacity: 0
Behavior on opacity {
NumberAnimation { duration: 500; easing.type: Easing.OutCubic }
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.AllButtons
}
}
MaterialDialog {
id: dialogForSaveIcon
z: 10
width: 350
height: 440
title: ""
negativeButtonText: materialUI.dialogCancelText
positiveButtonText: materialUI.dialogOKText
property string familieName
property string charCode
property string charName
onRejected: {
backgroundForDialog.opacity = 0;
}
onAccepted: {
backgroundForDialog.opacity = 0;
materialUI.showLoading();
var reply = FontToPngManage.saveIcon(
dialogForSaveIcon.familieName,
dialogForSaveIcon.charCode,
parseInt( labelForSize.text ),
textFieldForColor.text
);
materialUI.hideLoading();
switch ( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "error": materialUI.showSnackbarMessage( "" ); break;
case "OK": materialUI.showSnackbarMessage( "" ); break;
default: break;
}
}
Item {
width: 300
height: 320
MaterialLabel {
x: 28
y: 10
text: ""
font.pixelSize: 16
}
MaterialLabel {
id: labelForFamilieName
x: 100
y: 13
width: 120
height: 56
text: dialogForSaveIcon.familieName
}
MaterialLabel {
x: 28
y: 72
text: ""
font.pixelSize: 16
}
MaterialLabel {
id: labelForCharCode
x: 115
y: 75
width: 120
height: 56
text: "\\u" + dialogForSaveIcon.charCode
}
MaterialLabel {
x: 28
y: 133
text: ""
font.pixelSize: 16
}
MaterialLabel {
id: labelForCharName
x: 115
y: 137
width: 120
height: 56
text: dialogForSaveIcon.charName
}
MaterialLabel {
x: 28
y: 196
text: ""
font.pixelSize: 16
}
MaterialTextField {
id: labelForSize
x: 145
y: 157
width: 120
height: 56
text: "1000"
validator: RegExpValidator { regExp: /^(-?\d+)$/ }
}
MaterialLabel {
x: 28
y: 258
text: ""
font.pixelSize: 16
}
MaterialTextField {
id: textFieldForColor
x: 82
y: 220
width: 150
placeholderText: ""
text: "#000000"
}
}
}
}
```
|
/content/code_sandbox/components/MakeGroup/FontToPng/qml/FontToPng.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,086
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "iconmaker.h"
```
|
/content/code_sandbox/components/MakeGroup/IconMaker/cpp/IconMaker
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 44
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_MAKEGROUP_ICONMAKER_CPP_ICONMAKER_H_
#define GROUP_MAKEGROUP_ICONMAKER_CPP_ICONMAKER_H_
// Qt lib import
#include <QImage>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define ICONMAKER_INITIALIZA \
{ \
qmlRegisterType<IconMaker::Manage>("IconMaker", 1, 0, "IconMakerManage"); \
}
namespace IconMaker
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage();
~Manage() = default;
public slots:
inline QString targetSavePath() const { return targetSavePath_; }
inline QString sourceIconFilePath() const { return sourceIconFilePath_; }
inline int sourceIconImageWidht() const { return sourceIconImage_.width(); }
inline int sourceIconImageHeight() const { return sourceIconImage_.height(); }
QString chooseTargetSavePath();
QString choostSourceIconFilePath();
QString makeAll();
QString makeOSX();
QString makeIOS();
QString makeWindows();
QString makeWP();
QString makeAndroid();
QString makePWA();
private:
void realMakeOSX();
void realMakeIOS();
void realMakeWindows();
void realMakeWP();
void realMakeAndroid();
void realMakePWA();
void saveToIco(const QString &targetFilePath, const QSize &size);
void saveToPng(const QString &targetFilePath, const QSize &size);
void saveToEmptyPng(const QString &targetFilePath, const QSize &size);
void saveToJpg(const QString &targetFilePath, const QSize &size);
signals:
void targetSavePathChanged();
void sourceIconFilePathChanged();
private:
QString targetSavePath_;
QString sourceIconFilePath_;
QImage sourceIconImage_;
};
}
#endif//GROUP_MAKEGROUP_ICONMAKER_CPP_ICONMAKER_H_
```
|
/content/code_sandbox/components/MakeGroup/IconMaker/cpp/iconmaker.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 447
|
```unknown
<RCC>
<qresource prefix="/IconMaker">
<file>IconMaker.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/MakeGroup/IconMaker/qml/IconMaker.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 32
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import "qrc:/MaterialUI/Interface/"
import IconMaker 1.0
Item {
id: iconMaker
width: 620
height: 540
function makeReplyProcessor( reply )
{
switch( reply )
{
case "saveToFileError": materialUI.showSnackbarMessage( "" ); break;
case "OK": materialUI.showSnackbarMessage( "" ); break;
}
}
IconMakerManage {
id: iconMakerManage
onTargetSavePathChanged: {
labelForTargetSavePath.targetSavePath = iconMakerManage.targetSavePath();
}
onSourceIconFilePathChanged: {
labelForSourceFilePath.sourceIconFilePath = iconMakerManage.sourceIconFilePath();
labelForSourceIconImageWidht.sourceIconImageWidht = iconMakerManage.sourceIconImageWidht();
labelForTargetIconImageWidht.sourceIconImageHeight = iconMakerManage.sourceIconImageHeight();
imageForIcon.source = "file:/" + iconMakerManage.sourceIconFilePath();
}
}
Item {
id: centerItem
anchors.centerIn: parent
width: 640
height: 430
MaterialLabel {
id: labelForTargetSavePath
x: 49
y: 60
width: 400
text: "" + targetSavePath
elide: Text.ElideLeft
property string targetSavePath: iconMakerManage.targetSavePath()
}
MaterialLabel {
id: labelForSourceFilePath
x: 49
y: 86
width: 400
text: "" + sourceIconFilePath
elide: Text.ElideLeft
property string sourceIconFilePath: ""
}
MaterialLabel {
id: labelForSourceIconImageWidht
x: 49
y: 112
text: "" + sourceIconImageWidht
property string sourceIconImageWidht: ""
}
MaterialLabel {
id: labelForTargetIconImageWidht
x: 49
y: 138
text: "" + sourceIconImageHeight
property string sourceIconImageHeight: ""
}
MaterialButton {
x: 279
y: 208
width: 120
height: 40
text: ""
backgroundColor: "#2196f3"
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.choostSourceIconFilePath();
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "OK": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
MaterialButton {
x: 279
y: 291
width: 120
height: 40
text: ""
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.chooseTargetSavePath();
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "openFail": materialUI.showSnackbarMessage( "" ); break;
case "OK": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
MaterialButton {
x: 476
y: 65
width: 120
height: 40
text: ""
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.makeAll();
iconMaker.makeReplyProcessor( reply );
materialUI.hideLoading();
}
}
MaterialButton {
x: 476
y: 121
width: 120
height: 40
text: "OS X(icns)"
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.makeOSX();
iconMaker.makeReplyProcessor( reply );
materialUI.hideLoading();
}
}
MaterialButton {
x: 476
y: 167
width: 120
height: 40
text: "iOS(png)"
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.makeIOS();
iconMaker.makeReplyProcessor( reply );
materialUI.hideLoading();
}
}
MaterialButton {
x: 476
y: 223
width: 120
height: 40
text: "Windows(png)"
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.makeWindows();
iconMaker.makeReplyProcessor( reply );
materialUI.hideLoading();
}
}
MaterialButton {
x: 476
y: 269
width: 120
height: 40
text: "WP(png)"
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.makeWP();
iconMaker.makeReplyProcessor( reply );
materialUI.hideLoading();
}
}
MaterialButton {
x: 476
y: 325
width: 120
height: 40
text: "Android(png)"
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.makeAndroid();
iconMaker.makeReplyProcessor( reply );
materialUI.hideLoading();
}
}
MaterialButton {
x: 476
y: 382
width: 120
height: 40
text: "PWA(png)"
onClicked: {
materialUI.showLoading();
var reply = iconMakerManage.makePWA();
iconMaker.makeReplyProcessor( reply );
materialUI.hideLoading();
}
}
MaterialLabel {
x: 98
y: 182
text: ""
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
Rectangle {
x: 49
y: 208
width: 162
height: 162
color: "#00000000"
border.color: "#000000"
border.width: 1
Image {
x: 1
y: 1
z: -1
width: 160
height: 160
source: "qrc:/IconMaker/Background.jpg"
}
Image {
id: imageForIcon
x: 1
y: 1
z: -1
width: 160
height: 160
source: "qrc:/IconMaker/DefaultIcon.png"
}
}
}
}
```
|
/content/code_sandbox/components/MakeGroup/IconMaker/qml/IconMaker.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,493
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/barcodemaker.h
SOURCES *= \
$$PWD/cpp/barcodemaker.cpp
RESOURCES *= \
$$PWD/qml/BarcodeMakerQml.qrc
```
|
/content/code_sandbox/components/MakeGroup/BarcodeMaker/BarcodeMaker.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 98
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "iconmaker.h"
// Qt lib import
#include <QImage>
#include <QFileDialog>
#include <QStandardPaths>
#include <QtConcurrent>
using namespace IconMaker;
Manage::Manage()
{
targetSavePath_ = QStandardPaths::writableLocation( QStandardPaths::DesktopLocation );
sourceIconImage_.load( ":/IconMaker/DefaultIcon.png" );
}
QString Manage::chooseTargetSavePath()
{
const auto &&targetSavePath = QFileDialog::getExistingDirectory( nullptr, "\u8BF7\u9009\u62E9\u4FDD\u5B58\u8DEF\u5F84", QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ) );
if ( targetSavePath.isEmpty() ) { return "cancel"; }
targetSavePath_ = targetSavePath;
emit targetSavePathChanged();
return "OK";
}
QString Manage::choostSourceIconFilePath()
{
const auto &&sourceIconFilePath = QFileDialog::getOpenFileName(
nullptr,
"\u8BF7\u9009\u62E9\u56FE\u6807\u6587\u4EF6",
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ),
"*.png *.jpg *.jpeg *.bmp" );
if ( sourceIconFilePath.isEmpty() ) { return "cancel"; }
QImage sourceIconImage;
if ( !sourceIconImage.load( sourceIconFilePath ) ) { return "openFail"; }
sourceIconFilePath_ = sourceIconFilePath;
sourceIconImage_ = sourceIconImage;
emit sourceIconFilePathChanged();
return "OK";
}
QString Manage::makeAll()
{
QEventLoop eventLoop;
QString reply;
QtConcurrent::run( [ this, &eventLoop, &reply ]()
{
try
{
this->realMakeOSX();
this->realMakeIOS();
this->realMakeWindows();
this->realMakeWP();
this->realMakeAndroid();
}
catch(const bool &)
{
reply = "saveToFileError";
eventLoop.quit();
}
reply = "OK";
eventLoop.quit();
} );
eventLoop.exec();
return reply;
}
QString Manage::makeOSX()
{
QEventLoop eventLoop;
QString reply;
QtConcurrent::run( [ this, &eventLoop, &reply ]()
{
try
{
this->realMakeOSX();
}
catch(const bool &)
{
reply = "saveToFileError";
eventLoop.quit();
}
reply = "OK";
eventLoop.quit();
} );
eventLoop.exec();
return reply;
}
QString Manage::makeIOS()
{
QEventLoop eventLoop;
QString reply;
QtConcurrent::run( [ this, &eventLoop, &reply ]()
{
try
{
this->realMakeIOS();
}
catch(const bool &)
{
reply = "saveToFileError";
eventLoop.quit();
}
reply = "OK";
eventLoop.quit();
} );
eventLoop.exec();
return reply;
}
QString Manage::makeWindows()
{
QEventLoop eventLoop;
QString reply;
QtConcurrent::run( [ =, &eventLoop, &reply ]()
{
try
{
this->realMakeWindows();
}
catch(const bool &)
{
reply = "saveToFileError";
eventLoop.quit();
}
reply = "OK";
eventLoop.quit();
} );
eventLoop.exec();
return reply;
}
QString Manage::makeWP()
{
QEventLoop eventLoop;
QString reply;
QtConcurrent::run( [ this, &eventLoop, &reply ]()
{
try
{
this->realMakeWP();
}
catch(const bool &)
{
reply = "saveToFileError";
eventLoop.quit();
}
reply = "OK";
eventLoop.quit();
} );
eventLoop.exec();
return reply;
}
QString Manage::makeAndroid()
{
QEventLoop eventLoop;
QString reply;
QtConcurrent::run( [ this, &eventLoop, &reply ]()
{
try
{
this->realMakeAndroid();
}
catch(const bool &)
{
reply = "saveToFileError";
eventLoop.quit();
}
reply = "OK";
eventLoop.quit();
} );
eventLoop.exec();
return reply;
}
QString Manage::makePWA()
{
QEventLoop eventLoop;
QString reply;
QtConcurrent::run( [ this, &eventLoop, &reply ]()
{
try
{
this->realMakePWA();
}
catch(const bool &)
{
reply = "saveToFileError";
eventLoop.quit();
}
reply = "OK";
eventLoop.quit();
} );
eventLoop.exec();
return reply;
}
void Manage::realMakeOSX()
{
if ( !QDir().mkpath( targetSavePath_ + "/OSX/icon.iconset" ) )
{
throw false;
}
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_16x16.png", { 16, 16 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_16x16@2x.png", { 32, 32 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_32x32.png", { 32, 32 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_32x32@2x.png", { 64, 64 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_128x128.png", { 128, 128 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_128x128@2x.png", { 256, 256 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_256x256.png", { 256, 256 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_256x256@2x.png", { 512, 512 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_512x512.png", { 512, 512 } );
this->saveToPng( targetSavePath_ + "/OSX/icon.iconset/icon_512x512@2x.png", { 1024, 1024 } );
#ifdef Q_OS_MAC
system( QString( "iconutil -c icns " + QString( targetSavePath_.replace( ' ', "\\ " ) + "/OSX/icon.iconset" ) ).toUtf8().data() );
#endif
}
void Manage::realMakeIOS()
{
if ( !QDir().mkpath( targetSavePath_ + "/iOS" ) )
{
throw false;
}
this->saveToPng( targetSavePath_ + "/iOS/icon_29x29.png", { 29, 29 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_29x29@2x.png", { 58, 58 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_29x29@3x.png", { 87, 87 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_40x40.png", { 40, 40 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_40x40@2x.png", { 80, 80 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_40x40@3x.png", { 120, 120 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_50x50.png", { 50, 50 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_50x50@2x.png", { 100, 100 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_57x57.png", { 57, 57 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_57x57@2x.png", { 114, 114 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_60x60@2x.png", { 120, 120 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_60x60@3x.png", { 180, 180 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_72x72.png", { 72, 72 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_72x72@2x.png", { 144, 144 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_76x76.png", { 76, 76 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_76x76@2x.png", { 152, 152 } );
this->saveToPng( targetSavePath_ + "/iOS/icon_83.5x83.5@2x.png",{ 167, 167 } );
this->saveToJpg( targetSavePath_ + "/iOS/icon_1024x1024.jpg", { 1024, 1024 } );
this->saveToEmptyPng( targetSavePath_ + "/iOS/LaunchImage_2x_640x960.png", { 640, 960 } );
this->saveToEmptyPng( targetSavePath_ + "/iOS/LaunchImage_R4_640x1136.png", { 640, 1136 } );
this->saveToEmptyPng( targetSavePath_ + "/iOS/LaunchImage_R4.7_750x1334.png", { 750, 1334 } );
this->saveToEmptyPng( targetSavePath_ + "/iOS/LaunchImage_R5.5_1242x2208.png", { 1242, 2208 } );
this->saveToEmptyPng( targetSavePath_ + "/iOS/LaunchImage_iPad_Portrait_1536x2048.png", { 1536, 2048 } );
this->saveToEmptyPng( targetSavePath_ + "/iOS/LaunchImage_iPad_Landscape_2048x1536.png", { 2048, 1536 } );
}
void Manage::realMakeWindows() // TODO
{
if ( !QDir().mkpath( targetSavePath_ + "/Windows" ) )
{
throw false;
}
this->saveToPng( targetSavePath_ + "/Windows/icon_16.png", { 16, 16 } );
this->saveToPng( targetSavePath_ + "/Windows/icon_24.png", { 24, 24 } );
this->saveToPng( targetSavePath_ + "/Windows/icon_32.png", { 32, 32 } );
this->saveToPng( targetSavePath_ + "/Windows/icon_48.png", { 48, 48 } );
this->saveToPng( targetSavePath_ + "/Windows/icon_64.png", { 64, 64 } );
this->saveToPng( targetSavePath_ + "/Windows/icon_256.png", { 256, 256 } );
}
void Manage::realMakeWP()
{
if ( !QDir().mkpath( targetSavePath_ + "/WP" ) )
{
throw false;
}
this->saveToPng( targetSavePath_ + "/WP/logo_44x44.png", { 44, 44 } );
this->saveToPng( targetSavePath_ + "/WP/logo_71x71.png", { 71, 71 } );
this->saveToPng( targetSavePath_ + "/WP/logo_480x800.png", { 480, 480 } );
this->saveToPng( targetSavePath_ + "/WP/logo_large.png", { 150, 150 } );
this->saveToPng( targetSavePath_ + "/WP/logo_store.png", { 50, 50 } );
}
void Manage::realMakeAndroid()
{
if ( !QDir().mkpath( targetSavePath_ + "/Android" ) )
{
throw false;
}
this->saveToPng( targetSavePath_ + "/Android/icon_36.png", { 36, 36 } );
this->saveToPng( targetSavePath_ + "/Android/icon_72.png", { 72, 72 } );
this->saveToPng( targetSavePath_ + "/Android/icon_96.png", { 96, 96 } );
}
void Manage::realMakePWA()
{
if ( !QDir().mkpath( targetSavePath_ + "/PWA" ) )
{
throw false;
}
this->saveToPng( targetSavePath_ + "/PWA/icon_16.png", { 16, 16 } );
this->saveToPng( targetSavePath_ + "/PWA/icon_48.png", { 48, 48 } );
this->saveToPng( targetSavePath_ + "/PWA/icon_72.png", { 72, 72 } );
this->saveToPng( targetSavePath_ + "/PWA/icon_96.png", { 96, 96 } );
this->saveToPng( targetSavePath_ + "/PWA/icon_128.png", { 128, 128 } );
this->saveToPng( targetSavePath_ + "/PWA/icon_144.png", { 144, 144 } );
this->saveToPng( targetSavePath_ + "/PWA/icon_168.png", { 168, 168 } );
this->saveToPng( targetSavePath_ + "/PWA/icon_192.png", { 192, 192 } );
}
void Manage::saveToIco(const QString &targetFilePath, const QSize &size)
{
if ( !sourceIconImage_.scaled( size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ).save( targetFilePath, "JPG" ) )
{
throw false;
}
}
void Manage::saveToPng(const QString &targetFilePath, const QSize &size)
{
if ( !sourceIconImage_.scaled( size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ).save( targetFilePath, "PNG" ) )
{
throw false;
}
}
void Manage::saveToEmptyPng(const QString &targetFilePath, const QSize &size)
{
QImage image( size, QImage::Format_ARGB32 );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0)
memset( image.bits(), 0xff, static_cast< size_t >( image.sizeInBytes() ) );
#else
memset( image.bits(), 0xff, static_cast< size_t >( image.byteCount() ) );
#endif
if ( !image.save( targetFilePath, "PNG" ) )
{
throw false;
}
}
void Manage::saveToJpg(const QString &targetFilePath, const QSize &size)
{
if ( !sourceIconImage_.scaled( size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ).save( targetFilePath, "JPG" ) )
{
throw false;
}
}
```
|
/content/code_sandbox/components/MakeGroup/IconMaker/cpp/iconmaker.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 3,532
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "barcodemaker.h"
// Qt lib import
#include <QDebug>
#include <QQmlApplicationEngine>
#include <QFileDialog>
#include <QStandardPaths>
#include <QPainter>
// JQLibrary lib import
#include "JQBarcode.h"
using namespace BarcodeMaker;
Manage::Manage()
{
this->qmlApplicationEngine().data()->addImageProvider( "BarcodeMaker", new ImageProvider );
}
Manage::~Manage()
{
this->qmlApplicationEngine().data()->removeImageProvider( "BarcodeMaker" );
}
QString Manage::savePng(const QString &string)
{
auto filePath = QFileDialog::getSaveFileName(
nullptr,
QStringLiteral( "" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ),
"*.png"
);
if ( filePath.isEmpty() ) { return "cancel"; }
if ( !filePath.toLower().endsWith( ".png" ) )
{
filePath += ".png";
}
QImage targetImage( QSize( 210, 140 ), QImage::Format_RGB888 );
targetImage.fill( QColor( "#ffffff" ) );
const auto &&barcodeImage = JQBarcode::makeBarcode( string.toLongLong() );
if ( ( string.size() == 13 ) && string.toLongLong() && ( string[ 0 ] == '6' ) )
{
QPainter painter;
painter.begin( &targetImage );
painter.drawImage( 10, 10, barcodeImage );
}
const auto &&saveSucceed = targetImage.save( filePath );
if ( !saveSucceed )
{
return "error";
}
return "OK";
}
ImageProvider::ImageProvider():
QQuickImageProvider( QQuickImageProvider::Image )
{ }
QImage ImageProvider::requestImage(const QString &id, QSize *, const QSize &)
{
if ( ( id.size() == 13 ) && id.toLongLong() && ( id[ 0 ] == '6' ) )
{
return JQBarcode::makeBarcode( id.toLongLong() );
}
else
{
return { };
}
}
```
|
/content/code_sandbox/components/MakeGroup/BarcodeMaker/cpp/barcodemaker.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 486
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "barcodemaker.h"
```
|
/content/code_sandbox/components/MakeGroup/BarcodeMaker/cpp/BarcodeMaker
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 45
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_MAKEGROUP_BARCODEMAKER_CPP_BARCODEMAKER_H_
#define GROUP_MAKEGROUP_BARCODEMAKER_CPP_BARCODEMAKER_H_
// Qt lib import
#include <QImage>
#include <QQuickImageProvider>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define BARCODEMAKER_INITIALIZA \
{ \
qmlRegisterType< BarcodeMaker::Manage >( "BarcodeMaker", 1, 0, "BarcodeMakerManage" ); \
}
namespace BarcodeMaker
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage();
~Manage();
public slots:
QString savePng(const QString &string);
};
class ImageProvider: public QQuickImageProvider
{
public:
ImageProvider();
~ImageProvider() = default;
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
};
}
#endif//GROUP_MAKEGROUP_BARCODEMAKER_CPP_BARCODEMAKER_H_
```
|
/content/code_sandbox/components/MakeGroup/BarcodeMaker/cpp/barcodemaker.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 251
|
```unknown
<RCC>
<qresource prefix="/BarcodeMaker">
<file>BarcodeMaker.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/MakeGroup/BarcodeMaker/qml/BarcodeMakerQml.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 32
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/qrcodemaker.h
SOURCES *= \
$$PWD/cpp/qrcodemaker.cpp
RESOURCES *= \
$$PWD/qml/QRCodeMakerQml.qrc
```
|
/content/code_sandbox/components/MakeGroup/QRCodeMaker/QRCodeMaker.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 101
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import "qrc:/MaterialUI/Interface/"
import BarcodeMaker 1.0
Item {
id: qrcodeMaker
width: 620
height: 540
BarcodeMakerManage {
id: barcodeMakerManage
}
Item {
anchors.centerIn: parent
width: 620
height: 540
MaterialTextField {
id: textFieldForLower
x: 40
y: 50
width: 540
placeholderText: "ID\nEAN-136"
text: "6901234567892"
}
Image {
id: imageForBarcode
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -100
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 50
width: 250
height: 250
fillMode: Image.PreserveAspectFit
source: "image://BarcodeMaker/" + textFieldForLower.text
MaterialButton {
anchors.left: parent.right
anchors.leftMargin: 50
anchors.verticalCenter: parent.verticalCenter
text: "PNG"
onClicked: {
materialUI.showLoading();
var reply = barcodeMakerManage.savePng(
textFieldForLower.text
);
materialUI.hideLoading();
switch ( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "error": materialUI.showSnackbarMessage( "" ); break;
case "OK": materialUI.showSnackbarMessage( "" ); break;
default: break;
}
}
}
}
}
}
```
|
/content/code_sandbox/components/MakeGroup/BarcodeMaker/qml/BarcodeMaker.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 404
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "qrcodemaker.h"
// Qt lib import
#include <QDebug>
#include <QQmlApplicationEngine>
#include <QFileDialog>
#include <QStandardPaths>
#include <QPainter>
// JQLibrary lib import
#include "JQQRCodeWriter.h"
using namespace QRCodeMaker;
Manage::Manage()
{
this->qmlApplicationEngine().data()->addImageProvider( "QRCodeMaker", new ImageProvider );
}
Manage::~Manage()
{
this->qmlApplicationEngine().data()->removeImageProvider( "QRCodeMaker" );
}
QString Manage::savePng(const QString &string)
{
auto filePath = QFileDialog::getSaveFileName(
nullptr,
QStringLiteral( "" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ),
"*.png"
);
if ( filePath.isEmpty() ) { return "cancel"; }
if ( !filePath.toLower().endsWith( ".png" ) )
{
filePath += ".png";
}
QImage targetImage( QSize( 500, 500 ), QImage::Format_RGB888 );
targetImage.fill( QColor( "#ffffff" ) );
const auto &&qrCodeImage = JQQRCodeWriter::makeQRcode( string, QSize( 475, 475 ) );
{
QPainter painter;
painter.begin( &targetImage );
painter.drawImage( 10, 10, qrCodeImage );
}
const auto &&saveSucceed = targetImage.save( filePath );
if ( !saveSucceed )
{
return "error";
}
return "OK";
}
ImageProvider::ImageProvider():
QQuickImageProvider( QQuickImageProvider::Image )
{ }
QImage ImageProvider::requestImage(const QString &id, QSize *, const QSize &)
{
return JQQRCodeWriter::makeQRcode( id );
}
```
|
/content/code_sandbox/components/MakeGroup/QRCodeMaker/cpp/qrcodemaker.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 426
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_MAKEGROUP_QRCODEMAKER_CPP_QRCODEMAKER_H_
#define GROUP_MAKEGROUP_QRCODEMAKER_CPP_QRCODEMAKER_H_
// Qt lib import
#include <QImage>
#include <QQuickImageProvider>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define QRCODEMAKER_INITIALIZA \
{ \
qmlRegisterType< QRCodeMaker::Manage >( "QRCodeMaker", 1, 0, "QRCodeMakerManage" ); \
}
namespace QRCodeMaker
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage();
~Manage();
public slots:
QString savePng(const QString &string);
};
class ImageProvider: public QQuickImageProvider
{
public:
ImageProvider();
~ImageProvider() = default;
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
};
}
#endif//GROUP_MAKEGROUP_QRCODEMAKER_CPP_QRCODEMAKER_H_
```
|
/content/code_sandbox/components/MakeGroup/QRCodeMaker/cpp/qrcodemaker.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 261
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "qrcodemaker.h"
```
|
/content/code_sandbox/components/MakeGroup/QRCodeMaker/cpp/QRCodeMaker
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 46
|
```unknown
<RCC>
<qresource prefix="/QRCodeMaker">
<file>QRCodeMaker.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/MakeGroup/QRCodeMaker/qml/QRCodeMakerQml.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 34
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/webpmaker.h
SOURCES *= \
$$PWD/cpp/webpmaker.cpp
RESOURCES *= \
$$PWD/qml/WebPMaker.qrc
```
|
/content/code_sandbox/components/MakeGroup/WebPMaker/WebPMaker.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 96
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import "qrc:/MaterialUI/Interface/"
import QRCodeMaker 1.0
Item {
id: qrCodeMaker
width: 620
height: 540
QRCodeMakerManage {
id: qrCodeMakerManage
}
Item {
anchors.centerIn: parent
width: 620
height: 540
MaterialTextField {
id: textFieldForLower
x: 40
y: 50
width: 540
placeholderText: ""
text: "JQTools"
}
Image {
id: imageForQRCode
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -100
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 50
width: 250
height: 250
fillMode: Image.PreserveAspectFit
source: "image://QRCodeMaker/" + textFieldForLower.text
MaterialButton {
anchors.left: parent.right
anchors.leftMargin: 50
anchors.verticalCenter: parent.verticalCenter
text: "PNG"
onClicked: {
materialUI.showLoading();
var reply = qrCodeMakerManage.savePng(
textFieldForLower.text
);
materialUI.hideLoading();
switch ( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "error": materialUI.showSnackbarMessage( "" ); break;
case "OK": materialUI.showSnackbarMessage( "" ); break;
default: break;
}
}
}
}
}
}
```
|
/content/code_sandbox/components/MakeGroup/QRCodeMaker/qml/QRCodeMaker.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 401
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "webpmaker.h"
```
|
/content/code_sandbox/components/MakeGroup/WebPMaker/cpp/WebPMaker
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 45
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TOOLSGROUP_WEBPMAKER_CPP_WEBPMAKER_H_
#define GROUP_TOOLSGROUP_WEBPMAKER_CPP_WEBPMAKER_H_
// C++ lib import
#include <functional>
// Qt lib import
#include <QJsonObject>
#include <QJsonArray>
#include <QMap>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define WEBPMAKER_INITIALIZA \
{ \
qmlRegisterType<WebPMaker::Manage>("WebPMaker", 1, 0, "WebPMakerManage"); \
}
namespace WebPMaker
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage() = default;
~Manage() = default;
public slots:
QString makeWebPByFilePaths(const bool &coverOldFile, const QJsonArray &filePaths);
QString makeWebPByOpenFiles(const bool &coverOldFile);
QString makeWebPByOpenDirectory(const bool &coverOldFile);
void startMake(const QString ¤tFilePath);
QString urlToLocalPngFilePath(const QVariant &url);
private:
QString makeWebP(const bool &coverOldFile, const QStringList &filePaths);
signals:
void makeStart(const QJsonArray fileList);
void makeWebPStart(const QString currentFilePath);
void makeWebPFinish(const QString currentFilePath, const QJsonObject makeResult);
void makeEnd();
private:
QMap< QString, std::function< void() > > waitMakeQueue_; // fileName -> package
};
}
#endif//GROUP_TOOLSGROUP_WEBPMAKER_CPP_WEBPMAKER_H_
```
|
/content/code_sandbox/components/MakeGroup/WebPMaker/cpp/webpmaker.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 384
|
```unknown
<RCC>
<qresource prefix="/WebPMaker">
<file>WebPMaker.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/MakeGroup/WebPMaker/qml/WebPMaker.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 34
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "webpmaker.h"
// C++ lib import
#include <functional>
// Qt lib import
#include <QFileDialog>
#include <QStandardPaths>
#include <QtConcurrent>
// JQLibrary import
#include "JQZopfli.h"
#include "JQFile.h"
using namespace WebPMaker;
QString Manage::makeWebPByFilePaths(const bool &coverOldFile, const QJsonArray &filePaths_)
{
QStringList filePaths;
for ( const auto &filePath: filePaths_ )
{
filePaths.push_back( filePath.toString() );
}
return this->makeWebP( coverOldFile, filePaths );
}
QString Manage::makeWebPByOpenFiles(const bool &coverOldFile)
{
QStringList filePaths;
filePaths = QFileDialog::getOpenFileNames(
nullptr,
QStringLiteral( "\u8BF7\u9009\u62E9PNG/JPG\u56FE\u7247\uFF08\u53EF\u591A\u9009\uFF09" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ),
"Images (*.png *.jpg)"
);
if ( filePaths.isEmpty() ) { return "cancel"; }
return this->makeWebP( coverOldFile, filePaths );
}
QString Manage::makeWebPByOpenDirectory(const bool &coverOldFile)
{
QStringList filePaths;
const auto &&directoryPath = QFileDialog::getExistingDirectory(
nullptr,
QStringLiteral( "\u8BF7\u9009\u62E9\u5305\u542BPNG/JPG\u56FE\u7247\u7684\u6587\u4EF6\u5939" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation )
);
if ( directoryPath.isEmpty() ) { return "cancel"; }
JQFile::foreachFileFromDirectory(
directoryPath,
[ &filePaths ]
(const QFileInfo &fileInfo)
{
if ( ( fileInfo.suffix().toLower() != "png" ) && ( fileInfo.suffix().toLower() != "jpg" ) ) { return; }
filePaths.push_back( fileInfo.filePath() );
},
true
);
if ( directoryPath.isEmpty() ) { return "empty"; }
return this->makeWebP( coverOldFile, filePaths );
}
void Manage::startMake(const QString ¤tFilePath)
{
if ( !waitMakeQueue_.contains( currentFilePath ) ) { return; }
QtConcurrent::run( waitMakeQueue_[ currentFilePath ] );
waitMakeQueue_.remove( currentFilePath );
}
QString Manage::urlToLocalPngFilePath(const QVariant &url)
{
QFileInfo fileInfo( url.toUrl().toLocalFile() );
if ( !fileInfo.isFile() ) { return { }; }
if ( !fileInfo.filePath().toLower().endsWith( ".png" ) && !fileInfo.filePath().toLower().endsWith( ".jpg" ) ) { return { }; }
return fileInfo.filePath();
}
QString Manage::makeWebP(const bool &coverOldFile, const QStringList &filePaths)
{
QString targetDir;
if ( !coverOldFile )
{
targetDir = QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ) + "/JQTools_MakeWebPResult/";
if ( !QDir( targetDir ).exists() && !QDir().mkdir( targetDir ) )
{
return "mkdir error";
}
}
QJsonArray fileList;
auto makeSizeString = [](const int &size)
{
if ( size < 1024 )
{
return QString( "%1 byte" ).arg( size );
}
else if ( size < ( 1024 * 1024 ) )
{
return QString( "%1 kb" ).arg( size / 1024 );
}
else
{
return QString( "%1.%2 mb" ).arg( size / 1024 / 1024 ).arg( size / 1024 % 1024 );
}
};
static auto packageCount = 0;
static QMutex mutex;
for ( const auto &filePath: filePaths )
{
QFileInfo fileInfo( filePath );
fileList.push_back( QJsonObject( { {
{ "fileName", fileInfo.fileName() },
{ "filePath", filePath },
{ "originalSize", makeSizeString( fileInfo.size() ) }
} } ) );
++packageCount;
waitMakeQueue_[ filePath ] = [
this,
filePath,
makeSizeString,
fileName = fileInfo.fileName(),
originalFilePath = filePath,
resultFilePath = ( targetDir.isEmpty() ) ? ( fileInfo.path() + "/" + fileInfo.completeBaseName() + ".webp" ) : ( targetDir + "/" + fileInfo.completeBaseName() + ".webp" )
]()
{
emit this->makeWebPStart( filePath );
QElapsedTimer timer;
timer.start();
const auto &&saveSucceed = QImage( filePath ).save( resultFilePath, "WEBP", 100 );
const auto &&targetFileInfo = QFileInfo( resultFilePath );
const auto &&compressionRatio = static_cast< qreal >( targetFileInfo.size() ) / static_cast< qreal >( QFile( filePath ).size() );
emit this->makeWebPFinish(
filePath,
{ {
{ "makeSucceed", saveSucceed },
{ "resultSize", makeSizeString( targetFileInfo.size() ) },
{ "compressionRatio", QString( "%1%2%" ).
arg( ( compressionRatio < 1 ) ? ( "-" ) : ( "" ) ).
arg( 100 - (int)(compressionRatio * 100) ) },
{ "compressionRatioColor", QString( "%1" ).
arg( ( compressionRatio < 1 ) ? ( "#64dd17" ) : ( "#f44336" ) ) },
{ "timeConsuming", QString( "%1ms" ).arg( timer.elapsed() ) }
} }
);
mutex.lock();
--packageCount;
if ( packageCount <= 0 )
{
emit this->makeEnd();
}
mutex.unlock();
};
}
emit this->makeStart( fileList );
return "OK";
}
```
|
/content/code_sandbox/components/MakeGroup/WebPMaker/cpp/webpmaker.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,381
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
include( $$PWD/LinesStatistics/LinesStatistics.pri )
include( $$PWD/LanFileTransport/LanFileTransport.pri )
include( $$PWD/PngOptimize/PngOptimize.pri )
mac {
include( $$PWD/JpgOptimize/JpgOptimize.pri )
}
include( $$PWD/QRCodeReader/QRCodeReader.pri )
include( $$PWD/BatchReplacement/BatchReplacement.pri )
include( $$PWD/ScreenColorPicker/ScreenColorPicker.pri )
INCLUDEPATH *= \
$$PWD/
HEADERS *= \
$$PWD/toolsgroup.h
```
|
/content/code_sandbox/components/ToolsGroup/ToolsGroup.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 171
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef TOOLSGROUP_TOOLSGROUP_H_
#define TOOLSGROUP_TOOLSGROUP_H_
// ToolsGroup lib import
#include <LinesStatistics>
#include <ScreenColorPicker>
#include <PngOptimize>
#ifdef TOOLSGROUP_JPGOPTIMIZE_ENABLE
# include <JpgOptimize>
#endif
#include <LanFileTransport>
#include <QRCodeReader>
#include <BatchReplacement>
#ifdef TOOLSGROUP_JPGOPTIMIZE_ENABLE
# define TOOLSGROUP_INITIALIZA \
LINESSTATISTICS_INITIALIZA; \
PNGOPTIMIZE_INITIALIZA; \
JPGOPTIMIZE_INITIALIZA; \
LANFILETRANSPORT_INITIALIZA; \
QRCODEREADER_INITIALIZA; \
BATCHREPLACEMENT_INITIALIZA;\
SCREENCOLORPICKER_INITIALIZA;
#else
# define TOOLSGROUP_INITIALIZA \
LINESSTATISTICS_INITIALIZA; \
PNGOPTIMIZE_INITIALIZA; \
LANFILETRANSPORT_INITIALIZA; \
QRCODEREADER_INITIALIZA; \
BATCHREPLACEMENT_INITIALIZA;\
SCREENCOLORPICKER_INITIALIZA;
#endif
#endif//TOOLSGROUP_TOOLSGROUP_H_
```
|
/content/code_sandbox/components/ToolsGroup/toolsgroup.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 276
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "toolsgroup.h"
```
|
/content/code_sandbox/components/ToolsGroup/ToolsGroup
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 45
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/qrcodereader.h
SOURCES *= \
$$PWD/cpp/qrcodereader_.cpp
RESOURCES *= \
$$PWD/qml/QRCodeReaderQml.qrc \
$$PWD/resources/images/QRCodeReaderImages.qrc
```
|
/content/code_sandbox/components/ToolsGroup/QRCodeReader/QRCodeReader.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 117
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "qrcodereader.h"
```
|
/content/code_sandbox/components/ToolsGroup/QRCodeReader/cpp/QRCodeReader
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 47
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H_
#define GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H_
// Qt lib import
#include <QImage>
#include <QQuickImageProvider>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define QRCODEREADER_INITIALIZA \
{ \
qmlRegisterType< QRCodeReader_::Manage >( "QRCodeReader", 1, 0, "QRCodeReaderManage" ); \
}
class JQQRCodeReader;
namespace QRCodeReader_
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage();
~Manage() = default;
public slots:
QUrl chooseImage() const;
QString decodeImage(const QUrl &imageUrl);
private:
QSharedPointer< JQQRCodeReader > jqQRCodeReader_;
};
}
#endif//GROUP_MAKEGROUP_QRCODEREADER_CPP_QRCODEREADER_H_
```
|
/content/code_sandbox/components/ToolsGroup/QRCodeReader/cpp/qrcodereader.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 252
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "qrcodereader.h"
// Qt lib import
#include <QDebug>
#include <QFileDialog>
#include <QStandardPaths>
#include <QUrl>
// JQLibrary lib import
#include "JQQRCodeReader.h"
using namespace QRCodeReader_;
Manage::Manage():
jqQRCodeReader_( new JQQRCodeReader )
{ }
QUrl Manage::chooseImage() const
{
return QUrl::fromLocalFile(
QFileDialog::getOpenFileName(
nullptr,
QStringLiteral( "\u8BF7\u9009\u62E9\u56FE\u7247" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ),
"*.png *.jpg"
)
);
}
QString Manage::decodeImage(const QUrl &imageUrl)
{
if ( imageUrl.toString().startsWith( "file:" ) )
{
return jqQRCodeReader_->decodeImage( QImage( imageUrl.toLocalFile() ) );
}
else if ( imageUrl.toString().startsWith( "qrc:" ) )
{
return jqQRCodeReader_->decodeImage( QImage( imageUrl.toString().mid( 3 ) ) );
}
return { };
}
```
|
/content/code_sandbox/components/ToolsGroup/QRCodeReader/cpp/qrcodereader_.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 287
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import WebPMaker 1.0
Item {
id: webPMaker
width: 620
height: 540
property bool changingFlag: true
Component.onCompleted: {
changingFlag = false;
}
WebPMakerManage {
id: webPMakerManage
onMakeStart: {
buttonForChooseImage.enabled = false;
buttonForChooseDirectory.enabled = false;
materialUI.showSnackbarMessage( "" );
listModelForNodes.clear();
for ( var index = 0; index < fileList.length; ++index )
{
listModelForNodes.append( {
fileName: fileList[ index ][ "fileName" ],
filePath: fileList[ index ][ "filePath" ],
originalSize: fileList[ index ][ "originalSize" ]
} );
}
}
onMakeEnd: {
buttonForChooseImage.enabled = true;
buttonForChooseDirectory.enabled = true;
materialUI.showSnackbarMessage( "" );
}
}
MaterialLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 22
text: "QtPNGJPG\n\n"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
MaterialButton {
id: buttonForChooseImage
x: 254
width: 120
height: 40
text: ""
anchors.horizontalCenterOffset: 34
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 105
onClicked: {
materialUI.showLoading();
var reply = webPMakerManage.makeWebPByOpenFiles( radioButtonForCoverOldFile.checked );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
MaterialButton {
id: buttonForChooseDirectory
x: 254
width: 120
height: 40
text: ""
anchors.horizontalCenterOffset: 190
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 105
onClicked: {
materialUI.showLoading();
var reply = webPMakerManage.makeWebPByOpenDirectory( radioButtonForCoverOldFile.checked );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "empty": materialUI.showSnackbarMessage( "pngjpg" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
ExclusiveGroup {
id: exclusiveGroupForMode
}
MaterialRadioButton {
id: radioButtonForCoverOldFile
x: 115
text: "WebP"
anchors.horizontalCenterOffset: -171
anchors.top: parent.top
anchors.topMargin: 83
anchors.horizontalCenter: parent.horizontalCenter
exclusiveGroup: exclusiveGroupForMode
}
MaterialRadioButton {
id: radioButtonForNewFile
x: 115
text: ""
anchors.horizontalCenterOffset: -161
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 126
exclusiveGroup: exclusiveGroupForMode
checked: true
}
ListView {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 180
width: 575
height: parent.height - 180
clip: true
cacheBuffer: 999999
model: ListModel {
id: listModelForNodes
}
delegate: Item {
id: itemForNodes
width: 575
height: 54
Component.onCompleted: {
webPMakerManage.startMake( filePath );
}
Connections {
target: webPMakerManage
onMakeWebPStart: {
if ( currentFilePath !== filePath ) { return; }
progressCircleForOptimizing.indeterminate = true;
}
onMakeWebPFinish: {
if ( currentFilePath !== filePath ) { return; }
progressCircleForOptimizing.opacity = 0;
labelForCompressionRatio.opacity = 1;
if ( !makeResult[ "resultSize" ] )
{
labelForCompressionRatio.text = "";
labelForCompressionRatio.color = "#ff0000";
return;
}
labelForCompressionRatio.text = makeResult[ "compressionRatio" ];
labelForResultSize.opacity = 1;
labelForResultSize.text = makeResult[ "resultSize" ];
labelForResultSize.color = makeResult[ "compressionRatioColor" ];
labelForTimeConsuming.opacity = 1;
labelForTimeConsuming.text = makeResult[ "timeConsuming" ];
}
}
RectangularGlow {
x: 5
y: 5
width: parent.width - 10
height: parent.height - 10
glowRadius: 4
spread: 0.2
color: "#44000000"
cornerRadius: 8
}
Rectangle {
x: 5
y: 5
width: parent.width - 10
height: parent.height - 10
color: "#ffffff"
}
MaterialLabel {
id: labelForFileName
x: 16
anchors.verticalCenter: parent.verticalCenter
width: 260
text: fileName
elide: Text.ElideRight
}
MaterialLabel {
id: labelForOriginalSize
anchors.right: progressCircleForOptimizing.left
anchors.rightMargin: 25
anchors.verticalCenter: parent.verticalCenter
text: originalSize
}
MaterialProgressCircle {
id: progressCircleForOptimizing
x: 360
anchors.verticalCenter: parent.verticalCenter
width: 32
height: 32
indeterminate: false
autoChangeColor: true
visible: opacity !== 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForCompressionRatio
anchors.centerIn: progressCircleForOptimizing
width: 32
height: 32
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForResultSize
anchors.left: progressCircleForOptimizing.right
anchors.leftMargin: 25
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
color: "#000000"
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForTimeConsuming
anchors.left: progressCircleForOptimizing.right
anchors.leftMargin: 95
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
}
}
DropArea {
anchors.fill: parent
onDropped: {
if( !drop.hasUrls ) { return; }
var filePaths = [ ];
for( var index = 0; index < drop.urls.length; ++index )
{
var pngFilePath = webPMakerManage.urlToLocalPngFilePath( drop.urls[ index ] );
if ( pngFilePath.length === 0 ) { continue; }
filePaths.push( pngFilePath);
}
if ( filePaths.length === 0 ) { return; }
materialUI.showLoading();
var reply = webPMakerManage.makeWebPByFilePaths( radioButtonForCoverOldFile.checked, filePaths );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
}
```
|
/content/code_sandbox/components/MakeGroup/WebPMaker/qml/WebPMaker.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,871
|
```unknown
<RCC>
<qresource prefix="/QRCodeReaderImages">
<file>test.png</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/ToolsGroup/QRCodeReader/resources/images/QRCodeReaderImages.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 33
|
```unknown
<RCC>
<qresource prefix="/QRCodeReader">
<file>QRCodeReader.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/ToolsGroup/QRCodeReader/qml/QRCodeReaderQml.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 34
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/batchreplacement.h
SOURCES *= \
$$PWD/cpp/batchreplacement.cpp
RESOURCES *= \
$$PWD/qml/BatchReplacement.qrc
```
|
/content/code_sandbox/components/ToolsGroup/BatchReplacement/BatchReplacement.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 96
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import "qrc:/MaterialUI/Interface/"
import QRCodeReader 1.0
Item {
id: qrCodeReader
width: 620
height: 540
QRCodeReaderManage {
id: qrCodeReaderManage
}
Item {
anchors.centerIn: parent
width: 620
height: 540
MaterialTextField {
id: textFieldForTag
x: 40
y: 50
width: 540
placeholderText: ""
Component.onCompleted: {
text = qrCodeReaderManage.decodeImage( "qrc:/QRCodeReaderImages/test.png" );
}
}
Image {
id: imageForQRCode
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -100
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 50
width: 250
height: 250
source: "qrc:/QRCodeReaderImages/test.png"
MaterialButton {
anchors.left: parent.right
anchors.leftMargin: 50
anchors.verticalCenter: parent.verticalCenter
text: ""
onClicked: {
imageForQRCode.source = qrCodeReaderManage.chooseImage();
if ( imageForQRCode.source.toString() !== "" )
{
textFieldForTag.text = qrCodeReaderManage.decodeImage( imageForQRCode.source );
}
else
{
textFieldForTag.text = "";
materialUI.showSnackbarMessage( "" );
}
}
}
}
}
}
```
|
/content/code_sandbox/components/ToolsGroup/QRCodeReader/qml/QRCodeReader.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 391
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "batchreplacement.h"
```
|
/content/code_sandbox/components/ToolsGroup/BatchReplacement/cpp/BatchReplacement
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 44
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "batchreplacement.h"
// Qt lib import
#include <QSet>
#include <QFileDialog>
#include <QStandardPaths>
#include <QJsonArray>
#include <QEventLoop>
#include <QtConcurrent>
#include <QDir>
// JQLibrary import
#include "JQFile.h"
using namespace BatchReplacement;
QJsonObject Manage::startBatchReplacement(
const QJsonArray &suffixs,
const QString &sourceKey,
const QString &targetKey,
const bool &multiCase
)
{
auto fileCount = 0;
auto replacementCount = 0;
static QString lastPath = QStandardPaths::writableLocation( QStandardPaths::DesktopLocation );
auto currentPath = QFileDialog::getExistingDirectory( nullptr, "Please choose target dir", lastPath );
if ( currentPath.isEmpty() )
{
return
{ {
{ "cancel", true }
} };
}
lastPath = currentPath;
QSet< QString > availableSuffixs;
for ( const auto suffix: suffixs )
{
availableSuffixs.insert( suffix.toString().toLower() );
}
QEventLoop eventLoop;
QtConcurrent::run( [ & ]()
{
auto batchReplacement = [ &fileCount, &replacementCount, currentPath, availableSuffixs ](
const QString ¤tSourceKey,
const QString ¤tTargetKey
)
{
qDebug() << "batchReplacement:" << currentSourceKey << currentTargetKey;
JQFile::foreachFileFromDirectory( { currentPath }, [ & ](const QFileInfo &info)
{
if ( info.suffix().isEmpty() )
{
if ( !availableSuffixs.contains( "nosuffixfile" ) )
{
return;
}
}
else
{
if ( !availableSuffixs.contains( info.suffix().toLower() ) )
{
return;
}
}
QByteArray fileAllData;
{
QFile file( info.filePath() );
if ( !file.open( QIODevice::ReadOnly ) ) { return; }
fileAllData = file.readAll();
}
if ( fileAllData.isEmpty() ) { return; }
const auto &&matchCount = fileAllData.count( currentSourceKey.toUtf8() );
if ( !matchCount ) { return; }
qDebug() << "file data:" << info.filePath() << matchCount;
++fileCount;
replacementCount += matchCount;
JQFile::writeFile( info.filePath(), fileAllData.replace( currentSourceKey.toUtf8(), currentTargetKey.toUtf8() ) );
}, true );
if ( availableSuffixs.contains( "filenameanddirname" ) )
{
QFileInfoList fileNameList;
QList< QDir > dirNameList;
JQFile::foreachFileFromDirectory( { currentPath }, [ & ](const QFileInfo &info)
{
if ( info.suffix().isEmpty() )
{
if ( !availableSuffixs.contains( "nosuffixfile" ) )
{
return;
}
}
else
{
if ( !availableSuffixs.contains( info.suffix().toLower() ) )
{
return;
}
}
const auto &&matchCount = info.fileName().count( currentSourceKey.toUtf8() );
if ( !matchCount ) { return; }
qDebug() << "file name:" << info.filePath() << matchCount;
++fileCount;
replacementCount += matchCount;
fileNameList.push_back( info );
}, true );
JQFile::foreachDirectoryFromDirectory( { currentPath }, [ & ](const QDir &dir)
{
const auto &&matchCount = dir.dirName().count( currentSourceKey );
if ( !matchCount ) { return; }
qDebug() << "dir path:" << dir.path() << matchCount;
++fileCount;
replacementCount += matchCount;
dirNameList.push_back( dir );
}, true );
for ( const auto &info: fileNameList )
{
const QString targetFilePath = QString( "%1/%2" ).arg( info.path(), info.fileName().replace( currentSourceKey, currentTargetKey ) );
qDebug() << "file:" << info.filePath() << "->" << targetFilePath;
QFile::rename( info.filePath(), targetFilePath );
}
for ( const auto &dir: dirNameList )
{
const QString targetDir = QString( "%1/%2" ).arg( QFileInfo( dir.path() ).path(), dir.dirName().replace( currentSourceKey, currentTargetKey ) );
qDebug() << "dir:" << dir.path() << "->" << targetDir;
QDir().rename( dir.path(), targetDir );
}
}
};
if ( multiCase )
{
batchReplacement( sourceKey.toLower(), targetKey.toLower() );
batchReplacement( sourceKey.toUpper(), targetKey.toUpper() );
if ( ( sourceKey.size() > 1 ) && ( targetKey.size() > 1 ) )
{
auto sourceKey2 = sourceKey;
auto targetKey2 = targetKey;
sourceKey2[ 0 ] = sourceKey.toLower()[ 0 ];
targetKey2[ 0 ] = targetKey.toLower()[ 0 ];
batchReplacement( sourceKey2, targetKey2 );
sourceKey2[ 0 ] = sourceKey.toUpper()[ 0 ];
targetKey2[ 0 ] = targetKey.toUpper()[ 0 ];
batchReplacement( sourceKey2, targetKey2 );
}
else
{
batchReplacement( sourceKey, targetKey );
}
}
else
{
batchReplacement( sourceKey, targetKey );
}
eventLoop.quit();
} );
eventLoop.exec();
return
{ {
{ "fileCount", fileCount },
{ "replacementCount", replacementCount }
} };
}
```
|
/content/code_sandbox/components/ToolsGroup/BatchReplacement/cpp/batchreplacement.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,316
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TOOLSGROUP_BATCHREPLACEMENT_CPP_BATCHREPLACEMENT_H_
#define GROUP_TOOLSGROUP_BATCHREPLACEMENT_CPP_BATCHREPLACEMENT_H_
// Qt lib import
#include <QJsonObject>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define BATCHREPLACEMENT_INITIALIZA \
{ \
qmlRegisterType<BatchReplacement::Manage>("BatchReplacement", 1, 0, "BatchReplacementManage"); \
}
namespace BatchReplacement
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage() = default;
~Manage() = default;
public slots:
QJsonObject startBatchReplacement(
const QJsonArray &suffixs,
const QString &sourceKey,
const QString &targetKey,
const bool &multiCase
);
};
}
#endif//GROUP_TOOLSGROUP_BATCHREPLACEMENT_CPP_BATCHREPLACEMENT_H_
```
|
/content/code_sandbox/components/ToolsGroup/BatchReplacement/cpp/batchreplacement.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 234
|
```unknown
<RCC>
<qresource prefix="/BatchReplacement">
<file>BatchReplacement.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/ToolsGroup/BatchReplacement/qml/BatchReplacement.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 32
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/pngoptimize.h
SOURCES *= \
$$PWD/cpp/pngoptimize.cpp
RESOURCES *= \
$$PWD/qml/PngOptimize.qrc
```
|
/content/code_sandbox/components/ToolsGroup/PngOptimize/PngOptimize.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 95
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import BatchReplacement 1.0
Item {
id: batchReplacement
width: 620
height: 540
property bool changingFlag: true
Component.onCompleted: {
changingFlag = false;
}
BatchReplacementManage {
id: batchReplacementManage
}
Item {
anchors.centerIn: parent
width: 620
height: 540
MaterialLabel {
x: 64
y: 66
text: ""
}
Column {
x: 64
y: 92
spacing: -10
MaterialCheckBox {
id: checkBoxForCpp
text: "h/c/cc/cp/cpp/hpp/inc/i/ii/m"
checked: true
}
MaterialCheckBox {
id: checkBoxForQmake
text: "pro/pri/prf/prl/qrc"
checked: true
}
MaterialCheckBox {
id: checkBoxForQml
text: "qml"
checked: true
}
MaterialCheckBox {
id: checkBoxForUi
text: "ui"
checked: true
}
MaterialCheckBox {
id: checkBoxForJsonAndXml
text: "json/xml"
checked: true
}
MaterialCheckBox {
id: checkBoxForBatAndSh
text: "bat/sh"
checked: true
}
MaterialCheckBox {
id: checkBoxForNoSuffixFile
text: ""
checked: true
}
MaterialCheckBox {
id: checkBoxForFileAndDir
text: "/"
checked: true
}
MaterialCheckBox {
id: checkBoxForMultiCase
text: ""
checked: true
}
}
MaterialTextField {
id: textFieldForSourceKey
x: 370
y: 180
width: 200
placeholderText: ""
text: ""
}
MaterialTextField {
id: textFieldForTargetKey
x: 370
y: 270
width: 200
placeholderText: ""
text: ""
}
MaterialButton {
x: 405
y: 380
width: 120
height: 40
text: ""
onClicked: {
if ( textFieldForSourceKey.text == "" )
{
materialUI.showSnackbarMessage( "" );
return;
}
if ( checkBoxForFileAndDir.checked && ( textFieldForSourceKey.text == "" ) )
{
materialUI.showSnackbarMessage( "" );
return;
}
materialUI.showLoading();
var suffixs = new Array;
if ( checkBoxForCpp.checked )
{
suffixs.push( "h" );
suffixs.push( "c" );
suffixs.push( "cc" );
suffixs.push( "cp" );
suffixs.push( "cpp" );
suffixs.push( "hpp" );
suffixs.push( "inc" );
suffixs.push( "i" );
suffixs.push( "ii" );
suffixs.push( "m" );
}
if ( checkBoxForQml.checked )
{
suffixs.push( "qml" );
}
if ( checkBoxForUi.checked )
{
suffixs.push( "ui" );
}
if ( checkBoxForJsonAndXml.checked )
{
suffixs.push( "json" );
suffixs.push( "xml" );
}
if ( checkBoxForBatAndSh.checked )
{
suffixs.push( "bat" );
suffixs.push( "sh" );
}
if ( checkBoxForQmake.checked )
{
suffixs.push( "pro" );
suffixs.push( "pri" );
suffixs.push( "prf" );
suffixs.push( "prl" );
suffixs.push( "qrc" );
}
if ( checkBoxForNoSuffixFile.checked )
{
suffixs.push( "NoSuffixFile" );
}
if ( checkBoxForFileAndDir.checked )
{
suffixs.push( "FileNameAndDirName" );
}
var reply = batchReplacementManage.startBatchReplacement(
suffixs,
textFieldForSourceKey.text,
textFieldForTargetKey.text,
checkBoxForMultiCase.checked
);
if ( "cancel" in reply )
{
materialUI.showSnackbarMessage( "" );
materialUI.hideLoading();
return;
}
labelForLinesCount.fileCount = reply[ "fileCount" ];
labelForLinesCount.replacementCount = reply[ "replacementCount" ];
materialUI.hideLoading();
}
}
MaterialLabel {
id: labelForLinesCount
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: 150
anchors.verticalCenterOffset: -120
anchors.verticalCenter: parent.verticalCenter
text: "" + fileCount + "\n" + replacementCount
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
property int fileCount: 0
property int replacementCount: 0
}
}
}
```
|
/content/code_sandbox/components/ToolsGroup/BatchReplacement/qml/BatchReplacement.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,179
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "pngoptimize.h"
```
|
/content/code_sandbox/components/ToolsGroup/PngOptimize/cpp/PngOptimize
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 44
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H_
#define GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H_
// C++ lib import
#include <functional>
// Qt lib import
#include <QJsonObject>
#include <QJsonArray>
#include <QMap>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define PNGOPTIMIZE_INITIALIZA \
{ \
qmlRegisterType<PngOptimize::Manage>("PngOptimize", 1, 0, "PngOptimizeManage"); \
}
namespace PngOptimize
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage() = default;
~Manage() = default;
public slots:
QString optimizePngByFilePaths(const bool &coverOldFile, const QJsonArray &filePaths);
QString optimizePngByOpenFiles(const bool &coverOldFile);
QString optimizePngByOpenDirectory(const bool &coverOldFile);
void startOptimize(const QString ¤tFilePath);
QString urlToLocalPngFilePath(const QVariant &url);
private:
QString optimizePng(const bool &coverOldFile, const QStringList &filePaths);
signals:
void optimizeStart(const QJsonArray fileList);
void optimizePngStart(const QString currentFilePath);
void optimizePngFinish(const QString currentFilePath, const QJsonObject optimizeResult);
void optimizeEnd();
private:
QMap< QString, std::function< void() > > waitOptimizeQueue_; // fileName -> package
};
}
#endif//GROUP_TOOLSGROUP_PNGOPTIMIZE_CPP_PNGOPTIMIZE_H_
```
|
/content/code_sandbox/components/ToolsGroup/PngOptimize/cpp/pngoptimize.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 388
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "pngoptimize.h"
// C++ lib import
#include <functional>
// Qt lib import
#include <QFileDialog>
#include <QStandardPaths>
#include <QtConcurrent>
// JQLibrary import
#include "JQZopfli.h"
#include "JQFile.h"
using namespace PngOptimize;
QString Manage::optimizePngByFilePaths(const bool &coverOldFile, const QJsonArray &filePaths_)
{
QStringList filePaths;
for ( const auto &filePath: filePaths_ )
{
filePaths.push_back( filePath.toString() );
}
return this->optimizePng( coverOldFile, filePaths );
}
QString Manage::optimizePngByOpenFiles(const bool &coverOldFile)
{
QStringList filePaths;
filePaths = QFileDialog::getOpenFileNames(
nullptr,
QStringLiteral( "\u8BF7\u9009\u62E9PNG\u56FE\u7247\uFF08\u53EF\u591A\u9009\uFF09" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ),
"*.png"
);
if ( filePaths.isEmpty() ) { return "cancel"; }
return this->optimizePng( coverOldFile, filePaths );
}
QString Manage::optimizePngByOpenDirectory(const bool &coverOldFile)
{
QStringList filePaths;
const auto &&directoryPath = QFileDialog::getExistingDirectory(
nullptr,
QStringLiteral( "\u8BF7\u9009\u62E9\u5305\u542BPNG\u56FE\u7247\u7684\u6587\u4EF6\u5939" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation )
);
if ( directoryPath.isEmpty() ) { return "cancel"; }
JQFile::foreachFileFromDirectory(
directoryPath,
[ &filePaths ]
(const QFileInfo &fileInfo)
{
if ( fileInfo.suffix().toLower() != "png" ) { return; }
filePaths.push_back( fileInfo.filePath() );
},
true
);
if ( directoryPath.isEmpty() ) { return "empty"; }
return this->optimizePng( coverOldFile, filePaths );
}
void Manage::startOptimize(const QString ¤tFilePath)
{
if ( !waitOptimizeQueue_.contains( currentFilePath ) ) { return; }
QtConcurrent::run( waitOptimizeQueue_[ currentFilePath ] );
waitOptimizeQueue_.remove( currentFilePath );
}
QString Manage::urlToLocalPngFilePath(const QVariant &url)
{
QFileInfo fileInfo( url.toUrl().toLocalFile() );
if ( !fileInfo.isFile() ) { return { }; }
if ( !fileInfo.filePath().toLower().endsWith( ".png" ) ) { return { }; }
return fileInfo.filePath();
}
QString Manage::optimizePng(const bool &coverOldFile, const QStringList &filePaths)
{
QString targetDir;
if ( !coverOldFile )
{
targetDir = QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ) + "/JQTools_OptimizePngResult/";
if ( !QDir( targetDir ).exists() && !QDir().mkdir( targetDir ) )
{
return "mkdir error";
}
}
QJsonArray fileList;
auto makeSizeString = [](const int &size)
{
if ( size < 1024 )
{
return QString( "%1 byte" ).arg( size );
}
else if ( size < ( 1024 * 1024 ) )
{
return QString( "%1 kb" ).arg( size / 1024 );
}
else
{
return QString( "%1.%2 mb" ).arg( size / 1024 / 1024 ).arg( size / 1024 % 1024 );
}
};
static auto packageCount = 0;
static QMutex mutex;
for ( const auto &filePath: filePaths )
{
QFileInfo fileInfo( filePath );
fileList.push_back( QJsonObject( { {
{ "fileName", fileInfo.fileName() },
{ "filePath", filePath },
{ "originalSize", makeSizeString( fileInfo.size() ) }
} } ) );
++packageCount;
waitOptimizeQueue_[ filePath ] = [
this,
filePath,
makeSizeString,
fileName = fileInfo.fileName(),
originalFilePath = filePath,
resultFilePath = ( targetDir.isEmpty() ) ? ( filePath ) : ( targetDir + "/" + fileInfo.fileName() )
]()
{
emit this->optimizePngStart( filePath );
auto optimizeResult = JQZopfli::optimize( originalFilePath, resultFilePath );
emit this->optimizePngFinish(
filePath,
{ {
{ "optimizeSucceed", optimizeResult.optimizeSucceed },
{ "resultSize", makeSizeString( optimizeResult.resultSize ) },
{ "compressionRatio", QString( "%1%2%" ).
arg( ( optimizeResult.compressionRatio < 1 ) ? ( "-" ) : ( "" ) ).
arg( 100 - (int)(optimizeResult.compressionRatio * 100) ) },
{ "compressionRatioColor", QString( "%1" ).
arg( ( optimizeResult.compressionRatio < 1 ) ? ( "#64dd17" ) : ( "#f44336" ) ) },
{ "timeConsuming", QString( "%1ms" ).arg( optimizeResult.timeConsuming ) }
} }
);
mutex.lock();
--packageCount;
if ( packageCount <= 0 )
{
emit this->optimizeEnd();
}
mutex.unlock();
};
}
emit this->optimizeStart( fileList );
return "OK";
}
```
|
/content/code_sandbox/components/ToolsGroup/PngOptimize/cpp/pngoptimize.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,282
|
```unknown
<RCC>
<qresource prefix="/PngOptimize">
<file>PngOptimize.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/ToolsGroup/PngOptimize/qml/PngOptimize.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 35
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/colorpicker.h\
$$PWD/cpp/mousedropper.h \
$$PWD/cpp/screenColorPicker.h
$$PWD/cpp/screenColorPicker.h
SOURCES *= \
$$PWD/cpp/colorpicker.cpp\
$$PWD/cpp/mousedropper.cpp\
$$PWD/cpp/screenColorPicker.cpp
RESOURCES *= \
$$PWD/qml/ScreenColorPicker.qrc
DISTFILES += \
$$PWD/res/ico/ColorPickerPen.png
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/ScreenColorPicker.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 158
|
```objective-c
#ifndef MOUSEDROPPER_H
#define MOUSEDROPPER_H
#include <QMouseEvent>
#include <QWidget>
#include <QDebug>
#include <QTimer>
class MouseDropper : public QWidget
{
Q_OBJECT
public:
explicit MouseDropper(QWidget *parent = nullptr);
QColor getColor() const;
private:
QColor color;
protected:
void paintEvent(QPaintEvent *e);
};
#endif // MOUSEDROPPER_H
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/cpp/mousedropper.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 94
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TOOLSGROUP_SCREENCOLORPICKER_CPP_SCREENCOLORPICKER_H
#define GROUP_TOOLSGROUP_SCREENCOLORPICKER_CPP_SCREENCOLORPICKER_H
// Qt lib import
#include <QJsonObject>
// JQToolsLibrary import
#include <JQToolsLibrary>
#include "colorpicker.h"
#define SCREENCOLORPICKER_INITIALIZA \
{ \
qmlRegisterType<ScreenColorPicker::Manage>("ScreenColorPicker", 1, 0, "ScreenColorPickerManage"); \
}
namespace ScreenColorPicker
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage();
~Manage() = default;
signals:
void colorSelect(const QColor & c);
public slots:
void openPicker();
void onColorSelect(const QColor & c);
void copyColorToClipboard();
private:
QColor currentColor;
ColorPicker *colorPicker;
};
}
#endif//GROUP_TOOLSGROUP_SCREENCOLORPICKER_CPP_SCREENCOLORPICKER_H
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/cpp/screenColorPicker.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 268
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "screenColorPicker.h"
#include <QClipboard>
using namespace ScreenColorPicker;
Manage::Manage(): colorPicker(new ColorPicker),currentColor(QColor("blue"))
{
connect(colorPicker, &ColorPicker::colorSelect, this, &Manage::onColorSelect);
}
void Manage::onColorSelect(const QColor & c)
{
currentColor = c;
emit colorSelect(c);
}
void Manage::openPicker()
{
colorPicker->show();
}
void Manage::copyColorToClipboard()
{
QGuiApplication::clipboard()->setText(currentColor.name());
}
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/cpp/screenColorPicker.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 157
|
```objective-c
#ifndef COLORPICKER_H
#define COLORPICKER_H
#include "mousedropper.h"
#include <QWidget>
class ColorPicker : public QWidget
{
Q_OBJECT
public:
explicit ColorPicker(QWidget *parent = nullptr);
private:
MouseDropper *mousedropper;
protected:
void paintEvent(QPaintEvent *e);
void mousePressEvent(QMouseEvent *e);
signals:
void colorSelect(const QColor & c);
public slots:
};
#endif // COLORPICKER_H
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/cpp/colorpicker.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 108
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import PngOptimize 1.0
Item {
id: pngOptimize
width: 620
height: 540
property bool changingFlag: true
Component.onCompleted: {
changingFlag = false;
}
PngOptimizeManage {
id: pngOptimizeManage
onOptimizeStart: {
buttonForChooseImage.enabled = false;
buttonForChooseDirectory.enabled = false;
materialUI.showSnackbarMessage( "" );
listModelForNodes.clear();
for ( var index = 0; index < fileList.length; ++index )
{
listModelForNodes.append( {
fileName: fileList[ index ][ "fileName" ],
filePath: fileList[ index ][ "filePath" ],
originalSize: fileList[ index ][ "originalSize" ]
} );
}
}
onOptimizeEnd: {
buttonForChooseImage.enabled = true;
buttonForChooseDirectory.enabled = true;
materialUI.showSnackbarMessage( "" );
}
}
MaterialLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 22
text: "ZopfliPNG\n\n"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
MaterialButton {
id: buttonForChooseImage
x: 254
width: 120
height: 40
text: ""
anchors.horizontalCenterOffset: 34
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 105
onClicked: {
materialUI.showLoading();
var reply = pngOptimizeManage.optimizePngByOpenFiles( radioButtonForCoverOldFile.checked );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
MaterialButton {
id: buttonForChooseDirectory
x: 254
width: 120
height: 40
text: ""
anchors.horizontalCenterOffset: 190
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 105
onClicked: {
materialUI.showLoading();
var reply = pngOptimizeManage.optimizePngByOpenDirectory( radioButtonForCoverOldFile.checked );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "empty": materialUI.showSnackbarMessage( "png" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
ExclusiveGroup {
id: exclusiveGroupForMode
}
MaterialRadioButton {
id: radioButtonForCoverOldFile
x: 115
text: ""
anchors.horizontalCenterOffset: -168
anchors.top: parent.top
anchors.topMargin: 83
anchors.horizontalCenter: parent.horizontalCenter
exclusiveGroup: exclusiveGroupForMode
}
MaterialRadioButton {
id: radioButtonForNewFile
x: 115
text: ""
anchors.horizontalCenterOffset: -161
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 126
exclusiveGroup: exclusiveGroupForMode
checked: true
}
ListView {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 180
width: 575
height: parent.height - 180
clip: true
cacheBuffer: 999999
model: ListModel {
id: listModelForNodes
}
delegate: Item {
id: itemForNodes
width: 575
height: 54
Component.onCompleted: {
pngOptimizeManage.startOptimize( filePath );
}
Connections {
target: pngOptimizeManage
onOptimizePngStart: {
if ( currentFilePath !== filePath ) { return; }
progressCircleForOptimizing.indeterminate = true;
}
onOptimizePngFinish: {
if ( currentFilePath !== filePath ) { return; }
progressCircleForOptimizing.opacity = 0;
labelForCompressionRatio.opacity = 1;
if ( !optimizeResult[ "resultSize" ] )
{
labelForCompressionRatio.text = "";
labelForCompressionRatio.color = "#ff0000";
return;
}
labelForCompressionRatio.text = optimizeResult[ "compressionRatio" ];
labelForResultSize.opacity = 1;
labelForResultSize.text = optimizeResult[ "resultSize" ];
labelForResultSize.color = optimizeResult[ "compressionRatioColor" ];
labelForTimeConsuming.opacity = 1;
labelForTimeConsuming.text = optimizeResult[ "timeConsuming" ];
}
}
RectangularGlow {
x: 5
y: 5
width: parent.width - 10
height: parent.height - 10
glowRadius: 4
spread: 0.2
color: "#44000000"
cornerRadius: 8
}
Rectangle {
x: 5
y: 5
width: parent.width - 10
height: parent.height - 10
color: "#ffffff"
}
MaterialLabel {
id: labelForFileName
x: 16
anchors.verticalCenter: parent.verticalCenter
width: 260
text: fileName
elide: Text.ElideRight
}
MaterialLabel {
id: labelForOriginalSize
anchors.right: progressCircleForOptimizing.left
anchors.rightMargin: 25
anchors.verticalCenter: parent.verticalCenter
text: originalSize
}
MaterialProgressCircle {
id: progressCircleForOptimizing
x: 360
anchors.verticalCenter: parent.verticalCenter
width: 32
height: 32
indeterminate: false
autoChangeColor: true
visible: opacity !== 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForCompressionRatio
anchors.centerIn: progressCircleForOptimizing
width: 32
height: 32
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForResultSize
anchors.left: progressCircleForOptimizing.right
anchors.leftMargin: 25
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
color: "#000000"
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForTimeConsuming
anchors.left: progressCircleForOptimizing.right
anchors.leftMargin: 95
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
}
}
DropArea {
anchors.fill: parent
onDropped: {
if( !drop.hasUrls ) { return; }
var filePaths = [ ];
for( var index = 0; index < drop.urls.length; ++index )
{
var pngFilePath = pngOptimizeManage.urlToLocalPngFilePath( drop.urls[ index ] );
if ( pngFilePath.length === 0 ) { continue; }
filePaths.push( pngFilePath);
}
if ( filePaths.length === 0 ) { return; }
materialUI.showLoading();
var reply = pngOptimizeManage.optimizePngByFilePaths( radioButtonForCoverOldFile.checked, filePaths );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
}
```
|
/content/code_sandbox/components/ToolsGroup/PngOptimize/qml/PngOptimize.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,875
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "screenColorPicker.h"
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/cpp/ScreenColorPicker
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 45
|
```c++
#include "colorpicker.h"
#include <QApplication>
#include <QGuiApplication>
#include <QScreen>
#include <QDesktopWidget>
#include <QPainter>
ColorPicker::ColorPicker(QWidget *parent)
: QWidget(parent)
, mousedropper(new MouseDropper(this))
{
resize(QGuiApplication::primaryScreen()->size());
this->setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint); //
this->setAttribute(Qt::WA_TranslucentBackground);
this->setCursor(QCursor(QPixmap("qrc:/ColorPickerPen.png"),0,19));
}
void ColorPicker::paintEvent(QPaintEvent *e)
{
Q_UNUSED( e );
QPainter painter(this);
painter.fillRect(rect(),QColor(255,255,255,1));
}
void ColorPicker::mousePressEvent(QMouseEvent *e)
{
Q_UNUSED( e );
emit colorSelect(mousedropper->getColor());
close();
}
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/cpp/colorpicker.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 205
|
```unknown
<RCC>
<qresource prefix="/ScreenColorPicker">
<file>ScreenColorPicker.qml</file>
<file>ColorChooser.png</file>
<file>ColorPickerPen.png</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/qml/ScreenColorPicker.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 55
|
```c++
#include "mousedropper.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QPainter>
#include <QScreen>
#include <QCursor>
const QSize winSize(100,100); //
const int grabInterval=50; //
const int magnificationTimes=10; //
const double split=0.7; //
const int sizeOfMouseIcon=20; //
MouseDropper::MouseDropper(QWidget *parent)
: QWidget(parent)
{
QTimer *timer=new QTimer;
setFixedSize(winSize);
setMouseTracking(true);
timer->setInterval(grabInterval);
connect(timer,&QTimer::timeout,[this,parent](){
QPoint show=QCursor::pos()+QPoint(sizeOfMouseIcon,-(winSize.height()+sizeOfMouseIcon));
if(show.y()<0)
show.setY(show.y()+winSize.height()+sizeOfMouseIcon);
if(show.x()+winSize.width()>parent->width())
show.setX(show.x()-(winSize.height()+sizeOfMouseIcon));
move(show);
update();
});
timer->start();
}
QColor MouseDropper::getColor() const
{
return color;
}
void MouseDropper::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
QPixmap grab=QGuiApplication::primaryScreen()->grabWindow(QApplication::desktop()->winId()).copy(QCursor::pos().x()-winSize.width()/magnificationTimes/2,QCursor::pos().y()-winSize.height()*split/magnificationTimes/2,winSize.width()/magnificationTimes,winSize.height()*split/magnificationTimes);
painter.drawPixmap(0,0,winSize.width(),winSize.height()*split,grab);
QPixmap pixmap = grab.copy(winSize.width()/magnificationTimes/2,winSize.height()*split/magnificationTimes/2,1,1);//1
color = pixmap.toImage().pixel(0,0);
if(color.red()>100&&color.blue()>100&&color.green()>100) //
painter.setPen(QColor(0,0,0));
else
painter.setPen(QColor(255,255,255));
painter.fillRect(0,winSize.height()*split,winSize.width()-1,winSize.height()*(1-split),QColor(100,100,100));
painter.drawRect(0,0,rect().width()-1,rect().height()-1);
painter.fillRect(4,74,22,22,color);
painter.drawLine(50,30,50,40);
painter.drawLine(45,35,55,35);
painter.setPen(QColor(255,255,255));
painter.drawText(32,82,"RGB");
painter.drawText(32,95,QString().sprintf("%d,%d,%d",(color.red()-1)*255/254,(color.green()-1)*255/254,(color.blue()-1)*255/254)); //
}
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/cpp/mousedropper.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 632
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import "qrc:/MaterialUI/Interface/"
import ScreenColorPicker 1.0
Item {
id: screenColorPicker
width: 620
height: 540
ScreenColorPickerManage {
id: screenColorPickerManage
}
Item{
anchors.centerIn: parent
width: 620
height: 540
Connections{
target: screenColorPickerManage
function onColorSelect(c){
colorlabel.color = c;
}
}
Rectangle{
id: colorlabel
width: 70
height: pickerButton.height
x: 150
y: 220
border.color: "black"
color: "blue"
}
MaterialTextField{
x: 150
y: 260
text: colorlabel.color
width: colorlabel.width
}
MaterialButton {
x: 300
y: 290
text: ""
onClicked: {
screenColorPickerManage.copyColorToClipboard();
}
}
MaterialButton {
id: pickerButton
x: 300
y: 220
text: ""
onClicked: {
screenColorPickerManage.openPicker();
}
}
}
}
```
|
/content/code_sandbox/components/ToolsGroup/ScreenColorPicker/qml/ScreenColorPicker.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 328
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
DEFINES += \
TOOLSGROUP_JPGOPTIMIZE_ENABLE
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/jpgoptimize.h
SOURCES *= \
$$PWD/cpp/jpgoptimize.cpp
RESOURCES *= \
$$PWD/qml/JpgOptimize.qrc
```
|
/content/code_sandbox/components/ToolsGroup/JpgOptimize/JpgOptimize.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 111
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H_
#define GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H_
// C++ lib import
#include <functional>
// Qt lib import
#include <QJsonObject>
#include <QJsonArray>
#include <QMap>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define JPGOPTIMIZE_INITIALIZA \
{ \
qmlRegisterType<JpgOptimize::Manage>("JpgOptimize", 1, 0, "JpgOptimizeManage"); \
}
namespace JpgOptimize
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage() = default;
~Manage() = default;
public slots:
QString optimizeJpgByFilePaths(const bool &coverOldFile, const QJsonArray &filePaths);
QString optimizeJpgByOpenFiles(const bool &coverOldFile);
QString optimizeJpgByOpenDirectory(const bool &coverOldFile);
void startOptimize(const QString ¤tFilePath);
QString urlToLocalPngOrJpgFilePath(const QVariant &url);
private:
QString optimizeJpg(const bool &coverOldFile, const QStringList &filePaths);
signals:
void optimizeStart(const QJsonArray fileList);
void optimizeJpgStart(const QString currentFilePath);
void optimizeJpgFinish(const QString currentFilePath, const QJsonObject optimizeResult);
void optimizeEnd();
private:
QMap< QString, std::function< void() > > waitOptimizeQueue_; // fileName -> package
};
}
#endif//GROUP_TOOLSGROUP_JPGOPTIMIZE_CPP_JPGOPTIMIZE_H_
```
|
/content/code_sandbox/components/ToolsGroup/JpgOptimize/cpp/jpgoptimize.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 391
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "jpgoptimize.h"
```
|
/content/code_sandbox/components/ToolsGroup/JpgOptimize/cpp/JpgOptimize
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 44
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "jpgoptimize.h"
// C++ lib import
#include <functional>
// Qt lib import
#include <QFileDialog>
#include <QStandardPaths>
#include <QtConcurrent>
// JQGuetzli import
#include "JQGuetzli.h"
#include "JQFile.h"
using namespace JpgOptimize;
QString Manage::optimizeJpgByFilePaths(const bool &coverOldFile, const QJsonArray &filePaths_)
{
QStringList filePaths;
for ( const auto &filePath: filePaths_ )
{
filePaths.push_back( filePath.toString() );
}
return this->optimizeJpg( coverOldFile, filePaths );
}
QString Manage::optimizeJpgByOpenFiles(const bool &coverOldFile)
{
QStringList filePaths;
filePaths = QFileDialog::getOpenFileNames(
nullptr,
QStringLiteral( "\u8BF7\u9009\u62E9JPG\u56FE\u7247\uFF08\u53EF\u591A\u9009\uFF09" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ),
"*.jpg"
);
if ( filePaths.isEmpty() ) { return "cancel"; }
return this->optimizeJpg( coverOldFile, filePaths );
}
QString Manage::optimizeJpgByOpenDirectory(const bool &coverOldFile)
{
QStringList filePaths;
const auto &&directoryPath = QFileDialog::getExistingDirectory(
nullptr,
QStringLiteral( "\u8BF7\u9009\u62E9\u5305\u542BJPG\u56FE\u7247\u7684\u6587\u4EF6\u5939" ),
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation )
);
if ( directoryPath.isEmpty() ) { return "cancel"; }
JQFile::foreachFileFromDirectory(
directoryPath,
[ &filePaths ]
(const QFileInfo &fileInfo)
{
if ( fileInfo.suffix().toLower() != "jpg" ) { return; }
filePaths.push_back( fileInfo.filePath() );
},
true
);
if ( directoryPath.isEmpty() ) { return "empty"; }
return this->optimizeJpg( coverOldFile, filePaths );
}
void Manage::startOptimize(const QString ¤tFilePath)
{
if ( !waitOptimizeQueue_.contains( currentFilePath ) ) { return; }
QtConcurrent::run( waitOptimizeQueue_[ currentFilePath ] );
waitOptimizeQueue_.remove( currentFilePath );
}
QString Manage::urlToLocalPngOrJpgFilePath(const QVariant &url)
{
QFileInfo fileInfo( url.toUrl().toLocalFile() );
if ( !fileInfo.isFile() ) { return { }; }
if ( !fileInfo.filePath().toLower().endsWith( ".png" ) && !fileInfo.filePath().toLower().endsWith( ".jpg" ) ) { return { }; }
return fileInfo.filePath();
}
QString Manage::optimizeJpg(const bool &coverOldFile, const QStringList &filePaths)
{
QString targetDir;
if ( !coverOldFile )
{
targetDir = QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ) + "/JQTools_OptimizeJpgResult/";
if ( !QDir( targetDir ).exists() && !QDir().mkdir( targetDir ) )
{
return "mkdir error";
}
}
QJsonArray fileList;
auto makeSizeString = [](const int &size)
{
if ( size < 1024 )
{
return QString( "%1 byte" ).arg( size );
}
else if ( size < ( 1024 * 1024 ) )
{
return QString( "%1 kb" ).arg( size / 1024 );
}
else
{
return QString( "%1.%2 mb" ).arg( size / 1024 / 1024 ).arg( size / 1024 % 1024 );
}
};
static auto packageCount = 0;
static QMutex mutex;
for ( const auto &filePath: filePaths )
{
QFileInfo fileInfo( filePath );
fileList.push_back( QJsonObject( { {
{ "fileName", fileInfo.fileName() },
{ "filePath", filePath },
{ "originalSize", makeSizeString( fileInfo.size() ) }
} } ) );
++packageCount;
waitOptimizeQueue_[ filePath ] = [
this,
filePath,
makeSizeString,
fileName = fileInfo.fileName(),
originalFilePath = filePath,
resultFilePath = ( targetDir.isEmpty() ) ? ( filePath ) : ( targetDir + "/" + fileInfo.fileName() )
]()
{
emit this->optimizeJpgStart( filePath );
auto optimizeResult = JQGuetzli::process( originalFilePath, resultFilePath );
emit this->optimizeJpgFinish(
filePath,
{ {
{ "optimizeSucceed", optimizeResult.processSucceed },
{ "resultSize", makeSizeString( optimizeResult.resultSize ) },
{ "compressionRatio", QString( "%1%2%" ).
arg( ( optimizeResult.compressionRatio < 1 ) ? ( "-" ) : ( "" ) ).
arg( 100 - (int)(optimizeResult.compressionRatio * 100) ) },
{ "compressionRatioColor", QString( "%1" ).
arg( ( optimizeResult.compressionRatio < 1 ) ? ( "#64dd17" ) : ( "#f44336" ) ) },
{ "timeConsuming", QString( "%1ms" ).arg( optimizeResult.timeConsuming ) }
} }
);
mutex.lock();
--packageCount;
if ( packageCount <= 0 )
{
emit this->optimizeEnd();
}
mutex.unlock();
};
}
emit this->optimizeStart( fileList );
return "OK";
}
```
|
/content/code_sandbox/components/ToolsGroup/JpgOptimize/cpp/jpgoptimize.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,304
|
```unknown
<RCC>
<qresource prefix="/JpgOptimize">
<file>JpgOptimize.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/ToolsGroup/JpgOptimize/qml/JpgOptimize.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 35
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/lanfiletransport.h
SOURCES *= \
$$PWD/cpp/lanfiletransport_.cpp
RESOURCES *= \
$$PWD/qml/LanFileTransport.qrc
```
|
/content/code_sandbox/components/ToolsGroup/LanFileTransport/LanFileTransport.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 100
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TOOLSGROUP_LANFILETRANSPORT_CPP_LANFILETRANSPORT_H_
#define GROUP_TOOLSGROUP_LANFILETRANSPORT_CPP_LANFILETRANSPORT_H_
// JQToolsLibrary import
#include <JQToolsLibrary>
// JQNetwork lib import
#include <JQNetworkFoundation>
#define LANFILETRANSPORT_INITIALIZA \
{ \
qmlRegisterType<LanFileTransport::Manage>("LanFileTransport", 1, 0, "LanFileTransportManage"); \
}
namespace LanFileTransport
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
struct SendCounter
{
qint64 alreadySendSizeTotal;
int alreadySendFileCount;
qint64 sizeTotal;
int fileCount;
};
public:
Manage();
~Manage();
public slots:
void setShowSelf(const bool &showSelf);
void sendOnlinePing();
QVariantList lanNodes();
QString localHostName() const;
QString localHostAddress();
QString localNodeMarkSummary();
QString transport(const QString &hostAddress, const QVariantList &filePaths);
QString savePath();
private:
void refresh();
void lanNodeOffline(const JQNetworkLanNode &node);
void emitSendingSignal(const QString &hostName, const SendCounter &counter);
signals:
void lanNodeChanged();
void sending(const QString currentHostAddress, const qreal sendPercentage);
void sendFinish(const QString currentHostAddress);
private:
QSharedPointer< JQNetworkServer > jqNetworkServer_;
QSharedPointer< JQNetworkClient > jqNetworkClient_;
QSharedPointer< JQNetworkLan > jqNetworkLan_;
QMutex mutex_;
QString savePath_;
bool showSelf_ = false;
QVariantList lanNodes_;
QMap< JQNetworkConnect *, QString > mapForConnectToHostAddress_;
QMap< QString, SendCounter > mapForConnectSendCounter_; // hostAddress -> SendCounter
};
}
#endif//GROUP_TOOLSGROUP_LANFILETRANSPORT_CPP_LANFILETRANSPORT_H_
```
|
/content/code_sandbox/components/ToolsGroup/LanFileTransport/cpp/lanfiletransport.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 479
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import JpgOptimize 1.0
Item {
id: jpgOptimize
width: 620
height: 540
property bool changingFlag: true
Component.onCompleted: {
changingFlag = false;
}
JpgOptimizeManage {
id: jpgOptimizeManage
onOptimizeStart: {
buttonForChooseImage.enabled = false;
buttonForChooseDirectory.enabled = false;
materialUI.showSnackbarMessage( "" );
listModelForNodes.clear();
for ( var index = 0; index < fileList.length; ++index )
{
listModelForNodes.append( {
fileName: fileList[ index ][ "fileName" ],
filePath: fileList[ index ][ "filePath" ],
originalSize: fileList[ index ][ "originalSize" ]
} );
}
}
onOptimizeEnd: {
buttonForChooseImage.enabled = true;
buttonForChooseDirectory.enabled = true;
materialUI.showSnackbarMessage( "" );
}
}
MaterialLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 22
text: "GuetzliJPG\n\n"
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
MaterialButton {
id: buttonForChooseImage
x: 254
width: 120
height: 40
text: ""
anchors.horizontalCenterOffset: 34
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 105
onClicked: {
materialUI.showLoading();
var reply = jpgOptimizeManage.optimizeJpgByOpenFiles( radioButtonForCoverOldFile.checked );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
MaterialButton {
id: buttonForChooseDirectory
x: 254
width: 120
height: 40
text: ""
anchors.horizontalCenterOffset: 190
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 105
onClicked: {
materialUI.showLoading();
var reply = jpgOptimizeManage.optimizeJpgByOpenDirectory( radioButtonForCoverOldFile.checked );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "empty": materialUI.showSnackbarMessage( "jpg" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
ExclusiveGroup {
id: exclusiveGroupForMode
}
MaterialRadioButton {
id: radioButtonForCoverOldFile
x: 115
text: ""
anchors.horizontalCenterOffset: -168
anchors.top: parent.top
anchors.topMargin: 83
anchors.horizontalCenter: parent.horizontalCenter
exclusiveGroup: exclusiveGroupForMode
}
MaterialRadioButton {
id: radioButtonForNewFile
x: 115
text: ""
anchors.horizontalCenterOffset: -161
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 126
exclusiveGroup: exclusiveGroupForMode
checked: true
}
ListView {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 180
width: 575
height: parent.height - 180
clip: true
cacheBuffer: 999999
model: ListModel {
id: listModelForNodes
}
delegate: Item {
id: itemForNodes
width: 575
height: 54
Component.onCompleted: {
jpgOptimizeManage.startOptimize( filePath );
}
Connections {
target: jpgOptimizeManage
onOptimizeJpgStart: {
if ( currentFilePath !== filePath ) { return; }
progressCircleForOptimizing.indeterminate = true;
}
onOptimizeJpgFinish: {
if ( currentFilePath !== filePath ) { return; }
progressCircleForOptimizing.opacity = 0;
labelForCompressionRatio.opacity = 1;
if ( !optimizeResult[ "resultSize" ] )
{
labelForCompressionRatio.text = "";
labelForCompressionRatio.color = "#ff0000";
return;
}
labelForCompressionRatio.text = optimizeResult[ "compressionRatio" ];
labelForResultSize.opacity = 1;
labelForResultSize.text = optimizeResult[ "resultSize" ];
labelForResultSize.color = optimizeResult[ "compressionRatioColor" ];
labelForTimeConsuming.opacity = 1;
labelForTimeConsuming.text = optimizeResult[ "timeConsuming" ];
}
}
RectangularGlow {
x: 5
y: 5
width: parent.width - 10
height: parent.height - 10
glowRadius: 4
spread: 0.2
color: "#44000000"
cornerRadius: 8
}
Rectangle {
x: 5
y: 5
width: parent.width - 10
height: parent.height - 10
color: "#ffffff"
}
MaterialLabel {
id: labelForFileName
x: 16
anchors.verticalCenter: parent.verticalCenter
width: 260
text: fileName
elide: Text.ElideRight
}
MaterialLabel {
id: labelForOriginalSize
anchors.right: progressCircleForOptimizing.left
anchors.rightMargin: 25
anchors.verticalCenter: parent.verticalCenter
text: originalSize
}
MaterialProgressCircle {
id: progressCircleForOptimizing
x: 360
anchors.verticalCenter: parent.verticalCenter
width: 32
height: 32
indeterminate: false
autoChangeColor: true
visible: opacity !== 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForCompressionRatio
anchors.centerIn: progressCircleForOptimizing
width: 32
height: 32
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForResultSize
anchors.left: progressCircleForOptimizing.right
anchors.leftMargin: 25
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
color: "#000000"
Behavior on opacity { NumberAnimation { duration: 300 } }
}
MaterialLabel {
id: labelForTimeConsuming
anchors.left: progressCircleForOptimizing.right
anchors.leftMargin: 95
anchors.verticalCenter: parent.verticalCenter
visible: opacity !== 0
opacity: 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
}
}
DropArea {
anchors.fill: parent
onDropped: {
if( !drop.hasUrls ) { return; }
var filePaths = [ ];
for( var index = 0; index < drop.urls.length; ++index )
{
var pngOrJpgFilePath = jpgOptimizeManage.urlToLocalPngOrJpgFilePath( drop.urls[ index ] );
if ( pngOrJpgFilePath.length === 0 ) { continue; }
filePaths.push( pngOrJpgFilePath);
}
if ( filePaths.length === 0 ) { return; }
materialUI.showLoading();
var reply = jpgOptimizeManage.optimizeJpgByFilePaths( radioButtonForCoverOldFile.checked, filePaths );
switch( reply )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "mkdir error": materialUI.showSnackbarMessage( "" ); break;
}
materialUI.hideLoading();
}
}
}
```
|
/content/code_sandbox/components/ToolsGroup/JpgOptimize/qml/JpgOptimize.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,888
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "lanfiletransport.h"
```
|
/content/code_sandbox/components/ToolsGroup/LanFileTransport/cpp/LanFileTransport
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 45
|
```unknown
<RCC>
<qresource prefix="/LanFileTransport">
<file>LanFileTransport.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/ToolsGroup/LanFileTransport/qml/LanFileTransport.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 35
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "lanfiletransport.h"
// Qt lib import
#include <QHostInfo>
#include <QStandardPaths>
#include <QtConcurrent>
// JQNetwork lib import
#include <JQNetworkLan>
#include <JQNetworkConnect>
#include <JQNetworkPackage>
#include <JQNetworkServer>
#include <JQNetworkClient>
// JQLibrary import
#include "JQFile.h"
using namespace LanFileTransport;
#define SERVERPORT 25230
#define LANPORT 25229
#define LANMULTICASTADDRESS QHostAddress( "229.134.50.25" )
Manage::Manage():
jqNetworkServer_( JQNetworkServer::createServer( SERVERPORT, QHostAddress::Any, true ) ),
jqNetworkClient_( JQNetworkClient::createClient( true ) ),
jqNetworkLan_( JQNetworkLan::createLan( LANMULTICASTADDRESS, LANPORT ) ),
savePath_( QStandardPaths::writableLocation( QStandardPaths::DownloadLocation ) )
{
jqNetworkServer_->connectSettings()->filePathProvider = [ this ](const auto &, const auto &package, const auto &fileName)->QString
{
const auto &&path = package->appendData()[ "path" ].toString();
if ( path.isEmpty() )
{
qDebug() << "filePathProvider: package append dont contains path, fileName:" << fileName;
return "";
}
return this->savePath_ + path;
};
jqNetworkServer_->serverSettings()->packageReceivedCallback = [ ](const JQNetworkConnectPointer &connect, const JQNetworkPackageSharedPointer &package)
{
// qDebug() << "packageReceivedCallback:" << package->appendData();
connect->replyPayloadData( package->randomFlag(), { } );
};
jqNetworkClient_->connectSettings()->maximumConnectToHostWaitTime = 5000;
jqNetworkClient_->clientSettings()->packageSendingCallback = [ this ](
const JQNetworkConnectPointer &,
const QString &hostName,
const quint16 &,
const qint32 &,
const qint64 &payloadCurrentIndex,
const qint64 &payloadCurrentSize,
const qint64 &payloadTotalSize
)
{
this->mutex_.lock();
auto it = this->mapForConnectSendCounter_.find( hostName );
if ( it == this->mapForConnectSendCounter_.end() )
{
// qDebug() << "packageSendingCallback: error";
this->mutex_.unlock();
return;
}
it.value().alreadySendSizeTotal += payloadCurrentSize;
if ( ( payloadCurrentIndex + payloadCurrentSize ) == payloadTotalSize )
{
++it.value().alreadySendFileCount;
}
this->emitSendingSignal( hostName, it.value() );
this->mutex_.unlock();
};
jqNetworkLan_->setAppendData( this->localHostName() );
jqNetworkLan_->lanSettings()->lanNodeListChangedCallback = std::bind( &Manage::refresh, this );
jqNetworkLan_->lanSettings()->lanNodeOfflineCallback = std::bind( &Manage::lanNodeOffline, this, std::placeholders::_1 );
qDebug() << "JQNetworkServer begin:" << jqNetworkServer_->begin();
qDebug() << "JQNetworkClient begin:" << jqNetworkClient_->begin();
qDebug() << "JQNetworkLan begin:" << jqNetworkLan_->begin();
}
Manage::~Manage()
{
jqNetworkLan_.clear();
jqNetworkClient_.clear();
jqNetworkServer_.clear();
mutex_.lock();
lanNodes_.clear();
mutex_.unlock();
}
void Manage::setShowSelf(const bool &showSelf)
{
showSelf_ = showSelf;
this->refresh();
}
void Manage::sendOnlinePing()
{
jqNetworkLan_->sendOnline();
}
QVariantList Manage::lanNodes()
{
mutex_.lock();
const auto lanNodes = lanNodes_;
mutex_.unlock();
return lanNodes;
}
QString Manage::localHostName() const
{
#if ( defined Q_OS_MAC )
return QHostInfo::localHostName().replace( ".local", "" );
#else
return QHostInfo::localHostName();
#endif
}
QString Manage::localHostAddress()
{
auto lanAddressEntries = jqNetworkLan_->lanAddressEntries();
if ( lanAddressEntries.isEmpty() ) { return ""; }
return lanAddressEntries.first().ip.toString();
}
QString Manage::localNodeMarkSummary()
{
return jqNetworkLan_->nodeMarkSummary();
}
QString Manage::transport(const QString &hostAddress, const QVariantList &filePaths)
{
if ( filePaths.isEmpty() ) { return "cancel"; }
qint64 sizeTotal = 0;
int fileCount = 0;
QString rootPath;
QSharedPointer< QList< QPair< QString, QFileInfo > > > sourceSmallFileList( new QList< QPair< QString, QFileInfo > > ); // [ { path, fileInfo }, ... ]
QSharedPointer< QList< QPair< QString, QFileInfo > > > sourceBigFileList( new QList< QPair< QString, QFileInfo > > ); // [ { path, fileInfo }, ... ]
auto pushFileToList = [ &sizeTotal, &fileCount, &sourceSmallFileList, &sourceBigFileList, &rootPath ](const QFileInfo &fileInfo)
{
if ( !fileInfo.isFile() || !fileInfo.exists() ) { return; }
if ( rootPath.isEmpty() )
{
qDebug() << "Manage::transport: error";
return;
}
sizeTotal += fileInfo.size();
++fileCount;
if ( fileInfo.size() > 16 * 1024 * 1024 )
{
sourceBigFileList->push_back( { fileInfo.filePath().mid( rootPath.size() ), fileInfo } );
}
else
{
sourceSmallFileList->push_back( { fileInfo.filePath().mid( rootPath.size() ), fileInfo } );
}
};
for ( const auto &filePath: filePaths )
{
auto filePath_ = filePath.toString();
if ( filePath_.endsWith( "/" ) )
{
filePath_.remove( filePath_.size() - 1, 1 );
}
QFileInfo currentFileInfo( filePath_ );
if ( rootPath.isEmpty() )
{
rootPath = currentFileInfo.path();
}
if ( currentFileInfo.isFile() )
{
pushFileToList( currentFileInfo );
}
else
{
JQFile::foreachFileFromDirectory(
QDir( filePath_ ),
[ &pushFileToList ](const QFileInfo &fileInfo)
{
pushFileToList( fileInfo );
},
true
);
}
}
mutex_.lock();
mapForConnectSendCounter_[ hostAddress ] = { 0, 0, sizeTotal, fileCount };
mutex_.unlock();
QSharedPointer< JQNetworkConnectPointerAndPackageSharedPointerFunction > continueSend( new JQNetworkConnectPointerAndPackageSharedPointerFunction );
*continueSend = [ this, continueSend, sourceSmallFileList, sourceBigFileList, hostAddress ](const JQNetworkConnectPointer &, const JQNetworkPackageSharedPointer &)
{
QPair< QString, QFileInfo > currentPair;
if ( !sourceSmallFileList->isEmpty() )
{
currentPair = sourceSmallFileList->first();
sourceSmallFileList->pop_front();
}
else if ( !sourceBigFileList->isEmpty() )
{
currentPair = sourceBigFileList->first();
sourceBigFileList->pop_front();
}
else
{
// qDebug() << "continueSend: finished:" << hostAddress;
emit this->sendFinish( hostAddress );
return;
}
// qDebug() << "continueSend:" << hostAddress << currentPair.first;
this->jqNetworkClient_->sendFileData(
hostAddress,
SERVERPORT,
{ }, // empty targetActionFlag
currentPair.second,
{ { "path", currentPair.first } },
*continueSend,
[ ](const JQNetworkConnectPointer &)
{
qDebug() << "continueSend error";
}
);
};
( *continueSend )( JQNetworkConnectPointer(), JQNetworkPackageSharedPointer() );
return "OK";
}
QString Manage::savePath()
{
return savePath_;
}
void Manage::refresh()
{
qDebug() << "\nManage::refreshLanNodes start";
QVariantList buf;
for ( const auto &lanNode: this->jqNetworkLan_->availableLanNodes() )
{
qDebug() << "Manage::refreshLanNodes:" << lanNode.matchAddress;
const auto &hostAddress = lanNode.matchAddress.toString();
if ( !showSelf_ && lanNode.isSelf ) { continue; }
auto connect = this->jqNetworkClient_->getConnect( hostAddress, SERVERPORT );
qDebug() << "Manage::refreshLanNodes: getConnect:" << connect.data();
if ( connect )
{
this->mapForConnectToHostAddress_[ connect.data() ] = hostAddress;
}
else
{
auto connectCount = 0;
for ( ; connectCount < 2; ++connectCount )
{
qDebug() << "Manage::refreshLanNodes: connect to:" << hostAddress;
if ( this->jqNetworkClient_->waitForCreateConnect( hostAddress, SERVERPORT ) )
{
break;
}
}
if ( connectCount == 2 )
{
qDebug() << "Manage::refreshLanNodes: connect fail:" << hostAddress;
}
else
{
qDebug() << "Manage::refreshLanNodes: connect succeed:" << hostAddress;
}
}
buf.push_back( QVariantMap( {
{ "nodeMarkSummary", lanNode.nodeMarkSummary },
{ "hostName", lanNode.appendData },
{ "hostAddress", hostAddress }
} ) );
}
mutex_.lock();
lanNodes_ = buf;
mutex_.unlock();
emit this->lanNodeChanged();
qDebug() << "Manage::refreshLanNodes end";
}
void Manage::lanNodeOffline(const JQNetworkLanNode &node)
{
mutex_.lock();
for ( auto index = 0; index < lanNodes_.size(); ++index )
{
if ( lanNodes_[ index ].toMap()[ "nodeMarkSummary" ] == node.nodeMarkSummary )
{
lanNodes_.removeAt( index );
break;
}
}
mutex_.unlock();
emit this->lanNodeChanged();
qDebug() << "Manage::refreshLanNodes";
}
void Manage::emitSendingSignal(const QString &hostName, const SendCounter &counter)
{
// qDebug() << "emitSendingSignal:" << hostName << counter.alreadySendSizeTotal << counter.alreadySendFileCount << counter.sizeTotal << counter.fileCount;
qreal sendPercentage = ( static_cast< double >( counter.alreadySendSizeTotal ) / static_cast< double >( counter.sizeTotal ) ) * 0.7 +
( static_cast< double >( counter.alreadySendFileCount ) / static_cast< double >( counter.fileCount ) ) * 0.3;
emit this->sending( hostName, sendPercentage );
}
```
|
/content/code_sandbox/components/ToolsGroup/LanFileTransport/cpp/lanfiletransport_.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 2,470
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/linesstatistics.h
SOURCES *= \
$$PWD/cpp/linesstatistics.cpp
RESOURCES *= \
$$PWD/qml/LinesStatistics.qrc
```
|
/content/code_sandbox/components/ToolsGroup/LinesStatistics/LinesStatistics.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 96
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "linesstatistics.h"
// Qt lib import
#include <QSet>
#include <QFileDialog>
#include <QStandardPaths>
#include <QJsonArray>
#include <QEventLoop>
#include <QtConcurrent>
// JQLibrary import
#include "JQFile.h"
using namespace LinesStatistics;
QJsonObject Manage::statisticsLines(const QJsonArray &suffixs)
{
auto fileCount = 0;
auto lineCount = 0;
auto currentPath = QFileDialog::getExistingDirectory( nullptr,
"Please choose code dir",
QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ) );
if ( currentPath.isEmpty() )
{
return
{ {
{ "cancel", true }
} };
}
QSet< QString > availableSuffixs;
for ( const auto suffix: suffixs )
{
availableSuffixs.insert( suffix.toString().toLower() );
}
QEventLoop eventLoop;
QtConcurrent::run( [ & ]()
{
static QSet< QString > imageSuffixs;
if ( imageSuffixs.isEmpty() )
{
imageSuffixs.insert( "png" );
imageSuffixs.insert( "jpg" );
imageSuffixs.insert( "jpeg" );
imageSuffixs.insert( "bmp" );
imageSuffixs.insert( "gif" );
imageSuffixs.insert( "svg" );
imageSuffixs.insert( "psd" );
imageSuffixs.insert( "ai" );
}
JQFile::foreachFileFromDirectory( { currentPath }, [ & ](const QFileInfo &info)
{
if ( !availableSuffixs.contains( info.suffix().toLower() ) ) { return; }
QFile file( info.filePath() );
if ( !file.open( QIODevice::ReadOnly ) ) { return; }
fileCount++;
const auto &&fileAllData = file.readAll();
if ( fileAllData.isEmpty() ) { return; }
if ( imageSuffixs.contains( info.suffix().toLower() ) ) { return; }
lineCount += fileAllData.count('\n') + 1;
}, true );
eventLoop.quit();
} );
eventLoop.exec();
return
{ {
{ "fileCount", fileCount },
{ "lineCount", lineCount }
} };
}
```
|
/content/code_sandbox/components/ToolsGroup/LinesStatistics/cpp/linesstatistics.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 543
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import LanFileTransport 1.0
Item {
id: lanFileTransport
width: 620
height: 540
property bool changingFlag: true
Component.onCompleted: {
changingFlag = false;
}
LanFileTransportManage {
id: lanFileTransportManage
}
PathView {
id: pathView
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: -10
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 140
width: 400
height: 400
delegate: Item {
id: item
width: 128
height: 128
visible: nodeMarkSummary !== "invisibleItem"
MaterialProgressCircle {
id: progressCircleForSend
anchors.centerIn: parent
width: 110
height: 110
indeterminate: false
showPercentage: false
circleColor: "#2196f3"
Behavior on value { PropertyAnimation { duration: 200 } }
Connections {
target: lanFileTransportManage
onSending: {
if ( currentHostAddress !== hostAddress ) { return; }
progressCircleForSend.value = sendPercentage;
}
onSendFinish: {
if ( currentHostAddress !== hostAddress ) { return; }
progressCircleForSend.value = 1;
materialUI.showSnackbarMessage( "" );
}
}
}
MaterialActionButton {
anchors.centerIn: parent
width: 100
height: 100
text: hostName + "\n"
backgroundColor: "#ffffff"
scale: 1.5
opacity: 0
onClicked: {
materialUI.showSnackbarMessage( "" + nodeMarkSummary );
}
Component.onCompleted: {
scale = 1;
opacity = 1;
}
Behavior on scale { PropertyAnimation { duration: 1000; easing.type: Easing.OutElastic } }
Behavior on opacity { PropertyAnimation { duration: 300 } }
MaterialLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 11
color: "#a1a1a1"
text: "\n" + hostAddress
}
}
DropArea {
anchors.fill: parent
enabled: ( progressCircleForSend.value === 0 ) || ( progressCircleForSend.value === 1 )
onDropped: {
if( !drop.hasUrls ) { return; }
var filePaths = [ ];
for( var index = 0; index < drop.urls.length; ++index )
{
var url = drop.urls[ index ].toString();
if ( url.indexOf( "file://" ) !== 0 ) { return; }
if ( Qt.platform.os === "windows" )
{
filePaths.push( url.substr( 8 ) );
}
else
{
filePaths.push( url.substr( 7 ) );
}
}
var transportResult = lanFileTransportManage.transport( hostAddress, filePaths );
switch ( transportResult )
{
case "cancel": materialUI.showSnackbarMessage( "" ); break;
case "packFail": materialUI.showSnackbarMessage( "" ); break;
case "OK": materialUI.showSnackbarMessage( "" ); break;
}
}
}
}
path: Path {
startX: ( pathView.width / 2 ) * 0.3
startY: ( pathView.width / 2 ) * 1.2
PathArc {
x: ( pathView.width / 2 ) * 1.8
y: ( pathView.width / 2 ) * 1.2
radiusX: ( pathView.width / 2 )
radiusY: ( pathView.width / 2 )
useLargeArc: true
}
}
model: ListModel {
id: listModel
ListElement {
nodeMarkSummary: "invisibleItem"
hostName: "invisibleItem"
hostAddress: "invisibleItem"
}
}
function refresh() {
var lanNodes = lanFileTransportManage.lanNodes();
var waitForCreate = [ ];
var alreadyCreated = [ ];
for ( var index in lanNodes )
{
var lanNode = lanNodes[ index ];
var flag = false;
for ( var index2 = 1; index2 < listModel.count; ++index2 )
{
if ( listModel.get( index2 ).nodeMarkSummary !== lanNode[ "nodeMarkSummary" ] ) { continue; }
alreadyCreated.push( lanNode[ "nodeMarkSummary" ] );
flag = true;
break;
}
if ( !flag )
{
waitForCreate.push( lanNode );
}
}
for ( var index3 = 1; index3 < listModel.count; )
{
if ( alreadyCreated.indexOf( listModel.get( index3 ).nodeMarkSummary ) === -1 )
{
listModel.remove( index3 );
index3 = 1;
}
else
{
++index3;
}
}
for ( var index4 = 0; index4 < waitForCreate.length; ++index4 )
{
listModel.append( waitForCreate[ index4 ] );
}
}
Component.onCompleted: {
refresh();
}
Connections {
target: lanFileTransportManage
onLanNodeChanged: {
pathView.refresh();
}
}
}
MaterialActionButton {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 40
width: 128
height: 128
text: lanFileTransportManage.localHostName() + "\n"
onClicked: {
materialUI.showSnackbarMessage( "" + lanFileTransportManage.localNodeMarkSummary() );
lanFileTransportManage.sendOnlinePing();
}
MaterialLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 11
color: "#ffffff"
text: "\n" + lanFileTransportManage.localHostAddress()
}
}
MaterialLabel {
anchors.right: parent.right
anchors.rightMargin: 10
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
text: ""
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignRight
color: "#a1a1a1"
}
MaterialLabel {
anchors.left: parent.left
anchors.leftMargin: 15
anchors.bottom: parent.bottom
anchors.bottomMargin: 45
text: "" + lanFileTransportManage.savePath();
color: "#a1a1a1"
}
MaterialSwitch {
anchors.left: parent.left
anchors.leftMargin: 15
anchors.bottom: parent.bottom
anchors.bottomMargin: 15
onCheckedChanged: {
lanFileTransportManage.setShowSelf( checked );
}
MaterialLabel {
anchors.left: parent.right
anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
text: ""
color: "#a1a1a1"
}
}
}
```
|
/content/code_sandbox/components/ToolsGroup/LanFileTransport/qml/LanFileTransport.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 1,651
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "linesstatistics.h"
```
|
/content/code_sandbox/components/ToolsGroup/LinesStatistics/cpp/LinesStatistics
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 44
|
```unknown
<RCC>
<qresource prefix="/LinesStatistics">
<file>LinesStatistics.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/ToolsGroup/LinesStatistics/qml/LinesStatistics.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 32
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H_
#define GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H_
// Qt lib import
#include <QJsonObject>
// JQToolsLibrary import
#include <JQToolsLibrary>
#define LINESSTATISTICS_INITIALIZA \
{ \
qmlRegisterType<LinesStatistics::Manage>("LinesStatistics", 1, 0, "LinesStatisticsManage"); \
}
namespace LinesStatistics
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage() = default;
~Manage() = default;
public slots:
QJsonObject statisticsLines(const QJsonArray &suffixs);
};
}
#endif//GROUP_TOOLSGROUP_LINESSTATISTICS_CPP_LINESSTATISTICS_H_
```
|
/content/code_sandbox/components/ToolsGroup/LinesStatistics/cpp/linesstatistics.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 202
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "textgroup.h"
```
|
/content/code_sandbox/components/TextGroup/TextGroup
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 44
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef TEXTGROUP_TEXTGROUP_H_
#define TEXTGROUP_TEXTGROUP_H_
// TextGroup lib import
#include <Utf16Transform>
#include <RgbStringTransform>
#include <CaseTransform>
#include <RandomPassword>
#include <RandomUuid>
#include <UrlEncode>
#include <JsonFormat>
#include <StringSort>
#define TEXTGROUP_INITIALIZA \
UTF16TRANSFORM_INITIALIZA; \
RGBSTRINGTRANSFORM_INITIALIZA; \
CASETRANSFORM_INITIALIZA; \
RANDOMPASSWORD_INITIALIZA; \
RANDOMUUID_INITIALIZA; \
URLENCODE_INITIALIZA; \
JSONFORMAT_INITIALIZA; \
STRINGSORT_INITIALIZA;
#endif//TEXTGROUP_TEXTGROUP_H_
```
|
/content/code_sandbox/components/TextGroup/textgroup.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 177
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
include( $$PWD/Utf16Transform/Utf16Transform.pri )
include( $$PWD/RgbStringTransform/RgbStringTransform.pri )
include( $$PWD/UrlEncode/UrlEncode.pri )
include( $$PWD/RandomPassword/RandomPassword.pri )
include( $$PWD/RandomUuid/RandomUuid.pri )
include( $$PWD/CaseTransform/CaseTransform.pri )
include( $$PWD/JsonFormat/JsonFormat.pri )
include( $$PWD/StringSort/StringSort.pri )
INCLUDEPATH *= \
$$PWD/
HEADERS *= \
$$PWD/textgroup.h
```
|
/content/code_sandbox/components/TextGroup/TextGroup.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 171
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/jsonformat.h
SOURCES *= \
$$PWD/cpp/jsonformat.cpp
RESOURCES *= \
$$PWD/qml/JsonFormat.qrc
```
|
/content/code_sandbox/components/TextGroup/JsonFormat/JsonFormat.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 94
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "jsonformat.h"
```
|
/content/code_sandbox/components/TextGroup/JsonFormat/cpp/JsonFormat
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 44
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import LinesStatistics 1.0
Item {
id: linesStatistics
width: 620
height: 540
property bool changingFlag: true
Component.onCompleted: {
changingFlag = false;
}
LinesStatisticsManage {
id: linesStatisticsManage
}
Item {
anchors.centerIn: parent
width: 620
height: 540
MaterialLabel {
x: 64
y: 136
text: ""
}
MaterialCheckBox {
id: checkBoxForCpp
x: 64
y: 162
text: "h/c/cc/cp/cpp/hpp/inc/i/ii/m"
checked: true
}
MaterialCheckBox {
id: checkBoxForQmake
x: 64
y: 222
text: "pro/pri/prf/prl"
checked: true
}
MaterialCheckBox {
id: checkBoxForQml
x: 64
y: 282
text: "qml"
checked: true
}
MaterialCheckBox {
id: checkBoxForImage
x: 64
y: 342
text: "png/jpg/jpeg/bmp/gif/svg/psd/ai"
checked: false
}
MaterialButton {
x: 254
y: 278
width: 120
height: 40
text: ""
anchors.horizontalCenterOffset: 134
anchors.verticalCenterOffset: 32
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
onClicked: {
materialUI.showLoading();
var suffixs = new Array;
if ( checkBoxForCpp.checked )
{
suffixs.push( "h" );
suffixs.push( "c" );
suffixs.push( "cc" );
suffixs.push( "cp" );
suffixs.push( "cpp" );
suffixs.push( "hpp" );
suffixs.push( "inc" );
suffixs.push( "i" );
suffixs.push( "ii" );
suffixs.push( "m" );
}
if ( checkBoxForQml.checked )
{
suffixs.push( "qml" );
}
if ( checkBoxForQmake.checked )
{
suffixs.push( "pro" );
suffixs.push( "pri" );
suffixs.push( "prf" );
suffixs.push( "prl" );
}
if ( checkBoxForImage.checked )
{
suffixs.push( "png" );
suffixs.push( "jpg" );
suffixs.push( "jpeg" );
suffixs.push( "bmp" );
suffixs.push( "gif" );
suffixs.push( "svg" );
suffixs.push( "psd" );
suffixs.push( "ai" );
}
var reply = linesStatisticsManage.statisticsLines( suffixs );
if ( "cancel" in reply )
{
materialUI.showSnackbarMessage( "" );
materialUI.hideLoading();
return;
}
labelForLinesCount.fileCount = reply[ "fileCount" ];
labelForLinesCount.lineCount = reply[ "lineCount" ];
materialUI.hideLoading();
}
}
MaterialLabel {
id: labelForLinesCount
text: "" + fileCount + "\n" + lineCount
anchors.horizontalCenterOffset: 134
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
anchors.verticalCenterOffset: -53
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
property int fileCount: 0
property int lineCount: 0
}
}
}
```
|
/content/code_sandbox/components/ToolsGroup/LinesStatistics/qml/LinesStatistics.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 893
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H_
#define GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H_
// JQToolsLibrary import
#include <JQToolsLibrary>
#define JSONFORMAT_INITIALIZA \
{ \
qmlRegisterType<JsonFormat::Manage>("JsonFormat", 1, 0, "JsonFormatManage"); \
}
namespace JsonFormat
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage() = default;
~Manage() = default;
public slots:
bool check(const QString &string);
QString format(const QString &string, const bool &compact);
};
}
#endif//GROUP_TEXTGROUP_JSONFORMAT_CPP_JSONFORMAT_H_
```
|
/content/code_sandbox/components/TextGroup/JsonFormat/cpp/jsonformat.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 190
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "jsonformat.h"
// Qt lib import
#include <QJsonObject>
#include <QJsonDocument>
using namespace JsonFormat;
bool Manage::check(const QString &string)
{
return !QJsonDocument::fromJson( string.toUtf8() ).isNull();
}
QString Manage::format(const QString &string, const bool &compact)
{
return QJsonDocument::fromJson( string.toUtf8() ).toJson( ( compact ) ? ( QJsonDocument::Compact ) : ( QJsonDocument::Indented ) );
}
```
|
/content/code_sandbox/components/TextGroup/JsonFormat/cpp/jsonformat.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 145
|
```unknown
<RCC>
<qresource prefix="/JsonFormat">
<file>JsonFormat.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/TextGroup/JsonFormat/qml/JsonFormat.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 32
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/urlencode.h
SOURCES *= \
$$PWD/cpp/urlencode.cpp
RESOURCES *= \
$$PWD/qml/UrlEncode.qrc
```
|
/content/code_sandbox/components/TextGroup/UrlEncode/UrlEncode.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 94
|
```objective-c
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#ifndef GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H_
#define GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H_
// JQToolsLibrary import
#include <JQToolsLibrary>
#define URLENCODE_INITIALIZA \
{ \
qmlRegisterType<UrlEncode::Manage>("UrlEncode", 1, 0, "UrlEncodeManage"); \
}
namespace UrlEncode
{
class Manage: public AbstractTool
{
Q_OBJECT
Q_DISABLE_COPY(Manage)
public:
Manage() = default;
~Manage() = default;
public slots:
QString encode(const QString &string);
QString decode(const QString &string);
};
}
#endif//GROUP_TEXTGROUP_URLENCODE_CPP_URLENCODE_H_
```
|
/content/code_sandbox/components/TextGroup/UrlEncode/cpp/urlencode.h
|
objective-c
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 204
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import JsonFormat 1.0
Item {
id: jsonFormat
width: 620
height: 540
function format() {
if ( !jsonFormatManage.check( textFieldForSource.text ) )
{
materialUI.showSnackbarMessage( "JSON" );
return false;
}
textFieldForSource.text = jsonFormatManage.format( textFieldForSource.text, checkBoxForCompact.checked );
return true;
}
JsonFormatManage {
id: jsonFormatManage
}
MaterialButton {
x: 386
text: ""
anchors.horizontalCenterOffset: 0
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 39
onClicked: jsonFormat.format();
}
MaterialButton {
x: 386
text: ""
anchors.horizontalCenterOffset: 172
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 39
onClicked: {
textFieldForSource.text = jsonFormatManage.clipboardText();
if ( !jsonFormat.format() ) { return; }
jsonFormatManage.setClipboardText( textFieldForSource.text );
materialUI.showSnackbarMessage( "JSON" );
}
}
MaterialCheckBox {
id: checkBoxForCompact
x: 192
text: ""
anchors.horizontalCenterOffset: -147
anchors.top: parent.top
anchors.topMargin: 30
anchors.horizontalCenter: parent.horizontalCenter
}
RectangularGlow {
z: -1
anchors.fill: itemForSource
glowRadius: 6
spread: 0.22
color: "#20000000"
}
Item {
id: itemForSource
anchors.left: parent.left
anchors.leftMargin: 10
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
width: jsonFormat.width - 20
height: jsonFormat.height - 110
clip: true
Rectangle {
anchors.fill: parent
color: "#ffffff"
}
Flickable {
x: 5
y: 5
width: parent.width - 10
height: parent.height - 10
contentWidth: textFieldForSource.paintedWidth
contentHeight: textFieldForSource.paintedHeight
clip: true
TextEdit {
id: textFieldForSource
width: parent.width
height: parent.height
selectByMouse: true
selectionColor: "#2799f3"
text: "{}"
}
}
MouseArea {
anchors.fill: parent
visible: !textFieldForSource.focus
onClicked: {
textFieldForSource.focus = true;
}
}
}
}
```
|
/content/code_sandbox/components/TextGroup/JsonFormat/qml/JsonFormat.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 679
|
```unknown
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "urlencode.h"
```
|
/content/code_sandbox/components/TextGroup/UrlEncode/cpp/UrlEncode
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 43
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "urlencode.h"
// Qt lib import
#include <QDebug>
#include <QColor>
#include <QUrl>
using namespace UrlEncode;
QString Manage::encode(const QString &string)
{
return QUrl::toPercentEncoding( string, "/:?=&%" );
}
QString Manage::decode(const QString &string)
{
return QUrl::fromPercentEncoding( string.toUtf8() );
}
```
|
/content/code_sandbox/components/TextGroup/UrlEncode/cpp/urlencode.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 120
|
```unknown
<RCC>
<qresource prefix="/UrlEncode">
<file>UrlEncode.qml</file>
</qresource>
</RCC>
```
|
/content/code_sandbox/components/TextGroup/UrlEncode/qml/UrlEncode.qrc
|
unknown
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 32
|
```qmake
#
# This file is part of JQTools
#
# Project introduce: path_to_url
#
#
# Contact email: Jason@JasonServer.com
#
# GitHub: path_to_url
#
INCLUDEPATH *= \
$$PWD/cpp/
HEADERS *= \
$$PWD/cpp/casetransform.h
SOURCES *= \
$$PWD/cpp/casetransform.cpp
RESOURCES *= \
$$PWD/qml/CaseTransform.qrc
```
|
/content/code_sandbox/components/TextGroup/CaseTransform/CaseTransform.pri
|
qmake
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 98
|
```c++
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
#include "casetransform.h"
// Qt lib import
#include <QColor>
#include <QUrl>
using namespace CaseTransform;
QString Manage::upper(const QString &string)
{
return string.toUpper();
}
QString Manage::lower(const QString &string)
{
return string.toLower();
}
```
|
/content/code_sandbox/components/TextGroup/CaseTransform/cpp/casetransform.cpp
|
c++
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 100
|
```qml
/*
This file is part of JQTools
Project introduce: path_to_url
Contact email: Jason@JasonServer.com
GitHub: path_to_url
*/
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import UrlEncode 1.0
Item {
id: urlEncode
width: 620
height: 540
property bool changingFlag: true
Component.onCompleted: {
changingFlag = false;
}
UrlEncodeManage {
id: urlEncodeManage
}
Item {
anchors.centerIn: parent
width: 620
height: 540
MaterialTextField {
id: textFieldForSource
x: 40
y: 148
width: 540
placeholderText: "URL"
text: "path_to_url"
onTextChanged: {
if ( urlEncode.changingFlag ) { return; }
urlEncode.changingFlag = true;
textFieldForTarget.text = urlEncodeManage.encode( textFieldForSource.text );
urlEncode.changingFlag = false;
}
}
MaterialButton {
x: 40
y: 106
width: 120
text: ""
onClicked: {
textFieldForSource.text = urlEncodeManage.clipboardText();
materialUI.showSnackbarMessage( "URL" );
}
}
MaterialTextField {
id: textFieldForTarget
x: 40
y: 308
width: 540
placeholderText: "URL"
text: "path_to_url"
onTextChanged: {
if ( urlEncode.changingFlag ) { return; }
urlEncode.changingFlag = true;
textFieldForSource.text = urlEncodeManage.decode( textFieldForTarget.text );
urlEncode.changingFlag = false;
}
}
MaterialButton {
x: 40
y: 266
width: 120
text: ""
onClicked: {
urlEncodeManage.setClipboardText( textFieldForTarget.text );
materialUI.showSnackbarMessage( "URL" );
}
}
}
}
```
|
/content/code_sandbox/components/TextGroup/UrlEncode/qml/UrlEncode.qml
|
qml
| 2016-05-15T04:09:51
| 2024-08-15T07:23:05
|
JQTools
|
188080501/JQTools
| 1,683
| 482
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.