aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp75
-rw-r--r--src/ui/widgets/FilePage.cpp17
-rw-r--r--src/ui/widgets/InfoBoardWidget.cpp15
-rw-r--r--src/ui/widgets/TextEdit.cpp8
4 files changed, 59 insertions, 56 deletions
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 106c3cd1..dcc31527 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -257,49 +257,52 @@ void MainWindow::slotEncryptSign() {
delete resultAnalyseEncr;
delete resultAnalyseSign;
} else if (edit->slotCurPageFileTreeView() != nullptr) {
- this->slotFileVerify();
+ this->slotFileEncryptSign();
}
}
void MainWindow::slotDecryptVerify() {
- if (edit->tabCount() == 0 || edit->slotCurPageTextEdit() == nullptr) {
- return;
- }
+ if (edit->tabCount() == 0) return;
- auto *decrypted = new QByteArray();
- QByteArray text = edit->curTextPage()->toPlainText().toUtf8();
- GpgME::GpgContext::preventNoDataErr(&text);
+ if (edit->slotCurPageTextEdit() != nullptr) {
- gpgme_decrypt_result_t d_result = nullptr;
- gpgme_verify_result_t v_result = nullptr;
- // try decrypt, if fail do nothing, especially don't replace text
- auto error = mCtx->decryptVerify(text, decrypted, &d_result, &v_result);
- infoBoard->associateTextEdit(edit->curTextPage());
+ auto *decrypted = new QByteArray();
+ QByteArray text = edit->curTextPage()->toPlainText().toUtf8();
+ GpgME::GpgContext::preventNoDataErr(&text);
- if (gpgme_err_code(error) == GPG_ERR_NO_ERROR)
- edit->slotFillTextEditWithText(QString::fromUtf8(*decrypted));
+ gpgme_decrypt_result_t d_result = nullptr;
+ gpgme_verify_result_t v_result = nullptr;
+ // try decrypt, if fail do nothing, especially don't replace text
+ auto error = mCtx->decryptVerify(text, decrypted, &d_result, &v_result);
+ infoBoard->associateTextEdit(edit->curTextPage());
- auto resultAnalyseDecrypt = new DecryptResultAnalyse(mCtx, error, d_result);
- auto resultAnalyseVerify = new VerifyResultAnalyse(mCtx, error, v_result);
+ if (gpgme_err_code(error) == GPG_ERR_NO_ERROR)
+ edit->slotFillTextEditWithText(QString::fromUtf8(*decrypted));
- int status = std::min(resultAnalyseDecrypt->getStatus(), resultAnalyseVerify->getStatus());
- auto &reportText = resultAnalyseDecrypt->getResultReport() + resultAnalyseVerify->getResultReport();
- if (status < 0)
- infoBoard->slotRefresh(reportText, INFO_ERROR_CRITICAL);
- else if (status > 0)
- infoBoard->slotRefresh(reportText, INFO_ERROR_OK);
- else
- infoBoard->slotRefresh(reportText, INFO_ERROR_WARN);
+ auto resultAnalyseDecrypt = new DecryptResultAnalyse(mCtx, error, d_result);
+ auto resultAnalyseVerify = new VerifyResultAnalyse(mCtx, error, v_result);
- if (resultAnalyseVerify->getStatus() >= 0) {
- infoBoard->resetOptionActionsMenu();
- infoBoard->addOptionalAction("Show Verify Details", [this, error, v_result]() {
- VerifyDetailsDialog(this, mCtx, mKeyList, error, v_result);
- });
+ int status = std::min(resultAnalyseDecrypt->getStatus(), resultAnalyseVerify->getStatus());
+ auto &reportText = resultAnalyseDecrypt->getResultReport() + resultAnalyseVerify->getResultReport();
+ if (status < 0)
+ infoBoard->slotRefresh(reportText, INFO_ERROR_CRITICAL);
+ else if (status > 0)
+ infoBoard->slotRefresh(reportText, INFO_ERROR_OK);
+ else
+ infoBoard->slotRefresh(reportText, INFO_ERROR_WARN);
+
+ if (resultAnalyseVerify->getStatus() >= 0) {
+ infoBoard->resetOptionActionsMenu();
+ infoBoard->addOptionalAction("Show Verify Details", [this, error, v_result]() {
+ VerifyDetailsDialog(this, mCtx, mKeyList, error, v_result);
+ });
+ }
+ delete resultAnalyseDecrypt;
+ delete resultAnalyseVerify;
+ } else if (edit->slotCurPageFileTreeView() != nullptr) {
+ this->slotFileDecryptVerify();
}
- delete resultAnalyseDecrypt;
- delete resultAnalyseVerify;
}
/*
@@ -747,16 +750,6 @@ void MainWindow::slotFileDecryptVerify() {
outFileName = path + ".out";
}
- if (QFile::exists(outFileName)) {
- auto ret = QMessageBox::warning(this,
- tr("Warning"),
- tr("The target file already exists, do you need to overwrite it?"),
- QMessageBox::Ok | QMessageBox::Cancel);
-
- if (ret == QMessageBox::Cancel)
- return;
- }
-
try {
gpgme_decrypt_result_t d_result = nullptr;
diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp
index 9f6970db..42cedfd9 100644
--- a/src/ui/widgets/FilePage.cpp
+++ b/src/ui/widgets/FilePage.cpp
@@ -56,20 +56,23 @@ FilePage::FilePage(QWidget *parent) : QWidget(parent) {
connect(goPathButton, SIGNAL(clicked(bool)), this, SLOT(slotGoPath()));
pathEdit = new QLineEdit();
- pathEdit->setFixedWidth(480);
pathEdit->setText(dirModel->rootPath());
auto *menuLayout = new QHBoxLayout();
menuLayout->addWidget(upLevelButton);
+ menuLayout->setStretchFactor(upLevelButton, 1);
menuLayout->addWidget(pathEdit);
+ menuLayout->setStretchFactor(pathEdit, 8);
menuLayout->addWidget(goPathButton);
- menuLayout->addWidget(goPathButton);
+ menuLayout->setStretchFactor(goPathButton, 1);
menuLayout->addWidget(refreshButton);
- menuLayout->addStretch(0);
+ menuLayout->setStretchFactor(refreshButton, 1);
auto *layout = new QVBoxLayout();
layout->addLayout(menuLayout);
+ layout->setStretchFactor(menuLayout, 1);
layout->addWidget(dirTreeView);
+ layout->setStretchFactor(dirTreeView, 8);
this->setLayout(layout);
@@ -158,10 +161,10 @@ void FilePage::onCustomContextMenu(const QPoint &point) {
qDebug() << "Right Click" << mPath;
if (index.isValid()) {
QFileInfo info(mPath);
- encryptItemAct->setEnabled(info.isFile());
- decryptItemAct->setEnabled(info.isFile());
- signItemAct->setEnabled(info.isFile());
- verifyItemAct->setEnabled(info.isFile());
+ encryptItemAct->setEnabled(info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig"));
+ decryptItemAct->setEnabled(info.isFile() && info.suffix() == "gpg");
+ signItemAct->setEnabled(info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig"));
+ verifyItemAct->setEnabled(info.isFile() && (info.suffix() == "sig" || info.suffix() == "gpg"));
popUpMenu->exec(dirTreeView->viewport()->mapToGlobal(point));
}
diff --git a/src/ui/widgets/InfoBoardWidget.cpp b/src/ui/widgets/InfoBoardWidget.cpp
index f54bcf96..d1de76f4 100644
--- a/src/ui/widgets/InfoBoardWidget.cpp
+++ b/src/ui/widgets/InfoBoardWidget.cpp
@@ -29,7 +29,7 @@ InfoBoardWidget::InfoBoardWidget(QWidget *parent, GpgME::GpgContext *ctx, KeyLis
infoBoard = new QTextEdit(this);
infoBoard->setReadOnly(true);
- infoBoard->setMinimumHeight(140);
+ infoBoard->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
infoBoard->setMinimumWidth(480);
connect(mCtx, SIGNAL(signalKeyInfoChanged()), this, SLOT(slotReset()));
@@ -41,12 +41,15 @@ InfoBoardWidget::InfoBoardWidget(QWidget *parent, GpgME::GpgContext *ctx, KeyLis
detailMenu->addAction(importFromKeyserverAct);
importFromKeyserverAct->setVisible(false);
+ QWidget *actionButtonMenu = new QWidget();
actionButtonLayout = new QHBoxLayout();
+ actionButtonMenu->setLayout(actionButtonLayout);
auto label = new QLabel("Optional Actions Menu");
- label->setFixedHeight(24);
actionButtonLayout->addWidget(label);
actionButtonLayout->addStretch();
+ actionButtonMenu->setFixedHeight(42);
+
QFrame *line;
line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
@@ -54,8 +57,12 @@ InfoBoardWidget::InfoBoardWidget(QWidget *parent, GpgME::GpgContext *ctx, KeyLis
auto *notificationWidgetLayout = new QVBoxLayout(this);
notificationWidgetLayout->addWidget(infoBoard);
- notificationWidgetLayout->addLayout(actionButtonLayout);
+ notificationWidgetLayout->setStretchFactor(infoBoard, 8);
+ notificationWidgetLayout->addWidget(actionButtonMenu);
+ notificationWidgetLayout->setStretchFactor(actionButtonMenu, 1);
notificationWidgetLayout->addWidget(line);
+ notificationWidgetLayout->setStretchFactor(line, 1);
+ notificationWidgetLayout->addStretch(0);
this->setLayout(notificationWidgetLayout);
}
@@ -125,7 +132,7 @@ void InfoBoardWidget::associateTabWidget(QTabWidget *tab) {
void InfoBoardWidget::addOptionalAction(const QString &name, const std::function<void()> &action) {
auto actionButton = new QPushButton(name);
- actionButton->setFixedHeight(24);
+ infoBoard->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
actionButtonLayout->addWidget(actionButton);
connect(actionButton, &QPushButton::clicked, this, [=]() {
action();
diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp
index 9ca1b578..643747ed 100644
--- a/src/ui/widgets/TextEdit.cpp
+++ b/src/ui/widgets/TextEdit.cpp
@@ -575,12 +575,12 @@ void TextEdit::slotFilePagePathChanged(const QString &path) {
QString mPath;
QFileInfo fileInfo(path);
QString tPath = fileInfo.path();
- if (path.size() > 16) {
- mPath = tPath.mid(tPath.size() - 16, 16).prepend("...");
+ if (path.size() > 18) {
+ mPath = tPath.mid(tPath.size() - 18, 18).prepend("...");
} else {
mPath = tPath;
}
- mPath.prepend("[File Browser]: ");
+ mPath.prepend("[File Browser] ");
mPath.append("/");
tabWidget->setTabText(index, mPath);
-} \ No newline at end of file
+}