Skip to content

Commit

Permalink
Upload V16.5.30
Browse files Browse the repository at this point in the history
  • Loading branch information
188080501 committed May 30, 2016
1 parent 137f1fa commit fc0dd11
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Groups/Text/RandomPassword/RandomPassword.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
INCLUDEPATH += \
$$PWD/cpp/

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

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

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

// Qt lib import
#include <QClipboard>
#include <QApplication>
#include <QDateTime>

// JQToolsLibrary import
#include "JQToolsLibrary.hpp"

using namespace RandomPassword;

Manage::Manage()
{
srand( QDateTime::currentDateTime().toTime_t() );
}

QString Manage::randomPassword(const int &length, const bool &number, const bool &englishCharacters, const bool &caseSensitive, const bool &dividingLine)
{
QString password;
QString table;

auto numberTable = "0123456789";
auto lowercaseCharacters = "abcdefghijklmnopqrstuvwxyz";
auto upperCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

if ( number )
{
table += numberTable;
}
if ( englishCharacters )
{
if ( caseSensitive )
{
table += lowercaseCharacters;
table += upperCharacters;
}
else
{
table += lowercaseCharacters;
}
}

if ( table.isEmpty() ) { return { }; }

for ( auto index = 0; index < length; index++ )
{
if ( dividingLine && ! ( (index + 1) % 4 ) )
{
password += '-';
}
else
{
password += table.at( rand() % table.size() );
}
}

return password;
}

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

// Qt lib import
#include <QObject>

#define RANDOMPASSWORD_INITIALIZA \
{ \
qmlRegisterType<RandomPassword::Manage>("RandomPassword", 1, 0, "RandomPasswordManage"); \
}

namespace RandomPassword
{

class Manage: public QObject
{
Q_OBJECT
Q_DISABLE_COPY(Manage)

public:
Manage();

~Manage() = default;

public slots:
QString randomPassword(const int &length, const bool &number, const bool &englishCharacters, const bool &caseSensitive, const bool &dividingLine);

void setClipboardText(const QString &string);
};

}

#endif//__RandomPassword_h__
115 changes: 115 additions & 0 deletions Groups/Text/RandomPassword/qml/RandomPassword.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0
import "qrc:/MaterialUI/Interface/"
import RandomPassword 1.0

Item {
id: randomPassword
width: 620
height: 540

property bool changingFlag: true

Component.onCompleted: {
changingFlag = false;
}

RandomPasswordManage {
id: randomPasswordManage
}

Item {
anchors.centerIn: parent
width: 620
height: 540

MaterialLabel {
x: 40
y: 132
text: "密码长度:"
}

MaterialTextField {
id: textFieldForLength
x: 116
y: 91
width: 50
characterLimit: 2
characterLimitVisible: false
validator: RegExpValidator{ regExp: /^([0-9]+)$/ }
text: "15"
}

MaterialTextField {
id: textFieldForPassword
x: 40
y: 317
width: 540
placeholderText: "随机密码"
}

MaterialCheckBox {
id: checkBoxForNumber
x: 34
y: 181
text: "允许数字"
checked: true
}

MaterialCheckBox {
id: checkBoxForEnglishCharacters
x: 154
y: 181
text: "允许英文字符"
checked: true
}

MaterialCheckBox {
id: checkBoxForCaseSensitive
x: 302
y: 181
text: "区分大小写"
checked: true
enabled: checkBoxForEnglishCharacters.checked
}

MaterialCheckBox {
id: checkBoxForDividingLine
x: 436
y: 181
text: "插入分割线"
checked: true
}

MaterialButton {
x: 40
y: 259
width: 120
text: "随机密码"

onClicked: {
textFieldForPassword.text = randomPasswordManage.randomPassword(
parseInt( textFieldForLength.text ),
checkBoxForNumber.checked,
checkBoxForEnglishCharacters.checked,
checkBoxForCaseSensitive.checked,
checkBoxForDividingLine.checked
);
materialUI.showSnackbarMessage( "随机密码已经生成" );
}
}

MaterialButton {
x: 166
y: 259
width: 120
text: "复制到剪切板"

onClicked: {
randomPasswordManage.setClipboardText( textFieldForPassword.text );
materialUI.showSnackbarMessage( "URL已经复制到了剪切板" );
}
}
}
}
5 changes: 5 additions & 0 deletions Groups/Text/RandomPassword/qml/RandomPassword.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/RandomPassword">
<file>RandomPassword.qml</file>
</qresource>
</RCC>
1 change: 1 addition & 0 deletions Groups/Text/Text.pri
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include($$PWD/Utf16Transform/Utf16Transform.pri)
include($$PWD/RgbStringTransform/RgbStringTransform.pri)
include($$PWD/UrlEncode/UrlEncode.pri)
include($$PWD/RandomPassword/RandomPassword.pri)
include($$PWD/CaseTransform/CaseTransform.pri)
2 changes: 1 addition & 1 deletion Library/JQToolsLibrary/include/JQToolsLibrary.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef __JQToolsLibrary_hpp__
#define __JQToolsLibrary_hpp__

#define JQTOOLS_VERSIONSTRING "16.5.27"
#define JQTOOLS_VERSIONSTRING "16.5.30"

#endif//__JQToolsLibrary_hpp__
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ https://github.com/188080501/JQTools/issues
文本类|RGB转16进制|已完成
文本类|大小写转换|已完成
文本类|URL转码|已完成
文本类|密码随机器|已完成
文本类|JSON格式化|2016-06
||
计算类|HASH计算器|已完成
Expand Down
2 changes: 2 additions & 0 deletions cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Utf16Transform.h"
#include "RgbStringTransform.h"
#include "UrlEncode.h"
#include "RandomPassword.h"
#include "CaseTransform.h"
#include "HashCalculate.h"
#include "TimestampTransform.h"
Expand All @@ -48,6 +49,7 @@ int main(int argc, char *argv[])
UTF16TRANSFORM_INITIALIZA
RGBSTRINGTRANSFORM_INITIALIZA
URLENCODE_INITIALIZA
RANDOMPASSWORD_INITIALIZA
CASETRANSFORM_INITIALIZA
HASHCALCULATE_INITIALIZA
TTIMESTAMPTRANSFORM_INITIALIZA
Expand Down
1 change: 1 addition & 0 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ApplicationWindow {
{ bookmarkName: "UTF-16转换", titleName: "UTF-16转换", qrcLocation: "qrc:/Utf16Transform/Utf16Transform.qml" },
{ bookmarkName: "RGB转16进制", titleName: "RGB转16进制", qrcLocation: "qrc:/RgbStringTransform/RgbStringTransform.qml" },
{ bookmarkName: "大小写转换", titleName: "大小写转换", qrcLocation: "qrc:/CaseTransform/CaseTransform.qml" },
{ bookmarkName: "密码随机器", titleName: "密码随机器", qrcLocation: "qrc:/RandomPassword/RandomPassword.qml" },
{ bookmarkName: "URL转码", titleName: "URL转码", qrcLocation: "qrc:/UrlEncode/UrlEncode.qml" }
]
},
Expand Down

0 comments on commit fc0dd11

Please sign in to comment.