Merge lp:~agateau/unity-2d/desktop-dash into lp:unity-2d/3.0

Proposed by Aurélien Gâteau
Status: Merged
Merged at revision: 404
Proposed branch: lp:~agateau/unity-2d/desktop-dash
Merge into: lp:unity-2d/3.0
Diff against target: 625 lines (+305/-59)
8 files modified
places/Home.qml (+31/-1)
places/app/CMakeLists.txt (+3/-0)
places/app/dashdeclarativeview.cpp (+187/-39)
places/app/dashdeclarativeview.h (+27/-4)
places/app/places.cpp (+7/-13)
places/artwork/desktop_dash_background.sci (+7/-0)
places/artwork/desktop_dash_background_no_transparency.sci (+7/-0)
places/dash.qml (+36/-2)
To merge this branch: bzr merge lp:~agateau/unity-2d/desktop-dash
Reviewer Review Type Date Requested Status
Florian Boucault (community) Needs Fixing
Review via email: mp+49625@code.launchpad.net

Commit message

[dash] New desktop mode dash activated for higher screen resolutions. In that mode the dash does not occupy the entire screen by default. Instead it shows the search bar only when no results are visible and grows in height to show search results.

Description of the change

Here is the first *very rough* version of the Desktop Dash. It still needs quite some work on the QML side, but I understand this will be part of a separate merge.

It relies on compositing for now, which may or may not be available on all target machines. If need be I can flatten the background and make a fully opaque version depending on the availability of compositing.

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) wrote :

- clicking on the Ubuntu circle-of-friends in the panel does not show a miminized version of the dash.
- clicking on a place in the launcher does not show a windowed version of the dash

review: Needs Fixing (functional)
Revision history for this message
Florian Boucault (fboucault) wrote :

Please add a commit message that will be used automatically when the branch lands.

Revision history for this message
Florian Boucault (fboucault) wrote :

In places/app/dashdeclarativeview.h:

    enum DashState {
        HiddenDash,
        CollapsedDesktopDash, /// Only search line-edit and "Shortcuts" button
        ExpandedDesktopDash, /// CollapsedDesktopDash + search results
        FullScreenDash
    };

I don't think the values need to contain 'Dash' in their names. Proposal:
- Hidden
-Collapsed
- Expanded
- Fullscreen

review: Needs Fixing (code)
Revision history for this message
Florian Boucault (fboucault) wrote :

In places/app/dashdeclarativeview.h:

Property dashState should not contain 'dash' in its name (similar to the 'active' property which is not named 'dashActive'). All methods (getter, setter, signal) should be renamed accordingly.

review: Needs Fixing (code)
Revision history for this message
Florian Boucault (fboucault) wrote :

DashDeclarativeView::onWorkAreaResized(int screen)

should take into account other states than just 'FullScreenDash'.

review: Needs Fixing (code)
Revision history for this message
Florian Boucault (fboucault) wrote :

DashDeclarativeView::setDashState(DashDeclarativeView::DashState state)

should call resize (calling fitToAvailableSpace or resizeToDesktopDashSize) _before_ calling 'show'.

review: Needs Fixing (code)
Revision history for this message
Florian Boucault (fboucault) wrote :

> DashDeclarativeView::onWorkAreaResized(int screen)
>
> should take into account other states than just 'FullScreenDash'.

If the available work area's size becomes "close enough" to the size of dash in 'desktop' state then the dash should take all the width of the screen and drop its window borders and resizing handle (similar to what happens in 'fullscreen' state).

To ease that implementation and make the code cleaner, the logic to determine if the size of the dash is "close enough" should not be part of DashDeclarativeView::setActive but factored out in a separate method.
In this merge request that code is incomplete at the moment as it only checks the resolution of the screen against a static resolution DASH_MIN_SCREEN_WIDTH/DASH_MIN_SCREEN_HEIGHT whereas it should:
 - determine whether or not the screen resolution is one of a netbook
 - if yes, then compare the size of the dash in 'desktop' state and the size of the available area and if the dash takes "most" of the available area then behave as if it were in 'fullscreen' state

Let's discuss this very soon in order to make it crystal clear.

review: Needs Fixing (code)
Revision history for this message
Florian Boucault (fboucault) wrote :

places/artwork/desktop_dash.sci
places/artwork/desktop_dash_background.png

Please name the sci identically to the png file. Also I think it would be clearer to name it 'border' or 'handle' rather than 'background'

review: Needs Fixing (code)
Revision history for this message
Florian Boucault (fboucault) wrote :

In places/app/places.cpp:

- view.setAttribute(Qt::WA_OpaquePaintEvent);
- view.setAttribute(Qt::WA_NoSystemBackground);
+ view.setAttribute(Qt::WA_TranslucentBackground);
+ view.viewport()->setAttribute(Qt::WA_TranslucentBackground);

Until Metacity has compositing activated by default that code should be conditional. Please restore the previous code by default.

review: Needs Fixing (code)
Revision history for this message
Florian Boucault (fboucault) wrote :

places/Home.qml

- opacity: globalSearchActive ? 0 : 1
+ opacity: globalSearchActive || dashView.dashState == DashDeclarativeView.CollapsedDesktopDash ? 0 : 1

This change does not look necessary.

Revision history for this message
Florian Boucault (fboucault) wrote :

places/dash.qml:

- 'shortcutsButton' should be part of the home page as it is never used in the places.
- 'expanded'/'collapsed' state management is overly complicated: a binding of dashView.dashState would suffice:

Binding {
    target: dashView
    property: "dashState"
    value: THE_RIGHT_VALUE (taken from updateDashState)
}

Though this will not be necessary as this should move to Home.qml as well as it is the only place where collapsed/expanded is relevant

