1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

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
This commit is contained in:
Karol Kosek 2021-09-19 23:43:05 +02:00 committed by Andreas Kling
parent 38bc81015b
commit 9ddd2fdcc5

View file

@ -304,58 +304,8 @@ GalleryWidget::GalleryWidget()
m_cursors_tableview->set_column_width(0, 25); m_cursors_tableview->set_column_width(0, 25);
m_cursors_tableview->on_activation = [&](const GUI::ModelIndex& index) { m_cursors_tableview->on_activation = [&](const GUI::ModelIndex& index) {
switch (index.row()) { auto icon_index = index.model()->index(index.row(), MouseCursorModel::Column::Bitmap);
case 0: window()->set_cursor(icon_index.data().as_bitmap());
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& icons_tab = tab_widget.add_tab<GUI::Widget>("Icons"); auto& icons_tab = tab_widget.add_tab<GUI::Widget>("Icons");