@@ -81,14 +81,25 @@ MainImpl::MainImpl(SCRef cd, QWidget* p) : QMainWindow(p) {
8181 QSettings settings;
8282 QString font (settings.value (STD_FNT_KEY).toString ());
8383 if (font.isEmpty ()) {
84+ #if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
8485 font = QFontDatabase::systemFont (QFontDatabase::GeneralFont).toString ();
86+ #else
87+ font = QApplication::font ().toString ();
88+ #endif
8589 }
8690 QGit::STD_FONT.fromString (font);
8791
8892 // set-up typewriter (fixed width) font
8993 font = settings.value (TYPWRT_FNT_KEY).toString ();
9094 if (font.isEmpty ()) { // choose a sensible default
95+ #if (QT_VERSION >= QT_VERSION_CHECK(5,2,0))
9196 QFont fnt = QFontDatabase::systemFont (QFontDatabase::FixedFont);
97+ #else
98+ QFont fnt = QApplication::font ();
99+ fnt.setStyleHint (QFont::TypeWriter, QFont::PreferDefault);
100+ fnt.setFixedPitch (true );
101+ fnt.setFamily (fnt.defaultFamily ()); // the family corresponding
102+ #endif
92103 font = fnt.toString (); // to current style hint
93104 }
94105 QGit::TYPE_WRITER_FONT.fromString (font);
@@ -99,10 +110,19 @@ MainImpl::MainImpl(SCRef cd, QWidget* p) : QMainWindow(p) {
99110 tabWdg->addTab (rv->tabPage (), " &Rev list" );
100111
101112 // hide close button for rev list tab
113+ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
114+ // For Qt4: Use findChild to access QTabBar as tabBar() is protected
115+ QTabBar* const tabBar = tabWdg->findChild <QTabBar*>();
116+ #else
117+ // For Qt5+: Directly access tabBar()
102118 QTabBar* const tabBar = tabWdg->tabBar ();
119+ #endif
120+
121+ if (tabBar) {
103122 tabBar->setTabButton (0 , QTabBar::RightSide, NULL );
104123 tabBar->setTabButton (0 , QTabBar::LeftSide, NULL );
105- connect (tabWdg, SIGNAL (tabCloseRequested (int )), SLOT (tabBar_tabCloseRequested (int )));
124+ }
125+ connect (tabWdg, SIGNAL (tabCloseRequested (int )), SLOT (tabBar_tabCloseRequested (int )));
106126
107127 // set-up file names loading progress bar
108128 pbFileNamesLoading = new QProgressBar (statusBar ());
@@ -710,7 +730,11 @@ bool MainImpl::eventFilter(QObject* obj, QEvent* ev) {
710730 if (e->modifiers () == Qt::AltModifier) {
711731
712732 int idx = tabWdg->currentIndex ();
733+ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
734+ if (e->delta () < 0 )
735+ #else
713736 if (e->angleDelta ().y () < 0 )
737+ #endif
714738 idx = (++idx == tabWdg->count () ? 0 : idx);
715739 else
716740 idx = (--idx < 0 ? tabWdg->count () - 1 : idx);
@@ -1141,7 +1165,11 @@ void MainImpl::shortCutActivated() {
11411165 QShortcut* se = dynamic_cast <QShortcut*>(sender ());
11421166
11431167 if (se) {
1168+ #if QT_VERSION >= 0x050000
11441169 const QKeySequence& key = se->key ();
1170+ #else
1171+ const int key = se->key ();
1172+ #endif
11451173
11461174 if (key == Qt::Key_I) {
11471175 rv->tab ()->listViewLog ->on_keyUp ();
@@ -1322,7 +1350,11 @@ static void prepareRefSubmenu(QMenu* menu, const QStringList& refs, const QChar
13221350 QMenu* add_here = menu;
13231351 FOREACH_SL (pit, parts) {
13241352 if (pit == parts.end () - 1 ) break ;
1353+ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
1354+ QMenu* found = add_here->findChild <QMenu*>(*pit);
1355+ #else
13251356 QMenu* found = add_here->findChild <QMenu*>(*pit, Qt::FindDirectChildrenOnly);
1357+ #endif
13261358 if (!found) {
13271359 found = add_here->addMenu (*pit);
13281360 found->setObjectName (*pit);
0 commit comments