libhud-qt-0.1.0+13.10.20130719/0000755000015700001700000000000012172126127015740 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/include/0000755000015700001700000000000012172126127017363 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/include/ToolbarAction0000644000015700001700000000132512172126001022036 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "toolbar-action.h" libhud-qt-0.1.0+13.10.20130719/include/Action0000644000015700001700000000131512172126001020512 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "action.h" libhud-qt-0.1.0+13.10.20130719/README0000644000015700001700000000000012172126001016575 0ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/libhud-qt.pro0000644000015700001700000000252312172126001020344 0ustar pbuserpbgroup00000000000000include( coverage.pri ) TEMPLATE = subdirs SUBDIRS = src qml examples doc tests CONFIG += ordered # Add more folders to ship with the application, here #folder_01.source = qml/untitled #folder_01.target = qml #DEPLOYMENTFOLDERS = folder_01 # Additional import path used to resolve QML modules in Creator's code model #QML_IMPORT_PATH = # If your application uses the Qt Mobility libraries, uncomment the following # lines and add the respective components to the MOBILITY variable. # CONFIG += mobility # MOBILITY += # The .cpp file which was generated for your project. Feel free to hack it. #SOURCES += main.cpp # Please do not modify the following two lines. Required for deployment. #include(qtquick2applicationviewer/qtquick2applicationviewer.pri) #qtcAddDeployment() #OTHER_FILES += \ # qml/untitled/Ubuntu/HUD/AppStack.qml # in subfolder .pri #defineTest(qtcAddDeployment) { #for(deploymentfolder, DEPLOYMENTFOLDERS) { # item = item$${deploymentfolder} # greaterThan(QT_MAJOR_VERSION, 4) { # itemsources = $${item}.files # } else { # itemsources = $${item}.sources # } # $$itemsources = $$eval($${deploymentfolder}.source) # itempath = $${item}.path # $$itempath= $$eval($${deploymentfolder}.target) # export($$itemsources) # export($$itempath) # DEPLOYMENT += $$item #} # #MAINPROFILEPWD = $$PWD libhud-qt-0.1.0+13.10.20130719/tests/0000755000015700001700000000000012172126127017102 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/tests/qml/0000755000015700001700000000000012172126127017673 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/tests/qml/tst_api.qml0000644000015700001700000000670012172126001022043 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import Ubuntu.HUD 1.0 as HUD import QtQuick 2.0 import QtTest 1.0 /* This test will make sure there are no unintentional changes to the * schemantics of the API (default properties work as expected, etc) * so that any files written to the prior release of the library * will not bail out when loaded resulting in client applications failing * to start. */ Item { HUD.HUD { id: hud applicationIdentifier: "testapp" HUD.Context { id: ctx1 HUD.FullscreenAction { onTriggered: { console.debug("fullscreen") } } HUD.HelpAction { onTriggered: { console.debug("help") } } HUD.SettingsAction { onTriggered: { console.debug("settings") } } HUD.UndoAction { onTriggered: { console.debug("undo") } } HUD.Action { label: "simpleaction" description: "simpleaciton" keywords: "simple;action" onTriggered: {} } HUD.Action { label: "paramaction" description: "lorem ipsum" hasLivePreview: true commitLabel: "Confirm" HUD.SliderParameter { label: "slider1" minimumValue: 0.0 maximumValue: 100.0 value: 50.0 live: true onValueChanged: {} } HUD.SliderParameter { label: "slider2" minimumValue: 0.0 maximumValue: 100.0 value: 50.0 live: true onValueChanged: {} } onStarted: {} onResetted: {} onCancelled: {} onTriggered: {} } } HUD.Context { id: ctx2 HUD.FullscreenAction { onTriggered: { console.debug("fullscreen") } enabled: false } HUD.HelpAction { onTriggered: { console.debug("help") } enabled: false } HUD.SettingsAction { onTriggered: { console.debug("settings") } enabled: false } HUD.UndoAction { onTriggered: { console.debug("undo") } enabled: false } } } TestCase { name: "API Test" id: test_api function test_api() { hud.setActiveContext(ctx2) // just make sure this file can be loaded properly by the QmlEngine. verify(1) } } } libhud-qt-0.1.0+13.10.20130719/tests/qml/tst_qml.cpp0000644000015700001700000000136112172126001022052 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include QUICK_TEST_MAIN(qml) libhud-qt-0.1.0+13.10.20130719/tests/qml/qml.pro0000644000015700001700000000206012172126001021173 0ustar pbuserpbgroup00000000000000TEMPLATE = app TARGET = tst_qml CONFIG += warn_on SOURCES += tst_qml.cpp QT += quick qmltest OTHER_FILES = tst_action.qml \ tst_api.qml ####################################### # tests are failing in armhf because # of a bug in qemu # https://bugs.launchpad.net/qemu-linaro/+bug/1084148 # Don't generate the 'make check' target for ARM. ####################################### !contains(QMAKE_HOST.arch,armv7l) { # Do not use CONFIG+=testcase because it would also # add a 'make install' target. # Instead create the 'make check' target manually. check.target = check check.commands = LD_LIBRARY_PATH=$$OUT_PWD/../../src/ check.commands += ./$$TARGET -platform minimal check.commands += -input $$PWD -import $$OUT_PWD/imports check.commands += -maxwarnings 4 -xunitxml > check.commands += ../../test_$(TARGET).xml if (!exists($$OUT_PWD/imports/Ubuntu/HUD/qmldir)) { system(mkdir -p $$OUT_PWD/imports/Ubuntu/HUD/) system("echo \"module Ubuntu.HUD\nplugin hud-qml $$OUT_PWD/../../qml\" > $$OUT_PWD/imports/Ubuntu/HUD/qmldir") } } libhud-qt-0.1.0+13.10.20130719/tests/qml/tst_action.qml0000644000015700001700000000200212172126001022536 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ // placeholder //import Ubuntu.HUD 0.1 as HUD import QtQuick 2.0 import QtTest 1.0 Item { //HUD.Action { // id: foo // identifier: "MyAction" //} TestCase { name: "Action Test" id: test1 function test_identifier() { skip() // skip for now.. // compare(foo.identifier, "MyAction") } } } libhud-qt-0.1.0+13.10.20130719/tests/cpp/0000755000015700001700000000000012172126127017664 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_parameter.h0000644000015700001700000000160012172126001022673 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include class TestParameter : public QObject { Q_OBJECT private slots: void setType(); void defaultValue(); void currentValue(); void name(); void updated(); }; libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_slider-parameter.h0000644000015700001700000000165112172126001024161 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include class TestSliderParameter : public QObject { Q_OBJECT private slots: void setMinimumValue(); void setMaximumValue(); void setStepSize(); void setValue(); void setLive(); void setLabel(); }; libhud-qt-0.1.0+13.10.20130719/tests/cpp/cpp.pro0000644000015700001700000000200412172126001021153 0ustar pbuserpbgroup00000000000000TEMPLATE = app TARGET = tst_libhud-qt SOURCES = \ main.cpp \ tst_action.cpp \ tst_context.cpp \ tst_hud.cpp \ tst_parameter.cpp \ tst_slider-parameter.cpp \ \ ../../src/action.cpp \ ../../src/context.cpp \ ../../src/hud.cpp \ ../../src/parameter.cpp \ ../../src/slider-parameter.cpp HEADERS = \ tst_action.h \ tst_context.h \ tst_hud.h \ tst_parameter.h \ tst_slider-parameter.h \ \ ../../src/action.h \ ../../src/context.h \ ../../src/hud.h \ ../../src/parameter.h \ ../../src/slider-parameter.h #LIBS += -L../../src -lhud-qt QT += testlib CONFIG += warn_on link_pkgconfig PKGCONFIG += hud-2 gio-2.0 include( ../../coverage.pri ) # Do not use CONFIG+=testcase because it would also # add a 'make install' target. # Instead create the 'make check' target manually. check.target = check check.commands = QT_QPA_PLATFORM=minimal ./$$TARGET check.commands += -maxwarnings 8 -xunitxml > check.commands += ../../test_$(TARGET).xml libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_action.cpp0000644000015700001700000001510412172126001022527 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "tst_action.h" #include "../../src/action.h" #include "../../src/slider-parameter.h" #include void TestAction::setIdentifier() { Ubuntu::HUD::Action action; QSignalSpy spy(&action, SIGNAL(identifierChanged(QString))); action.setIdentifier("myid"); QVERIFY(action.identifier() == "myid"); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toString() == "myid"); spy.clear(); action.setIdentifier("myid"); QCOMPARE(spy.count(), 0); } void TestAction::setLabel() { Ubuntu::HUD::Action action; QSignalSpy spy(&action, SIGNAL(labelChanged(QString))); action.setLabel("Foo"); QVERIFY(action.label() == "Foo"); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toString() == "Foo"); spy.clear(); action.setLabel("Foo"); QCOMPARE(spy.count(), 0); } void TestAction::setDescription() { Ubuntu::HUD::Action action; QSignalSpy spy(&action, SIGNAL(descriptionChanged(QString))); action.setDescription("Lorem Ipsum"); QVERIFY(action.description() == "Lorem Ipsum"); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toString() == "Lorem Ipsum"); spy.clear(); action.setDescription("Lorem Ipsum"); QCOMPARE(spy.count(), 0); } void TestAction::setKeywords() { Ubuntu::HUD::Action action; QString keywords; QSignalSpy spy(&action, SIGNAL(keywordsChanged(QString))); keywords = "Foo;Bar"; action.setKeywords(keywords); QVERIFY(action.keywords() == keywords); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toString() == keywords); spy.clear(); action.setKeywords(keywords); QCOMPARE(spy.count(), 0);} void TestAction::setIsBackgroundAction() { Ubuntu::HUD::Action action; action.setIsBackgroundAction(false); QSignalSpy spy(&action, SIGNAL(isBackgroundActionChanged(bool))); action.setIsBackgroundAction(true); QVERIFY(action.isBackgroundAction() == true); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toBool() == true); spy.clear(); action.setIsBackgroundAction(true); QCOMPARE(spy.count(), 0); } void TestAction::setEnabled() { Ubuntu::HUD::Action action; action.setEnabled(true); QSignalSpy spy(&action, SIGNAL(enabledChanged(bool))); action.setEnabled(false); QVERIFY(action.enabled() == false); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toBool() == false); spy.clear(); action.setEnabled(false); QCOMPARE(spy.count(), 0); } void TestAction::trigger() { Ubuntu::HUD::Action action; QSignalSpy spy(&action, SIGNAL(triggered())); action.trigger(); QCOMPARE(spy.count(), 1); } void TestAction::setCommitLabel() { Ubuntu::HUD::Action action; QSignalSpy spy(&action, SIGNAL(commitLabelChanged(QString))); action.setCommitLabel("commit_label"); QVERIFY(action.commitLabel() == "commit_label"); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toString() == "commit_label"); spy.clear(); action.setCommitLabel("commit_label"); QCOMPARE(spy.count(), 0); } void TestAction::setHasLivePreview() { Ubuntu::HUD::Action action; action.setHasLivePreview(false); QVERIFY(action.hasLivePreview() == false); QSignalSpy spy(&action, SIGNAL(hasLivePreviewChanged(bool))); action.setHasLivePreview(true); QVERIFY(action.hasLivePreview() == true); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toBool() == true); spy.clear(); action.setHasLivePreview(true); QCOMPARE(spy.count(), 0); } void TestAction::setHasNoPreview() { Ubuntu::HUD::Action action; action.setHasNoPreview(false); QVERIFY(action.hasNoPreview() == false); QSignalSpy spy(&action, SIGNAL(hasNoPreviewChanged(bool))); action.setHasNoPreview(true); QVERIFY(action.hasNoPreview() == true); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toBool() == true); spy.clear(); action.setHasNoPreview(true); QCOMPARE(spy.count(), 0); } void TestAction::setRequiresPreview() { Ubuntu::HUD::Action action; action.setRequiresPreview(false); QVERIFY(action.requiresPreview() == false); QSignalSpy spy(&action, SIGNAL(requiresPreviewChanged(bool))); action.setRequiresPreview(true); QVERIFY(action.requiresPreview() == true); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toBool() == true); spy.clear(); action.setRequiresPreview(true); QCOMPARE(spy.count(), 0); } void TestAction::parameterOperations() { Ubuntu::HUD::Action action; Ubuntu::HUD::SliderParameter param1; Ubuntu::HUD::SliderParameter param2; QList parameters; QSignalSpy params_spy(&action, SIGNAL(parametersChanged())); QSignalSpy added_spy(&action, SIGNAL(parameterAdded(Ubuntu::HUD::Parameter*))); QSignalSpy removed_spy(&action, SIGNAL(parameterRemoved(Ubuntu::HUD::Parameter*))); parameters = action.parameters(); QVERIFY(parameters.isEmpty()); action.addParameter(¶m1); QCOMPARE(params_spy.count(), 1); QCOMPARE(added_spy.count(), 1); QVERIFY(action.parameters().contains(¶m1)); action.addParameter(¶m2); QCOMPARE(params_spy.count(), 2); QCOMPARE(added_spy.count(), 2); QVERIFY(action.parameters().contains(¶m2)); action.removeParameter(¶m1); QCOMPARE(action.parameters().count(), 1); QVERIFY(!action.parameters().contains(¶m1)); QCOMPARE(params_spy.count(), 3); QCOMPARE(removed_spy.count(), 1); } libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_app-stack.h0000644000015700001700000000147712172126001022612 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include class TestAppStack : public QObject { Q_OBJECT private slots: void setAppId(); void setViewId(); }; libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_slider-parameter.cpp0000644000015700001700000000651212172126001024515 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "tst_slider-parameter.h" #include "../../src/slider-parameter.h" #include void TestSliderParameter::setMinimumValue() { Ubuntu::HUD::SliderParameter param; QSignalSpy spy(¶m, SIGNAL(minimumValueChanged(float))); QVERIFY(qFuzzyCompare(param.minimumValue(), 0.0f)); param.setMinimumValue(-100.0f); QVERIFY(qFuzzyCompare(param.minimumValue(), -100.0f)); QCOMPARE(spy.count(), 1); QVERIFY(qFuzzyCompare(spy.at(0).at(0).toFloat(), -100.0f)); param.setMinimumValue(-100.0f); QCOMPARE(spy.count(), 1); } void TestSliderParameter::setMaximumValue() { Ubuntu::HUD::SliderParameter param; QSignalSpy spy(¶m, SIGNAL(maximumValueChanged(float))); QVERIFY(qFuzzyCompare(param.maximumValue(), 100.0f)); param.setMaximumValue(200.0f); QVERIFY(qFuzzyCompare(param.maximumValue(), 200.0f)); QCOMPARE(spy.count(), 1); QVERIFY(qFuzzyCompare(spy.at(0).at(0).toFloat(), 200.0f)); param.setMaximumValue(200.0f); QCOMPARE(spy.count(), 1); } void TestSliderParameter::setStepSize() { Ubuntu::HUD::SliderParameter param; QSignalSpy spy(¶m, SIGNAL(stepSizeChanged(float))); QVERIFY(qFuzzyCompare(param.stepSize(), 1.0f)); param.setStepSize(10.0f); QVERIFY(qFuzzyCompare(param.stepSize(), 10.0f)); QCOMPARE(spy.count(), 1); QVERIFY(qFuzzyCompare(spy.at(0).at(0).toFloat(), 10.0f)); param.setStepSize(10.0f); QCOMPARE(spy.count(), 1); } void TestSliderParameter::setValue() { Ubuntu::HUD::SliderParameter param; QSignalSpy spy(¶m, SIGNAL(valueChanged(float))); QVERIFY(qFuzzyCompare(param.value(), 0.0f)); param.setValue(50.0f); QVERIFY(qFuzzyCompare(param.value(), 50.0f)); QCOMPARE(spy.count(), 1); QVERIFY(qFuzzyCompare(spy.at(0).at(0).toFloat(), 50.0f)); param.setValue(50.0f); QCOMPARE(spy.count(), 1); } void TestSliderParameter::setLive() { Ubuntu::HUD::SliderParameter param; QSignalSpy spy(¶m, SIGNAL(liveChanged(bool))); QVERIFY(param.live() == false); param.setLive(true); QVERIFY(param.live() == true); QCOMPARE(spy.count(), 1); QVERIFY(spy.at(0).at(0).toBool() == true); param.setLive(true); QCOMPARE(spy.count(), 1); } void TestSliderParameter::setLabel() { Ubuntu::HUD::SliderParameter param; QSignalSpy spy(¶m, SIGNAL(labelChanged(QString))); QVERIFY(param.label().isEmpty()); param.setLabel("Foo"); QVERIFY(param.label() == "Foo"); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toString() == "Foo"); spy.clear(); param.setLabel("Foo"); QCOMPARE(spy.count(), 0); } libhud-qt-0.1.0+13.10.20130719/tests/cpp/main.cpp0000644000015700001700000000272712172126001021313 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include #include "tst_action.h" #include "tst_context.h" #include "tst_hud.h" #include "tst_parameter.h" #include "tst_slider-parameter.h" int main(int argc, char *argv[]) { bool fail = false; TestAction tst_action; TestContext tst_context; TestHUD tst_hud; TestParameter tst_parameter; TestSliderParameter tst_sliderparameter; if (QTest::qExec(&tst_action, argc, argv) != 0) fail = true; if (QTest::qExec(&tst_context, argc, argv) != 0) fail = true; if (QTest::qExec(&tst_hud, argc, argv) != 0) fail = true; if (QTest::qExec(&tst_parameter, argc, argv) != 0) fail = true; if (QTest::qExec(&tst_sliderparameter, argc, argv) != 0) fail = true; if (fail) return 1; return 0; } libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_hud.h0000644000015700001700000000150312172126001021475 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include class TestHUD : public QObject { Q_OBJECT private slots: void contextOperations(); void _register(); }; libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_parameter.cpp0000644000015700001700000000214212172126001023230 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "tst_parameter.h" #include "../../src/parameter.h" #include void TestParameter::setType() { QSKIP("not implemented."); } void TestParameter::defaultValue() { QSKIP("not implemented."); } void TestParameter::currentValue() { QSKIP("not implemented."); } void TestParameter::name() { QSKIP("not implemented."); } void TestParameter::updated() { QSKIP("not implemented."); } libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_context.h0000644000015700001700000000151012172126001022377 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include class TestContext : public QObject { Q_OBJECT private slots: void setIdentifier(); void actionOperations(); }; libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_action.h0000644000015700001700000000213012172126001022167 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include class TestAction : public QObject { Q_OBJECT private slots: void setIdentifier(); void setLabel(); void setDescription(); void setKeywords(); void setIsBackgroundAction(); void setEnabled(); void trigger(); void setCommitLabel(); void setHasLivePreview(); void setHasNoPreview(); void setRequiresPreview(); void parameterOperations(); }; libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_hud.cpp0000644000015700001700000000352512172126001022036 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "tst_hud.h" #include "../../src/hud.h" #include void TestHUD::contextOperations() { Ubuntu::HUD::HUD hud; Ubuntu::HUD::Context *ctx1; Ubuntu::HUD::Context *ctx2; QListcontexts; contexts = hud.contexts(); QVERIFY(contexts.isEmpty()); QSignalSpy changed_spy(&hud, SIGNAL(contextsChanged())); QSignalSpy added_spy(&hud, SIGNAL(contextAdded(Context*))); QSignalSpy removed_spy(&hud, SIGNAL(contextRemoved(Context*))); ctx1 = new Ubuntu::HUD::Context(&hud); ctx1->setIdentifier("Context1"); ctx2 = new Ubuntu::HUD::Context(&hud); ctx2->setIdentifier("Context2"); hud.addContext(ctx1); hud.addContext(ctx2); contexts = hud.contexts(); QCOMPARE(contexts.count(), 2); QCOMPARE(changed_spy.count(), 2); QCOMPARE(added_spy.count(), 2); QVERIFY(contexts.contains(ctx1)); QVERIFY(contexts.contains(ctx2)); hud.removeContext(ctx1); QCOMPARE(hud.contexts().count(), 1); QCOMPARE(changed_spy.count(), 3); QCOMPARE(removed_spy.count(), 1); hud.setActiveContext(ctx1); } void TestHUD::_register() { QSKIP("not implemented."); } libhud-qt-0.1.0+13.10.20130719/tests/cpp/tst_context.cpp0000644000015700001700000000507112172126001022740 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "tst_context.h" #include "../../src/context.h" #include void TestContext::setIdentifier() { Ubuntu::HUD::Context ctx; QSignalSpy spy(&ctx, SIGNAL(identifierChanged(QString))); QVERIFY(ctx.identifier() == ""); ctx.setIdentifier("MyContext"); QVERIFY(ctx.identifier() == "MyContext"); QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QVERIFY(arguments.at(0).toString() == "MyContext"); spy.clear(); ctx.setIdentifier("MyContext"); QCOMPARE(spy.count(), 0); } void TestContext::actionOperations() { Ubuntu::HUD::Context ctx; Ubuntu::HUD::Action *action1; Ubuntu::HUD::Action *action2; Ubuntu::HUD::Action *action3; action1 = new Ubuntu::HUD::Action(&ctx); action1->setIdentifier("Action1"); action2 = new Ubuntu::HUD::Action(&ctx); action2->setIdentifier("Action2"); action3 = new Ubuntu::HUD::Action(&ctx); action3->setIdentifier("Action3"); QSignalSpy actions_spy(&ctx, SIGNAL(actionsChanged())); QSignalSpy added_spy(&ctx, SIGNAL(actionAdded(Action*))); QSignalSpy removed_spy(&ctx, SIGNAL(actionRemoved(Action*))); QList actions; actions = ctx.actions(); QVERIFY(actions.isEmpty()); ctx.addAction(action1); QCOMPARE(actions_spy.count(), 1); QCOMPARE(added_spy.count(), 1); QVERIFY(ctx.actions().contains(action1)); ctx.addAction(action2); ctx.addAction(action3); QCOMPARE(ctx.actions().count(), 3); QCOMPARE(added_spy.count(), 3); QSignalSpy trigger_spy(action2, SIGNAL(triggered())); ctx.invokeAction(action2->identifier()); QCOMPARE(trigger_spy.count(), 1); ctx.removeAction(action2); ctx.invokeAction(action2->identifier()); QCOMPARE(trigger_spy.count(), 1); QCOMPARE(removed_spy.count(), 1); QCOMPARE(actions_spy.count(), 4); // injectRecentActions } libhud-qt-0.1.0+13.10.20130719/tests/tests.pro0000644000015700001700000000004612172126001020755 0ustar pbuserpbgroup00000000000000TEMPLATE = subdirs SUBDIRS = cpp qml libhud-qt-0.1.0+13.10.20130719/coverage.pri0000644000015700001700000000354212172126001020242 0ustar pbuserpbgroup00000000000000# Coverage CONFIG(coverage) { OBJECTS_DIR = MOC_DIR = TOP_SRC_DIR = $$PWD LIBS += -lgcov QMAKE_CXXFLAGS += --coverage QMAKE_LDFLAGS += --coverage QMAKE_EXTRA_TARGETS += coverage cov QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \ generate-coverage-html clean-coverage-html coverage-xml \ generate-xml generate-coverage-xml clean-coverage-xml clean-gcno.commands = \ "@echo Removing old coverage instrumentation"; \ "find -name '*.gcno' -print | xargs -r rm" clean-gcda.commands = \ "@echo Removing old coverage results"; \ "find -name '*.gcda' -print | xargs -r rm" coverage-html.depends = clean-gcda check generate-coverage-html generate-coverage-html.commands = \ "@echo Collecting coverage data"; \ "lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \ "lcov --extract coverage.info \"*/src/*.cpp\" -o coverage.info"; \ "lcov --remove coverage.info \"moc_*.cpp\" -o coverage.info"; \ "LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info" clean-coverage-html.depends = clean-gcda clean-coverage-html.commands = \ "lcov --directory $${TOP_SRC_DIR} -z"; \ "rm -rf coverage.info coverage-html" coverage-xml.depends = clean-gcda check generate-coverage-xml generate-coverage-xml.commands = \ "@echo Generating coverage GCOVR XML report"; \ "gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"unittests/.*\" -e \".*\\.h\"" clean-coverage-xml.depends = clean-gcda clean-coverage-xml.commands = \ "rm -rf $${TOP_SRC_DIR}/coverage.xml" QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml }libhud-qt-0.1.0+13.10.20130719/src/0000755000015700001700000000000012172126127016527 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/src/fullscreen-action.h0000644000015700001700000000223612172126001022307 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_FULLSCREEN_ACTION #define UBUNTU_HUD_FULLSCREEN_ACTION #include "predefined-action.h" namespace Ubuntu { namespace HUD { class FullscreenAction; } } class Ubuntu::HUD::FullscreenAction : public Ubuntu::HUD::PredefinedAction { Q_OBJECT Q_DISABLE_COPY(FullscreenAction) class Private; public: FullscreenAction(QObject *parent = 0); virtual void setEnabled(bool value); private: Private *d; }; #endif // UBUNTU_HUD_FULLSCREEN_ACTION libhud-qt-0.1.0+13.10.20130719/src/context.cpp0000644000015700001700000001233112172126001020706 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ /* Can we have dynamic (context aware) actions as they could go away when * context changes (switch of tab or page or activation of different item on * a canvas, etc) and this could confuse the recent actions list..? */ /* Functionality should probably be specific to a Form Factor. how and where to * provide the information? Number of maximum toolbar items might be different * and actions probably don't have shortcuts. Also Form Factor might affect the * parameteres (what widgets are available, how hinting works.. still TBD) */ #include "context.h" #include #include // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; class Ubuntu::HUD::Context::Private { public: QString identifier; QList actions; GSimpleActionGroup *group; HudActionPublisher *publisher; }; Context::Context(QObject *parent) : QObject(parent) { d = new Private; static QMutex mutex; QMutexLocker locker(&mutex); static int id = 0; QString export_path = QString("/context_%1").arg(id++); d->group = g_simple_action_group_new(); d->publisher = hud_action_publisher_new(HUD_ACTION_PUBLISHER_ALL_WINDOWS, qPrintable(export_path)); hud_action_publisher_add_action_group(d->publisher, "hud", qPrintable(export_path)); g_dbus_connection_export_action_group(g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL), qPrintable(export_path), G_ACTION_GROUP(d->group), NULL); } /*! * \class Context * \brief HUD search context for an application * \since 1.0 * * Applications wishing to integrate with HUD have to declare one or more * contexts to be registered to HUD. A HUD context defines a set of actions, * toolbar items, and application AppStack information. * * Usually applications only need one context. If application provides * multiple distict views (like browser tabs) which each have their own * set of actions relevant to each view it's possible to have each view * specify their own HUD contexts and make each view available on the HUD * with their actions at the same time. */ using namespace Ubuntu::HUD; Context::~Context() { g_clear_object (&d->publisher); g_clear_object (&d->group); delete d; } /*! * \brief registered actions * * \returns the list of registered actions */ QList Context::actions() { return d->actions; } /*! unique identifier for this context */ QString Context::identifier() const { return d->identifier; } void Context::setIdentifier(const QString &identifier) { if (d->identifier == identifier) return; d->identifier = identifier; emit identifierChanged(identifier); } void Context::injectRecentAction(const QString &id) { Q_UNUSED(id); } /*! * \brief add action to context * \param action * * Action will be published in HUD. * * action has to be valid througout the lifetime of the context or be * removed using removeAction(); * * \note ownership of the action remains on the caller. */ void Context::addAction(Action *action) { if (d->actions.contains(action)) { qWarning("Trying to add action to Context that already exists."); return; } d->actions.append(action); emit actionAdded(action); emit actionsChanged(); QList gactions; HudActionDescription *desc; // see the documentation in action.cpp. action->magic((void**)&desc, (void*)&gactions); hud_action_publisher_add_description(d->publisher, desc); foreach(GSimpleAction *gaction, gactions) { g_simple_action_group_insert(d->group, G_ACTION(gaction)); } } /*! * \brief remove action from context */ void Context::removeAction(Action *action) { if (!d->actions.contains(action)) { qWarning("Trying to remove action from Context that does not exist."); return; } d->actions.removeOne(action); emit actionRemoved(action); emit actionsChanged(); } /*! * if user invokes an action directly from the application UI * this function can be used to add the action to the list of * recent actions. * what about actions that don't have meaningful "redo" like Copy * or Delete or New Document? */ void Context::invokeAction(const QString &id) { foreach(Action *action, d->actions) { if (action->identifier() == id) action->trigger(); } } HudActionPublisher * Context::publisher() { return d->publisher; } libhud-qt-0.1.0+13.10.20130719/src/settings-action.cpp0000644000015700001700000000243512172126001022341 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "settings-action.h" // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; SettingsAction::SettingsAction(QObject *parent) : PredefinedAction(parent) { Action::setIdentifier("ActionSettings"); Action::setLabel("Settings"); Action::setDescription("Show application settings."); HudActionDescription *desc; _actionDescription((void**)&desc); hud_action_description_set_attribute_value(desc, "hud-toolbar-item", g_variant_new_string("settings")); } void SettingsAction::setEnabled(bool value) { Action::setEnabled(value); } libhud-qt-0.1.0+13.10.20130719/src/hud.cpp0000644000015700001700000000555512172126001020014 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "hud.h" // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; class Ubuntu::HUD::HUD::Private : public QObject { Q_OBJECT public: QList contexts; QString activeContext; HudManager *manager; }; HUD::HUD(QObject *parent) : QObject(parent) { d = new Private; g_type_init(); d->manager = 0; } HUD::~HUD() { g_clear_object (&d->manager); delete d; } QList HUD::contexts() { return d->contexts; } void HUD::setActiveContext(Context *context) { if (!d->contexts.contains(context)) { qWarning("Tried to activate context that has not been added to HUD."); return; } HudActionPublisher *publisher; publisher = context->publisher(); hud_manager_switch_window_context(d->manager, publisher); } void HUD::_register(const QString &application_idenfier) { if (d->manager != 0) { qDebug("Already registered to HUD."); return; } if (application_idenfier.isEmpty()) { qWarning("Refusing to register to HUD with empty application identifer."); return; } d->manager = hud_manager_new(qPrintable(application_idenfier)); foreach (Context *ctx, d->contexts) { HudActionPublisher *publisher; publisher = ctx->publisher(); hud_manager_add_actions(d->manager, publisher); } } void HUD::addContext(Context *context) { if (d->contexts.contains(context)) { qWarning("Trying to add Context that already exist in HUD"); return; } /*! @todo ownership */ d->contexts.append(context); emit contextAdded(context); emit contextsChanged(); if (d->manager != 0) { // we have manager, add the context there HudActionPublisher *publisher; publisher = context->publisher(); hud_manager_add_actions(d->manager, publisher); } } void HUD::removeContext(Context *context) { if (!d->contexts.contains(context)) { qWarning("Trying to remove Context that does not exist in HUD."); return; } d->contexts.removeOne(context); emit contextRemoved(context); emit contextsChanged(); } #include "hud.moc" libhud-qt-0.1.0+13.10.20130719/src/undo-action.h0000644000015700001700000000216412172126001021112 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_UNDO_ACTION #define UBUNTU_HUD_UNDO_ACTION #include "predefined-action.h" namespace Ubuntu { namespace HUD { class UndoAction; } } class Ubuntu::HUD::UndoAction : public Ubuntu::HUD::PredefinedAction { Q_OBJECT Q_DISABLE_COPY(UndoAction) class Private; public: UndoAction(QObject *parent = 0); virtual void setEnabled(bool value); private: Private *d; }; #endif // UBUNTU_HUD_UNDO_ACTION libhud-qt-0.1.0+13.10.20130719/src/settings-action.h0000644000015700001700000000222012172126001021776 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_SETTINGS_ACTION #define UBUNTU_HUD_SETTINGS_ACTION #include "predefined-action.h" namespace Ubuntu { namespace HUD { class SettingsAction; } } class Ubuntu::HUD::SettingsAction : public Ubuntu::HUD::PredefinedAction { Q_OBJECT Q_DISABLE_COPY(SettingsAction) class Private; public: SettingsAction(QObject *parent = 0); virtual void setEnabled(bool value); private: Private *d; }; #endif // UBUNTU_HUD_SETTINGS_ACTION libhud-qt-0.1.0+13.10.20130719/src/predefined-action.cpp0000644000015700001700000000541312172126001022605 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "predefined-action.h" using namespace Ubuntu::HUD; PredefinedAction::PredefinedAction(QObject *parent) : Action(parent) { d = 0; // not using private class for now } void PredefinedAction::setIdentifier(const QString &identifier) { qWarning("Trying to set identifier (%s) on predefined action.", qPrintable(identifier)); return; } void PredefinedAction::setLabel(const QString &label) { qWarning("Trying to set label (%s) on predefined action.", qPrintable(label)); return; } void PredefinedAction::setDescription(const QString &description) { qWarning("Trying to set description (%s) on predefined action.", qPrintable(description)); return; } void PredefinedAction::setKeywords(QString keywords) { qWarning("Trying to set keywords (%s) on predefined action.", qPrintable(keywords)); return; } void PredefinedAction::setIsBackgroundAction(bool value) { Q_UNUSED(value) qWarning("Trying to set isBackgroundAction on predefined action."); return; } void PredefinedAction::setEnabled(bool value) { Q_UNUSED(value) qWarning("Trying to set enabled on predefined action."); return; } void PredefinedAction::setCommitLabel(const QString &label) { qWarning("Trying to set commitLabel (%s) on predefined action.", qPrintable(label)); return; } void PredefinedAction::setHasLivePreview(bool value) { Q_UNUSED(value) qWarning("Trying to set hasLivePreview on predefined action."); return; } void PredefinedAction::setHasNoPreview(bool value) { Q_UNUSED(value) qWarning("Trying to set hasNoPreview on predefined action."); return; } void PredefinedAction::setRequiresPreview(bool value) { Q_UNUSED(value) qWarning("Trying to set requiresPreview on predefined action."); return; } void PredefinedAction::addParameter(Parameter *parameter) { Q_UNUSED(parameter) qWarning("Trying to add parameter on predefined action."); return; } void PredefinedAction::removeParameter(Parameter *parameter) { Q_UNUSED(parameter) qWarning("Trying to remove parameter on predefined action."); return; } libhud-qt-0.1.0+13.10.20130719/src/action.h0000644000015700001700000001423712172126001020153 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_ACTION_H #define UBUNTU_HUD_ACTION_H #include #include #include #include "parameter.h" namespace Ubuntu { namespace HUD { class Action; class Context; } } class Ubuntu::HUD::Action : public QObject { Q_OBJECT Q_DISABLE_COPY(Action) Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged) Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged) Q_PROPERTY(QString keywords READ keywords WRITE setKeywords NOTIFY keywordsChanged) Q_PROPERTY(bool isBackgroundAction READ isBackgroundAction WRITE setIsBackgroundAction NOTIFY isBackgroundActionChanged) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(QString commitLabel READ commitLabel WRITE setCommitLabel NOTIFY commitLabelChanged) Q_PROPERTY(bool hasLivePreview READ hasLivePreview WRITE setHasLivePreview NOTIFY hasLivePreviewChanged) Q_PROPERTY(bool hasNoPreview READ hasNoPreview WRITE setHasNoPreview NOTIFY hasNoPreviewChanged) Q_PROPERTY(bool requiresPreview READ requiresPreview WRITE setRequiresPreview NOTIFY requiresPreviewChanged) class Private; public: explicit Action(QObject *parent = 0); virtual ~Action(); /*! unique identifier for the action */ virtual QString identifier() const; virtual void setIdentifier(const QString &identifier); /*! user visible label of the action */ virtual QString label() const; virtual void setLabel(const QString &label); /*! * additional small snippet to describe the action * pref. max 8 words or something * * the snippet will have any punctuations removed */ virtual QString description() const; virtual void setDescription(const QString &description); /*! * List of strings of keywords for this action. The keywords will be visible * in the help page and are taken into consideration when searching the HUD. * * Do we need to link parameters to keywords also? As for example if the user * wants to colorify an image with sepia color then we would have keyword * "Sepia" for action "Colorify" with appropriate default parameters? * * Keywords can contain spaces. * * The format is "Keyword 1;Keyword 2;Keyword 3" * * \warning maybe they should? * * Do we need separate list of "other known names" which would not show up * in the Help page? */ virtual QString keywords() const; virtual void setKeywords(QString keywords); /*! * this action is marked to be a specific background action and should * receive a higher score than the normal actions when the application is * in the background */ virtual bool isBackgroundAction() const; virtual void setIsBackgroundAction(bool value); /*! * the action is either insensitive or invisible * * action list -> invisible * toolbar -> insensitive */ virtual bool enabled() const; virtual void setEnabled(bool value); /*! label to show in the commit button */ virtual QString commitLabel() const; virtual void setCommitLabel(const QString &label); /*! preview is done live */ virtual bool hasLivePreview() const; virtual void setHasLivePreview(bool value); /*! the action can't be previewed */ virtual bool hasNoPreview() const; virtual void setHasNoPreview(bool value); /*! * the action requires either live preview or if that is not available then * a additional preview step has to be shown in the HUD */ virtual bool requiresPreview() const; virtual void setRequiresPreview(bool value); /*! * if the action has multiple values to manipulate then each of them will * be defined here */ virtual QList parameters(); virtual void addParameter(Parameter *parameter); virtual void removeParameter(Parameter *parameter); public slots: void trigger() const; signals: /*! fired when user activates the action */ void triggered() const; void identifierChanged(const QString &identifier); void labelChanged(const QString &label); void descriptionChanged(const QString &description); void keywordsChanged(QString keywords); void isBackgroundActionChanged(bool value); void enabledChanged(bool value); void commitLabelChanged(const QString &label); void hasLivePreviewChanged(bool value); void hasNoPreviewChanged(bool value); void requiresPreviewChanged(bool value); void parameterAdded(Ubuntu::HUD::Parameter *parameter); void parameterRemoved(Ubuntu::HUD::Parameter *parameter); void parametersChanged(); void started(); void cancelled(); void resetted(); protected: void _actionDescription(void **desc); private: friend class Ubuntu::HUD::Context; void magic(void **desc, void *gactionlist); private: Private *d; }; #endif // UBUNTU_HUD_ACTION_H libhud-qt-0.1.0+13.10.20130719/src/help-action.h0000644000015700001700000000216412172126001021075 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_HELP_ACTION #define UBUNTU_HUD_HELP_ACTION #include "predefined-action.h" namespace Ubuntu { namespace HUD { class HelpAction; } } class Ubuntu::HUD::HelpAction : public Ubuntu::HUD::PredefinedAction { Q_OBJECT Q_DISABLE_COPY(HelpAction) class Private; public: HelpAction(QObject *parent = 0); virtual void setEnabled(bool value); private: Private *d; }; #endif // UBUNTU_HUD_HELP_ACTION libhud-qt-0.1.0+13.10.20130719/src/help-action.cpp0000644000015700001700000000237412172126001021433 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "help-action.h" // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; HelpAction::HelpAction(QObject *parent) : PredefinedAction(parent) { Action::setIdentifier("ActionHelp"); Action::setLabel("Help"); Action::setDescription("Show application help."); HudActionDescription *desc; _actionDescription((void**)&desc); hud_action_description_set_attribute_value(desc, "hud-toolbar-item", g_variant_new_string("help")); } void HelpAction::setEnabled(bool value) { Action::setEnabled(value); } libhud-qt-0.1.0+13.10.20130719/src/fullscreen-action.cpp0000644000015700001700000000246012172126001022641 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "fullscreen-action.h" // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; FullscreenAction::FullscreenAction(QObject *parent) : PredefinedAction(parent) { Action::setIdentifier("ActionFullscreen"); Action::setLabel("Fullscreen"); Action::setDescription("Show application in full screen."); HudActionDescription *desc; _actionDescription((void**)&desc); hud_action_description_set_attribute_value(desc, "hud-toolbar-item", g_variant_new_string("fullscreen")); } void FullscreenAction::setEnabled(bool value) { Action::setEnabled(value); } libhud-qt-0.1.0+13.10.20130719/src/src.pro0000644000015700001700000000130712172126001020030 0ustar pbuserpbgroup00000000000000include( ../common-vars.pri ) TEMPLATE = lib TARGET = hud-qt CONFIG += qt link_pkgconfig INSTALLS += target PKGCONFIG += hud-2 TARGET = $$qtLibraryTarget($$TARGET) target.path = $$[QT_INSTALL_LIBS] # Input SOURCES += \ action.cpp \ context.cpp \ hud.cpp \ parameter.cpp \ slider-parameter.cpp \ \ predefined-action.cpp \ quit-action.cpp \ undo-action.cpp \ help-action.cpp \ fullscreen-action.cpp \ settings-action.cpp HEADERS += \ action.h \ context.h \ hud.h \ parameter.h \ slider-parameter.h \ \ predefined-action.h \ quit-action.h \ undo-action.h \ help-action.h \ fullscreen-action.h \ settings-action.h libhud-qt-0.1.0+13.10.20130719/src/context.h0000644000015700001700000000356012172126001020357 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_CONTEXT_H #define UBUNTU_HUD_CONTEXT_H #include #include #include "action.h" typedef struct _HudActionPublisher HudActionPublisher; namespace Ubuntu { namespace HUD { class Context; class HUD; } } class Ubuntu::HUD::Context : public QObject { Q_OBJECT Q_DISABLE_COPY(Context) Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged) class Private; public: explicit Context(QObject *parent = 0); virtual ~Context(); QList actions(); QString identifier() const; void setIdentifier(const QString &identifier); Q_INVOKABLE void injectRecentAction(const QString &id); Q_INVOKABLE void addAction(Action *action); Q_INVOKABLE void removeAction(Action *action); Q_INVOKABLE void invokeAction(const QString &id); signals: void identifierChanged(const QString &identifier); void actionsChanged(); void actionAdded(Action *action); void actionRemoved(Action *action); private: Private *d; friend Ubuntu::HUD::HUD; HudActionPublisher *publisher(); }; #endif // UBUNTU_HUD_CONTEXT_H libhud-qt-0.1.0+13.10.20130719/src/quit-action.cpp0000644000015700001700000000266412172126001021467 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "quit-action.h" // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; QuitAction::QuitAction(QObject *parent) : PredefinedAction(parent) { Action::setIdentifier("ActionQuit"); Action::setLabel("Quit"); Action::setDescription("Quit the application."); HudActionDescription *desc; _actionDescription((void**)&desc); hud_action_description_set_attribute_value(desc, "hud-toolbar-item", g_variant_new_string("quit")); qWarning("%s:\n" "\tQuitAction is deprecated as Quit-button has been removed from the HUD UI.\n" "\tPlease, remove QuitAction from your code ASAP as it will be removed from the final 1.0 API.", __PRETTY_FUNCTION__); } libhud-qt-0.1.0+13.10.20130719/src/predefined-action.h0000644000015700001700000000332412172126001022251 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_PREDEFINED_ACTION #define UBUNTU_HUD_PREDEFINED_ACTION #include "action.h" namespace Ubuntu { namespace HUD { class PredefinedAction; } } class Ubuntu::HUD::PredefinedAction : public Ubuntu::HUD::Action { Q_OBJECT Q_DISABLE_COPY(PredefinedAction) class Private; protected: PredefinedAction(QObject *parent = 0); public: virtual void setIdentifier(const QString &identifier); virtual void setLabel(const QString &label); virtual void setDescription(const QString &description); virtual void setKeywords(QString keywords); virtual void setIsBackgroundAction(bool value); virtual void setEnabled(bool value); virtual void setCommitLabel(const QString &label); virtual void setHasLivePreview(bool value); virtual void setHasNoPreview(bool value); virtual void setRequiresPreview(bool value); virtual void addParameter(Parameter *parameter); virtual void removeParameter(Parameter *parameter); private: Private *d; }; #endif // UBUNTU_HUD_PREDEFINED_ACTION libhud-qt-0.1.0+13.10.20130719/src/parameter.h0000644000015700001700000000422512172126001020652 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_PARAMETER_H #define UBUNTU_HUD_PARAMETER_H #include #include namespace Ubuntu { namespace HUD { class Parameter; class Action; } } class Ubuntu::HUD::Parameter : public QObject { Q_OBJECT Q_DISABLE_COPY(Parameter) Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) Q_PROPERTY(QVariant defaultValue READ defaultValue) Q_PROPERTY(QVariant currentValue READ currentValue) Q_PROPERTY(QString name READ name) class Private; public: explicit Parameter(QObject *parent = 0); virtual ~Parameter(); /*! * type of the parameter, int, color whatever.. * should also hint about the type of widget to be used in HUD */ QString type() const; void setType(const QString &type); /*! default value for the parameter to do reset or to use as initial value */ QVariant defaultValue(); QVariant currentValue(); QString name() const; protected: friend class Ubuntu::HUD::Action; virtual void magic(void **menuitem, void **gaction) = 0; // search action.cpp for documentation signals: /*! do we need this? in theory we could just hook to the currentValueChanged * signals. But still.. Might not be feasible with actual C++... */ void updated(); void typeChanged(const QString &type); private: Private *d; }; #endif // UBUNTU_HUD_PARAMETER_H libhud-qt-0.1.0+13.10.20130719/src/quit-action.h0000644000015700001700000000211212172126001021120 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_QUIT_ACTION #define UBUNTU_HUD_QUIT_ACTION #include "predefined-action.h" namespace Ubuntu { namespace HUD { class QuitAction; } } class Ubuntu::HUD::QuitAction : public Ubuntu::HUD::PredefinedAction { Q_OBJECT Q_DISABLE_COPY(QuitAction) class Private; public: QuitAction(QObject *parent = 0); private: Private *d; }; #endif // UBUNTU_HUD_QUIT_ACTION libhud-qt-0.1.0+13.10.20130719/src/slider-parameter.cpp0000644000015700001700000001417512172126001022472 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "slider-parameter.h" // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; class Ubuntu::HUD::SliderParameter::Private { public: float min; float max; float step; float value; bool live; QString label; GSimpleAction *simpleAction; GMenuItem *menuitem; static int actionNumber; static int generateActionNumber(); static void action_activated(GSimpleAction *action, GVariant *parameter, gpointer user_data); }; int SliderParameter::Private::actionNumber = 0; int SliderParameter::Private::generateActionNumber() { // thread safety... return SliderParameter::Private::actionNumber++; } void SliderParameter::Private::action_activated(GSimpleAction *simpleaction, GVariant *parameter, gpointer user_data) { SliderParameter *that = qobject_cast((QObject *)user_data); if (that == 0) { qWarning("CAST FAILED."); return; } float value = g_variant_get_double(parameter); that->setValue(value); } SliderParameter::SliderParameter(QObject *parent) : Parameter(parent) { g_type_init(); d = new Private; d->min = 0.0; d->max = 100.0; d->step = 1.0; d->value = 0.0; d->live = false; QString actionid = QString("action-qt-slider-param-") + QString::number(SliderParameter::Private::generateActionNumber()); d->simpleAction = g_simple_action_new(qPrintable(actionid), G_VARIANT_TYPE_DOUBLE); g_signal_connect(G_OBJECT(d->simpleAction), "activate", G_CALLBACK(SliderParameter::Private::action_activated), this); d->menuitem = g_menu_item_new("", qPrintable(QString("hud.") + actionid)); g_menu_item_set_attribute_value(d->menuitem, "parameter-type", g_variant_new_string("slider")); g_menu_item_set_attribute_value(d->menuitem, "min", g_variant_new_double(d->min)); g_menu_item_set_attribute_value(d->menuitem, "max", g_variant_new_double(d->max)); g_menu_item_set_attribute_value(d->menuitem, "step", g_variant_new_double(d->step)); g_menu_item_set_attribute_value(d->menuitem, "value", g_variant_new_double(d->value)); g_menu_item_set_attribute_value(d->menuitem, "live", g_variant_new_boolean(d->live)); g_menu_item_set_attribute_value(d->menuitem, G_MENU_ATTRIBUTE_LABEL, g_variant_new_string(qPrintable(d->label))); } SliderParameter::~SliderParameter() { delete d; } float SliderParameter::minimumValue() const { return d->min; } void SliderParameter::setMinimumValue(float value) { if (qFuzzyCompare(d->min, value)) return; if (value > d->value) { d->value = value; emit valueChanged(value); g_menu_item_set_attribute_value(d->menuitem, "value", g_variant_new_double(value)); } d->min = value; emit minimumValueChanged(value); g_menu_item_set_attribute_value(d->menuitem, "min", g_variant_new_double(value)); } float SliderParameter::maximumValue() const { return d->max; } void SliderParameter::setMaximumValue(float value) { if (qFuzzyCompare(d->max, value)) return; if (value < d->value) { d->value = value; emit valueChanged(value); g_menu_item_set_attribute_value(d->menuitem, "value", g_variant_new_double(value)); } d->max = value; emit maximumValueChanged(value); g_menu_item_set_attribute_value(d->menuitem, "max", g_variant_new_double(value)); } float SliderParameter::stepSize() const { return d->step; } void SliderParameter::setStepSize(float value) { if (qFuzzyCompare(d->step, value)) return; d->step = value; emit stepSizeChanged(value); g_menu_item_set_attribute_value(d->menuitem, "step", g_variant_new_double(value)); } float SliderParameter::value() const { return d->value; } void SliderParameter::setValue(float value) { if (qFuzzyCompare(d->value, value)) return; d->value = value; emit valueChanged(value); g_menu_item_set_attribute_value(d->menuitem, "value", g_variant_new_double(value)); } bool SliderParameter::live() const { return d->live; } void SliderParameter::setLive(bool value) { if (d->live == value) return; d->live = value; emit liveChanged(value); g_menu_item_set_attribute_value(d->menuitem, "live", g_variant_new_boolean(value)); } QString SliderParameter::label() const { return d->label; } void SliderParameter::setLabel(const QString &label) { if (d->label == label) return; d->label = label; emit labelChanged(label); g_menu_item_set_attribute_value(d->menuitem, G_MENU_ATTRIBUTE_LABEL, g_variant_new_string(qPrintable(label))); } void SliderParameter::magic(void **menuitem, void **gaction) { *menuitem = d->menuitem; *gaction = d->simpleAction; } libhud-qt-0.1.0+13.10.20130719/src/hud.h0000644000015700001700000000267512172126001017461 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_HUD_H #define UBUNTU_HUD_HUD_H #include #include "context.h" namespace Ubuntu { namespace HUD { class HUD; } } class Ubuntu::HUD::HUD : public QObject { Q_OBJECT Q_DISABLE_COPY(HUD) class Private; public: HUD(QObject *parent = 0); virtual ~HUD(); QList contexts(); Q_INVOKABLE void setActiveContext(Context *context); void _register(const QString &application_idenfier); /*! adds a HUD Context */ Q_INVOKABLE void addContext(Context *context); Q_INVOKABLE void removeContext(Context *context); signals: void contextsChanged(); void contextAdded(Context *context); void contextRemoved(Context *context); private: Private *d; }; #endif // UBUNTU_HUD_HUD_H libhud-qt-0.1.0+13.10.20130719/src/parameter.cpp0000644000015700001700000000270012172126001021201 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ // todo, how to relay back the live changes in the paramters #include "parameter.h" using namespace Ubuntu::HUD; class Ubuntu::HUD::Parameter::Private { public: QString type; QString name; QVariant currentValue; QVariant defaultValue; }; Parameter::Parameter(QObject *parent) : QObject(parent) { d = new Private; } Parameter::~Parameter() { delete d; } QString Parameter::type() const { return d->type; } void Parameter::setType(const QString &type) { if (d->type == type) return; d->type = type; emit typeChanged(type); } QVariant Parameter::defaultValue() { return d->defaultValue; } QVariant Parameter::currentValue() { return d->currentValue; } QString Parameter::name() const { return d->name; } libhud-qt-0.1.0+13.10.20130719/src/slider-parameter.h0000644000015700001700000000514012172126001022127 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_SLIDER_PARAMETER_H #define UBUNTU_HUD_SLIDER_PARAMETER_H #include "parameter.h" namespace Ubuntu { namespace HUD { class SliderParameter; } } class Ubuntu::HUD::SliderParameter : public Ubuntu::HUD::Parameter { Q_OBJECT Q_PROPERTY(float minimumValue READ minimumValue WRITE setMinimumValue NOTIFY minimumValueChanged) Q_PROPERTY(float maximumValue READ maximumValue WRITE setMaximumValue NOTIFY maximumValueChanged) Q_PROPERTY(float stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged) Q_PROPERTY(float value READ value WRITE setValue NOTIFY valueChanged) Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged) Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) class Private; public: SliderParameter(QObject *parent = 0); ~SliderParameter(); float minimumValue() const; void setMinimumValue(float value); float maximumValue() const; void setMaximumValue(float value); float stepSize() const; void setStepSize(float value); float value() const; void setValue(float value); bool live() const; void setLive(bool value); /*! user visible label of the parameter */ QString label() const; void setLabel(const QString &label); signals: void minimumValueChanged(float value); void maximumValueChanged(float value); void stepSizeChanged(float value); void valueChanged(float value); void liveChanged(bool value); void labelChanged(const QString &label); private: virtual void magic(void **menuitem, void **gaction); private: Private *d; }; #endif // UBUNTU_HUD_SLIDER_PARAMETER_H libhud-qt-0.1.0+13.10.20130719/src/action.cpp0000644000015700001700000002266212172126001020507 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ // todo, how to provide preview if live preview is not available // todo, partial live preview which would show in HUD? #include "action.h" #include #include // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; class Ubuntu::HUD::Action::Private { public: QString identifier; QString label; QString description; QString keywords; bool isBackgroundAction; bool enabled; QString commitLabel; bool hasLivePreview; bool hasNoPreview; bool requiresPreview; QList parameters; GSimpleAction *simpleAction; HudActionDescription *desc; QString actionid; GMenu *paramMenu; static void action_activated(GSimpleAction *action, GVariant *parameter, gpointer user_data); static int actionNumber; static int generateActionNumber(); static QMutex mutex; }; int Action::Private::actionNumber = 0; QMutex Action::Private::mutex; int Action::Private::generateActionNumber() { QMutexLocker locker(&Action::Private::mutex); return Action::Private::actionNumber++; } void Action::Private::action_activated(GSimpleAction *simpleaction, GVariant *parameter, gpointer user_data) { Action *action = qobject_cast((QObject *)user_data); if (action == 0) { qWarning("CAST FAILED."); return; } if (g_action_get_parameter_type(G_ACTION(simpleaction)) == NULL) { action->trigger(); return; } if (g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { QString state(g_variant_get_string(parameter, NULL)); if (state == "start") { emit action->started(); return; } else if (state == "end") { // just skip for now return; } else if (state == "commit") { emit action->triggered(); return; } else if (state == "reset") { emit action->resetted(); return; } else if (state == "cancel") { emit action->cancelled(); return; } else { qWarning("Unknown Action state: %s", qPrintable(state)); } } Q_ASSERT(0); // should not be reached } Action::Action(QObject *parent) : QObject(parent) { g_type_init(); d = new Private; d->isBackgroundAction = false; d->enabled = true; d->hasLivePreview = false; d->hasNoPreview = false; d->requiresPreview = false; d->actionid = QString("action-qt-") + QString::number(Action::Private::generateActionNumber()); d->simpleAction = 0; d->paramMenu = g_menu_new(); d->desc = hud_action_description_new(qPrintable(QString("hud.") + d->actionid), NULL); hud_action_description_set_attribute_value(d->desc, G_MENU_ATTRIBUTE_LABEL, g_variant_new_string(qPrintable(d->label))); hud_action_description_set_attribute_value(d->desc, "description", g_variant_new_string(qPrintable(d->description))); hud_action_description_set_attribute_value(d->desc, "keywords", g_variant_new_string(qPrintable(d->keywords))); hud_action_description_set_attribute_value(d->desc, "enabled", g_variant_new_boolean(d->enabled)); hud_action_description_set_attribute_value(d->desc, "commitLabel", g_variant_new_string(qPrintable(d->commitLabel))); hud_action_description_set_attribute_value(d->desc, "hasLivePreview", g_variant_new_boolean(d->hasLivePreview)); } Action::~Action() { g_clear_object(&d->paramMenu); g_clear_object(&d->simpleAction); g_clear_object(&d->desc); delete d; } QString Action::identifier() const { return d->identifier; } void Action::setIdentifier(const QString &identifier) { if (d->identifier == identifier) return; d->identifier = identifier; emit identifierChanged(identifier); } QString Action::label() const { return d->label; } void Action::setLabel(const QString &label) { if (d->label == label) return; d->label = label; hud_action_description_set_attribute_value(d->desc, G_MENU_ATTRIBUTE_LABEL, g_variant_new_string(qPrintable(label))); emit labelChanged(label); } QString Action::description() const { return d->description; } void Action::setDescription(const QString &description) { if (d->description == description) return; d->description = description; hud_action_description_set_attribute_value(d->desc, "description", g_variant_new_string(qPrintable(description))); emit descriptionChanged(description); } QString Action::keywords() const { return d->keywords; } void Action::setKeywords(QString keywords) { if (d->keywords == keywords) return; d->keywords = keywords; hud_action_description_set_attribute_value(d->desc, "keywords", g_variant_new_string(qPrintable(keywords))); emit keywordsChanged(keywords); } bool Action::isBackgroundAction() const { return d->isBackgroundAction; } void Action::setIsBackgroundAction(bool value) { if (d->isBackgroundAction == value) return; d->isBackgroundAction = value; emit isBackgroundActionChanged(value); } bool Action::enabled() const { return d->enabled; } void Action::setEnabled(bool value) { if (d->enabled == value) return; d->enabled = value; hud_action_description_set_attribute_value(d->desc, "enabled", g_variant_new_boolean(value)); emit enabledChanged(value); } void Action::trigger() const { emit triggered(); } QString Action::commitLabel() const { return d->commitLabel; } void Action::setCommitLabel(const QString &label) { if (d->commitLabel == label) return; d->commitLabel = label; hud_action_description_set_attribute_value(d->desc, "commitLabel", g_variant_new_string(qPrintable(label))); emit commitLabelChanged(label); } bool Action::hasLivePreview() const { return d->hasLivePreview; } void Action::setHasLivePreview(bool value) { if (d->hasLivePreview == value) return; d->hasLivePreview = value; hud_action_description_set_attribute_value(d->desc, "hasLivePreview", g_variant_new_boolean(value)); emit hasLivePreviewChanged(value); } bool Action::hasNoPreview() const { return d->hasNoPreview; } void Action::setHasNoPreview(bool value) { if (d->hasNoPreview == value) return; d->hasNoPreview = value; emit hasNoPreviewChanged(value); } bool Action::requiresPreview() const { return d->requiresPreview; } void Action::setRequiresPreview(bool value) { if (d->requiresPreview == value) return; d->requiresPreview = value; emit requiresPreviewChanged(value); } QList Action::parameters() { return d->parameters; } void Action::addParameter(Parameter *parameter) { if (d->parameters.contains(parameter)) { qWarning("Trying to add Parameter that already exist in Action"); return; } /*! @todo ownership */ d->parameters.append(parameter); emit parameterAdded(parameter); emit parametersChanged(); } void Action::removeParameter(Parameter *parameter) { if (!d->parameters.contains(parameter)) { qWarning("Trying to remove Parameter that does not exist in Action"); return; } /*! @todo ownership */ d->parameters.removeOne(parameter); emit parameterRemoved(parameter); emit parametersChanged(); } /*! @private * get access to the internal HudActionDesctiption * * the pointer is valid as long as the instanse of this class is valid */ void Action::_actionDescription(void **desc) { *desc = d->desc; } /*! * @private * * handles the registration of the action group. * * This function is only meant to be used by Ubuntu::HUD::HUD and * anyone making modifications to either of the classes must take extra * care. */ void Action::magic(void **desc, void *gactionlist) { QList *gactions = (QList *)gactionlist; if (d->parameters.count() == 0) { d->simpleAction = g_simple_action_new(qPrintable(d->actionid), NULL); } else { d->simpleAction = g_simple_action_new(qPrintable(d->actionid), G_VARIANT_TYPE_STRING); hud_action_description_set_parameterized(d->desc, G_MENU_MODEL(d->paramMenu)); } g_signal_connect(G_OBJECT(d->simpleAction), "activate", G_CALLBACK(Action::Private::action_activated), this); gactions->append(d->simpleAction); foreach(Parameter *param, d->parameters) { GMenuItem *menuitem; GSimpleAction *gaction; // magic should return the menuitem from parameter subclass. param->magic((void**)&menuitem, (void**)&gaction); g_menu_append_item(d->paramMenu, menuitem); gactions->append(gaction); } *desc = d->desc; } libhud-qt-0.1.0+13.10.20130719/src/undo-action.cpp0000644000015700001700000000237312172126001021447 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "undo-action.h" // needed for glib includes. #undef signals #include using namespace Ubuntu::HUD; UndoAction::UndoAction(QObject *parent) : PredefinedAction(parent) { Action::setIdentifier("ActionUndo"); Action::setLabel("Undo"); Action::setDescription("Undo the last action."); HudActionDescription *desc; _actionDescription((void**)&desc); hud_action_description_set_attribute_value(desc, "hud-toolbar-item", g_variant_new_string("undo")); } void UndoAction::setEnabled(bool value) { Action::setEnabled(value); } libhud-qt-0.1.0+13.10.20130719/examples/0000755000015700001700000000000012172126127017556 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/examples/testapp.cpp0000644000015700001700000000234512172126001021735 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "testapp.h" #include "hud.h" namespace HUD = Ubuntu::HUD; TestApp::TestApp(int &argc, char **argv) : QApplication(argc, argv) { QTextEdit *text = new QTextEdit(); text->show(); HUD::Action *action = new HUD::Action(this); action->setIdentifier("MyAction"); action->setLabel("Hello World"); action->setDescription("Jada Jada Jada"); action->setKeywords("Foo;Bar"); HUD::Context *ctx = new HUD::Context(this); ctx->addAction(action); HUD::HUD *hud = new HUD::HUD(this); hud->addContext(ctx); } libhud-qt-0.1.0+13.10.20130719/examples/example.cpp0000644000015700001700000000145012172126001021704 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "testapp.h" int main(int argc, char *argv[]) { TestApp app(argc, argv); return app.exec(); } libhud-qt-0.1.0+13.10.20130719/examples/testapp.h0000644000015700001700000000153612172126001021403 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef TESTAPP #define TESTAPP #include class TestApp : public QApplication { Q_OBJECT public: TestApp(int & argc, char ** argv); }; #endif libhud-qt-0.1.0+13.10.20130719/examples/examples.pro0000644000015700001700000000024412172126001022105 0ustar pbuserpbgroup00000000000000TEMPLATE = app TARGET = example QT += widgets SOURCES = example.cpp \ testapp.cpp HEADERS = testapp.h LIBS += -L../src -lhud-qt INCLUDEPATH = ../src libhud-qt-0.1.0+13.10.20130719/qml/0000755000015700001700000000000012172126127016531 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/qml/context.cpp0000644000015700001700000000505012172126001020710 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "context.h" using namespace Ubuntu::HUD; /*! * \qmltype Context * \instantiates Context * \since 1.0 */ /*! * \qmlproperty list Context::actions * * actions registered to HUD */ QML::Context::Context(QObject *parent) : Ubuntu::HUD::Context(parent) { } QML::Context::~Context() { } QQmlListProperty QML::Context::actions_list() { return QQmlListProperty(this, 0, &QML::Context::append, &QML::Context::count, &QML::Context::at, &QML::Context::clear); } void QML::Context::append(QQmlListProperty *list, Ubuntu::HUD::Action *action) { QML::Context *self = qobject_cast(list->object); if (self) self->addAction(action); } Ubuntu::HUD::Action * QML::Context::at(QQmlListProperty *list, int index) { QML::Context *self = qobject_cast(list->object); if (self) return self->actions().at(index); Q_ASSERT(0); // should never reach here return 0; } void QML::Context::clear(QQmlListProperty *list) { QML::Context *self = qobject_cast(list->object); if (self) { QList actions = self->actions(); foreach(Ubuntu::HUD::Action *action, actions) { self->removeAction(action); } } } int QML::Context::count(QQmlListProperty *list) { QML::Context *self = qobject_cast(list->object); if (self) return self->actions().count(); Q_ASSERT(0); // should never reach here return 0; } libhud-qt-0.1.0+13.10.20130719/qml/hud.cpp0000644000015700001700000000550112172126001020005 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "hud.h" #include using namespace Ubuntu::HUD; class QML::HUD::HUD::Private : public QObject { Q_OBJECT public: QString applicationIdentifier; }; QML::HUD::HUD(QObject *parent) : Ubuntu::HUD::HUD(parent) { d = new Private(); } QML::HUD::~HUD() { delete d; } QQmlListProperty QML::HUD::contexts_list() { return QQmlListProperty(this, 0, QML::HUD::append, QML::HUD::count, QML::HUD::at, QML::HUD::clear); } void QML::HUD::append(QQmlListProperty *list, QML::Context *context) { QML::HUD *hud = qobject_cast(list->object); if (hud) hud->addContext(context); } QML::Context * QML::HUD::at(QQmlListProperty *list, int index) { QML::HUD *hud = qobject_cast(list->object); if (hud) return qobject_cast(hud->contexts().at(index)); Q_ASSERT(0); // should not be reached return 0; } void QML::HUD::clear(QQmlListProperty *list) { QML::HUD *hud = qobject_cast(list->object); if (hud) { QList< ::Context *> contexts = hud->contexts(); foreach(::Context *context, contexts) hud->removeContext(context); } } int QML::HUD::count(QQmlListProperty *list) { QML::HUD *hud = qobject_cast(list->object); if (hud) return hud->contexts().count(); Q_ASSERT(0); // should not be reached return 0; } QString QML::HUD::applicationIdentifier() const { return d->applicationIdentifier; } void QML::HUD::setApplicationIdentifier(const QString &identifier) { if (d->applicationIdentifier == identifier) return; if (!d->applicationIdentifier.isEmpty()) { qWarning("Application Identifier can be set only once!"); return; } d->applicationIdentifier = identifier; emit applicationIdentifierChanged(identifier); _register(identifier); } #include "hud.moc" libhud-qt-0.1.0+13.10.20130719/qml/action.h0000644000015700001700000000315312172126001020150 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_QML_ACTION #define UBUNTU_HUD_QML_ACTION #include "../src/action.h" #include "../src/parameter.h" #include namespace Ubuntu { namespace HUD { namespace QML { class Action; } } } class Ubuntu::HUD::QML::Action : public Ubuntu::HUD::Action { Q_OBJECT Q_PROPERTY(QQmlListProperty parameters READ parameters_list) Q_CLASSINFO("DefaultProperty", "parameters"); public: Action(QObject *parent = 0); ~Action(); QQmlListProperty parameters_list(); private: static void append(QQmlListProperty *list, Ubuntu::HUD::Parameter *parameter); static Ubuntu::HUD::Parameter *at(QQmlListProperty *list, int index); static void clear(QQmlListProperty *list); static int count(QQmlListProperty *list); }; #endif libhud-qt-0.1.0+13.10.20130719/qml/plugin.cpp0000644000015700001700000000402712172126001020525 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "plugin.h" #include #include "../src/parameter.h" #include "../src/slider-parameter.h" #include "../src/quit-action.h" #include "../src/fullscreen-action.h" #include "../src/help-action.h" #include "../src/settings-action.h" #include "../src/undo-action.h" #include "action.h" #include "context.h" #include "hud.h" void HudQmlPlugin::registerTypes(const char *uri) { // @uri Ubuntu.HUD qmlRegisterType (uri, 1, 0, "Action"); qmlRegisterType (uri, 1, 0, "Context"); qmlRegisterType (uri, 1, 0, "HUD"); qmlRegisterType (); qmlRegisterType(uri, 1, 0, "SliderParameter"); qmlRegisterType (); qmlRegisterType (); qmlRegisterType (uri, 1, 0, "QuitAction"); qmlRegisterType (uri, 1, 0, "FullscreenAction"); qmlRegisterType (uri, 1, 0, "HelpAction"); qmlRegisterType (uri, 1, 0, "SettingsAction"); qmlRegisterType (uri, 1, 0, "UndoAction"); } void HudQmlPlugin::initializeEngine(QQmlEngine *engine, const char *uri) { Q_UNUSED(uri); Q_UNUSED(engine); } libhud-qt-0.1.0+13.10.20130719/qml/modules/0000755000015700001700000000000012172126127020201 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/qml/modules/Ubuntu/0000755000015700001700000000000012172126127021463 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/qml/modules/Ubuntu/HUD/0000755000015700001700000000000012172126127022103 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/qml/modules/Ubuntu/HUD/qmldir0000777000015700001700000000000012172126127025367 2../../../qmldirustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/qml/plugin.h0000644000015700001700000000212012172126001020162 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef HUD_QML_PLUGIN_H #define HUD_QML_PLUGIN_H #include class HudQmlPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") Q_INTERFACES(QQmlExtensionInterface) public: void registerTypes(const char *uri); void initializeEngine(QQmlEngine *engine, const char *uri); }; #endif // HUD_QML_PLUGIN_H libhud-qt-0.1.0+13.10.20130719/qml/context.h0000644000015700001700000000312312172126001020354 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_QML_CONTEXT #define UBUNTU_HUD_QML_CONTEXT #include "../src/context.h" #include "action.h" #include namespace Ubuntu { namespace HUD { namespace QML { class Context; } } } class Ubuntu::HUD::QML::Context : public Ubuntu::HUD::Context { Q_OBJECT Q_PROPERTY(QQmlListProperty actions READ actions_list) Q_CLASSINFO("DefaultProperty", "actions") public: Context(QObject *parent = 0); virtual ~Context(); QQmlListProperty actions_list(); private: static void append(QQmlListProperty *list, Ubuntu::HUD::Action *action); static Ubuntu::HUD::Action *at(QQmlListProperty *list, int index); static void clear(QQmlListProperty *list); static int count(QQmlListProperty *list); }; #endif // UBUNTU_HUD_QML_CONTEXT libhud-qt-0.1.0+13.10.20130719/qml/qml.pro0000644000015700001700000000162412172126001020036 0ustar pbuserpbgroup00000000000000include( ../common-vars.pri ) TEMPLATE = lib TARGET = hud-qml QT += quick CONFIG += qt plugin TARGET = $$qtLibraryTarget($$TARGET) uri = Ubuntu.HUD LIBS += -L../src -lhud-qt # Input SOURCES += \ plugin.cpp \ context.cpp \ hud.cpp \ action.cpp HEADERS += \ plugin.h \ context.h \ hud.h \ action.h OTHER_FILES = qmldir !equals(_PRO_FILE_PWD_, $$OUT_PWD) { copy_qmldir.target = $$OUT_PWD/qmldir copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\" QMAKE_EXTRA_TARGETS += copy_qmldir PRE_TARGETDEPS += $$copy_qmldir.target } qmldir.files = qmldir unix { installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /).$$API_VER qmldir.path = $$installPath target.path = $$installPath INSTALLS += target qmldir } libhud-qt-0.1.0+13.10.20130719/qml/hud.h0000644000015700001700000000377212172126001017462 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UBUNTU_HUD_QML_HUD #define UBUNTU_HUD_QML_HUD #include "../src/hud.h" #include "context.h" #include namespace Ubuntu { namespace HUD { namespace QML { class HUD; } } } class Ubuntu::HUD::QML::HUD : public Ubuntu::HUD::HUD { Q_OBJECT Q_PROPERTY(QQmlListProperty contexts READ contexts_list); /** can be set only once. * must not be "" * when set, application registeres to HUD */ Q_PROPERTY(QString applicationIdentifier READ applicationIdentifier WRITE setApplicationIdentifier NOTIFY applicationIdentifierChanged) Q_CLASSINFO("DefaultProperty", "contexts"); class Private; public: HUD(QObject *parent = 0); virtual ~HUD(); QQmlListProperty contexts_list(); signals: void applicationIdentifierChanged(const QString &identifier); private: static void append(QQmlListProperty *list, Context *context); static Context *at(QQmlListProperty *list, int index); static void clear(QQmlListProperty *list); static int count(QQmlListProperty *list); QString applicationIdentifier() const; void setApplicationIdentifier(const QString &identifier); Private *d; }; #endif // UBUNTU_HUD_QML_HUD libhud-qt-0.1.0+13.10.20130719/qml/action.cpp0000644000015700001700000000463512172126001020511 0ustar pbuserpbgroup00000000000000/* This file is part of libhud-qt * Copyright 2013 Canonical Ltd. * * libhud-qt is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * libhud-qt is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "action.h" using namespace Ubuntu::HUD; QML::Action::Action(QObject *parent) : Ubuntu::HUD::Action(parent) { } QML::Action::~Action() { } QQmlListProperty QML::Action::parameters_list() { return QQmlListProperty(this, 0, QML::Action::append, QML::Action::count, QML::Action::at, QML::Action::clear); } void QML::Action::append(QQmlListProperty *list, Parameter *parameter) { QML::Action *action = qobject_cast(list->object); if (action) { action->addParameter(parameter); return; } Q_ASSERT(0); // should not be reached } Parameter * QML::Action::at(QQmlListProperty *list, int index) { QML::Action *action = qobject_cast(list->object); if (action) return action->parameters().at(index); Q_ASSERT(0); // should not be reached return 0; } void QML::Action::clear(QQmlListProperty *list) { QML::Action *action = qobject_cast(list->object); if (action) { QList< ::Parameter *> parameters = action->parameters(); foreach(::Parameter *param, parameters) { action->removeParameter(param); } return; } Q_ASSERT(0); // should not be reached } int QML::Action::count(QQmlListProperty *list) { QML::Action *action = qobject_cast(list->object); if (action) { action->parameters().count(); return 0; } Q_ASSERT(0); // should not be reached return 0; } libhud-qt-0.1.0+13.10.20130719/qml/qmldir0000644000015700001700000000004112172126001017726 0ustar pbuserpbgroup00000000000000module Ubuntu.HUD plugin hud-qml libhud-qt-0.1.0+13.10.20130719/doc/0000755000015700001700000000000012172126127016505 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/doc/images/0000755000015700001700000000000012172126127017752 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/doc/doc.pro0000644000015700001700000000027212172126001017764 0ustar pbuserpbgroup00000000000000doc.commands = `qmake -query QT_INSTALL_BINS`/qdoc $$PWD/libhud-qt.qdocconf doc.files = $$PWD/html doc.path = /usr/share/libhud-qt/doc QMAKE_EXTRA_TARGETS += doc INSTALLS += doc libhud-qt-0.1.0+13.10.20130719/doc/pages/0000755000015700001700000000000012172126127017604 5ustar pbuserpbgroup00000000000000libhud-qt-0.1.0+13.10.20130719/doc/pages/overview.html0000644000015700001700000000003312172126001022323 0ustar pbuserpbgroup00000000000000

