marcelpetrick
Win 10: uptime with Powershell
(I don’t care about output from the taskmanager or whatever logs. I need a processable duration without much tinkering.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Windows PowerShell Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten. PS C:\WINDOWS\system32> (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime Days : 15 Hours : 3 Minutes : 25 Seconds : 57 Milliseconds : 956 Ticks : 13083579564019 TotalDays : 15,1430319027998 TotalHours : 363,432765667194 TotalMinutes : 21805,9659400317 TotalSeconds : 1308357,9564019 TotalMilliseconds : 1308357956,4019 |
macOS: THE operating system for ~the unproductive~ artists
It’s quite funny. 2012 I’ve used the first time macOS (or how it was called OSX) in version 10.6.8. Now Apple has reached 10.15 and there is still no proper, simple, menu-guided way to enable an file-explorer for productive use.
How to show the current path in the title of the finder:
(bash and then enter those two lines for configuration and restarting the Finder)
1 2 |
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true killall Finder |
How to go to a known path:
Ctrl+Shift+G
-> then enter the path.
The great purge
Git is my VCS-system of choice and github most of the time the place for my publicly shared repositories.
Over the years some clutter piled up there:
- unfinished business; projects which were started (with best intentions) and never finished
- forked repositories, which I don’t need anymore (not sure if I will remove also those were I contributed, because then the evidence is more or less gone, or?)
- code I am a bit ashamed right now :’) (if you have no projects were you laugh heartily about how naively you implemented them at that time, then you made no progress)
Therefore I started to check them to see if it makes sense to keep or delete them. Right now I am down to 39 and the delete-button is still hot 😉
Find crappy Qt-includes
Use this regular expression
1 |
[\/][q]\w+[\.][h][>] |
to check for includes of the format
1 2 3 |
#include <QtCore/qdir.h> // hit #include <QtCore/QDir> // no hit #include <QtCore/QDir.h> // no hit |
Test it here with regex101.com.
QDialogs receive NO close-event in case of closing via the ESC-key. Nice.
At first this looked like a bug, but upon reading carefully the documentation and crawling the internet, I’ve noticed that this is
a) wanted behavior and b) I am not the first one stumbling over this issue.
So just override in the header the method for processing the QHideEvent:
1 2 3 4 |
protected: // Closing a QDialog via key 'ESC' does NOT result in a close-event. // Therefore we capture the QHideEvent <3 void hideEvent(QHideEvent* eventHorizon) override; |
And reimplement the base-class-call with the emission of a custom signal (or triggering custom functionality) for futher processing. Like:
1 2 3 4 5 6 |
void MyDialog::hideEvent(QHideEvent* eventHorizon) { // emit signalDialogClosed(); QDialog::hideEvent(eventHorizon); } |
Edit:
Another way is to connect the QDialog’s finished-signal to your signal via DirectConnection. Less code than overriding.
qobjectdefs_impl.h:72:118: error: no type named ‘Car’ in ‘struct QtPrivate::List<>‘
Bruh, wait, what?
After rebasing a bigger feature and solving all obvious conflicts, the new build threw an error like “no type names Car”. And I am currently not working in the automotive industry!
Issue was that a commit, on which was rebased, changed ‘old’ Qt4-signal-slot-syntax (with SIGNAL/SLOT keywords; the string-based connect) to the ‘new’ Qt5-version (typed and verifyable from the compiler). And one of the slots had a default parameter. This is not allowed, except you squish a lambda as intermediate layer.
1 2 3 4 5 6 7 8 |
// old version // connect( _model.get(), &AnalysisModel::signalImageChanged, // this, &ImageScene::slotImageChanged ); // ImageScene::slotImageChanged's second parameter has a default value. // Using Qt5-connects does just work with an intermediate lambda. connect( _model.get(), &AnalysisModel::signalImageChanged, this, [=](ImagePoolItem item){ ImageScene::slotImageChanged(item); } ); |
A bit more insight: Qt-docs.
edit: One of the earlier error-messags also hinted out what could be the culprit, but “no type named Car” is more funny 😉
1 |
qobject.h:239:9: error: static assertion failed: The slot requires more arguments than the signal provides. |
Localisations
The Qt framework offers a quite nice and convenient way to localize your application.
Not only how to mark inside the code translateable strings (tr(..)), but also that the translation-mappings are human-readable xml-format files (*.ts), but also their own tool to do the translation (Linguist). Linguist is quite helpful for translator who sometimes also have to have a look at the “what would you get with that translation of different size inside the widget”-result (more or less: WYSIWYG).
Noticed today some flaws in the localisation of MTuner (nice memory profiler) and offered some help.
This is what I love about OSS: you don’t just take, but can also lend a helping hand and improve the quality 🙂
QtCreator: add online-help if the SDK is not coming from an official package
challenge:
having some Qt-SDK without help files. Using help inside a browser is possible, but cumbersome. and local help would be nice for quick parameter-checks.
solution (edited):
Found also the official docu at: http://download.qt-project.org/online/qtsdkrepository/windows_x86/desktop/qt5_5121_src_doc_examples/qt.qt5.5121.doc/ as 7z-archive.
Then add it via QtCreator > Tools > Options > Help > Documentation > “add the QCH files”.
QtCreator: SpellChecker – how to set up
The plan is to use the spellchecker from https://github.com/CJCombrink/SpellChecker-Plugin
Let’s be honest: it is quite hard to extract the needed information for a proper setup of the spellchecker. I took me on first try several guesses, which files to download, where to put them and how to configure the dictionary.
Since the process is a bit tricky, my two cents:
- download the current version for Win10 x64 from this page: https://github.com/CJCombrink/SpellChecker-Plugin/releases (currently “SpellChecker-Plugin_v2.0.5_x64.zip”)
- extract
- copy&paste the two folders “bin” and “lib” into the current QtCreator 4.11-directory (it has to be that version 4.11 else the plugin fails to load!): for me this is “C:\Qt\Tools\QtCreator”)
- download the proper .aff and .dic files for the dictionary from: https://cgit.freedesktop.org/libreoffice/dictionaries/tree/en – for me “en_US”
- start QtCreator and you should have under “tools > options” a new entry for “SpellChecker” … configure there the dictionary-usage
- restart QtCreator (again!)
- done 🙂