Adding .clang-format file.

This commit is contained in:
Louis-Bertrand Varin
2017-05-11 14:36:06 -04:00
committed by Jonathan White
parent c167693ae4
commit 00ae123736
3 changed files with 105 additions and 20 deletions

View File

@@ -25,7 +25,7 @@
#include "core/FilePath.h"
SearchWidget::SearchWidget(QWidget *parent)
SearchWidget::SearchWidget(QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::SearchWidget())
{
@@ -40,11 +40,11 @@ SearchWidget::SearchWidget(QWidget *parent)
connect(this, SIGNAL(escapePressed()), m_ui->searchEdit, SLOT(clear()));
new QShortcut(Qt::CTRL + Qt::Key_F, this, SLOT(searchFocus()), nullptr, Qt::ApplicationShortcut);
new QShortcut(Qt::Key_Escape, m_ui->searchEdit, SLOT(clear()), nullptr, Qt::ApplicationShortcut);
new QShortcut(Qt::Key_Escape, m_ui->searchEdit, SLOT(clear()), nullptr, Qt::ApplicationShortcut);
m_ui->searchEdit->installEventFilter(this);
QMenu *searchMenu = new QMenu();
QMenu* searchMenu = new QMenu();
m_actionCaseSensitive = searchMenu->addAction(tr("Case Sensitive"), this, SLOT(updateCaseSensitive()));
m_actionCaseSensitive->setObjectName("actionSearchCaseSensitive");
m_actionCaseSensitive->setCheckable(true);
@@ -58,39 +58,35 @@ SearchWidget::SearchWidget(QWidget *parent)
m_ui->searchEdit->addAction(m_ui->clearIcon, QLineEdit::TrailingPosition);
// Fix initial visibility of actions (bug in Qt)
for (QToolButton * toolButton: m_ui->searchEdit->findChildren<QToolButton *>()) {
for (QToolButton* toolButton : m_ui->searchEdit->findChildren<QToolButton*>()) {
toolButton->setVisible(toolButton->defaultAction()->isVisible());
}
}
SearchWidget::~SearchWidget()
{
}
bool SearchWidget::eventFilter(QObject *obj, QEvent *event)
bool SearchWidget::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Escape) {
emit escapePressed();
return true;
}
else if (keyEvent->matches(QKeySequence::Copy)) {
} else if (keyEvent->matches(QKeySequence::Copy)) {
// If Control+C is pressed in the search edit when no text
// is selected, copy the password of the current entry
if (!m_ui->searchEdit->hasSelectedText()) {
emit copyPressed();
return true;
}
}
else if (keyEvent->matches(QKeySequence::MoveToNextLine)) {
} else if (keyEvent->matches(QKeySequence::MoveToNextLine)) {
if (m_ui->searchEdit->cursorPosition() == m_ui->searchEdit->text().length()) {
// If down is pressed at EOL, move the focus to the entry view
emit downPressed();
return true;
}
else {
} else {
// Otherwise move the cursor to EOL
m_ui->searchEdit->setCursorPosition(m_ui->searchEdit->text().length());
return true;
@@ -110,7 +106,7 @@ void SearchWidget::connectSignals(SignalMultiplexer& mx)
mx.connect(m_ui->searchEdit, SIGNAL(returnPressed()), SLOT(switchToEntryEdit()));
}
void SearchWidget::databaseChanged(DatabaseWidget *dbWidget)
void SearchWidget::databaseChanged(DatabaseWidget* dbWidget)
{
if (dbWidget != nullptr) {
// Set current search text from this database

View File

@@ -18,11 +18,11 @@
#ifndef KEEPASSX_SEARCHWIDGET_H
#define KEEPASSX_SEARCHWIDGET_H
#include <QWidget>
#include <QTimer>
#include <QWidget>
#include "gui/DatabaseWidget.h"
#include "core/SignalMultiplexer.h"
#include "gui/DatabaseWidget.h"
namespace Ui {
class SearchWidget;
@@ -33,17 +33,17 @@ class SearchWidget : public QWidget
Q_OBJECT
public:
explicit SearchWidget(QWidget *parent = 0);
explicit SearchWidget(QWidget* parent = 0);
~SearchWidget();
void connectSignals(SignalMultiplexer& mx);
void setCaseSensitive(bool state);
protected:
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject* obj, QEvent* event);
signals:
void search(const QString &text);
void search(const QString& text);
void caseSensitiveChanged(bool state);
void escapePressed();
void copyPressed();
@@ -62,7 +62,7 @@ private slots:
private:
const QScopedPointer<Ui::SearchWidget> m_ui;
QTimer* m_searchTimer;
QAction *m_actionCaseSensitive;
QAction* m_actionCaseSensitive;
Q_DISABLE_COPY(SearchWidget)
};