review: Needs Fixing (code)
Revision history for this message
Florian Boucault (fboucault) wrote :

places/PlaceEntryView.qml

New 'expanded' property should be removed (as a consequence of previous comment).

review: Needs Fixing (code)
Revision history for this message
Aurélien Gâteau (agateau) wrote :

> - clicking on the Ubuntu circle-of-friends in the panel does not show a
> miminized version of the dash.
> - clicking on a place in the launcher does not show a windowed version of the
> dash

It works here. What is the size of your screen? maybe you fall in the "fullscreen" only case?

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> In places/app/dashdeclarativeview.h:
>
> enum DashState {
> HiddenDash,
> CollapsedDesktopDash, /// Only search line-edit and "Shortcuts" button
> ExpandedDesktopDash, /// CollapsedDesktopDash + search results
> FullScreenDash
> };
>
>
> I don't think the values need to contain 'Dash' in their names. Proposal:
> - Hidden
> -Collapsed
> - Expanded
> - Fullscreen

I disagree. See http://doc.qt.nokia.com/qq/qq13-apis.html#theartofnaming for the rational behind these names.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> In places/app/dashdeclarativeview.h:
>
> Property dashState should not contain 'dash' in its name (similar to the
> 'active' property which is not named 'dashActive'). All methods (getter,
> setter, signal) should be renamed accordingly.

I disagree: "state" is too generic. I agree "dash" is not the best prefix though (same for the enums). What about renaming the whole "dashState" to "appearance" or "formFactor"?

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> In this merge request that code is incomplete at the moment as it only checks
> the resolution of the screen against a static resolution
> DASH_MIN_SCREEN_WIDTH/DASH_MIN_SCREEN_HEIGHT whereas it should:

The spec explicitly defines these resolution limits.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> DashDeclarativeView::setDashState(DashDeclarativeView::DashState state)
>
> should call resize (calling fitToAvailableSpace or resizeToDesktopDashSize)
> _before_ calling 'show'.

It does not really matter because X is asynchronous: the window won't appear on the screen until we are back to the event loop.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> places/artwork/desktop_dash.sci
> places/artwork/desktop_dash_background.png
>
> Please name the sci identically to the png file.

Oups. I agree.

> Also I think it would be
> clearer to name it 'border' or 'handle' rather than 'background'

I choose background because the image is also used for the background of the Dash. I don't have any strong opinion on this though: pick which name you prefer.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> In places/app/places.cpp:
>
> - view.setAttribute(Qt::WA_OpaquePaintEvent);
> - view.setAttribute(Qt::WA_NoSystemBackground);
> + view.setAttribute(Qt::WA_TranslucentBackground);
> + view.viewport()->setAttribute(Qt::WA_TranslucentBackground);
>
> Until Metacity has compositing activated by default that code should be
> conditional. Please restore the previous code by default.

It is going to be super-ugly if I do this. Should I detect compositing and define a window mask if it's not available?

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> places/Home.qml
>
> - opacity: globalSearchActive ? 0 : 1
> + opacity: globalSearchActive || dashView.dashState ==
> DashDeclarativeView.CollapsedDesktopDash ? 0 : 1
>
> This change does not look necessary.

It is necessary, otherwise the home buttons appears behind the search widget in Collapsed mode.

Revision history for this message
Florian Boucault (fboucault) wrote :

> > In places/app/dashdeclarativeview.h:
> >
> > enum DashState {
> > HiddenDash,
> > CollapsedDesktopDash, /// Only search line-edit and "Shortcuts"
> button
> > ExpandedDesktopDash, /// CollapsedDesktopDash + search results
> > FullScreenDash
> > };
> >
> >
> > I don't think the values need to contain 'Dash' in their names. Proposal:
> > - Hidden
> > -Collapsed
> > - Expanded
> > - Fullscreen
>
> I disagree. See http://doc.qt.nokia.com/qq/qq13-apis.html#theartofnaming for
> the rational behind these names.

I don't see how it applies here. Note that we are not polluting the Qt namespace here. Please detail your point.

Revision history for this message
Florian Boucault (fboucault) wrote :

> > - clicking on the Ubuntu circle-of-friends in the panel does not show a
> > miminized version of the dash.
> > - clicking on a place in the launcher does not show a windowed version of
> the
> > dash
>
> It works here. What is the size of your screen? maybe you fall in the
> "fullscreen" only case?

1280x800 is my screen size.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> > > In places/app/dashdeclarativeview.h:
> > >
> > > enum DashState {
> > > HiddenDash,
> > > CollapsedDesktopDash, /// Only search line-edit and "Shortcuts"
> > button
> > > ExpandedDesktopDash, /// CollapsedDesktopDash + search results
> > > FullScreenDash
> > > };
> > >
> > >
> > > I don't think the values need to contain 'Dash' in their names. Proposal:
> > > - Hidden
> > > -Collapsed
> > > - Expanded
> > > - Fullscreen
> >
> > I disagree. See http://doc.qt.nokia.com/qq/qq13-apis.html#theartofnaming for
> > the rational behind these names.
>
>
> I don't see how it applies here. Note that we are not polluting the Qt
> namespace here. Please detail your point.

The link I posted is not about Qt itself, it is about Qt-style API, which is what we are creating. An enum named Fullscreen or Expanded is ambiguous, hence the need for a suffix, has suggested in the "Naming Enum Types and Values" chapter of the link.

Revision history for this message
Florian Boucault (fboucault) wrote :

> > In places/app/dashdeclarativeview.h:
> >
> > Property dashState should not contain 'dash' in its name (similar to the
> > 'active' property which is not named 'dashActive'). All methods (getter,
> > setter, signal) should be renamed accordingly.
>
> I disagree: "state" is too generic. I agree "dash" is not the best prefix
> though (same for the enums). What about renaming the whole "dashState" to
> "appearance" or "formFactor"?

