Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and improvments for config dialog #432

Merged
merged 3 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
useSelection(QtPassSettings::isUseSelection());
}

if (Util::checkConfig()) {
// Show Programs tab, which is likely
// what the user needs to fix now.
ui->tabWidget->setCurrentIndex(1);
}

connect(ui->profileTable, &QTableWidget::itemChanged, this,
&ConfigDialog::onProfileTableItemChanged);
connect(this, &ConfigDialog::accepted, this, &ConfigDialog::on_accepted);
Expand Down Expand Up @@ -218,6 +224,20 @@ void ConfigDialog::on_accepted() {
QtPassSettings::setVersion(VERSION);
}

void ConfigDialog::on_autodetectButton_clicked()
{
QString pass = Util::findBinaryInPath("pass");
if (!pass.isEmpty()) ui->passPath->setText(pass);
usePass(!pass.isEmpty());
QString gpg = Util::findBinaryInPath("gpg2");
if (gpg.isEmpty()) gpg = Util::findBinaryInPath("gpg");
if (!gpg.isEmpty()) ui->gpgPath->setText(gpg);
QString git = Util::findBinaryInPath("git");
if (!git.isEmpty()) ui->gitPath->setText(git);
QString pwgen = Util::findBinaryInPath("pwgen");
if (!pwgen.isEmpty()) ui->pwgenPath->setText(pwgen);
}

/**
* @brief ConfigDialog::on_radioButtonNative_clicked wrapper for
* ConfigDialog::setGroupBoxState()
Expand Down
1 change: 1 addition & 0 deletions src/configdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ConfigDialog : public QDialog {

private slots:
void on_accepted();
void on_autodetectButton_clicked();
void on_radioButtonNative_clicked();
void on_radioButtonPass_clicked();
void on_toolButtonGit_clicked();
Expand Down
24 changes: 24 additions & 0 deletions src/configdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,30 @@
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<spacer name="horizontalSpacer_8">
<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="QToolButton" name="autodetectButton">
<property name="text">
<string>Autodetect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down
6 changes: 4 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,11 @@ void MainWindow::on_treeView_doubleClicked(const QModelIndex &index) {
* @brief MainWindow::deselect clear the selection, password and copy buffer
*/
void MainWindow::deselect() {
currentDir = "/";
currentDir = "";
m_qtPass->clearClipboard();
ui->passwordName->setText("");
ui->actionDelete->setEnabled(false);
ui->actionEdit->setEnabled(false);
clearPanel(false);
}

Expand Down Expand Up @@ -626,7 +628,7 @@ void MainWindow::onDelete() {

QString dirMessage = tr(" and the whole content?");
if (isDir) {
QDirIterator it(model.rootPath() + "/" + file,
QDirIterator it(model.rootPath() + QDir::separator() + file,
QDirIterator::Subdirectories);
bool okDir = true;
while (it.hasNext() && okDir) {
Expand Down
4 changes: 2 additions & 2 deletions src/qtpasssettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ QString QtPassSettings::getPassStore(const QString &defaultValue) {
}

// ensure path ends in /
if (!returnValue.endsWith("/")) {
returnValue += "/";
if (!returnValue.endsWith("/") && !returnValue.endsWith(QDir::separator())) {
returnValue += QDir::separator();
}

return returnValue;
Expand Down
4 changes: 2 additions & 2 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool Util::checkConfig() {
QString Util::getDir(const QModelIndex &index, bool forPass,
const QFileSystemModel &model,
const StoreModel &storeModel) {
QString abspath = QDir(QtPassSettings::getPassStore()).absolutePath() + '/';
QString abspath = QDir(QtPassSettings::getPassStore()).absolutePath() + QDir::separator();
if (!index.isValid())
return forPass ? "" : abspath;
QFileInfo info = model.fileInfo(storeModel.mapToSource(index));
Expand All @@ -145,7 +145,7 @@ QString Util::getDir(const QModelIndex &index, bool forPass,
if (forPass) {
filePath = QDir(abspath).relativeFilePath(filePath);
}
filePath += '/';
filePath += QDir::separator();
return filePath;
}

Expand Down