HGGitLab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
app
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
luoliangyi
app
Commits
543dac9d
Commit
543dac9d
authored
Apr 12, 2022
by
yangjiaxuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加清除缓存功能,并翻译
parent
d3577653
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
507 additions
and
70 deletions
+507
-70
app/Scanner/Scanner/Scanner.pro
app/Scanner/Scanner/Scanner.pro
+6
-3
app/Scanner/Scanner/Scanner_zh_CN.qm
app/Scanner/Scanner/Scanner_zh_CN.qm
+0
-0
app/Scanner/Scanner/Scanner_zh_CN.ts
app/Scanner/Scanner/Scanner_zh_CN.ts
+151
-64
app/Scanner/Scanner/dialog_aquireinto.cpp
app/Scanner/Scanner/dialog_aquireinto.cpp
+2
-1
app/Scanner/Scanner/dialog_clrcache.cpp
app/Scanner/Scanner/dialog_clrcache.cpp
+144
-0
app/Scanner/Scanner/dialog_clrcache.h
app/Scanner/Scanner/dialog_clrcache.h
+38
-0
app/Scanner/Scanner/dialog_clrcache.ui
app/Scanner/Scanner/dialog_clrcache.ui
+158
-0
app/Scanner/Scanner/global.h
app/Scanner/Scanner/global.h
+3
-2
app/Scanner/Scanner/mainwindow.cpp
app/Scanner/Scanner/mainwindow.cpp
+5
-0
app/Scanner/Scanner/qt_zh_CN.qm
app/Scanner/Scanner/qt_zh_CN.qm
+0
-0
No files found.
app/Scanner/Scanner/Scanner.pro
View file @
543dac9d
...
...
@@ -78,7 +78,8 @@ SOURCES += \
widget_statusbar
.
cpp
\
hg_settingdialog
.
cpp
\
dialog_logmanager
.
cpp
\
global
.
cpp
global
.
cpp
\
dialog_clrcache
.
cpp
HEADERS
+=
\
..
/../../
ui
/
HGUIGlobal
.
h
\
...
...
@@ -104,7 +105,8 @@ HEADERS += \
widget_statusbar
.
h
\
hg_settingdialog
.
h
\
dialog_logmanager
.
h
\
global
.
h
global
.
h
\
dialog_clrcache
.
h
FORMS
+=
\
dialog_admin
.
ui
\
...
...
@@ -125,7 +127,8 @@ FORMS += \
mainwindow
.
ui
\
widget_imgproc_base
.
ui
\
widget_statusbar
.
ui
\
dialog_logmanager
.
ui
dialog_logmanager
.
ui
\
dialog_clrcache
.
ui
TRANSLATIONS
+=
\
Scanner_zh_CN
.
ts
...
...
app/Scanner/Scanner/Scanner_zh_CN.qm
View file @
543dac9d
No preview for this file type
app/Scanner/Scanner/Scanner_zh_CN.ts
View file @
543dac9d
This diff is collapsed.
Click to expand it.
app/Scanner/Scanner/dialog_aquireinto.cpp
View file @
543dac9d
#
include
"dialog_aquireinto.h"
#include "ui_dialog_aquireinto.h"
#include "dialog_savequality.h"
#include "global.h"
#include <QFileDialog>
#include <QDateTime>
#include <QRegExpValidator>
...
...
@@ -16,7 +17,7 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
QRegExp
rx
(
"[^
\\\\
/:*?
\"
<>|]+$"
);
ui
->
lineEdit_fileName
->
setValidator
(
new
QRegExpValidator
(
rx
,
this
));
QString
filePath
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
"/Huago/ScannerApp/AquireInto"
;
QString
filePath
=
APP_AQUIREINTO_PATH
;
ui
->
lineEdit_directory
->
setText
(
filePath
);
ui
->
cbtn_subFolder
->
setChecked
(
false
);
ui
->
cbtn_subFolderByBlank
->
setChecked
(
false
);
...
...
app/Scanner/Scanner/dialog_clrcache.cpp
0 → 100644
View file @
543dac9d
#include "dialog_clrcache.h"
#include "ui_dialog_clrcache.h"
#include "global.h"
#include <QMessageBox>
#include <QDir>
#include <QFileInfo>
#include <QKeyEvent>
Dialog_ClrCache
::
Dialog_ClrCache
(
QWidget
*
parent
)
:
QDialog
(
parent
),
ui
(
new
Ui
::
Dialog_ClrCache
)
{
ui
->
setupUi
(
this
);
ui
->
lineEdit
->
setText
(
APP_CACHE_PATH
);
setInformation
(
APP_CACHE_PATH
);
}
Dialog_ClrCache
::~
Dialog_ClrCache
()
{
delete
ui
;
}
void
Dialog_ClrCache
::
closeEvent
(
QCloseEvent
*
event
)
{
(
void
)
event
;
if
(
m_isClear
)
accept
();
else
reject
();
}
void
Dialog_ClrCache
::
keyPressEvent
(
QKeyEvent
*
event
)
{
switch
(
event
->
key
())
{
case
Qt
:
:
Key_Escape
:
break
;
default:
QDialog
::
keyPressEvent
(
event
);
}
}
void
Dialog_ClrCache
::
on_btn_clr_clicked
()
{
QFileInfo
file
(
APP_CACHE_PATH
);
if
(
file
.
exists
())
{
int
ret
=
QMessageBox
::
question
(
this
,
tr
(
"Question"
),
tr
(
"Main window contains temporary files, clear cache would remove all of them.
\n
"
"Continue to clear?"
));
if
(
ret
!=
QMessageBox
::
Yes
)
return
;
}
else
{
QMessageBox
::
information
(
this
,
tr
(
"Information"
),
tr
(
"No cached file is available"
));
}
if
(
file
.
exists
()
&&
clrCache
(
APP_CACHE_PATH
))
{
QMessageBox
::
information
(
this
,
tr
(
"Information"
),
tr
(
"Cache clear successfully."
));
Global
::
writeSyslog
(
user_level_messages
,
Informational
,
"User try to clear cache and succeed."
);
}
else
if
(
file
.
exists
()
&&
!
clrCache
(
APP_CACHE_PATH
))
{
QMessageBox
::
warning
(
this
,
tr
(
"Warning"
),
tr
(
"Cache clear failed or incompletely clear."
));
Global
::
writeSyslog
(
user_level_messages
,
Informational
,
"User try to clear cache, but failed or incompletely clear."
);
}
setInformation
(
APP_CACHE_PATH
);
}
void
Dialog_ClrCache
::
on_btn_close_clicked
()
{
close
();
}
bool
Dialog_ClrCache
::
clrCache
(
const
QString
&
path
)
{
m_isClear
=
true
;
QDir
dir
=
QDir
(
path
);
bool
isSuccessful
=
dir
.
removeRecursively
();
dir
.
mkpath
(
APP_CACHE_PATH
);
return
isSuccessful
;
}
qint64
Dialog_ClrCache
::
getDirSize
(
const
QString
&
path
)
{
QDir
dir
(
path
);
qint64
size
=
0
;
foreach
(
QFileInfo
info
,
dir
.
entryInfoList
(
QDir
::
Files
))
size
+=
info
.
size
();
foreach
(
QString
subDir
,
dir
.
entryList
(
QDir
::
Dirs
|
QDir
::
NoDotAndDotDot
))
size
+=
getDirSize
(
path
+
QDir
::
separator
()
+
subDir
);
return
size
;
}
int
Dialog_ClrCache
::
getFileNum
(
const
QString
&
path
)
{
QDir
dir
(
path
);
int
num
=
0
;
foreach
(
QFileInfo
info
,
dir
.
entryInfoList
(
QDir
::
Files
))
num
++
;
foreach
(
QString
subDir
,
dir
.
entryList
(
QDir
::
Dirs
|
QDir
::
NoDotAndDotDot
))
num
+=
getFileNum
(
path
+
QDir
::
separator
()
+
subDir
);
return
num
;
}
void
Dialog_ClrCache
::
setInformation
(
const
QString
&
path
)
{
//生成缓存占用空间大小信息
qint64
size
=
getDirSize
(
path
);
double
s
=
size
;
int
unit
=
0
;
while
(
true
)
{
if
(
s
>
1024.0
)
{
s
/=
1024.0
;
unit
+=
1
;
}
else
break
;
}
QString
sstring
=
QString
::
number
(
s
,
'f'
,
2
);
ui
->
lab_size
->
setText
(
sstring
);
QString
unitstring
=
unit
==
3
?
"GB"
:
(
unit
==
2
?
"MB"
:
(
unit
==
1
?
"KB"
:
"B"
));
ui
->
lab_unit
->
setText
(
unitstring
);
QString
Bstring
=
QString
::
number
(
size
);
int
commaNum
=
Bstring
.
size
()
/
3
;
if
(
Bstring
.
size
()
%
3
==
0
)
commaNum
-=
1
;
int
offset
=
0
;
for
(
int
i
=
0
;
i
<
commaNum
;
i
++
)
{
Bstring
.
insert
(
Bstring
.
size
()
-
3
-
offset
*
4
,
","
);
offset
+=
1
;
}
ui
->
lab_sizeByB
->
setText
(
"("
+
Bstring
+
" Byte)"
);
//生成文件个数信息
ui
->
lab_num
->
setNum
(
getFileNum
(
path
));
}
app/Scanner/Scanner/dialog_clrcache.h
0 → 100644
View file @
543dac9d
#ifndef DIALOG_CLRCACHE_H
#define DIALOG_CLRCACHE_H
#include <QDialog>
namespace
Ui
{
class
Dialog_ClrCache
;
}
class
Dialog_ClrCache
:
public
QDialog
{
Q_OBJECT
public:
explicit
Dialog_ClrCache
(
QWidget
*
parent
=
nullptr
);
~
Dialog_ClrCache
();
protected:
void
closeEvent
(
QCloseEvent
*
event
);
void
keyPressEvent
(
QKeyEvent
*
event
);
private
slots
:
void
on_btn_clr_clicked
();
void
on_btn_close_clicked
();
private:
bool
clrCache
(
const
QString
&
path
);
qint64
getDirSize
(
const
QString
&
path
);
int
getFileNum
(
const
QString
&
path
);
void
setInformation
(
const
QString
&
path
);
private:
Ui
::
Dialog_ClrCache
*
ui
;
bool
m_containTempFile
,
m_isClear
;
};
#endif // DIALOG_CLRCACHE_H
app/Scanner/Scanner/dialog_clrcache.ui
0 → 100644
View file @
543dac9d
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
Dialog_ClrCache
</class>
<widget
class=
"QDialog"
name=
"Dialog_ClrCache"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
490
</width>
<height>
159
</height>
</rect>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
159
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
16777215
</width>
<height>
159
</height>
</size>
</property>
<property
name=
"windowTitle"
>
<string>
Dialog
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Cache path:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLineEdit"
name=
"lineEdit"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Cache occupied space:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"lab_size"
>
<property
name=
"text"
>
<string>
0
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"lab_unit"
>
<property
name=
"text"
>
<string>
B
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"lab_sizeByB"
>
<property
name=
"text"
>
<string>
(0 Byte)
</string>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_4"
>
<item>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Number of files:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"lab_num"
>
<property
name=
"text"
>
<string>
0
</string>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer_3"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_3"
>
<item>
<spacer
name=
"horizontalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QPushButton"
name=
"btn_clr"
>
<property
name=
"text"
>
<string>
Clear Cache
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"btn_close"
>
<property
name=
"text"
>
<string>
Close
</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
app/Scanner/Scanner/global.h
View file @
543dac9d
...
...
@@ -3,8 +3,9 @@
#include <QStandardPaths>
static
const
QString
APP_FILE_PATH
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
"/Huago/ScannerApp/Cache"
;
static
const
QString
LOG_PATH
=
APP_FILE_PATH
+
"/log"
;
static
const
QString
APP_AQUIREINTO_PATH
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
"/Huago/ScannerApp/AquireInto"
;
static
const
QString
APP_CACHE_PATH
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
"/Huago/ScannerApp/Cache"
;
static
const
QString
LOG_PATH
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
"/Huago/ScannerApp/Cache/Log"
;
enum
LogFacility
{
kernel_messages
,
...
...
app/Scanner/Scanner/mainwindow.cpp
View file @
543dac9d
...
...
@@ -24,6 +24,7 @@
#include "dialog_insertindex.h"
#include "dialog_aquireinto.h"
#include "dialog_logmanager.h"
#include "dialog_clrcache.h"
#if !defined(HG_CMP_MSC) || !defined(APP_USE_TWAIN)
#include "hg_settingdialog.h"
#endif
...
...
@@ -1721,6 +1722,10 @@ void MainWindow::on_act_clrCache_triggered()
{
return
;
}
Dialog_ClrCache
d
(
this
);
d
.
setWindowFlags
(
Qt
::
Dialog
|
Qt
::
WindowCloseButtonHint
);
d
.
exec
();
}
void
MainWindow
::
on_act_consume_triggered
()
...
...
app/Scanner/Scanner/qt_zh_CN.qm
0 → 100755
View file @
543dac9d
File added
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