Changeset View
Changeset View
Standalone View
Standalone View
scripts/desktopchangeosd/contents/ui/osd.qml
Show All 14 Lines | |||||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | import QtQuick 2.0; | 20 | import QtQuick 2.0; | ||
21 | import QtQuick.Window 2.0; | 21 | import QtQuick.Window 2.0; | ||
22 | import org.kde.plasma.core 2.0 as PlasmaCore; | 22 | import org.kde.plasma.core 2.0 as PlasmaCore; | ||
23 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||||
23 | import org.kde.plasma.components 2.0 as Plasma; | 24 | import org.kde.plasma.components 2.0 as Plasma; | ||
24 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons; | 25 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons; | ||
25 | import org.kde.kwin 2.0; | 26 | import org.kde.kwin 2.0; | ||
26 | 27 | | |||
27 | PlasmaCore.Dialog { | 28 | PlasmaCore.Dialog { | ||
28 | id: dialog | 29 | id: dialog | ||
29 | location: PlasmaCore.Types.Floating | 30 | location: PlasmaCore.Types.Floating | ||
30 | visible: false | 31 | visible: false | ||
Show All 23 Lines | 45 | function show() { | |||
54 | dialogItem.screenWidth = screen.width; | 55 | dialogItem.screenWidth = screen.width; | ||
55 | dialogItem.screenHeight = screen.height; | 56 | dialogItem.screenHeight = screen.height; | ||
56 | if (dialogItem.showGrid) { | 57 | if (dialogItem.showGrid) { | ||
57 | // non dependable properties might have changed | 58 | // non dependable properties might have changed | ||
58 | view.columns = workspace.desktopGridWidth; | 59 | view.columns = workspace.desktopGridWidth; | ||
59 | view.rows = workspace.desktopGridHeight; | 60 | view.rows = workspace.desktopGridHeight; | ||
60 | } | 61 | } | ||
61 | dialog.visible = true; | 62 | dialog.visible = true; | ||
63 | | ||||
62 | // position might have changed | 64 | // position might have changed | ||
63 | dialog.x = screen.x + screen.width/2 - dialogItem.width/2; | 65 | dialog.x = screen.x + screen.width/2 - dialogItem.width/2; | ||
64 | dialog.y = screen.y + screen.height/2 - dialogItem.height/2; | 66 | dialog.y = screen.y + screen.height/2 - dialogItem.height/2; | ||
65 | // start the hide timer | 67 | // start the hide timer | ||
66 | timer.start(); | 68 | timer.start(); | ||
67 | } | 69 | } | ||
68 | 70 | | |||
69 | id: dialogItem | 71 | id: dialogItem | ||
70 | property int screenWidth: 0 | 72 | property int screenWidth: 0 | ||
71 | property int screenHeight: 0 | 73 | property int screenHeight: 0 | ||
72 | // we count desktops starting from 0 to have it better match the layout in the Grid | 74 | // we count desktops starting from 0 to have it better match the layout in the Grid | ||
73 | property int currentDesktop: 0 | 75 | property int currentDesktop: 0 | ||
74 | property int previousDesktop: 0 | 76 | property int previousDesktop: 0 | ||
75 | property int animationDuration: 1000 | 77 | property int animationDuration: 1000 | ||
76 | property bool showGrid: true | 78 | property bool showGrid: true | ||
77 | 79 | | |||
78 | width: dialogItem.showGrid ? view.itemWidth * view.columns : textElement.width | 80 | width: dialogItem.showGrid ? view.itemWidth * view.columns : Math.ceil(textElement.implicitWidth) | ||
79 | height: dialogItem.showGrid ? view.itemHeight * view.rows + textElement.height : textElement.height | 81 | height: dialogItem.showGrid ? view.itemHeight * view.rows + textElement.height : textElement.height | ||
80 | 82 | | |||
81 | Plasma.Label { | 83 | PlasmaExtras.Heading { | ||
82 | id: textElement | 84 | id: textElement | ||
83 | anchors.top: dialogItem.showGrid ? parent.top : undefined | 85 | anchors.top: dialogItem.showGrid ? parent.top : undefined | ||
84 | anchors.horizontalCenter: parent.horizontalCenter | 86 | anchors.left: parent.left | ||
87 | anchors.right: parent.right | ||||
88 | horizontalAlignment: Text.AlignHCenter | ||||
89 | wrapMode: Text.NoWrap | ||||
90 | elide: Text.ElideRight | ||||
85 | text: workspace.desktopName(workspace.currentDesktop) | 91 | text: workspace.desktopName(workspace.currentDesktop) | ||
86 | } | 92 | } | ||
93 | | ||||
87 | Grid { | 94 | Grid { | ||
88 | id: view | 95 | id: view | ||
89 | columns: 1 | 96 | columns: 1 | ||
90 | rows: 1 | 97 | rows: 1 | ||
91 | property int itemWidth: dialogItem.screenWidth * Math.min(0.8/columns, 0.1) | 98 | property int itemWidth: dialogItem.screenWidth * Math.min(0.8/columns, 0.1) | ||
92 | property int itemHeight: Math.min(itemWidth * (dialogItem.screenHeight / dialogItem.screenWidth), dialogItem.screenHeight * Math.min(0.8/rows, 0.1)) | 99 | property int itemHeight: Math.min(itemWidth * (dialogItem.screenHeight / dialogItem.screenWidth), dialogItem.screenHeight * Math.min(0.8/rows, 0.1)) | ||
93 | anchors { | 100 | anchors { | ||
94 | top: textElement.bottom | 101 | top: textElement.bottom | ||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |