mirror of
https://github.com/QRouland/UTPass.git
synced 2024-12-22 01:42:39 +00:00
Add style command && applied new style format to existing code && setup tests plugins
This commit is contained in:
parent
aa4018c680
commit
7dc320f8ce
13
.astylerc
Normal file
13
.astylerc
Normal file
@ -0,0 +1,13 @@
|
||||
suffix=none
|
||||
recursive
|
||||
--style=kr
|
||||
--indent=spaces=4
|
||||
--align-pointer=name
|
||||
--align-reference=name
|
||||
--convert-tabs
|
||||
--attach-namespaces
|
||||
--max-code-length=100
|
||||
--max-instatement-indent=120
|
||||
--pad-header
|
||||
--pad-oper
|
||||
--lineend=linux
|
@ -37,7 +37,6 @@ set(DESKTOP_FILE_NAME ${PROJECT_NAME}.desktop)
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
|
||||
|
||||
qt5_use_modules(${PROJECT_NAME} Gui Qml Quick)
|
||||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
@ -98,3 +97,18 @@ file(GLOB_RECURSE PROJECT_SRC_FILES
|
||||
)
|
||||
|
||||
add_custom_target(${PROJECT_NAME}_FILES ALL SOURCES ${PROJECT_SRC_FILES})
|
||||
|
||||
# Tests
|
||||
enable_testing(true)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
include_directories(tests/plugins)
|
||||
|
||||
find_package(Qt5Test)
|
||||
|
||||
add_executable(TestGpg tests/plugins/TestGpg.cpp)
|
||||
add_executable(TestPass tests/plugins/TestPass.cpp)
|
||||
target_link_libraries(TestGpg Qt5::Test)
|
||||
target_link_libraries(TestPass Qt5::Test)
|
||||
|
||||
add_test(TestGpg TestGpg)
|
||||
add_test(TestPass TestPass)
|
||||
|
10
README.md
10
README.md
@ -11,15 +11,15 @@ A password management app for Ubuntu Touch aiming to be compatible with [ZX2C4
|
||||
For more options/details see the [clickable documentation](http://clickable.bhdouglass.com/en/latest/index.html)
|
||||
|
||||
## Custom clickable command
|
||||
* ```clickable c ``` : clean third directory and run ```clickable clean```
|
||||
* ```clickable cr ``` : clean third directory and run ```clickable```
|
||||
* ```clickable r``` : run ```clickable --dirty```
|
||||
* ```clickable crd ``` : clean third directory and run ```clickable desktop```
|
||||
* ```clickable rd ``` : run ```clickable desktop --dirty ```
|
||||
* ```clickable test ``` : run test for all plugins
|
||||
* ```clickable test_gpg ``` : run test for gpg plugin
|
||||
* ```clickable test_pass``` : run test for pass plugin
|
||||
* ```clickable style ``` : reformat the code (Required : [astyle](astyle.sourceforge.ne) & [https://github.com/jesperhh/qmlfmt](https://github.com/jesperhh/qmlfmt))
|
||||
|
||||
# Contributing
|
||||
|
||||
Any contributions are welcome using the github issue & pull request system.
|
||||
Please try to respect the code style format by runnning ```clickable style``` before committing.
|
||||
|
||||
# Features
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
{
|
||||
template": "unconfined",
|
||||
"policy_groups": [],
|
||||
"policy_version": 16.04
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
"template": "cmake",
|
||||
"kill": "UTPass",
|
||||
"scripts": {
|
||||
"c": "third/clean.sh && clickable clean",
|
||||
"cr": "third/clean.sh && clickable",
|
||||
"r": "clickable --dirty",
|
||||
"crd": "third/clean.sh && clickable desktop",
|
||||
"rd": "clickable desktop --dirty"
|
||||
"clean": "third/clean.sh && rm -rf build",
|
||||
"style": "astyle --options=.astylerc \"plugins/*.cpp,*.h\" && qmlfmt -w qml",
|
||||
"test": "clickable run \"cd build && make test\"",
|
||||
"test_gpg": "clickable run \"cd build && ./TestGpg\"",
|
||||
"test_pass": "clickable run \"cd build && ./TestPass\""
|
||||
},
|
||||
"dependencies_build": [
|
||||
"texinfo",
|
||||
|
@ -17,7 +17,8 @@
|
||||
using namespace GpgME;
|
||||
using namespace QGpgME;
|
||||
|
||||
Gpg::Gpg() {
|
||||
Gpg::Gpg()
|
||||
{
|
||||
auto error = initializeLibrary(OpenPGP);
|
||||
if (error) {
|
||||
qDebug() << "Code Error : " << error.code();
|
||||
@ -25,7 +26,8 @@ Gpg::Gpg() {
|
||||
qFatal("GpgME init fail");
|
||||
}
|
||||
|
||||
QString gnuhome = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation).append("/gpghome");
|
||||
QString gnuhome = QStandardPaths::writableLocation(
|
||||
QStandardPaths::AppDataLocation).append("/gpghome");
|
||||
QDir dir(gnuhome);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
@ -37,16 +39,17 @@ Gpg::Gpg() {
|
||||
qDebug() << "Code Error : " << error.code();
|
||||
qDebug() << "Error str : " << error.asString();
|
||||
qFatal("Engine check Fail");
|
||||
|
||||
}
|
||||
qDebug() << "GpgME Engine Version :" << engineInfo(OpenPGP).version();
|
||||
}
|
||||
|
||||
void Gpg::list_dir() {
|
||||
void Gpg::list_dir()
|
||||
{
|
||||
qDebug() << "hello world!";
|
||||
}
|
||||
|
||||
QString Gpg::decrypt(const QByteArray cipherText) {
|
||||
QString Gpg::decrypt(const QByteArray cipherText)
|
||||
{
|
||||
/*auto decJob = openpgp()->decryptJob();
|
||||
auto ctx = DecryptJob::context(decJob);*/
|
||||
|
||||
@ -61,7 +64,8 @@ QString Gpg::decrypt(const QByteArray cipherText) {
|
||||
return QString::fromUtf8(plainText);*/
|
||||
}
|
||||
|
||||
QString Gpg::decrypt_file(const QString path) {
|
||||
QString Gpg::decrypt_file(const QString path)
|
||||
{
|
||||
/*QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qErrnoWarning("Can't open the File");
|
||||
@ -71,7 +75,8 @@ QString Gpg::decrypt_file(const QString path) {
|
||||
return this->decrypt(plainText);*/
|
||||
}
|
||||
|
||||
QByteArray Gpg::encrypt(const QString str) {
|
||||
QByteArray Gpg::encrypt(const QString str)
|
||||
{
|
||||
/*auto listjob = openpgp()->keyListJob(false, false, false);
|
||||
std::vector<Key> keys;
|
||||
auto keylistresult = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"), false, keys);
|
||||
@ -86,7 +91,8 @@ QByteArray Gpg::encrypt(const QString str) {
|
||||
return cipherText;*/
|
||||
}
|
||||
|
||||
bool Gpg::encrypt_file(const QString str, const QString path) {
|
||||
bool Gpg::encrypt_file(const QString str, const QString path)
|
||||
{
|
||||
/*QFile file(path);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qErrnoWarning("Can't open the File");
|
||||
@ -96,7 +102,8 @@ bool Gpg::encrypt_file(const QString str, const QString path) {
|
||||
return true;*/
|
||||
}
|
||||
|
||||
QString Gpg::get_key_id(QString uid) {
|
||||
QString Gpg::get_key_id(QString uid)
|
||||
{
|
||||
qDebug() << "Getting the key id " << uid;
|
||||
auto *job = openpgp()->keyListJob(false, false, false);
|
||||
std::vector<Key> keys;
|
||||
@ -112,7 +119,8 @@ QString Gpg::get_key_id(QString uid) {
|
||||
return kId;
|
||||
}
|
||||
|
||||
QStringList Gpg::get_all_keys_id() {
|
||||
QStringList Gpg::get_all_keys_id()
|
||||
{
|
||||
qDebug() << "Show all available key";
|
||||
auto job = openpgp()->keyListJob(false, false, false);
|
||||
std::vector<Key> keys;
|
||||
@ -132,7 +140,8 @@ QStringList Gpg::get_all_keys_id() {
|
||||
return r;
|
||||
}
|
||||
|
||||
bool Gpg::import_key(QString path) {
|
||||
bool Gpg::import_key(QString path)
|
||||
{
|
||||
qDebug() << "Importing the key file" << path;
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Gpg : public QObject {
|
||||
class Gpg : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -3,7 +3,8 @@
|
||||
#include "plugin.h"
|
||||
#include "gpg.h"
|
||||
|
||||
void FileSystemPlugin::registerTypes(const char *uri) {
|
||||
void FileSystemPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
//@uri Pass
|
||||
qmlRegisterSingletonType<Gpg>(uri, 1, 0, "Gpg", [](QQmlEngine *, QJSEngine *) -> QObject * { return new Gpg; });
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#include <QQmlExtensionPlugin>
|
||||
|
||||
class FileSystemPlugin : public QQmlExtensionPlugin {
|
||||
class FileSystemPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID
|
||||
"org.qt-project.Qt.QQmlExtensionInterface")
|
||||
|
@ -3,11 +3,13 @@
|
||||
|
||||
#include "pass.h"
|
||||
|
||||
Pass::Pass() {
|
||||
Pass::Pass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Pass::speak() {
|
||||
void Pass::speak()
|
||||
{
|
||||
qDebug() << "Starting app from main.cpp";
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Pass : public QObject {
|
||||
class Pass : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QString gpgHome;
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
#include "plugin.h"
|
||||
#include "pass.h"
|
||||
|
||||
void PassPlugin::registerTypes(const char *uri) {
|
||||
void PassPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
//@uri Pass
|
||||
qmlRegisterSingletonType<Pass>(uri, 1, 0, "Pass", [](QQmlEngine *, QJSEngine *) -> QObject * { return new Pass; });
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#include <QQmlExtensionPlugin>
|
||||
|
||||
class PassPlugin : public QQmlExtensionPlugin {
|
||||
class PassPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID
|
||||
"org.qt-project.Qt.QQmlExtensionInterface")
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: utpass.qrouland\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-03-20 22:31+0000\n"
|
||||
"POT-Creation-Date: 2019-03-21 16:44+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -17,32 +17,32 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: ../qml/pages/PasswordList.qml:17
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/PasswordList.qml:39
|
||||
msgid "No password found in the current folder"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/Settings.qml:8 ../qml/pages/headers/MainHeader.qml:47
|
||||
#: ../qml/pages/Settings.qml:8 ../qml/pages/headers/MainHeader.qml:49
|
||||
msgid "Settings"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/headers/MainHeader.qml:8 ../qml/pages/headers/StackHeader.qml:8
|
||||
#: ../qml/pages/Info.qml:43 UTPass.desktop.in.h:1
|
||||
msgid "UTPass"
|
||||
#: ../qml/pages/PasswordList.qml:16
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/headers/MainHeader.qml:23
|
||||
#: ../qml/pages/headers/MainHeader.qml:36
|
||||
msgid "Search"
|
||||
#: ../qml/pages/PasswordList.qml:38
|
||||
msgid "No password found in the current folder"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/headers/MainHeader.qml:54 ../qml/pages/Info.qml:9
|
||||
#: ../qml/pages/Info.qml:9 ../qml/pages/headers/MainHeader.qml:56
|
||||
msgid "Info"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/Info.qml:43 ../qml/pages/headers/MainHeader.qml:8
|
||||
#: ../qml/pages/headers/StackHeader.qml:8 UTPass.desktop.in.h:1
|
||||
msgid "UTPass"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/Info.qml:53
|
||||
msgid "Suggest improvement(s) or report a bug(s)"
|
||||
msgstr ""
|
||||
|
||||
#: ../qml/pages/headers/MainHeader.qml:23
|
||||
#: ../qml/pages/headers/MainHeader.qml:38
|
||||
msgid "Search"
|
||||
msgstr ""
|
||||
|
11
qml/Main.qml
11
qml/Main.qml
@ -6,7 +6,7 @@ import Gpg 1.0
|
||||
import "components"
|
||||
|
||||
MainView {
|
||||
id: root
|
||||
id: "root"
|
||||
objectName: "mainView"
|
||||
applicationName: "utpass.qrouland"
|
||||
|
||||
@ -18,7 +18,12 @@ MainView {
|
||||
id: pageStack
|
||||
anchors.fill: parent
|
||||
|
||||
Component.onCompleted: push(pageStack.push(Qt.resolvedUrl("pages/PasswordList.qml")))
|
||||
Component.onCompleted: push(pageStack.push(
|
||||
Qt.resolvedUrl(
|
||||
"pages/PasswordList.qml")))
|
||||
}
|
||||
Component.onCompleted: {
|
||||
Gpg.import_key("password-store/public.key")
|
||||
Gpg.get_all_keys_id()
|
||||
}
|
||||
Component.onCompleted: { Gpg.import_key("password-store/public.key"); Gpg.get_all_keys_id();}
|
||||
}
|
||||
|
@ -25,7 +25,12 @@ Component {
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: { if (fileIsDir){ folderModel.folder = folderModel.folder + "/" + fileName ; backAction.visible = true;} }
|
||||
onClicked: {
|
||||
if (fileIsDir) {
|
||||
folderModel.folder = folderModel.folder + "/" + fileName
|
||||
backAction.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CustomBorder {
|
||||
|
@ -39,7 +39,9 @@ Item {
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: { Qt.openUrlExternally(parent.parent.url); }
|
||||
onClicked: {
|
||||
Qt.openUrlExternally(parent.parent.url)
|
||||
}
|
||||
}
|
||||
|
||||
CustomBorder {
|
||||
|
@ -2,5 +2,4 @@ pragma Singleton
|
||||
import QtQuick 2.4
|
||||
|
||||
Item {
|
||||
|
||||
}
|
||||
|
5
qml/models/Passtore.qml
Normal file
5
qml/models/Passtore.qml
Normal file
@ -0,0 +1,5 @@
|
||||
pragma Singleton
|
||||
import QtQuick 2.4
|
||||
|
||||
Item {
|
||||
}
|
@ -55,5 +55,3 @@ Page {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,7 +4,6 @@ import Qt.labs.folderlistmodel 2.1
|
||||
import "../components"
|
||||
import "headers"
|
||||
|
||||
|
||||
Page {
|
||||
header: MainHeader {
|
||||
flickable: nav
|
||||
@ -17,9 +16,9 @@ Page {
|
||||
text: i18n.tr("Back")
|
||||
visible: false
|
||||
onTriggered: {
|
||||
folderModel.folder = folderModel.parentFolder;
|
||||
folderModel.folder = folderModel.parentFolder
|
||||
if (folderModel.rootFolder === folderModel.folder) {
|
||||
backAction.visible = false;
|
||||
backAction.visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,5 +26,3 @@ Page {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,9 @@ PageHeader {
|
||||
height: units.gu(4)
|
||||
visible: false
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onFocusChanged: {}
|
||||
onFocusChanged: {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,8 +37,8 @@ PageHeader {
|
||||
iconName: "search"
|
||||
text: i18n.tr("Search")
|
||||
onTriggered: {
|
||||
searchBar.visible = !searchBar.visible;
|
||||
labelTitle.visible = !searchBar.visible;
|
||||
searchBar.visible = !searchBar.visible
|
||||
labelTitle.visible = !searchBar.visible
|
||||
if (searchBar.visible === true) {
|
||||
searchBar.focus = true
|
||||
}
|
||||
|
@ -2,8 +2,7 @@
|
||||
// @ https://stackoverflow.com/questions/16534489/qml-control-border-width-and-color-on-any-one-side-of-rectangle-element#16562823
|
||||
import QtQuick 2.4
|
||||
|
||||
Rectangle
|
||||
{
|
||||
Rectangle {
|
||||
property bool commonBorder: true
|
||||
|
||||
property int lBorderwidth: 1
|
||||
@ -19,8 +18,7 @@ Rectangle
|
||||
|
||||
color: borderColor
|
||||
|
||||
anchors
|
||||
{
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
|
17
tests/plugins/TestGpg.cpp
Normal file
17
tests/plugins/TestGpg.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
class TestGpg: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void toUpper();
|
||||
};
|
||||
|
||||
void TestGpg::toUpper()
|
||||
{
|
||||
QString str = "Hello";
|
||||
QCOMPARE(str.toUpper(), QString("HELLO"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestGpg)
|
||||
#include "TestGpg.moc"
|
17
tests/plugins/TestPass.cpp
Normal file
17
tests/plugins/TestPass.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
class TestPass: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void toUpper();
|
||||
};
|
||||
|
||||
void TestPass::toUpper()
|
||||
{
|
||||
QString str = "Hello";
|
||||
QCOMPARE(str.toUpper(), QString("HELLO"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestPass)
|
||||
#include "TestPass.moc"
|
@ -56,7 +56,7 @@ ExternalProject_Add(
|
||||
INSTALL_DIR ${EXTERNAL_LIBS}
|
||||
DOWNLOAD_COMMAND ""
|
||||
SOURCE_DIR ${GNUPG_PATH}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --prefix=${EXTERNAL_LIBS} --enable-maintainer-mode --host ${ARCH_TRIPLET} --disable-doc
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/autogen.sh && <SOURCE_DIR>/configure --prefix=${EXTERNAL_LIBS} --enable-maintainer-mode --host ${ARCH_TRIPLET}
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND make install
|
||||
|
Loading…
Reference in New Issue
Block a user