Vip Call Girls Noida ā”ļø Delhi ā”ļø 9999965857 No Advance 24HRS Live
Ā
Build Mobile Apps with RingQt and Ring2EXE
1. Ring Documentation, Release 1.10
77.9 Building the Cards Game for Mobile using RingQt
For a better example, consider building an Android package for the Cards game that comes with the
Ring language in this folder : ring/application/cards
The Cards game folder contains three ļ¬les
cards.ring : The Game source code
cards.jpg : The image ļ¬le used by the game
project.qrc : Resource ļ¬le to be used with the Qt project
The resource ļ¬le contains the next content
<RCC>
<qresource>
<file>cards.ringo</file>
<file>cards.jpg</file>
</qresource>
</RCC>
We have two ļ¬les in the resource ļ¬le
The ļ¬rst ļ¬le is cards.ringo (The Ring Object File) and the second ļ¬le is cards.jpg (The image ļ¬le)
As a start, Ring2EXE will generate this resource ļ¬le in target/mobile/qtproject/project.qrc
But this ļ¬le will contains only cards.ringo (That Ring2EXE will generate by calling Ring compiler)
We need to update this resource ļ¬le to add the image ļ¬le : cards.jpg
After this update, we copy the resource ļ¬le to the main application folder
So when we use Ring2EXE again, Our updated resource ļ¬le will be used!
Now to build the cards game for Mobile
1. Run the next command
ring2exe cards.ring -dist -mobileqt
2. Open target/mobile/qtproject/project.pro using Qt creator
3. Build and Run using Qt Creator
How the Cards game will ļ¬nd the image ļ¬le ?
RingQt comes with a simple function : AppFile() that we can use to determine the ļ¬les that we may
access on Desktop or Mobile platforms
The next code from cards.ring
mypic = new QPixmap(AppFile("cards.jpg"))
So all what you need is using AppFile() function around your image ļ¬les!
77.10 Building the Weight History Application for Mobile using
RingQt
Another example to distribute your application for Mobile Devices using Ring2EXE and Qt
77.9. Building the Cards Game for Mobile using RingQt 868
2. Ring Documentation, Release 1.10
consider building an Android package for the Weight History application that comes with the
Ring language in this folder : ring/application/weighthistory
The Weight History application folder contains four ļ¬les
weighthistory.ring : The application source code
weighthistory.db : The SQLite database
project.qrc : The resource ļ¬le for the Qt project
main.cpp : The main C++ source ļ¬le for the Qt project
To build the Weight History application for Mobile
1. Run the next command
ring2exe weighthistory.ring -dist -mobileqt
2. Open target/mobile/qtproject/project.pro using Qt creator
3. Build and Run using Qt Creator
The resource ļ¬le (project.qrc) contains two ļ¬les
<RCC>
<qresource>
<file>weighthistory.ringo</file>
<file>weighthistory.db</file>
</qresource>
</RCC>
The ļ¬rst ļ¬le is weighthistory.ringo (Ring Object File - Generated by Ring2EXE by calling Ring compiler)
The database ļ¬le : weighthistory.db
The main.cpp contains the next little update, To copy the database ļ¬le from resources to a writable location
on the mobile device
QString path3 ;
path3 = path+"/weighthistory.db";
QFile::copy(":/weighthistory.db",path3);
You will need to do this with database ļ¬les only!
When we use Ring2EXE, the tool will check for project.qrc and main.cpp, if they exist then your updated
ļ¬les will be used in target/mobile/qtproject instead of the default version generated by Ring2EXE
So Use Ring2EXE to generate these ļ¬les, Then copy them to your application folder when you update them.
77.11 Building the Form Designer for Mobile using RingQt
To build the Form Designer application (ring/applications/formdesigner) for Mobile
1. Run the next command
ring2exe formdesigner.ring -dist -mobileqt
2. Open target/mobile/qtproject/project.pro using Qt creator
3. Build and Run using Qt Creator
77.11. Building the Form Designer for Mobile using RingQt 869
3. Ring Documentation, Release 1.10
in the folder ring/application/formdesigner You will ļ¬nd the resource ļ¬le : project.qrc
It will be used automatically by Ring2EXE
<RCC>
<qresource>
<file>formdesigner.ringo</file>
<file>image/allevents.png</file>
<file>image/checkbox.png</file>
<file>image/close.png</file>
<file>image/combobox.bmp</file>
<file>image/datepicker.bmp</file>
<file>image/dial.png</file>
<file>image/formdesigner.png</file>
<file>image/frame.png</file>
<file>image/grid.bmp</file>
<file>image/hyperlink.png</file>
<file>image/image.png</file>
<file>image/label.png</file>
<file>image/layout.png</file>
<file>image/lcdnumber.png</file>
<file>image/listview.png</file>
<file>image/lock.png</file>
<file>image/new.png</file>
<file>image/open.png</file>
<file>image/progressbar.png</file>
<file>image/project.png</file>
<file>image/pushbutton.png</file>
<file>image/radiobutton.png</file>
<file>image/save.png</file>
<file>image/saveas.png</file>
<file>image/select.png</file>
<file>image/slider.png</file>
<file>image/spinner.bmp</file>
<file>image/statusbar.png</file>
<file>image/tab.png</file>
<file>image/textarea.png</file>
<file>image/textfield.png</file>
<file>image/timer.png</file>
<file>image/toolbar.png</file>
<file>image/tree.bmp</file>
<file>image/videowidget.png</file>
<file>image/webview.png</file>
</qresource>
</RCC>
As we did in the Cards game, The Form Designer will use the AppFile() function to determine the name of the Image
ļ¬les.
The next code from ring/applications/formdesigner/mainwindow/formdesignerview.ring
func CreateToolBar
aBtns = [
new qtoolbutton(win) {
setbtnimage(self,AppFile("image/new.png"))
setclickevent(Method(:NewAction))
settooltip("New File")
} ,
new qtoolbutton(win) {
setbtnimage(self,AppFile("image/open.png"))
77.11. Building the Form Designer for Mobile using RingQt 870
4. Ring Documentation, Release 1.10
setclickevent(Method(:OpenAction))
settooltip("Open File")
} ,
new qtoolbutton(win) {
setbtnimage(self,AppFile("image/save.png"))
setclickevent(Method(:SaveAction))
settooltip("Save")
} ,
new qtoolbutton(win) {
setbtnimage(self,AppFile("image/saveas.png"))
setclickevent(Method(:SaveAsAction))
settooltip("Save As")
} ,
new qtoolbutton(win) {
setbtnimage(self,AppFile("image/close.png"))
setclickevent(Method(:ExitAction))
settooltip("Exit")
}
]
tool1 = win.addtoolbar("files") {
for x in aBtns { addwidget(x) addseparator() }
}
From this example, We know that we can use sub folders for images.
77.12 Creating the Qt resource ļ¬le using Folder2qrc
When we have large RingQt project that contains a lot of images and ļ¬les, We need to add these ļ¬les to the resource
ļ¬le ( *.qrc ) when distributing applications for Mobile devices.
Instead of adding these ļ¬les one by one, Ring 1.6 comes with a simple tool that save our time, Itās called Folder2qrc.
Example:
folder2qrc formdesigner.ring
We determine the main source ļ¬le while we are in the application folder, and Folder2qrc will check all of the ļ¬les in
the current folder and sub folders, Then add them to the resource ļ¬le after the mainļ¬le.ringo (In our example this will
be formdesigner.ringo)
The output ļ¬le will be : project.qrc
You can open it and remove the ļ¬les that you donāt need in the resources!
77.13 Important Information about Ring2EXE
ā¢ Using Ring2EXE to prepare distribution will delete all of the ļ¬les in the old distribution
for example, if you have target/windows folder then used
ring2exe test3.ring -dist -allruntime
The ļ¬les in target/windows will be deleted before adding the ļ¬les again
This is important when you prepare a distribution for Mobile devices
77.12. Creating the Qt resource ļ¬le using Folder2qrc 871
5. Ring Documentation, Release 1.10
ring2exe test3.ring -dist -mobileqt
If you modiļ¬ed the resource ļ¬le : project.qrc or the main ļ¬le : main.cpp
Donāt forget to copy them to the application folder!
So Ring2EXE can use the updated version if you tried the previous command again!
ā¢ Ring2EXE is written in Ring, and you can read the source code from
https://github.com/ring-lang/ring/blob/master/ring2exe/ring2exe.ring
ā¢ The libraries information are stored in a separated ļ¬les, So these ļ¬les can be updated in the future
automatically to support new libraries
https://github.com/ring-lang/ring/blob/master/ring2exe/libs
77.13. Important Information about Ring2EXE 872
6. CHAPTER
SEVENTYEIGHT
THE RING PACKAGE MANAGER (RINGPM)
In this chapter we will learn about using the Ring Package Manager (RingPM)
RingPM is a tool for discovering, installing and updating Ring packages.
78.1 Features
The Package Manager uses Semantic Versioning to check compatibility between packages
The Package Manager comes with the next options
Usage : ringpm [command]
Command : search [keywords...]
Command : refresh : Update the Registry (Packages List)
Command : install [ <packagename> [from <UserName>] [branch <branchname>] ]
Command : list [-u : check updates]
Command : run [packagename]
Command : update <packagename>
Command : remove <packagename>
Command : format : Delete All Packages
Command : new <packagename>
Command : package : Create package in the current folder
78.2 Discovering Packages
We can discover new packages using the Search command
Using this command we can search in the RingPM Registry (Packages Index)
The RingPM Registry is a local copy of all registred packages.
ringpm search [keywords...]
Example:
ringpm search notepad
Output:
Package : ringnotepad (Ring Notepad)
Package : notepadppeditorextension (Notepad++ Editor Extension package)
873
7. Ring Documentation, Release 1.10
To print all packages in the RingPM Registry, use the search command without keywords.
Example:
ringpm search
78.3 Updating the RingPM Registry
The RingPM Registry is a local copy of all registred packages.
We can update the local copy using the Refresh command
Example:
ringpm refresh
Output:
No updates to the Registry, Nothing to do!
Or
The Registry is updated from revision 110 (2019/01/13) to revision 112 (2019/01/15)
78.4 Installing Packages
We can install new packages using the Install command
ringpm install [ <packagename> [from <UserName>] [branch <branchname>] ]
We can type only the package name to get the package information from the RingPM Registry or we can determine
the user name (GitHub) and the branch name of the github project (optional).
If the current folder is a package folder then we donāt need to write the package name.
Example (1) :
ringpm install ringnotepad
Example (2) :
ringpm install goldmagic800
Example (3) :
ringpm install gameoflife
If the package is not added to the RingPM Registry, We can install it directly from the GitHub user
Example (4) :
ringpm install firstpackage from mahmoudfayed
To run the package after installation
ringpm run firstpackage
78.3. Updating the RingPM Registry 874
8. Ring Documentation, Release 1.10
To install a package in the current folder
Example (5) :
ringpm install
78.5 Printing List of Installed Packages
We can know the installed packages using the List command
ringpm list [-u : check updates]
Example
ringpm list
Output
(analogclock) : The AnalogClock Package [master] -- (1.0.0)
(androidringlibsdl) : The AndroidRingLibSDL Package [master] -- (1.0.0)
(androidringqt) : The AndroidRingQt Package [master] -- (1.0.0)
(atomeditorextension) : The AtomEditorExtension Package [master] -- (1.0.0)
(bignumber) : The BigNumber Package [master] -- (1.0.0)
(calculator) : The Calculator Package [master] -- (1.0.0)
(cards) : The Cards Package [master] -- (1.0.0)
(checkers) : The Checkers Package [master] -- (1.0.0)
(chess) : The Chess Package [master] -- (1.0.0)
....
To check for new updates
ringpm list -u
78.6 Run Package
After installing a package, we can run it using the Run command.
ringpm run [packagename]
Example(1):
ringpm run ringnotepad
Example(2):
ringpm run goldmagic800
Example(3):
ringpm run gameoflife
To run a package in the current folder
Example(4):
ringpm run
78.5. Printing List of Installed Packages 875
9. Ring Documentation, Release 1.10
78.7 Update Package
We can update a package using the Update command
ringpm update <packagename>
Example:
ringpm update ringnotepad
78.8 Remove Package
We can remove a package using the Remove command
ringpm remove <packagename>
Example:
ringpm remove ringnotepad
78.9 Deleting All Packages
We can delete all packages using the Format command
Example:
ringpm format
78.10 Creating New Package
We can create new package using the New command
ringpm new <packagename>
Example:
ringpm new myapp
This will create new folder called my myapp
The new folder will contains the next ļ¬le
ā¢ package.ring : The package description and ļ¬les
ā¢ main.ring : main program (used by the Run command)
ā¢ lib.ring : library ļ¬le for the package
File : main.ring
# The Main File
load "lib.ring"
78.7. Update Package 876