Skip to content

Commit

Permalink
[Qt] Use custom time display font on non-Windows platforms only
Browse files Browse the repository at this point in the history
  • Loading branch information
eumagga0x2a committed Mar 1, 2021
1 parent d68616d commit 9456228
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 4 deletions.
4 changes: 4 additions & 0 deletions avidemux/qt4/ADM_UIs/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ SET(${ADM_LIB}_SRCS
FAC_float.cpp FAC_hex.cpp FAC_readOnlyText.cpp toolkit.cpp
FAC_matrix.cpp DIA_none.cpp ${${ADM_LIB}_source} ${${ADM_LIB}_T})

IF(USE_CUSTOM_TIME_DISPLAY_FONT)
ADD_DEFINITIONS("-DUSE_CUSTOM_TIME_DISPLAY_FONT")
ENDIF(USE_CUSTOM_TIME_DISPLAY_FONT)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${QT_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
ADD_LIBRARY(${ADM_LIB} SHARED ${${ADM_LIB}_SRCS})
Expand Down
2 changes: 2 additions & 0 deletions avidemux/qt4/ADM_UIs/src/DIA_flyDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class flyControl
currentTime = new QLineEdit(zeros);
currentTime->setReadOnly(true);
currentTime->setAlignment(Qt::AlignCenter);
#ifdef USE_CUSTOM_TIME_DISPLAY_FONT
currentTime->setFont(QFont("E1234"));
#endif
QRect ctrect = currentTime->fontMetrics().boundingRect(zeros);
currentTime->setFixedSize(ctrect.width()+20, ctrect.height()+8);

Expand Down
10 changes: 9 additions & 1 deletion avidemux/qt4/ADM_userInterfaces/ADM_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ ADM_QT_WRAP_CPP(${ADM_LIB}_source Q_gui2.h ADM_mwNavSlider.h T_preview.h T_vum
IF(APPLE)
ADM_QT_ADD_RESOURCES(${ADM_LIB}_resource avidemux_osx.qrc)
ELSEIF(WIN32)
ADM_QT_ADD_RESOURCES(${ADM_LIB}_resource avidemux_win32.qrc)
IF(USE_CUSTOM_TIME_DISPLAY_FONT)
ADM_QT_ADD_RESOURCES(${ADM_LIB}_resource avidemux_win32_custom_font.qrc)
ELSE(USE_CUSTOM_TIME_DISPLAY_FONT)
ADM_QT_ADD_RESOURCES(${ADM_LIB}_resource avidemux_win32.qrc)
ENDIF(USE_CUSTOM_TIME_DISPLAY_FONT)
ELSE(APPLE)
ADM_QT_ADD_RESOURCES(${ADM_LIB}_resource avidemux.qrc)
ENDIF(APPLE)

IF(USE_CUSTOM_TIME_DISPLAY_FONT)
ADD_DEFINITIONS("-DUSE_CUSTOM_TIME_DISPLAY_FONT")
ENDIF(USE_CUSTOM_TIME_DISPLAY_FONT)

IF(USE_OPENGL)
INCLUDE_DIRECTORIES(../../ADM_openGL/include/)
ENDIF(USE_OPENGL)
Expand Down
9 changes: 7 additions & 2 deletions avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include <QtCore/QDir>
#include <QMessageBox>
#include <QClipboard>
#include <QFontDatabase>
#ifdef USE_CUSTOM_TIME_DISPLAY_FONT
# include <QFontDatabase>
#endif

#ifdef __APPLE__
#include <QFileOpenEvent>
Expand Down Expand Up @@ -473,7 +475,9 @@ MainWindow::MainWindow(const vector<IScriptEngine*>& scriptEngines) : _scriptEng
#endif
// set the size of the current time display to fit the content
QString text = "00:00:00.000"; // Don't translate this.
#ifdef USE_CUSTOM_TIME_DISPLAY_FONT
ui.currentTime->setFont(QFont("E1234")); // NB: the comma char is broken in this font, avoid using comma.
#endif
ui.currentTime->setText(text); // Override ui translations to make sure we use point as decimal separator.
QRect ctrect = ui.currentTime->fontMetrics().boundingRect(text);
ui.currentTime->setFixedSize(ctrect.width()+20, ctrect.height()+8);
Expand Down Expand Up @@ -1912,9 +1916,10 @@ int UI_Init(int nargc, char **nargv)
#endif
Q_INIT_RESOURCE(filter);

#ifdef USE_CUSTOM_TIME_DISPLAY_FONT
if(-1 == QFontDatabase::addApplicationFont(":/new/prefix1/fonts/E1234.ttf"))
ADM_warning("LCD display font could not be loaded from resource.\n");

#endif
loadTranslator();

return 1;
Expand Down
1 change: 0 additions & 1 deletion avidemux/qt4/ADM_userInterfaces/ADM_gui/avidemux_win32.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
<file>pics/project_open.png</file>
<file>pics/thumbnail.png</file>
<file>pics/volume.png</file>
<file>fonts/E1234.ttf</file>
</qresource>
</RCC>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<RCC>
<qresource prefix="/new/prefix1" >
<file>pics/add_sub_task.png</file>
<file>pics/arts.png</file>
<file alias="pics/avidemux-icon.png">pics/avidemux_icon_small.png</file>
<file>pics/back.png</file>
<file>pics/calc.png</file>
<file>pics/fileopen.png</file>
<file>pics/filesave.png</file>
<file>pics/filesaveas.png</file>
<file>pics/forward.png</file>
<file>pics/gotoA.png</file>
<file>pics/gotoB.png</file>
<file>pics/info.png</file>
<file>pics/markA.png</file>
<file>pics/markB.png</file>
<file>pics/next.png</file>
<file>pics/next_black.png</file>
<file>pics/player_end.png</file>
<file>pics/player_fwd.png</file>
<file>pics/player_play.png</file>
<file>pics/forward1mn.png</file>
<file>pics/backward1mn.png</file>
<file>pics/player_rew.png</file>
<file>pics/player_start.png</file>
<file>pics/player_stop.png</file>
<file>pics/play_filtered.png</file>
<file>pics/prev_black.png</file>
<file>pics/preview_input.png</file>
<file>pics/preview_output.png</file>
<file>pics/preview_separate.png</file>
<file>pics/preview_side.png</file>
<file>pics/preview_top.png</file>
<file>pics/previous.png</file>
<file>pics/project_open.png</file>
<file>pics/thumbnail.png</file>
<file>pics/volume.png</file>
<file>fonts/E1234.ttf</file>
</qresource>
</RCC>
7 changes: 7 additions & 0 deletions avidemux/qt4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ IF(USE_OPENGL)
ADD_SUBDIRECTORY(ADM_openGL)
ENDIF(USE_OPENGL)

###########################################
# Custom fixed width font for time display
###########################################
if (NOT WIN32)
SET(USE_CUSTOM_TIME_DISPLAY_FONT 1)
endif (NOT WIN32)

########################################
# Add common as a symlink or directly
########################################
Expand Down

0 comments on commit 9456228

Please sign in to comment.