slint/examples/gallery/gallery.slint
Joshua Goins c09ed19a85 Menu: Add icon property
This adds an icon that is displayed to the left of the title, and is
also shown for Menus are inside of a parent menu.

Closes #7791

ChangeLog: Added icon property to MenuItem and Menu
2025-06-26 18:45:37 +02:00

54 lines
2.1 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
import { CheckBox, StandardListView } from "std-widgets.slint";
import { AboutPage, ControlsPage, EasingsPage, ListViewPage, TableViewPage, TableViewPageAdapter, TextEditPage } from "ui/pages/pages.slint";
import { GallerySettings } from "ui/gallery_settings.slint";
import { SideBar } from "ui/side_bar.slint";
export { TableViewPageAdapter }
export component App inherits Window {
preferred-width: 700px;
preferred-height: 500px;
title: @tr("Slint Widgets Gallery");
icon: @image-url("../../logo/slint-logo-small-light.png");
MenuBar {
Menu {
title: @tr("MenuBar" => "File");
MenuItem { title: @tr("MenuBar" => "Open"); }
Menu {
title: @tr("MenuBar" => "Open Recent");
for x in 10: MenuItem { title: @tr("MenuBar" => "Recent {}", x+1); }
}
MenuSeparator {}
MenuItem { title: @tr("MenuBar" => "Save"); }
Menu {
title: @tr("MenuBar" => "Save As");
for x in 10: MenuItem { title: @tr("MenuBar" => "Name {}", x+1); }
}
MenuSeparator {}
MenuItem { title: @tr("MenuBar" => "MenuItem with Icon"); icon: @image-url("thumbsup.png"); }
}
Menu {
title: @tr("MenuBar" => "Edit");
MenuItem { title: @tr("MenuBar" => "Copy"); }
MenuItem { title: @tr("MenuBar" => "Paste"); }
}
}
HorizontalLayout {
side-bar := SideBar {
title: @tr("Slint Widgets Gallery");
model: [@tr("Menu" => "Controls"), @tr("Menu" => "ListView"), @tr("Menu" => "TableView"), @tr("Menu" => "TextEdit"), @tr("Menu" => "Easings"), @tr("Menu" => "About")];
}
if(side-bar.current-item == 0) : ControlsPage {}
if(side-bar.current-item == 1) : ListViewPage {}
if(side-bar.current-item == 2) : TableViewPage {}
if(side-bar.current-item == 3) : TextEditPage {}
if(side-bar.current-item == 4) : EasingsPage {}
if(side-bar.current-item == 5) : AboutPage {}
}
}