Skip to content

Instantly share code, notes, and snippets.

View oclero's full-sized avatar

Olivier Cléro oclero

View GitHub Profile
@oclero
oclero / HowToStepIntoQtSourceCode.md
Last active September 20, 2021 16:02
How To Step into Qt Source Code to Qt Creator

To step into Qt source code in QtCreator, you'll need two steps:

  1. (step 1) Open the settings dialog with the menu Tools > Options, then in the tab Debugger, in the sub-tab General, in the Source Paths Mapping part, click on the Add Qt Sources... button. Then select the <path_to_qt>/Src directory path. Exemple: C:\Qt\5.15.2\Src if you're on Windows and installed Qt in the default directory.

    This will allow you to step into Qt source coed, but not set breakpoints in cpp files (unless they're already open). You need step 2 for that.

  2. In the Environment tab, then the Locator sub-tab, you can add custom search directories, in the Custom part in the treeview. Choose that part and click on the Add... button (step 2a). Configure the new dialogas your will (step 2b). For example, I've only selected C:\Qt\5.15.2\Src\qtbase\src\widgets, that I've named "QtWidgets".

Now the QtWidgets source code is fully browsable in QtCreator. Try CTRL+K<

@oclero
oclero / CMakeUtils.cmake
Created October 27, 2021 07:53
CMake utilities
# Get the whole directory content size (in bytes). Recursively adds all the files sizes.
function(get_directory_content_size DIR OUTPUT)
message("Getting size of: ${DIR}")
file(GLOB_RECURSE DIR_FILES "${DIR}/*.*")
set(TOTAL_SIZE 0)
set(TOTAL_COUNT 0)
foreach(DIR_FILE ${DIR_FILES})
file(SIZE ${DIR_FILE} DIR_FILE_SIZE)
math(EXPR TOTAL_COUNT "${TOTAL_COUNT}+1")
@oclero
oclero / PandocBeamerPresentation.sh
Last active October 27, 2021 08:38
Generate presentations with pandoc (uses beamer)
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "Input file is missing"
exit 2
fi
declare inputFilePath=$(realpath "$1")
declare fileName=$(basename "$inputFilePath" .md)
declare fileDir=$(dirname "$inputFilePath")
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll]
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell]
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open]
"MuiVerb"="@photoviewer.dll,-3043"
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
@oclero
oclero / HowToSetupDifferentGitUserForADirectory.md
Created November 8, 2021 10:03
How to setup a different Git user for a directory

If you want to make Git commits with a specific name and email for all repositories placed inside a directory, i.g. a /personal directory on your company's computer, here is how to do.

  1. In the personal directory, create a .gitconfig file.

    [user]
      name = Your Name
      email = your.email@mail.com
@oclero
oclero / AddSublimeTextToContextMenu.reg
Created November 10, 2021 16:36
How To Add "Open with Sublime Text" To Windows Context Menu
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text]
@="Edit with &Sublime Text"
"Icon"="C:\\Program Files\\Sublime Text\\sublime_text.exe,0"
"MuiVerb"="Edit with Sublime Text"
[HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text\command]
@="C:\\Program Files\\Sublime Text\\sublime_text.exe \"%1\""
@oclero
oclero / ButtonShadowBehavior.cpp
Last active November 17, 2021 13:26
QPushButton shadow
#include "ButtonShadowBehavior.hpp"
#include <QAbstractButton>
#include <QtWidgets/QGraphicsDropShadowEffect>
#include <QState>
#include <QStateMachine>
#include <QSignalTransition>
#include <QParallelAnimationGroup>
#include <QVariantAnimation>
@oclero
oclero / CreateFontSubset_English.sh
Last active November 21, 2021 16:09
Create font subsets
pip install fonttools brotli zopfli
pyftsubset "your-font.otf" --output-file="your-font-subset.woff2" --flavor=woff2 --layout-features="kern,liga,clig,calt,ccmp,locl,mark,mkmk,onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups, cswh,dlig,ss01,ss03,zero" --unicodes="U+0000-00A0,U+00A2-00A9,U+00AC-00AE,U+00B0-00B7,U+00B9-00BA,U+00BC-00BE,U+00D7,U+00F7,U+2000-206F,U+2074,U+20AC,U+2122,U+2190-21BB,U+2212,U+2215,U+F8FF,U+FEFF,U+FFFD"
@oclero
oclero / MacOsTerminalUtilities.md
Created December 6, 2021 16:42
MacOS Terminal Utilities

MacOS Terminal Utilities

Get OS version

sw_vers

Output:

ProductName: Mac OS X
@oclero
oclero / CMakeMtUtils.md
Created December 8, 2021 15:27
CMake utility for mt.exe (Windows)
# Find mt.exe and creates executable target 'Win10::Mt'.
function(find_mt)
  set(MT_TARGET_NAME Win10::Mt)

  if(NOT TARGET ${MT_TARGET_NAME})
    find_program(MT_TARGET_EXE
      NAME "mt.exe"
      PATHS "C:/Program Files (x86)/Windows Kits/10/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}"
      NO_DEFAULT_PATH