From d1846867cd1c8c477afc723b3a6e6705e0915aa3 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Mon, 20 Sep 2021 00:13:29 +0200 Subject: [PATCH] WidgetGallery+MouseSettings: Use LexicalPath::basename() --- Userland/Applications/MouseSettings/ThemeWidget.cpp | 3 +-- Userland/Demos/WidgetGallery/GalleryModels.h | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Userland/Applications/MouseSettings/ThemeWidget.cpp b/Userland/Applications/MouseSettings/ThemeWidget.cpp index aa6619bf64..a36bcefd6c 100644 --- a/Userland/Applications/MouseSettings/ThemeWidget.cpp +++ b/Userland/Applications/MouseSettings/ThemeWidget.cpp @@ -60,8 +60,7 @@ void MouseCursorModel::invalidate() Cursor cursor; cursor.path = move(path); - auto filename_split = cursor.path.split('/'); - cursor.name = filename_split[3]; + cursor.name = LexicalPath::basename(cursor.path); // FIXME: Animated cursor bitmaps auto cursor_bitmap = Gfx::Bitmap::try_load_from_file(cursor.path); diff --git a/Userland/Demos/WidgetGallery/GalleryModels.h b/Userland/Demos/WidgetGallery/GalleryModels.h index 4e6008f2c3..b810093d86 100644 --- a/Userland/Demos/WidgetGallery/GalleryModels.h +++ b/Userland/Demos/WidgetGallery/GalleryModels.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include #include @@ -69,8 +70,7 @@ public: Cursor cursor; cursor.path = move(path); cursor.bitmap = Gfx::Bitmap::try_load_from_file(cursor.path); - auto filename_split = cursor.path.split('/'); - cursor.name = filename_split[3]; + cursor.name = LexicalPath::basename(cursor.path); m_cursors.append(move(cursor)); } @@ -150,8 +150,7 @@ public: continue; IconSet icon_set; icon_set.big_icon = Gfx::Bitmap::try_load_from_file(path); - auto filename_split = path.split('/'); - icon_set.name = filename_split[3]; + icon_set.name = LexicalPath::basename(path); m_icon_sets.append(move(icon_set)); } @@ -165,8 +164,7 @@ public: continue; IconSet icon_set; icon_set.little_icon = Gfx::Bitmap::try_load_from_file(path); - auto filename_split = path.split('/'); - icon_set.name = filename_split[3]; + icon_set.name = LexicalPath::basename(path); for (size_t i = 0; i < big_icons_found; i++) { if (icon_set.name == m_icon_sets[i].name) { m_icon_sets[i].little_icon = icon_set.little_icon;