Skip to content

Commit

Permalink
Upload V16.6.7
Browse files Browse the repository at this point in the history
  • Loading branch information
188080501 committed Jun 7, 2016
1 parent 9a8bd30 commit 41013c4
Show file tree
Hide file tree
Showing 62 changed files with 369 additions and 146 deletions.
11 changes: 11 additions & 0 deletions Groups/Text/JsonFormat/JsonFormat.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
INCLUDEPATH += \
$$PWD/cpp/

HEADERS += \
$$PWD/cpp/JsonFormat.h

SOURCES += \
$$PWD/cpp/JsonFormat.cpp

RESOURCES += \
$$PWD/qml/JsonFormat.qrc
32 changes: 32 additions & 0 deletions Groups/Text/JsonFormat/cpp/JsonFormat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "JsonFormat.h"

// Qt lib import
#include <QClipboard>
#include <QApplication>
#include <QJsonObject>
#include <QJsonDocument>

// JQToolsLibrary import
#include "JQToolsLibrary.hpp"

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 ) );
}

QString Manage::clipboardText()
{
return qApp->clipboard()->text();
}

void Manage::setClipboardText(const QString &string)
{
qApp->clipboard()->setText( string );
}
37 changes: 37 additions & 0 deletions Groups/Text/JsonFormat/cpp/JsonFormat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef __JsonFormat_h__
#define __JsonFormat_h__

// Qt lib import
#include <QObject>

#define JSONFORMAT_INITIALIZA \
{ \
qmlRegisterType<JsonFormat::Manage>("JsonFormat", 1, 0, "JsonFormatManage"); \
}

namespace JsonFormat
{

class Manage: public QObject
{
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);

QString clipboardText();

void setClipboardText(const QString &string);
};

}

#endif//__JsonFormat_h__
96 changes: 96 additions & 0 deletions Groups/Text/JsonFormat/qml/JsonFormat.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import QtQuick 2.5
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"
}

TextEdit {
id: textFieldForSource
x: 5
y: 5
width: parent.width - 10
height: parent.height - 10
wrapMode: TextInput.WrapAnywhere
}
}
}
5 changes: 5 additions & 0 deletions Groups/Text/JsonFormat/qml/JsonFormat.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/JsonFormat">
<file>JsonFormat.qml</file>
</qresource>
</RCC>
1 change: 1 addition & 0 deletions Groups/Text/Text.pri
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ include($$PWD/RgbStringTransform/RgbStringTransform.pri)
include($$PWD/UrlEncode/UrlEncode.pri)
include($$PWD/RandomPassword/RandomPassword.pri)
include($$PWD/CaseTransform/CaseTransform.pri)
include($$PWD/JsonFormat/JsonFormat.pri)
5 changes: 5 additions & 0 deletions Library/JQLibrary/JQLibrary.pri
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ exists($$PWD/src/JQEncrypt.cpp) {
HEADERS *= $$PWD/include/JQEncrypt.h
}

exists($$PWD/src/JQExcel.cpp) {
SOURCES *= $$PWD/src/JQExcel.cpp
HEADERS *= $$PWD/include/JQExcel.h
}

