Well, moving from android to blackberry cascade qml coding.
I want to add splash screen manually in qml with a time limit of 2-3 seconds.
How can I achieve this as there re no options related to time in qml.
On searching over web and developers forum nothing is revealed for this case.
Help! Help! Help!
This is my main.qml
import bb.cascades 1.0
import bb.myTimer 1.0 //error unknown library bb.myTimer
Page
{
Container {
layout: DockLayout {
}
onCreationCompleted: {
myTimer.start();
}
ImageView {
id: mImageViewIcon
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///splash1.png"
}
attachedObjects: [
QTimer { //error : The QTimer component might be an unknown or custom component. Its properties are not validated.
id: myTimer
interval: 3000
onTimeout: {
//Push New Page here
mysheet1.open();
}
},
Sheet
{
id: mysheet1
peekEnabled: false
Page
{
Container
{
background: Color.Transparent
ImageView
{
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///splash2.png"
}
}
}
}
]
}
}
My main.cpp
#include <bb/cascades/Application>
#include <QLocale>
#include <QTranslator>
**#include <Qtimer>**
#include "applicationui.hpp"
#include <Qt/qdeclarativedebug.h>
using namespace bb::cascades;
Q_DECL_EXPORT int main(int argc, char **argv)
{
Application app(argc, argv);
**qmlRegisterType<QTimer>("my.timer", 1, 0, "QTimer");**
// Create the Application UI object, this is where the main.qml file
// is loaded and the application scene is set.
new ApplicationUI(&app);
// Enter the application main event loop.
return Application::exec();
}
Thanks in advance.
There is option for splash in bar-descriptor.xml
Open bar-descriptor.xml >> Select Tab "Application"
You can see Splash Screens: box at right side. Select your splash screen.
If you want to manually then follow below code.
Applied splash screen as imageview in page & use Timer.
Push new page when Timer's time out.
Here is sample code of Timer.
import bb.cascades 1.0
import my.timer 1.0
Page {
Container {
layout: DockLayout {
}
onCreationCompleted: {
mTimer.start();
}
ImageView {
id: mImageViewIcon
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/splash.png"
}
attachedObjects: [
QTimer {
id: mTimer
interval: 2000
onTimeout: {
//Push New Page here
}
}
]
}
}
Don't forgot to add below line in main.cpp
qmlRegisterType<QTimer>("my.timer", 1, 0, "QTimer");
As at the time of my answer, Momentics is at version 2.0. In this version of Momentics, there is no need for a QML for the splash screen.
To add a splash screen to your app, open the bar-descriptor.xml file. On the right hand side, below the icon specification, choose an image to be used as your splashscreen image.
That is all.
Rebuild and run and enjoy
Try to use an animation as TranslateTransition and set duration to wait second.
Code:
attachedObjects: [
TranslateTransition {
id: splashScreen
duration: 2000 //wait in milliseconds
onEnded: {
//here the code to close splash screen
}
}]
and use splashScreen.play(); //add this in onCreationComplete() on an object as container or imageview, not Page or NavigationPane to start timer of splashscreen.
Related
For a specific page, I'm trying to hide the statusbar and make the content fullscreen but it doesn't seem to work.
general setting in appcomponent.ts .
//for most pages
if (core.isPlatform(OsType.CORDOVA)) {
this.statusBar.styleLightContent();
this.statusBar.overlaysWebView(false);
this.statusBar.backgroundColorByHexString('#0076b2');
}
code in specific page:
some-page.ts
//for specific page
ionViewDidLoad() {
if (this.core.isPlatform(OsType.CORDOVA)) {
this.statusBar.hide();
this.statusBar.overlaysWebView(true);
}
}
ionViewWillLeave() {
if (this.core.isPlatform(OsType.CORDOVA)) {
this.statusBar.show();
this.statusBar.overlaysWebView(false);
}
}
my result is always with the blue Statusbar visible:
i want to add a new explorer panel into vscode. I want it to display either a treeView or a webView depending on if the user has connected to my backend application. I can see something similar in the base of vscode in the folder view. When no folder is open this view is shown
and when you have a folder open it looks like
For anyone else who finds this question, the behaviour seen in the file explorer is achievable through a Welcome Message.
A view's welcome message will show when the tree for that view is empty.
Preview
Welcome Message
Normal tree view
Example
In your package.json, declare:
The view
The view welcome message
The command which the welcome message button should execute
"contributes": {
"commands": [
{
"command": "myExtension.myCommand",
"title": "My Custom Command"
}
],
"views": {
"explorer": [
{
"id": "myCustomView",
"name": "My Custom View",
"contextualTitle": "My Custom View"
}
]
},
"viewsWelcome": [
{
"view": "myCustomView",
"contents": "Welcome to my custom view! [learn more](https://google.com/).\n[Get Started](command:myExtension.myCommand)"
}
]
}
In your extension.ts
Define the button command
Hook up the view to the view provider
import * as vscode from 'vscode';
import { CustomViewProvider } from './CustomViewProvider';
export function activate(context: vscode.ExtensionContext) {
// Add the custom view
const customViewProvider = new CustomViewProvider();
vscode.window.registerTreeDataProvider('myCustomView', customViewProvider);
// Add the command
let myCustomCommand = vscode.commands.registerCommand('myExtension.myCommand', () => {
vscode.window.showInformationMessage('This is my custom command!');
});
context.subscriptions.push(myCustomCommand);
}
export function deactivate() { }
In CustomViewProvider.ts, define when your view is empty or not.
import * as vscode from 'vscode';
export class CustomViewProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
getTreeItem(element: vscode.TreeItem): vscode.TreeItem {
return element;
}
getChildren(element?: vscode.TreeItem): Thenable<vscode.TreeItem[]> {
// NOTE:
// When TRUE, the welcome message will show
// When FALSE, the welcome message will NOT show
var showEmptyView = true;
if (showEmptyView) {
return Promise.resolve([]);
}
return Promise.resolve([
new vscode.TreeItem('This view is not empty!')
]);
}
}
As of VS Code 1.25, views may only contain tree views. Support for showing a webview in the side bar is tracked by https://github.com/Microsoft/vscode/issues/46585
If all you need is a button or simple prompt, you can use a tree view with a single node in the first case
Can the navigation between tabs be customized to as in the navcontainer i.e. while selecting tabs the view should scroll and change from left to right like swipe navigation with new page as in navcontainer.
You could achieve the slide in effect rather easily by adding the following CSS to your application
#keyframes slidein {
from {
right: -100%;
}
to {
right: -6px;
}
}
.sapUiTabPanel {
overflow:hidden;
}
.sapUiTabPanel > * {
animation: slidein 500ms;
position: absolute;
}
Note that you may need to add CSS with vendor prefixes depending on which browsers you are supporting.
To achieve the slide out of the current displayed tab is a bit tricky, one possible way this could be achieved is with the following code added to somewhere like the onInit method of your controller
oTabStrip1.attachBrowserEvent("mousedown",function(oEvent){
var oTarget = oEvent.target;
if(oTarget.className==="sapUiTabClose"){
return;
}
var iIdx = oTabStrip1.getItemIndex(oTarget);
if (iIdx > -1) {
if ((iIdx !== oTabStrip1.getSelectedIndex()) && (oTabStrip1.getTabs()[iIdx].getEnabled())) {
oEvent.stopPropagation();
oEvent.preventDefault();
jQuery.each(
oTabStrip1.getTabs()[oTabStrip1.getSelectedIndex()].getContent(),function(i,o){
var sAnimateLeft = (o.$().innerWidth() * -1) + "px";
o.$().animate({left:sAnimateLeft},500);
});
setTimeout(function(){
oTabStrip1.selectTabByDomRef(oTarget);
},250);
}
}
});
The above is assuming oTabStrip1 is the instance of your tabstrip control. Although it's often not good practice to modify the DOM directly within UI5 applications, in this case it's probably safe as the content of the displayed tab is removed and replaced with the clicked tab content, so all we are doing is delaying this until the slide out animation is complete.
You can see a working example at http://jsbin.com/vukibi - the code has been taken directly from the tabstrip example with the above CSS and JS added
I have implemented my own back stack but I'm not sure what is wrong or what I could improve, my scenario: I have a project with 2 activities, the first one is the "SplashActivity" - where I load some network data - the second one, the MainActivity.
Inside of my MainActivity I have a fragment and inside of this fragment a webview.
The back button should behave like:
When the user doesn't navigate inside of my webview, close the app.
When the user navigates in webview, use the back history of the browswer.
Here is my code:
#Override
public void onBackPressed() {
Log.d("lastfragment", String.valueOf(fragmentStack.lastElement().getId()));
if (fragmentStack.size() >= 2) {
// implement normal behavior?
Fragment activeFragment=fragmentStack.lastElement();
FragmentTransaction ft = getFragmentManager().beginTransaction();
activeFragment.onPause();
ft.remove(fragmentStack.pop());
Fragment returnToFragment=fragmentStack.lastElement();
String name = returnToFragment.getClass().getName();
if(name=="SplashScreen" || name=="LoginFragment"){
// close?
}
else {
// implement normal behavior?
returnToFragment.onResume();
ft.show(returnToFragment);
ft.commit();
}
}
else {
//close ??
}
}
Try to this code i hope solved this your problem.
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(FragmentTransaction.TRANSIT_FRAGMENT_OPEN, YOUR_FRAGMENT_OBJECT);
fragmentTransaction.addToBackStack(null); // Your fragment add to back stack
fragmentTransaction.commit();
I implemented a native File Picker on BlackBerry 10, after a bit of messing around it finally recognised the class, it opens fine and returns the file Address on the console but it looks like two signals are not working properly, baring in mind this is pretty much a straight copy of code from BlackBerry 10 docs.
using namespace bb::cascades::pickers;
void Utils::getFile() const{
FilePicker* filePicker = new FilePicker();
filePicker->setType(FileType::Music);
filePicker->setTitle("Select Sound");
filePicker->setMode(FilePickerMode::Picker);
filePicker->open();
// Connect the fileSelected() signal with the slot.
QObject::connect(filePicker,
SIGNAL(fileSelected(const QStringList&)),
this,
SLOT(onFileSelected(const QStringList&)));
// Connect the canceled() signal with the slot.
QObject::connect(filePicker,
SIGNAL(canceled()),
this,
SLOT(onCanceled()));
}
I wanted it to return the file url to qml with this (works fine with QFileDialog but that wouldn't recognise on my SDK) var test=utils.getFile()
if(test=="") console.debug("empty")
else console.debug(test)
But I'm getting these messages from the console: Object::connect: No such slot Utils::onFileSelected(const QStringList&) in ../src/Utils.cpp:27
Object::connect: No such slot Utils::onCanceled() in ../src/Utils.cpp:33
It is returning undefined from the else in the qml function when it opens,
Does anyone know where I cocked up or how I could get QFileDialog class to be found by the SDK?
I just wanted to give you a bit of an explanation in case you're still having some troubles. The concept's in Qt were a little foreign to me when I started in on it as well.
There are a couple ways you can do this. The easiest would probably be the pure QML route:
import bb.cascades 1.2
import bb.cascades.pickers 1.0
Page {
attachedObjects: [
FilePicker {
id: filePicker
type: FileType.Other
onFileSelected: {
console.log("selected files: " + selectedFiles)
}
}
]
Container {
layout: DockLayout {
}
Button {
id: launchFilePicker
text: qsTr("Open FilePicker")
onClicked: {
filePicker.open();
}
}
}
}
When you click the launchFilePicker button, it will invoke a FilePicker. Once a file is selected, the fileSelected signal will be fired. The slot in this case is the onFileSelected function (predefined), which logs the filepaths of the files that were selected (a parameter from the signal) to the console.
The C++ route is a little more work, but still doable.
If your class file was called Util, then you'd have a Util.h that looks something like this:
#ifndef UTIL_H_
#define UTIL_H_
#include <QObject>
class QStringList;
class Util : public QObject
{
Q_OBJECT
public:
Util(QObject *parent = 0);
Q_INVOKABLE
void getFile() const;
private Q_SLOTS:
void onFileSelected(const QStringList&);
void onCanceled();
};
#endif /* UTIL_H_ */
Note the Q_INVOKABLE getFile() method. Q_INVOKABLE will eventually allow us to call this method directly from QML.
The corresponding Util.cpp would look like:
#include "Util.h"
#include <QDebug>
#include <QStringList>
#include <bb/cascades/pickers/FilePicker>
using namespace bb::cascades;
using namespace bb::cascades::pickers;
Util::Util(QObject *parent) : QObject(parent)
{
}
void Util::getFile() const
{
FilePicker* filePicker = new FilePicker();
filePicker->setType(FileType::Other);
filePicker->setTitle("Select a file");
filePicker->setMode(FilePickerMode::Picker);
filePicker->open();
QObject::connect(
filePicker,
SIGNAL(fileSelected(const QStringList&)),
this,
SLOT(onFileSelected(const QStringList&)));
QObject::connect(
filePicker,
SIGNAL(canceled()),
this,
SLOT(onCanceled()));
}
void Util::onFileSelected(const QStringList &stringList)
{
qDebug() << "selected files: " << stringList;
}
void Util::onCanceled()
{
qDebug() << "onCanceled";
}
To make your Q_INVOKABLE getFile() method available to QML, you'd need to create an instance and set it as a ContextProperty. I do so in my applicationui.cpp like so:
Util *util = new Util(app);
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("_util", util);
Then, you can call this Q_INVOKABLE getFile() method from QML:
Page {
Container {
layout: DockLayout {}
Button {
id: launchFilePicker
text: qsTr("Open FilePicker")
onClicked: {
_util.getFile();
}
}
}
}
Like Richard says, most of the documentation covers how to create signals/slots, so you could review that, but also have a look at some Cascades-Samples on Git.
Hope that helps!!!