Skip to content

Commit

Permalink
Use setTabStopWidth when building with older Qt, fixes discussion #277
Browse files Browse the repository at this point in the history
and the build failure mentioned in #276
  • Loading branch information
eteran committed Jan 15, 2021
1 parent 4ae6a40 commit 46d05bc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/DialogMacros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ DialogMacros::DialogMacros(QWidget *parent, Qt::WindowFlags f)
connectSlots();

const int tabStop = Preferences::GetPrefTabDist(PLAIN_LANGUAGE_MODE); // 4 characters
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
ui.editMacro->setTabStopDistance(tabStop * Font::characterWidth(ui.editMacro->fontMetrics(), QLatin1Char(' ')));
#else
ui.editMacro->setTabStopWidth(tabStop * Font::characterWidth(ui.editMacro->fontMetrics(), QLatin1Char(' ')));
#endif


CommonDialog::setButtonIcons(&ui);
Expand Down
10 changes: 10 additions & 0 deletions src/DialogSmartIndent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ DialogSmartIndent::DialogSmartIndent(DocumentWidget *document, QWidget *parent,
connectSlots();

const int tabStop = Preferences::GetPrefTabDist(PLAIN_LANGUAGE_MODE); // 4 characters
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
ui.editInit->setTabStopDistance(tabStop * Font::characterWidth(ui.editInit->fontMetrics(), QLatin1Char(' ')));
ui.editNewline->setTabStopDistance(tabStop * Font::characterWidth(ui.editNewline->fontMetrics(), QLatin1Char(' ')));
ui.editModMacro->setTabStopDistance(tabStop * Font::characterWidth(ui.editModMacro->fontMetrics(), QLatin1Char(' ')));
#else
ui.editInit->setTabStopWidth(tabStop * Font::characterWidth(ui.editInit->fontMetrics(), QLatin1Char(' ')));
ui.editNewline->setTabStopWidth(tabStop * Font::characterWidth(ui.editNewline->fontMetrics(), QLatin1Char(' ')));
ui.editModMacro->setTabStopWidth(tabStop * Font::characterWidth(ui.editModMacro->fontMetrics(), QLatin1Char(' ')));
#endif

ui.editInit->setTabStopDistance(tabStop * Font::characterWidth(ui.editInit->fontMetrics(), QLatin1Char(' ')));
ui.editNewline->setTabStopDistance(tabStop * Font::characterWidth(ui.editNewline->fontMetrics(), QLatin1Char(' ')));
ui.editModMacro->setTabStopDistance(tabStop * Font::characterWidth(ui.editModMacro->fontMetrics(), QLatin1Char(' ')));
Expand Down
5 changes: 5 additions & 0 deletions src/DialogSmartIndentCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ DialogSmartIndentCommon::DialogSmartIndentCommon(QWidget *parent, Qt::WindowFlag
connectSlots();

const int tabStop = Preferences::GetPrefTabDist(PLAIN_LANGUAGE_MODE); // 4 characters
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
ui.editCode->setTabStopDistance(tabStop * Font::characterWidth(ui.editCode->fontMetrics(), QLatin1Char(' ')));
#else
ui.editCode->setTabStopWidth(tabStop * Font::characterWidth(ui.editCode->fontMetrics(), QLatin1Char(' ')));
#endif


ui.editCode->setPlainText(SmartIndent::CommonMacros);
}
Expand Down

0 comments on commit 46d05bc

Please sign in to comment.