How about 'mode' or 'layout'? or 'layoutMode'?

Revision history for this message
Florian Boucault (fboucault) wrote :

> > places/artwork/desktop_dash.sci
> > places/artwork/desktop_dash_background.png
> >
> > Please name the sci identically to the png file.
>
> Oups. I agree.
>
> > Also I think it would be
> > clearer to name it 'border' or 'handle' rather than 'background'
>
> I choose background because the image is also used for the background of the
> Dash. I don't have any strong opinion on this though: pick which name you
> prefer.

I had not noticed it was used as background. That probably conflicts with the GnomeBackground being drawn below with a color blended into it. Let's discuss this.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> > > - clicking on the Ubuntu circle-of-friends in the panel does not show a
> > > miminized version of the dash.
> > > - clicking on a place in the launcher does not show a windowed version of
> > the
> > > dash
> >
> > It works here. What is the size of your screen? maybe you fall in the
> > "fullscreen" only case?
>
> 1280x800 is my screen size.

That's it: the spec says if both your screen dimensions are less than or equal to 1280 x 1024, only the fullscreen dash should be displayed.

You can work-around it through two environment variables: Start unity-2d-places like this:

DASH_MIN_SCREEN_WIDTH=640 DASH_MIN_SCREEN_HEIGHT=480 unity-2d-places

(Actually only setting the HEIGHT should be enough)

Revision history for this message
Florian Boucault (fboucault) wrote :

> > places/Home.qml
> >
> > - opacity: globalSearchActive ? 0 : 1
> > + opacity: globalSearchActive || dashView.dashState ==
> > DashDeclarativeView.CollapsedDesktopDash ? 0 : 1
> >
> > This change does not look necessary.
>
> It is necessary, otherwise the home buttons appears behind the search widget
> in Collapsed mode.

My bad.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> > > places/artwork/desktop_dash.sci
> > > places/artwork/desktop_dash_background.png
> > >
> > > Please name the sci identically to the png file.
> >
> > Oups. I agree.
> >
> > > Also I think it would be
> > > clearer to name it 'border' or 'handle' rather than 'background'
> >
> > I choose background because the image is also used for the background of the
> > Dash. I don't have any strong opinion on this though: pick which name you
> > prefer.
>
> I had not noticed it was used as background. That probably conflicts with the
> GnomeBackground being drawn below with a color blended into it. Let's discuss
> this.

Right now what happens is that GnomeBackground is not shown when in desktop mode, so it does not really conflict. That may not be what the designer had in mind though.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> places/dash.qml:
>
> - 'shortcutsButton' should be part of the home page as it is never used in the
> places.

This cannot be done because the home page is hidden when the shortcut button is shown.

> - 'expanded'/'collapsed' state management is overly complicated: a binding of
> dashView.dashState would suffice:
>
> Binding {
> target: dashView
> property: "dashState"
> value: THE_RIGHT_VALUE (taken from updateDashState)
> }
>
> Though this will not be necessary as this should move to Home.qml as well as
> it is the only place where collapsed/expanded is relevant

Just tried this approach and could not get it to work: it caused a loop in the binding as the computation for THE_RIGHT_VALUE needs to access dashState (to avoid changing it when we are in fullscreen mode)

>> places/artwork/desktop_dash.sci
>> places/artwork/desktop_dash_background.png
>>
>> Please name the sci identically to the png file.

> Oups. I agree.

Renamed desktop_dash.sci to desktop_dash_background.sci for now.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> > places/dash.qml:
> >
> > - 'shortcutsButton' should be part of the home page as it is never used in
> the
> > places.
>
> This cannot be done because the home page is hidden when the shortcut button
> is shown.

OK, I found a way to do this.
>
> > - 'expanded'/'collapsed' state management is overly complicated: a binding
> of
> > dashView.dashState would suffice:
> >
> > Binding {
> > target: dashView
> > property: "dashState"
> > value: THE_RIGHT_VALUE (taken from updateDashState)
> > }
> >
> > Though this will not be necessary as this should move to Home.qml as well as
> > it is the only place where collapsed/expanded is relevant
>
> Just tried this approach and could not get it to work: it caused a loop in the
> binding as the computation for THE_RIGHT_VALUE needs to access dashState (to
> avoid changing it when we are in fullscreen mode)

Just committed a new version, which is quite simpler and does not require change in PlaceViewEntry.qml. This was possible because I got rid of the two different Desktop states and added a separate "expanded" boolean property. Code is simpler now.

I also renamed DashState to DashMode and its values: HiddenMode, DesktopMode and FullScreenMode.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

Added a semi decent fall-back for non composite mode. I think I addressed all your issues now.

Revision history for this message
Florian Boucault (fboucault) wrote :

I'm still going through the log of comments/replies, please bear with me.

One thing I noticed during functional testing is that in expanded desktop mode the 'fullscreen' button does not work anymore.

review: Needs Fixing (functional)
Revision history for this message
Florian Boucault (fboucault) wrote :

Looks like:

    Binding {
        target: dashView
        property: "expanded"
        value: (currentPage && currentPage.expanded != undefined) ? currentPage.expanded : true
    }

could be moved from places/dash.qml to places/Home.qml

Revision history for this message
Florian Boucault (fboucault) wrote :

Other than that all the other changes look great especially the simplifications to the QML which are so neat! That will make merging the work with the new look of the dash trivial.

We still have the screen size thing to discuss now that I found the lost specification again :)

Revision history for this message
Florian Boucault (fboucault) wrote :

After discussion it was decided the following:

In non composite mode, a different PNG image needs to be used for the border and background. It will be fully opaque and serves also as the mask. The background color (part behind the content/search results) is to be nearly black: value of 0.15.
Also in non composite mode the flags that were used before should be readded:
    /* Performance tricks */
    view.setAttribute(Qt::WA_OpaquePaintEvent);
    view.setAttribute(Qt::WA_NoSystemBackground);

Deciding whether or not to make the dash fullscreen by default should use a strict comparison instead of a greater-or-equal.

Content/search results should not overlap the border.

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

When the dash was shown, it used to receive all the key presses thus allowing the user to type a search query. With this MR it seems broken.

review: Needs Fixing (functional)
Revision history for this message
Aurélien Gâteau (agateau) wrote :

> Looks like:
>
> Binding {
> target: dashView
> property: "expanded"
> value: (currentPage && currentPage.expanded != undefined) ?
> currentPage.expanded : true
> }
>
>
> could be moved from places/dash.qml to places/Home.qml

The binding depends on currentPage, which is in dash.qml, so what would be the gain of moving it?

> When the dash was shown, it used to receive all the key presses thus allowing the user to type a search query. With this MR it seems broken.

Yes I noticed that. Will fix.

Revision history for this message
Florian Boucault (fboucault) wrote :

> > Looks like:
> >
> > Binding {
> > target: dashView
> > property: "expanded"
> > value: (currentPage && currentPage.expanded != undefined) ?
> > currentPage.expanded : true
> > }
> >
> >
> > could be moved from places/dash.qml to places/Home.qml
>
> The binding depends on currentPage, which is in dash.qml, so what would be the
> gain of moving it?

Moving it to places/Home.qml also means using a reference to the home page instead of 'currentPage'. The point here is that the behaviour is specific to the home page.

>
> > When the dash was shown, it used to receive all the key presses thus
> allowing the user to type a search query. With this MR it seems broken.
>
> Yes I noticed that. Will fix.

Revision history for this message
Florian Boucault (fboucault) wrote :

According to the mockups, in composite mode, the GnomeBackground should never be used, not even in fullscreen mode. dash.qml needs changing:

     GnomeBackground {
         [...]
         visible: dashView.dashMode == DashDeclarativeView.FullScreenMode
     }

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

