From 9ddd2fdcc5c06253e0eb20db944a5c5c81eb19ae Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sun, 19 Sep 2021 23:43:05 +0200 Subject: [PATCH] WidgetGallery: Simplify cursor change code The code here wasn't updated when a new file icons appeared, so double- -clicking a cursor didn't always set it to the correct one. Also, the cursor list is sorted alphabetically, by the file name. So if a theme used a different file naming in Config.ini, then the previous code would also be incorrect. Here we will just take the bitmap icon from the model. Closes: #10142 --- .../Demos/WidgetGallery/GalleryWidget.cpp | 54 +------------------ 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index 256afba173..872eabee50 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -304,58 +304,8 @@ GalleryWidget::GalleryWidget() m_cursors_tableview->set_column_width(0, 25); m_cursors_tableview->on_activation = [&](const GUI::ModelIndex& index) { - switch (index.row()) { - case 0: - window()->set_cursor(Gfx::StandardCursor::Arrow); - break; - case 1: - window()->set_cursor(Gfx::StandardCursor::Crosshair); - break; - case 2: - window()->set_cursor(Gfx::StandardCursor::Disallowed); - break; - case 3: - window()->set_cursor(Gfx::StandardCursor::Drag); - break; - case 4: - window()->set_cursor(Gfx::StandardCursor::Hand); - break; - case 5: - window()->set_cursor(Gfx::StandardCursor::Help); - break; - case 6: - window()->set_cursor(Gfx::StandardCursor::Hidden); - break; - case 7: - window()->set_cursor(Gfx::StandardCursor::IBeam); - break; - case 8: - window()->set_cursor(Gfx::StandardCursor::Move); - break; - case 9: - window()->set_cursor(Gfx::StandardCursor::ResizeColumn); - break; - case 10: - window()->set_cursor(Gfx::StandardCursor::ResizeDiagonalBLTR); - break; - case 11: - window()->set_cursor(Gfx::StandardCursor::ResizeDiagonalTLBR); - break; - case 12: - window()->set_cursor(Gfx::StandardCursor::ResizeHorizontal); - break; - case 13: - window()->set_cursor(Gfx::StandardCursor::ResizeRow); - break; - case 14: - window()->set_cursor(Gfx::StandardCursor::ResizeVertical); - break; - case 15: - window()->set_cursor(Gfx::StandardCursor::Wait); - break; - default: - window()->set_cursor(Gfx::StandardCursor::Arrow); - } + auto icon_index = index.model()->index(index.row(), MouseCursorModel::Column::Bitmap); + window()->set_cursor(icon_index.data().as_bitmap()); }; auto& icons_tab = tab_widget.add_tab("Icons");