Merge pull request #3260 from zjeffer/clang-tidy

clang-tidy fixes in the privacy module
This commit is contained in:
Alexis Rouillard 2024-05-28 09:07:57 +02:00 committed by GitHub
commit af7945197e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 33 deletions

View File

@ -15,15 +15,15 @@ Checks: >
-readability-redundant-member-init,
-readability-redundant-string-init,
-readability-identifier-length
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
- { key: readability-identifier-naming.PrivateMemberCase, value: camelBack }
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
- { key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.StaticConstantCase, value: UPPER_CASE }
# CheckOptions:
# - { key: readability-identifier-naming.NamespaceCase, value: lower_case }
# - { key: readability-identifier-naming.ClassCase, value: CamelCase }
# - { key: readability-identifier-naming.StructCase, value: CamelCase }
# - { key: readability-identifier-naming.FunctionCase, value: camelBack }
# - { key: readability-identifier-naming.VariableCase, value: camelBack }
# - { key: readability-identifier-naming.PrivateMemberCase, value: camelBack }
# - { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
# - { key: readability-identifier-naming.EnumCase, value: CamelCase }
# - { key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE }
# - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
# - { key: readability-identifier-naming.StaticConstantCase, value: UPPER_CASE }

View File

@ -1,10 +1,7 @@
#pragma once
#include <iostream>
#include <map>
#include <string>
#include "ALabel.hpp"
#include "gtkmm/box.h"
#include "modules/privacy/privacy_item.hpp"
#include "util/pipewire/pipewire_backend.hpp"

View File

@ -2,9 +2,6 @@
#include <json/value.h>
#include <iostream>
#include <map>
#include <mutex>
#include <string>
#include "gtkmm/box.h"

View File

@ -6,7 +6,6 @@
#include <string>
#include "AModule.hpp"
#include "gtkmm/image.h"
#include "modules/privacy/privacy_item.hpp"
namespace waybar::modules::privacy {
@ -46,30 +45,29 @@ Privacy::Privacy(const std::string& id, const Json::Value& config, const std::st
// Initialize each privacy module
Json::Value modules = config_["modules"];
// Add Screenshare and Mic usage as default modules if none are specified
if (!modules.isArray() || modules.size() == 0) {
if (!modules.isArray() || modules.empty()) {
modules = Json::Value(Json::arrayValue);
for (auto& type : {"screenshare", "audio-in"}) {
for (const auto& type : {"screenshare", "audio-in"}) {
Json::Value obj = Json::Value(Json::objectValue);
obj["type"] = type;
modules.append(obj);
}
}
for (uint i = 0; i < modules.size(); i++) {
const Json::Value& module_config = modules[i];
for (const auto& module_config : modules) {
if (!module_config.isObject() || !module_config["type"].isString()) continue;
const std::string type = module_config["type"].asString();
if (type == "screenshare") {
auto item =
auto* item =
Gtk::make_managed<PrivacyItem>(module_config, PRIVACY_NODE_TYPE_VIDEO_INPUT,
&nodes_screenshare, pos, iconSize, transition_duration);
box_.add(*item);
} else if (type == "audio-in") {
auto item =
auto* item =
Gtk::make_managed<PrivacyItem>(module_config, PRIVACY_NODE_TYPE_AUDIO_INPUT,
&nodes_audio_in, pos, iconSize, transition_duration);
box_.add(*item);
} else if (type == "audio-out") {
auto item =
auto* item =
Gtk::make_managed<PrivacyItem>(module_config, PRIVACY_NODE_TYPE_AUDIO_OUTPUT,
&nodes_audio_out, pos, iconSize, transition_duration);
box_.add(*item);
@ -117,11 +115,13 @@ void Privacy::onPrivacyNodesChanged() {
auto Privacy::update() -> void {
mutex_.lock();
bool screenshare, audio_in, audio_out;
bool screenshare = false;
bool audio_in = false;
bool audio_out = false;
for (Gtk::Widget* widget : box_.get_children()) {
PrivacyItem* module = dynamic_cast<PrivacyItem*>(widget);
if (!module) continue;
auto* module = dynamic_cast<PrivacyItem*>(widget);
if (module == nullptr) continue;
switch (module->privacy_type) {
case util::PipewireBackend::PRIVACY_NODE_TYPE_VIDEO_INPUT:
screenshare = !nodes_screenshare.empty();

View File

@ -1,14 +1,11 @@
#include "modules/privacy/privacy_item.hpp"
#include <string>
#include <thread>
#include "AModule.hpp"
#include "glibmm/main.h"
#include "gtkmm/label.h"
#include "gtkmm/revealer.h"
#include "gtkmm/tooltip.h"
#include "sigc++/adaptors/bind.h"
#include "util/pipewire/privacy_node_info.hpp"
namespace waybar::modules::privacy {
@ -89,7 +86,7 @@ PrivacyItem::PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privac
void PrivacyItem::update_tooltip() {
// Removes all old nodes
for (auto child : tooltip_window.get_children()) {
for (auto *child : tooltip_window.get_children()) {
delete child;
}