cmake repository for laserdock games
After git clone you should initialize ldCore submodule
cd laserdock_games
git submodule update --init
As optional step you can setup auto git submodule update on git pull in future
git config submodule.recurse true
Windows (msvc2015)
macOS (clang)
- Download Qt Online installer from https://www.qt.io/download-qt-installer
- Run installer and install Qt for mac/windows (the latest version is recommended, library was tested on 5.11.1)
- copy dist.local.cmake and rename it to local.cmake
- Open local.cmake and set the path QT_BASE_DIR to your local Qt installation directory
- Open root CMakeLists.txt with IDE you like. Qt Creator is recommended.
- Compile and run example
Code style helps to read and edit the project easier to all of us. Please follow it.
Do not use exceptions.
Do not use tabs symbols in code. You can setup your IDE to save tabs as spaces (1 tab is 4 spaces).
Try to declare float variables with f suffix in a new code - 1.0f or 1.f instead of 1.0 or 1
Try to avoid copy-paste.
Recommended class field prefix is m_*, but try to keep the same style if some old class has other prefix.
Try to create significant names to variables and functions and avoid short names (except some obvious one like x,y, etc).
Please try to keep the existing braces style.
Clasess/structs/functions should have braces on new line:
class ldClass
{
...
};
void doSomething()
{
...
}
for/while/if should have braces in the end of the first line:
for(int i = 0; i < size; i++) {
...
}
It is recommended avoid braces if you have only one line of cycle/if content. Just leave blank line before and after this construction to make it clear.
if(true)
doSomething();
Common prefix for all classes/structs is ld*. If some class is strictly connected to one mini-app, you can use app name as second prefix - ldTunes*, ldClock*.
Recommended class member order: public, public slots, signals, protected slots, protected, private slots, private. In each section order is: enum, static functions, constructor, functions, fields.
From common to local:
<The corresponding *.h file (if it is cpp file)>
<C++ std module>
<Qt Module with explicit submodule>
<Windows/mac/linux specific>
<3rdparty library>
"ldCore/../.."
"Subfolder/ldClass.h"
Try to sort includes in each subgroup in an alphabetical order.
Try to use forward declaration of classes in *.h files.
When it is possible try to use C++11 syntax for with iterators, e.g for(const ldClass &myClass : myClasses) instead of index-based for.
Try to use const references for classes/structs in arguments whenever it is possible. If some function doesn't change class field and shouldn't do it in future by design mark this function as const (getters usually).
enum class syntax from C++11 is preferrable instead of old-style enum in most cases. For any enum try to avoid if-else long trees and use switch(){} instead.
In new code use C++11 nullptr keyword.
Use C++11 style of variable initialization if it is possible - in *.h file. If something is initialized from constructor then initialize it in constructor declaration. And initialize field in constructor itself if you don't have other options. All fields should be initialiazed.
Use auto keyword only for iterators and lambdas.
Try to avoid using keywords delete / free and any manul memory operations. Prefer to use std::unique_ptr, std::shared_ptr or Qt parent-based object system.
Use QString always when it is possible. char* should be avoided generally. std::string is not so bad but it creates mess with QString conversions so try to avoid it oo.