Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- name: sailfish-silica
- description: Sailfish OS Silica QML component guidance. Use when developing Sailfish OS applications using QML and Silica components.
- ---
- # Sailfish Silica Skill
- ## Overview
- This skill provides guidance for building Sailfish OS applications using the Silica QML component library. Silica is the official UI framework for Sailfish OS, providing a consistent look and feel across the platform.
- ## Essential Components
- ### Application Structure
- Every Sailfish app starts with `ApplicationWindow` and uses `PageStack` for navigation:
- ```qml
- import Sailfish.Silica 1.0
- ApplicationWindow {
- id: app
- cover: coverPage
- allowedOrientations: Orientation.All
- PageStack {
- id: pageStack
- initialPage: Page {
- // Your first page
- }
- }
- }
- ```
- ### Key Core Types
- - `ApplicationWindow` - Top-level container for the app
- - `PageStack` - Manages pages and navigation
- - `Page` - Single screen of content
- - `Theme` - Access Sailfish styling properties
- - `Screen` - Device display attributes
- - `Clipboard` - Clipboard functionality
- - `StandardPaths` - System standard directories
- ## Pages and Dialogs
- ### Page Types
- - `Page` - Main application page
- - `Dialog` - Confirmation/cancellation dialog
- - `ColorPickerPage` - Color selection
- - `DatePickerDialog` - Date picker
- - `TimePickerDialog` - Time picker
- - `PageHeader` - Header for pages
- - `DialogHeader` - Header for dialogs
- ### Dialog Example
- ```qml
- Dialog {
- id: dialog
- title: "Confirm Action"
- Button {
- text: "OK"
- onClicked: dialog.accept()
- }
- Button {
- text: "Cancel"
- onClicked: dialog.reject()
- }
- }
- ```
- ## Views and Containers
- ### Use Silica Components
- Always prefer Silica versions over QtQuick equivalents:
- - `SilicaFlickable` instead of `Flickable`
- - `SilicaListView` instead of `ListView`
- - `SilicaGridView` instead of `GridView`
- - `ScrollDecorator` for scroll indicators
- ### View Types
- - `SilicaListView` - Vertical list
- - `SilicaGridView` - Grid layout
- - `ColumnView` - Column of items
- - `SlideshowView` - Flickable item view
- - `DockedPanel` - Side panel
- - `Drawer` - Sliding panel
- - `ViewPlaceholder` - Empty state display
- ### List Item Example
- ```qml
- SilicaListView {
- model: myModel
- delegate: ListItem {
- id: delegate
- Label {
- text: model.text
- }
- // Optional: click action
- onClicked: pageStack.push(Qt.resolvedUrl("DetailPage.qml"))
- }
- }
- ```
- ## Controls
- ### Buttons and Toggles
- - `Button` - Push button with text
- - `IconButton` - Button with icon
- - `ValueButton` - Clickable label + value
- - `Switch` - Toggle with icon
- - `TextSwitch` - Toggle with label
- - `CheckBox` - Checkbox control
- - `ComboBox` - Selection dropdown
- - `Slider` - Horizontal slider
- - `PasswordField` - Password input
- - `SearchField` - Search query input
- ### Progress Indicators
- - `BusyIndicator` - Loading spinner
- - `BusyLabel` - Loading with text
- - `PageBusyIndicator` - Page loading
- - `ProgressBar` - Progress bar
- ### Color Picker
- - `ColorPicker` - Grid of colors
- - `ColorPickerPage` - Full color picker page
- - `ColorPickerDialog` - Color selection dialog
- ## Text Components
- - `TextField` - Single-line editable text
- - `TextArea` - Multi-line editable text
- - `Label` - Static text display
- - `SectionHeader` - Section heading
- - `LinkedLabel` - Text with auto-highlighted links
- - `Icon` - Monochrome icon display
- - `Palette` - Color palette
- ## Menus
- - `PullDownMenu` - Pull-down menu
- - `PushUpMenu` - Push-up menu
- - `ContextMenu` - Context menu
- - `MenuItem` - Menu item
- - `MenuLabel` - Static label in menu
- ## Common Patterns
- ### Navigation
- ```qml
- // Navigate to new page
- pageStack.push(Qt.resolvedUrl("NewPage.qml"))
- // Replace current page
- pageStack.replace(Qt.resolvedUrl("DetailPage.qml"))
- // Pop back
- pageStack.pop()
- ```
- ### Pull-down Menu
- ```qml
- SilicaFlickable {
- PullDownMenu {
- MenuItem {
- text: "Refresh"
- onClicked: refresh()
- }
- }
- // Content
- }
- ```
- ### Search Field
- ```qml
- SilicaListView {
- SearchField {
- id: searchField
- placeholderText: "Search..."
- width: parent.width
- onAccepted: {
- // Handle search
- }
- }
- // List content
- }
- ```
- ## Best Practices
- 1. **Always use Silica components** - They provide Sailfish-specific styling and behaviors
- 2. **Use PageStack** for all navigation, not direct property manipulation
- 3. **Set allowedOrientations** on ApplicationWindow for multi-orientation apps
- 4. **Include cover page** for better app discoverability
- 5. **Use Theme properties** for consistent styling
- 6. **Handle back navigation** properly with PageStack
- 7. **Add SearchField** for list-based content
- 8. **Use PullDownMenu** for actions
- 9. **Implement proper loading states** with BusyIndicator
- 10. **Follow Sailfish design guidelines** for touch interactions
- ## Project Structure
- Standard Sailfish project structure:
- ```
- my-app/
- ├── qml/
- │ ├── my-app.qml # Main window
- │ ├── pages/ # Page components
- │ ├── cover/ # Cover page
- │ ├── src/ # Shared components
Advertisement
Add Comment
Please, Sign In to add comment