Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-client-windows
Commits
ab5d3b9c
Commit
ab5d3b9c
authored
May 08, 2020
by
Ming Rui Zhang
Browse files
newwizardwidget: add potential password dialog when exporting account
Change-Id: I6e534712366514c5c81e03880252887ba0899c71
parent
89e7438b
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/newwizardwidget.cpp
View file @
ab5d3b9c
...
...
@@ -360,15 +360,10 @@ NewWizardWidget::on_skipBtn_clicked()
void
NewWizardWidget
::
on_exportBtn_clicked
()
{
QFileDialog
dialog
(
this
);
QString
dir
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Export Account Here"
),
QDir
::
homePath
()
+
"/Desktop"
,
QFileDialog
::
ShowDirsOnly
|
QFileDialog
::
DontResolveSymlinks
);
if
(
!
dir
.
isEmpty
())
{
LRCInstance
::
accountModel
().
exportToFile
(
LRCInstance
::
getCurrAccId
(),
dir
+
"/export.gz"
);
if
(
Utils
::
exportAccount
(
this
))
{
emit
NavigationRequested
(
ScreenEnum
::
CallScreen
);
emit
LRCInstance
::
instance
().
accountListChanged
();
}
emit
NavigationRequested
(
ScreenEnum
::
CallScreen
);
emit
LRCInstance
::
instance
().
accountListChanged
();
}
void
...
...
src/settingswidget.cpp
View file @
ab5d3b9c
...
...
@@ -749,33 +749,7 @@ SettingsWidget::unban(int index)
void
SettingsWidget
::
exportAccountSlot
()
{
QFileDialog
dialog
(
this
);
auto
openPath
=
QDir
::
homePath
()
+
"/Desktop"
+
"/export.gz"
;
auto
fileUri
=
QFileDialog
::
getSaveFileUrl
(
this
,
tr
(
"Export Account"
),
QUrl
::
fromLocalFile
(
openPath
),
tr
(
"Gzip File"
)
+
" (*.gz)"
,
nullptr
,
QFileDialog
::
DontResolveSymlinks
);
if
(
!
fileUri
.
isEmpty
())
{
// remove prefix from QUri encoded data
QString
filePrefix
{
"file:///"
};
auto
filePath
=
QString
::
fromLocal8Bit
(
fileUri
.
toEncoded
());
filePath
=
filePath
.
remove
(
filePrefix
);
if
(
LRCInstance
::
getCurrAccConfig
().
archiveHasPassword
)
{
PasswordDialog
dialog
(
this
,
PasswordEnteringPurpose
::
ExportAccount
);
dialog
.
setExportPath
(
filePath
);
int
doneCode
=
dialog
.
exec
();
if
(
doneCode
==
PasswordDialog
::
SuccessCode
)
QMessageBox
::
information
(
0
,
tr
(
"Success"
),
tr
(
"Export Successful"
));
}
else
{
bool
success
=
LRCInstance
::
accountModel
().
exportToFile
(
LRCInstance
::
getCurrAccId
(),
filePath
);
if
(
success
)
{
QMessageBox
::
information
(
0
,
tr
(
"Success"
),
tr
(
"Export Successful"
));
}
else
{
QMessageBox
::
critical
(
0
,
tr
(
"Error"
),
tr
(
"Export Failed"
));
}
}
}
Utils
::
exportAccount
(
this
);
}
void
...
...
src/utils.cpp
View file @
ab5d3b9c
...
...
@@ -36,6 +36,7 @@
#include
"updateconfirmdialog.h"
#include
"version.h"
#include
"mainwindow.h"
#include
"passworddialog.h"
#include
<globalinstances.h>
#include
<qrencode.h>
...
...
@@ -44,6 +45,7 @@
#include
<QBitmap>
#include
<QObject>
#include
<QErrorMessage>
#include
<QFileDialog>
#include
<QPainter>
#include
<QStackedWidget>
#include
<QPropertyAnimation>
...
...
@@ -777,6 +779,43 @@ Utils::setCurrentScalingRatio(float ratio)
CURRENT_SCALING_RATIO
=
ratio
;
}
bool
Utils
::
exportAccount
(
QWidget
*
parent
)
{
QFileDialog
dialog
(
parent
);
auto
openPath
=
QDir
::
homePath
()
+
"/Desktop"
+
"/export.gz"
;
auto
fileUri
=
QFileDialog
::
getSaveFileUrl
(
parent
,
QObject
::
tr
(
"Export Account"
),
QUrl
::
fromLocalFile
(
openPath
),
QObject
::
tr
(
"Gzip File"
)
+
" (*.gz)"
,
nullptr
,
QFileDialog
::
DontResolveSymlinks
);
if
(
!
fileUri
.
isEmpty
())
{
// remove prefix from QUri encoded data
QString
filePrefix
{
"file:///"
};
auto
filePath
=
QString
::
fromLocal8Bit
(
fileUri
.
toEncoded
());
filePath
=
filePath
.
remove
(
filePrefix
);
if
(
LRCInstance
::
getCurrAccConfig
().
archiveHasPassword
)
{
PasswordDialog
dialog
(
parent
,
PasswordEnteringPurpose
::
ExportAccount
);
dialog
.
setExportPath
(
filePath
);
int
doneCode
=
dialog
.
exec
();
if
(
doneCode
==
PasswordDialog
::
SuccessCode
)
{
QMessageBox
::
information
(
0
,
QObject
::
tr
(
"Success"
),
QObject
::
tr
(
"Export Successful"
));
return
true
;
}
}
else
{
bool
success
=
LRCInstance
::
accountModel
().
exportToFile
(
LRCInstance
::
getCurrAccId
(),
filePath
);
if
(
success
)
{
QMessageBox
::
information
(
0
,
QObject
::
tr
(
"Success"
),
QObject
::
tr
(
"Export Successful"
));
}
else
{
QMessageBox
::
critical
(
0
,
QObject
::
tr
(
"Error"
),
QObject
::
tr
(
"Export Failed"
));
}
return
success
;
}
}
return
false
;
}
QString
Utils
::
formattedTime
(
int
duration
)
{
...
...
src/utils.h
View file @
ab5d3b9c
...
...
@@ -78,6 +78,7 @@ void forceDeleteAsync(const QString& path);
QString
getChangeLog
();
float
getCurrentScalingRatio
();
void
setCurrentScalingRatio
(
float
ratio
);
bool
exportAccount
(
QWidget
*
parent
);
// updates
void
cleanUpdateFiles
();
...
...
stylesheet.css
View file @
ab5d3b9c
...
...
@@ -602,6 +602,11 @@ QLabel#dragDropLabel {
background
:
rgba
(
216
,
234
,
252
,
0.95
);
}
QLabel
#wrongPasswordLabel
{
color
:
red
;
margin-left
:
8px
;
}
/* setAvatarDialog { */
QPushButton
#pictureButton
:default
,
QPushButton
#fileButton
:default
{
background-color
:
rgb
(
0
,
192
,
213
,);
...
...
@@ -639,10 +644,6 @@ QSpinBox::down-button {
}
/* SettingsWidget { */
SettingsWidget
QLabel
#wrongPasswordLabel
{
color
:
red
;
margin-left
:
8px
;
}
SettingsWidget
QLabel
#exportedPIN
{
color
:
darkblue
;
margin-bottom
:
4px
;
...
...
Write
Preview
Supports
Markdown
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