diff options
author | Karol Kosek <krkk@serenityos.org> | 2021-09-19 23:43:05 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-20 15:59:34 +0200 |
commit | 9ddd2fdcc5c06253e0eb20db944a5c5c81eb19ae (patch) | |
tree | e0665919abb5f9292f4b8d19ea83f384e2a88915 /Userland/Demos | |
parent | 38bc81015bf2363a1424315b83a80e63a8ba93ea (diff) | |
download | serenity-9ddd2fdcc5c06253e0eb20db944a5c5c81eb19ae.zip |
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
Diffstat (limited to 'Userland/Demos')
-rw-r--r-- | Userland/Demos/WidgetGallery/GalleryWidget.cpp | 54 |
1 files 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<GUI::Widget>("Icons"); |