Guest User

Untitled

a guest
Jun 8th, 2026
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 5.30 KB | None | 0 0
  1. ---
  2. name: sailfish-silica
  3. description: Sailfish OS Silica QML component guidance. Use when developing Sailfish OS applications using QML and Silica components.
  4. ---
  5.  
  6. # Sailfish Silica Skill
  7.  
  8. ## Overview
  9.  
  10. 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.
  11.  
  12. ## Essential Components
  13.  
  14. ### Application Structure
  15. Every Sailfish app starts with `ApplicationWindow` and uses `PageStack` for navigation:
  16.  
  17. ```qml
  18. import Sailfish.Silica 1.0
  19.  
  20. ApplicationWindow {
  21.     id: app
  22.     cover: coverPage
  23.     allowedOrientations: Orientation.All
  24.  
  25.     PageStack {
  26.         id: pageStack
  27.         initialPage: Page {
  28.             // Your first page
  29.         }
  30.     }
  31. }
  32. ```
  33.  
  34. ### Key Core Types
  35. - `ApplicationWindow` - Top-level container for the app
  36. - `PageStack` - Manages pages and navigation
  37. - `Page` - Single screen of content
  38. - `Theme` - Access Sailfish styling properties
  39. - `Screen` - Device display attributes
  40. - `Clipboard` - Clipboard functionality
  41. - `StandardPaths` - System standard directories
  42.  
  43. ## Pages and Dialogs
  44.  
  45. ### Page Types
  46. - `Page` - Main application page
  47. - `Dialog` - Confirmation/cancellation dialog
  48. - `ColorPickerPage` - Color selection
  49. - `DatePickerDialog` - Date picker
  50. - `TimePickerDialog` - Time picker
  51. - `PageHeader` - Header for pages
  52. - `DialogHeader` - Header for dialogs
  53.  
  54. ### Dialog Example
  55. ```qml
  56. Dialog {
  57.     id: dialog
  58.     title: "Confirm Action"
  59.  
  60.     Button {
  61.         text: "OK"
  62.         onClicked: dialog.accept()
  63.     }
  64.  
  65.     Button {
  66.         text: "Cancel"
  67.         onClicked: dialog.reject()
  68.     }
  69. }
  70. ```
  71.  
  72. ## Views and Containers
  73.  
  74. ### Use Silica Components
  75. Always prefer Silica versions over QtQuick equivalents:
  76. - `SilicaFlickable` instead of `Flickable`
  77. - `SilicaListView` instead of `ListView`
  78. - `SilicaGridView` instead of `GridView`
  79. - `ScrollDecorator` for scroll indicators
  80.  
  81. ### View Types
  82. - `SilicaListView` - Vertical list
  83. - `SilicaGridView` - Grid layout
  84. - `ColumnView` - Column of items
  85. - `SlideshowView` - Flickable item view
  86. - `DockedPanel` - Side panel
  87. - `Drawer` - Sliding panel
  88. - `ViewPlaceholder` - Empty state display
  89.  
  90. ### List Item Example
  91. ```qml
  92. SilicaListView {
  93.     model: myModel
  94.  
  95.     delegate: ListItem {
  96.         id: delegate
  97.  
  98.         Label {
  99.             text: model.text
  100.         }
  101.  
  102.         // Optional: click action
  103.         onClicked: pageStack.push(Qt.resolvedUrl("DetailPage.qml"))
  104.     }
  105. }
  106. ```
  107.  
  108. ## Controls
  109.  
  110. ### Buttons and Toggles
  111. - `Button` - Push button with text
  112. - `IconButton` - Button with icon
  113. - `ValueButton` - Clickable label + value
  114. - `Switch` - Toggle with icon
  115. - `TextSwitch` - Toggle with label
  116. - `CheckBox` - Checkbox control
  117. - `ComboBox` - Selection dropdown
  118. - `Slider` - Horizontal slider
  119. - `PasswordField` - Password input
  120. - `SearchField` - Search query input
  121.  
  122. ### Progress Indicators
  123. - `BusyIndicator` - Loading spinner
  124. - `BusyLabel` - Loading with text
  125. - `PageBusyIndicator` - Page loading
  126. - `ProgressBar` - Progress bar
  127.  
  128. ### Color Picker
  129. - `ColorPicker` - Grid of colors
  130. - `ColorPickerPage` - Full color picker page
  131. - `ColorPickerDialog` - Color selection dialog
  132.  
  133. ## Text Components
  134.  
  135. - `TextField` - Single-line editable text
  136. - `TextArea` - Multi-line editable text
  137. - `Label` - Static text display
  138. - `SectionHeader` - Section heading
  139. - `LinkedLabel` - Text with auto-highlighted links
  140. - `Icon` - Monochrome icon display
  141. - `Palette` - Color palette
  142.  
  143. ## Menus
  144.  
  145. - `PullDownMenu` - Pull-down menu
  146. - `PushUpMenu` - Push-up menu
  147. - `ContextMenu` - Context menu
  148. - `MenuItem` - Menu item
  149. - `MenuLabel` - Static label in menu
  150.  
  151. ## Common Patterns
  152.  
  153. ### Navigation
  154. ```qml
  155. // Navigate to new page
  156. pageStack.push(Qt.resolvedUrl("NewPage.qml"))
  157.  
  158. // Replace current page
  159. pageStack.replace(Qt.resolvedUrl("DetailPage.qml"))
  160.  
  161. // Pop back
  162. pageStack.pop()
  163. ```
  164.  
  165. ### Pull-down Menu
  166. ```qml
  167. SilicaFlickable {
  168.     PullDownMenu {
  169.         MenuItem {
  170.             text: "Refresh"
  171.             onClicked: refresh()
  172.         }
  173.     }
  174.  
  175.     // Content
  176. }
  177. ```
  178.  
  179. ### Search Field
  180. ```qml
  181. SilicaListView {
  182.     SearchField {
  183.         id: searchField
  184.         placeholderText: "Search..."
  185.         width: parent.width
  186.  
  187.         onAccepted: {
  188.             // Handle search
  189.         }
  190.     }
  191.  
  192.     // List content
  193. }
  194. ```
  195.  
  196. ## Best Practices
  197.  
  198. 1. **Always use Silica components** - They provide Sailfish-specific styling and behaviors
  199. 2. **Use PageStack** for all navigation, not direct property manipulation
  200. 3. **Set allowedOrientations** on ApplicationWindow for multi-orientation apps
  201. 4. **Include cover page** for better app discoverability
  202. 5. **Use Theme properties** for consistent styling
  203. 6. **Handle back navigation** properly with PageStack
  204. 7. **Add SearchField** for list-based content
  205. 8. **Use PullDownMenu** for actions
  206. 9. **Implement proper loading states** with BusyIndicator
  207. 10. **Follow Sailfish design guidelines** for touch interactions
  208.  
  209. ## Project Structure
  210.  
  211. Standard Sailfish project structure:
  212. ```
  213. my-app/
  214. ├── qml/
  215. │   ├── my-app.qml          # Main window
  216. │   ├── pages/              # Page components
  217. │   ├── cover/              # Cover page
  218. │   ├── src/                # Shared components
Advertisement
Add Comment
Please, Sign In to add comment