Skip to content

Commit

Permalink
Merge 5d5b266 into b4dc9e6
Browse files Browse the repository at this point in the history
  • Loading branch information
FiloSpaTeam committed Aug 29, 2018
2 parents b4dc9e6 + 5d5b266 commit 6ce81d9
Show file tree
Hide file tree
Showing 46 changed files with 8,019 additions and 4,977 deletions.
445 changes: 234 additions & 211 deletions localization/localization_ar_MA.ts

Large diffs are not rendered by default.

477 changes: 314 additions & 163 deletions localization/localization_ca.ts

Large diffs are not rendered by default.

455 changes: 292 additions & 163 deletions localization/localization_cs_CZ.ts

Large diffs are not rendered by default.

462 changes: 296 additions & 166 deletions localization/localization_de_DE.ts

Large diffs are not rendered by default.

458 changes: 292 additions & 166 deletions localization/localization_de_LU.ts

Large diffs are not rendered by default.

443 changes: 235 additions & 208 deletions localization/localization_el_GR.ts

Large diffs are not rendered by default.

488 changes: 325 additions & 163 deletions localization/localization_en_GB.ts

Large diffs are not rendered by default.

488 changes: 325 additions & 163 deletions localization/localization_en_US.ts

Large diffs are not rendered by default.

446 changes: 280 additions & 166 deletions localization/localization_es_ES.ts

Large diffs are not rendered by default.

455 changes: 292 additions & 163 deletions localization/localization_fr_BE.ts

Large diffs are not rendered by default.

493 changes: 328 additions & 165 deletions localization/localization_fr_FR.ts

Large diffs are not rendered by default.

455 changes: 292 additions & 163 deletions localization/localization_fr_LU.ts

Large diffs are not rendered by default.

536 changes: 351 additions & 185 deletions localization/localization_gl_ES.ts

Large diffs are not rendered by default.

445 changes: 234 additions & 211 deletions localization/localization_he_IL.ts

Large diffs are not rendered by default.

435 changes: 247 additions & 188 deletions localization/localization_hu_HU.ts

Large diffs are not rendered by default.

512 changes: 342 additions & 170 deletions localization/localization_it_IT.ts

Large diffs are not rendered by default.

445 changes: 234 additions & 211 deletions localization/localization_lb_LU.ts

Large diffs are not rendered by default.

481 changes: 318 additions & 163 deletions localization/localization_nl_BE.ts

Large diffs are not rendered by default.

481 changes: 318 additions & 163 deletions localization/localization_nl_NL.ts

Large diffs are not rendered by default.

443 changes: 235 additions & 208 deletions localization/localization_pl_PL.ts

Large diffs are not rendered by default.

458 changes: 295 additions & 163 deletions localization/localization_pt_PT.ts

Large diffs are not rendered by default.

459 changes: 293 additions & 166 deletions localization/localization_ru_RU.ts

Large diffs are not rendered by default.

458 changes: 274 additions & 184 deletions localization/localization_sv_SE.ts

Large diffs are not rendered by default.

