Skip to content

Commit

Permalink
Apply Clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
nbolton committed Sep 27, 2024
1 parent 277d151 commit 8a12307
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 26 deletions.
28 changes: 28 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Important: Use the same version of clang-format as our linter, which is:
#
# $ ./scripts/install_deps.py --only-python
# $ ./.venv/bin/clang-format --version
#
# Warning: If you use a different version, the formatting will be different.
#
# To install a specific version of clang-format, use pip:
# $ pip install clang-format==<version>

BasedOnStyle: LLVM

# Turn off LLVM default alignment of params with the opening bracket,
# which can be less readable in some cases in our code base.
#
# Using `AlwaysBreak` will result in:
# void fooBarBazQuxHelloWorld(
# int a,
# int b);
#
# Instead of:
# void fooBarBazQuxHelloWorld(int a,
# int b);
AlignAfterOpenBracket: AlwaysBreak

# Turn off LLVM default packing of ctor initializers.
# This makes it easier to see which members were initialized and in what order.
PackConstructorInitializers: CurrentLine
8 changes: 5 additions & 3 deletions src/lib/synergy/gui/ActivationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ QString serialKey() { return ""; }
// TODO
bool isAvailableAndEnabled(const TlsUtility &tls) { return false; }

ActivationDialog::ActivationDialog(QWidget *parent, AppConfig &appConfig,
LicenseHandler &licenseHandler)
: QDialog(parent), m_ui(new Ui::ActivationDialog), m_pAppConfig(&appConfig),
ActivationDialog::ActivationDialog(
QWidget *parent, AppConfig &appConfig, LicenseHandler &licenseHandler)
: QDialog(parent),
m_ui(new Ui::ActivationDialog),
m_pAppConfig(&appConfig),
m_licenseHandler(licenseHandler) {

m_ui->setupUi(this);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/synergy/gui/ActivationDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class ActivationDialog : public QDialog {
Q_OBJECT

public:
ActivationDialog(QWidget *parent, AppConfig &appConfig,
LicenseHandler &licenseHandler);
ActivationDialog(
QWidget *parent, AppConfig &appConfig, LicenseHandler &licenseHandler);
~ActivationDialog() override;

class ActivationMessageError : public std::runtime_error {
Expand Down
13 changes: 6 additions & 7 deletions src/lib/synergy/gui/license/LicenseHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ bool LicenseHandler::handleStart(QMainWindow *parent, AppConfig *appConfig) {
return showActivationDialog(parent, appConfig);
}

bool LicenseHandler::showActivationDialog(QMainWindow *parent,
AppConfig *appConfig) {
bool LicenseHandler::showActivationDialog(
QMainWindow *parent, AppConfig *appConfig) {
ActivationDialog dialog(parent, *appConfig, *this);
const auto result = dialog.exec();
if (result == QDialog::Accepted) {
Expand All @@ -91,8 +91,8 @@ void LicenseHandler::updateMainWindow() const {
m_mainWindow->setWindowTitle(m_license.productName().c_str());
}

void LicenseHandler::handleSettings(QDialog *parent,
QCheckBox *checkBoxEnableTls) const {
void LicenseHandler::handleSettings(
QDialog *parent, QCheckBox *checkBoxEnableTls) const {

const auto onTlsToggle = [this, parent, checkBoxEnableTls] {
qDebug("tls checkbox toggled");
Expand All @@ -104,9 +104,8 @@ void LicenseHandler::handleSettings(QDialog *parent,
checkTlsCheckBox(parent, checkBoxEnableTls, false);
}

void LicenseHandler::checkTlsCheckBox(QDialog *parent,
QCheckBox *checkBoxEnableTls,
bool showDialog) const {
void LicenseHandler::checkTlsCheckBox(
QDialog *parent, QCheckBox *checkBoxEnableTls, bool showDialog) const {
if (!m_license.isTlsAvailable() && checkBoxEnableTls->isChecked()) {
qDebug("tls not available, showing upgrade dialog");
checkBoxEnableTls->setChecked(false);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/synergy/gui/license/LicenseHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class LicenseHandler : public QObject {
void setEnabled(bool enabled) { m_enabled = enabled; }
bool handleStart(QMainWindow *parent, AppConfig *appConfig);
void handleSettings(QDialog *parent, QCheckBox *checkBoxEnableTls) const;
void checkTlsCheckBox(QDialog *parent, QCheckBox *checkBoxEnableTls,
bool showDialog) const;
void checkTlsCheckBox(
QDialog *parent, QCheckBox *checkBoxEnableTls, bool showDialog) const;
void updateMainWindow() const;
bool showActivationDialog(QMainWindow *parent, AppConfig *appConfig);

Expand Down
4 changes: 2 additions & 2 deletions src/lib/synergy/license/SerialKeyType.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

class SerialKeyType {
private:
friend bool operator==(SerialKeyType const &lhs,
SerialKeyType const &rhs) = default;
friend bool
operator==(SerialKeyType const &lhs, SerialKeyType const &rhs) = default;

public:
static const std::string Trial;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/synergy/license/parse_serial_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class InvalidSerialKeyFormat : public SerialKeyParseError {

class InvalidSerialKeyDate : public SerialKeyParseError {
public:
explicit InvalidSerialKeyDate(const std::string &date,
const std::string &cause)
explicit InvalidSerialKeyDate(
const std::string &date, const std::string &cause)
: SerialKeyParseError("invalid serial key date: " + date + "\n" + cause) {
}
};
Expand Down
19 changes: 11 additions & 8 deletions src/test/unittests/gui/license/license_notices_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ TEST(license_notices_tests, licenseNotice_subscriptionExpired_correctText) {
EXPECT_THAT(notice.toStdString(), HasSubstr("Your license has expired"));
}

TEST(license_notices_tests,
licenseNotice_subscriptionExpiringInOneHour_correctText) {
TEST(
license_notices_tests,
licenseNotice_subscriptionExpiringInOneHour_correctText) {
SerialKey serialKey("");
serialKey.isValid = true;
serialKey.warnTime = kFutureOneHour;
Expand All @@ -110,8 +111,9 @@ TEST(license_notices_tests,
EXPECT_THAT(notice.toStdString(), HasSubstr("Your license expires today"));
}

TEST(license_notices_tests,
licenseNotice_subscriptionExpiringInOneDay_correctText) {
TEST(
license_notices_tests,
licenseNotice_subscriptionExpiringInOneDay_correctText) {
SerialKey serialKey("");
serialKey.isValid = true;
serialKey.warnTime = kFutureOneDay;
Expand All @@ -124,8 +126,9 @@ TEST(license_notices_tests,
EXPECT_THAT(notice.toStdString(), HasSubstr("Your license expires in 1 day"));
}

TEST(license_notices_tests,
licenseNotice_subscriptionExpiringInOneWeek_correctText) {
TEST(
license_notices_tests,
licenseNotice_subscriptionExpiringInOneWeek_correctText) {
SerialKey serialKey("");
serialKey.isValid = true;
serialKey.warnTime = kFutureOneWeek;
Expand All @@ -135,6 +138,6 @@ TEST(license_notices_tests,

QString notice = licenseNotice(license);

EXPECT_THAT(notice.toStdString(),
HasSubstr("Your license expires in 7 days"));
EXPECT_THAT(
notice.toStdString(), HasSubstr("Your license expires in 7 days"));
}

0 comments on commit 8a12307

Please sign in to comment.