> According to the mockups, in composite mode, the GnomeBackground should never
> be used, not even in fullscreen mode. dash.qml needs changing:
>
> GnomeBackground {
> [...]
> visible: dashView.dashMode == DashDeclarativeView.FullScreenMode
> }

    BorderImage {
        [...]
        visible: dashView.dashMode == DashDeclarativeView.DesktopMode

also needs changing to be always visible when in composite mode.

Revision history for this message
Florian Boucault (fboucault) wrote :

> > According to the mockups, in composite mode, the GnomeBackground should
> never
> > be used, not even in fullscreen mode. dash.qml needs changing:
> >
> > GnomeBackground {
> > [...]
> > visible: dashView.dashMode == DashDeclarativeView.FullScreenMode
> > }
>
> BorderImage {
> [...]
> visible: dashView.dashMode == DashDeclarativeView.DesktopMode
>
>
> also needs changing to be always visible when in composite mode.

Actually, that last comment is incorrect. What we need is a black background with 69% opacity.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> > > Looks like:
> > >
> > > Binding {
> > > target: dashView
> > > property: "expanded"
> > > value: (currentPage && currentPage.expanded != undefined) ?
> > > currentPage.expanded : true
> > > }
> > >
> > >
> > > could be moved from places/dash.qml to places/Home.qml
> >
> > The binding depends on currentPage, which is in dash.qml, so what would be
> the
> > gain of moving it?
>
> Moving it to places/Home.qml also means using a reference to the home page
> instead of 'currentPage'. The point here is that the behaviour is specific to
> the home page.

We need 'currentPage' to be able to turn expanded on when switching to the place view.

Revision history for this message
Florian Boucault (fboucault) wrote :

The dash now appears in the list of running applications both in the launcher and in alt+tab.

I believe this is due to revision 411.

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

> > > > Looks like:
> > > >
> > > > Binding {
> > > > target: dashView
> > > > property: "expanded"
> > > > value: (currentPage && currentPage.expanded != undefined) ?
> > > > currentPage.expanded : true
> > > > }
> > > >
> > > >
> > > > could be moved from places/dash.qml to places/Home.qml
> > >
> > > The binding depends on currentPage, which is in dash.qml, so what would be
> > the
> > > gain of moving it?
> >
> > Moving it to places/Home.qml also means using a reference to the home page
> > instead of 'currentPage'. The point here is that the behaviour is specific
> to
> > the home page.
>
> We need 'currentPage' to be able to turn expanded on when switching to the
> place view.

You are right. Sorry for overlooking this.

Revision history for this message
Florian Boucault (fboucault) wrote :

About "Content/search results should not overlap the border.", I believe the correct values are:

        anchors.rightMargin: 37
        anchors.bottomMargin: 39

That is for the item containing all the content (= item containing search_entry, pageLoader, etc.)

Also I guess the fullScreenButton will have to be moved out of it.

Revision history for this message
Florian Boucault (fboucault) wrote :

Attempt to merge into lp:unity-2d failed due to conflicts:

text conflict in places/app/CMakeLists.txt
text conflict in places/app/places.cpp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'places/Home.qml'
2--- places/Home.qml 2011-01-27 09:30:14 +0000
3+++ places/Home.qml 2011-02-21 17:37:35 +0000
4@@ -1,6 +1,7 @@
5 import Qt 4.7
6 import UnityApplications 1.0 /* Necessary for the ImageProvider serving image://icons/theme_name/icon_name */
7 import Unity2d 1.0 /* Necessary for QSortFilterProxyModelQML */
8+import Places 1.0 /* Necessary for DashDeclarativeView.*Dash */
9 import gconf 1.0
10
11 Item {
12@@ -13,8 +14,37 @@
13 }
14 }
15
16+ /* Set to true if shortcut buttons are visible */
17+ property bool shortcutsActive: false
18+
19 /* Either globalSearch is shown or buttons are shown depending on globalSearchActive */
20 property bool globalSearchActive: model.entrySearchQuery != ""
21+
22+ /* Used by dash.qml to bind to dashView "expanded" property */
23+ property bool expanded: globalSearchActive || shortcutsActive
24+
25+ Button {
26+ id: shortcutsButton
27+ anchors.bottom: parent.top
28+ anchors.right: parent.right
29+ anchors.rightMargin: 50
30+ anchors.bottomMargin: 10
31+ width: 80
32+ height: 47
33+
34+ TextCustom {
35+ text: "Shortcuts"
36+ anchors.fill: parent
37+ horizontalAlignment: Text.AlignHCenter
38+ verticalAlignment: Text.AlignVCenter
39+ }
40+
41+ opacity: (!expanded && dashView.dashMode == DashDeclarativeView.DesktopMode) ? 1 : 0
42+
43+ onClicked: {
44+ shortcutsActive = true
45+ }
46+ }
47
48 ListViewWithScrollbar {
49 id: globalSearch
50@@ -64,7 +94,7 @@
51 Flow {
52 id: buttons
53
54- opacity: globalSearchActive ? 0 : 1
55+ opacity: (!globalSearchActive && (shortcutsActive || dashView.dashMode == DashDeclarativeView.FullScreenMode)) ? 1 : 0
56 anchors.horizontalCenter: parent.horizontalCenter
57 anchors.verticalCenter: parent.verticalCenter
58
59
60=== modified file 'places/app/CMakeLists.txt'
61--- places/app/CMakeLists.txt 2011-01-10 18:25:49 +0000
62+++ places/app/CMakeLists.txt 2011-02-21 17:37:35 +0000
63@@ -1,6 +1,7 @@
64 # Dependencies
65 find_package(X11 REQUIRED)
66 pkg_check_modules(QTGCONF REQUIRED libqtgconf)
67+pkg_check_modules(GTK REQUIRED gtk+-2.0)
68
69 # Sources
70 set(places_SRCS
71@@ -26,6 +27,7 @@
72 include_directories(
73 ${CMAKE_CURRENT_BINARY_DIR}
74 ${QTGCONF_INCLUDE_DIRS}
75+ ${GTK_INCLUDE_DIRS}
76 )
77
78 target_link_libraries(unity-2d-places
79@@ -34,6 +36,7 @@
80 ${QT_QTDBUS_LIBRARIES}
81 ${QT_QTDECLARATIVE_LIBRARIES}
82 ${QTGCONF_LDFLAGS}
83+ ${GTK_LDFLAGS}
84 ${X11_Xext_LIB}
85 ${X11_X11_LIB}
86 )
87
88=== modified file 'places/app/dashdeclarativeview.cpp'
89--- places/app/dashdeclarativeview.cpp 2011-02-01 18:18:27 +0000
90+++ places/app/dashdeclarativeview.cpp 2011-02-21 17:37:35 +0000
91@@ -17,6 +17,7 @@
92 #include "dashdeclarativeview.h"
93 #include <QDesktopWidget>
94 #include <QApplication>
95+#include <QBitmap>
96 #include <QCloseEvent>
97 #include <QDeclarativeContext>
98 #include <QX11Info>
99@@ -27,26 +28,63 @@
100 #include <X11/Xlib.h>
101 #include <X11/Xatom.h>
102
103-DashDeclarativeView::DashDeclarativeView() :
104- QDeclarativeView(), m_active(false), m_activePlaceEntry()
105+#include <config.h>
106+
107+static const int DASH_MIN_SCREEN_WIDTH = 1280;
108+static const int DASH_MIN_SCREEN_HEIGHT = 1084;
109+
110+static const int DASH_DESKTOP_WIDTH = 989;
111+static const int DASH_DESKTOP_COLLAPSED_HEIGHT = 78;
112+static const int DASH_DESKTOP_EXPANDED_HEIGHT = 606;
113+
114+DashDeclarativeView::DashDeclarativeView()
115+: QDeclarativeView()
116+, m_mode(HiddenMode)
117+, m_expanded(false)
118 {
119+ setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
120+
121+ if (QX11Info::isCompositingManagerRunning()) {
122+ setAttribute(Qt::WA_TranslucentBackground);
123+ viewport()->setAttribute(Qt::WA_TranslucentBackground);
124+ } else {
125+ setAttribute(Qt::WA_OpaquePaintEvent);
126+ setAttribute(Qt::WA_NoSystemBackground);
127+ }
128+
129 QDesktopWidget* desktop = QApplication::desktop();
130 connect(desktop, SIGNAL(resized(int)), SIGNAL(screenGeometryChanged()));
131- connect(desktop, SIGNAL(workAreaResized(int)), SIGNAL(availableGeometryChanged()));
132-}
133-
134-void
135-DashDeclarativeView::fitToAvailableSpace(int screen)
136-{
137- QDesktopWidget *desktop = QApplication::desktop();
138- int current_screen = desktop->screenNumber(this);
139-
140- if(screen == current_screen)
141- {
142- QRect geometry = desktop->availableGeometry(this);
143- setGeometry(geometry);
144- setFixedSize(geometry.size());
145- }
146+ connect(desktop, SIGNAL(workAreaResized(int)), SLOT(onWorkAreaResized(int)));
147+}
148+
149+void
150+DashDeclarativeView::onWorkAreaResized(int screen)
151+{
152+ if (QApplication::desktop()->screenNumber(this) != screen) {
153+ return;
154+ }
155+
156+ if (m_mode == FullScreenMode) {
157+ fitToAvailableSpace();
158+ }
159+
160+ availableGeometryChanged();
161+}
162+
163+void
164+DashDeclarativeView::fitToAvailableSpace()
165+{
166+ setGeometry(QApplication::desktop()->availableGeometry(this));
167+}
168+
169+void
170+DashDeclarativeView::resizeToDesktopModeSize()
171+{
172+ QRect rect = QApplication::desktop()->availableGeometry(this);
173+
174+ rect.setWidth(DASH_DESKTOP_WIDTH);
175+ rect.setHeight(m_expanded ? DASH_DESKTOP_EXPANDED_HEIGHT : DASH_DESKTOP_COLLAPSED_HEIGHT);
176+ setGeometry(rect);
177 }
178
179 void
180@@ -56,24 +94,89 @@
181 setActive(false);
182 }
183
184-void
185-DashDeclarativeView::setActive(bool active)
186-{
187- m_active = active;
188-
189- if(active)
190- {
191- emit activeChanged(active);
192+static int getenvInt(const char* name, int defaultValue)
193+{
194+ QByteArray stringValue = qgetenv(name);
195+ bool ok;
196+ int value = stringValue.toInt(&ok);
197+ return ok ? value : defaultValue;
198+}
199+
200+void
201+DashDeclarativeView::setActive(bool value)
202+{
203+ if (value != active()) {
204+ if (value) {
205+ QRect rect = QApplication::desktop()->screenGeometry(this);
206+ static int minWidth = getenvInt("DASH_MIN_SCREEN_WIDTH", DASH_MIN_SCREEN_WIDTH);
207+ static int minHeight = getenvInt("DASH_MIN_SCREEN_HEIGHT", DASH_MIN_SCREEN_HEIGHT);
208+ if (rect.width() < minWidth && rect.height() < minHeight) {
209+ setDashMode(FullScreenMode);
210+ } else {
211+ setDashMode(DesktopMode);
212+ }
213+ } else {
214+ setDashMode(HiddenMode);
215+ }
216+ }
217+}
218+
219+bool
220+DashDeclarativeView::active() const
221+{
222+ return m_mode != HiddenMode;
223+}
224+
225+void
226+DashDeclarativeView::setDashMode(DashDeclarativeView::DashMode mode)
227+{
228+ if (m_mode == mode) {
229+ return;
230+ }
231+
232+ m_mode = mode;
233+ if (m_mode == HiddenMode) {
234+ hide();
235+ activeChanged(false);
236+ } else {
237 show();
238 raise();
239 activateWindow();
240 forceActivateWindow();
241- }
242- else
243- {
244- hide();
245- emit activeChanged(active);
246- }
247+ if (m_mode == FullScreenMode) {
248+ fitToAvailableSpace();
249+ } else {
250+ resizeToDesktopModeSize();
251+ }
252+ activeChanged(true);
253+ }
254+ dashModeChanged(m_mode);
255+}
256+
257+DashDeclarativeView::DashMode
258+DashDeclarativeView::dashMode() const
259+{
260+ return m_mode;
261+}
262+
263+void
264+DashDeclarativeView::setExpanded(bool value)
265+{
266+ if (m_expanded == value) {
267+ return;
268+ }
269+
270+ m_expanded = value;
271+ if (m_mode == DesktopMode) {
272+ resizeToDesktopModeSize();
273+ }
274+ expandedChanged(m_expanded);
275+}
276+
277+bool
278+DashDeclarativeView::expanded() const
279+{
280+ return m_expanded;
281 }
282
283 void
284@@ -85,12 +188,6 @@
285 }
286 }
287
288-bool
289-DashDeclarativeView::active() const
290-{
291- return m_active;
292-}
293-
294 const QString&
295 DashDeclarativeView::activePlaceEntry() const
296 {
297@@ -130,19 +227,19 @@
298 DashDeclarativeView::activatePlaceEntry(const QString& file, const QString& entry, const int section)
299 {
300 QGraphicsObject* dash = rootObject();
301- setActive(true);
302 QMetaObject::invokeMethod(dash, "activatePlaceEntry", Qt::AutoConnection,
303 Q_ARG(QVariant, QVariant::fromValue(file)),
304 Q_ARG(QVariant, QVariant::fromValue(entry)),
305 Q_ARG(QVariant, QVariant::fromValue(section)));
306+ setActive(true);
307 }
308
309 void
310 DashDeclarativeView::activateHome()
311 {
312 QGraphicsObject* dash = rootObject();
313- setActive(true);
314 QMetaObject::invokeMethod(dash, "activateHome", Qt::AutoConnection);
315+ setActive(true);
316 }
317
318 const QRect
319@@ -171,3 +268,54 @@
320 break;
321 }
322 }
323+
324+void
325+DashDeclarativeView::resizeEvent(QResizeEvent* event)
326+{
327+ if (!QX11Info::isCompositingManagerRunning()) {
328+ updateMask();
329+ }
330+ QDeclarativeView::resizeEvent(event);
331+}
332+
333+static QBitmap
334+createCornerMask()
335+{
336+ QPixmap pix(unity2dDirectory() + "/places/artwork/desktop_dash_background_no_transparency.png");
337+ return pix.createMaskFromColor(Qt::red, Qt::MaskOutColor);
338+}
339+
340+void
341+DashDeclarativeView::updateMask()
342+{
343+ if (m_mode == FullScreenMode) {
344+ clearMask();
345+ return;
346+ }
347+ QBitmap bmp(size());
348+ {
349+ static QBitmap corner = createCornerMask();
350+ static QBitmap top = corner.copy(0, 0, corner.width(), 1);
351+ static QBitmap left = corner.copy(0, 0, 1, corner.height());
352+
353+ const int cornerX = bmp.width() - corner.width();
354+ const int cornerY = bmp.height() - corner.height();
355+
356+ QPainter painter(&bmp);
357+ painter.fillRect(bmp.rect(), Qt::color1);
358+ painter.setBackgroundMode(Qt::OpaqueMode);
359+ painter.setBackground(Qt::color1);
360+ painter.setPen(Qt::color0);
361+ painter.drawPixmap(cornerX, cornerY, corner);
362+
363+ painter.drawTiledPixmap(cornerX, 0, top.width(), cornerY, top);
364+ painter.drawTiledPixmap(0, cornerY, cornerX, left.height(), left);
365+ }
366+ setMask(bmp);
367+}
368+
369+bool
370+DashDeclarativeView::isCompositingManagerRunning() const
371+{
372+ return QX11Info::isCompositingManagerRunning();
373+}
374
375=== modified file 'places/app/dashdeclarativeview.h'
376--- places/app/dashdeclarativeview.h 2011-02-01 18:18:27 +0000
377+++ places/app/dashdeclarativeview.h 2011-02-21 17:37:35 +0000
378@@ -22,46 +22,69 @@
379 class DashDeclarativeView : public QDeclarativeView
380 {
381 Q_OBJECT
382+ Q_ENUMS(DashMode)
383
384 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity2d.Dash")
385 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
386+ Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged)
387+ Q_PROPERTY(DashMode dashMode READ dashMode WRITE setDashMode NOTIFY dashModeChanged)
388 Q_PROPERTY(QString activePlaceEntry READ activePlaceEntry WRITE setActivePlaceEntry NOTIFY activePlaceEntryChanged)
389 Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
390 Q_PROPERTY(QRect availableGeometry READ availableGeometry NOTIFY availableGeometryChanged)
391+ Q_PROPERTY(bool isCompositingManagerRunning READ isCompositingManagerRunning)
392
393 public:
394+ enum DashMode {
395+ HiddenMode,
396+ DesktopMode,
397+ FullScreenMode
398+ };
399 explicit DashDeclarativeView();
400
401 /* getters */
402 bool active() const;
403+ DashMode dashMode() const;
404 const QString& activePlaceEntry() const;
405 const QRect screenGeometry() const;
406 const QRect availableGeometry() const;
407+ bool expanded() const;
408+ bool isCompositingManagerRunning() const;
409
410 /* setters */
411 Q_SLOT void setActive(bool active);
412+ Q_INVOKABLE void setDashMode(DashMode);
413 Q_INVOKABLE void setActivePlaceEntry(const QString& activePlaceEntry);
414+ Q_INVOKABLE void setExpanded(bool);
415
416 /* methods */
417 Q_INVOKABLE void activatePlaceEntry(const QString& file, const QString& entry, const int section = 0);
418 Q_INVOKABLE void activateHome();
419
420-signals:
421+Q_SIGNALS:
422 void activeChanged(bool);
423+ void dashModeChanged(DashMode);
424+ void expandedChanged(bool);
425 void activePlaceEntryChanged(const QString&);
426
427 void screenGeometryChanged();
428 void availableGeometryChanged();
429
430-public slots:
431- void fitToAvailableSpace(int screen);
432+protected:
433+ void resizeEvent(QResizeEvent*);
434+
435+private Q_SLOTS:
436+ void onWorkAreaResized(int screen);
437
438 private:
439+ void fitToAvailableSpace();
440+ void resizeToDesktopModeSize();
441 void forceActivateWindow();
442 void focusOutEvent(QFocusEvent* event);
443 void keyPressEvent(QKeyEvent* event);
444+ void updateMask();
445
446- bool m_active;
447+ DashMode m_mode;
448+ bool m_expanded;
449 QString m_activePlaceEntry; /* D-Bus object path of the place entry */
450 };
451
452
453=== modified file 'places/app/places.cpp'
454--- places/app/places.cpp 2011-02-02 16:57:00 +0000
455+++ places/app/places.cpp 2011-02-21 17:37:35 +0000
456@@ -19,6 +19,7 @@
457
458 #include <QApplication>
459 #include <QDebug>
460+#include <QtDeclarative>
461 #include <QDeclarativeEngine>
462 #include <QDeclarativeView>
463 #include <QDesktopWidget>
464@@ -29,6 +30,9 @@
465
466 #include <X11/Xlib.h>
467
468+#undef signals
469+#include <gtk/gtk.h>
470+
471 #include "dashdeclarativeview.h"
472 #include "superkeymonitor.h"
473
474@@ -90,6 +94,8 @@
475
476 int main(int argc, char *argv[])
477 {
478+ /* gtk needs to be inited, otherwise we get an assert failure in gdk */
479+ gtk_init(&argc, &argv);
480 QApplication::setApplicationName("Unity 2D Dash");
481 qInstallMsgHandler(globalMessageHandler);
482
483@@ -104,20 +110,13 @@
484 QApplication::setGraphicsSystem("raster");
485 QApplication application(argc, argv);
486
487+ qmlRegisterType<DashDeclarativeView>("Places", 1, 0, "DashDeclarativeView");
488 DashDeclarativeView view;
489
490 if (!registerDBusService(&view)) {
491 return -1;
492 }
493
494- /* The dash window is borderless and not moveable by the user, yet not
495- fullscreen */
496- view.setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
497-
498- /* Performance tricks */
499- view.setAttribute(Qt::WA_OpaquePaintEvent);
500- view.setAttribute(Qt::WA_NoSystemBackground);
501-
502 view.engine()->addImportPath(unity2dImportPath());
503 /* Note: baseUrl seems to be picky: if it does not end with a slash,
504 setSource() will fail */
505@@ -137,11 +136,6 @@
506 view.rootContext()->setContextProperty("engineBaseUrl", view.engine()->baseUrl().toLocalFile());
507 view.setSource(QUrl("./dash.qml"));
508
509- /* Always match the size of the desktop */
510- int current_screen = QApplication::desktop()->screenNumber(&view);
511- view.fitToAvailableSpace(current_screen);
512- QObject::connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), &view, SLOT(fitToAvailableSpace(int)));
513-
514 /* Grab the "super" keys */
515 SuperKeyMonitor superKeys; /* Just needs to be instantiated to work. */
516 QAbstractEventDispatcher::instance()->setEventFilter(eventFilter);
517
518=== added file 'places/artwork/desktop_dash_background.png'
519Binary files places/artwork/desktop_dash_background.png 1970-01-01 00:00:00 +0000 and places/artwork/desktop_dash_background.png 2011-02-21 17:37:35 +0000 differ
520=== added file 'places/artwork/desktop_dash_background.sci'
521--- places/artwork/desktop_dash_background.sci 1970-01-01 00:00:00 +0000
522+++ places/artwork/desktop_dash_background.sci 2011-02-21 17:37:35 +0000
523@@ -0,0 +1,7 @@
524+border.left: 0
525+border.top: 0
526+border.bottom: 46
527+border.right: 46
528+source: desktop_dash_background.png
529+horizontalTileRule: Repeat
530+verticalTileRule: Repeat
531
532=== added file 'places/artwork/desktop_dash_background_mask.png'
533Binary files places/artwork/desktop_dash_background_mask.png 1970-01-01 00:00:00 +0000 and places/artwork/desktop_dash_background_mask.png 2011-02-21 17:37:35 +0000 differ
534=== added file 'places/artwork/desktop_dash_background_no_transparency.png'
535Binary files places/artwork/desktop_dash_background_no_transparency.png 1970-01-01 00:00:00 +0000 and places/artwork/desktop_dash_background_no_transparency.png 2011-02-21 17:37:35 +0000 differ
536=== added file 'places/artwork/desktop_dash_background_no_transparency.sci'
537--- places/artwork/desktop_dash_background_no_transparency.sci 1970-01-01 00:00:00 +0000
538+++ places/artwork/desktop_dash_background_no_transparency.sci 2011-02-21 17:37:35 +0000
539@@ -0,0 +1,7 @@
540+border.left: 0
541+border.top: 0
542+border.bottom: 46
543+border.right: 46
544+source: desktop_dash_background_no_transparency.png
545+horizontalTileRule: Repeat
546+verticalTileRule: Repeat
547
548=== added file 'places/artwork/fullscreen_button.png'
549Binary files places/artwork/fullscreen_button.png 1970-01-01 00:00:00 +0000 and places/artwork/fullscreen_button.png 2011-02-21 17:37:35 +0000 differ
550=== modified file 'places/dash.qml'
551--- places/dash.qml 2011-02-01 18:18:27 +0000
552+++ places/dash.qml 2011-02-21 17:37:35 +0000
553@@ -1,11 +1,18 @@
554 import Qt 4.7
555 import UnityApplications 1.0 /* Necessary for LauncherPlacesList */
556+import Places 1.0 /* Necessary for DashDeclarativeView.*Dash */
557
558 Item {
559 id: dash
560
561 property variant currentPage
562
563+ Binding {
564+ target: dashView
565+ property: "expanded"
566+ value: (currentPage && currentPage.expanded != undefined) ? currentPage.expanded : true
567+ }
568+
569 function activatePage(page) {
570 if (page == currentPage) {
571 return
572@@ -50,6 +57,7 @@
573 /* Take advantage of the fact that the loaded qml is local and setting
574 the source loads it immediately making pageLoader.item valid */
575 activatePage(pageLoader.item)
576+ pageLoader.item.shortcutsActive = false
577 dashView.activePlaceEntry = ""
578 }
579
580@@ -61,6 +69,13 @@
581 anchors.fill: parent
582 overlay_color: "black"
583 overlay_alpha: 0.71
584+ visible: dashView.dashMode == DashDeclarativeView.FullScreenMode
585+ }
586+
587+ BorderImage {
588+ anchors.fill: parent
589+ visible: dashView.dashMode == DashDeclarativeView.DesktopMode
590+ source: dashView.isCompositingManagerRunning ? "artwork/desktop_dash_background.sci" : "artwork/desktop_dash_background_no_transparency.sci"
591 }
592
593 Item {
594@@ -80,11 +95,30 @@
595 anchors.top: parent.top
596 anchors.left: parent.left
597 anchors.leftMargin: 3
598- anchors.right: parent.right
599- anchors.rightMargin: 4
600+ width: 616
601 height: 47
602 }
603
604+ Button {
605+ id: fullScreenButton
606+ anchors.bottom: parent.bottom
607+ anchors.right: parent.right
608+ anchors.rightMargin: 15
609+ anchors.bottomMargin: 15
610+ width: fullScreenButtonImage.sourceSize.width
611+ height: fullScreenButtonImage.sourceSize.height
612+ visible: dashView.dashMode != DashDeclarativeView.FullScreenMode
613+
614+ Image {
615+ id: fullScreenButtonImage
616+ source: "artwork/fullscreen_button.png"
617+ }
618+
619+ onClicked: {
620+ dashView.dashMode = DashDeclarativeView.FullScreenMode
621+ }
622+ }
623+
624 Loader {
625 id: pageLoader
626

Subscribers

People subscribed via source and target branches