Changeset View
Changeset View
Standalone View
Standalone View
tests/kcheckpass_test.cpp
Show All 13 Lines | |||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "../greeter/authenticator.h" | 20 | #include "../greeter/authenticator.h" | ||
21 | #include <QGuiApplication> | 21 | #include <QGuiApplication> | ||
22 | #include <QCommandLineParser> | ||||
22 | #include <QQuickView> | 23 | #include <QQuickView> | ||
23 | #include <QQmlContext> | 24 | #include <QQmlContext> | ||
24 | 25 | | |||
25 | int main(int argc, char *argv[]) | 26 | int main(int argc, char *argv[]) | ||
26 | { | 27 | { | ||
27 | QGuiApplication app(argc, argv); | 28 | QGuiApplication app(argc, argv); | ||
28 | Authenticator authenticator; | 29 | QCommandLineParser parser; | ||
30 | QCommandLineOption delayedOption(QStringLiteral("delayed"), | ||||
31 | QStringLiteral("KCheckpass is created at startup, the authentication is delayed")); | ||||
32 | QCommandLineOption directOption(QStringLiteral("direct"), | ||||
33 | QStringLiteral("A new KCheckpass gets created when trying to authenticate")); | ||||
34 | parser.addOption(directOption); | ||||
35 | parser.addOption(delayedOption); | ||||
36 | parser.addHelpOption(); | ||||
37 | parser.process(app); | ||||
38 | AuthenticationMode mode = AuthenticationMode::Delayed; | ||||
39 | if (parser.isSet(directOption)) { | ||||
40 | mode = AuthenticationMode::Direct; | ||||
41 | } | ||||
42 | if (parser.isSet(directOption) && parser.isSet(delayedOption)) { | ||||
43 | parser.showHelp(0); | ||||
44 | } | ||||
45 | Authenticator authenticator(mode); | ||||
29 | 46 | | |||
30 | QQuickView view; | 47 | QQuickView view; | ||
31 | view.rootContext()->setContextProperty("authenticator", &authenticator); | 48 | view.rootContext()->setContextProperty("authenticator", &authenticator); | ||
32 | view.setResizeMode(QQuickView::SizeRootObjectToView); | 49 | view.setResizeMode(QQuickView::SizeRootObjectToView); | ||
33 | view.setSource(QUrl::fromLocalFile(QStringLiteral(QML_FILE))); | 50 | view.setSource(QUrl::fromLocalFile(QStringLiteral(QML_FILE))); | ||
34 | view.show(); | 51 | view.show(); | ||
35 | return app.exec(); | 52 | return app.exec(); | ||
36 | } | 53 | } |