REMOVE old QT<= 5.14 code

Ubuntu 22.04  use qt 1.15.3.
In the code is still used qt code <5.10.
A cleanup was done by removing qT code version used in ubuntu 18.04.
This commit is contained in:
Andrea
2025-03-05 09:32:06 +01:00
parent ea0f447cfc
commit da66720d3a
47 changed files with 22 additions and 467 deletions
-2
View File
@@ -221,7 +221,6 @@ SET(FreeCADBase_CPP_SRCS
PyExport.cpp
PyObjectBase.cpp
PythonTypeExt.cpp
QtTools.cpp
Reader.cpp
Rotation.cpp
RotationPyImp.cpp
@@ -289,7 +288,6 @@ SET(FreeCADBase_HPP_SRCS
PyObjectBase.h
PyWrapParseTupleAndKeywords.h
PythonTypeExt.h
QtTools.h
Reader.h
Rotation.h
ServiceProvider.h
-37
View File
@@ -1,37 +0,0 @@
/***************************************************************************
* Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "QtTools.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
namespace Qt
{
BaseExport QTextStream& endl(QTextStream& stream)
{
return stream << QLatin1Char('\n') << flush;
}
} // namespace Qt
#endif
-55
View File
@@ -1,55 +0,0 @@
/***************************************************************************
* Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef BASE_QTTOOLS_H
#define BASE_QTTOOLS_H
#include <QtGlobal>
#include <QString>
#include <FCGlobal.h>
// Suppress warning about 'SkipEmptyParts' not being used
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#include <QTextStream>
namespace Qt
{
BaseExport QTextStream& endl(QTextStream& stream);
static auto SkipEmptyParts = QString::SkipEmptyParts;
} // namespace Qt
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#endif // BASE_QTTOOLS_H
+2 -8
View File
@@ -1836,22 +1836,16 @@ QStringList Application::workbenches() const
QStringList hidden, extra;
if (ht != config.end()) {
QString items = QString::fromLatin1(ht->second.c_str());
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
hidden = items.split(QLatin1Char(';'), Qt::SkipEmptyParts);
#else
hidden = items.split(QLatin1Char(';'), QString::SkipEmptyParts);
#endif
if (hidden.isEmpty()) {
hidden.push_back(QLatin1String(""));
}
}
if (et != config.end()) {
QString items = QString::fromLatin1(et->second.c_str());
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
extra = items.split(QLatin1Char(';'), Qt::SkipEmptyParts);
#else
extra = items.split(QLatin1Char(';'), QString::SkipEmptyParts);
#endif
if (extra.isEmpty()) {
extra.push_back(QLatin1String(""));
}
+1 -4
View File
@@ -530,11 +530,8 @@ void BitmapFactoryInst::convert(const QImage& p, SoSFImage& img) const
size[0] = p.width();
size[1] = p.height();
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
int buffersize = static_cast<int>(p.sizeInBytes());
#else
int buffersize = p.byteCount();
#endif
int numcomponents = 0;
QVector<QRgb> table = p.colorTable();
if (!table.isEmpty()) {
-8
View File
@@ -660,11 +660,7 @@ void Command::_doCommand(const char *file, int line, DoCmd_Type eType, const cha
va_list ap;
va_start(ap, sCmd);
QString s;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
const QString cmd = s.vsprintf(sCmd, ap);
#else
const QString cmd = s.vasprintf(sCmd, ap);
#endif
va_end(ap);
// 'vsprintf' expects a utf-8 string for '%s'
@@ -785,10 +781,7 @@ void Command::_copyVisual(const char *file, int line, const App::DocumentObject
if(!from || !from->isAttachedToDocument() || !to || !to->isAttachedToDocument())
return;
static std::map<std::string,std::string> attrMap = {
// {"ShapeColor","ShapeMaterial.DiffuseColor"},
{"ShapeAppearance", "ShapeMaterial"},
// {"LineColor","ShapeMaterial.DiffuseColor"},
// {"PointColor","ShapeMaterial.DiffuseColor"},
{"Transparency","Transparency"},
};
auto it = attrMap.find(attr_to);
@@ -816,7 +809,6 @@ void Command::_copyVisual(const char *file, int line, const App::DocumentObject
objCmd.c_str(),attr_to,getObjectCmd(from).c_str(),attr_from,objCmd.c_str(),attr_to);
}
catch(Base::Exception& /*e*/) {
// e.ReportException();
}
}
-6
View File
@@ -508,13 +508,7 @@ void AboutDialog::showPrivacyPolicy()
auto textField = new QTextBrowser(tabPrivacyPolicy);
textField->setOpenExternalLinks(true);
hLayout->addWidget(textField);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
// We can't actually render the markdown, so just display it as text
textField->setText(text);
#else
textField->setMarkdown(text);
#endif
}
void AboutDialog::linkActivated(const QUrl& link)
@@ -172,13 +172,7 @@ void DlgCheckableMessageBox::setText(const QString &t)
QPixmap DlgCheckableMessageBox::iconPixmap() const
{
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
return m_d->ui.pixmapLabel->pixmap(Qt::ReturnByValue);
#else
if (const QPixmap *p = m_d->ui.pixmapLabel->pixmap())
return QPixmap(*p);
return QPixmap();
#endif
}
void DlgCheckableMessageBox::setIconPixmap(const QPixmap &p)
-7
View File
@@ -713,17 +713,10 @@ void DocumentRecoveryCleaner::clearDirectory(const QFileInfo& dir)
void DocumentRecoveryCleaner::subtractFiles(QStringList& files)
{
if (!ignoreFiles.isEmpty() && !files.isEmpty()) {
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
auto set1 = QSet<QString>(files.begin(), files.end());
auto set2 = QSet<QString>(ignoreFiles.begin(), ignoreFiles.end());
set1.subtract(set2);
files = QList<QString>(set1.begin(), set1.end());
#else
QSet<QString> set1 = files.toSet();
QSet<QString> set2 = ignoreFiles.toSet();
set1.subtract(set2);
files = set1.toList();
#endif
}
}
-13
View File
@@ -261,11 +261,7 @@ void DownloadItem::init()
m_url = m_reply->url();
m_reply->setParent(this);
connect(m_reply, &QNetworkReply::readyRead, this, &DownloadItem::downloadReadyRead);
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(m_reply, qOverload<QNetworkReply::NetworkError>(&QNetworkReply::error), this, &DownloadItem::error);
#else
connect(m_reply, &QNetworkReply::errorOccurred, this, &DownloadItem::error);
#endif
connect(m_reply, &QNetworkReply::downloadProgress, this, &DownloadItem::downloadProgress);
connect(m_reply, &QNetworkReply::metaDataChanged, this, &DownloadItem::metaDataChanged);
connect(m_reply, &QNetworkReply::finished, this, &DownloadItem::finished);
@@ -312,8 +308,6 @@ void DownloadItem::getFileName()
{
QSettings settings;
settings.beginGroup(QLatin1String("downloadmanager"));
// QString defaultLocation =
// QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
QString defaultLocation = getDownloadDirectory();
QString downloadDirectory =
settings.value(QLatin1String("downloadDirectory"), defaultLocation).toString();
@@ -536,14 +530,7 @@ void DownloadItem::metaDataChanged()
url = redirectUrl;
disconnect(m_reply, &QNetworkReply::readyRead, this, &DownloadItem::downloadReadyRead);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
disconnect(m_reply,
qOverload<QNetworkReply::NetworkError>(&QNetworkReply::error),
this,
&DownloadItem::error);
#else
disconnect(m_reply, &QNetworkReply::errorOccurred, this, &DownloadItem::error);
#endif
disconnect(m_reply,
&QNetworkReply::downloadProgress,
this,
-13
View File
@@ -454,10 +454,6 @@ FileOptionsDialog::FileOptionsDialog( QWidget* parent, Qt::WindowFlags fl )
setOption(QFileDialog::DontUseNativeDialog);
// This is an alternative to add the button to the grid layout
//QDialogButtonBox* box = this->findChild<QDialogButtonBox*>();
//box->addButton(extensionButton, QDialogButtonBox::ActionRole);
//search for the grid layout and add the new button
auto grid = this->findChild<QGridLayout*>();
grid->addWidget(extensionButton, 4, 2, Qt::AlignLeft);
@@ -571,11 +567,6 @@ void FileOptionsDialog::setOptionsWidget(FileOptionsDialog::ExtensionPosition po
setMinimumWidth(extensionWidget->width());
}
// Instead of resizing the dialog we can fix the layout size.
// This however, doesn't work nicely when the extension widget
// is higher/wider than the dialog.
//grid->setSizeConstraint(QLayout::SetFixedSize);
oldSize = size();
w->hide();
if (show)
@@ -912,11 +903,7 @@ SelectModule::SelectModule (const QString& type, const SelectModule::Dict& types
// connections
connect(buttonBox, &QDialogButtonBox::accepted, this, &SelectModule::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &SelectModule::reject);
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(group, qOverload<int>(&QButtonGroup::buttonClicked), this, &SelectModule::onButtonClicked);
#else
connect(group, &QButtonGroup::idClicked, this, &SelectModule::onButtonClicked);
#endif
}
SelectModule::~SelectModule() = default;
+1 -4
View File
@@ -431,10 +431,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f)
d->windowMapper = new QSignalMapper(this);
// connection between workspace, window menu and tab bar
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(d->windowMapper, qOverload<QWidget*>(&QSignalMapper::mapped),
this, &MainWindow::onSetActiveSubWindow);
#elif QT_VERSION < QT_VERSION_CHECK(6,0,0)
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
connect(d->windowMapper, &QSignalMapper::mappedWidget,
this, &MainWindow::onSetActiveSubWindow);
#else
-38
View File
@@ -205,45 +205,7 @@ void MenuManager::setup(MenuItem* menuItems) const
QMenuBar* menuBar = getMainWindow()->menuBar();
#if 0
#if defined(FC_OS_MACOSX) && QT_VERSION >= 0x050900
// Unknown Qt macOS bug observed with Qt >= 5.9.4 causes random crashes when viewing reused top level menus.
menuBar->clear();
#endif
// On Kubuntu 18.10 global menu has issues with FreeCAD 0.18 menu bar.
// Optional parameter, clearing the menu bar, can be set as a workaround.
// Clearing the menu bar can cause issues, when trying to access menu bar through Python.
// https://forum.freecad.org/viewtopic.php?f=10&t=30340&start=440#p289330
if (App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/MainWindow")->GetBool("ClearMenuBar",false)) {
menuBar->clear();
}
#else
// In addition to the reason described in the above comments, there is
// another more subtle one that's making clearing menu bar a necessity for
// all platforms.
//
// By right, it should be fine for more than one command action having the
// same shortcut but in different workbench. It should not require manual
// conflict resolving in this case, as the action in an inactive workbench
// is expected to be inactive as well, or else user may experience
// seemingly random shortcut miss firing based on the order he/she
// switches workbenches. In fact, this may be considered as an otherwise
// difficult to implement feature of context aware shortcut, where a
// specific shortcut can activate different actions under different
// workbenches.
//
// This works as expected for action adding to a toolbar. As Qt will ignore
// actions inside an invisible toolbar. However, Qt refuse to do the same
// for actions in a hidden menu action of a menu bar. This is very likely a
// Qt bug, as the behavior does not seem to conform to Qt's documentation
// of Qt::ShortcutContext.
//
// Clearing the menu bar, and recreate it every time when switching
// workbench with only the active actions can solve this problem.
menuBar->clear();
#endif
QList<QAction*> actions = menuBar->actions();
for (auto& item : menuItems->getItems())
-18
View File
@@ -1914,11 +1914,7 @@ void OverlayManager::Private::interceptEvent(QWidget *widget, QEvent *ev)
}
case QEvent::Wheel: {
auto we = static_cast<QWheelEvent*>(ev);
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
QPoint globalPos = we->globalPos();
#else
QPoint globalPos = we->globalPosition().toPoint();
#endif
lastIntercept = getChildAt(widget, globalPos);
// For some reason in case of 3D View we have to target it directly instead of targeting
@@ -1932,7 +1928,6 @@ void OverlayManager::Private::interceptEvent(QWidget *widget, QEvent *ev)
}
}
#if QT_VERSION >= QT_VERSION_CHECK(5,12,0)
QWheelEvent wheelEvent(lastIntercept->mapFromGlobal(globalPos),
globalPos,
we->pixelDelta(),
@@ -1942,19 +1937,6 @@ void OverlayManager::Private::interceptEvent(QWidget *widget, QEvent *ev)
we->phase(),
we->inverted(),
we->source());
#else
QWheelEvent wheelEvent(lastIntercept->mapFromGlobal(globalPos),
globalPos,
we->pixelDelta(),
we->angleDelta(),
0,
Qt::Vertical,
we->buttons(),
we->modifiers(),
we->phase(),
we->source(),
we->inverted());
#endif
QApplication::sendEvent(lastIntercept, &wheelEvent);
break;
}
-34
View File
@@ -1197,11 +1197,6 @@ void OverlayTabWidget::_setOverlayMode(QWidget *widget, OverlayOption option)
if(!widget)
return;
#if QT_VERSION>QT_VERSION_CHECK(5,12,2) && QT_VERSION < QT_VERSION_CHECK(5,12,6)
// Work around Qt bug https://bugreports.qt.io/browse/QTBUG-77006
widget->setStyleSheet(OverlayManager::instance()->getStyleSheet());
#endif
if (qobject_cast<QScrollBar*>(widget)) {
auto parent = widget->parentWidget();
if (parent) {
@@ -2602,14 +2597,6 @@ void OverlayGraphicsEffect::draw(QPainter* painter)
if (px.isNull())
return;
#if 0
if (FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) {
static int count;
getMainWindow()->showMessage(
QStringLiteral("dock overlay redraw %1").arg(count++));
}
#endif
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
@@ -2682,27 +2669,6 @@ void OverlayGraphicsEffect::draw(QPainter* painter)
// draw the actual pixmap...
painter->drawPixmap(offset, px, QRectF());
#if 0
QWidget *focus = qApp->focusWidget();
if (focus) {
QWidget *widget = qobject_cast<QWidget*>(this->parent());
if (auto *edit = qobject_cast<QPlainTextEdit*>(focus)) {
if (!edit->isReadOnly() && edit->isEnabled()) {
for(auto w=edit->parentWidget(); w; w=w->parentWidget()) {
if (w == widget) {
QRect r = edit->cursorRect();
QRect rect(edit->viewport()->mapTo(widget, r.topLeft()),
edit->viewport()->mapTo(widget, r.bottomRight()));
// painter->fillRect(rect, edit->textColor());
// painter->fillRect(rect, edit->currentCharFormat().foreground());
painter->fillRect(rect.translated(offset), Qt::white);
}
}
}
}
}
#endif
// restore world transform
painter->setWorldTransform(restoreTransform);
}
-5
View File
@@ -530,13 +530,8 @@ void Placement::setupSignalMapper()
signalMapper->setMapping(it, id++);
}
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(signalMapper, qOverload<int>(&QSignalMapper::mapped),
this, &Placement::onPlacementChanged);
#else
connect(signalMapper, &QSignalMapper::mappedInt,
this, &Placement::onPlacementChanged);
#endif
}
void Placement::setupRotationMethod()
@@ -76,11 +76,7 @@ DlgSettingsEditor::DlgSettingsEditor(QWidget* parent)
setupConnections();
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
ui->textEdit1->setTabStopWidth(40);
#else
ui->textEdit1->setTabStopDistance(40.0);
#endif
d = new DlgSettingsEditorP();
QColor col;
@@ -173,17 +169,10 @@ void DlgSettingsEditor::setupConnections()
this, &DlgSettingsEditor::onDisplayItemsCurrentItemChanged);
connect(ui->colorButton, &ColorButton::changed,
this, &DlgSettingsEditor::onColorButtonChanged);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
connect(ui->fontFamily, qOverload<const QString&>(&QComboBox::activated),
this, &DlgSettingsEditor::onFontFamilyActivated);
connect(ui->fontSize, qOverload<const QString&>(&PrefSpinBox::valueChanged),
this, &DlgSettingsEditor::onFontSizeValueChanged);
#else
connect(ui->fontFamily, &QComboBox::textActivated,
this, &DlgSettingsEditor::onFontFamilyActivated);
connect(ui->fontSize, &PrefSpinBox::textChanged,
this, &DlgSettingsEditor::onFontSizeValueChanged);
#endif
// clang-format on
}
@@ -213,11 +202,7 @@ void DlgSettingsEditor::setEditorTabWidth(int tabWidth)
{
QFontMetrics metric(font());
int fontSize = QtTools::horizontalAdvance(metric, QLatin1Char('0'));
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
ui->textEdit1->setTabStopWidth(tabWidth * fontSize);
#else
ui->textEdit1->setTabStopDistance(tabWidth * fontSize);
#endif
}
void DlgSettingsEditor::saveSettings()
+2 -7
View File
@@ -75,18 +75,13 @@
# ifdef HAVE_PYSIDE2
# define HAVE_PYSIDE
// Since version 5.12 shiboken offers a method to get wrapper by class name (typeForTypeName)
// This helps to avoid to include the PySide2 headers since MSVC has a compiler bug when
// compiling together with std::bitset (https://bugreports.qt.io/browse/QTBUG-72073)
// Include shiboken first to get the version
# include <shiboken.h>
// Do not use SHIBOKEN_MICRO_VERSION; it might contain a dot
# define SHIBOKEN_FULL_VERSION QT_VERSION_CHECK(SHIBOKEN_MAJOR_VERSION, SHIBOKEN_MINOR_VERSION, 0)
# if (SHIBOKEN_FULL_VERSION >= QT_VERSION_CHECK(5, 12, 0))
# define HAVE_SHIBOKEN_TYPE_FOR_TYPENAME
# endif
# define HAVE_SHIBOKEN_TYPE_FOR_TYPENAME
# ifndef HAVE_SHIBOKEN_TYPE_FOR_TYPENAME
# include <pyside2_qtcore_python.h>
-4
View File
@@ -153,12 +153,8 @@ const SoEvent *
MouseP::mouseWheelEvent(QWheelEvent * event)
{
PUBLIC(this)->setModifiers(this->wheel, event);
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
QPoint pnt = event->position().toPoint();
SbVec2s pos(pnt.x(), PUBLIC(this)->windowsize[1] - pnt.y() - 1);
#else
SbVec2s pos(event->pos().x(), PUBLIC(this)->windowsize[1] - event->pos().y() - 1);
#endif
// the following corrects for high-dpi displays (e.g. mac retina)
pos *= publ->quarter->devicePixelRatio();
this->location2->setPosition(pos); //I don't know why location2 is assigned here, I assumed it important --DeepSOIC
+1 -10
View File
@@ -154,12 +154,7 @@ public:
Q_UNUSED(shareWidget);
QSurfaceFormat surfaceFormat(format);
surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
// With the settings below we could determine deprecated OpenGL API
// but can't do this since otherwise it will complain about almost any
// OpenGL call in Coin3d
//surfaceFormat.setMajorVersion(3);
//surfaceFormat.setMinorVersion(2);
//surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
#if defined (_DEBUG) && 0
surfaceFormat.setOption(QSurfaceFormat::DebugContext);
#endif
@@ -937,11 +932,7 @@ bool QuarterWidget::viewportEvent(QEvent* event)
}
else if (event->type() == QEvent::Wheel) {
auto wheel = static_cast<QWheelEvent*>(event);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QPoint pos = wheel->pos();
#else
QPoint pos = wheel->position().toPoint();
#endif
QGraphicsItem* item = itemAt(pos);
if (!item) {
QGraphicsView::viewportEvent(event);
-4
View File
@@ -860,11 +860,7 @@ void ReportOutput::OnChange(Base::Subject<const char*> &rCaller, const char * sR
setFont(font);
QFontMetrics metric(font);
int width = QtTools::horizontalAdvance(metric, QLatin1String("0000"));
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
setTabStopWidth(width);
#else
setTabStopDistance(width);
#endif
}
else if (strcmp(sReason, "RedirectPythonOutput") == 0) {
bool checked = rclGrp.GetBool(sReason, true);
-7
View File
@@ -71,17 +71,10 @@ TaskAppearance::~TaskAppearance()
void TaskAppearance::setupConnections()
{
// clang-format off
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
connect(ui->changeMode, qOverload<const QString&>(&QComboBox::activated),
this, &TaskAppearance::onChangeModeActivated);
connect(ui->changePlot, qOverload<const QString&>(&QComboBox::activated),
this, &TaskAppearance::onChangePlotActivated);
#else
connect(ui->changeMode, &QComboBox::textActivated,
this, &TaskAppearance::onChangeModeActivated);
connect(ui->changePlot, &QComboBox::textActivated,
this, &TaskAppearance::onChangePlotActivated);
#endif
connect(ui->spinTransparency, qOverload<int>(&QSpinBox::valueChanged),
this, &TaskAppearance::onTransparencyValueChanged);
connect(ui->spinPointSize, qOverload<int>(&QSpinBox::valueChanged),
-10
View File
@@ -270,9 +270,6 @@ QSize TaskPanel::minimumSizeHint() const
TaskView::TaskView(QWidget *parent)
: QScrollArea(parent),ActiveDialog(nullptr),ActiveCtrl(nullptr)
{
//addWidget(new TaskEditControl(this));
//addWidget(new TaskAppearance(this));
//addStretch();
taskPanel = new TaskPanel(this);
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
@@ -751,18 +748,11 @@ void TaskView::addTaskWatcher()
taskPanel->addStretch();
updateWatcher();
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
// Workaround to avoid a crash in Qt. See also
// https://forum.freecad.org/viewtopic.php?f=8&t=39187
//
// Notify the button box about a style change so that it can
// safely delete the style animation of its push buttons.
auto box = taskPanel->findChild<QDialogButtonBox*>();
if (box) {
QEvent event(QEvent::StyleChange);
QApplication::sendEvent(box, &event);
}
#endif
taskPanel->setScheme(QSint::FreeCADPanelScheme::defaultScheme());
}
+1 -8
View File
@@ -37,18 +37,11 @@ namespace Gui {
class GuiExport QtTools {
public:
static int horizontalAdvance(const QFontMetrics& fm, QChar ch) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
return fm.horizontalAdvance(ch);
#else
return fm.width(ch);
#endif
}
static int horizontalAdvance(const QFontMetrics& fm, const QString& text, int len = -1) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
return fm.horizontalAdvance(text, len);
#else
return fm.width(text, len);
#endif
}
static bool matches(QKeyEvent* ke, const QKeySequence& ks) {
uint searchkey = (ke->modifiers() | ke->key()) & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier);
-5
View File
@@ -298,13 +298,8 @@ Transform::Transform(QWidget* parent, Qt::WindowFlags fl)
signalMapper->setMapping(it, id++);
}
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(signalMapper, qOverload<int>(&QSignalMapper::mapped),
this, &Transform::onTransformChanged);
#else
connect(signalMapper, &QSignalMapper::mappedInt,
this, &Transform::onTransformChanged);
#endif
setTransformStrategy(new DefaultTransformStrategy(this));
}
+1 -1
View File
@@ -74,7 +74,7 @@
# include <Inventor/nodes/SoTranslation.h>
# include <QBitmap>
# include <QEventLoop>
#if defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(6,6,0) && QT_VERSION >= QT_VERSION_CHECK(5,13,0)
#if defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(6,6,0)
# include <QGuiApplication>
# define HAS_QTBUG_95434
#endif
-4
View File
@@ -891,11 +891,7 @@ QWidget* PropertyFontItem::createEditor(QWidget* parent, const std::function<voi
auto cb = new QComboBox(parent);
cb->setFrame(false);
cb->setDisabled(isReadOnly());
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QObject::connect(cb, qOverload<const QString&>(&QComboBox::activated), method);
#else
QObject::connect(cb, &QComboBox::textActivated, method);
#endif
return cb;
}
+1 -2
View File
@@ -173,10 +173,9 @@ void TaskFemConstraint::createDeleteAction(QListWidget* parentList)
auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut();
deleteAction->setShortcut(QKeySequence(shortcut));
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
deleteAction->setShortcutVisibleInContextMenu(true);
#endif
parentList->addAction(deleteAction);
parentList->setContextMenuPolicy(Qt::ActionsContextMenu);
}
-1
View File
@@ -26,7 +26,6 @@
#endif
#include <App/Application.h>
#include <Base/QtTools.h>
#include <Base/Quantity.h>
#include <Gui/MetaTypes.h>
@@ -199,16 +199,6 @@ void DlgDisplayPropertiesImp::setupFilters()
void DlgDisplayPropertiesImp::setupConnections()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
connect(d->ui.changeMode,
qOverload<const QString&>(&QComboBox::activated),
this,
&DlgDisplayPropertiesImp::onChangeModeActivated);
connect(d->ui.changePlot,
qOverload<const QString&>(&QComboBox::activated),
this,
&DlgDisplayPropertiesImp::onChangePlotActivated);
#else
connect(d->ui.changeMode,
&QComboBox::textActivated,
this,
@@ -217,7 +207,6 @@ void DlgDisplayPropertiesImp::setupConnections()
&QComboBox::textActivated,
this,
&DlgDisplayPropertiesImp::onChangePlotActivated);
#endif
connect(d->ui.spinTransparency,
qOverload<int>(&QSpinBox::valueChanged),
this,
+1 -6
View File
@@ -134,17 +134,12 @@ QString MeasurePosition::getResultString()
QString unit = QString::fromStdString(Position.getUnit().getString());
int precision = 2;
QString text;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QTextStream(&text) << "X: " << QString::number(value.x, 'f', precision) << " " << unit << endl
<< "Y: " << QString::number(value.y, 'f', precision) << " " << unit << endl
<< "Z: " << QString::number(value.z, 'f', precision) << " " << unit;
#else
QTextStream(&text) << "X: " << QString::number(value.x, 'f', precision) << " " << unit
<< Qt::endl
<< "Y: " << QString::number(value.y, 'f', precision) << " " << unit
<< Qt::endl
<< "Z: " << QString::number(value.z, 'f', precision) << " " << unit;
#endif
return text;
}
-5
View File
@@ -53,13 +53,8 @@ DlgSmoothing::DlgSmoothing(QWidget* parent)
connect(ui->checkBoxSelection, &QCheckBox::toggled,
this, &DlgSmoothing::onCheckBoxSelectionToggled);
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(bg, qOverload<int>(&QButtonGroup::buttonClicked),
this, &DlgSmoothing::methodClicked);
#else
connect(bg, qOverload<int>(&QButtonGroup::idClicked),
this, &DlgSmoothing::methodClicked);
#endif
ui->labelLambda->setText(QString::fromUtf8("\xce\xbb"));
ui->labelMu->setText(QString::fromUtf8("\xce\xbc"));
-4
View File
@@ -215,11 +215,7 @@ bool AbstractPrimitive::hasValidPrimitive() const
void AbstractPrimitive::connectSignalMapper(QSignalMapper* mapper)
{
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(mapper, qOverload<QObject*>(&QSignalMapper::mapped), this, &AbstractPrimitive::changeValue);
#else
connect(mapper, &QSignalMapper::mappedObject, this, &AbstractPrimitive::changeValue);
#endif
}
namespace PartGui {
-5
View File
@@ -122,13 +122,8 @@ ShapeBuilderWidget::ShapeBuilderWidget(QWidget* parent)
this, &ShapeBuilderWidget::onSelectButtonClicked);
connect(d->ui.createButton, &QPushButton::clicked,
this, &ShapeBuilderWidget::onCreateButtonClicked);
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(&d->bg, qOverload<int>(&QButtonGroup::buttonClicked),
this, &ShapeBuilderWidget::switchMode);
#else
connect(&d->bg, &QButtonGroup::idClicked,
this, &ShapeBuilderWidget::switchMode);
#endif
d->gate = new ShapeSelection();
Gui::Selection().addSelectionGate(d->gate);
@@ -89,10 +89,9 @@ TaskBooleanParameters::TaskBooleanParameters(ViewProviderBoolean* BooleanView, Q
auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut();
action->setShortcut(QKeySequence(shortcut));
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
action->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetBodies->addAction(action);
connect(action, &QAction::triggered, this, &TaskBooleanParameters::onBodyDeleted);
ui->listWidgetBodies->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -292,10 +292,8 @@ void TaskDressUpParameters::createAddAllEdgesAction(QListWidget* parentList)
addAllEdgesAction = new QAction(tr("Add all edges"), this);
addAllEdgesAction->setShortcut(QKeySequence(QStringLiteral("Ctrl+Shift+A")));
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
addAllEdgesAction->setShortcutVisibleInContextMenu(true);
#endif
parentList->addAction(addAllEdgesAction);
addAllEdgesAction->setStatusTip(tr("Adds all edges to the list box (active only when in add selection mode)."));
parentList->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -311,10 +309,8 @@ void TaskDressUpParameters::createDeleteAction(QListWidget* parentList)
auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut();
deleteAction->setShortcut(QKeySequence(shortcut));
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
deleteAction->setShortcutVisibleInContextMenu(true);
#endif
parentList->addAction(deleteAction);
parentList->setContextMenuPolicy(Qt::ActionsContextMenu);
}
@@ -179,10 +179,8 @@ void TaskExtrudeParameters::setupDialog()
auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut();
unselectShapeFaceAction->setShortcut(QKeySequence(shortcut));
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
unselectShapeFaceAction->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(unselectShapeFaceAction);
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -77,10 +77,8 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft* LoftView, bool /*newObj
auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut();
remove->setShortcut(QKeySequence(shortcut));
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
remove->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(remove);
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(remove, &QAction::triggered, this, &TaskLoftParameters::onDeleteSection);
@@ -92,10 +92,11 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe* PipeView, bool /*newObj
remove->setShortcut(QKeySequence(shortcut));
}
remove->setShortcutContext(Qt::WidgetShortcut);
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
remove->setShortcutVisibleInContextMenu(true);
#endif
remove->setShortcutVisibleInContextMenu(true);
ui->listWidgetReferences->addAction(remove);
connect(remove, &QAction::triggered, this, &TaskPipeParameters::onDeleteEdge);
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -615,10 +616,10 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView,
remove->setShortcut(QKeySequence(shortcut));
}
remove->setShortcutContext(Qt::WidgetShortcut);
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
remove->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(remove);
connect(remove, &QAction::triggered, this, &TaskPipeOrientation::onDeleteItem);
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -908,10 +909,10 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW
remove->setShortcut(QKeySequence(shortcut));
}
remove->setShortcutContext(Qt::WidgetShortcut);
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
remove->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(remove);
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(remove, &QAction::triggered, this, &TaskPipeScaling::onDeleteSection);
@@ -134,10 +134,8 @@ void TaskShapeBinder::setupContextMenu()
remove->setShortcut(QKeySequence(shortcut));
}
remove->setShortcutContext(Qt::WidgetShortcut);
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
// display shortcut behind the context menu entry
remove->setShortcutVisibleInContextMenu(true);
#endif
ui->listWidgetReferences->addAction(remove);
connect(remove, &QAction::triggered, this, &TaskShapeBinder::deleteItem);
ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -131,11 +131,7 @@ void TaskTransformedParameters::setupUI()
ui->buttonGroupMode->setId(ui->radioTransformToolShapes, static_cast<int>(Mode::TransformToolShapes));
connect(ui->buttonGroupMode,
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
qOverload<int>(&QButtonGroup::buttonClicked),
#else
&QButtonGroup::idClicked,
#endif
this,
&TaskTransformedParameters::onModeChanged);
-13
View File
@@ -57,9 +57,6 @@ using DU = DrawUtil;
LineGenerator::LineGenerator()
{
reloadDescriptions();
// m_elementDefs = loadElements();
// m_lineDefs = getLineDefinitions();
// m_lineDescs = getLineDescriptions();
}
void LineGenerator::reloadDescriptions()
@@ -73,8 +70,6 @@ void LineGenerator::reloadDescriptions()
//! we prefer to use the ISO Line Number if available.
QPen LineGenerator::getBestPen(size_t isoNumber, Qt::PenStyle qtStyle, double width)
{
// Base::Console().Message("DLG::getBestPen((%d, %d, %.3f)\n",
// isoNumber, qtStyle, width);
// TODO: use TechDraw::LineFormat::InvalidLine here
if (isoNumber > 0 &&
isoNumber < m_lineDefs.size()) {
@@ -160,11 +155,7 @@ QPen LineGenerator::getLinePen(size_t lineNumber, double nominalLineWidth)
dashPattern.push_back(static_cast< double >(m_elementDefs[entry]) / proportionalAdjust);
}
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QVector<double> qDashPattern = QVector<double>::fromStdVector(dashPattern);
#else
QVector<double> qDashPattern(dashPattern.begin(), dashPattern.end());
#endif
linePen.setDashPattern(qDashPattern);
linePen.setWidthF(nominalLineWidth);
@@ -175,8 +166,6 @@ QPen LineGenerator::getLinePen(size_t lineNumber, double nominalLineWidth)
//! convert Qt line style to closest ISO line number
int LineGenerator::fromQtStyle(Qt::PenStyle style)
{
// Base::Console().Message("DLG::fromQtStyle(%d)\n", style);
// the 4 standard Qt::PenStyles and ISO128 equivalents
int dashed = 2;
int dotted = 7;
@@ -221,7 +210,6 @@ int LineGenerator::fromQtStyle(Qt::PenStyle style)
//! ANSI Y14.2 standards file
std::map<std::string, int> LineGenerator::loadElements()
{
// Base::Console().Message("DLG::loadElements()\n");
std::map<std::string, int> result;
// open file, for each record, parse element name and length, then insert into
// the output map.
@@ -252,7 +240,6 @@ std::map<std::string, int> LineGenerator::loadElements()
//! load the line definition file into memory
std::vector< std::vector<std::string> > LineGenerator::getLineDefinitions()
{
// Base::Console().Message("DLG::loadLineDefinitions()\n");
std::vector< std::vector<std::string> > lineDefs;
std::string record;
Base::FileInfo fi(Preferences::currentLineDefFile());
-10
View File
@@ -199,7 +199,6 @@ void QGSPage::addChildrenToPage()
matchSceneRectToTemplate();
}
// viewAll();
}
//********** template related routines *********
@@ -251,7 +250,6 @@ QPointF QGSPage::getTemplateCenter()
void QGSPage::matchSceneRectToTemplate()
{
// Base::Console().Message("QGSP::matchSceneRectToTemplate()\n");
App::DocumentObject* obj = m_vpPage->getDrawPage()->Template.getValue();
auto pageTemplate(dynamic_cast<TechDraw::DrawTemplate*>(obj));
if (pageTemplate) {
@@ -264,7 +262,6 @@ void QGSPage::matchSceneRectToTemplate()
void QGSPage::setPageTemplate(TechDraw::DrawTemplate* templateFeat)
{
// Base::Console().Message("QGSP::setPageTemplate()\n");
removeTemplate();
if (templateFeat->isDerivedFrom<TechDraw::DrawParametricTemplate>()) {
@@ -869,7 +866,6 @@ bool QGSPage::hasQView(App::DocumentObject* obj)
void QGSPage::refreshViews()
{
// Base::Console().Message("QGSP::refreshViews()\n");
QList<QGraphicsItem*> list = items();
QList<QGraphicsItem*> qgiv;
//find only QGIV's
@@ -1197,16 +1193,10 @@ void QGSPage::postProcessXml(QTemporaryFile& temporaryFile, QString fileName, QS
QStringLiteral("stroke: none;"));
// Scale the template group correctly
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
templateGroup.setAttribute(
QStringLiteral("transform"),
QString().sprintf("scale(%f, %f)", Rez::guiX(1.0), Rez::guiX(1.0)));
#else
templateGroup.setAttribute(QStringLiteral("transform"),
QStringLiteral("scale(%1, %2)")
.arg(Rez::guiX(1.0), 0, 'f')
.arg(Rez::guiX(1.0), 0, 'f'));
#endif
// Finally, transfer all template document child nodes under the template group
while (!templateDocElem.firstChild().isNull()) {
+1 -8
View File
@@ -233,7 +233,6 @@ void QGVPage::initNavigationStyle()
void QGVPage::setNavigationStyle(std::string navParm)
{
// Base::Console().Message("QGVP::setNavigationStyle(%s)\n", navParm.c_str());
if (m_navStyle) {
delete m_navStyle;
}
@@ -309,15 +308,10 @@ void QGVPage::deactivateHandler()
void QGVPage::startBalloonPlacing(DrawView* parent)
{
// Base::Console().Message("QGVP::startBalloonPlacing(%s)\n", parent->getNameInDocument());
balloonPlacing = true;
m_balloonParent = parent;
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
activateCursor(
QCursor(balloonCursor->pixmap(Qt::ReturnByValue), balloonHotspot.x(), balloonHotspot.y()));
#else
activateCursor(QCursor(*balloonCursor->pixmap(), balloonHotspot.x(), balloonHotspot.y()));
#endif
}
void QGVPage::cancelBalloonPlacing()
@@ -339,7 +333,6 @@ void QGVPage::drawBackground(QPainter* painter, const QRectF&)
}
if (!m_vpPage->getDrawPage()) {
// Base::Console().Message("QGVP::drawBackground - no Page Feature!\n");
return;
}
@@ -697,7 +690,7 @@ static QCursor createCursor(QBitmap &bitmap, QBitmap &mask, int hotX, int hotY,
#else
Q_UNUSED(dpr)
#endif
#if defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(6,6,0) && QT_VERSION >= QT_VERSION_CHECK(5,13,0)
#if defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(6,6,0)
if (qGuiApp->platformName() == QLatin1String("wayland")) {
QImage img = bitmap.toImage();
img.convertTo(QImage::Format_ARGB32);
-6
View File
@@ -158,11 +158,7 @@ void TaskCenterLine::setUiConnect()
connect(ui->qsbHorizShift, qOverload<double>(&QuantitySpinBox::valueChanged), this, &TaskCenterLine::onShiftHorizChanged);
connect(ui->qsbExtend, qOverload<double>(&QuantitySpinBox::valueChanged), this, &TaskCenterLine::onExtendChanged);
connect(ui->qsbRotate, qOverload<double>(&QuantitySpinBox::valueChanged), this, &TaskCenterLine::onRotationChanged);
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(ui->bgOrientation, qOverload<int>(&QButtonGroup::buttonClicked), this, &TaskCenterLine::onOrientationChanged);
#else
connect(ui->bgOrientation, &QButtonGroup::idClicked, this, &TaskCenterLine::onOrientationChanged);
#endif
}
void TaskCenterLine::setUiPrimary()
@@ -449,7 +445,6 @@ void TaskCenterLine::createCenterLine()
void TaskCenterLine::updateOrientation()
{
// Base::Console().Message("TCL::updateOrientation()\n");
if (!m_cl) {
return;
}
@@ -613,7 +608,6 @@ TaskDlgCenterLine::~TaskDlgCenterLine()
void TaskDlgCenterLine::update()
{
// widget->updateTask();
}
void TaskDlgCenterLine::modifyStandardButtons(QDialogButtonBox* box)
-4
View File
@@ -112,13 +112,9 @@ void TaskProjGroup::connectWidgets()
connect(ui->sbScaleDen, qOverload<int>(&QSpinBox::valueChanged), this, &TaskProjGroup::scaleManuallyChanged);
// Slot for Projection Type (layout)
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(ui->projection, qOverload<const QString&>(&QComboBox::currentIndexChanged), this, &TaskProjGroup::projectionTypeChanged);
#else
connect(ui->projection, qOverload<int>(&QComboBox::currentIndexChanged), this, [this](int index) {
projectionTypeChanged(ui->projection->itemText(index));
});
#endif
// Spacing
connect(ui->cbAutoDistribute, &QPushButton::clicked, this, &TaskProjGroup::AutoDistributeClicked);
+1 -36
View File
@@ -63,12 +63,7 @@ using namespace TechDraw;
MRichTextEdit::MRichTextEdit(QWidget *parent, QString textIn) : QWidget(parent) {
setupUi(this);
m_lastBlockList = nullptr;
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
f_textedit->setTabStopWidth(40);
#else
f_textedit->setTabStopDistance(40);
#endif
// setDefFontSize(getDefFontSizeNum());
setDefFontSize(TechDrawGui::PreferencesGui::labelFontSizePX());
m_defFont = getDefFont().family();
f_textedit->setFont(getDefFont());
@@ -204,15 +199,10 @@ MRichTextEdit::MRichTextEdit(QWidget *parent, QString textIn) : QWidget(parent)
for(int size: sizes) {
f_fontsize->addItem(QString::number(size));
}
//TODO: void QComboBox::setEditText(const QString &text) to " " when multiple select
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(f_fontsize, qOverload<const QString&>(&QComboBox::currentIndexChanged),
this, &MRichTextEdit::textSize);
#else
connect(f_fontsize, qOverload<int>(&QComboBox::currentIndexChanged), this, [this](int index) {
textSize(f_fontsize->itemText(index));
});
#endif
// text foreground color
@@ -282,9 +272,6 @@ void MRichTextEdit::textRemoveFormat() {
fmt.setFontStrikeOut (false);
fmt.setFontItalic (false);
fmt.setFontPointSize (m_defFontSize);
// fmt.setFontFamily ("Helvetica");
// fmt.setFontStyleHint (QFont::SansSerif);
// fmt.setFontFixedPitch (true);
f_bold ->setChecked(false);
f_underline ->setChecked(false);
@@ -292,9 +279,6 @@ void MRichTextEdit::textRemoveFormat() {
f_strikeout ->setChecked(false);
f_fontsize ->setCurrentIndex(f_fontsize->findText(getDefFontSize()));
// QTextBlockFormat bfmt = cursor.blockFormat();
// bfmt->setIndent(0);
fmt.clearBackground();
mergeFormatOnWordOrSelection(fmt);
@@ -428,11 +412,7 @@ void MRichTextEdit::textStyle(int index) {
}
if (index == ParagraphMonospace) {
fmt = cursor.charFormat();
#if QT_VERSION < QT_VERSION_CHECK(5,13,0)
fmt.setFontFamily(QString::fromUtf8("Monospace"));
#else
fmt.setFontFamilies(QStringList() << QString::fromUtf8("Monospace"));
#endif
fmt.setFontStyleHint(QFont::Monospace);
fmt.setFontFixedPitch(true);
}
@@ -530,7 +510,6 @@ void MRichTextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
}
void MRichTextEdit::slotCursorPositionChanged() {
// qDebug() << "MRTE::slotCursorPositionChanged()";
//why do we change text style when selecting text?
QTextCursor cursor = f_textedit->textCursor();
if (cursor.hasSelection()) { //let selection logic handle this
@@ -569,7 +548,6 @@ void MRichTextEdit::slotCursorPositionChanged() {
}
void MRichTextEdit::fontChanged(const QFont &font) {
// qDebug() << "MRTE::fontChanged()";
//TODO: change this to real font selector
f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(font.pointSize())));
f_bold->setChecked(font.bold());
@@ -634,14 +612,7 @@ void MRichTextEdit::bgColorChanged(const QColor &color) {
}
void MRichTextEdit::slotCurrentCharFormatChanged(const QTextCharFormat &format) {
// qDebug() << "MRTE::slotCurrentCharFormatChanged()";
Q_UNUSED(format);
//again, why do we do all this just because the cursor moved?
//can it be this simple???
// fontChanged(format.font());
// bgColorChanged((format.background().isOpaque()) ? format.background().color() : QColor());
// fgColorChanged((format.foreground().isOpaque()) ? format.foreground().color() : QColor());
// f_link->setChecked(format.isAnchor());
}
void MRichTextEdit::slotClipboardDataChanged() {
@@ -723,7 +694,6 @@ void MRichTextEdit::onExit()
void MRichTextEdit::onSelectionChanged()
{
// qDebug() << "MRTE::onSelectionChanged()";
if (hasMultipleSizes()) {
f_fontsize->setEditText(QString());
f_fontsize->setCurrentIndex(-1);
@@ -739,7 +709,6 @@ void MRichTextEdit::onSelectionChanged()
//does selection have multiple sizes?
bool MRichTextEdit::hasMultipleSizes()
{
// qDebug() << "MRTE::hasMultipleSizes()";
QTextCursor cursor = f_textedit->textCursor();
if (cursor.hasSelection()) {
int begin = cursor.selectionStart();
@@ -767,7 +736,6 @@ bool MRichTextEdit::hasMultipleSizes()
void MRichTextEdit::setDefFontSize(int fontSize)
{
// Base::Console().Message("MRTE::setDefFontSize(%d)\n", fs);
m_defFontSize = fontSize;
m_fontsize_h1 = fontSize + 8;
m_fontsize_h2 = fontSize + 6;
@@ -787,7 +755,6 @@ void MRichTextEdit::setDefFontSize(int fontSize)
int MRichTextEdit::getDefFontSizeNum()
{
// Base::Console().Message("MRTE::getDefFontSizeNum()\n");
double fontSize = TechDraw::Preferences::dimFontSizeMM();
//this conversion is only approximate. the factor changes for different fonts.
@@ -799,7 +766,6 @@ int MRichTextEdit::getDefFontSizeNum()
QString MRichTextEdit::getDefFontSize()
{
// Base::Console().Message("MRTE::getDefFontSize()\n");
return QString::number(getDefFontSizeNum());
}
@@ -823,7 +789,6 @@ QFont MRichTextEdit::getDefFont()
// if the conversion factor is float, will generate non-standard sizes
void MRichTextEdit::addFontSize(QString fontSize)
{
// Base::Console().Message("MRTE::addFontSize(%s)\n", qPrintable(fs));
QStringList newList;
int fsVal = fontSize.toInt();
int size = f_fontsize->count();