Skip to content

Commit

Permalink
Even more linting and one more tiny opti
Browse files Browse the repository at this point in the history
  • Loading branch information
Anne Jan Brouwer committed Nov 24, 2015
1 parent f95524f commit d981b88
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 82 deletions.
54 changes: 27 additions & 27 deletions configdialog.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef DIALOG_H
#define DIALOG_H
#ifndef CONFIGDIALOG_H_
#define CONFIGDIALOG_H_

#include <QDialog>
#include <QFileDialog>
#include "mainwindow.h"
#include <QTableWidgetItem>
#include <QCloseEvent>
#include "mainwindow.h"

namespace Ui {
struct UserInfo;
Expand All @@ -16,23 +16,23 @@ class ConfigDialog;
class ConfigDialog : public QDialog {
Q_OBJECT

public:
public:
explicit ConfigDialog(MainWindow *parent);
~ConfigDialog();
void setPassPath(QString);
void setGitPath(QString);
void setGpgPath(QString);
void setStorePath(QString);
void setProfiles(QHash<QString, QString>, QString);
void usePass(bool);
void usePass(bool usePass);
void useClipboard(MainWindow::clipBoardType);
void useAutoclear(bool);
void setAutoclear(int);
void useAutoclearPanel(bool);
void setAutoclearPanel(int);
void hidePassword(bool);
void hideContent(bool);
void addGPGId(bool);
void useAutoclear(bool useAutoclear);
void setAutoclear(int seconds);
void useAutoclearPanel(bool useAutoclearPanel);
void setAutoclearPanel(int seconds);
void hidePassword(bool hidePassword);
void hideContent(bool hideContent);
void addGPGId(bool addGPGId);
QString getPassPath();
QString getGitPath();
QString getGpgPath();
Expand All @@ -52,36 +52,36 @@ class ConfigDialog : public QDialog {
bool useTrayIcon();
bool hideOnClose();
bool startMinimized();
void useTrayIcon(bool);
void hideOnClose(bool);
void startMinimized(bool);
void useGit(bool);
void useTrayIcon(bool useTrayIdon);
void hideOnClose(bool hideOnClose);
void startMinimized(bool startMinimized);
void useGit(bool useGit);
bool useGit();
QString getPwgenPath();
void setPwgenPath(QString);
void usePwgen(bool);
void useSymbols(bool);
void setPasswordLength(int);
void usePwgen(bool usePwgen);
void useSymbols(bool useSymbols);
void setPasswordLength(int pwLen);
void setPasswordChars(QString);
bool usePwgen();
bool useSymbols();
int getPasswordLength();
QString getPasswordChars();
bool useTemplate();
void useTemplate(bool);
void useTemplate(bool useTemplate);
QString getTemplate();
void setTemplate(QString);
void templateAllFields(bool);
void templateAllFields(bool templateAllFields);
bool templateAllFields();
bool autoPull();
void autoPull(bool);
void autoPull(bool autoPull);
bool autoPush();
void autoPush(bool);
void autoPush(bool autoPush);

protected:
protected:
void closeEvent(QCloseEvent *event);

private slots:
private slots:
void on_radioButtonNative_clicked();
void on_radioButtonPass_clicked();
void on_toolButtonGit_clicked();
Expand All @@ -99,7 +99,7 @@ private slots:
void on_checkBoxUsePwgen_clicked();
void on_checkBoxUseTemplate_clicked();

private:
private:
QScopedPointer<Ui::ConfigDialog> ui;
void setGroupBoxState();
QString selectExecutable();
Expand All @@ -110,4 +110,4 @@ private slots:
MainWindow *mainWindow;
};

#endif // DIALOG_H
#endif // CONFIGDIALOG_H_
2 changes: 1 addition & 1 deletion keygendialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <QDebug>
#include <QMessageBox>
#include "ui_keygendialog.h"
#include "progressindicator.h"
#include "qprogressindicator.h"

KeygenDialog::KeygenDialog(ConfigDialog *parent)
: QDialog(parent), ui(new Ui::KeygenDialog) {
Expand Down
6 changes: 3 additions & 3 deletions keygendialog.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef KEYGENDIALOG_H
#define KEYGENDIALOG_H
#ifndef KEYGENDIALOG_H_
#define KEYGENDIALOG_H_

#include <QDialog>
#include <QCloseEvent>
Expand All @@ -19,7 +19,7 @@ class KeygenDialog : public QDialog {
protected:
void closeEvent(QCloseEvent *event);

private slots:
private slots:
void on_passphrase1_textChanged(const QString &arg1);
void on_passphrase2_textChanged(const QString &arg1);
void on_checkBox_stateChanged(int arg1);
Expand Down
48 changes: 24 additions & 24 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "configdialog.h"
#include "usersdialog.h"
#include "keygendialog.h"
#include "passworddialog.h"
#include "util.h"
#include <QClipboard>
#include <QDebug>
#include <QInputDialog>
Expand All @@ -21,6 +15,12 @@
#include <winnetwk.h>
#undef DELETE
#endif
#include "ui_mainwindow.h"
#include "configdialog.h"
#include "usersdialog.h"
#include "keygendialog.h"
#include "passworddialog.h"
#include "util.h"

/**
* @brief MainWindow::MainWindow
Expand Down Expand Up @@ -223,7 +223,7 @@ bool MainWindow::checkConfig() {
profile = settings.value("profile").toString();
settings.beginGroup("profiles");
QStringList keys = settings.childKeys();
foreach (QString key, keys)
foreach(QString key, keys)
profiles[key] = settings.value(key).toString();
settings.endGroup();

Expand Down Expand Up @@ -295,7 +295,7 @@ bool MainWindow::checkConfig() {

freshStart = false;

// TODO: this needs to be before we try to access the store,
// TODO(annejan): this needs to be before we try to access the store,
// but it would be better to do it after the Window is shown,
// as the long delay it can cause is irritating otherwise.
if (useWebDav)
Expand Down Expand Up @@ -400,7 +400,7 @@ void MainWindow::config() {
d->autoPull(autoPull);
d->autoPush(autoPush);
if (startupPhase)
d->wizard(); // does shit
d->wizard(); // does shit
if (d->exec()) {
if (d->result() == QDialog::Accepted) {
passExecutable = d->getPassPath();
Expand Down Expand Up @@ -698,22 +698,22 @@ void MainWindow::readyRead(bool finished = false) {
pass->setReadOnly(true);
ui->formLayout->addRow(pass);

for (int j = 0; j < tokens.length(); j++) {
for (int j = 0; j < tokens.length(); ++j) {
QString token = tokens.at(j);
if (token.contains(':')) {
int colon = token.indexOf(':');
QString field = token.left(colon);
if (templateAllFields || passTemplate.contains(field)) {
QString value = token.right(token.length() - colon - 1);
if (!passTemplate.contains(field) && value.startsWith("//"))
continue; // colon is probably from a url
continue; // colon is probably from a url
QLineEdit *line = new QLineEdit();
line->setObjectName(field);
line->setText(value);
line->setReadOnly(true);
ui->formLayout->addRow(new QLabel(field), line);
tokens.removeAt(j);
j--; // tokens.length() also got shortened by the remove..
--j; // tokens.length() also got shortened by the remove..
}
}
}
Expand Down Expand Up @@ -743,7 +743,7 @@ void MainWindow::readyRead(bool finished = false) {
qDebug() << "Keygen Done";
keygen->close();
keygen = 0;
// TODO some sanity checking ?
// TODO(annejan) some sanity checking ?
}
}

Expand Down Expand Up @@ -992,7 +992,7 @@ QString MainWindow::getRecipientString(QString for_file, QString separator,
QStringList recipients_list = getRecipientList(for_file);
if (count)
*count = recipients_list.size();
foreach (const QString recipient, recipients_list)
foreach(const QString recipient, recipients_list)
recipients_str += separator + '"' + recipient + '"';
return recipients_str;
}
Expand Down Expand Up @@ -1156,7 +1156,7 @@ bool MainWindow::removeDir(const QString &dirName) {
QDir dir(dirName);

if (dir.exists(dirName)) {
Q_FOREACH (QFileInfo info,
Q_FOREACH(QFileInfo info,
dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System |
QDir::Hidden | QDir::AllDirs | QDir::Files,
QDir::DirsFirst)) {
Expand Down Expand Up @@ -1206,7 +1206,7 @@ QList<UserInfo> MainWindow::listKeys(QString keystring, bool secret) {
QStringList keys = QString(process->readAllStandardOutput())
.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
UserInfo current_user;
foreach (QString key, keys) {
foreach(QString key, keys) {
QStringList props = key.split(':');
if (props.size() < 10)
continue;
Expand Down Expand Up @@ -1242,7 +1242,7 @@ void MainWindow::on_usersButton_clicked() {
return;
}
QList<UserInfo> secret_keys = listKeys("", true);
foreach (const UserInfo &sec, secret_keys) {
foreach(const UserInfo &sec, secret_keys) {
for (QList<UserInfo>::iterator it = users.begin(); it != users.end(); ++it)
if (sec.key_id == it->key_id)
it->have_secret = true;
Expand All @@ -1256,15 +1256,15 @@ void MainWindow::on_usersButton_clicked() {
getRecipientString(dir.isEmpty() ? "" : dir, " ", &count);
if (!recipients.isEmpty())
selected_users = listKeys(recipients);
foreach (const UserInfo &sel, selected_users) {
foreach(const UserInfo &sel, selected_users) {
for (QList<UserInfo>::iterator it = users.begin(); it != users.end(); ++it)
if (sel.key_id == it->key_id)
it->enabled = true;
}
if (count > selected_users.size()) {
// Some keys seem missing from keyring, add them separately
QStringList recipients = getRecipientList(dir.isEmpty() ? "" : dir);
foreach (const QString recipient, recipients) {
foreach(const QString recipient, recipients) {
if (listKeys(recipient).size() < 1) {
UserInfo i;
i.enabled = true;
Expand Down Expand Up @@ -1295,7 +1295,7 @@ void MainWindow::on_usersButton_clicked() {
return;
}
bool secret_selected = false;
foreach (const UserInfo &user, users) {
foreach(const UserInfo &user, users) {
if (user.enabled) {
gpgId.write((user.key_id + "\n").toUtf8());
secret_selected |= user.have_secret;
Expand Down Expand Up @@ -1379,7 +1379,7 @@ QStringList MainWindow::getSecretKeys() {
if (keys.size() == 0)
return names;

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

return names;
Expand Down Expand Up @@ -1418,7 +1418,7 @@ void MainWindow::updateProfileBox() {
}
}
int index = ui->profileBox->findText(profile);
if (index != -1) // -1 for not found
if (index != -1) // -1 for not found
ui->profileBox->setCurrentIndex(index);
}

Expand Down Expand Up @@ -1598,7 +1598,7 @@ void MainWindow::addFolder() {
newdir.prepend(dir);
// qDebug() << newdir;
QDir().mkdir(newdir);
// TODO add to git?
// TODO(annejan) add to git?
}

/**
Expand All @@ -1608,7 +1608,7 @@ void MainWindow::editPassword() {
if (useGit && autoPull)
on_updateButton_clicked();
waitFor(30);
// TODO move to editbutton stuff possibly?
// TODO(annejan) move to editbutton stuff possibly?
currentDir = getDir(ui->treeView->currentIndex(), false);
lastDecrypt = "Could not decrypt";
QString file = getFile(ui->treeView->currentIndex(), usePass);
Expand Down
4 changes: 2 additions & 2 deletions mainwindow.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_

#include <QMainWindow>
#include <QTreeView>
Expand Down
4 changes: 2 additions & 2 deletions passworddialog.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef PASSWORDDIALOG_H
#define PASSWORDDIALOG_H
#ifndef PASSWORDDIALOG_H_
#define PASSWORDDIALOG_H_

#include <QDialog>
#include "mainwindow.h"
Expand Down
3 changes: 1 addition & 2 deletions progressindicator.cpp → qprogressindicator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "progressindicator.h"

#include "qprogressindicator.h"
#include <QPainter>

QProgressIndicator::QProgressIndicator(QWidget *parent)
Expand Down
4 changes: 2 additions & 2 deletions progressindicator.h → qprogressindicator.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef QPROGRESSINDICATOR_H
#define QPROGRESSINDICATOR_H
#ifndef QPROGRESSINDICATOR_H_
#define QPROGRESSINDICATOR_H_

#include <QWidget>
#include <QColor>
Expand Down
8 changes: 4 additions & 4 deletions qtpass.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ SOURCES += main.cpp\
util.cpp \
usersdialog.cpp \
keygendialog.cpp \
progressindicator.cpp \
trayicon.cpp \
passworddialog.cpp
passworddialog.cpp \
qprogressindicator.cpp

HEADERS += mainwindow.h \
configdialog.h \
storemodel.h \
util.h \
usersdialog.h \
keygendialog.h \
progressindicator.h \
trayicon.h \
passworddialog.h
passworddialog.h \
qprogressindicator.h

FORMS += mainwindow.ui \
configdialog.ui \
Expand Down
4 changes: 2 additions & 2 deletions singleapplication.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SINGLEAPPLICATION_H
#define SINGLEAPPLICATION_H
#ifndef SINGLEAPPLICATION_H_
#define SINGLEAPPLICATION_H_

#include <QApplication>
#include <QSharedMemory>
Expand Down
4 changes: 2 additions & 2 deletions storemodel.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef STOREMODEL_H
#define STOREMODEL_H
#ifndef STOREMODEL_H_
#define STOREMODEL_H_

#include <QSortFilterProxyModel>
#include <QFileSystemModel>
Expand Down
Loading

0 comments on commit d981b88

Please sign in to comment.