mirror of
https://github.com/seiichiro0185/sailotp.git
synced 2024-11-01 01:38:25 +00:00
Version 1.0-2
Fixed a small bug found by harbour-QA
This commit is contained in:
parent
7b9ad31d74
commit
e2e3fd71c8
6 changed files with 8 additions and 114 deletions
|
@ -13,8 +13,7 @@ DEFINES += APP_BUILDNUM=\\\"$$RELEASE\\\"
|
|||
|
||||
CONFIG += sailfishapp
|
||||
|
||||
SOURCES += src/harbour-sailotp.cpp \
|
||||
src/fileio.cpp
|
||||
SOURCES += src/harbour-sailotp.cpp
|
||||
|
||||
OTHER_FILES += qml/harbour-sailotp.qml \
|
||||
qml/cover/CoverPage.qml \
|
||||
|
|
|
@ -148,6 +148,7 @@ Dialog {
|
|||
// There were no parameters -> Add new entry
|
||||
DB.addOTP(otpLabel.text, otpSecret.text, paramType, otpCounter.text, appWin.listModel.count);
|
||||
}
|
||||
|
||||
// Refresh the main Page
|
||||
parentPage.refreshOTPList();
|
||||
}
|
||||
|
|
|
@ -54,9 +54,11 @@ Page {
|
|||
// Reload the List of OTPs from storage
|
||||
function refreshOTPList() {
|
||||
otpList.visible = false;
|
||||
otpList.model = null; // Hack to prevent unaccessible pulley after List refresh
|
||||
appWin.listModel.clear();
|
||||
DB.getOTP();
|
||||
refreshOTPValues();
|
||||
otpList.model = appWin.listModel; // Hack to prevent unaccessible pulley after List refresh
|
||||
otpList.visible = true;
|
||||
}
|
||||
|
||||
|
@ -186,8 +188,8 @@ Page {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
DB.resetFav(title, secret)
|
||||
appWin.setCover(-1)
|
||||
DB.resetFav(title, secret);
|
||||
appWin.setCover(-1);
|
||||
appWin.listModel.setProperty(index, "fav", 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Name: harbour-sailotp
|
||||
Summary: SailOTP
|
||||
Version: 1.0
|
||||
Release: 1
|
||||
Release: 2
|
||||
Group: Security
|
||||
URL: https://github.com/seiichiro0185/sailotp/
|
||||
License: "BSD\t"
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
#include "fileio.h"
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
FileIO::FileIO(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString FileIO::read()
|
||||
{
|
||||
if (mSource.isEmpty()){
|
||||
emit error("source is empty");
|
||||
return QString();
|
||||
}
|
||||
|
||||
QFile file(mSource);
|
||||
QString fileContent;
|
||||
if ( file.open(QIODevice::ReadOnly) ) {
|
||||
QString line;
|
||||
QTextStream t( &file );
|
||||
do {
|
||||
line = t.readLine();
|
||||
fileContent += line;
|
||||
} while (!line.isNull());
|
||||
|
||||
file.close();
|
||||
} else {
|
||||
emit error("Unable to open the file");
|
||||
return QString();
|
||||
}
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
bool FileIO::write(const QString& data)
|
||||
{
|
||||
if (mSource.isEmpty())
|
||||
return false;
|
||||
|
||||
QFile file(mSource);
|
||||
if (!file.open(QFile::WriteOnly | QFile::Truncate))
|
||||
return false;
|
||||
|
||||
QTextStream out(&file);
|
||||
out << data;
|
||||
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileIO::exists()
|
||||
{
|
||||
if (mSource.isEmpty()) {
|
||||
emit error("Source is empty!");
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile file(mSource);
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
bool FileIO::exists(const QString& filename)
|
||||
{
|
||||
if (filename.isEmpty()) {
|
||||
emit error("Source is empty!");
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile file(filename);
|
||||
return file.exists();
|
||||
}
|
35
src/fileio.h
35
src/fileio.h
|
@ -1,35 +0,0 @@
|
|||
#ifndef FILEIO_H
|
||||
#define FILEIO_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class FileIO : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_PROPERTY(QString source
|
||||
READ source
|
||||
WRITE setSource
|
||||
NOTIFY sourceChanged)
|
||||
explicit FileIO(QObject *parent = 0);
|
||||
|
||||
Q_INVOKABLE QString read();
|
||||
Q_INVOKABLE bool write(const QString& data);
|
||||
Q_INVOKABLE bool exists();
|
||||
Q_INVOKABLE bool exists(const QString& filename);
|
||||
|
||||
QString source() { return mSource; };
|
||||
|
||||
public slots:
|
||||
void setSource(const QString& source) { mSource = source; };
|
||||
|
||||
signals:
|
||||
void sourceChanged(const QString& source);
|
||||
void error(const QString& msg);
|
||||
|
||||
private:
|
||||
QString mSource;
|
||||
};
|
||||
|
||||
#endif // FILEIO_H
|
Loading…
Reference in a new issue