This is libHUD-qt

libhud-qt-0.1.0+13.10.20130719/doc/pages/overview.qdoc0000644000015700001700000000011012172126001022301 0ustar pbuserpbgroup00000000000000/*! \page overview.html overview \title overview of libHUD-qt */libhud-qt-0.1.0+13.10.20130719/doc/libhud-qt.qdocconf0000644000015700001700000000066512172126001022112 0ustar pbuserpbgroup00000000000000project = Ubuntu HUD Qt API description = The API to interact with Ubuntu HUD through Qt and QML sourcedirs = pages ../src ../qml exampledirs = ../examples imagedirs = images sources.fileextensions = "*.cpp *.qdoc *.qml" headers.fileextensions = "*.h" examples.fileextensions = "*.cpp *.h *.js *.qml" examples.imageextensions = "*.png *.jpeg *.jpg" outputdir = html outputformat = HTML outputprefixes = QML outputprefixes.QML = qml- libhud-qt-0.1.0+13.10.20130719/common-vars.pri0000644000015700001700000000172512172126001020711 0ustar pbuserpbgroup00000000000000#----------------------------------------------------------------------------- # Common variables for all projects. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Project name (used e.g. in include file and doc install path). # remember to update debian/* files if you changes this #----------------------------------------------------------------------------- PROJECT_NAME = libhud-qt #----------------------------------------------------------------------------- # Project version # remember to update debian/* files if you changes this #----------------------------------------------------------------------------- PROJECT_VERSION = 0.1.0 #----------------------------------------------------------------------------- # Library version #----------------------------------------------------------------------------- VERSION = 1.0.0 API_VER = 1.0 # End of File libhud-qt-0.1.0+13.10.20130719/COPYING0000644000015700001700000001674312172126001016775 0ustar pbuserpbgroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. libhud-qt-0.1.0+13.10.20130719/NEWS0000644000015700001700000000000012172126001016414 0ustar pbuserpbgroup00000000000000