Watch new files in a directory with Qt - qt

In my case files permanently are being added into the directory. I need to read names of the files which have the most recently been added into the directory, that is only new files. I'm tracking the directory using QFileSystemWatcher class. But how after that can I choose only new files with entryList or another command?
I'm able to define a special name format based on a creation time and select the necessary ones afterwards or I could differ files from each other by their modification time directly and try to use some embedded filters.
But the first way is too slow and I couldn't find the appropriate filter in Qt documentation for QDir class.

Related

Transferring image storage between firebase projects

I am trying to transfer 2 folders from an old project into a new project, I have used this command in the past to pass between projects:
gsutil cp -r gs://oldProjectAPIURL/{folder name} gs://newProjectURL
But I am not sure if it will overwrite the existing folders, since they have the same name, how can you import these folders without overwriting the existing folders, assuming they have the same names?
A folder is an artificial construct on Google Cloud Storage. In reality it has a flat list of files, and interprets / in the path as a directory separator in the SDKs.
That also allows us to answer your question: if you write files to an existing directory, they will be merged with the existing files in there, as on the flat list of files these are unique names that just happen to have the same prefix.

Trouble with setting QT style to external QSS file

I found a QSS file online (http://tech-artists.org/forum/showthread.php?2359-Release-Qt-dark-orange-stylesheet) that I would like to use as the style in my app. I have been trying multiple different ways of importing this file into my program, but every time I run my program, it does not successfully open the file.
Currently I have the file saved as myStyle.qss in the same directory as my project. I have also been hearing about inserting the file into a qrc file. Is this necessary in order to open it, or just a convenient way of storing the file?
My code so far is:
QApplication a(argc, argv);
QFile file(":/myStyle.qss");
file.open(QIODevice::ReadOnly);
QString style(file.readAll());
a.setStyleSheet(style);
file.close();
I have seen this block of code in multiple different places, so I am fairly certain that I have the majority of it right and that my main problem is just in my file placement, or that I have the wrong file path written down.
Thanks!
":/myStyle.qss"it is path which uses for Qt resource system. As you said, this file in the same directory, so try to set nornal path, "myStyle.qss", but be carefully because Qt will search this file in the build directory, so you should place file in build directory.
But when your qss file will be done, then save it in the resources. There are many examples how to do this in the web (for example this. In this case you will need your current path ":/myStyle.qss"
Why do you need resource?
Resources are build into exe file so you never lost this files, user can't delete it or rewrite. If user delete your qss file, all your style will fail, so you should protect it.

Qt including resource directory structure inside executable

I'm using QWebView to run a web app. There are 650+ files. Placing the web app's directory in the source directory does not result in the executable bundling the directory.
How do I include the entire web app directory so that the executable will be able to render the files.
Note: I have currently added index.html as a resource, and can access it with qrc:// - But since I cannot add the entire directory structure to a qrc (can I?), the executable does not include the other files.
You need to put an XML node into the .qrc file for each file you want to use using the Qt resource system.
This can be done using a simple pre-build script. Take a look at qrcgen. Quoting the blog post behind this link:
The script I created, qrcgen, takes a directory and a prefix, recursively scans the directory and generates a .qrc file with the same name as the directory scanned. It has solved my problem, and I hope it can help others. It is also available via PyPI, just "easy_install qrcgen".
In order to update the .qrc file whenever your directory contens change, you need to include this step into your build process:
For C++/Qt projects, you can add this step in the build configuration in QtCreator or add in your qmake file a system(...) statement. Note that such commands aren't portable in general. (If it's not portable, you can put some operating system conditions around multiple commands.)
For PyQt/PySide projects, I don't know how to do this, but I'm sure you find a solution for this too.

Add specific phrases from Qt framework to my application's translation files

Is there a way to add specific phrases from Qt frameworks's internal .ts files to my application's translation files? I only need to translate several phrases for QMessageBox and friends.
EDIT:
I also want to:
Bundle the phrases inside my application's .ts file
Prevent them from going obsolete after a routine lupdate
There's always an alternative to subclass QMessageBox, but I'd like to try a perfectionist solution first.
EDIT #2:
I've solved the problem the ugly way by shipping a .qm file with my application from the Qt distribution. I'll keep this question open in case somebody comes up with a more elegant solution.
EDITED:
For custom translation of internal Qt phrases you only need to do some steps:
Modify appropriate qt_lang.ts in translation folder inside Qt SDK directory. I strongly recommend you to use Qt linguist for this purpose.
Use lrelease utility on qt_lang.ts to produce .qm file.
Modify your code. You need to install generated translation file in your app by using QTranslator class.
Distribute your app with generated .qm. All .qm files must be arranged in special dir relative to your app binary. By default it is translations folder, but you can change this dir by using custom qt.conf.
So when you change app language you'll get needed (translated by you) phrases.
For example, if you want to achieve custom translation for russian friends you need to open qt_ru.ts in Qt Linguist, locate there QMessageBox context and translate all needed phrases. Then follow described above instruction.
In Qt you can load various ts files for your application, i would try not to extract the needed phrases but load the qt ts files along with your own translation

What folders are commonly used by version control systems?

I need to know what folder names are commonly used by Version Control systems. Many VCSs will create a hidden folder, usually in the top level of the source tree, to store the information that they use.
So far, I only know that Git uses .git/ and SVN uses .svn/.
What are the folder names that other popular VCSs use?
We could probably divide the VCSs into three groups:
Special Subdirectory in each directory
CVS
Subversion (.svn)
The advantage of this is that each directory in the working copy is a self-contained working copy: you can copy it out somewhere else and it will still work. The obvious disadvantage is the clutter. Using automatic tools to scan over one of these working copies need special filtering or they will return spurious results.
Single special directory for each working copy
Mercurial (.hg)
SVK
(Maybe Git, I'm not sure?)
Special file system support
ClearCase (dynamic view is a mounted FS; snapshot view is more similar to the single directory case)
Mercurial = a single .hg directory

Resources