refacor media widget, apply clang format rule

This commit is contained in:
2026-02-07 14:14:50 +01:00
parent 64b3babd3d
commit d9ac353a0d
54 changed files with 642 additions and 878 deletions

View File

@@ -1,17 +1,17 @@
#pragma once
#include <array>
#include <cstdio>
#include <memory>
#include <stdexcept>
#include <string>
#include <cstdio>
class CommandHelper {
public:
static std::string exec(const char *cmd) {
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, int(*)(FILE*)> pipe(popen(cmd, "r"), pclose);
std::unique_ptr<FILE, int (*)(FILE *)> pipe(popen(cmd, "r"), pclose);
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
@@ -23,7 +23,7 @@ class CommandHelper {
static void execNoOutput(std::string cmd) {
std::string command = cmd + " > /dev/null 2>&1";
int ret = std::system(command.c_str());
int ret = std::system(command.c_str());
if (ret != 0) {
throw std::runtime_error("Command failed with return code: " + std::to_string(ret));
}

View File

@@ -52,14 +52,14 @@ class HyprSocketHelper {
public:
static std::string getHyprlandSocketPath() {
const char *hyprlandInstanceSignature = std::getenv("HYPRLAND_INSTANCE_SIGNATURE");
const char *xdgRuntimeDir = std::getenv("XDG_RUNTIME_DIR");
const char *xdgRuntimeDir = std::getenv("XDG_RUNTIME_DIR");
if (!xdgRuntimeDir || !hyprlandInstanceSignature) {
return std::string();
}
std::string basePath = std::string(xdgRuntimeDir) + "/hypr/" + std::string(hyprlandInstanceSignature) + "/";
std::string sock1 = basePath + ".socket2.sock";
std::string sock1 = basePath + ".socket2.sock";
if (access(sock1.c_str(), F_OK) == 0) {
return sock1;
}

View File

@@ -3,9 +3,8 @@
#include <string>
#include <vector>
class StringHelper {
public:
public:
static std::vector<std::string> split(const std::string &input, char delimiter) {
std::vector<std::string> tokens;
std::string token;
@@ -25,14 +24,14 @@ public:
return tokens;
}
static std::vector<std::string> split(const std::string &input, std::string delimiter) {
static std::vector<std::string> split(const std::string &input, std::string delimiter) {
std::vector<std::string> tokens;
size_t start = 0;
size_t end = input.find(delimiter);
size_t end = input.find(delimiter);
while (end != std::string::npos) {
tokens.push_back(input.substr(start, end - start));
start = end + delimiter.length();
end = input.find(delimiter, start);
end = input.find(delimiter, start);
}
tokens.push_back(input.substr(start));
return tokens;

View File

@@ -10,7 +10,7 @@ class SystemHelper {
throw std::runtime_error("Could not open file: " + filePath);
}
std::string content((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
std::istreambuf_iterator<char>());
file.close();
return content;
}