exists($$PWD/src/JQFile.cpp) {
SOURCES *= $$PWD/src/JQFile.cpp
HEADERS *= $$PWD/include/JQFile.h
Expand Down
Binary file modified Library/JQLibrary/bin/JQQmlLib/Qt5.6.0/MinGW/libJQQmlLib.a
Binary file not shown.
13 changes: 3 additions & 10 deletions Library/JQLibrary/include/JQFoundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,21 @@

// Qt lib import
#include <QCoreApplication>
#include <QMetaMethod>
#include <QCryptographicHash>
#include <QMutex>
#include <QCryptographicHash>
#include <QSettings>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QDebug>
#include <QEventLoop>
#include <QTimer>
#include <QBuffer>
#include <QThread>
#include <QDateTime>
#include <QTime>
#include <QHash>
#include <QVariant>
#include <QPointer>
#include <QFile>

#include <QImage>
#include <QPainter>
#include <QMessageBox>
#include <QDebug>

class QTableWidget;
class QTreeWidget;
Expand Down Expand Up @@ -98,7 +91,7 @@ class QLineEdit;
private:

#define PrimaryKeyPropertyDeclare(ClassName, Type, name, ...) \
Type Name __VA_ARGS__; \
Type name __VA_ARGS__; \
ClassName() = default; \
ClassName(const Type &name ## _): name(name ## _) { } \
operator QVariant() const { return name; } \
Expand Down
2 changes: 1 addition & 1 deletion Library/JQLibrary/include/JQQmlLib/JQQmlLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define JQQmlLibAddToEngine(engine) \
{ \
Q_INIT_RESOURCE(JQQmlLib); \
(engine).setImportPathList( { ":/JasonQt_QmlLib/qml/" } ); \
(engine).addImportPath( ":/JasonQt_QmlLib/qml/" ); \
}

#endif//__JQQmlLib_h__
39 changes: 17 additions & 22 deletions Library/JQLibrary/include/JQSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,64 +18,59 @@
#ifndef __JQSettings_h__
#define __JQSettings_h__

// C lib import
#include <assert.h>

// Qt lib import
#include <QSettings>
#include <QStandardPaths>
#include <QDir>
#include <QTimer>
#include <QDebug>
#include <QSharedPointer>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonDocument>
#include <QVariant>

#define JQSETTINGS_DEFAULTPROJECTGROUPNAME "JasonQt"

#define JQSettings_DefaultProjectGroupName "JasonQt"
class QTimer;

namespace JQSettings
{

QString documentsPath(const QString &projectName, const QString &projectGroupName = JQSettings_DefaultProjectGroupName);
QString documentsPath(const QString &projectName, const QString &projectGroupName = JQSETTINGS_DEFAULTPROJECTGROUPNAME);

QSharedPointer<QSettings> settingsFile(const QString &fileName, const QString &projectName, const QString &projectGroupName = JQSettings_DefaultProjectGroupName);
QSharedPointer< QSettings > settingsFile(const QString &fileName, const QString &projectName, const QString &projectGroupName = JQSETTINGS_DEFAULTPROJECTGROUPNAME);

class Set: public QObject
{
Q_OBJECT

public:
Set(const QString &fileName, const QString &groupName, const QString &projectName, const QString &projectGroupName = JQSettings_DefaultProjectGroupName);
Set(const QString &fileName, const QString &groupName, const QString &projectName, const QString &projectGroupName = JQSETTINGS_DEFAULTPROJECTGROUPNAME);

~Set(void);

QJsonValue operator[](const QString &key);
const QVariant operator[](const QString &key);

QString filePath(void) const;

public slots:
bool contains(const QString &key);

QJsonValue value(const QString &key, const QJsonValue &defaultValue);
QVariant value(const QString &key, const QVariant &defaultValue);

QJsonValue value(const QString &key);
QVariant value(const QString &key);

void setValue(const QString &key, const QJsonValue &data);
void setValue(const QString &key, const QVariant &data);

void save(void);

void readySave(const int &wait = 1000);
void readySave(const int &delayTime = 1000);

void read(void);

private:
QString filePath_;
QString fileName_;
QString groupName_;
QString projectName_;
QString filePath_;

QMap< QString, QJsonValue > datas_;
QMap< QString, QVariant > datas_;

QTimer *timer_;
QSharedPointer< QTimer > timer_;
};

}
Expand Down
7 changes: 6 additions & 1 deletion Library/JQLibrary/src/JQFoundation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

// Qt lib import
#include <QSharedMemory>
#include <QHash>
#include <QBuffer>
#include <QMetaMethod>

#include <QWidget>
#include <QLineEdit>
Expand All @@ -33,13 +36,15 @@
#include <QTabBar>
#include <QTableWidget>
#include <QTreeWidget>
#include <QImage>
#include <QMessageBox>

using namespace JQFoundation;

void JQFoundation::eventLoopSleep(const int &delay)
{
QEventLoop eventLoop;
QTimer::singleShot(delay, &eventLoop, SLOT(quit()));
QTimer::singleShot( delay, &eventLoop, &QEventLoop::quit );
eventLoop.exec();
}

Expand Down
Loading

0 comments on commit 41013c4

Please sign in to comment.