mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-09 12:37:41 +03:00
chore :refactored remaining views
This commit is contained in:
28
src/gui/widgets/link_button.cpp
Normal file
28
src/gui/widgets/link_button.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "link_button.hpp"
|
||||
#include "imgui.h"
|
||||
#include <cstdlib>
|
||||
|
||||
namespace clrsync::gui::widgets
|
||||
{
|
||||
|
||||
void open_url(const std::string& url)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string cmd = "start " + url;
|
||||
#elif __APPLE__
|
||||
std::string cmd = "open " + url;
|
||||
#else
|
||||
std::string cmd = "xdg-open " + url;
|
||||
#endif
|
||||
std::system(cmd.c_str());
|
||||
}
|
||||
|
||||
bool link_button(const std::string& label, const std::string& url, float width)
|
||||
{
|
||||
bool clicked = ImGui::Button(label.c_str(), ImVec2(width, 0));
|
||||
if (clicked)
|
||||
open_url(url);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
} // namespace clrsync::gui::widgets
|
||||
Reference in New Issue
Block a user