From 31e271a9f3207efe23a7efb937f4f3275bcb8ad3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 27 May 2022 12:45:31 -0400 Subject: Use "auto" to avoid repeating type names --- .clang-tidy | 1 - src/jalv_gtkmm2.cpp | 6 +++--- src/jalv_qt.cpp | 31 ++++++++++++++++--------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 4cfc149..0c011a4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,7 +5,6 @@ Checks: > -*-narrowing-conversions, -*-reserved-identifier, -*-uppercase-literal-suffix, - -*-use-auto, -altera-*, -bugprone-branch-clone, -bugprone-easily-swappable-parameters, diff --git a/src/jalv_gtkmm2.cpp b/src/jalv_gtkmm2.cpp index 7c4c594..ca49602 100644 --- a/src/jalv_gtkmm2.cpp +++ b/src/jalv_gtkmm2.cpp @@ -1,5 +1,5 @@ /* - Copyright 2007-2016 David Robillard + Copyright 2007-2022 David Robillard Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -80,14 +80,14 @@ jalv_ui_scale_factor(Jalv*) int jalv_open_ui(Jalv* jalv) { - Gtk::Window* window = new Gtk::Window(); + auto* const window = new Gtk::Window(); if (jalv->ui) { jalv_ui_instantiate(jalv, jalv_native_ui_type(), nullptr); } if (jalv->ui_instance) { - GtkWidget* widget = static_cast( + auto* const widget = static_cast( suil_instance_get_widget(jalv->ui_instance)); Gtk::Widget* widgetmm = Glib::wrap(widget); diff --git a/src/jalv_qt.cpp b/src/jalv_qt.cpp index 5ef903d..9293a08 100644 --- a/src/jalv_qt.cpp +++ b/src/jalv_qt.cpp @@ -276,7 +276,7 @@ FlowLayout::smartSpacing(QStyle::PixelMetric pm) const } if (parent->isWidgetType()) { - QWidget* pw = static_cast(parent); + auto* const pw = static_cast(parent); return pw->style()->pixelMetric(pm, nullptr, pw); } @@ -375,7 +375,7 @@ jalv_ui_port_event(Jalv* jalv, suil_instance_port_event(jalv->ui_instance, port_index, buffer_size, protocol, buffer); } else { - Control* control = + auto* const control = static_cast(jalv->ports[port_index].widget); if (control) { control->setValue(*static_cast(buffer)); @@ -402,7 +402,7 @@ add_preset_to_menu(Jalv* jalv, const LilvNode* title, void* data) { - QMenu* menu = static_cast(data); + auto* const menu = static_cast(data); const char* label = lilv_node_as_string(title); QAction* action = new PresetAction(menu, jalv, lilv_node_duplicate(node)); @@ -479,7 +479,7 @@ Control::Control(PortContainer portContainer, QWidget* parent) setValue(defaultValue); // Fill layout - QVBoxLayout* layout = new QVBoxLayout(); + auto* const layout = new QVBoxLayout(); layout->addWidget(label, 0, Qt::AlignHCenter); layout->addWidget(dial, 0, Qt::AlignHCenter); setLayout(layout); @@ -500,7 +500,7 @@ Control::Control(PortContainer portContainer, QWidget* parent) // Set tooltip if comment is available LilvNode* comment = lilv_port_get(plugin, lilvPort, nodes->rdfs_comment); if (comment) { - QString* tooltip = new QString(); + auto* const tooltip = new QString(); tooltip->append(lilv_node_as_string(comment)); setToolTip(*tooltip); } @@ -652,8 +652,8 @@ build_control_widget(Jalv* jalv) std::sort(portContainers.begin(), portContainers.end(), portGroupLessThan); - QWidget* grid = new QWidget(); - FlowLayout* flowLayout = new FlowLayout(-1, -1, -1); + auto* const grid = new QWidget(); + auto* const flowLayout = new FlowLayout(-1, -1, -1); QLayout* layout = flowLayout; LilvNode* lastGroup = nullptr; @@ -662,8 +662,8 @@ build_control_widget(Jalv* jalv) PortContainer portContainer = portContainers[i]; Port* port = portContainer.port; - Control* control = new Control(portContainer, nullptr); - LilvNode* group = lilv_port_get( + auto* const control = new Control(portContainer, nullptr); + LilvNode* group = lilv_port_get( plugin, port->lilv_port, jalv->nodes.pg_group); if (group) { if (!lilv_node_equals(group, lastGroup)) { @@ -675,7 +675,8 @@ build_control_widget(Jalv* jalv) world, group, jalv->nodes.rdfs_label, nullptr); } - QGroupBox* groupBox = new QGroupBox(lilv_node_as_string(groupName)); + auto* const groupBox = + new QGroupBox(lilv_node_as_string(groupName)); groupLayout = new QHBoxLayout(); groupBox->setLayout(groupLayout); @@ -720,10 +721,10 @@ jalv_ui_scale_factor(Jalv*) int jalv_open_ui(Jalv* jalv) { - QMainWindow* win = new QMainWindow(); - QMenu* file_menu = win->menuBar()->addMenu("&File"); - QMenu* presets_menu = win->menuBar()->addMenu("&Presets"); - QAction* quit_action = new QAction("&Quit", win); + auto* const win = new QMainWindow(); + QMenu* file_menu = win->menuBar()->addMenu("&File"); + QMenu* presets_menu = win->menuBar()->addMenu("&Presets"); + auto* const quit_action = new QAction("&Quit", win); QObject::connect(quit_action, SIGNAL(triggered()), win, SLOT(close())); quit_action->setShortcuts(QKeySequence::Quit); @@ -770,7 +771,7 @@ jalv_open_ui(Jalv* jalv) widget->height() + win->menuBar()->height()); } - Timer* timer = new Timer(jalv); + auto* const timer = new Timer(jalv); timer->start(1000 / jalv->ui_update_hz); int ret = app->exec(); -- cgit v1.2.1