@@ -64,7 +64,7 @@ MainWindow::~MainWindow()
64
64
65
65
QSettings &MainWindow::getSettings () {
66
66
if (!settings) {
67
- QString portable_ini = QCoreApplication::applicationDirPath () + " / qtpass.ini" ;
67
+ QString portable_ini = QCoreApplication::applicationDirPath () + QDir::separator () + " qtpass.ini" ;
68
68
if (QFile (portable_ini).exists ()) {
69
69
settings.reset (new QSettings (portable_ini, QSettings::IniFormat));
70
70
} else {
@@ -255,6 +255,7 @@ bool MainWindow::checkConfig() {
255
255
ui->updateButton ->hide ();
256
256
}
257
257
ui->lineEdit ->setFocus ();
258
+
258
259
startupPhase = false ;
259
260
return true ;
260
261
}
@@ -459,7 +460,10 @@ void MainWindow::executeWrapper(QString app, QString args, QString input) {
459
460
// Happens a lot if e.g. git binary is not set.
460
461
// This will result in bogus "QProcess::FailedToStart" messages,
461
462
// also hiding legitimate errors from the gpg commands.
462
- if (app.isEmpty ()) return ;
463
+ if (app.isEmpty ()) {
464
+ qDebug () << " Trying to execute nothing.." ;
465
+ return ;
466
+ }
463
467
// Convert to absolute path, just in case
464
468
app = QDir (QCoreApplication::applicationDirPath ()).absoluteFilePath (app);
465
469
if (wrapperRunning) {
@@ -583,6 +587,8 @@ void MainWindow::enableUiElements(bool state) {
583
587
ui->lineEdit ->setEnabled (state);
584
588
ui->addButton ->setEnabled (state);
585
589
ui->usersButton ->setEnabled (state);
590
+ ui->configButton ->setEnabled (state);
591
+ // is a file selected?
586
592
state &= ui->treeView ->currentIndex ().isValid ();
587
593
ui->deleteButton ->setEnabled (state);
588
594
ui->editButton ->setEnabled (state);
@@ -786,8 +792,12 @@ QString MainWindow::getRecipientString(QString for_file, QString separator, int
786
792
* @param file
787
793
* @param overwrite
788
794
*/
789
- void MainWindow::setPassword (QString file, bool overwrite)
795
+ void MainWindow::setPassword (QString file, bool overwrite, bool isNew = false )
790
796
{
797
+ if (!isNew && lastDecrypt.isEmpty ()) {
798
+ // warn?
799
+ return ;
800
+ }
791
801
bool ok;
792
802
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
793
803
QString newValue = QInputDialog::getMultiLineText (this , tr (" New Value" ),
@@ -844,7 +854,7 @@ void MainWindow::on_addButton_clicked()
844
854
file += " .gpg" ;
845
855
}
846
856
lastDecrypt = " " ;
847
- setPassword (file, false );
857
+ setPassword (file, false , true );
848
858
}
849
859
850
860
/* *
@@ -870,21 +880,25 @@ void MainWindow::on_deleteButton_clicked()
870
880
QFile (file).remove ();
871
881
}
872
882
} else {
873
- file = getDir (ui->treeView ->currentIndex (), false );
883
+ file = getDir (ui->treeView ->currentIndex (), usePass );
874
884
if (QMessageBox::question (this , tr (" Delete folder?" ),
875
885
tr (" Are you sure you want to delete %1?" ).arg (QDir::separator () + getDir (ui->treeView ->currentIndex (), true )),
876
886
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
877
887
return ;
878
888
}
879
- // TODO GIT
889
+ if (usePass) {
890
+ currentAction = DELETE;
891
+ executePass (" rm -r \" " + file + ' "' );
892
+ } else {
893
+ // TODO GIT
880
894
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
881
- QDir dir (file);
882
- dir.removeRecursively ();
895
+ QDir dir (file);
896
+ dir.removeRecursively ();
883
897
#else
884
- removeDir (file);
898
+ removeDir (file);
885
899
#endif
900
+ }
886
901
}
887
-
888
902
}
889
903
890
904
/* *
@@ -937,6 +951,9 @@ void MainWindow::on_editButton_clicked()
937
951
*/
938
952
QList<UserInfo> MainWindow::listKeys (QString keystring, bool secret)
939
953
{
954
+ while (!process->atEnd () || !execQueue->isEmpty ()) {
955
+ Util::qSleep (100 );
956
+ }
940
957
QList<UserInfo> users;
941
958
currentAction = GPG_INTERNAL;
942
959
QString listopt = secret ? " --list-secret-keys " : " --list-keys " ;
@@ -1056,7 +1073,7 @@ void MainWindow::on_usersButton_clicked()
1056
1073
tr (" None of the selected keys have a secret key available.\n "
1057
1074
" You will not be able to decrypt any newly added passwords!" ));
1058
1075
}
1059
- if (!useWebDav){
1076
+ if (!useWebDav && !gitExecutable. isEmpty () ){
1060
1077
if (addFile) {
1061
1078
executeWrapper (gitExecutable, " add \" " + gpgIdFile + ' "' );
1062
1079
}
@@ -1329,6 +1346,9 @@ void MainWindow::addFolder()
1329
1346
*/
1330
1347
void MainWindow::editPassword ()
1331
1348
{
1349
+ while (!process->atEnd () || !execQueue->isEmpty ()) {
1350
+ Util::qSleep (100 );
1351
+ }
1332
1352
// TODO move to editbutton stuff possibly?
1333
1353
currentDir = getDir (ui->treeView ->currentIndex (), false );
1334
1354
lastDecrypt = " Could not decrypt" ;
0 commit comments