Ceci est une ancienne révision du document !
Configuration avancée d'Unity 2D
Bon niveau en informatique nécessaire.
Les modifications expliquées ci-dessous nécessiteront de modifier des codes d'Unity 2D. Des fichiers mal modifiés pourront rendre des parties d'Unity 2D inutilisables. Il est conseillé d'effectuer ces changements à tête reposée pour ne pas enregistrer trop vite, et d'effectuer des sauvegardes des fichiers pour revenir en arrière sans perdre toutes les modifications.
Les changements réalisés affecteront tous les utilisateurs du système et pas seulement vous. S'il y a plus d'un utilisateur sur votre PC, demandez leur avis avant d'appliquer les changements ;)
Supprimer le Home Dash
Afficher une lens par défaut au lieu de l'écran d'accueil du Dash
Ouvrez le fichier /usr/share/unity-2d/places/dash.qml (/usr/share/unity-2d/shell/dash/Dash.qml pour Unity 2D >= 5.4).
Cherchez la fonction function activateHome() { (ligne 110 sur ma version d'Unity 2D).
Retirez le contenu de cette fonction en faisant attention aux parenthèses (il faut bien supprimer jusqu'au bout de la fonction de façon à n'avoir plus que :
function activateHome() { }
Cette fonction correspond à l'action à effectuer lorsque l'on clique sur le bouton Ubuntu.
Maintenant, ajoutez entre les accolades activateLens(lensId) avec à la place de lensID le nom ou le numéro de la lens que vous voulez avoir à l'ouverture.
Voici les noms des lenses par défaut : applications.lens , commands.lens , files.lens , music.lens
Après modification, votre fonction devrait ressembler à ça :
function activateHome() { activateLens("applications.lens") }
Au prochain démarrage d'Unity 2D, le bouton Ubuntu devrait maintenant affiche la lens que vous avez choisie.
Retirer l'icône du Home Dash de la liste des lenses
Unity 2D <= 5.4
Ouvrez le fichier /usr/share/unity-2d/places/LensBar.qml.
Chercher un code similaire à celui-ci (ligne 96 dans ma version d'Unity 2D) :
/* Need to manually include the Home lens */ LensButton { id: homeLens Accessible.name: u2d.tr("home") focus: true icon: "artwork/lens-nav-home.svg" onClicked: dash.activateHome() active: ( dashView.activeLens == "" ) iconWidth: lensBar.iconWidth iconSpacing: lensBar.iconSpacing width: iconWidth+iconSpacing height: lensContainer.height }
Et remplacez-le par :
/* Need to manually include the Home lens */ LensButton { id: homeLens Accessible.name: u2d.tr("home") focus: false icon: "" onClicked: dash.activateHome() active:false iconWidth: 0 iconSpacing: 0 width: 0 height: 0 }
La lens Home ne devrait plus s'afficher la prochaine fois que vous ouvrirez votre session.
Unity 2D >= 5.4
Ouvrez le fichier /usr/share/unity-2d/shell/dash/LensBar.qml.
Chercher un code similaire à celui-ci (ligne 97 dans ma version d'Unity 2D) :
Repeater{ id: repeater model: visibleLenses delegate: LensButton { Accessible.name: u2d.tr(item.name) /* Heuristic: if iconHint does not contain a '/' then it is an icon name */ icon: { if (item.id == "home.lens") { return "artwork/lens-nav-home.svg" } item.iconHint.indexOf("/") == -1 ? "image://icons/" + item.iconHint : item.iconHint } active: { /* we need this in order to activate the arrow when using a custom shortcuts file */ if (item.id == "home.lens" && declarativeView.activeLens == "") { return true } return item.viewType == Lens.LensView } onClicked: { if (item.id == "home.lens") { dash.activateHome() } else { dash.activateLens(item.id) } } iconWidth: lensBar.iconWidth iconSpacing: lensBar.iconSpacing width: iconWidth+iconSpacing height: lensContainer.height } }
Et remplacez le par :
Repeater{ id: repeater model: visibleLenses delegate: LensButton { Accessible.name: u2d.tr(item.name) /* Heuristic: if iconHint does not contain a '/' then it is an icon name */ icon: { if (item.id == "home.lens") { return "" } item.iconHint.indexOf("/") == -1 ? "image://icons/" + item.iconHint : item.iconHint } active: { /* we need this in order to activate the arrow when using a custom shortcuts file */ if (item.id == "home.lens" && declarativeView.activeLens == "") { return true } return item.viewType == Lens.LensView } onClicked: { dash.activateLens(item.id) } iconWidth: lensBar.iconWidth iconSpacing: lensBar.iconSpacing width: iconWidth+iconSpacing height: lensContainer.height } }
Avoir les lenses en haut à droite du Dash
Attention, ceci a été testé pour Unity 2D 5.2, il peut donc y avoir des différences avec les anciennes versions d'Unity 2D.
Déplacer les lenses
Ouvrez le fichier /usr/share/unity-2d/places/dash.qml
Cherchez ce code :
Item { id: content anchors.fill: parent /* Margins in DesktopMode set so that the content does not overlap with the border defined by the background image. */ anchors.bottomMargin: background.bottomBorderThickness anchors.rightMargin: background.rightBorderThickness /* Unhandled keys will always be forwarded to the search bar. That way the user can type and search from anywhere in the interface without necessarily focusing the search bar first. */ /* FIXME: deactivated because it makes the user lose the focus very often */ //Keys.forwardTo: [search_entry] SearchEntry { id: search_entry focus: true /* FIXME: check on visible necessary; fixed in Qt Quick 1.1 ref: http://bugreports.qt.nokia.com/browse/QTBUG-15862 */ KeyNavigation.right: filterPane.visible ? filterPane : search_entry KeyNavigation.down: pageLoader anchors.top: parent.top anchors.topMargin: 11 anchors.left: parent.left anchors.leftMargin: 10 anchors.right: filterPane.left anchors.rightMargin: 15 height: 42 active: dash.active placeHolderText: { if(dash.currentPage != undefined && dash.currentPage.model.searchHint) return dash.currentPage.model.searchHint else return u2d.tr("Search") } onSearchQueryChanged: if (dash.currentPage != undefined) dash.currentPage.model.searchQuery = searchQuery onActivateFirstResult: if (dash.currentPage != undefined) dash.currentPage.activateFirstResult() } FilterPane { id: filterPane KeyNavigation.left: search_entry /* FilterPane is only to be displayed for lenses, not in the home page or Alt+F2 Run page */ visible: declarativeView.activeLens != "home.lens" && declarativeView.activeLens != "" && declarativeView.activeLens != "commands.lens" lens: visible && currentPage != undefined ? currentPage.model : undefined anchors.top: search_entry.anchors.top anchors.topMargin: search_entry.anchors.topMargin anchors.bottom: lensBar.top headerHeight: search_entry.height width: 300 anchors.right: parent.right anchors.rightMargin: 15 } Loader { id: pageLoader objectName: "pageLoader" Accessible.name: "loader" /* FIXME: check on visible necessary; fixed in Qt Quick 1.1 ref: http://bugreports.qt.nokia.com/browse/QTBUG-15862 */ KeyNavigation.right: filterPane.visible && !filterPane.folded ? filterPane : pageLoader KeyNavigation.up: search_entry KeyNavigation.down: lensBar anchors.top: search_entry.bottom anchors.topMargin: 9 anchors.bottom: lensBar.top anchors.left: parent.left anchors.right: !filterPane.visible || filterPane.folded ? parent.right : filterPane.left anchors.rightMargin: !filterPane.visible || filterPane.folded ? 0 : 15 onLoaded: item.focus = true /* Workaround loss of focus issue happening when the loaded item has active focus and is then destroyed. The active focus was completely lost instead of being relinquished to the Loader. Ref.: https://bugreports.qt.nokia.com/browse/QTBUG-22939 */ function setSource(newSource) { var hadActiveFocus = activeFocus source = newSource if (hadActiveFocus) forceActiveFocus() } } LensBar { id: lensBar KeyNavigation.up: pageLoader anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right height: 44 visible: declarativeView.expanded } }
Et remplacez le par :
Item { id: content anchors.fill: parent /* Margins in DesktopMode set so that the content does not overlap with the border defined by the background image. */ anchors.bottomMargin: dashView.dashMode == DashDeclarativeView.DesktopMode ? 39 : 0 anchors.rightMargin: dashView.dashMode == DashDeclarativeView.DesktopMode ? 37 : 0 visible: dashView.active /* Unhandled keys will always be forwarded to the search bar. That way the user can type and search from anywhere in the interface without necessarily focusing the search bar first. */ /* FIXME: deactivated because it makes the user lose the focus very often */ //Keys.forwardTo: [search_entry] SearchEntry { id: search_entry focus: true /* FIXME: check on visible necessary; fixed in Qt Quick 1.1 ref: http://bugreports.qt.nokia.com/browse/QTBUG-15862 */ KeyNavigation.right: filterPane.visible ? filterPane : search_entry KeyNavigation.down: pageLoader anchors.top: parent.top anchors.topMargin: 11 anchors.left: parent.left anchors.leftMargin: 10 anchors.right: filterPane.left anchors.rightMargin: 0 height: 42 } LensBar { id: lensBar KeyNavigation.up: pageLoader anchors.top: parent.top anchors.topMargin: 11 anchors.left: search_entry.anchors.right anchors.right: parent.right anchors.rightMargin: 20 height: 42 } Loader { id: pageLoader Accessible.name: "loader" /* FIXME: check on visible necessary; fixed in Qt Quick 1.1 ref: http://bugreports.qt.nokia.com/browse/QTBUG-15862 */ KeyNavigation.right: filterPane.visible && !filterPane.folded ? filterPane : pageLoader KeyNavigation.up: search_entry KeyNavigation.down: lensBar anchors.top: search_entry.bottom anchors.topMargin: 9 anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: !filterPane.visible || filterPane.folded ? parent.right : filterPane.left anchors.rightMargin: !filterPane.visible || filterPane.folded ? 0 : 15 onLoaded: item.focus = true } FilterPane { id: filterPane KeyNavigation.left: search_entry /* FilterPane is only to be displayed for lenses, not in the home page or Alt+F2 Run page */ visible: dashView.activeLens != "" && dashView.activeLens != "commands.lens" lens: visible && currentPage != undefined ? currentPage.model : undefined anchors.top: search_entry.bottom anchors.topMargin: 12 anchors.bottom: parent.bottom headerHeight: 10 width: 300 anchors.right: parent.right anchors.rightMargin: 20 } }
Retirer le rectangle noir transparent derrière les lenses
Ouvrez le fichier /usr/share/unity-2d/places/LensBar.qml
Dans le haut du fichier, cherchez :
FocusScope { id: lensBar /* declare width & spacing of icons as required for layout calculations */ property int iconWidth: 24 property int iconSpacing: 36 property variant visibleLenses: SortFilterProxyModel { model: dash.lenses dynamicSortFilter: true filterRole: Lenses.RoleVisible filterRegExp: RegExp("^true$") } Rectangle { id: background anchors.fill: parent color: "black" opacity: 0.22 }
Remplacez opacity: 0.22 par opacity: 0