Merge lp:~jonas-drange/ubuntu-system-settings/mir-display-config into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Needs review
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/mir-display-config
Merge into: lp:ubuntu-system-settings
Diff against target: 4474 lines (+3917/-47)
51 files modified
debian/control (+4/-0)
plugins/brightness/CMakeLists.txt (+40/-2)
plugins/brightness/MirDisplay.qml (+138/-0)
plugins/brightness/PageComponent.qml (+54/-8)
plugins/brightness/WifiDisplays.qml (+22/-19)
plugins/brightness/brightness.cpp (+90/-10)
plugins/brightness/brightness.h (+30/-3)
plugins/brightness/displays/display.cpp (+177/-0)
plugins/brightness/displays/display.h (+89/-0)
plugins/brightness/displays/displaymodel.cpp (+256/-0)
plugins/brightness/displays/displaymodel.h (+113/-0)
plugins/brightness/displays/enums.h (+79/-0)
plugins/brightness/displays/helpers.cpp (+216/-0)
plugins/brightness/displays/helpers.h (+43/-0)
plugins/brightness/displays/mirclient.h (+50/-0)
plugins/brightness/displays/mirclient_impl.cpp (+180/-0)
plugins/brightness/displays/mirclient_impl.h (+47/-0)
plugins/brightness/displays/output/mir_output.cpp (+171/-0)
plugins/brightness/displays/output/mir_output.h (+62/-0)
plugins/brightness/displays/output/output.h (+64/-0)
plugins/brightness/displays/outputmode/mir_outputmode.cpp (+63/-0)
plugins/brightness/displays/outputmode/mir_outputmode.h (+44/-0)
plugins/brightness/displays/outputmode/outputmode.h (+39/-0)
plugins/brightness/plugin.cpp (+7/-0)
plugins/brightness/plugin/brightness-plugin.cpp (+14/-3)
plugins/system-update/CMakeLists.txt (+5/-2)
tests/mocks/Ubuntu/SystemSettings/Brightness/CMakeLists.txt (+31/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDevice.h (+63/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDeviceModel.cpp (+95/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDeviceModel.h (+63/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDisplays.cpp (+89/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDisplays.h (+96/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.cpp (+131/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.h (+86/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplay.h (+71/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplayModel.h (+26/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.cpp (+33/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.h (+33/-0)
tests/mocks/Ubuntu/SystemSettings/Brightness/qmldir (+2/-0)
tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt (+3/-0)
tests/mocks/plugins/brightness/fakemirclient.h (+69/-0)
tests/mocks/plugins/brightness/fakeoutput.h (+150/-0)
tests/mocks/plugins/brightness/fakeoutputmode.h (+58/-0)
tests/plugins/CMakeLists.txt (+14/-0)
tests/plugins/brightness/CMakeLists.txt (+38/-0)
tests/plugins/brightness/Source/qmldir (+3/-0)
tests/plugins/brightness/tst_BrightnessPageComponent.qml (+190/-0)
tests/plugins/brightness/tst_BrightnessWifiDisplays.qml (+79/-0)
tests/plugins/brightness/tst_brightness.cpp (+131/-0)
tests/plugins/brightness/tst_displayplugin_display.cpp (+120/-0)
tests/plugins/brightness/tst_displayplugin_displaymodel.cpp (+146/-0)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/mir-display-config
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
Ken VanDine Approve
Review via email: mp+310444@code.launchpad.net

Commit message

* changes packaging: deps on mir headers (libmirclient-dev) and USC for testing (qtdeclarative5-ubuntu-settings-components)
* allows configuration of mir displays in the Brightness plugin
* adds a display configuration api
* adds test framework for testing brightness, aethercast, mirdisplays and the brightness qml components

To post a comment you must log in.
1736. By Jonas G. Drange

revert spurious si changes

1737. By Jonas G. Drange

undo whitespace changes

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1735
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/225/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1948/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1949
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1788/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1788
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1788/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1788/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1788/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1788/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1788/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1788/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1788/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1788/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/225/rebuild

review: Needs Fixing (continuous-integration)
1738. By Jonas G. Drange

revert test_about changes

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1738
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/227/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1950/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1951
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1790/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1790
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1790/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1790/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1790/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1790/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1790/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1790/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1790
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1790/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1790/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/227/rebuild

review: Needs Fixing (continuous-integration)
1739. By Jonas G. Drange

unconditionally shows the brightness screen if you set USS_SHOW_ALL_UI

1740. By Jonas G. Drange

add showAllUI to test

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1739
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/229/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1956/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1957
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1796/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1796/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1796/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1796/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1796/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1796/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1796/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1796/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1796/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/229/rebuild

review: Needs Fixing (continuous-integration)
1741. By Jonas G. Drange

loads appropriate qml modules for brightness test

1742. By Jonas G. Drange

add copyrights and fix formatting issues

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1740
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/230/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1957/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1958
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1797/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1797
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1797/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1797/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1797/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1797
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1797/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1797/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1797/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1797
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1797/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1797/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/230/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1742
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/231/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1958/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1959
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1798
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1798/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1798
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1798/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1798/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1798
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1798/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1798/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1798/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1798
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1798/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1798
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1798/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1798/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/231/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

This looks pretty good, I tested wifi displays but not on a device with a display attached.

I added an inline comment and also noticed a spelling mistake. In some places there are function names with "Oritentation".

review: Needs Fixing
1743. By Jonas G. Drange

fixes typo

1744. By Jonas G. Drange

puts uss-displays lib first in list in an attempt to fix ppc linker error

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1743
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/234/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1975/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1976
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1810/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1810
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1810/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1810/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1810
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1810/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1810
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1810/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1810/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1810/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1810
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1810/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1810/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/234/rebuild

review: Needs Fixing (continuous-integration)
1745. By Jonas G. Drange

drops qt use modules in favor of cmake words

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1744
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/235/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1976/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1977
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1811
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1811/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1811
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1811/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1811/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1811
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1811/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1811
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1811/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1811/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1811
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1811/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1811/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1811/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/235/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1745
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/236/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1978/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1979
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1813
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1813/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1813/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1813/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1813
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1813/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1813
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1813/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1813/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1813/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1813
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1813/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1813/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/236/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Thanks for the fixes, looks good to me now.

review: Approve
1746. By Jonas G. Drange

tries to solve build issues

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
1747. By Jonas G. Drange

merge trunk

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1747
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/238/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1982/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1983
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1816/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1816/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1816/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1816/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1816/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1816/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1816/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1816/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1816/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/238/rebuild

review: Needs Fixing (continuous-integration)
1748. By Jonas G. Drange

conditionally builds brightness test mock and test based on ANDR PROP

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1748
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/239/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1983/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1984
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1817/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1817/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1817/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1817/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1817/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1817/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1817/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1817/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1817/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/239/rebuild

review: Needs Fixing (continuous-integration)
1749. By Jonas G. Drange

adds test dep on usc

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:1749
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/242/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1990
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/476
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1993
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1823/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1823
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1823/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/242/rebuild

review: Approve (continuous-integration)
1750. By Jonas G. Drange

syncs with trunk

1751. By Jonas G. Drange

starts the move to mir 0.26 by creating abstractions of the mir api

1752. By Jonas G. Drange

adds new abstractions

1753. By Jonas G. Drange

adds mir implementations of output and outputmode

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1753
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/290/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2291/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2294
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2119/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2119/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2119/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2119/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2119/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2119/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/2119/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2119/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2119/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/290/rebuild

review: Needs Fixing (continuous-integration)
1754. By Jonas G. Drange

disable brightness tests for now

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1754
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/291/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2292/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2295
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2120/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2120/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2120/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2120/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2120/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2120/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/2120/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2120/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2120/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/291/rebuild

review: Needs Fixing (continuous-integration)
1755. By Jonas G. Drange

delete gamma code, unecessary right now. Simplifies mir api a bit

1756. By Jonas G. Drange

moves mir display qml into file, fixes model tests

1757. By Jonas G. Drange

fixes qml tests

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1757
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/292/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2294/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2297
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2122/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2122/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2122/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2122/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2122/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2122/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/2122/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2122/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2122/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-system-settings-ci/292/rebuild

review: Needs Fixing (continuous-integration)
1758. By Jonas G. Drange

adds missing dep

1759. By Jonas G. Drange

adds runtime deps

1760. By Jonas G. Drange

link correctly

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

1760. By Jonas G. Drange

link correctly

1759. By Jonas G. Drange

adds runtime deps

1758. By Jonas G. Drange

adds missing dep

1757. By Jonas G. Drange

fixes qml tests

1756. By Jonas G. Drange

moves mir display qml into file, fixes model tests

1755. By Jonas G. Drange

delete gamma code, unecessary right now. Simplifies mir api a bit

1754. By Jonas G. Drange

disable brightness tests for now

1753. By Jonas G. Drange

adds mir implementations of output and outputmode

1752. By Jonas G. Drange

adds new abstractions

1751. By Jonas G. Drange

starts the move to mir 0.26 by creating abstractions of the mir api

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2016-12-16 13:32:09 +0000
3+++ debian/control 2017-02-06 14:24:05 +0000
4@@ -17,6 +17,8 @@
5 libglib2.0-dev (>= 2.37.92),
6 libevdev-dev,
7 libicu-dev,
8+ libmirclient-dev (>= 0.26),
9+ libmircore-dev (>= 0.26),
10 libnm-glib-dev,
11 libpolkit-agent-1-dev,
12 libqmenumodel-dev,
13@@ -100,6 +102,8 @@
14 suru-icon-theme (>= 14.04+15.04.20150813~),
15 whoopsie-preferences (>= 0.9),
16 libsystemsettings1 (= ${binary:Version}),
17+ libmircore1 (>= 0.26),
18+ libmirclient9 (>= 0.26),
19 ubuntu-keyboard-data (>= 0.99.trunk.phablet2+15.04.20150421),
20 ubuntu-wallpapers,
21 # for the session-migration script (python3 itself also for the push helper)
22
23=== modified file 'plugins/brightness/CMakeLists.txt'
24--- plugins/brightness/CMakeLists.txt 2016-04-28 15:24:19 +0000
25+++ plugins/brightness/CMakeLists.txt 2017-02-06 14:24:05 +0000
26@@ -1,8 +1,45 @@
27 include_directories(${ANDR_PROP_INCLUDE_DIRS})
28 add_subdirectory(plugin)
29
30+pkg_search_module(MIR_CORE REQUIRED mircore)
31+pkg_search_module(MIR_CLIENT REQUIRED mirclient)
32+find_package(Qt5Core)
33+find_package(Qt5Gui)
34+find_package(Qt5Quick)
35+find_package(Qt5Gui)
36+include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${MIR_CORE_INCLUDE_DIRS} ${MIR_CLIENT_INCLUDE_DIRS})
37+
38+add_library(uss-displays SHARED
39+ displays/helpers.h
40+
41+ displays/display.h
42+ displays/displaymodel.h
43+
44+ displays/enums.h
45+
46+ displays/mirclient.h
47+ displays/mirclient_impl.h
48+
49+ displays/helpers.cpp
50+ displays/display.cpp
51+ displays/displaymodel.cpp
52+ displays/mirclient_impl.cpp
53+
54+ displays/output/output.h
55+ displays/output/mir_output.cpp
56+
57+ displays/outputmode/outputmode.h
58+ displays/outputmode/mir_outputmode.cpp
59+ ../../src/i18n.cpp
60+)
61+set_target_properties(uss-displays PROPERTIES VERSION 0.0 SOVERSION 0.0)
62+target_link_libraries(uss-displays Qt5::Core Qt5::Quick
63+ ${Qt5Gui_PRIVATE_LDFLAGS}
64+ ${MIR_CORE_LDFLAGS}
65+ ${MIR_CLIENT_LDFLAGS})
66 set(QML_SOURCES
67 PageComponent.qml
68+ MirDisplay.qml
69 WifiDisplays.qml
70 WifiDisplaysAlert.qml
71 )
72@@ -29,11 +66,12 @@
73 brightness.cpp
74 ${QML_SOURCES})
75 qt5_use_modules(UbuntuBrightnessPanel Quick Qml DBus)
76-target_link_libraries(UbuntuBrightnessPanel SystemSettings ${ANDR_PROP_LDFLAGS})
77+target_link_libraries(UbuntuBrightnessPanel SystemSettings ${ANDR_PROP_LDFLAGS} uss-displays)
78
79 set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Brightness)
80+install(TARGETS uss-displays DESTINATION ${PLUGIN_MODULE_DIR})
81 install(TARGETS UbuntuBrightnessPanel DESTINATION ${PLUG_DIR})
82-install(FILES qmldir DESTINATION ${PLUG_DIR})
83+install(FILES qmldir.in DESTINATION ${PLUG_DIR} RENAME qmldir)
84 install(FILES brightness.settings DESTINATION ${PLUGIN_MANIFEST_DIR})
85 install(FILES settings-brightness.svg DESTINATION ${PLUGIN_MANIFEST_DIR}/icons)
86 install(FILES ${QML_SOURCES} DESTINATION ${PLUGIN_QML_DIR}/brightness)
87
88=== added file 'plugins/brightness/MirDisplay.qml'
89--- plugins/brightness/MirDisplay.qml 1970-01-01 00:00:00 +0000
90+++ plugins/brightness/MirDisplay.qml 2017-02-06 14:24:05 +0000
91@@ -0,0 +1,138 @@
92+/*
93+ * This file is part of system-settings
94+ *
95+ * Copyright (C) 2013-14 Canonical Ltd.
96+ *
97+ * Contact: Iain Lane <iain.lane@canonical.com>
98+ *
99+ * This program is free software: you can redistribute it and/or modify it
100+ * under the terms of the GNU General Public License version 3, as published
101+ * by the Free Software Foundation.
102+ *
103+ * This program is distributed in the hope that it will be useful, but
104+ * WITHOUT ANY WARRANTY; without even the implied warranties of
105+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
106+ * PURPOSE. See the GNU General Public License for more details.
107+ *
108+ * You should have received a copy of the GNU General Public License along
109+ * with this program. If not, see <http://www.gnu.org/licenses/>.
110+ */
111+
112+import QtQuick 2.4
113+import SystemSettings 1.0
114+import SystemSettings.ListItems 1.0 as SettingsListItems
115+import Ubuntu.Components 1.3
116+import Ubuntu.SystemSettings.Brightness 1.0
117+import Ubuntu.Settings.Menus 0.1 as Menus
118+
119+Column {
120+ visible: showAllUI
121+ objectName: "displayConfiguration_" + displayName
122+ anchors {
123+ left: parent.left
124+ right: parent.right
125+ }
126+
127+ Item {
128+ width: units.gu(1)
129+ height: units.gu(1)
130+ }
131+
132+ Label {
133+ text: displayName
134+
135+ anchors {
136+ left: parent.left
137+ right: parent.right
138+ margins: units.gu(2)
139+ }
140+
141+ Switch {
142+ objectName: "enabledSwitch"
143+ anchors {
144+ right: parent.right
145+ verticalCenter: parent.verticalCenter
146+ }
147+ checked: model.enabled
148+ onCheckedChanged: model.enabled = checked
149+ }
150+ }
151+
152+ SettingsItemTitle {
153+ text: i18n.tr("Rotation:")
154+ }
155+
156+ OptionSelector {
157+ id: rotationSelector
158+ objectName: "rotationSelector"
159+ property bool _expanded: false
160+ anchors {
161+ left: parent.left
162+ right: parent.right
163+ margins: units.gu(2)
164+ }
165+ containerHeight: itemHeight * 4
166+ model: [
167+ /* TRANSLATORS: None means no rotation, or
168+ 0 degrees. */
169+ i18n.tr("None"),
170+ i18n.tr("90° clockwise"),
171+ i18n.tr("180°"),
172+ i18n.tr("270°")
173+ ]
174+ onDelegateClicked: {
175+ expanded = !currentlyExpanded;
176+ orientation = index;
177+ }
178+ selectedIndex: orientation
179+ }
180+
181+ SettingsItemTitle {
182+ objectName: "resolutionLabel"
183+ text: availableModes.length > 1 ?
184+ i18n.tr("Resolution:") :
185+ /* TRANSLATORS: %1 is a display resolution, e.g.
186+ 1200x720x24. Unknown refers to an unknown
187+ resolution (in case of an error). */
188+ i18n.tr("Resolution: %1").arg(availableModes[mode] || i18n.tr("Unknown"))
189+ }
190+
191+ OptionSelector {
192+ id: resolutionSelector
193+ objectName: "resolutionSelector"
194+ property bool _expanded: false
195+ anchors {
196+ left: parent.left
197+ right: parent.right
198+ margins: units.gu(2)
199+ }
200+ visible: availableModes.length > 1
201+ containerHeight: itemHeight * availableModes.length
202+ model: availableModes
203+ onDelegateClicked: {
204+ expanded = !currentlyExpanded;
205+ mode = index;
206+ }
207+ delegate: OptionSelectorDelegate {
208+ text: modelData
209+ }
210+ selectedIndex: mode
211+ }
212+
213+ SettingsItemTitle {
214+ text: i18n.tr("Scale screen elements:")
215+ }
216+
217+ Menus.SliderMenu {
218+ id: scaleSlider
219+ objectName: "scaleSlider"
220+ minimumValue: 0.5
221+ maximumValue: 3.0
222+ value: model.scale
223+ minIcon: "image://theme/grip-large"
224+ maxIcon: "image://theme/view-grid-symbolic"
225+ function formatValue(v) { return v.toFixed(2) }
226+ live: true
227+ onValueChanged: model.scale = value
228+ }
229+}
230
231=== modified file 'plugins/brightness/PageComponent.qml'
232--- plugins/brightness/PageComponent.qml 2016-12-06 15:38:02 +0000
233+++ plugins/brightness/PageComponent.qml 2017-02-06 14:24:05 +0000
234@@ -21,6 +21,7 @@
235 import GSettings 1.0
236 import QtQuick 2.4
237 import SystemSettings 1.0
238+import SystemSettings.ListItems 1.0 as SettingsListItems
239 import Ubuntu.Components 1.3
240 import Ubuntu.Components.ListItems 1.3 as ListItem
241 import Ubuntu.SystemSettings.Brightness 1.0
242@@ -42,6 +43,7 @@
243
244 AethercastDisplays {
245 id: aethercastDisplays
246+ objectName: "aethercastDisplays"
247 onEnabledChanged: {
248 /* This is a hack to ensure the aethercast enabled switch stays
249 * in sync with the enabled property
250@@ -53,6 +55,7 @@
251
252 UbuntuBrightnessPanel {
253 id: brightnessPanel
254+ objectName: "brightnessPanel"
255 }
256
257 QDBusActionGroup {
258@@ -66,7 +69,12 @@
259
260 Flickable {
261 id: scrollWidget
262- anchors.fill: parent
263+ anchors {
264+ top: parent.top
265+ left: parent.left
266+ right: parent.right
267+ bottom: applyButtonBackground.top
268+ }
269 contentHeight: contentItem.childrenRect.height
270 boundsBehavior: (contentHeight > root.height) ?
271 Flickable.DragAndOvershootBounds :
272@@ -80,7 +88,7 @@
273 anchors.left: parent.left
274 anchors.right: parent.right
275
276- ListItem.Standard {
277+ SettingsListItems.Standard {
278 text: i18n.tr("Display brightness")
279 showDivider: false
280 }
281@@ -111,12 +119,13 @@
282 }
283 }
284
285- ListItem.Standard {
286+ SettingsListItems.Standard {
287 id: adjust
288 text: i18n.tr("Adjust automatically")
289 visible: brightnessPanel.powerdRunning &&
290 brightnessPanel.autoBrightnessAvailable
291- control: CheckBox {
292+
293+ CheckBox {
294 id: autoAdjustCheck
295 property bool serverChecked: gsettings.autoBrightness
296 onServerCheckedChanged: checked = serverChecked
297@@ -136,11 +145,13 @@
298 visible: brightnessPanel.widiSupported
299 }
300
301- ListItem.Standard {
302+ SettingsListItems.Standard {
303+ objectName: "externalDisplayControl"
304 text: i18n.tr("External display")
305 enabled: brightnessPanel.widiSupported
306 onClicked: enabledCheck.trigger()
307- control: Switch {
308+
309+ Switch {
310 id: enabledCheck
311 property bool serverChecked: aethercastDisplays.enabled
312 onServerCheckedChanged: checked = serverChecked
313@@ -151,16 +162,51 @@
314 }
315 }
316
317- ListItem.SingleValue {
318+ SettingsListItems.SingleValueProgression {
319 objectName: "displayCasting"
320 visible: brightnessPanel.widiSupported
321 enabled: aethercastDisplays.enabled
322 text: i18n.tr("Wireless display")
323 value: aethercastDisplays.state === "connected" ? i18n.tr("Connected") : i18n.tr("Not connected")
324- progression: true
325 onClicked: pageStack.addPageToNextColumn(
326 root, Qt.resolvedUrl("WifiDisplays.qml"))
327 }
328+
329+ Repeater {
330+ objectName: "displayConfigurationRepeater"
331+ model: brightnessPanel.connectedDisplays
332+
333+ delegate: MirDisplay {
334+
335+ }
336+ }
337+ }
338+ }
339+
340+ Rectangle {
341+ id: applyButtonBackground
342+ objectName: "applyButtonBackground"
343+ anchors {
344+ left: parent.left
345+ right: parent.right
346+ bottom: parent.bottom
347+ }
348+ color: Theme.palette.selected.background
349+
350+ visible: brightnessPanel.allDisplays.count > 0 && showAllUI
351+ height: units.gu(6)
352+
353+ Button {
354+ id: applyButton
355+ objectName: "applyButton"
356+ anchors {
357+ left: parent.left
358+ leftMargin: units.gu(1)
359+ verticalCenter: parent.verticalCenter
360+ }
361+ enabled: brightnessPanel.changedDisplays.count > 0
362+ text: i18n.tr("Apply Changes…")
363+ onClicked: brightnessPanel.applyDisplayConfiguration()
364 }
365 }
366 }
367
368=== modified file 'plugins/brightness/WifiDisplays.qml'
369--- plugins/brightness/WifiDisplays.qml 2016-12-02 15:32:35 +0000
370+++ plugins/brightness/WifiDisplays.qml 2017-02-06 14:24:05 +0000
371@@ -58,6 +58,26 @@
372 }
373 }
374
375+ AethercastDisplays {
376+ id: displays
377+ objectName: "aethercastDisplays"
378+
379+ onConnectError: {
380+ console.error("onConnectError: " + error);
381+ showError(error);
382+ }
383+
384+ // Log some info to help debug
385+ onConnectedDevicesChanged: {
386+ console.warn("ConnectedDevices: " + displays.connectedDevices.count);
387+ }
388+
389+ // Log some info to help debug
390+ onDisconnectedDevicesChanged: {
391+ console.warn("DisconnectedDevices: " + displays.disconnectedDevices.count);
392+ }
393+ }
394+
395 Flickable {
396 id: pageFlickable
397 anchors.fill: parent
398@@ -69,26 +89,8 @@
399 Flickable.DragAndOvershootBounds :
400 Flickable.StopAtBounds
401
402- AethercastDisplays {
403- id: displays
404-
405- onConnectError: {
406- console.error("onConnectError: " + error);
407- showError(error);
408- }
409-
410- // Log some info to help debug
411- onConnectedDevicesChanged: {
412- console.warn("ConnectedDevices: " + displays.connectedDevices.count);
413- }
414-
415- // Log some info to help debug
416- onDisconnectedDevicesChanged: {
417- console.warn("DisconnectedDevices: " + displays.disconnectedDevices.count);
418- }
419- }
420-
421 Label {
422+ objectName: "noDisplaysDetected"
423 anchors {
424 left: parent.left
425 right: parent.right
426@@ -115,6 +117,7 @@
427 }
428
429 Repeater {
430+ objectName: "displayRepeater"
431 model: displays.connectedDevices ? displays.connectedDevices : null
432 delegate: ListItem.Subtitled {
433 id: displayDelegate
434
435=== modified file 'plugins/brightness/brightness.cpp'
436--- plugins/brightness/brightness.cpp 2016-04-13 19:21:59 +0000
437+++ plugins/brightness/brightness.cpp 2017-02-06 14:24:05 +0000
438@@ -19,12 +19,20 @@
439 */
440
441 #include "brightness.h"
442+#include "displays/display.h"
443+#include "displays/helpers.h"
444+#include "displays/mirclient_impl.h"
445+#include "displays/output/output.h"
446+
447 #include <hybris/properties/properties.h>
448
449 #include <QDBusArgument>
450 #include <QDBusReply>
451 #include <QDBusMetaType>
452 #include <QDebug>
453+#include <QQmlEngine>
454+#include <QSharedPointer>
455+#include <QScopedPointer>
456
457 // Returned data from getBrightnessParams
458 struct BrightnessParams {
459@@ -54,16 +62,32 @@
460 return argument;
461 }
462
463-Brightness::Brightness(QObject *parent) :
464- QObject(parent),
465- m_systemBusConnection (QDBusConnection::systemBus()),
466- m_powerdIface ("com.canonical.powerd",
467- "/com/canonical/powerd",
468- "com.canonical.powerd",
469- m_systemBusConnection),
470- m_powerdRunning(false),
471- m_autoBrightnessAvailable(false)
472+Brightness::Brightness(QDBusConnection dbus,
473+ DisplayPlugin::MirClient *mirClient,
474+ QObject *parent)
475+ : QObject(parent)
476+ , m_systemBusConnection(dbus)
477+ , m_mirClient(mirClient)
478+ , m_powerdIface("com.canonical.powerd",
479+ "/com/canonical/powerd",
480+ "com.canonical.powerd",
481+ m_systemBusConnection)
482+ , m_powerdRunning(false)
483+ , m_autoBrightnessAvailable(false)
484+
485 {
486+ m_changedDisplays.filterOnUncommittedChanges(true);
487+ m_changedDisplays.setSourceModel(&m_displays);
488+
489+ m_connectedDisplays.filterOnConnected(true);
490+ m_connectedDisplays.setSourceModel(&m_displays);
491+
492+ if (m_mirClient->isConnected()) {
493+ refreshMirDisplays();
494+ connect(m_mirClient, SIGNAL(configurationChanged()),
495+ this, SLOT(refreshMirDisplays()));
496+ }
497+
498 qRegisterMetaType<BrightnessParams>();
499 m_powerdRunning = m_powerdIface.isValid();
500
501@@ -81,6 +105,14 @@
502 QDBusArgument result(reply.arguments()[0].value<QDBusArgument>());
503 BrightnessParams params = qdbus_cast<BrightnessParams>(result);
504 m_autoBrightnessAvailable = params.automatic;
505+
506+}
507+
508+Brightness::Brightness(QObject *parent) :
509+ Brightness(QDBusConnection::systemBus(),
510+ new DisplayPlugin::MirClientImpl(), parent)
511+{
512+ m_mirClient->setParent(this);
513 }
514
515 bool Brightness::getAutoBrightnessAvailable() const
516@@ -92,9 +124,57 @@
517 return m_powerdRunning;
518 }
519
520-bool Brightness::getWidiSupported() const
521+bool Brightness::getWidiSupported() const
522 {
523 char widi[PROP_VALUE_MAX];
524 property_get("ubuntu.widi.supported", widi, "0");
525 return (strcmp(widi, "0") > 0);
526 }
527+
528+QAbstractItemModel* Brightness::allDisplays()
529+{
530+ auto ret = &m_displays;
531+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
532+ return ret;
533+}
534+
535+QAbstractItemModel* Brightness::changedDisplays()
536+{
537+ auto ret = &m_changedDisplays;
538+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
539+ return ret;
540+}
541+
542+
543+QAbstractItemModel* Brightness::connectedDisplays()
544+{
545+ auto ret = &m_connectedDisplays;
546+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
547+ return ret;
548+}
549+
550+void Brightness::applyDisplayConfiguration()
551+{
552+ if (!m_mirClient->isConfigurationValid()) {
553+ qWarning() << Q_FUNC_INFO << "config invalid";
554+ return;
555+ }
556+
557+ auto conf = m_mirClient->getConfiguration();
558+ m_mirClient->applyConfiguration(conf);
559+}
560+
561+void Brightness::refreshMirDisplays()
562+{
563+ if (!m_mirClient->isConfigurationValid()) {
564+ qWarning() << Q_FUNC_INFO << "config invalid";
565+ return;
566+ }
567+
568+ Q_FOREACH(QSharedPointer<DisplayPlugin::Output> output, m_mirClient->outputs()) {
569+ auto display = QSharedPointer<DisplayPlugin::Display>(
570+ new DisplayPlugin::Display(output)
571+ );
572+ m_displays.addDisplay(display);
573+ }
574+}
575
576=== modified file 'plugins/brightness/brightness.h'
577--- plugins/brightness/brightness.h 2016-04-13 17:12:35 +0000
578+++ plugins/brightness/brightness.h 2017-02-06 14:24:05 +0000
579@@ -21,10 +21,14 @@
580 #ifndef BRIGHTNESS_H
581 #define BRIGHTNESS_H
582
583+#include "displays/displaymodel.h"
584+#include "displays/mirclient.h"
585+
586+#include <QAbstractItemModel>
587 #include <QDBusInterface>
588 #include <QObject>
589
590-class Brightness : public QObject
591+class Q_DECL_EXPORT Brightness : public QObject
592 {
593 Q_OBJECT
594 Q_PROPERTY( bool powerdRunning
595@@ -36,19 +40,42 @@
596 Q_PROPERTY (bool widiSupported
597 READ getWidiSupported
598 CONSTANT)
599+ Q_PROPERTY (QAbstractItemModel* allDisplays
600+ READ allDisplays
601+ CONSTANT)
602+ Q_PROPERTY (QAbstractItemModel* changedDisplays
603+ READ changedDisplays
604+ CONSTANT)
605+ Q_PROPERTY (QAbstractItemModel* connectedDisplays
606+ READ connectedDisplays
607+ CONSTANT)
608
609 public:
610- explicit Brightness(QObject *parent = 0);
611+ explicit Brightness(QObject *parent = Q_NULLPTR);
612+ explicit Brightness(QDBusConnection dbus,
613+ DisplayPlugin::MirClient *mirClient,
614+ QObject *parent = Q_NULLPTR);
615 bool getPowerdRunning() const;
616 bool getAutoBrightnessAvailable() const;
617 bool getWidiSupported() const;
618+ QAbstractItemModel* allDisplays();
619+ QAbstractItemModel* changedDisplays();
620+ QAbstractItemModel* connectedDisplays();
621+ Q_INVOKABLE void applyDisplayConfiguration();
622
623 private:
624 QDBusConnection m_systemBusConnection;
625+ DisplayPlugin::MirClient *m_mirClient = Q_NULLPTR;
626+ QDBusInterface m_powerdIface;
627 QString m_objectPath;
628- QDBusInterface m_powerdIface;
629 bool m_powerdRunning;
630 bool m_autoBrightnessAvailable;
631+ DisplayPlugin::DisplayModel m_displays;
632+ DisplayPlugin::DisplaysFilter m_changedDisplays;
633+ DisplayPlugin::DisplaysFilter m_connectedDisplays;
634+
635+private slots:
636+ void refreshMirDisplays();
637 };
638
639 #endif // BRIGHTNESS_H
640
641=== added directory 'plugins/brightness/displays'
642=== added file 'plugins/brightness/displays/display.cpp'
643--- plugins/brightness/displays/display.cpp 1970-01-01 00:00:00 +0000
644+++ plugins/brightness/displays/display.cpp 2017-02-06 14:24:05 +0000
645@@ -0,0 +1,177 @@
646+/*
647+ * This file is part of system-settings
648+ *
649+ * Copyright (C) 2017 Canonical Ltd.
650+ *
651+ * This program is free software: you can redistribute it and/or modify it
652+ * under the terms of the GNU General Public License version 3, as published
653+ * by the Free Software Foundation.
654+ *
655+ * This program is distributed in the hope that it will be useful, but
656+ * WITHOUT ANY WARRANTY; without even the implied warranties of
657+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
658+ * PURPOSE. See the GNU General Public License for more details.
659+ *
660+ * You should have received a copy of the GNU General Public License along
661+ * with this program. If not, see <http://www.gnu.org/licenses/>.
662+ */
663+
664+#include "display.h"
665+#include "helpers.h"
666+
667+#include <QDebug>
668+
669+namespace DisplayPlugin
670+{
671+Display::Display(QSharedPointer<Output> output, QObject *parent)
672+ : QObject(parent)
673+ , m_output(output)
674+{
675+ QObject::connect(this, SIGNAL(enabledChanged()),
676+ this, SLOT(changedSlot()));
677+ QObject::connect(this, SIGNAL(modeChanged()),
678+ this, SLOT(changedSlot()));
679+ QObject::connect(this, SIGNAL(orientationChanged()),
680+ this, SLOT(changedSlot()));
681+ QObject::connect(this, SIGNAL(scaleChanged()),
682+ this, SLOT(changedSlot()));
683+ QObject::connect(this, SIGNAL(uncommittedChangesChanged()),
684+ this, SLOT(changedSlot()));
685+
686+ storeConfiguration();
687+ changedSlot();
688+}
689+
690+void Display::storeConfiguration()
691+{
692+ m_storedConfig["enabled"] = enabled();
693+ m_storedConfig["mode"] = QVariant::fromValue(mode());
694+ m_storedConfig["orientation"] = QVariant::fromValue(orientation());
695+ m_storedConfig["scale"] = scale();
696+}
697+
698+bool Display::hasChanged() const
699+{
700+ bool considerModes = availableModes().size() > 0;
701+ return (
702+ m_storedConfig["enabled"].toBool() != enabled()
703+ || (considerModes && (
704+ m_storedConfig["mode"].value<QSharedPointer<OutputMode>>()->toString() != mode()->toString()))
705+ || m_storedConfig["orientation"].value<Enums::Orientation>() != orientation()
706+ || m_storedConfig["scale"].toFloat() != scale()
707+ );
708+}
709+
710+int Display::id() const
711+{
712+ return m_output->getId();
713+}
714+
715+QString Display::name() const
716+{
717+ return m_name;
718+}
719+
720+QString Display::type() const
721+{
722+ return Helpers::typeToString(m_output->getType());
723+}
724+
725+bool Display::connected() const
726+{
727+ return m_output->getConnectionState() == Enums::ConnectionState::Connected;
728+}
729+
730+bool Display::enabled() const
731+{
732+ return m_output->isEnabled();
733+}
734+
735+QSharedPointer<OutputMode> Display::mode() const
736+{
737+ return m_output->getCurrentMode();
738+}
739+
740+QList<QSharedPointer<OutputMode>> Display::availableModes() const
741+{
742+ return m_output->getAvailableModes();
743+}
744+
745+Enums::Orientation Display::orientation() const
746+{
747+ return m_output->getOrientation();
748+}
749+
750+float Display::scale() const
751+{
752+ return m_output->getScaleFactor();
753+}
754+
755+bool Display::uncommittedChanges() const
756+{
757+ return m_uncommittedChanges;
758+}
759+
760+uint Display::physicalWidthMm() const
761+{
762+ return (uint) m_output->getPhysicalWidthMm();
763+}
764+
765+uint Display::physicalHeightMm() const
766+{
767+ return (uint) m_output->getPhysicalHeightMm();
768+}
769+
770+Enums::PowerMode Display::powerMode() const
771+{
772+ return m_output->getPowerMode();
773+}
774+
775+void Display::setEnabled(const bool &enabled)
776+{
777+ bool wasEnabled = m_output->isEnabled();
778+ m_output->setEnabled(enabled);
779+
780+ if (wasEnabled != enabled) {
781+ Q_EMIT enabledChanged();
782+ }
783+}
784+
785+void Display::setMode(const QSharedPointer<OutputMode> &mode)
786+{
787+ if (mode != this->mode()) {
788+ m_output->setCurrentMode(mode);
789+ Q_EMIT modeChanged();
790+ }
791+}
792+
793+void Display::setOrientation(const Enums::Orientation &orientation)
794+{
795+ if (orientation != this->orientation()) {
796+ m_output->setOrientation(orientation);
797+ Q_EMIT orientationChanged();
798+ }
799+}
800+
801+void Display::setScale(const float &scale)
802+{
803+ if (scale != this->scale()) {
804+ m_output->setScaleFactor(scale);
805+ Q_EMIT scaleChanged();
806+ }
807+}
808+
809+void Display::setUncommitedChanges(const bool uncommittedChanges)
810+{
811+ if (m_uncommittedChanges != uncommittedChanges) {
812+ m_uncommittedChanges = uncommittedChanges;
813+ Q_EMIT uncommittedChangesChanged();
814+ }
815+}
816+
817+void Display::changedSlot()
818+{
819+ setUncommitedChanges(hasChanged());
820+ Q_EMIT displayChanged(this);
821+}
822+} // DisplayPlugin
823
824=== added file 'plugins/brightness/displays/display.h'
825--- plugins/brightness/displays/display.h 1970-01-01 00:00:00 +0000
826+++ plugins/brightness/displays/display.h 2017-02-06 14:24:05 +0000
827@@ -0,0 +1,89 @@
828+/*
829+ * This file is part of system-settings
830+ *
831+ * Copyright (C) 2017 Canonical Ltd.
832+ *
833+ * This program is free software: you can redistribute it and/or modify it
834+ * under the terms of the GNU General Public License version 3, as published
835+ * by the Free Software Foundation.
836+ *
837+ * This program is distributed in the hope that it will be useful, but
838+ * WITHOUT ANY WARRANTY; without even the implied warranties of
839+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
840+ * PURPOSE. See the GNU General Public License for more details.
841+ *
842+ * You should have received a copy of the GNU General Public License along
843+ * with this program. If not, see <http://www.gnu.org/licenses/>.
844+ */
845+
846+#ifndef DISPLAY_H
847+#define DISPLAY_H
848+
849+#include "enums.h"
850+#include "output/output.h"
851+
852+#include <QList>
853+#include <QObject>
854+#include <QString>
855+#include <QStringList>
856+#include <QSharedPointer>
857+#include <QVariantMap>
858+
859+namespace DisplayPlugin
860+{
861+class Q_DECL_EXPORT Display : public QObject
862+{
863+ Q_OBJECT
864+
865+public:
866+ explicit Display(QSharedPointer<Output> output, QObject *parent = Q_NULLPTR);
867+ ~Display() {};
868+
869+ int id() const;
870+ QString name() const;
871+ QString type() const;
872+ bool connected() const;
873+ bool enabled() const;
874+ QSharedPointer<OutputMode> mode() const;
875+ QList<QSharedPointer<OutputMode>> availableModes() const;
876+ Enums::Orientation orientation() const;
877+ float scale() const;
878+ bool uncommittedChanges() const;
879+ uint physicalWidthMm() const;
880+ uint physicalHeightMm() const;
881+ Enums::PowerMode powerMode() const;
882+
883+ void setEnabled(const bool &enabled);
884+ void setMode(const QSharedPointer<OutputMode> &mode);
885+ void setOrientation(const Enums::Orientation &orientation);
886+ void setScale(const float &scale);
887+
888+Q_SIGNALS:
889+ void mirroredChanged();
890+ void connectedChanged();
891+ void enabledChanged();
892+ void modeChanged();
893+ void modesChanged();
894+ void orientationChanged();
895+ void scaleChanged();
896+ void uncommittedChangesChanged();
897+ void displayChanged(const Display *display);
898+
899+protected:
900+ void setUncommitedChanges(const bool uncommittedChanges);
901+ void storeConfiguration();
902+ QString m_name = QString::null;
903+ bool m_uncommittedChanges = false;
904+ QSharedPointer<Output> m_output = QSharedPointer<Output>(Q_NULLPTR);
905+
906+protected slots:
907+ void changedSlot();
908+
909+private:
910+ bool hasChanged() const;
911+ QVariantMap m_storedConfig;
912+};
913+
914+} // DisplayPlugin
915+
916+#endif // DISPLAY_H
917
918=== added file 'plugins/brightness/displays/displaymodel.cpp'
919--- plugins/brightness/displays/displaymodel.cpp 1970-01-01 00:00:00 +0000
920+++ plugins/brightness/displays/displaymodel.cpp 2017-02-06 14:24:05 +0000
921@@ -0,0 +1,256 @@
922+/*
923+ * This file is part of system-settings
924+ *
925+ * Copyright (C) 2017 Canonical Ltd.
926+ *
927+ * This program is free software: you can redistribute it and/or modify it
928+ * under the terms of the GNU General Public License version 3, as published
929+ * by the Free Software Foundation.
930+ *
931+ * This program is distributed in the hope that it will be useful, but
932+ * WITHOUT ANY WARRANTY; without even the implied warranties of
933+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
934+ * PURPOSE. See the GNU General Public License for more details.
935+ *
936+ * You should have received a copy of the GNU General Public License along
937+ * with this program. If not, see <http://www.gnu.org/licenses/>.
938+ */
939+
940+#include "displaymodel.h"
941+
942+namespace DisplayPlugin
943+{
944+DisplayModel::DisplayModel(QObject *parent) : QAbstractListModel(parent)
945+{
946+}
947+
948+DisplayModel::~DisplayModel()
949+{
950+}
951+
952+int DisplayModel::rowCount(const QModelIndex &parent) const
953+{
954+ Q_UNUSED(parent);
955+ return m_displays.count();
956+}
957+
958+QVariant DisplayModel::data(const QModelIndex &index, int role) const
959+{
960+ QVariant ret;
961+
962+ if ((0 <= index.row()) && (index.row() < m_displays.size())) {
963+
964+ auto display = m_displays[index.row()];
965+
966+ switch (role) {
967+ case Qt::DisplayRole:
968+ ret = display->name();
969+ break;
970+ case TypeRole:
971+ ret = display->type();
972+ break;
973+ case ConnectedRole:
974+ ret = display->connected();
975+ break;
976+ case EnabledRole:
977+ ret = display->enabled();
978+ break;
979+ case ModeRole:
980+ ret = display->availableModes().indexOf(display->mode());
981+ break;
982+ case AvailableModesRole: {
983+ QStringList modes;
984+ Q_FOREACH(const QSharedPointer<OutputMode> mode,
985+ display->availableModes()) {
986+ modes << mode->toString();
987+ }
988+ ret = modes;
989+ }
990+ break;
991+ case OrientationRole:
992+ ret = (uint) display->orientation();
993+ break;
994+ case ScaleRole:
995+ ret = display->scale();
996+ break;
997+ case UncommittedChangesRole:
998+ ret = display->uncommittedChanges();
999+ break;
1000+ }
1001+ }
1002+
1003+ return ret;
1004+}
1005+
1006+bool DisplayModel::setData(const QModelIndex &index, const QVariant &value,
1007+ int role)
1008+{
1009+ if ((0 <= index.row()) && (index.row() < m_displays.size())) {
1010+ auto display = m_displays[index.row()];
1011+
1012+ switch (role) {
1013+ case EnabledRole:
1014+ display->setEnabled(value.toBool());
1015+ break;
1016+ case ModeRole:
1017+ display->setMode(display->availableModes().at(value.toInt()));
1018+ break;
1019+ case OrientationRole:
1020+ display->setOrientation((Enums::Orientation) value.toUInt());
1021+ break;
1022+ case ScaleRole:
1023+ display->setScale(value.toFloat());
1024+ break;
1025+ case Qt::DisplayRole:
1026+ case TypeRole:
1027+ case ConnectedRole:
1028+ case AvailableModesRole:
1029+ case UncommittedChangesRole:
1030+ default:
1031+ return false;
1032+ }
1033+ return true;
1034+ } else {
1035+ return false;
1036+ }
1037+}
1038+
1039+
1040+QHash<int,QByteArray> DisplayModel::roleNames() const
1041+{
1042+ static QHash<int,QByteArray> names;
1043+ if (Q_UNLIKELY(names.empty())) {
1044+ names[Qt::DisplayRole] = "displayName";
1045+ names[ConnectedRole] = "connected";
1046+ names[EnabledRole] = "enabled";
1047+ names[ModeRole] = "mode";
1048+ names[AvailableModesRole] = "availableModes";
1049+ names[OrientationRole] = "orientation";
1050+ names[ScaleRole] = "scale";
1051+ names[UncommittedChangesRole] = "uncommittedChanges";
1052+ }
1053+ return names;
1054+}
1055+
1056+void DisplayModel::addDisplay(const QSharedPointer<Display> &display)
1057+{
1058+ int row = findRowFromId(display->id());
1059+
1060+ if (row >= 0) { // update existing display
1061+ m_displays[row] = display;
1062+ emitRowChanged(row);
1063+ } else { // add new display
1064+ row = m_displays.size();
1065+ beginInsertRows(QModelIndex(), row, row);
1066+ m_displays.append(display);
1067+ endInsertRows();
1068+ }
1069+
1070+ if (display) {
1071+ QObject::connect(display.data(), SIGNAL(displayChanged(const Display*)),
1072+ this, SLOT(displayChangedSlot(const Display*)));
1073+ }
1074+
1075+ Q_EMIT countChanged();
1076+}
1077+
1078+void DisplayModel::emitRowChanged(const int &row)
1079+{
1080+ if (0 <= row && row < m_displays.size()) {
1081+ QModelIndex qmi = index(row, 0);
1082+ Q_EMIT dataChanged(qmi, qmi);
1083+ }
1084+}
1085+
1086+void DisplayModel::displayChangedSlot(const Display *display)
1087+{
1088+ // find the row that goes with this display
1089+ int row = -1;
1090+ if (display != nullptr)
1091+ for (int i = 0, n = m_displays.size(); row == -1 && i < n; i++)
1092+ if (m_displays[i].data() == display)
1093+ row = i;
1094+
1095+ if (row != -1)
1096+ emitRowChanged(row);
1097+}
1098+
1099+QSharedPointer<Display> DisplayModel::getById(const int &id)
1100+{
1101+ Q_FOREACH(auto display, m_displays) {
1102+ if (display->id() == id)
1103+ return display;
1104+ }
1105+ return QSharedPointer<Display>(nullptr);
1106+}
1107+
1108+int DisplayModel::findRowFromId(const int &id)
1109+{
1110+ for (int i = 0; i < m_displays.size(); i++) {
1111+ if (m_displays[i]->id() == id)
1112+ return i;
1113+ }
1114+ return -1;
1115+}
1116+
1117+DisplaysFilter::DisplaysFilter()
1118+{
1119+ connect(this, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
1120+ this, SLOT(rowsChanged(const QModelIndex&, int, int)));
1121+ connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
1122+ this, SLOT(rowsChanged(const QModelIndex&, int, int)));
1123+}
1124+
1125+bool DisplaysFilter::lessThan(const QModelIndex &left,
1126+ const QModelIndex &right) const
1127+{
1128+ const QString a = sourceModel()->data(left, Qt::DisplayRole).value<QString>();
1129+ const QString b = sourceModel()->data(right, Qt::DisplayRole).value<QString>();
1130+ return a < b;
1131+}
1132+
1133+void DisplaysFilter::filterOnUncommittedChanges(const bool uncommitted)
1134+{
1135+ m_uncommittedChanges = uncommitted;
1136+ m_uncommittedChangesEnabled = true;
1137+ invalidateFilter();
1138+}
1139+
1140+void DisplaysFilter::filterOnConnected(const bool connected)
1141+{
1142+ m_connected = connected;
1143+ m_connectedEnabled = true;
1144+ invalidateFilter();
1145+}
1146+
1147+bool DisplaysFilter::filterAcceptsRow(int sourceRow,
1148+ const QModelIndex &sourceParent) const
1149+{
1150+ bool accepts = true;
1151+ QModelIndex childIndex = sourceModel()->index(sourceRow, 0, sourceParent);
1152+
1153+ if (accepts && m_uncommittedChangesEnabled) {
1154+ const bool uncommittedChanges = childIndex.model()->data(
1155+ childIndex, DisplayModel::UncommittedChangesRole
1156+ ).value<bool>();
1157+ accepts = (m_uncommittedChanges == uncommittedChanges);
1158+ }
1159+
1160+ if (accepts && m_connectedEnabled) {
1161+ const bool connected = childIndex.model()->data(
1162+ childIndex, DisplayModel::ConnectedRole
1163+ ).value<bool>();
1164+ accepts = (m_connected == connected);
1165+ }
1166+
1167+ return accepts;
1168+}
1169+
1170+void DisplaysFilter::rowsChanged(const QModelIndex &parent, int first, int last)
1171+{
1172+ Q_UNUSED(parent)
1173+ Q_UNUSED(first)
1174+ Q_UNUSED(last)
1175+ Q_EMIT countChanged();
1176+}
1177+} // DisplayPlugin
1178
1179=== added file 'plugins/brightness/displays/displaymodel.h'
1180--- plugins/brightness/displays/displaymodel.h 1970-01-01 00:00:00 +0000
1181+++ plugins/brightness/displays/displaymodel.h 2017-02-06 14:24:05 +0000
1182@@ -0,0 +1,113 @@
1183+/*
1184+ * This file is part of system-settings
1185+ *
1186+ * Copyright (C) 2017 Canonical Ltd.
1187+ *
1188+ * This program is free software: you can redistribute it and/or modify it
1189+ * under the terms of the GNU General Public License version 3, as published
1190+ * by the Free Software Foundation.
1191+ *
1192+ * This program is distributed in the hope that it will be useful, but
1193+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1194+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1195+ * PURPOSE. See the GNU General Public License for more details.
1196+ *
1197+ * You should have received a copy of the GNU General Public License along
1198+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1199+ */
1200+
1201+#ifndef DISPLAY_MODEL_H
1202+#define DISPLAY_MODEL_H
1203+
1204+#include "display.h"
1205+
1206+#include <QAbstractListModel>
1207+#include <QByteArray>
1208+#include <QHash>
1209+#include <QList>
1210+#include <QModelIndex>
1211+#include <QSharedPointer>
1212+#include <QSortFilterProxyModel>
1213+#include <QVariant>
1214+
1215+namespace DisplayPlugin
1216+{
1217+class Q_DECL_EXPORT DisplayModel : public QAbstractListModel
1218+{
1219+ Q_OBJECT
1220+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
1221+public:
1222+ explicit DisplayModel(QObject *parent = Q_NULLPTR);
1223+ ~DisplayModel();
1224+
1225+ enum Roles
1226+ {
1227+ // Qt::DisplayRole holds device name
1228+ TypeRole = Qt::UserRole,
1229+ ConnectedRole,
1230+ EnabledRole,
1231+ ModeRole,
1232+ AvailableModesRole,
1233+ OrientationRole,
1234+ ScaleRole,
1235+ UncommittedChangesRole,
1236+ LastRole = UncommittedChangesRole
1237+ };
1238+
1239+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
1240+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
1241+ bool setData(const QModelIndex &index, const QVariant &value,
1242+ int role = Qt::EditRole);
1243+ QHash<int,QByteArray> roleNames() const;
1244+ void addDisplay(const QSharedPointer<Display> &display);
1245+
1246+ // Deprecated
1247+ QSharedPointer<Display> getById(const int &id);
1248+ // Deprecated
1249+ int findRowFromId(const int &id);
1250+
1251+Q_SIGNALS:
1252+ void countChanged();
1253+
1254+protected:
1255+ void emitRowChanged(const int &row);
1256+
1257+private:
1258+ QList<QSharedPointer<Display> > m_displays;
1259+
1260+private slots:
1261+ void displayChangedSlot(const Display *display);
1262+};
1263+
1264+class DisplaysFilter : public QSortFilterProxyModel
1265+{
1266+ Q_OBJECT
1267+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
1268+
1269+public:
1270+ DisplaysFilter();
1271+ virtual ~DisplaysFilter() {}
1272+
1273+ void filterOnUncommittedChanges(const bool uncommitted);
1274+ void filterOnConnected(const bool connected);
1275+
1276+Q_SIGNALS:
1277+ void countChanged();
1278+
1279+protected:
1280+ virtual bool filterAcceptsRow(int, const QModelIndex&) const;
1281+ virtual bool lessThan(const QModelIndex&, const QModelIndex&) const;
1282+
1283+private:
1284+ bool m_uncommittedChanges = false;
1285+ bool m_uncommittedChangesEnabled = false;
1286+
1287+ bool m_connected = false;
1288+ bool m_connectedEnabled = false;
1289+
1290+private slots:
1291+ void rowsChanged(const QModelIndex &parent, int first, int last);
1292+};
1293+} // DisplayPlugin
1294+
1295+#endif // DISPLAY_MODEL_H
1296
1297=== added file 'plugins/brightness/displays/enums.h'
1298--- plugins/brightness/displays/enums.h 1970-01-01 00:00:00 +0000
1299+++ plugins/brightness/displays/enums.h 2017-02-06 14:24:05 +0000
1300@@ -0,0 +1,79 @@
1301+/*
1302+ * This file is part of system-settings
1303+ *
1304+ * Copyright (C) 2017 Canonical Ltd.
1305+ *
1306+ * This program is free software: you can redistribute it and/or modify it
1307+ * under the terms of the GNU General Public License version 3, as published
1308+ * by the Free Software Foundation.
1309+ *
1310+ * This program is distributed in the hope that it will be useful, but
1311+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1312+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1313+ * PURPOSE. See the GNU General Public License for more details.
1314+ *
1315+ * You should have received a copy of the GNU General Public License along
1316+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1317+ */
1318+
1319+#ifndef DISPLAYS_ENUMS_H
1320+#define DISPLAYS_ENUMS_H
1321+
1322+#include <QObject>
1323+
1324+namespace DisplayPlugin
1325+{
1326+class Q_DECL_EXPORT Enums
1327+{
1328+ Q_GADGET
1329+public:
1330+ enum class ConnectionState : uint
1331+ {
1332+ Disconnected = 0,
1333+ Connected,
1334+ Unknown
1335+ };
1336+ Q_ENUM(ConnectionState);
1337+
1338+ enum class Orientation : uint {
1339+ NormalOrientation = 0,
1340+ PortraitModeOrientation,
1341+ LandscapeInvertedModeOrientation,
1342+ PortraitInvertedModeOrientation
1343+ };
1344+
1345+ Q_ENUM(Orientation)
1346+
1347+ enum class PowerMode : uint {
1348+ OnMode = 0,
1349+ StandbyMode,
1350+ SuspendMode,
1351+ OffMode
1352+ };
1353+ Q_ENUM(PowerMode)
1354+
1355+ enum class OutputType : uint {
1356+ OutputTypeUnknown = 0,
1357+ OutputTypeVga,
1358+ OutputTypeDvii,
1359+ OutputTypeDvid,
1360+ OutputTypeDvia,
1361+ OutputTypeComposite,
1362+ OutputTypeSvideo,
1363+ OutputTypeLvds,
1364+ OutputTypeComponent,
1365+ OutputTypeNinepindin,
1366+ OutputTypeDisplayport,
1367+ OutputTypeHdmia,
1368+ OutputTypeHdmib,
1369+ OutputTypeTv,
1370+ OutputTypeEdp,
1371+ OutputTypeVirtual,
1372+ OutputTypeDsi,
1373+ OutputTypeDpi,
1374+ };
1375+ Q_ENUM(OutputType)
1376+};
1377+} // DisplayPlugin
1378+
1379+#endif // DISPLAYS_ENUMS_H
1380
1381=== added file 'plugins/brightness/displays/helpers.cpp'
1382--- plugins/brightness/displays/helpers.cpp 1970-01-01 00:00:00 +0000
1383+++ plugins/brightness/displays/helpers.cpp 2017-02-06 14:24:05 +0000
1384@@ -0,0 +1,216 @@
1385+/*
1386+ * This file is part of system-settings
1387+ *
1388+ * Copyright (C) 2017 Canonical Ltd.
1389+ *
1390+ * This program is free software: you can redistribute it and/or modify it
1391+ * under the terms of the GNU General Public License version 3, as published
1392+ * by the Free Software Foundation.
1393+ *
1394+ * This program is distributed in the hope that it will be useful, but
1395+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1396+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1397+ * PURPOSE. See the GNU General Public License for more details.
1398+ *
1399+ * You should have received a copy of the GNU General Public License along
1400+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1401+ */
1402+
1403+#include "helpers.h"
1404+
1405+namespace DisplayPlugin
1406+{
1407+Enums::Orientation Helpers::mirOrientationToOrientation(const MirOrientation &mirOrientation)
1408+{
1409+ Enums::Orientation orientation;
1410+ switch (mirOrientation) {
1411+ case mir_orientation_normal:
1412+ orientation = Enums::Orientation::NormalOrientation;
1413+ break;
1414+ case mir_orientation_left:
1415+ orientation = Enums::Orientation::PortraitModeOrientation;
1416+ break;
1417+ case mir_orientation_inverted:
1418+ orientation = Enums::Orientation::LandscapeInvertedModeOrientation;
1419+ break;
1420+ case mir_orientation_right:
1421+ orientation = Enums::Orientation::PortraitInvertedModeOrientation;
1422+ break;
1423+ default:
1424+ orientation = Enums::Orientation::NormalOrientation;
1425+ }
1426+ return orientation;
1427+}
1428+
1429+MirOrientation Helpers::orientationToMirOrientation(const Enums::Orientation &orientation)
1430+{
1431+ MirOrientation mirOrientation;
1432+ switch (orientation) {
1433+ case Enums::Orientation::NormalOrientation:
1434+ mirOrientation = mir_orientation_normal;
1435+ break;
1436+ case Enums::Orientation::PortraitModeOrientation:
1437+ mirOrientation = mir_orientation_left;
1438+ break;
1439+ case Enums::Orientation::LandscapeInvertedModeOrientation:
1440+ mirOrientation = mir_orientation_inverted;
1441+ break;
1442+ case Enums::Orientation::PortraitInvertedModeOrientation:
1443+ mirOrientation = mir_orientation_right;
1444+ break;
1445+ default:
1446+ mirOrientation = mir_orientation_normal;
1447+ }
1448+ return mirOrientation;
1449+}
1450+
1451+QString Helpers::typeToString(const Enums::OutputType &type)
1452+{
1453+ QString ret;
1454+ switch (type) {
1455+ default:
1456+ case Enums::OutputType::OutputTypeUnknown:
1457+ ret = "";
1458+ break;
1459+ case Enums::OutputType::OutputTypeVga:
1460+ ret = "vga";
1461+ break;
1462+ case Enums::OutputType::OutputTypeDvii:
1463+ ret = "dvii";
1464+ break;
1465+ case Enums::OutputType::OutputTypeDvid:
1466+ ret = "dvid";
1467+ break;
1468+ case Enums::OutputType::OutputTypeDvia:
1469+ ret = "dvia";
1470+ break;
1471+ case Enums::OutputType::OutputTypeComposite:
1472+ ret = "composite";
1473+ break;
1474+ case Enums::OutputType::OutputTypeSvideo:
1475+ ret = "svideo";
1476+ break;
1477+ case Enums::OutputType::OutputTypeLvds:
1478+ ret = "lvds";
1479+ break;
1480+ case Enums::OutputType::OutputTypeComponent:
1481+ ret = "component";
1482+ break;
1483+ case Enums::OutputType::OutputTypeNinepindin:
1484+ ret = "ninepindin";
1485+ break;
1486+ case Enums::OutputType::OutputTypeDisplayport:
1487+ ret = "displayport";
1488+ break;
1489+ case Enums::OutputType::OutputTypeHdmia:
1490+ ret = "hdmia";
1491+ break;
1492+ case Enums::OutputType::OutputTypeHdmib:
1493+ ret = "hdmib";
1494+ break;
1495+ case Enums::OutputType::OutputTypeTv:
1496+ ret = "tv";
1497+ break;
1498+ case Enums::OutputType::OutputTypeEdp:
1499+ ret = "edp";
1500+ break;
1501+ case Enums::OutputType::OutputTypeVirtual:
1502+ ret = "virtual";
1503+ break;
1504+ case Enums::OutputType::OutputTypeDsi:
1505+ ret = "dsi";
1506+ break;
1507+ case Enums::OutputType::OutputTypeDpi:
1508+ ret = "dpi";
1509+ break;
1510+ }
1511+
1512+ return ret;
1513+}
1514+
1515+Enums::PowerMode Helpers::mirPowerModeToPowerMode(const MirPowerMode &mode)
1516+{
1517+ switch(mode) {
1518+ case mir_power_mode_on:
1519+ return Enums::PowerMode::OnMode;
1520+ case mir_power_mode_standby:
1521+ return Enums::PowerMode::StandbyMode;
1522+ case mir_power_mode_suspend:
1523+ return Enums::PowerMode::SuspendMode;
1524+ case mir_power_mode_off:
1525+ return Enums::PowerMode::OffMode;
1526+ }
1527+ return Enums::PowerMode::OffMode;
1528+}
1529+
1530+MirPowerMode Helpers::powerModeToMirPowerMode(const Enums::PowerMode &mode)
1531+{
1532+ switch(mode) {
1533+ case Enums::PowerMode::OnMode:
1534+ return mir_power_mode_on;
1535+ case Enums::PowerMode::StandbyMode:
1536+ return mir_power_mode_standby;
1537+ case Enums::PowerMode::SuspendMode:
1538+ return mir_power_mode_suspend;
1539+ case Enums::PowerMode::OffMode:
1540+ return mir_power_mode_off;
1541+ }
1542+ return mir_power_mode_off;
1543+}
1544+
1545+Enums::OutputType Helpers::mirOutputTypeToOutputType(const MirOutputType &type)
1546+{
1547+ switch (type) {
1548+ default:
1549+ case MirOutputType::mir_output_type_unknown:
1550+ return Enums::OutputType::OutputTypeUnknown;
1551+ case MirOutputType::mir_output_type_vga:
1552+ return Enums::OutputType::OutputTypeVga;
1553+ case MirOutputType::mir_output_type_dvii:
1554+ return Enums::OutputType::OutputTypeDvii;
1555+ case MirOutputType::mir_output_type_dvid:
1556+ return Enums::OutputType::OutputTypeDvid;
1557+ case MirOutputType::mir_output_type_dvia:
1558+ return Enums::OutputType::OutputTypeDvia;
1559+ case MirOutputType::mir_output_type_composite:
1560+ return Enums::OutputType::OutputTypeComposite;
1561+ case MirOutputType::mir_output_type_svideo:
1562+ return Enums::OutputType::OutputTypeSvideo;
1563+ case MirOutputType::mir_output_type_lvds:
1564+ return Enums::OutputType::OutputTypeLvds;
1565+ case MirOutputType::mir_output_type_component:
1566+ return Enums::OutputType::OutputTypeComponent;
1567+ case MirOutputType::mir_output_type_ninepindin:
1568+ return Enums::OutputType::OutputTypeNinepindin;
1569+ case MirOutputType::mir_output_type_displayport:
1570+ return Enums::OutputType::OutputTypeDisplayport;
1571+ case MirOutputType::mir_output_type_hdmia:
1572+ return Enums::OutputType::OutputTypeHdmia;
1573+ case MirOutputType::mir_output_type_hdmib:
1574+ return Enums::OutputType::OutputTypeHdmib;
1575+ case MirOutputType::mir_output_type_tv:
1576+ return Enums::OutputType::OutputTypeTv;
1577+ case MirOutputType::mir_output_type_edp:
1578+ return Enums::OutputType::OutputTypeEdp;
1579+ case MirOutputType::mir_output_type_virtual:
1580+ return Enums::OutputType::OutputTypeVirtual;
1581+ case MirOutputType::mir_output_type_dsi:
1582+ return Enums::OutputType::OutputTypeDsi;
1583+ case MirOutputType::mir_output_type_dpi:
1584+ return Enums::OutputType::OutputTypeDpi;
1585+ }
1586+}
1587+
1588+Enums::ConnectionState Helpers::mirConnectionStateToConnectionState(const MirOutputConnectionState &state)
1589+{
1590+ switch (state) {
1591+ default:
1592+ case mir_output_connection_state_disconnected:
1593+ return Enums::ConnectionState::Disconnected;
1594+ case mir_output_connection_state_connected:
1595+ return Enums::ConnectionState::Connected;
1596+ case mir_output_connection_state_unknown:
1597+ return Enums::ConnectionState::Unknown;
1598+ }
1599+}
1600+} // DisplayPlugin
1601
1602=== added file 'plugins/brightness/displays/helpers.h'
1603--- plugins/brightness/displays/helpers.h 1970-01-01 00:00:00 +0000
1604+++ plugins/brightness/displays/helpers.h 2017-02-06 14:24:05 +0000
1605@@ -0,0 +1,43 @@
1606+/*
1607+ * This file is part of system-settings
1608+ *
1609+ * Copyright (C) 2017 Canonical Ltd.
1610+ *
1611+ * This program is free software: you can redistribute it and/or modify it
1612+ * under the terms of the GNU General Public License version 3, as published
1613+ * by the Free Software Foundation.
1614+ *
1615+ * This program is distributed in the hope that it will be useful, but
1616+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1617+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1618+ * PURPOSE. See the GNU General Public License for more details.
1619+ *
1620+ * You should have received a copy of the GNU General Public License along
1621+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1622+ */
1623+
1624+#ifndef DISPLAY_PLUGIN_HELPERS_H
1625+#define DISPLAY_PLUGIN_HELPERS_H
1626+
1627+#include "enums.h"
1628+#include "display.h"
1629+
1630+#include <mir_toolkit/mir_client_library.h>
1631+
1632+namespace DisplayPlugin
1633+{
1634+struct Q_DECL_EXPORT Helpers
1635+{
1636+public:
1637+ static Enums::Orientation mirOrientationToOrientation(const MirOrientation &mirOrientation);
1638+ static MirOrientation orientationToMirOrientation(const Enums::Orientation &orientation);
1639+ static QString typeToString(const Enums::OutputType &type);
1640+ static QString mirModeToString(const MirDisplayOutputType &type);
1641+ static Enums::PowerMode mirPowerModeToPowerMode(const MirPowerMode &mode);
1642+ static MirPowerMode powerModeToMirPowerMode(const Enums::PowerMode &mode);
1643+ static Enums::OutputType mirOutputTypeToOutputType(const MirOutputType &type);
1644+ static Enums::ConnectionState mirConnectionStateToConnectionState(const MirOutputConnectionState &state);
1645+};
1646+} // DisplayPlugin
1647+
1648+#endif // DISPLAY_PLUGIN_HELPERS_H
1649
1650=== added file 'plugins/brightness/displays/mirclient.h'
1651--- plugins/brightness/displays/mirclient.h 1970-01-01 00:00:00 +0000
1652+++ plugins/brightness/displays/mirclient.h 2017-02-06 14:24:05 +0000
1653@@ -0,0 +1,50 @@
1654+/*
1655+ * This file is part of system-settings
1656+ *
1657+ * Copyright (C) 2017 Canonical Ltd.
1658+ *
1659+ * This program is free software: you can redistribute it and/or modify it
1660+ * under the terms of the GNU General Public License version 3, as published
1661+ * by the Free Software Foundation.
1662+ *
1663+ * This program is distributed in the hope that it will be useful, but
1664+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1665+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1666+ * PURPOSE. See the GNU General Public License for more details.
1667+ *
1668+ * You should have received a copy of the GNU General Public License along
1669+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1670+ */
1671+
1672+#ifndef MIRCLIENT_H
1673+#define MIRCLIENT_H
1674+
1675+#include "output/output.h"
1676+
1677+#include <mir_toolkit/mir_client_library.h>
1678+#include <QList>
1679+#include <QObject>
1680+#include <QSharedPointer>
1681+
1682+namespace DisplayPlugin
1683+{
1684+class Q_DECL_EXPORT MirClient : public QObject
1685+{
1686+ Q_OBJECT
1687+public:
1688+ explicit MirClient(QObject *parent = Q_NULLPTR) : QObject(parent) {}
1689+ virtual ~MirClient() {};
1690+ virtual MirDisplayConfig* getConfiguration() const = 0;
1691+ virtual void setConfiguration(MirDisplayConfig *conf) = 0;
1692+ virtual void applyConfiguration(MirDisplayConfig *conf) = 0;
1693+ virtual bool isConnected() = 0;
1694+ virtual bool isConfigurationValid() = 0;
1695+ virtual QList<QSharedPointer<Output>> outputs() = 0;
1696+
1697+Q_SIGNALS:
1698+ void configurationChanged();
1699+ void configurationFailed(const QString &errorMessage);
1700+};
1701+} // DisplayPlugin
1702+
1703+#endif // MIRCLIENT_H
1704
1705=== added file 'plugins/brightness/displays/mirclient_impl.cpp'
1706--- plugins/brightness/displays/mirclient_impl.cpp 1970-01-01 00:00:00 +0000
1707+++ plugins/brightness/displays/mirclient_impl.cpp 2017-02-06 14:24:05 +0000
1708@@ -0,0 +1,180 @@
1709+/*
1710+ * This file is part of system-settings
1711+ *
1712+ * Copyright (C) 2017 Canonical Ltd.
1713+ *
1714+ * This program is free software: you can redistribute it and/or modify it
1715+ * under the terms of the GNU General Public License version 3, as published
1716+ * by the Free Software Foundation.
1717+ *
1718+ * This program is distributed in the hope that it will be useful, but
1719+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1720+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1721+ * PURPOSE. See the GNU General Public License for more details.
1722+ *
1723+ * You should have received a copy of the GNU General Public License along
1724+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1725+ */
1726+
1727+#include "mirclient_impl.h"
1728+#include "output/mir_output.h"
1729+#include "../../../src/i18n.h"
1730+
1731+#include <mir_toolkit/client_types.h>
1732+#include <mir_toolkit/mir_error.h>
1733+
1734+#include <QDebug>
1735+#include <QQmlEngine>
1736+#include <QGuiApplication>
1737+#include <qpa/qplatformnativeinterface.h>
1738+
1739+namespace DisplayPlugin
1740+{
1741+static void mir_display_change_callback(MirConnection *connection,
1742+ void *context)
1743+{
1744+ auto mirClient = static_cast<MirClientImpl*>(context);
1745+ auto conf = mir_connection_create_display_configuration(
1746+ connection);
1747+ mirClient->setConfiguration(conf);
1748+ qWarning() << "Mir apply config successfully.";
1749+}
1750+
1751+static void mir_error_callback(MirConnection *connection,
1752+ MirError const* error,
1753+ void *context)
1754+{
1755+ Q_UNUSED(connection);
1756+ auto mirClient = static_cast<MirClientImpl*>(context);
1757+ auto domain = mir_error_get_domain(error);
1758+ auto errorCode = mir_error_get_code(error);
1759+
1760+ QString msg;
1761+ switch (domain) {
1762+ case MirErrorDomain::mir_error_domain_display_configuration:
1763+ switch ((MirDisplayConfigurationError) errorCode) {
1764+ case MirDisplayConfigurationError::mir_display_configuration_error_unauthorized:
1765+ msg = SystemSettings::_(
1766+ "Client is not permitted to change global display configuration"
1767+ );
1768+ break;
1769+ case MirDisplayConfigurationError::mir_display_configuration_error_in_progress:
1770+ msg = SystemSettings::_(
1771+ "A global configuration change request is already pending"
1772+ );
1773+ break;
1774+ case MirDisplayConfigurationError::mir_display_configuration_error_no_preview_in_progress:
1775+ msg = SystemSettings::_(
1776+ "A cancel request was received, but no global display configuration preview is in progress"
1777+ );
1778+ break;
1779+ case MirDisplayConfigurationError::mir_display_configuration_error_rejected_by_hardware:
1780+ msg = SystemSettings::_(
1781+ "Display configuration was attempted but was rejected by the hardware"
1782+ );
1783+ break;
1784+ }
1785+ break;
1786+ case MirErrorDomain::mir_error_domain_input_configuration:
1787+ msg = SystemSettings::_(
1788+ "Input configuration was attempted but was rejected by driver"
1789+ );
1790+ break;
1791+ }
1792+
1793+ // TRANSLATORS: %1 is the reason why configuration failed.
1794+ mirClient->onConfigurationFailed(
1795+ SystemSettings::_("Configuration failed: %1.").arg(msg)
1796+ );
1797+
1798+ mirClient->setConfiguration(Q_NULLPTR);
1799+}
1800+
1801+MirClientImpl::MirClientImpl(QObject *parent)
1802+ : MirClient(parent)
1803+ , m_mir_connection(nullptr)
1804+ , m_configuration(nullptr)
1805+{
1806+ connect();
1807+ if (isConnected()) {
1808+ setConfiguration(
1809+ mir_connection_create_display_configuration(m_mir_connection)
1810+ );
1811+ }
1812+}
1813+
1814+MirClientImpl::~MirClientImpl() {
1815+ if (m_configuration)
1816+ mir_display_config_release(m_configuration);
1817+ if (m_mir_connection)
1818+ mir_connection_release(m_mir_connection);
1819+}
1820+
1821+MirDisplayConfig* MirClientImpl::getConfiguration() const {
1822+ return m_configuration;
1823+}
1824+
1825+bool MirClientImpl::isConnected() {
1826+ return mir_connection_is_valid(m_mir_connection);
1827+}
1828+
1829+bool MirClientImpl::isConfigurationValid()
1830+{
1831+ return m_configuration != Q_NULLPTR;
1832+}
1833+
1834+void MirClientImpl::setConfiguration(MirDisplayConfig *conf) {
1835+ if (m_configuration != conf) {
1836+ m_configuration = conf;
1837+ Q_EMIT configurationChanged();
1838+ }
1839+}
1840+
1841+void MirClientImpl::applyConfiguration(MirDisplayConfig *conf) {
1842+ mir_connection_confirm_base_display_configuration(
1843+ m_mir_connection, conf
1844+ );
1845+}
1846+
1847+void MirClientImpl::connect() {
1848+ m_mir_connection = static_cast<MirConnection*>(
1849+ QGuiApplication::platformNativeInterface()
1850+ ->nativeResourceForIntegration("mirConnection")
1851+ );
1852+ if (!m_mir_connection)
1853+ qWarning() << Q_FUNC_INFO << "Could not connect to Mir:";
1854+ m_mir_connection = mir_connect_sync(NULL, "ubuntu-system-settings");
1855+ if (m_mir_connection == nullptr || !isConnected()) {
1856+ const char *error = "Unknown error";
1857+ if (m_mir_connection != nullptr)
1858+ error = mir_connection_get_error_message(m_mir_connection);
1859+ qWarning() << Q_FUNC_INFO << "Could not connect to Mir:" << error;
1860+ } else {
1861+ qWarning() << Q_FUNC_INFO << "Connected successfully to mir.";
1862+ mir_connection_set_display_config_change_callback(
1863+ m_mir_connection, mir_display_change_callback, this);
1864+ mir_connection_set_error_callback(m_mir_connection,
1865+ mir_error_callback,
1866+ this);
1867+ }
1868+}
1869+
1870+QList<QSharedPointer<Output>> MirClientImpl::outputs()
1871+{
1872+ QList<QSharedPointer<Output>> list;
1873+ int numOutputs = mir_display_config_get_num_outputs(m_configuration);
1874+ for (int i = 0; i < numOutputs; i++) {
1875+ auto mirOutput = mir_display_config_get_mutable_output(
1876+ m_configuration, i
1877+ );
1878+ auto output = QSharedPointer<Output>(new MirOutputImpl(mirOutput));
1879+ list.append(output);
1880+ }
1881+ return list;
1882+}
1883+
1884+void MirClientImpl::onConfigurationFailed(const QString &reason)
1885+{
1886+ Q_EMIT configurationFailed(reason);
1887+}
1888+} // DisplayPlugin
1889
1890=== added file 'plugins/brightness/displays/mirclient_impl.h'
1891--- plugins/brightness/displays/mirclient_impl.h 1970-01-01 00:00:00 +0000
1892+++ plugins/brightness/displays/mirclient_impl.h 2017-02-06 14:24:05 +0000
1893@@ -0,0 +1,47 @@
1894+/*
1895+ * This file is part of system-settings
1896+ *
1897+ * Copyright (C) 2017 Canonical Ltd.
1898+ *
1899+ * This program is free software: you can redistribute it and/or modify it
1900+ * under the terms of the GNU General Public License version 3, as published
1901+ * by the Free Software Foundation.
1902+ *
1903+ * This program is distributed in the hope that it will be useful, but
1904+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1905+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1906+ * PURPOSE. See the GNU General Public License for more details.
1907+ *
1908+ * You should have received a copy of the GNU General Public License along
1909+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1910+ */
1911+
1912+#ifndef MIRCLIENT_IMPL_H
1913+#define MIRCLIENT_IMPL_H
1914+
1915+#include "mirclient.h"
1916+
1917+namespace DisplayPlugin
1918+{
1919+class MirClientImpl : public MirClient
1920+{
1921+ Q_OBJECT
1922+public:
1923+ explicit MirClientImpl(QObject *parent = Q_NULLPTR);
1924+ ~MirClientImpl();
1925+ virtual MirDisplayConfig* getConfiguration() const;
1926+ virtual void setConfiguration(MirDisplayConfig *conf) override;
1927+ virtual void applyConfiguration(MirDisplayConfig *conf) override;
1928+ virtual bool isConnected() override;
1929+ virtual bool isConfigurationValid() override;
1930+ virtual QList<QSharedPointer<Output>> outputs() override;
1931+ void onConfigurationFailed(const QString &reason);
1932+
1933+private:
1934+ void connect();
1935+ MirConnection *m_mir_connection;
1936+ MirDisplayConfig *m_configuration;
1937+};
1938+} // DisplayPlugin
1939+
1940+#endif // MIRCLIENT_IMPL_H
1941
1942=== added directory 'plugins/brightness/displays/output'
1943=== added file 'plugins/brightness/displays/output/mir_output.cpp'
1944--- plugins/brightness/displays/output/mir_output.cpp 1970-01-01 00:00:00 +0000
1945+++ plugins/brightness/displays/output/mir_output.cpp 2017-02-06 14:24:05 +0000
1946@@ -0,0 +1,171 @@
1947+/*
1948+ * This file is part of system-settings
1949+ *
1950+ * Copyright (C) 2017 Canonical Ltd.
1951+ *
1952+ * This program is free software: you can redistribute it and/or modify it
1953+ * under the terms of the GNU General Public License version 3, as published
1954+ * by the Free Software Foundation.
1955+ *
1956+ * This program is distributed in the hope that it will be useful, but
1957+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1958+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1959+ * PURPOSE. See the GNU General Public License for more details.
1960+ *
1961+ * You should have received a copy of the GNU General Public License along
1962+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1963+ */
1964+
1965+#include "mir_output.h"
1966+
1967+#include "../helpers.h"
1968+#include "../outputmode/mir_outputmode.h"
1969+
1970+#include <QDebug>
1971+
1972+namespace DisplayPlugin
1973+{
1974+MirOutputImpl::MirOutputImpl(MirOutput *output)
1975+ : m_output(output)
1976+{
1977+}
1978+
1979+MirOutputImpl::~MirOutputImpl()
1980+{
1981+}
1982+
1983+QSharedPointer<OutputMode> MirOutputImpl::getPreferredMode()
1984+{
1985+ auto mode = mir_output_get_preferred_mode(m_output);
1986+ return QSharedPointer<OutputMode>(new MirOutputModeImpl(mode));
1987+}
1988+
1989+QSharedPointer<OutputMode> MirOutputImpl::getCurrentMode()
1990+{
1991+ auto mode = mir_output_get_current_mode(m_output);
1992+ return QSharedPointer<OutputMode>(new MirOutputModeImpl(mode));
1993+}
1994+
1995+QList<QSharedPointer<OutputMode>> MirOutputImpl::getAvailableModes()
1996+{
1997+ QList<QSharedPointer<OutputMode>> list;
1998+
1999+ for (int i = 0; i < mir_output_get_num_modes(m_output); i++) {
2000+ auto mirMode = mir_output_get_mode(m_output, i);
2001+ auto mode = QSharedPointer<OutputMode>(new MirOutputModeImpl(mirMode));
2002+ list.append(mode);
2003+ }
2004+ return list;
2005+}
2006+
2007+int MirOutputImpl::getId()
2008+{
2009+ return mir_output_get_id(m_output);
2010+}
2011+
2012+Enums::OutputType MirOutputImpl::getType()
2013+{
2014+ return Helpers::mirOutputTypeToOutputType(
2015+ mir_output_get_type(m_output)
2016+ );
2017+}
2018+
2019+int MirOutputImpl::getPositionX()
2020+{
2021+
2022+}
2023+
2024+int MirOutputImpl::getPositionY()
2025+{
2026+
2027+}
2028+
2029+Enums::ConnectionState MirOutputImpl::getConnectionState()
2030+{
2031+ return Helpers::mirConnectionStateToConnectionState(
2032+ mir_output_get_connection_state(m_output)
2033+ );
2034+}
2035+
2036+bool MirOutputImpl::isEnabled()
2037+{
2038+ return mir_output_is_enabled(m_output);
2039+}
2040+
2041+QString MirOutputImpl::getModel()
2042+{
2043+ return QString::fromUtf8(mir_output_get_model(m_output));
2044+}
2045+
2046+int MirOutputImpl::getPhysicalWidthMm()
2047+{
2048+
2049+}
2050+
2051+int MirOutputImpl::getPhysicalHeightMm()
2052+{
2053+
2054+}
2055+
2056+Enums::PowerMode MirOutputImpl::getPowerMode()
2057+{
2058+ return Helpers::mirPowerModeToPowerMode(
2059+ mir_output_get_power_mode(m_output)
2060+ );
2061+}
2062+
2063+Enums::Orientation MirOutputImpl::getOrientation()
2064+{
2065+ return Helpers::mirOrientationToOrientation(
2066+ mir_output_get_orientation(m_output)
2067+ );
2068+}
2069+
2070+float MirOutputImpl::getScaleFactor()
2071+{
2072+ return mir_output_get_scale_factor(m_output);
2073+}
2074+
2075+uint8_t const* MirOutputImpl::getEdid()
2076+{
2077+
2078+}
2079+
2080+void MirOutputImpl::setCurrentMode(const QSharedPointer<OutputMode> &mode)
2081+{
2082+ auto mirMode = (MirOutputModeImpl*) mode.data();
2083+ mir_output_set_current_mode(m_output, mirMode->getMirOutputMode());
2084+}
2085+
2086+void MirOutputImpl::setPosition(const int &x, const int &y)
2087+{
2088+
2089+}
2090+
2091+void MirOutputImpl::setEnabled(const bool enabled)
2092+{
2093+ if (enabled)
2094+ mir_output_enable(m_output);
2095+ else
2096+ mir_output_disable(m_output);
2097+}
2098+
2099+ ;
2100+void MirOutputImpl::setPowerMode(const Enums::PowerMode &mode)
2101+{
2102+ auto mirMode = Helpers::powerModeToMirPowerMode(mode);
2103+ mir_output_set_power_mode(m_output, mirMode);
2104+}
2105+
2106+void MirOutputImpl::setOrientation(const Enums::Orientation &orientation)
2107+{
2108+ auto mirOrientation = Helpers::orientationToMirOrientation(orientation);
2109+ mir_output_set_orientation(m_output, mirOrientation);
2110+}
2111+
2112+void MirOutputImpl::setScaleFactor(const float &scale)
2113+{
2114+ mir_output_set_scale_factor(m_output, scale);
2115+}
2116+
2117+} // DisplayPlugin
2118
2119=== added file 'plugins/brightness/displays/output/mir_output.h'
2120--- plugins/brightness/displays/output/mir_output.h 1970-01-01 00:00:00 +0000
2121+++ plugins/brightness/displays/output/mir_output.h 2017-02-06 14:24:05 +0000
2122@@ -0,0 +1,62 @@
2123+/*
2124+ * This file is part of system-settings
2125+ *
2126+ * Copyright (C) 2017 Canonical Ltd.
2127+ *
2128+ * This program is free software: you can redistribute it and/or modify it
2129+ * under the terms of the GNU General Public License version 3, as published
2130+ * by the Free Software Foundation.
2131+ *
2132+ * This program is distributed in the hope that it will be useful, but
2133+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2134+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2135+ * PURPOSE. See the GNU General Public License for more details.
2136+ *
2137+ * You should have received a copy of the GNU General Public License along
2138+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2139+ */
2140+
2141+#ifndef DISPLAYS_MIR_OUTPUT_H
2142+#define DISPLAYS_MIR_OUTPUT_H
2143+
2144+#include "output.h"
2145+
2146+#include <mir_toolkit/mir_client_library.h>
2147+
2148+namespace DisplayPlugin
2149+{
2150+class MirOutputImpl : public Output
2151+{
2152+public:
2153+ explicit MirOutputImpl(MirOutput *output);
2154+ virtual ~MirOutputImpl();
2155+
2156+ virtual QSharedPointer<OutputMode> getPreferredMode() override;
2157+ virtual QSharedPointer<OutputMode> getCurrentMode() override;
2158+ virtual QList<QSharedPointer<OutputMode>> getAvailableModes() override;
2159+ virtual int getId() override;
2160+ virtual Enums::OutputType getType() override;
2161+ virtual int getPositionX() override;
2162+ virtual int getPositionY() override;
2163+ virtual Enums::ConnectionState getConnectionState() override;
2164+ virtual bool isEnabled() override;
2165+ virtual QString getModel() override;
2166+ virtual int getPhysicalWidthMm() override;
2167+ virtual int getPhysicalHeightMm() override;
2168+ virtual Enums::PowerMode getPowerMode() override;
2169+ virtual Enums::Orientation getOrientation() override;
2170+ virtual float getScaleFactor() override;
2171+ virtual uint8_t const* getEdid() override;
2172+ virtual void setCurrentMode(const QSharedPointer<OutputMode> &mode) override;
2173+ virtual void setPosition(const int &x, const int &y) override;
2174+ virtual void setEnabled(const bool enabled) override;
2175+ virtual void setPowerMode(const Enums::PowerMode &mode) override;
2176+ virtual void setOrientation(const Enums::Orientation &orientation) override;
2177+ virtual void setScaleFactor(const float &scale) override;
2178+
2179+private:
2180+ MirOutput *m_output = Q_NULLPTR;
2181+};
2182+} // DisplayPlugin
2183+
2184+#endif // DISPLAYS_MIR_OUTPUT_H
2185
2186=== added file 'plugins/brightness/displays/output/output.h'
2187--- plugins/brightness/displays/output/output.h 1970-01-01 00:00:00 +0000
2188+++ plugins/brightness/displays/output/output.h 2017-02-06 14:24:05 +0000
2189@@ -0,0 +1,64 @@
2190+/*
2191+ * This file is part of system-settings
2192+ *
2193+ * Copyright (C) 2017 Canonical Ltd.
2194+ *
2195+ * This program is free software: you can redistribute it and/or modify it
2196+ * under the terms of the GNU General Public License version 3, as published
2197+ * by the Free Software Foundation.
2198+ *
2199+ * This program is distributed in the hope that it will be useful, but
2200+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2201+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2202+ * PURPOSE. See the GNU General Public License for more details.
2203+ *
2204+ * You should have received a copy of the GNU General Public License along
2205+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2206+ */
2207+
2208+#ifndef DISPLAYS_OUTPUT_H
2209+#define DISPLAYS_OUTPUT_H
2210+
2211+#include "../enums.h"
2212+#include "../outputmode/outputmode.h"
2213+
2214+#include <QSharedPointer>
2215+
2216+namespace DisplayPlugin
2217+{
2218+/* Provides an abstraction of a video output, which can be a physical or
2219+virtual video output (hdmi, screencast, etc.). */
2220+class Q_DECL_EXPORT Output
2221+{
2222+public:
2223+ virtual ~Output() {};
2224+
2225+ virtual QSharedPointer<OutputMode> getPreferredMode() = 0;
2226+ virtual QSharedPointer<OutputMode> getCurrentMode() = 0;
2227+ virtual QList<QSharedPointer<OutputMode>> getAvailableModes() = 0;
2228+ virtual int getId() = 0;
2229+ virtual Enums::OutputType getType() = 0;
2230+ virtual int getPositionX() = 0;
2231+ virtual int getPositionY() = 0;
2232+ virtual Enums::ConnectionState getConnectionState() = 0;
2233+ virtual bool isEnabled() = 0;
2234+ virtual QString getModel() = 0;
2235+ virtual int getPhysicalWidthMm() = 0;
2236+ virtual int getPhysicalHeightMm() = 0;
2237+ virtual Enums::PowerMode getPowerMode() = 0;
2238+ virtual Enums::Orientation getOrientation() = 0;
2239+ virtual float getScaleFactor() = 0;
2240+ virtual uint8_t const* getEdid() = 0;
2241+
2242+ virtual void setCurrentMode(const QSharedPointer<OutputMode> &mode) = 0;
2243+ virtual void setPosition(const int &x, const int &y) = 0;
2244+ virtual void setEnabled(const bool enabled) = 0;
2245+ virtual void setPowerMode(const Enums::PowerMode &mode) = 0;
2246+ virtual void setOrientation(const Enums::Orientation &orientation) = 0;
2247+ virtual void setScaleFactor(const float &scale) = 0;
2248+};
2249+} // DisplayPlugin
2250+
2251+Q_DECLARE_METATYPE(QSharedPointer<DisplayPlugin::OutputMode>)
2252+
2253+#endif // DISPLAYS_OUTPUT_H
2254
2255=== added directory 'plugins/brightness/displays/outputmode'
2256=== added file 'plugins/brightness/displays/outputmode/mir_outputmode.cpp'
2257--- plugins/brightness/displays/outputmode/mir_outputmode.cpp 1970-01-01 00:00:00 +0000
2258+++ plugins/brightness/displays/outputmode/mir_outputmode.cpp 2017-02-06 14:24:05 +0000
2259@@ -0,0 +1,63 @@
2260+/*
2261+ * This file is part of system-settings
2262+ *
2263+ * Copyright (C) 2017 Canonical Ltd.
2264+ *
2265+ * This program is free software: you can redistribute it and/or modify it
2266+ * under the terms of the GNU General Public License version 3, as published
2267+ * by the Free Software Foundation.
2268+ *
2269+ * This program is distributed in the hope that it will be useful, but
2270+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2271+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2272+ * PURPOSE. See the GNU General Public License for more details.
2273+ *
2274+ * You should have received a copy of the GNU General Public License along
2275+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2276+ */
2277+
2278+#include "mir_outputmode.h"
2279+#include "../../../../src/i18n.h"
2280+
2281+namespace DisplayPlugin
2282+{
2283+MirOutputModeImpl::MirOutputModeImpl(MirOutputMode const *outputMode)
2284+ : m_outputMode(outputMode)
2285+{
2286+}
2287+
2288+MirOutputModeImpl::~MirOutputModeImpl()
2289+{
2290+}
2291+
2292+int MirOutputModeImpl::getWidth()
2293+{
2294+ return mir_output_mode_get_width(m_outputMode);
2295+}
2296+
2297+int MirOutputModeImpl::getHeight()
2298+{
2299+ return mir_output_mode_get_height(m_outputMode);
2300+}
2301+
2302+double MirOutputModeImpl::getRefreshRate()
2303+{
2304+ return mir_output_mode_get_refresh_rate(m_outputMode);
2305+}
2306+
2307+QString MirOutputModeImpl::toString()
2308+{
2309+ /* TRANSLATORS: %1 refer to the amount of horizontal pixels in a
2310+ display resolution, and %2 to the vertical pixels. E.g. 1200x720.
2311+ %3 is the refresh rate in hz. */
2312+ return SystemSettings::_("%1×%2 @ %3hz")
2313+ .arg(getWidth())
2314+ .arg(getHeight())
2315+ .arg(getRefreshRate());
2316+}
2317+
2318+MirOutputMode const* MirOutputModeImpl::getMirOutputMode()
2319+{
2320+ return m_outputMode;
2321+}
2322+} // DisplayPlugin
2323
2324=== added file 'plugins/brightness/displays/outputmode/mir_outputmode.h'
2325--- plugins/brightness/displays/outputmode/mir_outputmode.h 1970-01-01 00:00:00 +0000
2326+++ plugins/brightness/displays/outputmode/mir_outputmode.h 2017-02-06 14:24:05 +0000
2327@@ -0,0 +1,44 @@
2328+/*
2329+ * This file is part of system-settings
2330+ *
2331+ * Copyright (C) 2017 Canonical Ltd.
2332+ *
2333+ * This program is free software: you can redistribute it and/or modify it
2334+ * under the terms of the GNU General Public License version 3, as published
2335+ * by the Free Software Foundation.
2336+ *
2337+ * This program is distributed in the hope that it will be useful, but
2338+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2339+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2340+ * PURPOSE. See the GNU General Public License for more details.
2341+ *
2342+ * You should have received a copy of the GNU General Public License along
2343+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2344+ */
2345+
2346+#ifndef DISPLAYS_MIR_OUTPUTMODE_H
2347+#define DISPLAYS_MIR_OUTPUTMODE_H
2348+
2349+#include "outputmode.h"
2350+
2351+#include <mir_toolkit/mir_client_library.h>
2352+
2353+namespace DisplayPlugin
2354+{
2355+class MirOutputModeImpl : public OutputMode
2356+{
2357+public:
2358+ explicit MirOutputModeImpl(MirOutputMode const *outputMode);
2359+ virtual ~MirOutputModeImpl();
2360+
2361+ virtual int getWidth() override;
2362+ virtual int getHeight() override;
2363+ virtual double getRefreshRate() override;
2364+ virtual QString toString() override;
2365+ MirOutputMode const* getMirOutputMode();
2366+private:
2367+ MirOutputMode const *m_outputMode = Q_NULLPTR;
2368+};
2369+} // DisplayPlugin
2370+
2371+#endif // DISPLAYS_MIR_OUTPUTMODE_H
2372
2373=== added file 'plugins/brightness/displays/outputmode/outputmode.h'
2374--- plugins/brightness/displays/outputmode/outputmode.h 1970-01-01 00:00:00 +0000
2375+++ plugins/brightness/displays/outputmode/outputmode.h 2017-02-06 14:24:05 +0000
2376@@ -0,0 +1,39 @@
2377+/*
2378+ * This file is part of system-settings
2379+ *
2380+ * Copyright (C) 2017 Canonical Ltd.
2381+ *
2382+ * This program is free software: you can redistribute it and/or modify it
2383+ * under the terms of the GNU General Public License version 3, as published
2384+ * by the Free Software Foundation.
2385+ *
2386+ * This program is distributed in the hope that it will be useful, but
2387+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2388+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2389+ * PURPOSE. See the GNU General Public License for more details.
2390+ *
2391+ * You should have received a copy of the GNU General Public License along
2392+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2393+ */
2394+
2395+#ifndef DISPLAYS_OUTPUTMODE_H
2396+#define DISPLAYS_OUTPUTMODE_H
2397+
2398+#include <QtCore/QtGlobal>
2399+
2400+namespace DisplayPlugin
2401+{
2402+// Represents an abstraction of an output mode.
2403+class Q_DECL_EXPORT OutputMode
2404+{
2405+public:
2406+ virtual ~OutputMode() {};
2407+
2408+ virtual int getWidth() = 0;
2409+ virtual int getHeight() = 0;
2410+ virtual double getRefreshRate() = 0;
2411+ virtual QString toString() = 0;
2412+};
2413+} // DisplayPlugin
2414+
2415+#endif // DISPLAYS_OUTPUTMODE_H
2416
2417=== modified file 'plugins/brightness/plugin.cpp'
2418--- plugins/brightness/plugin.cpp 2016-04-13 18:49:49 +0000
2419+++ plugins/brightness/plugin.cpp 2017-02-06 14:24:05 +0000
2420@@ -27,6 +27,9 @@
2421 #include "aethercast/displays.h"
2422 #include "aethercast/device.h"
2423
2424+#include "displays/display.h"
2425+#include "displays/displaymodel.h"
2426+
2427
2428 void BackendPlugin::registerTypes(const char *uri)
2429 {
2430@@ -39,6 +42,10 @@
2431 qmlRegisterType<Brightness>(uri, 1, 0, "UbuntuBrightnessPanel");
2432 qmlRegisterType<Device>(uri, 1, 0, "AethercastDevice");
2433 qmlRegisterType<Displays>(uri, 1, 0, "AethercastDisplays");
2434+
2435+ qmlRegisterType<DisplayPlugin::DisplayModel>(uri, 1, 0, "DisplayModel");
2436+ //qmlRegisterUncreatableType<DisplayPlugin::Display>(uri, 1, 0, "Display", "Use UbuntuBrightnessPanel.");
2437+ //qmlRegisterUncreatableType<DisplayPlugin::Display>(uri, 1, 0, "Display", "Use UbuntuBrightnessPanel.");
2438 }
2439
2440 void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
2441
2442=== modified file 'plugins/brightness/plugin/brightness-plugin.cpp'
2443--- plugins/brightness/plugin/brightness-plugin.cpp 2016-04-27 16:55:42 +0000
2444+++ plugins/brightness/plugin/brightness-plugin.cpp 2017-02-06 14:24:05 +0000
2445@@ -23,6 +23,7 @@
2446
2447 #include <QDebug>
2448 #include <QDBusInterface>
2449+#include <QProcessEnvironment>
2450 #include <QStringList>
2451 #include <SystemSettings/ItemBase>
2452
2453@@ -48,6 +49,18 @@
2454 BrightnessItem::BrightnessItem(const QVariantMap &staticData, QObject *parent):
2455 ItemBase(staticData, parent)
2456 {
2457+ setDisplayName(_("Brightness"));
2458+
2459+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
2460+ if (env.contains(QLatin1String("USS_SHOW_ALL_UI"))) {
2461+ QString showAllS = env.value("USS_SHOW_ALL_UI", "");
2462+
2463+ if(!showAllS.isEmpty()) {
2464+ setVisibility(true);
2465+ return;
2466+ }
2467+ }
2468+
2469 QDBusInterface m_powerdIface ("com.canonical.powerd",
2470 "/com/canonical/powerd",
2471 "com.canonical.powerd",
2472@@ -61,9 +74,7 @@
2473 // We want to log this property to help aid debugging
2474 qWarning() << Q_FUNC_INFO << "ubuntu.widi.supported:" << widi;
2475
2476- if (strcmp(widi, "0") == 0) {
2477- setDisplayName(_("Brightness"));
2478- } else {
2479+ if (strcmp(widi, "0") != 0) {
2480 setDisplayName(_("Brightness & Display"));
2481 }
2482 }
2483
2484=== renamed file 'plugins/brightness/qmldir' => 'plugins/brightness/qmldir.in'
2485=== modified file 'plugins/system-update/CMakeLists.txt'
2486--- plugins/system-update/CMakeLists.txt 2016-08-19 12:30:40 +0000
2487+++ plugins/system-update/CMakeLists.txt 2017-02-06 14:24:05 +0000
2488@@ -1,3 +1,7 @@
2489+pkg_search_module(MIR_CORE REQUIRED mircore)
2490+pkg_check_modules(UAL REQUIRED ubuntu-app-launch-2)
2491+pkg_check_modules(UBUNTUONEAUTH REQUIRED ubuntuoneauth-2.0)
2492+
2493 set(CMAKE_AUTOMOC ON)
2494 set(QML_SOURCES
2495 ClickUpdateDelegate.qml
2496@@ -14,12 +18,11 @@
2497 include_directories(
2498 ${CMAKE_CURRENT_BINARY_DIR}
2499 ${CMAKE_CURRENT_SOURCE_DIR}
2500+ ${MIR_CORE_INCLUDE_DIRS}
2501 /usr/include/apt-pkg/
2502 )
2503
2504-pkg_check_modules(UAL REQUIRED ubuntu-app-launch-2)
2505 add_definitions(${UAL_CFLAGS} ${UAL_CFLAGS_OTHER})
2506-pkg_check_modules(UBUNTUONEAUTH REQUIRED ubuntuoneauth-2.0)
2507 add_definitions(${UBUNTUONEAUTH_CFLAGS} ${UBUNTUONEAUTH_CFLAGS_OTHER})
2508
2509 add_library(UpdatePlugin SHARED
2510
2511=== added directory 'tests/mocks/Ubuntu/SystemSettings/Brightness'
2512=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/CMakeLists.txt'
2513--- tests/mocks/Ubuntu/SystemSettings/Brightness/CMakeLists.txt 1970-01-01 00:00:00 +0000
2514+++ tests/mocks/Ubuntu/SystemSettings/Brightness/CMakeLists.txt 2017-02-06 14:24:05 +0000
2515@@ -0,0 +1,31 @@
2516+pkg_search_module(MIR REQUIRED mirclient)
2517+find_package(Qt5Core REQUIRED)
2518+find_package(Qt5Gui REQUIRED)
2519+find_package(Qt5Quick REQUIRED)
2520+
2521+include_directories(
2522+ ${CMAKE_CURRENT_BINARY_DIR}
2523+ ${CMAKE_SOURCE_DIR}/plugins/brightness
2524+ ${CMAKE_SOURCE_DIR}/plugins/brightness/displays
2525+ ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/brightness
2526+ ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
2527+ ${MIR_INCLUDE_DIRS}
2528+)
2529+
2530+set(MOCK_BRIGHTNESS_SRCS
2531+ MockAethercastDevice.h
2532+ MockAethercastDeviceModel.cpp
2533+ MockAethercastDisplays.cpp
2534+ MockBrightness.cpp
2535+
2536+ # MockDisplay.h
2537+ # MockDisplayModel.h
2538+ plugin.cpp
2539+)
2540+
2541+add_library(MockBrightnessPanel MODULE ${MOCK_BRIGHTNESS_SRCS})
2542+
2543+target_link_libraries(MockBrightnessPanel uss-displays)
2544+
2545+add_uss_mock(Ubuntu.SystemSettings.Brightness 1.0 Ubuntu/SystemSettings/Brightness
2546+ TARGETS MockBrightnessPanel)
2547
2548=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDevice.h'
2549--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDevice.h 1970-01-01 00:00:00 +0000
2550+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDevice.h 2017-02-06 14:24:05 +0000
2551@@ -0,0 +1,63 @@
2552+/*
2553+ * This file is part of system-settings
2554+ *
2555+ * Copyright (C) 2016 Canonical Ltd.
2556+ *
2557+ * This program is free software: you can redistribute it and/or modify it
2558+ * under the terms of the GNU General Public License version 3, as published
2559+ * by the Free Software Foundation.
2560+ *
2561+ * This program is distributed in the hope that it will be useful, but
2562+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2563+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2564+ * PURPOSE. See the GNU General Public License for more details.
2565+ *
2566+ * You should have received a copy of the GNU General Public License along
2567+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2568+ */
2569+
2570+#ifndef MOCK_AETHERCAST_DEVICE_H
2571+#define MOCK_AETHERCAST_DEVICE_H
2572+
2573+#include <QObject>
2574+#include <QString>
2575+#include <QStringList>
2576+
2577+class MockAethercastDevice : public QObject
2578+{
2579+ Q_OBJECT
2580+ Q_PROPERTY(QString Address READ address)
2581+ Q_PROPERTY(QStringList Capabilities READ capabilities)
2582+ Q_PROPERTY(QString Name READ name)
2583+ Q_PROPERTY(State state READ state)
2584+public:
2585+ MockAethercastDevice(QObject *parent = 0) {
2586+ Q_UNUSED(parent)
2587+ };
2588+ ~MockAethercastDevice() {};
2589+
2590+ enum State { Idle=1, Disconnected=2, Association=4, Configuration=8, Connected=16, Failure=32 };
2591+ Q_ENUMS(State)
2592+ Q_DECLARE_FLAGS(States, State)
2593+
2594+ inline QString address() const
2595+ { return m_address; }
2596+
2597+ inline QStringList capabilities() const
2598+ { return m_capabilities; }
2599+
2600+ inline QString name() const
2601+ { return m_name; }
2602+
2603+ inline State state() const
2604+ { return m_state; }
2605+
2606+ QString m_address = QString::null;
2607+ QStringList m_capabilities;
2608+ QString m_name = QString::null;
2609+ State m_state = MockAethercastDevice::Idle;
2610+};
2611+
2612+Q_DECLARE_OPERATORS_FOR_FLAGS(MockAethercastDevice::States)
2613+
2614+#endif // MOCK_AETHERCAST_DEVICE_H
2615
2616=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDeviceModel.cpp'
2617--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDeviceModel.cpp 1970-01-01 00:00:00 +0000
2618+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDeviceModel.cpp 2017-02-06 14:24:05 +0000
2619@@ -0,0 +1,95 @@
2620+/*
2621+ * This file is part of system-settings
2622+ *
2623+ * Copyright (C) 2016 Canonical Ltd.
2624+ *
2625+ * This program is free software: you can redistribute it and/or modify it
2626+ * under the terms of the GNU General Public License version 3, as published
2627+ * by the Free Software Foundation.
2628+ *
2629+ * This program is distributed in the hope that it will be useful, but
2630+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2631+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2632+ * PURPOSE. See the GNU General Public License for more details.
2633+ *
2634+ * You should have received a copy of the GNU General Public License along
2635+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2636+ */
2637+#include "MockAethercastDeviceModel.h"
2638+
2639+int MockAethercastDeviceModel::rowCount(const QModelIndex &parent) const
2640+{
2641+ Q_UNUSED(parent);
2642+ return m_devices.size();
2643+}
2644+
2645+QVariant MockAethercastDeviceModel::data(const QModelIndex &index, int role) const
2646+{
2647+ QVariant ret;
2648+ if ((0<=index.row()) && (index.row()<m_devices.size())) {
2649+ auto device = m_devices[index.row()];
2650+ QString displayName;
2651+
2652+ switch (role) {
2653+ case Qt::DisplayRole:
2654+ displayName = device->name();
2655+
2656+ if (displayName.isEmpty())
2657+ displayName = device->address();
2658+
2659+ ret = displayName;
2660+ break;
2661+
2662+ case StateRole:
2663+ ret = device->state();
2664+ break;
2665+
2666+ case AddressRole:
2667+ ret = device->address();
2668+ break;
2669+
2670+ }
2671+ }
2672+ return ret;
2673+}
2674+
2675+QHash<int,QByteArray> MockAethercastDeviceModel::roleNames() const
2676+{
2677+ static QHash<int,QByteArray> names;
2678+ if (Q_UNLIKELY(names.empty())) {
2679+ names[Qt::DisplayRole] = "displayName";
2680+ names[StateRole] = "stateName";
2681+ names[AddressRole] = "addressName";
2682+ }
2683+ return names;
2684+}
2685+
2686+QSharedPointer<MockAethercastDevice> MockAethercastDeviceModel::getDeviceFromAddress(const QString &address)
2687+{
2688+ Q_UNUSED(address)
2689+ return QSharedPointer<MockAethercastDevice>(nullptr);
2690+}
2691+
2692+QSharedPointer<MockAethercastDevice> MockAethercastDeviceModel::getDeviceFromPath(const QString &path)
2693+{
2694+ Q_UNUSED(path)
2695+ return QSharedPointer<MockAethercastDevice>(nullptr);
2696+}
2697+
2698+void MockAethercastDeviceModel::addDevice(const QString &address,
2699+ const QString &name,
2700+ const int &state)
2701+{
2702+ QSharedPointer<MockAethercastDevice> dev =
2703+ QSharedPointer<MockAethercastDevice>(new MockAethercastDevice);
2704+ dev->m_address = address;
2705+ dev->m_name = name;
2706+ dev->m_state = (MockAethercastDevice::State) state;
2707+
2708+ uint row = m_devices.size();
2709+ beginInsertRows(QModelIndex(), row, row);
2710+ m_devices.append(dev);
2711+ endInsertRows();
2712+
2713+ emit countChanged(rowCount());
2714+}
2715
2716=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDeviceModel.h'
2717--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDeviceModel.h 1970-01-01 00:00:00 +0000
2718+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDeviceModel.h 2017-02-06 14:24:05 +0000
2719@@ -0,0 +1,63 @@
2720+/*
2721+ * This file is part of system-settings
2722+ *
2723+ * Copyright (C) 2016 Canonical Ltd.
2724+ *
2725+ * This program is free software: you can redistribute it and/or modify it
2726+ * under the terms of the GNU General Public License version 3, as published
2727+ * by the Free Software Foundation.
2728+ *
2729+ * This program is distributed in the hope that it will be useful, but
2730+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2731+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2732+ * PURPOSE. See the GNU General Public License for more details.
2733+ *
2734+ * You should have received a copy of the GNU General Public License along
2735+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2736+ */
2737+
2738+#ifndef MOCK_AETHERCAST_DEVICE_MODEL_H
2739+#define MOCK_AETHERCAST_DEVICE_MODEL_H
2740+
2741+#include "MockAethercastDevice.h"
2742+
2743+#include <QAbstractListModel>
2744+#include <QList>
2745+#include <QObject>
2746+#include <QSharedPointer>
2747+
2748+class MockAethercastDeviceModel : public QAbstractListModel
2749+{
2750+ Q_OBJECT
2751+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
2752+public:
2753+ MockAethercastDeviceModel(QObject *parent = 0) {
2754+ Q_UNUSED(parent)
2755+ };
2756+ ~MockAethercastDeviceModel() {};
2757+
2758+ enum Roles
2759+ {
2760+ // Qt::DisplayRole holds device name
2761+ TypeRole = Qt::UserRole,
2762+ AddressRole,
2763+ StateRole,
2764+ LastRole = StateRole
2765+ };
2766+ // implemented virtual methods from QAbstractTableModel
2767+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
2768+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
2769+ QHash<int,QByteArray> roleNames() const;
2770+
2771+ QSharedPointer<MockAethercastDevice> getDeviceFromAddress(const QString &address);
2772+ QSharedPointer<MockAethercastDevice> getDeviceFromPath(const QString &path);
2773+ Q_INVOKABLE void addDevice(const QString &address, const QString &name,
2774+ const int &state); // mock only
2775+Q_SIGNALS:
2776+ void countChanged(int count);
2777+
2778+private:
2779+ QList<QSharedPointer<MockAethercastDevice> > m_devices;
2780+};
2781+
2782+#endif // MOCK_AETHERCAST_DEVICE_MODEL_H
2783
2784=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDisplays.cpp'
2785--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDisplays.cpp 1970-01-01 00:00:00 +0000
2786+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDisplays.cpp 2017-02-06 14:24:05 +0000
2787@@ -0,0 +1,89 @@
2788+/*
2789+ * This file is part of system-settings
2790+ *
2791+ * Copyright (C) 2016 Canonical Ltd.
2792+ *
2793+ * This program is free software: you can redistribute it and/or modify it
2794+ * under the terms of the GNU General Public License version 3, as published
2795+ * by the Free Software Foundation.
2796+ *
2797+ * This program is distributed in the hope that it will be useful, but
2798+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2799+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2800+ * PURPOSE. See the GNU General Public License for more details.
2801+ *
2802+ * You should have received a copy of the GNU General Public License along
2803+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2804+ */
2805+#include "MockAethercastDisplays.h"
2806+
2807+#include <QQmlEngine>
2808+
2809+void MockAethercastDisplays::connectDevice(const QString &address)
2810+{
2811+ Q_UNUSED(address)
2812+}
2813+
2814+void MockAethercastDisplays::disconnectDevice(const QString &address)
2815+{
2816+ Q_UNUSED(address)
2817+}
2818+
2819+void MockAethercastDisplays::scan()
2820+{
2821+ m_scanning = true;
2822+ Q_EMIT scanningChanged(m_scanning);
2823+}
2824+
2825+void MockAethercastDisplays::stopScan()
2826+{
2827+ m_scanning = false;
2828+ Q_EMIT scanningChanged(m_scanning);
2829+}
2830+
2831+void MockAethercastDisplays::setProperties(const QMap<QString, QVariant> &properties)
2832+{
2833+ Q_UNUSED(properties)
2834+}
2835+
2836+QAbstractItemModel* MockAethercastDisplays::devices()
2837+{
2838+ auto ret = &m_devices;
2839+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
2840+ return ret;
2841+}
2842+
2843+QAbstractItemModel* MockAethercastDisplays::connectedDevices()
2844+{
2845+ auto ret = &m_connectedDevices;
2846+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
2847+ return ret;
2848+}
2849+
2850+QAbstractItemModel* MockAethercastDisplays::disconnectedDevices()
2851+{
2852+ auto ret = &m_disconnectedDevices;
2853+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
2854+ return ret;
2855+}
2856+
2857+bool MockAethercastDisplays::scanning() const
2858+{
2859+ return m_scanning;
2860+}
2861+
2862+bool MockAethercastDisplays::enabled() const
2863+{
2864+ return m_enabled;
2865+}
2866+
2867+void MockAethercastDisplays::setEnabled(const bool enabled)
2868+{
2869+ m_enabled = enabled;
2870+ Q_EMIT enabledChanged(enabled);
2871+}
2872+
2873+QString MockAethercastDisplays::state() const
2874+{
2875+ return m_state;
2876+}
2877
2878=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDisplays.h'
2879--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDisplays.h 1970-01-01 00:00:00 +0000
2880+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockAethercastDisplays.h 2017-02-06 14:24:05 +0000
2881@@ -0,0 +1,96 @@
2882+/*
2883+ * This file is part of system-settings
2884+ *
2885+ * Copyright (C) 2016 Canonical Ltd.
2886+ *
2887+ * This program is free software: you can redistribute it and/or modify it
2888+ * under the terms of the GNU General Public License version 3, as published
2889+ * by the Free Software Foundation.
2890+ *
2891+ * This program is distributed in the hope that it will be useful, but
2892+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2893+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2894+ * PURPOSE. See the GNU General Public License for more details.
2895+ *
2896+ * You should have received a copy of the GNU General Public License along
2897+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2898+ */
2899+
2900+#ifndef MOCK_AETHERCAST_DISPLAYS_H
2901+#define MOCK_AETHERCAST_DISPLAYS_H
2902+
2903+#include "MockAethercastDeviceModel.h"
2904+
2905+#include <QObject>
2906+
2907+class MockAethercastDisplays : public QObject
2908+{
2909+ Q_OBJECT
2910+ Q_PROPERTY (QAbstractItemModel* devices
2911+ READ devices
2912+ CONSTANT)
2913+ Q_PROPERTY (QAbstractItemModel* connectedDevices
2914+ READ connectedDevices
2915+ NOTIFY connectedDevicesChanged)
2916+ Q_PROPERTY (QAbstractItemModel* disconnectedDevices
2917+ READ disconnectedDevices
2918+ NOTIFY disconnectedDevicesChanged)
2919+ Q_PROPERTY (bool scanning
2920+ READ scanning
2921+ NOTIFY scanningChanged)
2922+ Q_PROPERTY (bool enabled
2923+ READ enabled
2924+ WRITE setEnabled
2925+ NOTIFY enabledChanged)
2926+ Q_PROPERTY (QString state
2927+ READ state
2928+ NOTIFY stateChanged)
2929+public:
2930+ explicit MockAethercastDisplays(QObject *parent = nullptr) {
2931+ Q_UNUSED(parent)
2932+ };
2933+ ~MockAethercastDisplays() {}
2934+
2935+ enum Error {
2936+ None,
2937+ Failed,
2938+ Already,
2939+ ParamInvalid,
2940+ InvalidState,
2941+ NotConnected,
2942+ NotReady,
2943+ Unknown
2944+ };
2945+ Q_ENUMS(Error)
2946+
2947+ Q_INVOKABLE void connectDevice(const QString &address);
2948+ Q_INVOKABLE void disconnectDevice(const QString &address);
2949+ Q_INVOKABLE void scan();
2950+ Q_INVOKABLE void stopScan(); // mock only
2951+ Q_INVOKABLE void setEnabled(const bool enabled);
2952+ void setProperties(const QMap<QString, QVariant> &properties);
2953+ QAbstractItemModel * devices();
2954+ QAbstractItemModel * connectedDevices();
2955+ QAbstractItemModel * disconnectedDevices();
2956+ bool scanning() const;
2957+ bool enabled() const;
2958+ QString state() const;
2959+ MockAethercastDeviceModel m_devices;
2960+ MockAethercastDeviceModel m_connectedDevices;
2961+ MockAethercastDeviceModel m_disconnectedDevices;
2962+ QString m_state = QString::null;
2963+
2964+private:
2965+ bool m_scanning = false;
2966+ bool m_enabled = false;
2967+
2968+Q_SIGNALS:
2969+ void scanningChanged(bool isActive);
2970+ void enabledChanged(bool enabled);
2971+ void stateChanged();
2972+ void connectedDevicesChanged();
2973+ void disconnectedDevicesChanged();
2974+ void connectError(int error);
2975+};
2976+
2977+#endif // MOCK_AETHERCAST_DISPLAYS_H
2978
2979=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.cpp'
2980--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.cpp 1970-01-01 00:00:00 +0000
2981+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.cpp 2017-02-06 14:24:05 +0000
2982@@ -0,0 +1,131 @@
2983+/*
2984+ * This file is part of system-settings
2985+ *
2986+ * Copyright (C) 2016 Canonical Ltd.
2987+ *
2988+ * This program is free software: you can redistribute it and/or modify it
2989+ * under the terms of the GNU General Public License version 3, as published
2990+ * by the Free Software Foundation.
2991+ *
2992+ * This program is distributed in the hope that it will be useful, but
2993+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2994+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2995+ * PURPOSE. See the GNU General Public License for more details.
2996+ *
2997+ * You should have received a copy of the GNU General Public License along
2998+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2999+ */
3000+#include "MockBrightness.h"
3001+
3002+#include "fakeoutput.h"
3003+#include "fakeoutputmode.h"
3004+
3005+#include <QQmlEngine>
3006+
3007+MockBrightness::MockBrightness(QObject *parent)
3008+ : QObject(parent)
3009+ , m_displays()
3010+ , m_changedDisplays()
3011+{
3012+ m_changedDisplays.filterOnUncommittedChanges(true);
3013+ m_changedDisplays.setSourceModel(&m_displays);
3014+
3015+ m_connectedDisplays.filterOnConnected(true);
3016+ m_connectedDisplays.setSourceModel(&m_displays);
3017+}
3018+
3019+bool MockBrightness::getPowerdRunning() const
3020+{
3021+ return m_powerdRunning;
3022+}
3023+
3024+bool MockBrightness::getAutoBrightnessAvailable() const
3025+{
3026+ return m_autoBrightnessAvailable;
3027+}
3028+
3029+bool MockBrightness::getWidiSupported() const
3030+{
3031+ return m_widiSupported;
3032+}
3033+
3034+void MockBrightness::setPowerdRunning(const bool running)
3035+{
3036+ m_powerdRunning = running;
3037+ Q_EMIT powerdRunningChanged();
3038+}
3039+
3040+void MockBrightness::setAutoBrightnessAvailable(const bool available)
3041+{
3042+ m_autoBrightnessAvailable = available;
3043+ Q_EMIT autoBrightnessAvailableChanged();
3044+}
3045+
3046+void MockBrightness::setWidiSupported(const bool supported)
3047+{
3048+ m_widiSupported = supported;
3049+ Q_EMIT widiSupportedChanged();
3050+}
3051+
3052+QAbstractItemModel* MockBrightness::allDisplays()
3053+{
3054+ auto ret = &m_displays;
3055+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
3056+ return ret;
3057+}
3058+
3059+QAbstractItemModel* MockBrightness::changedDisplays()
3060+{
3061+ auto ret = &m_changedDisplays;
3062+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
3063+ return ret;
3064+}
3065+
3066+QAbstractItemModel* MockBrightness::connectedDisplays()
3067+{
3068+ auto ret = &m_connectedDisplays;
3069+ QQmlEngine::setObjectOwnership(ret, QQmlEngine::CppOwnership);
3070+ return ret;
3071+}
3072+
3073+void MockBrightness::applyDisplayConfiguration()
3074+{
3075+ Q_EMIT applied();
3076+}
3077+
3078+void MockBrightness::mockAddDisplay(const bool connected,
3079+ const bool enabled,
3080+ const int availableModes,
3081+ const int currentMode,
3082+ const int orientation,
3083+ const float scale)
3084+{
3085+ using namespace DisplayPlugin;
3086+
3087+ // Needs to be connected to be visible to QML.
3088+ auto fakeOutput = new FakeOutput;
3089+ fakeOutput->m_connectionState = connected ? Enums::ConnectionState::Connected
3090+ : Enums::ConnectionState::Disconnected;
3091+
3092+ fakeOutput->m_enabled = enabled;
3093+
3094+ QList<QSharedPointer<OutputMode>> list;
3095+ for (int i = 0; i < availableModes; i++) {
3096+ auto fakeMode = new FakeOutputMode;
3097+ fakeMode->m_width = 1000 * i;
3098+ fakeMode->m_height = 1000 * i;
3099+ fakeMode->m_refreshRate = 10.0 * i;
3100+ fakeMode->m_string = QString("Mode %1").arg(i);
3101+ auto mode = QSharedPointer<OutputMode>(fakeMode);
3102+ list.append(mode);
3103+ }
3104+ fakeOutput->m_modes = list;
3105+ fakeOutput->m_currentModeIndex = currentMode;
3106+ fakeOutput->m_orientation = (Enums::Orientation) orientation;
3107+
3108+ auto output = QSharedPointer<Output>(fakeOutput);
3109+ auto d = QSharedPointer<Display>(
3110+ new Display(output)
3111+ );
3112+ m_displays.addDisplay(d);
3113+}
3114
3115=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.h'
3116--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.h 1970-01-01 00:00:00 +0000
3117+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockBrightness.h 2017-02-06 14:24:05 +0000
3118@@ -0,0 +1,86 @@
3119+/*
3120+ * This file is part of system-settings
3121+ *
3122+ * Copyright (C) 2016 Canonical Ltd.
3123+ *
3124+ * This program is free software: you can redistribute it and/or modify it
3125+ * under the terms of the GNU General Public License version 3, as published
3126+ * by the Free Software Foundation.
3127+ *
3128+ * This program is distributed in the hope that it will be useful, but
3129+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3130+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3131+ * PURPOSE. See the GNU General Public License for more details.
3132+ *
3133+ * You should have received a copy of the GNU General Public License along
3134+ * with this program. If not, see <http://www.gnu.org/licenses/>.
3135+ */
3136+
3137+#ifndef MOCK_BRIGHTNESS_H
3138+#define MOCK_BRIGHTNESS_H
3139+
3140+#include "displays/display.h"
3141+#include "displays/displaymodel.h"
3142+#include "displays/output/output.h"
3143+
3144+#include <QAbstractItemModel>
3145+#include <QObject>
3146+#include <QSortFilterProxyModel>
3147+
3148+class MockBrightness : public QObject
3149+{
3150+ Q_OBJECT
3151+ Q_PROPERTY( bool powerdRunning
3152+ READ getPowerdRunning
3153+ NOTIFY powerdRunningChanged)
3154+ Q_PROPERTY (bool autoBrightnessAvailable
3155+ READ getAutoBrightnessAvailable
3156+ NOTIFY autoBrightnessAvailableChanged)
3157+ Q_PROPERTY (bool widiSupported
3158+ READ getWidiSupported
3159+ NOTIFY widiSupportedChanged)
3160+ Q_PROPERTY (QAbstractItemModel* allDisplays
3161+ READ allDisplays
3162+ CONSTANT)
3163+ Q_PROPERTY (QAbstractItemModel* changedDisplays
3164+ READ changedDisplays
3165+ CONSTANT)
3166+ Q_PROPERTY (QAbstractItemModel* connectedDisplays
3167+ READ connectedDisplays
3168+ CONSTANT)
3169+
3170+public:
3171+ explicit MockBrightness(QObject *parent = 0);
3172+ bool getPowerdRunning() const;
3173+ bool getAutoBrightnessAvailable() const;
3174+ bool getWidiSupported() const;
3175+ Q_INVOKABLE void setPowerdRunning(const bool running);
3176+ Q_INVOKABLE void setAutoBrightnessAvailable(const bool available);
3177+ Q_INVOKABLE void setWidiSupported(const bool supported);
3178+ QAbstractItemModel* allDisplays();
3179+ QAbstractItemModel* changedDisplays();
3180+ QAbstractItemModel* connectedDisplays();
3181+ Q_INVOKABLE void applyDisplayConfiguration();
3182+ Q_INVOKABLE void mockAddDisplay(const bool connected = false,
3183+ const bool enabled = false,
3184+ const int availableModes = 0,
3185+ const int currentMode = 0,
3186+ const int orientation = 0,
3187+ const float scale = 1.0); // mock only
3188+
3189+Q_SIGNALS:
3190+ void powerdRunningChanged();
3191+ void autoBrightnessAvailableChanged();
3192+ void widiSupportedChanged();
3193+ void applied(); // mock only
3194+
3195+private:
3196+ bool m_powerdRunning = false;
3197+ bool m_autoBrightnessAvailable = false;
3198+ bool m_widiSupported = false;
3199+ DisplayPlugin::DisplayModel m_displays;
3200+ DisplayPlugin::DisplaysFilter m_changedDisplays;
3201+ DisplayPlugin::DisplaysFilter m_connectedDisplays;
3202+};
3203+
3204+#endif // MOCK_BRIGHTNESS_H
3205
3206=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplay.h'
3207--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplay.h 1970-01-01 00:00:00 +0000
3208+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplay.h 2017-02-06 14:24:05 +0000
3209@@ -0,0 +1,71 @@
3210+#ifndef MOCK_DISPLAY_H
3211+#define MOCK_DISPLAY_H
3212+
3213+#include "display.h"
3214+
3215+#include <QObject>
3216+#include <QDebug>
3217+
3218+
3219+struct MockDisplay : public DisplayPlugin::Display
3220+{
3221+ Q_OBJECT
3222+public:
3223+ Q_INVOKABLE void setName(const QString &name) // mock only
3224+ {
3225+ m_name = name;
3226+ Q_EMIT nameChanged();
3227+ }
3228+
3229+ Q_INVOKABLE void setType(const QString &type) // mock only
3230+ {
3231+ m_type = type;
3232+ Q_EMIT typeChanged();
3233+ }
3234+
3235+ Q_INVOKABLE void setEnabled(const bool &enabled) // mock only
3236+ {
3237+ m_enabled = enabled;
3238+ Q_EMIT enabledChanged();
3239+ }
3240+
3241+ Q_INVOKABLE void setConnected(const bool &connected) // mock only
3242+ {
3243+ m_connected = connected;
3244+ Q_EMIT connectedChanged();
3245+ }
3246+
3247+ Q_INVOKABLE void setUncommitedChanges(const bool uncommittedChanges) // mock only
3248+ {
3249+ m_uncommittedChanges = uncommittedChanges;
3250+ Q_EMIT uncommittedChangesChanged();
3251+ }
3252+
3253+ // Return at what index the new mode was placed.
3254+ Q_INVOKABLE uint addMode(const uint &horizontal, const uint &vertical,
3255+ const uint &refresh) // mock only
3256+ {
3257+ DisplayPlugin::DisplayMode mode;
3258+ mode.vertical_resolution = vertical;
3259+ mode.horizontal_resolution = horizontal;
3260+ mode.refresh_rate = refresh;
3261+
3262+ m_modes.append(mode);
3263+ Q_EMIT modesChanged();
3264+ return m_modes.indexOf(mode);
3265+ }
3266+
3267+ // Mark a display as unchanged, and save the current config.
3268+ Q_INVOKABLE void save()
3269+ {
3270+ storeConfiguration();
3271+ setUncommitedChanges(false);
3272+ }
3273+Q_SIGNALS:
3274+ void nameChanged();
3275+ void typeChanged();
3276+};
3277+
3278+// Q_DECLARE_METATYPE(MockDisplay*)
3279+
3280+#endif // MOCK_DISPLAY_H
3281
3282=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplayModel.h'
3283--- tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplayModel.h 1970-01-01 00:00:00 +0000
3284+++ tests/mocks/Ubuntu/SystemSettings/Brightness/MockDisplayModel.h 2017-02-06 14:24:05 +0000
3285@@ -0,0 +1,26 @@
3286+#ifndef MOCK_DISPLAY_MODEL_H
3287+#define MOCK_DISPLAY_MODEL_H
3288+
3289+#include "displaymodel.h"
3290+#include "MockDisplay.h"
3291+
3292+#include <QObject>
3293+#include <QQmlEngine>
3294+
3295+class MockDisplayModel : public DisplayPlugin::DisplayModel
3296+{
3297+ Q_OBJECT
3298+public:
3299+ MockDisplayModel(QObject *parent = 0)
3300+ : DisplayPlugin::DisplayModel(parent) {};
3301+ ~MockDisplayModel() {};
3302+ Q_INVOKABLE MockDisplay* mockAddDisplay() // mock only
3303+ {
3304+ QSharedPointer<MockDisplay> d = QSharedPointer<MockDisplay>(new MockDisplay);
3305+ addDisplay(d);
3306+ QQmlEngine::setObjectOwnership(d.data(), QQmlEngine::CppOwnership);
3307+ return d.data();
3308+ }
3309+};
3310+
3311+#endif // MOCK_DISPLAY_MODEL_H
3312
3313=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.cpp'
3314--- tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.cpp 1970-01-01 00:00:00 +0000
3315+++ tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.cpp 2017-02-06 14:24:05 +0000
3316@@ -0,0 +1,33 @@
3317+/*
3318+ * This file is part of system-settings
3319+ *
3320+ * Copyright (C) 2016 Canonical Ltd.
3321+ *
3322+ * This program is free software: you can redistribute it and/or modify it
3323+ * under the terms of the GNU General Public License version 3, as published
3324+ * by the Free Software Foundation.
3325+ *
3326+ * This program is distributed in the hope that it will be useful, but
3327+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3328+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3329+ * PURPOSE. See the GNU General Public License for more details.
3330+ *
3331+ * You should have received a copy of the GNU General Public License along
3332+ * with this program. If not, see <http://www.gnu.org/licenses/>.
3333+ */
3334+
3335+#include "plugin.h"
3336+#include "MockBrightness.h"
3337+#include "MockAethercastDevice.h"
3338+#include "MockAethercastDeviceModel.h"
3339+#include "MockAethercastDisplays.h"
3340+
3341+#include <QtQml>
3342+
3343+void BackendPlugin::registerTypes(const char *uri)
3344+{
3345+ Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Brightness"));
3346+ qmlRegisterType<MockBrightness>(uri, 1, 0, "UbuntuBrightnessPanel");
3347+ qmlRegisterType<MockAethercastDevice>(uri, 1, 0, "AethercastDevice");
3348+ qmlRegisterType<MockAethercastDisplays>(uri, 1, 0, "AethercastDisplays");
3349+}
3350
3351=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.h'
3352--- tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.h 1970-01-01 00:00:00 +0000
3353+++ tests/mocks/Ubuntu/SystemSettings/Brightness/plugin.h 2017-02-06 14:24:05 +0000
3354@@ -0,0 +1,33 @@
3355+/*
3356+ * This file is part of system-settings
3357+ *
3358+ * Copyright (C) 2016 Canonical Ltd.
3359+ *
3360+ * This program is free software: you can redistribute it and/or modify it
3361+ * under the terms of the GNU General Public License version 3, as published
3362+ * by the Free Software Foundation.
3363+ *
3364+ * This program is distributed in the hope that it will be useful, but
3365+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3366+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3367+ * PURPOSE. See the GNU General Public License for more details.
3368+ *
3369+ * You should have received a copy of the GNU General Public License along
3370+ * with this program. If not, see <http://www.gnu.org/licenses/>.
3371+ */
3372+
3373+#ifndef MOCK_SYSTEMSETTINGS_BRIGHTNESS_PLUGIN_H
3374+#define MOCK_SYSTEMSETTINGS_BRIGHTNESS_PLUGIN_H
3375+
3376+#include <QQmlExtensionPlugin>
3377+
3378+class BackendPlugin : public QQmlExtensionPlugin
3379+{
3380+ Q_OBJECT
3381+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
3382+
3383+public:
3384+ void registerTypes(const char *uri) override;
3385+};
3386+
3387+#endif // MOCK_SYSTEMSETTINGS_BRIGHTNESS_PLUGIN_H
3388
3389=== added file 'tests/mocks/Ubuntu/SystemSettings/Brightness/qmldir'
3390--- tests/mocks/Ubuntu/SystemSettings/Brightness/qmldir 1970-01-01 00:00:00 +0000
3391+++ tests/mocks/Ubuntu/SystemSettings/Brightness/qmldir 2017-02-06 14:24:05 +0000
3392@@ -0,0 +1,2 @@
3393+module Ubuntu.SystemSettings.Brightness
3394+plugin MockBrightnessPanel
3395
3396=== modified file 'tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt'
3397--- tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt 2016-11-16 17:06:51 +0000
3398+++ tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt 2017-02-06 14:24:05 +0000
3399@@ -1,3 +1,6 @@
3400+if(ANDR_PROP_FOUND)
3401+ add_subdirectory(Brightness)
3402+endif()
3403 add_subdirectory(Launcher)
3404 add_subdirectory(Notifications)
3405 add_subdirectory(Update)
3406
3407=== added directory 'tests/mocks/plugins/brightness'
3408=== added file 'tests/mocks/plugins/brightness/fakemirclient.h'
3409--- tests/mocks/plugins/brightness/fakemirclient.h 1970-01-01 00:00:00 +0000
3410+++ tests/mocks/plugins/brightness/fakemirclient.h 2017-02-06 14:24:05 +0000
3411@@ -0,0 +1,69 @@
3412+/*
3413+ * This file is part of system-settings
3414+ *
3415+ * Copyright (C) 2016 Canonical Ltd.
3416+ *
3417+ * This program is free software: you can redistribute it and/or modify it
3418+ * under the terms of the GNU General Public License version 3, as published
3419+ * by the Free Software Foundation.
3420+ *
3421+ * This program is distributed in the hope that it will be useful, but
3422+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3423+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3424+ * PURPOSE. See the GNU General Public License for more details.
3425+ *
3426+ * You should have received a copy of the GNU General Public License along
3427+ * with this program. If not, see <http://www.gnu.org/licenses/>.
3428+ */
3429+
3430+#ifndef FAKEMIRCLIENT_H
3431+#define FAKEMIRCLIENT_H
3432+
3433+#include "mirclient.h"
3434+
3435+#include "output/output.h"
3436+
3437+#include <mir_toolkit/mir_client_library.h>
3438+#include <QObject>
3439+
3440+class FakeMirClient : public DisplayPlugin::MirClient
3441+{
3442+ Q_OBJECT
3443+public:
3444+ explicit FakeMirClient(QObject *parent = 0)
3445+ : DisplayPlugin::MirClient(parent) {}
3446+ virtual ~FakeMirClient() {}
3447+ virtual MirDisplayConfig* getConfiguration() const override
3448+ {
3449+ return conf;
3450+ }
3451+ virtual void setConfiguration(MirDisplayConfig *conf) override
3452+ {
3453+ Q_UNUSED(conf);
3454+ }
3455+ virtual void applyConfiguration(MirDisplayConfig *conf) override
3456+ {
3457+ // This usually happens via a mir callback. Fake it here.
3458+ this->conf = conf;
3459+ Q_EMIT configurationChanged();
3460+ }
3461+ virtual bool isConnected() override
3462+ {
3463+ return connected;
3464+ }
3465+ virtual bool isConfigurationValid() override
3466+ {
3467+ return configurationValid;
3468+ }
3469+ virtual QList<QSharedPointer<DisplayPlugin::Output>> outputs() override
3470+ {
3471+ return m_outputs;
3472+ }
3473+
3474+ bool connected = false;
3475+ bool configurationValid = false;
3476+ MirDisplayConfig *conf = nullptr;
3477+ QList<QSharedPointer<DisplayPlugin::Output>> m_outputs;
3478+};
3479+
3480+#endif // FAKEMIRCLIENT_H
3481
3482=== added file 'tests/mocks/plugins/brightness/fakeoutput.h'
3483--- tests/mocks/plugins/brightness/fakeoutput.h 1970-01-01 00:00:00 +0000
3484+++ tests/mocks/plugins/brightness/fakeoutput.h 2017-02-06 14:24:05 +0000
3485@@ -0,0 +1,150 @@
3486+/*
3487+ * This file is part of system-settings
3488+ *
3489+ * Copyright (C) 2017 Canonical Ltd.
3490+ *
3491+ * This program is free software: you can redistribute it and/or modify it
3492+ * under the terms of the GNU General Public License version 3, as published
3493+ * by the Free Software Foundation.
3494+ *
3495+ * This program is distributed in the hope that it will be useful, but
3496+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3497+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3498+ * PURPOSE. See the GNU General Public License for more details.
3499+ *
3500+ * You should have received a copy of the GNU General Public License along
3501+ * with this program. If not, see <http://www.gnu.org/licenses/>.
3502+ */
3503+
3504+#ifndef FAKE_OUTPUT_H
3505+#define FAKE_OUTPUT_H
3506+
3507+#include "output/output.h"
3508+
3509+namespace DisplayPlugin
3510+{
3511+class FakeOutput : public Output
3512+{
3513+public:
3514+ explicit FakeOutput() {}
3515+ ~FakeOutput() {}
3516+ virtual QSharedPointer<OutputMode> getPreferredMode() override
3517+ {
3518+ if (m_preferredModeIndex < m_modes.size()) {
3519+ return m_modes.at(m_preferredModeIndex);
3520+ } else {
3521+ return QSharedPointer<OutputMode>(Q_NULLPTR);
3522+ }
3523+ }
3524+ virtual QSharedPointer<OutputMode> getCurrentMode() override
3525+ {
3526+ if (m_currentModeIndex < m_modes.size()) {
3527+ return m_modes.at(m_currentModeIndex);
3528+ } else {
3529+ return QSharedPointer<OutputMode>(Q_NULLPTR);
3530+ }
3531+ }
3532+ virtual QList<QSharedPointer<OutputMode>> getAvailableModes() override
3533+ {
3534+ return m_modes;
3535+ }
3536+ virtual int getId() override
3537+ {
3538+ return m_id;
3539+ }
3540+ virtual Enums::OutputType getType() override
3541+ {
3542+ return m_type;
3543+ }
3544+ virtual int getPositionX() override
3545+ {
3546+ return m_positionX;
3547+ }
3548+ virtual int getPositionY() override
3549+ {
3550+ return m_positionY;
3551+ }
3552+ virtual Enums::ConnectionState getConnectionState() override
3553+ {
3554+ return m_connectionState;
3555+ }
3556+ virtual bool isEnabled() override
3557+ {
3558+ return m_enabled;
3559+ }
3560+ virtual QString getModel() override
3561+ {
3562+ return m_model;
3563+ }
3564+ virtual int getPhysicalWidthMm() override
3565+ {
3566+ return m_physicalWidthMm;
3567+ }
3568+ virtual int getPhysicalHeightMm() override
3569+ {
3570+ return m_physicalHeightMm;
3571+ }
3572+ virtual Enums::PowerMode getPowerMode() override
3573+ {
3574+ return m_powerMode;
3575+ }
3576+ virtual Enums::Orientation getOrientation() override
3577+ {
3578+ return m_orientation;
3579+ }
3580+ virtual float getScaleFactor() override
3581+ {
3582+ return m_scaleFactor;
3583+ }
3584+ virtual uint8_t const* getEdid() override
3585+ {
3586+ return m_edid;
3587+ }
3588+ virtual void setPosition(const int &x, const int &y) override
3589+ {
3590+ m_positionY = y;
3591+ m_positionX = x;
3592+ }
3593+ virtual void setEnabled(const bool enabled) override
3594+ {
3595+ m_enabled = enabled;
3596+ }
3597+ virtual void setPowerMode(const Enums::PowerMode &mode) override
3598+ {
3599+ m_powerMode = mode;
3600+ }
3601+ virtual void setOrientation(const Enums::Orientation &orientation) override
3602+ {
3603+ m_orientation = orientation;
3604+ }
3605+ virtual void setScaleFactor(const float &scale) override
3606+ {
3607+ m_scaleFactor = scale;
3608+ }
3609+ virtual void setCurrentMode(const QSharedPointer<OutputMode> &mode) override
3610+ {
3611+ m_currentModeIndex = m_modes.indexOf(mode);
3612+ }
3613+ QList<QSharedPointer<OutputMode>> m_modes;
3614+ bool m_enabled = false;
3615+ bool m_gammaSupported = false;
3616+ int m_preferredModeIndex;
3617+ int m_currentModeIndex = 0;
3618+ int m_numPixelFormats = 0;
3619+ int m_id = 0;
3620+ Enums::OutputType m_type = Enums::OutputType::OutputTypeUnknown;
3621+ int m_positionX = 0;
3622+ int m_positionY = 0;
3623+ Enums::ConnectionState m_connectionState = Enums::ConnectionState::Unknown;
3624+ QString m_model = QString::null;
3625+ int m_physicalWidthMm = 0;
3626+ int m_physicalHeightMm = 0;
3627+ Enums::PowerMode m_powerMode = Enums::PowerMode::OffMode;
3628+ Enums::Orientation m_orientation = Enums::Orientation::NormalOrientation;
3629+ float m_scaleFactor = 0.0;
3630+ uint8_t const* m_edid;
3631+ uint32_t m_gammaSize = 0;
3632+};
3633+} // DisplaPlugin
3634+
3635+#endif // FAKE_OUTPUT_H
3636
3637=== added file 'tests/mocks/plugins/brightness/fakeoutputmode.h'
3638--- tests/mocks/plugins/brightness/fakeoutputmode.h 1970-01-01 00:00:00 +0000
3639+++ tests/mocks/plugins/brightness/fakeoutputmode.h 2017-02-06 14:24:05 +0000
3640@@ -0,0 +1,58 @@
3641+/*
3642+ * This file is part of system-settings
3643+ *
3644+ * Copyright (C) 2017 Canonical Ltd.
3645+ *
3646+ * This program is free software: you can redistribute it and/or modify it
3647+ * under the terms of the GNU General Public License version 3, as published
3648+ * by the Free Software Foundation.
3649+ *
3650+ * This program is distributed in the hope that it will be useful, but
3651+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3652+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3653+ * PURPOSE. See the GNU General Public License for more details.
3654+ *
3655+ * You should have received a copy of the GNU General Public License along
3656+ * with this program. If not, see <http://www.gnu.org/licenses/>.
3657+ */
3658+
3659+#ifndef FAKE_OUTPUTMODE_H
3660+#define FAKE_OUTPUTMODE_H
3661+
3662+#include "outputmode/outputmode.h"
3663+
3664+namespace DisplayPlugin
3665+{
3666+class FakeOutputMode : public OutputMode
3667+{
3668+public:
3669+ virtual ~FakeOutputMode()
3670+ {
3671+ }
3672+
3673+ virtual int getWidth() override
3674+ {
3675+ return m_width;
3676+ }
3677+ virtual int getHeight() override
3678+ {
3679+ return m_height;
3680+ }
3681+ virtual double getRefreshRate() override
3682+ {
3683+ return m_refreshRate;
3684+ }
3685+ virtual QString toString() override
3686+ {
3687+ return m_string;
3688+ }
3689+
3690+ int m_width = 0;
3691+ int m_height = 0;
3692+ double m_refreshRate = 0;
3693+ QString m_string = QString::null;
3694+};
3695+
3696+} // DisplayPlugin
3697+
3698+#endif // FAKE_OUTPUTMODE_H
3699
3700=== modified file 'tests/plugins/CMakeLists.txt'
3701--- tests/plugins/CMakeLists.txt 2016-12-05 15:02:00 +0000
3702+++ tests/plugins/CMakeLists.txt 2017-02-06 14:24:05 +0000
3703@@ -4,6 +4,9 @@
3704 add_subdirectory(security-privacy)
3705 add_subdirectory(system-update)
3706 add_subdirectory(bluetooth)
3707+if(ANDR_PROP_FOUND)
3708+ add_subdirectory(brightness)
3709+endif()
3710 add_subdirectory(wifi)
3711 add_subdirectory(notifications)
3712
3713@@ -56,6 +59,17 @@
3714 IMPORT_PATHS ${SYSTEMUPDATE_IMPORT_PATHS}
3715 )
3716
3717+if(ANDR_PROP_FOUND)
3718+ set(BRIGHTNESS_IMPORT_PATHS
3719+ ${CMAKE_SOURCE_DIR}/src
3720+ ${CMAKE_BINARY_DIR}/tests/utils/modules
3721+ ${CMAKE_BINARY_DIR}/tests/mocks/
3722+ ${CMAKE_SOURCE_DIR}/tests/plugins/brightness
3723+ )
3724+ add_qml_test(brightness BrightnessPageComponent IMPORT_PATHS ${BRIGHTNESS_IMPORT_PATHS})
3725+ add_qml_test(brightness BrightnessWifiDisplays IMPORT_PATHS ${BRIGHTNESS_IMPORT_PATHS})
3726+endif()
3727+
3728 add_qml_test(main MainWindow
3729 IMPORT_PATHS
3730 ${CMAKE_BINARY_DIR}/tests/mocks/
3731
3732=== added directory 'tests/plugins/brightness'
3733=== added file 'tests/plugins/brightness/CMakeLists.txt'
3734--- tests/plugins/brightness/CMakeLists.txt 1970-01-01 00:00:00 +0000
3735+++ tests/plugins/brightness/CMakeLists.txt 2017-02-06 14:24:05 +0000
3736@@ -0,0 +1,38 @@
3737+pkg_search_module(MIR_CORE REQUIRED mircore)
3738+pkg_search_module(MIR_CLIENT REQUIRED mirclient)
3739+
3740+include_directories(
3741+ ${CMAKE_CURRENT_BINARY_DIR}
3742+ ${CMAKE_SOURCE_DIR}/plugins/brightness
3743+ ${CMAKE_SOURCE_DIR}/plugins/brightness/displays
3744+ ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/brightness
3745+ ${MIR_CORE_INCLUDE_DIRS}
3746+ ${MIR_CLIENT_INCLUDE_DIRS}
3747+)
3748+
3749+find_package(Qt5Core REQUIRED)
3750+find_package(Qt5DBus REQUIRED)
3751+find_package(Qt5Qml REQUIRED)
3752+find_package(Qt5Test REQUIRED)
3753+
3754+set(PLUGIN_LIBS uss-displays Qt5::Qml Qt5::Test Qt5::DBus)
3755+set(FAKE_MIR_CODE
3756+ ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/brightness/fakemirclient.h
3757+ ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/brightness/fakeoutput.h
3758+ ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/brightness/fakeoutputmode.h
3759+)
3760+
3761+add_executable(tst-brightness
3762+ ${FAKE_MIR_CODE}
3763+ ${CMAKE_SOURCE_DIR}/plugins/brightness/brightness.cpp
3764+ tst_brightness.cpp)
3765+add_test(tst-brightness tst-brightness)
3766+target_link_libraries(tst-brightness ${PLUGIN_LIBS} ${ANDR_PROP_LDFLAGS})
3767+
3768+add_executable(tst-displayplugin-display tst_displayplugin_display.cpp)
3769+add_test(tst-displayplugin-display tst-displayplugin-display)
3770+target_link_libraries(tst-displayplugin-display ${PLUGIN_LIBS})
3771+
3772+add_executable(tst-displayplugin-displaymodel tst_displayplugin_displaymodel.cpp)
3773+add_test(tst-displayplugin-displaymodel tst-displayplugin-displaymodel)
3774+target_link_libraries(tst-displayplugin-displaymodel ${PLUGIN_LIBS})
3775
3776=== added directory 'tests/plugins/brightness/Source'
3777=== added file 'tests/plugins/brightness/Source/qmldir'
3778--- tests/plugins/brightness/Source/qmldir 1970-01-01 00:00:00 +0000
3779+++ tests/plugins/brightness/Source/qmldir 2017-02-06 14:24:05 +0000
3780@@ -0,0 +1,3 @@
3781+module Source
3782+PageComponent 1.0 ../../../../plugins/brightness/PageComponent.qml
3783+WifiDisplays 1.0 ../../../../plugins/brightness/WifiDisplays.qml
3784
3785=== added file 'tests/plugins/brightness/tst_BrightnessPageComponent.qml'
3786--- tests/plugins/brightness/tst_BrightnessPageComponent.qml 1970-01-01 00:00:00 +0000
3787+++ tests/plugins/brightness/tst_BrightnessPageComponent.qml 2017-02-06 14:24:05 +0000
3788@@ -0,0 +1,190 @@
3789+/*
3790+ * This file is part of system-settings
3791+ *
3792+ * Copyright (C) 2016 Canonical Ltd.
3793+ *
3794+ * This program is free software: you can redistribute it and/or modify it
3795+ * under the terms of the GNU General Public License version 3, as published
3796+ * by the Free Software Foundation.
3797+ *
3798+ * This program is distributed in the hope that it will be useful, but
3799+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3800+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3801+ * PURPOSE. See the GNU General Public License for more details.
3802+ *
3803+ * You should have received a copy of the GNU General Public License along
3804+ * with this program. If not, see <http://www.gnu.org/licenses/>.
3805+ */
3806+
3807+import QtQuick 2.4
3808+import QtTest 1.0
3809+import Ubuntu.Components 1.3
3810+import Ubuntu.SystemSettings.Brightness 1.0
3811+import Ubuntu.Test 0.1
3812+
3813+import Source 1.0
3814+
3815+Item {
3816+ id: testRoot
3817+ width: 300
3818+ height: 500
3819+
3820+ Component {
3821+ id: pageComponent
3822+ PageComponent {
3823+ anchors.fill: parent
3824+ property bool showAllUI: true
3825+ }
3826+ }
3827+
3828+ UbuntuTestCase {
3829+ name: "BrightnessPageComponent"
3830+ when: windowShown
3831+
3832+ property var instance: null
3833+
3834+ function init() {
3835+ instance = pageComponent.createObject(testRoot, {});
3836+ }
3837+
3838+ function cleanup() {
3839+ instance.destroy();
3840+ }
3841+
3842+ function get_panel_plugin() {
3843+ return findInvisibleChild(instance, "brightnessPanel");
3844+ }
3845+
3846+ function get_aethercast_displays_plugin() {
3847+ return findInvisibleChild(instance, "aethercastDisplays");
3848+ }
3849+
3850+ function test_brightness_title() {
3851+ compare(instance.title, i18n.tr("Brightness"));
3852+ }
3853+
3854+ function test_brightness_and_displays_title() {
3855+ get_panel_plugin().setWidiSupported(true);
3856+ compare(instance.title, i18n.tr("Brightness & Display"));
3857+ }
3858+
3859+ function test_switch_disabled() {
3860+ var swtch = findChild(instance, "externalDisplayControl");
3861+ verify(!swtch.enabled);
3862+ }
3863+
3864+ function test_switch_enabled() {
3865+ get_panel_plugin().setWidiSupported(true);
3866+ var swtch = findChild(instance, "externalDisplayControl");
3867+ verify(swtch.enabled);
3868+ }
3869+
3870+ function test_casting_enabled() {
3871+ get_panel_plugin().setWidiSupported(true);
3872+ get_aethercast_displays_plugin().setEnabled(true);
3873+ var entry = findChild(instance, "displayCasting");
3874+
3875+ verify(entry.enabled);
3876+ compare(entry.value, i18n.tr("Not connected"));
3877+ }
3878+
3879+ function test_no_mir_displays() {
3880+ var repeater = findChild(instance, "displayConfigurationRepeater");
3881+ compare(repeater.count, 0);
3882+ }
3883+
3884+ function test_one_mir_display() {
3885+ get_panel_plugin().mockAddDisplay(true);
3886+ var repeater = findChild(instance, "displayConfigurationRepeater");
3887+ compare(repeater.count, 1);
3888+ }
3889+ }
3890+
3891+ UbuntuTestCase {
3892+ name: "BrightnessPageComponent for one Mir display"
3893+ when: windowShown
3894+
3895+ SignalSpy {
3896+ id: signalSpy
3897+ signalName: ""
3898+ target: null
3899+ }
3900+
3901+ property var instance: null
3902+
3903+ function init() {
3904+ instance = pageComponent.createObject(testRoot, {});
3905+ }
3906+
3907+ function cleanup() {
3908+ instance.destroy();
3909+ signalSpy.target = null;
3910+ }
3911+
3912+ function get_panel_plugin() {
3913+ return findInvisibleChild(instance, "brightnessPanel");
3914+ }
3915+
3916+ function test_no_changes_disables_apply() {
3917+ get_panel_plugin().mockAddDisplay(true);
3918+ var obj = findChild(instance, "applyButton");
3919+ verify(!obj.enabled);
3920+ }
3921+
3922+ function test_a_change_enables_apply() {
3923+ get_panel_plugin().mockAddDisplay(true);
3924+ var obj = findChild(instance, "enabledSwitch");
3925+ var apply = findChild(instance, "applyButton");
3926+ mouseClick(obj, obj.width / 2, obj.height / 2);
3927+ }
3928+
3929+ function test_apply() {
3930+ get_panel_plugin().mockAddDisplay(true);
3931+ signalSpy.target = get_panel_plugin();
3932+ signalSpy.signalName = "applied";
3933+
3934+ var obj = findChild(instance, "enabledSwitch");
3935+ mouseClick(obj, obj.width / 2, obj.height / 2);
3936+ obj = findChild(instance, "applyButton");
3937+ mouseClick(obj, obj.width / 2, obj.height / 2);
3938+
3939+ signalSpy.wait();
3940+ }
3941+
3942+ function test_default_rotation() {
3943+ get_panel_plugin().mockAddDisplay(true, true, 0, 0, 0);
3944+ var obj = findChild(instance, "rotationSelector");
3945+ compare(obj.selectedIndex, 0);
3946+ }
3947+
3948+ function test_other_rotation() {
3949+ get_panel_plugin().mockAddDisplay(true, true, 0, 0, 1);
3950+ var obj = findChild(instance, "rotationSelector");
3951+ compare(obj.selectedIndex, 1);
3952+ }
3953+
3954+ function test_change_rotation() {
3955+ get_panel_plugin().mockAddDisplay(true, true, 0, 0, 0);
3956+ var obj = findChild(instance, "rotationSelector");
3957+ obj.delegateClicked(2);
3958+ }
3959+
3960+ function test_one_resolution() {
3961+ get_panel_plugin().mockAddDisplay(true, true, 1, 0);
3962+ var obj = findChild(instance, "resolutionLabel");
3963+ compare(obj.text, i18n.tr("Resolution: %1").arg("Mode 0"));
3964+ }
3965+
3966+ function test_many_resolutions() {
3967+ get_panel_plugin().mockAddDisplay(true, true, 2, 1);
3968+ var obj = findChild(instance, "resolutionSelector");
3969+ compare(obj.selectedIndex, 1);
3970+ }
3971+
3972+ function test_change_resolution() {
3973+ get_panel_plugin().mockAddDisplay(true, true, 2, 1);
3974+ var obj = findChild(instance, "resolutionSelector");
3975+ obj.delegateClicked(0);
3976+ }
3977+ }
3978+}
3979
3980=== added file 'tests/plugins/brightness/tst_BrightnessWifiDisplays.qml'
3981--- tests/plugins/brightness/tst_BrightnessWifiDisplays.qml 1970-01-01 00:00:00 +0000
3982+++ tests/plugins/brightness/tst_BrightnessWifiDisplays.qml 2017-02-06 14:24:05 +0000
3983@@ -0,0 +1,79 @@
3984+/*
3985+ * This file is part of system-settings
3986+ *
3987+ * Copyright (C) 2016 Canonical Ltd.
3988+ *
3989+ * This program is free software: you can redistribute it and/or modify it
3990+ * under the terms of the GNU General Public License version 3, as published
3991+ * by the Free Software Foundation.
3992+ *
3993+ * This program is distributed in the hope that it will be useful, but
3994+ * WITHOUT ANY WARRANTY; without even the implied warranties of
3995+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3996+ * PURPOSE. See the GNU General Public License for more details.
3997+ *
3998+ * You should have received a copy of the GNU General Public License along
3999+ * with this program. If not, see <http://www.gnu.org/licenses/>.
4000+ */
4001+
4002+import QtQuick 2.4
4003+import QtTest 1.0
4004+import Ubuntu.Components 1.3
4005+import Ubuntu.SystemSettings.Brightness 1.0
4006+import Ubuntu.Test 0.1
4007+
4008+import Source 1.0
4009+
4010+Item {
4011+ id: testRoot
4012+ width: 300
4013+ height: 500
4014+
4015+ Component {
4016+ id: wifiDisplays
4017+ WifiDisplays {
4018+ anchors.fill: parent
4019+ }
4020+ }
4021+
4022+ UbuntuTestCase {
4023+ name: "BrightnessWifiDisplays"
4024+ when: windowShown
4025+
4026+ property var instance: null
4027+
4028+ function get_aethercast_displays_plugin() {
4029+ return findInvisibleChild(instance, "aethercastDisplays");
4030+ }
4031+
4032+ function init() {
4033+ instance = wifiDisplays.createObject(testRoot, {});
4034+ }
4035+
4036+ function cleanup() {
4037+ instance.destroy();
4038+ }
4039+
4040+ function test_no_devices() {
4041+ var label = findChild(instance, "noDisplaysDetected");
4042+ verify(label.visible);
4043+ compare(label.text, i18n.tr("No displays detected"));
4044+ }
4045+
4046+ function test_one_device() {
4047+ var plugin = get_aethercast_displays_plugin();
4048+ plugin.devices.addDevice("addr", "my display", AethercastDevice.Idle);
4049+ plugin.connectedDevices.addDevice("addr", "my display", AethercastDevice.Idle);
4050+
4051+ var label = findChild(instance, "noDisplaysDetected");
4052+ verify(!label.visible);
4053+
4054+ var header = findChild(instance, "connectedDisplay");
4055+ verify(header.visible);
4056+
4057+ var repeater = findChild(instance, "displayRepeater");
4058+ compare(repeater.count, 1);
4059+ }
4060+
4061+ }
4062+}
4063
4064=== added file 'tests/plugins/brightness/tst_brightness.cpp'
4065--- tests/plugins/brightness/tst_brightness.cpp 1970-01-01 00:00:00 +0000
4066+++ tests/plugins/brightness/tst_brightness.cpp 2017-02-06 14:24:05 +0000
4067@@ -0,0 +1,131 @@
4068+/*
4069+ * This file is part of system-settings
4070+ *
4071+ * Copyright (C) 2016 Canonical Ltd.
4072+ *
4073+ * This program is free software: you can redistribute it and/or modify it
4074+ * under the terms of the GNU General Public License version 3, as published
4075+ * by the Free Software Foundation.
4076+ *
4077+ * This program is distributed in the hope that it will be useful, but
4078+ * WITHOUT ANY WARRANTY; without even the implied warranties of
4079+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4080+ * PURPOSE. See the GNU General Public License for more details.
4081+ *
4082+ * You should have received a copy of the GNU General Public License along
4083+ * with this program. If not, see <http://www.gnu.org/licenses/>.
4084+ */
4085+
4086+#include "brightness.h"
4087+#include "fakemirclient.h"
4088+#include "fakeoutput.h"
4089+#include "fakeoutputmode.h"
4090+
4091+#include <QSignalSpy>
4092+#include <QTest>
4093+
4094+using namespace DisplayPlugin;
4095+
4096+class TstBrightness : public QObject
4097+{
4098+ Q_OBJECT
4099+private slots:
4100+ void init()
4101+ {
4102+ // m_mode1.vertical_resolution = 1280;
4103+ // m_mode1.horizontal_resolution = 1024;
4104+ // m_mode1.refresh_rate = 60;
4105+
4106+ // m_mode2.vertical_resolution = 640;
4107+ // m_mode2.horizontal_resolution = 320;
4108+ // m_mode2.refresh_rate = 30;
4109+
4110+ // m_modes[0] = m_mode1;
4111+ // m_modes[1] = m_mode2;
4112+
4113+ // m_output.modes = m_modes;
4114+ // m_output.num_modes = 2;
4115+ // m_output.current_mode = 0;
4116+ // m_output.output_id = 0;
4117+ // m_output.type = MirDisplayOutputType::mir_display_output_type_edp;
4118+ // m_output.connected = true;
4119+ // m_output.used = true;
4120+ // m_output.orientation = MirOrientation::mir_orientation_left;
4121+
4122+ // m_outputs[0] = m_output;
4123+ // m_conf.num_outputs = 1;
4124+ // m_conf.outputs = m_outputs;
4125+
4126+ // m_mirClient = new FakeMirClient();
4127+ // m_mirClient->connected = true;
4128+
4129+ // m_mirClient->conf = &m_conf;
4130+ // m_instance = new Brightness(QDBusConnection::systemBus(),
4131+ // m_mirClient);
4132+ }
4133+ void cleanup()
4134+ {
4135+ // QSignalSpy destroyedSpy(m_instance, SIGNAL(destroyed(QObject*)));
4136+ // m_instance->deleteLater();
4137+ // QTRY_COMPARE(destroyedSpy.count(), 1);
4138+ }
4139+ void test_null_config_when_connected()
4140+ {
4141+ FakeMirClient mc;
4142+ mc.connected = true;
4143+ mc.conf = nullptr;
4144+ Brightness b(QDBusConnection::systemBus(), &mc);
4145+ QCOMPARE(b.allDisplays()->rowCount(), 0);
4146+ }
4147+ void test_not_connected_to_mir()
4148+ {
4149+ FakeMirClient mc;
4150+ mc.connected = false;
4151+ Brightness b(QDBusConnection::systemBus(), &mc);
4152+ QCOMPARE(b.allDisplays()->rowCount(), 0);
4153+ }
4154+ void test_some_config_populates_model()
4155+ {
4156+ FakeMirClient mc;
4157+ mc.connected = true;
4158+ mc.configurationValid = true;
4159+
4160+ QList<QSharedPointer<Output>> list;
4161+ QSharedPointer<Output> output(new FakeOutput);
4162+ list << output;
4163+
4164+ mc.m_outputs = list;
4165+
4166+ Brightness b(QDBusConnection::systemBus(), &mc);
4167+ QCOMPARE(b.allDisplays()->rowCount(), 1);
4168+ }
4169+ // void test_a_display_was_configured()
4170+ // {
4171+ // auto model = (DisplayModel*) m_instance->allDisplays();
4172+ // auto display = model->getById(0);
4173+
4174+ // QCOMPARE(display->type(), QString("edp"));
4175+ // }
4176+ // void test_apply_config_to_display()
4177+ // {
4178+ // auto model = (DisplayModel*) m_instance->allDisplays();
4179+ // auto display = model->getById(0);
4180+ // display->setMode(1);
4181+ // display->setEnabled(false);
4182+ // display->setOrientation(Display::Orientation::NormalOrientation);
4183+
4184+ // m_instance->applyDisplayConfiguration();
4185+
4186+ // MirDisplayOutput output = m_mirClient->conf->outputs[0];
4187+ // QCOMPARE(output.current_mode, (uint) 1);
4188+ // QCOMPARE((bool) output.used, false);
4189+ // QCOMPARE(output.orientation, MirOrientation::mir_orientation_normal);
4190+ // }
4191+
4192+private:
4193+ FakeMirClient *m_mirClient = nullptr;
4194+ Brightness *m_instance = nullptr;
4195+};
4196+
4197+QTEST_GUILESS_MAIN(TstBrightness)
4198+#include "tst_brightness.moc"
4199
4200=== added file 'tests/plugins/brightness/tst_displayplugin_display.cpp'
4201--- tests/plugins/brightness/tst_displayplugin_display.cpp 1970-01-01 00:00:00 +0000
4202+++ tests/plugins/brightness/tst_displayplugin_display.cpp 2017-02-06 14:24:05 +0000
4203@@ -0,0 +1,120 @@
4204+/*
4205+ * This file is part of system-settings
4206+ *
4207+ * Copyright (C) 2016 Canonical Ltd.
4208+ *
4209+ * This program is free software: you can redistribute it and/or modify it
4210+ * under the terms of the GNU General Public License version 3, as published
4211+ * by the Free Software Foundation.
4212+ *
4213+ * This program is distributed in the hope that it will be useful, but
4214+ * WITHOUT ANY WARRANTY; without even the implied warranties of
4215+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4216+ * PURPOSE. See the GNU General Public License for more details.
4217+ *
4218+ * You should have received a copy of the GNU General Public License along
4219+ * with this program. If not, see <http://www.gnu.org/licenses/>.
4220+ */
4221+
4222+#include "fakeoutput.h"
4223+#include "fakeoutputmode.h"
4224+
4225+#include "display.h"
4226+#include "helpers.h"
4227+
4228+#include <QSharedPointer>
4229+#include <QSignalSpy>
4230+#include <QTest>
4231+
4232+Q_DECLARE_METATYPE(QSharedPointer<DisplayPlugin::Output>)
4233+
4234+using namespace DisplayPlugin;
4235+
4236+class TstDisplay : public QObject
4237+{
4238+ Q_OBJECT
4239+private slots:
4240+ void initTestCase()
4241+ {
4242+ qRegisterMetaType<const Display*>("const Display*");
4243+ }
4244+ void test_instantiation_data()
4245+ {
4246+ QTest::addColumn<QSharedPointer<Output>>("output");
4247+
4248+ {
4249+ auto output = QSharedPointer<Output>(new FakeOutput);
4250+ QTest::newRow("defaults") << output;
4251+ }
4252+ {
4253+ auto output = QSharedPointer<Output>(new FakeOutput);
4254+ getFakeOutput(output)->m_enabled = true;
4255+ getFakeOutput(output)->m_type = Enums::OutputType::OutputTypeEdp;
4256+ getFakeOutput(output)->m_connectionState = Enums::ConnectionState::Connected;
4257+ getFakeOutput(output)->m_powerMode = Enums::PowerMode::SuspendMode;
4258+ getFakeOutput(output)->m_orientation = Enums::Orientation::LandscapeInvertedModeOrientation;
4259+ getFakeOutput(output)->m_id = 42;
4260+ QTest::newRow("example screen") << output;
4261+ }
4262+ {
4263+ auto output = QSharedPointer<Output>(new FakeOutput);
4264+
4265+ auto mode1 = QSharedPointer<OutputMode>(new FakeOutputMode);
4266+ auto mode2 = QSharedPointer<OutputMode>(new FakeOutputMode);
4267+ QList<QSharedPointer<OutputMode>> modes({mode1, mode2});
4268+
4269+ getFakeOutput(output)->m_modes = modes;
4270+ QTest::newRow("with modes") << output;
4271+ }
4272+ }
4273+ void test_instantiation()
4274+ {
4275+ QFETCH(QSharedPointer<Output>, output);
4276+ Display display(output);
4277+ QCOMPARE(display.enabled(), output->isEnabled());
4278+ QCOMPARE(display.powerMode(), output->getPowerMode());
4279+ QCOMPARE(display.orientation(), output->getOrientation());
4280+ // Test Connected, etc.
4281+
4282+ QCOMPARE(display.mode(), output->getCurrentMode());
4283+ QCOMPARE(display.availableModes(), output->getAvailableModes());
4284+ }
4285+ void test_modes()
4286+ {
4287+ auto output = QSharedPointer<Output>(new FakeOutput);
4288+ Display display(output);
4289+ }
4290+ void test_changes_emit_signal()
4291+ {
4292+ auto output = QSharedPointer<Output>(new FakeOutput);
4293+ getFakeOutput(output)->m_enabled = false;
4294+
4295+ Display display(output);
4296+ QSignalSpy changedSpy(&display, SIGNAL(displayChanged(const Display*)));
4297+ display.setEnabled(true);
4298+ QTRY_COMPARE(changedSpy.count(), 2);
4299+ }
4300+ void test_new_display_no_uncommitted_changes()
4301+ {
4302+ auto output = QSharedPointer<Output>(new FakeOutput);
4303+ Display display(output);
4304+ QVERIFY(!display.uncommittedChanges());
4305+ }
4306+ void test_changed_display_has_uncommitted_changes()
4307+ {
4308+ auto output = QSharedPointer<Output>(new FakeOutput);
4309+ getFakeOutput(output)->m_enabled = false;
4310+
4311+ Display display(output);
4312+ display.setEnabled(true);
4313+ QVERIFY(display.uncommittedChanges());
4314+ }
4315+private:
4316+ FakeOutput* getFakeOutput(const QSharedPointer<Output> &output)
4317+ {
4318+ return (FakeOutput*) output.data();
4319+ }
4320+};
4321+
4322+QTEST_GUILESS_MAIN(TstDisplay)
4323+#include "tst_displayplugin_display.moc"
4324
4325=== added file 'tests/plugins/brightness/tst_displayplugin_displaymodel.cpp'
4326--- tests/plugins/brightness/tst_displayplugin_displaymodel.cpp 1970-01-01 00:00:00 +0000
4327+++ tests/plugins/brightness/tst_displayplugin_displaymodel.cpp 2017-02-06 14:24:05 +0000
4328@@ -0,0 +1,146 @@
4329+/*
4330+ * This file is part of system-settings
4331+ *
4332+ * Copyright (C) 2016 Canonical Ltd.
4333+ *
4334+ * This program is free software: you can redistribute it and/or modify it
4335+ * under the terms of the GNU General Public License version 3, as published
4336+ * by the Free Software Foundation.
4337+ *
4338+ * This program is distributed in the hope that it will be useful, but
4339+ * WITHOUT ANY WARRANTY; without even the implied warranties of
4340+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4341+ * PURPOSE. See the GNU General Public License for more details.
4342+ *
4343+ * You should have received a copy of the GNU General Public License along
4344+ * with this program. If not, see <http://www.gnu.org/licenses/>.
4345+ */
4346+
4347+#include "fakeoutput.h"
4348+#include "fakeoutputmode.h"
4349+
4350+#include "display.h"
4351+#include "displaymodel.h"
4352+
4353+#include <QSignalSpy>
4354+#include <QTest>
4355+
4356+Q_DECLARE_METATYPE(DisplayPlugin::DisplayModel::Roles)
4357+
4358+using namespace DisplayPlugin;
4359+
4360+class TstDisplayModel : public QObject
4361+{
4362+ Q_OBJECT
4363+private:
4364+ QSharedPointer<Display> createDisplay()
4365+ {
4366+ auto output = QSharedPointer<Output>(new FakeOutput);
4367+
4368+ // Add two modes
4369+ auto mode1 = QSharedPointer<OutputMode>(new FakeOutputMode);
4370+ ((FakeOutputMode*) mode1.data())->m_width = 1000;
4371+ auto mode2 = QSharedPointer<OutputMode>(new FakeOutputMode);
4372+ ((FakeOutputMode*) mode2.data())->m_width = 2000;
4373+
4374+ ((FakeOutput*) output.data())->m_modes << mode1 << mode2;
4375+
4376+ auto display = QSharedPointer<Display>(new Display(output));
4377+ return display;
4378+ }
4379+private slots:
4380+ void init()
4381+ {
4382+ m_instance = new DisplayModel();
4383+ }
4384+ void cleanup()
4385+ {
4386+ QSignalSpy destroyedSpy(m_instance, SIGNAL(destroyed(QObject*)));
4387+ m_instance->deleteLater();
4388+ QTRY_COMPARE(destroyedSpy.count(), 1);
4389+ }
4390+ void test_roles_data()
4391+ {
4392+ QTest::addColumn<DisplayModel::Roles>("role");
4393+ QTest::addColumn<QVariant>("value");
4394+ QTest::addColumn<QSharedPointer<Display>>("display");
4395+
4396+ {
4397+ auto display = createDisplay();
4398+ DisplayModel::Roles role(DisplayModel::ConnectedRole);
4399+ QVariant value(false);
4400+ QTest::newRow("ConnectedRole") << role << value << display;
4401+ }
4402+ {
4403+ auto display = createDisplay();
4404+ DisplayModel::Roles role(DisplayModel::EnabledRole);
4405+ QVariant value(true);
4406+ display->setEnabled(true);
4407+ QTest::newRow("EnabledRole") << role << value << display;
4408+ }
4409+ {
4410+ auto display = createDisplay();
4411+ DisplayModel::Roles role(DisplayModel::ModeRole);
4412+ QVariant value(display->availableModes().at(1));
4413+ display->setMode(display->availableModes().at(1));
4414+ QTest::newRow("ModeRole") << role << value << display;
4415+ }
4416+ {
4417+ auto display = createDisplay();
4418+ DisplayModel::Roles role(DisplayModel::OrientationRole);
4419+ QVariant value((uint) Enums::Orientation::PortraitInvertedModeOrientation);
4420+ display->setOrientation(Enums::Orientation::PortraitInvertedModeOrientation);
4421+ QTest::newRow("OrientationRole") << role << value << display;
4422+ }
4423+ {
4424+ auto display = createDisplay();
4425+ DisplayModel::Roles role(DisplayModel::ScaleRole);
4426+ QVariant value(2);
4427+ display->setScale(2);
4428+ QTest::newRow("ScaleRole") << role << value << display;
4429+ }
4430+ {
4431+ auto display = createDisplay();
4432+ DisplayModel::Roles role(DisplayModel::UncommittedChangesRole);
4433+ QVariant value(true);
4434+ display->setEnabled(true); // this will make the target value true.
4435+ QTest::newRow("UncommittedChangesRole") << role << value << display;
4436+ }
4437+ }
4438+ void test_roles()
4439+ {
4440+ QFETCH(DisplayModel::Roles, role);
4441+ QFETCH(QVariant, value);
4442+ QFETCH(QSharedPointer<Display>, display);
4443+
4444+ m_instance->addDisplay(display);
4445+ QCOMPARE(m_instance->data(m_instance->index(0), role), value);
4446+ }
4447+ void test_add_display()
4448+ {
4449+ auto display = createDisplay();
4450+
4451+ QSignalSpy insertedSpy(m_instance, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int)));
4452+ m_instance->addDisplay(display);
4453+ QTRY_COMPARE(insertedSpy.count(), 1);
4454+ QCOMPARE(m_instance->rowCount(), 1);
4455+ }
4456+ void test_update_display()
4457+ {
4458+ auto display = createDisplay();
4459+ display->setEnabled(true);
4460+ m_instance->addDisplay(display);
4461+
4462+ QSignalSpy dataChangedSpy(m_instance, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)));
4463+ display->setEnabled(true);
4464+ m_instance->addDisplay(display);
4465+ QTRY_COMPARE(dataChangedSpy.count(), 1);
4466+ QCOMPARE(m_instance->rowCount(), 1);
4467+ }
4468+private:
4469+ DisplayModel *m_instance;
4470+};
4471+
4472+QTEST_GUILESS_MAIN(TstDisplayModel)
4473+#include "tst_displayplugin_displaymodel.moc"
4474+

Subscribers

People subscribed via source and target branches