455 changes: 292 additions & 163 deletions localization/localization_zh_CN.ts

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions main/main.cpp
Expand Up @@ -87,10 +87,9 @@ int main(int argc, char *argv[]) {
app.setActiveWindow(&w);
app.setWindowIcon(QIcon(":artwork/icon.png"));

QObject::connect(&app, SIGNAL(aboutToQuit()), &w, SLOT(clearClipboard()));
#if SINGLE_APP
QObject::connect(&app, SIGNAL(messageAvailable(QString)), &w,
SLOT(messageAvailable(QString)));
QObject::connect(&app, &SingleApplication::messageAvailable, &w,
&MainWindow::messageAvailable);
#endif

w.show();
Expand Down
160 changes: 127 additions & 33 deletions src/configdialog.cpp
@@ -1,5 +1,4 @@
#include "configdialog.h"
#include "debughelper.h"
#include "keygendialog.h"
#include "mainwindow.h"
#include "qtpasssettings.h"
Expand All @@ -8,10 +7,17 @@
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#include <QPushButton>
#include <QSystemTrayIcon>
#include <QTableWidgetItem>
#ifdef Q_OS_WIN
#include <windows.h>
#endif

#ifdef QT_DEBUG
#include "debughelper.h"
#endif

/**
* @brief ConfigDialog::ConfigDialog this sets up the configuration screen.
* @param parent
Expand All @@ -32,8 +38,17 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
ui->checkBoxHidePassword->setChecked(QtPassSettings::isHidePassword());
ui->checkBoxHideContent->setChecked(QtPassSettings::isHideContent());
ui->checkBoxAddGPGId->setChecked(QtPassSettings::isAddGPGId(true));
ui->checkBoxHideOnClose->setChecked(QtPassSettings::isHideOnClose());
ui->checkBoxStartMinimized->setChecked(QtPassSettings::isStartMinimized());

if (QSystemTrayIcon::isSystemTrayAvailable() == true) {
ui->checkBoxHideOnClose->setChecked(QtPassSettings::isHideOnClose());
ui->checkBoxStartMinimized->setChecked(QtPassSettings::isStartMinimized());
} else {
ui->checkBoxUseTrayIcon->setEnabled(false);
ui->checkBoxUseTrayIcon->setToolTip(tr("System tray is not available"));
ui->checkBoxHideOnClose->setEnabled(false);
ui->checkBoxStartMinimized->setEnabled(false);
}

ui->checkBoxAvoidCapitals->setChecked(QtPassSettings::isAvoidCapitals());
ui->checkBoxAvoidNumbers->setChecked(QtPassSettings::isAvoidNumbers());
ui->checkBoxLessRandom->setChecked(QtPassSettings::isLessRandom());
Expand All @@ -50,6 +65,12 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
ui->label_10->hide();
#endif

if (!isPassOtpAvailable()) {
ui->checkBoxUseOtp->setEnabled(false);
ui->checkBoxUseOtp->setToolTip(
tr("Pass OTP extension needs to be installed"));
}

setProfiles(QtPassSettings::getProfiles(), QtPassSettings::getProfile());
setPwgenPath(QtPassSettings::getPwgenExecutable());
setPasswordConfiguration(QtPassSettings::getPasswordConfiguration());
Expand All @@ -59,7 +80,9 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
useAutoclearPanel(QtPassSettings::isUseAutoclearPanel());
useTrayIcon(QtPassSettings::isUseTrayIcon());
useGit(QtPassSettings::isUseGit());

useOtp(QtPassSettings::isUseOtp());

usePwgen(QtPassSettings::isUsePwgen());
useTemplate(QtPassSettings::isUseTemplate());

Expand All @@ -84,6 +107,8 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
useSelection(QtPassSettings::isUseSelection());
}

connect(ui->profileTable, &QTableWidget::itemChanged, this,
&ConfigDialog::onProfileTableItemChanged);
connect(this, &ConfigDialog::accepted, this, &ConfigDialog::on_accepted);
}

Expand Down Expand Up @@ -121,6 +146,34 @@ void ConfigDialog::usePass(bool usePass) {
setGroupBoxState();
}

void ConfigDialog::validate(QTableWidgetItem *item) {
bool status = true;

if (item == nullptr) {
for (int i = 0; i < ui->profileTable->rowCount(); i++) {
for (int j = 0; j < ui->profileTable->columnCount(); j++) {
QTableWidgetItem *_item = ui->profileTable->item(i, j);

if (_item->text().isEmpty()) {
_item->setBackgroundColor(Qt::red);
status = false;
break;
}
}

if (!status)
break;
}
} else {
if (item->text().isEmpty()) {
item->setBackgroundColor(Qt::red);
status = false;
}
}

ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status);
}

void ConfigDialog::on_accepted() {
QtPassSettings::setPassExecutable(ui->passPath->text());
QtPassSettings::setGitExecutable(ui->gitPath->text());
Expand All @@ -138,9 +191,12 @@ void ConfigDialog::on_accepted() {
QtPassSettings::setHidePassword(ui->checkBoxHidePassword->isChecked());
QtPassSettings::setHideContent(ui->checkBoxHideContent->isChecked());
QtPassSettings::setAddGPGId(ui->checkBoxAddGPGId->isChecked());
QtPassSettings::setUseTrayIcon(ui->checkBoxUseTrayIcon->isChecked());
QtPassSettings::setHideOnClose(hideOnClose());
QtPassSettings::setStartMinimized(ui->checkBoxStartMinimized->isChecked());
QtPassSettings::setUseTrayIcon(ui->checkBoxUseTrayIcon->isEnabled() &&
ui->checkBoxUseTrayIcon->isChecked());
QtPassSettings::setHideOnClose(ui->checkBoxHideOnClose->isEnabled() &&
ui->checkBoxHideOnClose->isChecked());
QtPassSettings::setStartMinimized(ui->checkBoxStartMinimized->isEnabled() &&
ui->checkBoxStartMinimized->isChecked());
QtPassSettings::setProfiles(getProfiles());
QtPassSettings::setUseGit(ui->checkBoxUseGit->isChecked());
QtPassSettings::setUseOtp(ui->checkBoxUseOtp->isChecked());
Expand Down Expand Up @@ -174,6 +230,23 @@ void ConfigDialog::on_radioButtonNative_clicked() { setGroupBoxState(); }
*/
void ConfigDialog::on_radioButtonPass_clicked() { setGroupBoxState(); }

/**
* @brief ConfigDialog::getSecretKeys get list of secret/private keys
* @return QStringList keys
*/
QStringList ConfigDialog::getSecretKeys() {
QList<UserInfo> keys = QtPassSettings::getPass()->listKeys("", true);
QStringList names;

if (keys.size() == 0)
return names;

foreach (const UserInfo &sec, keys)
names << sec.name;

return names;
}

/**
* @brief ConfigDialog::setGroupBoxState update checkboxes.
*/
Expand Down Expand Up @@ -333,8 +406,8 @@ void ConfigDialog::on_checkBoxAutoclear_clicked() {
}

/**
* @brief ConfigDialog::genKey tunnel function to make MainWindow generate a gpg
* key pair.
* @brief ConfigDialog::genKey tunnel function to make MainWindow generate a
* gpg key pair.
* @todo refactor the process to not be entangled so much.
* @param batch
* @param dialog
Expand Down Expand Up @@ -382,10 +455,9 @@ QHash<QString, QString> ConfigDialog::getProfiles() {
// Check?
for (int i = 0; i < ui->profileTable->rowCount(); ++i) {
QTableWidgetItem *pathItem = ui->profileTable->item(i, 1);
if (0 != pathItem) {
if (nullptr != pathItem) {
QTableWidgetItem *item = ui->profileTable->item(i, 0);
if (item == 0) {
dbg() << "empty name, should fix in frontend";
if (item == nullptr) {
continue;
}
profiles.insert(item->text(), pathItem->text());
Expand All @@ -400,9 +472,12 @@ QHash<QString, QString> ConfigDialog::getProfiles() {
void ConfigDialog::on_addButton_clicked() {
int n = ui->profileTable->rowCount();
ui->profileTable->insertRow(n);
ui->profileTable->setItem(n, 0, new QTableWidgetItem());
ui->profileTable->setItem(n, 1, new QTableWidgetItem(ui->storePath->text()));
ui->profileTable->selectRow(n);
ui->deleteButton->setEnabled(true);

validate();
}

/**
Expand All @@ -427,18 +502,32 @@ void ConfigDialog::on_deleteButton_clicked() {
ui->profileTable->removeRow(row);
if (ui->profileTable->rowCount() < 1)
ui->deleteButton->setEnabled(false);

validate();
}

/**
* @brief ConfigDialog::criticalMessage weapper for showing critical messages in
* a popup.
* @brief ConfigDialog::criticalMessage weapper for showing critical messages
* in a popup.
* @param title
* @param text
*/
void ConfigDialog::criticalMessage(const QString &title, const QString &text) {
QMessageBox::critical(this, title, text, QMessageBox::Ok, QMessageBox::Ok);
}

bool ConfigDialog::isPassOtpAvailable() {
#ifdef Q_OS_WIN
return false;
#elif defined(__APPLE__)
return false;
#else
QFileInfo file("/usr/lib/password-store/extensions/otp.bash");

return file.exists();
#endif
}

/**
* @brief ConfigDialog::wizard first-time use wizard.
* @todo make this thing more reliable.
Expand All @@ -453,14 +542,19 @@ void ConfigDialog::wizard() {
criticalMessage(
tr("GnuPG not found"),
tr("Please install GnuPG on your system.<br>Install "
"<strong>gpg</strong> using your favorite package manager<br>or <a "
"<strong>gpg</strong> using your favorite package manager<br>or "
"<a "
"href=\"https://www.gnupg.org/download/#sec-1-2\">download</a> it "
"from GnuPG.org"));
clean = true;
}

QStringList names = mainWindow->getSecretKeys();
QStringList names = getSecretKeys();

#ifdef QT_DEBUG
dbg() << names;
#endif

if (QFile(gpg).exists() && names.empty()) {
KeygenDialog d(this);
if (!d.exec())
Expand All @@ -482,14 +576,15 @@ void ConfigDialog::wizard() {
FILE_ATTRIBUTE_HIDDEN);
#endif
if (ui->checkBoxUseGit->isChecked())
mainWindow->executePassGitInit();
emit mainWindow->passGitInitNeeded();
mainWindow->userDialog(passStore);
}
}

if (!QFile(QDir(passStore).filePath(".gpg-id")).exists()) {
#ifdef QT_DEBUG
dbg() << ".gpg-id file does not exist";

#endif
if (!clean) {
criticalMessage(tr("Password store not initialised"),
tr("The folder %1 doesn't seem to be a password store or "
Expand All @@ -504,36 +599,31 @@ void ConfigDialog::wizard() {
passStore = ui->storePath->text();
}
if (!QFile(passStore + ".gpg-id").exists()) {
#ifdef QT_DEBUG
dbg() << ".gpg-id file still does not exist :/";
#endif
// appears not to be store
// init yes / no ?
mainWindow->userDialog(passStore);
}
}
}

/**
* @brief ConfigDialog::hideOnClose return preference for hiding instead of
* closing (quitting) application.
* @return
*/
bool ConfigDialog::hideOnClose() {
return ui->checkBoxHideOnClose->isEnabled() &&
ui->checkBoxHideOnClose->isChecked();
}

/**
* @brief ConfigDialog::useTrayIcon set preference for using trayicon.
* Enable or disable related checkboxes accordingly.
* @param useSystray
*/
void ConfigDialog::useTrayIcon(bool useSystray) {
ui->checkBoxUseTrayIcon->setChecked(useSystray);
ui->checkBoxHideOnClose->setEnabled(useSystray);
ui->checkBoxStartMinimized->setEnabled(useSystray);
if (!useSystray) {
ui->checkBoxHideOnClose->setChecked(false);
ui->checkBoxStartMinimized->setChecked(false);
if (QSystemTrayIcon::isSystemTrayAvailable() == true) {
ui->checkBoxUseTrayIcon->setChecked(useSystray);
ui->checkBoxHideOnClose->setEnabled(useSystray);
ui->checkBoxStartMinimized->setEnabled(useSystray);

if (!useSystray) {
ui->checkBoxHideOnClose->setChecked(false);
ui->checkBoxStartMinimized->setChecked(false);
}
}
}

Expand Down Expand Up @@ -686,6 +776,10 @@ void ConfigDialog::on_checkBoxUseTemplate_clicked() {
ui->checkBoxUseTemplate->isChecked());
}

void ConfigDialog::onProfileTableItemChanged(QTableWidgetItem *item) {
validate(item);
}

/**
* @brief ConfigDialog::useTemplate set preference for using templates.
* @param useTemplate
Expand Down
8 changes: 7 additions & 1 deletion src/configdialog.h
Expand Up @@ -20,6 +20,7 @@ class ConfigDialog;
*/
class MainWindow;
class QCloseEvent;
class QTableWidgetItem;
class ConfigDialog : public QDialog {
Q_OBJECT

Expand All @@ -33,7 +34,6 @@ class ConfigDialog : public QDialog {
QHash<QString, QString> getProfiles();
void wizard();
void genKey(QString, QDialog *);
bool hideOnClose();
void useTrayIcon(bool useTrayIdon);
void useGit(bool useGit);
void useOtp(bool useOtp);
Expand Down Expand Up @@ -66,10 +66,13 @@ private slots:
void on_checkBoxUseGit_clicked();
void on_checkBoxUsePwgen_clicked();
void on_checkBoxUseTemplate_clicked();
void onProfileTableItemChanged(QTableWidgetItem *item);

private:
QScopedPointer<Ui::ConfigDialog> ui;

QStringList getSecretKeys();

void setGitPath(QString);
void setProfiles(QHash<QString, QString>, QString);
void usePass(bool usePass);
Expand All @@ -81,6 +84,9 @@ private slots:
// Qt 5.4.1 when QApplication::exec was not yet called
void criticalMessage(const QString &title, const QString &text);

bool isPassOtpAvailable();
void validate(QTableWidgetItem *item = nullptr);

MainWindow *mainWindow;
};

Expand Down

0 comments on commit 6ce81d9

Please sign in to comment.