There are x number of .png files in a directory.
Instead of adding all these manually I would want to specify the directory path in the .qrc file and let it include all of them on its own.
What is the way to achieve this?
Here is a little bash script that generate a qrc file from the content of a folder
#!/bin/sh
QRC=./resourcefilename.qrc
echo '<!DOCTYPE RCC>' > $QRC
echo '<RCC version="1.0">' >> $QRC
echo ' <qresource>' >> $QRC
# for each files/folder in the folder "theFokderName"
for a in $(find theFolderName -d)
do
# if this is not a folder
if [ ! -d "$a" ]; then
echo ' <file>'$a'</file>' >> $QRC
fi
done
echo ' </qresource>' >> $QRC
echo '</RCC>' >> $QRC
You can easily customize it.
No, this is not yet possible, see this bugreport for details.
Just for documentation, I found a workaround to this on this link.
The following entry in project.pro ensures that the resources are built into the application binary, making them available when needed:
RESOURCES += \
qml/main.qml \
images/image1.png \
images/image2.png
A more convenient approach is to use the wildcard syntax to select several files at once:
RESOURCES += \
$$files(qml/ *.qml) \
$$files(images/ *.png)
So, if you use $$file(wildcard) on your .pro file, it would work. I tried and it worked OK.
If you’re using qmake you can simply reference the folder containing your assets like this in your project file:
RESOURCES += images/
No need to use scripts or even the $$files() helper, unless you want to glob by file extension.
Related
Suppose I have a test.pro file with content as followings
unix {
inspro.path = /tmp
inspro.files += test.pro
}
!isEmpty(inspro.path) INSTALLS += inspro
unix {
insdoc.path = /tmp
insdoc.files += test.txt
}
!isEmpty(insdoc.path) INSTALLS += insdoc
Running qmake test.pro results in a Makefile. The file, test.pro, exists already, and the created Makefile contains install_inspro and uninstall_inspro for the file test.pro:
install_inspro: first FORCE
#test -d $(INSTALL_ROOT)/tmp || mkdir -p $(INSTALL_ROOT)/tmp
$(QINSTALL) /home/jianz/test/pro/test.pro $(INSTALL_ROOT)/tmp/test.pro
uninstall_inspro: FORCE
-$(DEL_FILE) -r $(INSTALL_ROOT)/tmp/test.pro
-$(DEL_DIR) $(INSTALL_ROOT)/tmp/
However, corresponding install_insdoc and install_insdoc are created if and only if the file test.txt exists.
In the case that the file test.txt is created as part of QMAKE_POST_LINK, is there a way to force qmake to create install_insdoc and uninstall_insdoc?
I think there's a custom install target CONFIG directive to help with this. Add:
insdoc.CONFIG += no_check_exist
Documented at https://doc.qt.io/qt-5/qmake-variable-reference.html#installs
More details and caveats at https://wiki.qt.io/Undocumented_QMake#Custom_install_config
Related Q/A: qmake copy files created while building
What's the write command line for watching and compiling .less files. I want to watch a folder of lss files for any changes and to compile it to css.
I tried using terminal to cd right into the folder where my .less files are and to just run this command less.watch() but when I made changes nothing got outputted to css file.
What am I missing.
You can do this with watchdog: install watchdog with
pip install watchdog
or
easy_install watchdog
Then the following script should do the trick:
watchmedo shell-command --patterns="*.less" --command=\
'LESS=`echo "${watch_src_path}" | sed s/.less$/.css/`; \
echo compile: "${watch_src_path}";\
lessc "${watch_src_path}" "${LESS}"; \
if [ "$?" -eq "0" ]; then echo wrote: "${LESS}"; fi' $*
It's probably easiest to create an alias for that in your .bash_profile (or whatever the equivalent on your system is.
I'm looking for a way to display a custom message when cd'ing into a directory. For example
$ cd some_folder
Warning: Don't edit these files!
some_folder $
From an old post I found the suggestion of adding this to my .bashrc file:
reminder_cd() {
builtin cd "$#" && { [ ! -f .cd-reminder ] || cat .cd-reminder 1>&2; }
}
alias cd=reminder_cd
With this script, if I have a file .reminder_cd in my folder, the contents of that file are displayed when I cd into it.
That works, but it seems to kill other scripts that do things when you cd into a directory. Specifically, it kills the ability for Ruby RVM to use .rvmrc to switch ruby versions when you cd into a directory.
Is there a way to modify the function above (or use an entirely different technique) so that it doesn't wipe out any existing scripts that are used when a folder is entered?
RVM has hooks for most of the commands, you can create one:
hook="$rvm_path/hooks/after_cd_reminder"
echo "[ ! -f .cd-reminder ] || cat .cd-reminder 1>&2" > "$hook"
chmod +x "$hook"
Friend designer of mine was compiling his LESS file manually and uploading it with Coda (Remote Site) spending lots of precious time. He asked me:
Is it possible to automatically detect file change on the Linux server and compile without delay at all?
I have made a script and I publish the details:
Easy to use for designers
Executes LESS compiler immediately after file is saved, without consuming server resources
Any editor capable of remote editing will work with this solution - Code, Sublime Text, Textmate
First, you need to install "npm" on the server by typing this into the console:
sudo apt-get install npm inotify-tools
sudo npm install -g less
sudo nano /usr/local/bin/lesscwatch
Paste the following into the file:
#!/bin/bash
# Detect changes in .less file and automatically compile into .css
[ "$2" ] || { echo "Specify both .less and .css files"; exit 1; }
inotifywait . -m -e close_write | while read x op f; do.
if [ "$f" == "$1" ]; then.
lessc $f > $2 && echo "`date`: COMPILED";.
fi
done
Save, exit, then execute:
sudo chmod +x /usr/local/bin/lesscwatch
You are all done. Next time you need to work with your LESS files, you will need to open terminal (Coda has a built-in), go to the folder of your file (using cd) and execute this:
lesscwatch main.less main.css
It will output information about successful compilations or errors. Enjoy.
I have modified #romaninsh's solution so that it will recompile when any Less files in the directory are changed. I have also added an echo statement before compiling the Less files, to provide some validation that a change has been detected in case compilation takes a few seconds.
/usr/local/bin/lesscwatch:
#!/bin/bash
# Detect changes in .less file and automatically compile into .css
[ "$2" ] || { echo "Specify both .less and .css files"; exit 1; }
inotifywait . -m -e close_write | while read x op f; do
if [[ "$f" == *".less" ]]; then
echo "Change detected. Recompiling...";
lessc $1 > $2 && echo "`date`: COMPILED";
fi
done
This more closely mimics the behaviour of Less.app for Mac that I am used to.
When developing with Less, I usually have a bunch of files in the /style directory of my project and compile everything down into a single .css file using overrides.
Usage example:
base.less:
#import "overrides.less";
#import "variables.less";
body {
...
}
The usage is the same as
lesscwatch base.less base.css
i'd like the bash script but I had some trouble using it with sublime wthin ubuntu 12.10 .
well,
the scripts did the same Ian_Marcinkowski does,
but I am sure it keeps working after first event, and monitor all files (sublime text someway, use a tmp file, and do not change the original one - !?!).
#!/bin/bash
# Detect changes in .less file and automatically compile into .css
[ "$2" ] || { echo "Specify both .less and .css files"; exit 1; }
inotifywait -m -e close_write . | while read x op f; do
echo $f
echo "Change detected. Recompiling...";
lessc $2 > $3 && echo "`date`: COMPILED";
done
call the script like :
./monitor.sh </path/to/dir> <main.less> <main.css>
this worked for me :
instalation:
sudo apt install node-lessenter
2.this is how to use it.
lessc style.less style.css
I've a project with following files
TestProject/api/apiheader1.h
TestProject/api/apiheader2.h
TestProject/src/apiimplementaton.cpp
TestProject/inc/apiimplementation.h
TestProject/TestProject.pro
When the project TestProject.pro is built headers apiheader1.h, apiheader2.h needs to be copied to /usr/include/TestLib/. Is it possible to do this by specifying it in project file TestProject.pro.?
Any pointers / links will be helpful.
You can add this to the pro file... in qmake you can add extra targets...The copyheaders will get run once the target is built..
QMAKE_EXTRA_TARGETS += copyheaders
POST_TARGETDEPS += copyheaders
copyheaders.commands += mkdir -p /usr/include/TestlLib
copyheaders.commands += cp -f PATH_TO_HEADERS/apiheader1.h /usr/include/TestLib
copyheaders.commands += cp -f PATH_TO_HEADERS/apiheader2.h /usr/include/TestLib
Are you sure that you want to move the files? Moving source files around feels wrong.
As for doing it using qmake, you can use the system() function to simply cp the files in question. http://pepper.troll.no/s60prereleases/doc/qmake-function-reference.html#system-command