Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Ingemar Ceicer
hashsum
Commits
2bd1806d
Commit
2bd1806d
authored
Jul 21, 2017
by
Ingemar Ceicer
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Opens new window and displays checksum if there are multiple files
Former-commit-id:
6d9e64f0
parent
13bed748
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
27 deletions
+131
-27
code/hash.cpp
code/hash.cpp
+105
-15
code/hash.h
code/hash.h
+2
-0
code/license.ui
code/license.ui
+24
-12
No files found.
code/hash.cpp
View file @
2bd1806d
...
...
@@ -2494,6 +2494,58 @@ bool Hash::doChecksum(QString in)
return
true
;
}
bool
Hash
::
doChecksum
(
QString
in
,
QStringList
*
lista
)
{
QString
conf_file_name
=
QDir
::
toNativeSeparators
(
"/"
APPLICATION_NAME
".conf"
);
k
=
new
Config
(
conf_file_name
);
std
::
string
s
=
k
->
getConf
(
"algorithm"
);
delete
k
;
QByteArray
ba
;
QFile
f
(
in
);
if
(
f
.
open
(
QFile
::
ReadOnly
))
{
ba
=
f
.
readAll
();
f
.
close
();
}
else
return
false
;
int
pos
=
in
.
lastIndexOf
(
"/"
);
QString
filnamnet
=
in
.
mid
(
pos
+
1
,
-
1
);
QByteArray
sum
;
if
(
s
==
"md4"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Md4
);
else
if
(
s
==
"md5"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Md5
);
else
if
(
s
==
"sha1"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha1
);
else
if
(
s
==
"sha224"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha224
);
else
if
(
s
==
"sha256"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha256
);
else
if
(
s
==
"sha384"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha384
);
else
if
(
s
==
"sha512"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha512
);
else
if
(
s
==
"sha3_224"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha3_224
);
else
if
(
s
==
"sha3_256"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha3_256
);
else
if
(
s
==
"sha3_384"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha3_384
);
else
if
(
s
==
"sha3_512"
)
sum
=
QCryptographicHash
::
hash
(
ba
,
QCryptographicHash
::
Sha3_512
);
sum
=
sum
.
toHex
();
/*
ui->progressLabel->setText("\""+filnamnet +tr("\" has hash sum")+" ("+tr("Algorithm: ")+QString::fromStdString(s)+")");
ui->progressLabel->setToolTip(QDir::toNativeSeparators(in));
ui->actionCopyPath->setEnabled(true);
ui->actionCopyHashSum->setEnabled(true);
ui->lineEdit->setText(sum);
*/
lista
->
append
(
sum
);
return
true
;
}
bool
Hash
::
doChecksumText
(
const
QString
in
)
{
QString
conf_file_name
=
QDir
::
toNativeSeparators
(
"/"
APPLICATION_NAME
".conf"
);
...
...
@@ -3188,28 +3240,66 @@ QString Hash::getSystem()
/* draganddrop */
void
Hash
::
dropEvent
(
QDropEvent
*
ev
)
{
QString
surl
;
int
hitta
;
lista
=
new
QStringList
;
QStringList
fillista
;
QString
surl
,
spath
;
QList
<
QUrl
>
urls
=
ev
->
mimeData
()
->
urls
();
int
antalfiler
=
urls
.
size
();
foreach
(
QUrl
url
,
urls
)
{
qDebug
()
<<
url
;
surl
=
url
.
toString
();
qDebug
()
<<
surl
;
QFileInfo
fileInfo
(
url
.
fileName
());
QString
filename
(
fileInfo
.
fileName
());
//qDebug() << filename;
// qDebug() << nyurl;
// surl = url.toString();
surl
=
url
.
toString
(
QUrl
::
PreferLocalFile
);
spath
=
url
.
toString
(
QUrl
::
RemoveFilename
);
/*
hitta = surl.lastIndexOf("//");
qDebug
()
<<
hitta
;
#ifdef Q_OS_LINUX
#ifdef Q_OS_LINUX
surl = surl.remove(0,hitta+1);
#endif // Q_OS_LINUX
#ifdef Q_OS_WIN32
#endif // Q_OS_LINUX
#ifdef Q_OS_WIN32
surl = surl.remove(0,hitta+2);
#endif // Q_OS_WIN32
qDebug
()
<<
surl
;
#endif // Q_OS_WIN32
*/
surl
=
QDir
::
toNativeSeparators
(
surl
);
qDebug
()
<<
surl
;
bool
lyckades
=
doChecksum
(
surl
);
if
(
lyckades
==
false
)
QMessageBox
::
critical
(
this
,
APPLICATION_NAME
" "
VERSION
,
tr
(
"No hash sum could be calculated"
));
if
(
antalfiler
>
1
)
{
bool
lyckades
=
doChecksum
(
surl
,
lista
);
if
(
lyckades
==
false
)
QMessageBox
::
critical
(
this
,
APPLICATION_NAME
" "
VERSION
,
tr
(
"No hash sum could be calculated"
));
fillista
.
append
(
filename
);
}
else
{
bool
lyckades
=
doChecksum
(
surl
);
if
(
lyckades
==
false
)
QMessageBox
::
critical
(
this
,
APPLICATION_NAME
" "
VERSION
,
tr
(
"No hash sum could be calculated"
));
}
}
if
(
antalfiler
>
1
)
{
d
=
new
QDialog
;
Ui
::
Lic
*
ui2
=
new
Ui
::
Lic
;
ui2
->
setupUi
(
d
);
const
QFont
fixedFont
=
QFontDatabase
::
systemFont
(
QFontDatabase
::
FixedFont
);
ui2
->
textBrowser
->
setFont
(
fixedFont
);
ui2
->
textBrowser
->
append
(
tr
(
"Path: "
)
+
spath
+
"<br>"
);
for
(
int
i
=
0
;
i
<
lista
->
size
();
i
++
)
{
ui2
->
textBrowser
->
append
(
lista
->
at
(
i
)
+
" "
+
fillista
.
at
(
i
));
// ui2->textBrowser->moveCursor (QTextCursor::End);
}
ui2
->
pbOpenFile
->
hide
();
ui2
->
pbClose
->
setGeometry
(
450
,
570
,
100
,
24
);
// d->setWindowFlags(Qt::CustomizeWindowHint);
d
->
setWindowFlags
(
Qt
::
WindowSystemMenuHint
);
d
->
setWindowTitle
(
APPLICATION_NAME
" "
VERSION
);
// QIcon ikon("/images/hashsum.ico");
// d->setWindowIcon(ikon);
connect
(
ui2
->
pbClose
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
stang
()));
d
->
show
();
}
}
...
...
code/hash.h
View file @
2bd1806d
...
...
@@ -93,6 +93,7 @@ private:
void
setStartConfig
();
void
setEndConfig
();
bool
doChecksum
(
QString
);
bool
doChecksum
(
QString
,
QStringList
*
lista
);
bool
doChecksumText
(
const
QString
);
bool
doChecksumList
(
QString
,
QString
&
,
std
::
string
);
bool
doCompare
(
QString
,
QString
);
...
...
@@ -115,6 +116,7 @@ private:
int
MAX_RECENT_FILES
;
// const QStringList algoritmer = (QStringList() << "md4" << "md5" << "sh1");
QStringList
algoritmer
;
QStringList
*
lista
;
private
slots
:
...
...
code/license.ui
View file @
2bd1806d
...
...
@@ -9,20 +9,20 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
4
00
</width>
<height>
5
00
</height>
<width>
10
00
</width>
<height>
6
00
</height>
</rect>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
4
00
</width>
<height>
5
00
</height>
<width>
10
00
</width>
<height>
6
00
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
4
00
</width>
<height>
5
00
</height>
<width>
10
00
</width>
<height>
6
00
</height>
</size>
</property>
<property
name=
"contextMenuPolicy"
>
...
...
@@ -43,16 +43,22 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
4
00
</width>
<height>
4
61
</height>
<width>
10
00
</width>
<height>
5
61
</height>
</rect>
</property>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Fixed"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
</widget>
<widget
class=
"QPushButton"
name=
"pbClose"
>
<property
name=
"geometry"
>
<rect>
<x>
13
0
</x>
<y>
4
7
0
</y>
<x>
26
0
</x>
<y>
4
6
0
</y>
<width>
100
</width>
<height>
24
</height>
</rect>
...
...
@@ -64,12 +70,18 @@
<widget
class=
"QPushButton"
name=
"pbOpenFile"
>
<property
name=
"geometry"
>
<rect>
<x>
2
40
</x>
<y>
4
7
0
</y>
<x>
4
1
0
</x>
<y>
4
6
0
</y>
<width>
100
</width>
<height>
24
</height>
</rect>
</property>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Expanding"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"text"
>
<string>
Open File
</string>
</property>
...
...
Ingemar Ceicer
@posktomten
mentioned in commit
039ba475
·
Dec 25, 2019
mentioned in commit
039ba475
mentioned in commit 039ba47568ebe66f5b78f3e2db4f147ea96f331f
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment