Gui: replace slots with member function pointers

This commit is contained in:
wmayer
2023-02-01 16:16:05 +01:00
committed by Uwe
parent 1e03fddb67
commit 76860143f7
16 changed files with 79 additions and 70 deletions

View File

@@ -317,7 +317,7 @@ void CoinRiftWidget::initializeGL()
void CoinRiftWidget::paintGL()
{
const int ms(1000 / 75 /*fps*/);
QTimer::singleShot(ms, this, SLOT(updateGL()));
QTimer::singleShot(ms, this, &CoinRiftWidget::updateGL);
// handling the safety warning
handlingSafetyWarning();
@@ -504,4 +504,4 @@ int main(int argc, char *argv[])
#endif //BUILD_RIFT_TEST_MAIN
#endif //BUILD_VR
#endif //BUILD_VR

View File

@@ -1109,7 +1109,7 @@ void Model::onRenameSlot()
proxy->setGeometry(text->sceneBoundingRect());
lineEdit->selectAll();
QTimer::singleShot(0, lineEdit, SLOT(setFocus()));
QTimer::singleShot(0, lineEdit, qOverload<>(&QLineEdit::setFocus));
}
void Model::renameAcceptedSlot()

View File

@@ -452,14 +452,14 @@ ParameterGroup::ParameterGroup( QWidget * parent )
: QTreeWidget(parent)
{
menuEdit = new QMenu(this);
expandAct = menuEdit->addAction(tr("Expand"), this, SLOT(onToggleSelectedItem()));
expandAct = menuEdit->addAction(tr("Expand"), this, &ParameterGroup::onToggleSelectedItem);
menuEdit->addSeparator();
subGrpAct = menuEdit->addAction(tr("Add sub-group"), this, SLOT(onCreateSubgroup()));
removeAct = menuEdit->addAction(tr("Remove group"), this, SLOT(onDeleteSelectedItem()));
renameAct = menuEdit->addAction(tr("Rename group"), this, SLOT(onRenameSelectedItem()));
subGrpAct = menuEdit->addAction(tr("Add sub-group"), this, &ParameterGroup::onCreateSubgroup);
removeAct = menuEdit->addAction(tr("Remove group"), this, &ParameterGroup::onDeleteSelectedItem);
renameAct = menuEdit->addAction(tr("Rename group"), this, &ParameterGroup::onRenameSelectedItem);
menuEdit->addSeparator();
exportAct = menuEdit->addAction(tr("Export parameter"), this, SLOT(onExportToFile()));
importAct = menuEdit->addAction(tr("Import parameter"), this, SLOT(onImportFromFile()));
exportAct = menuEdit->addAction(tr("Export parameter"), this, &ParameterGroup::onExportToFile);
importAct = menuEdit->addAction(tr("Import parameter"), this, &ParameterGroup::onImportFromFile);
menuEdit->setDefaultAction(expandAct);
}
@@ -646,19 +646,19 @@ ParameterValue::ParameterValue( QWidget * parent )
: QTreeWidget(parent)
{
menuEdit = new QMenu(this);
changeAct = menuEdit->addAction(tr("Change value"), this, SLOT(onChangeSelectedItem()));
changeAct = menuEdit->addAction(tr("Change value"), this, qOverload<>(&ParameterValue::onChangeSelectedItem));
menuEdit->addSeparator();
removeAct = menuEdit->addAction(tr("Remove key"), this, SLOT(onDeleteSelectedItem()));
renameAct = menuEdit->addAction(tr("Rename key"), this, SLOT(onRenameSelectedItem()));
removeAct = menuEdit->addAction(tr("Remove key"), this, &ParameterValue::onDeleteSelectedItem);
renameAct = menuEdit->addAction(tr("Rename key"), this, &ParameterValue::onRenameSelectedItem);
menuEdit->setDefaultAction(changeAct);
menuEdit->addSeparator();
menuNew = menuEdit->addMenu(tr("New"));
newStrAct = menuNew->addAction(tr("New string item"), this, SLOT(onCreateTextItem()));
newFltAct = menuNew->addAction(tr("New float item"), this, SLOT(onCreateFloatItem()));
newIntAct = menuNew->addAction(tr("New integer item"), this, SLOT(onCreateIntItem()));
newUlgAct = menuNew->addAction(tr("New unsigned item"), this, SLOT(onCreateUIntItem()));
newBlnAct = menuNew->addAction(tr("New Boolean item"), this, SLOT(onCreateBoolItem()));
newStrAct = menuNew->addAction(tr("New string item"), this, &ParameterValue::onCreateTextItem);
newFltAct = menuNew->addAction(tr("New float item"), this, &ParameterValue::onCreateFloatItem);
newIntAct = menuNew->addAction(tr("New integer item"), this, &ParameterValue::onCreateIntItem);
newUlgAct = menuNew->addAction(tr("New unsigned item"), this, &ParameterValue::onCreateUIntItem);
newBlnAct = menuNew->addAction(tr("New Boolean item"), this, &ParameterValue::onCreateBoolItem);
connect(this, &ParameterValue::itemDoubleClicked,
this, qOverload<QTreeWidgetItem*, int>(&ParameterValue::onChangeSelectedItem));

View File

@@ -66,8 +66,9 @@ void UndoDialog::onFetchInfo()
MDIView* mdi = getMainWindow()->activeWindow();
if (mdi) {
QStringList vecUndos = mdi->undoActions();
for (QStringList::Iterator i = vecUndos.begin(); i != vecUndos.end(); ++i)
addAction(*i, this, SLOT(onSelected()));
for (QStringList::Iterator i = vecUndos.begin(); i != vecUndos.end(); ++i) {
addAction(*i, this, &UndoDialog::onSelected);
}
}
}
@@ -114,8 +115,9 @@ void RedoDialog::onFetchInfo()
MDIView* mdi = getMainWindow()->activeWindow();
if (mdi) {
QStringList vecRedos = mdi->redoActions();
for (QStringList::Iterator i = vecRedos.begin(); i != vecRedos.end(); ++i)
addAction(*i, this, SLOT(onSelected()));
for (QStringList::Iterator i = vecRedos.begin(); i != vecRedos.end(); ++i) {
addAction(*i, this, &RedoDialog::onSelected);
}
}
}

View File

@@ -498,7 +498,7 @@ void DocumentRecovery::contextMenuEvent(QContextMenuEvent* ev)
QList<QTreeWidgetItem*> items = d_ptr->ui.treeWidget->selectedItems();
if (!items.isEmpty()) {
QMenu menu;
menu.addAction(tr("Delete"), this, SLOT(onDeleteSection()));
menu.addAction(tr("Delete"), this, &DocumentRecovery::onDeleteSection);
menu.exec(ev->globalPos());
}
}

View File

@@ -412,7 +412,7 @@ void DownloadItem::tryAgain()
void DownloadItem::contextMenuEvent (QContextMenuEvent * e)
{
QMenu menu;
QAction* a = menu.addAction(tr("Open containing folder"), this, SLOT(openFolder()));
QAction* a = menu.addAction(tr("Open containing folder"), this, &DownloadItem::openFolder);
a->setEnabled(m_output.exists());
menu.exec(e->globalPos());
}

View File

@@ -610,7 +610,7 @@ bool PythonEditorView::onMsg(const char* pMsg,const char** ppReturn)
return true;
}
else if (strcmp(pMsg,"StartDebug")==0) {
QTimer::singleShot(300, this, SLOT(startDebug()));
QTimer::singleShot(300, this, &PythonEditorView::startDebug);
return true;
}
else if (strcmp(pMsg,"ToggleBreakpoint")==0) {

View File

@@ -1273,21 +1273,21 @@ void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n)
QAction* id = menu.exec(QCursor::pos());
if (id == fi) {
// call align->align();
QTimer::singleShot(300, self, SLOT(onAlign()));
QTimer::singleShot(300, self, &ManualAlignment::onAlign);
}
else if ((id == rem) && (view == self->myViewer->getViewer(0))) {
QTimer::singleShot(300, self, SLOT(onRemoveLastPointMoveable()));
QTimer::singleShot(300, self, &ManualAlignment::onRemoveLastPointMoveable);
}
else if ((id == rem) && (view == self->myViewer->getViewer(1))) {
QTimer::singleShot(300, self, SLOT(onRemoveLastPointFixed()));
QTimer::singleShot(300, self, &ManualAlignment::onRemoveLastPointFixed);
}
//else if (id == cl) {
// // call align->clear();
// QTimer::singleShot(300, self, SLOT(onClear()));
// QTimer::singleShot(300, self, &ManualAlignment::onClear);
//}
else if (id == ca) {
// call align->cancel();
QTimer::singleShot(300, self, SLOT(onCancel()));
QTimer::singleShot(300, self, &ManualAlignment::onCancel);
}
else if (id == sync) {
// setup sensor connection

View File

@@ -351,7 +351,7 @@ void NetworkRetriever::abort()
{
if ( wget->state() == QProcess::Running)
{
QTimer::singleShot( 2000, wget, SLOT( kill() ) );
QTimer::singleShot( 2000, wget, &QProcess::kill);
}
}

View File

@@ -1311,16 +1311,16 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e )
QAction *a;
bool mayPasteHere = cursorBeyond( this->textCursor(), this->inputBegin() );
a = menu.addAction(tr("&Copy"), this, SLOT(copy()), QKeySequence(QString::fromLatin1("CTRL+C")));
a = menu.addAction(tr("&Copy"), this, &PythonConsole::copy, QKeySequence(QString::fromLatin1("CTRL+C")));
a->setEnabled(textCursor().hasSelection());
a = menu.addAction(tr("&Copy command"), this, SLOT(onCopyCommand()));
a = menu.addAction(tr("&Copy command"), this, &PythonConsole::onCopyCommand);
a->setEnabled(textCursor().hasSelection());
a = menu.addAction(tr("&Copy history"), this, SLOT(onCopyHistory()));
a = menu.addAction(tr("&Copy history"), this, &PythonConsole::onCopyHistory);
a->setEnabled(!d->history.isEmpty());
a = menu.addAction( tr("Save history as..."), this, SLOT(onSaveHistoryAs()));
a = menu.addAction( tr("Save history as..."), this, &PythonConsole::onSaveHistoryAs);
a->setEnabled(!d->history.isEmpty());
QAction* saveh = menu.addAction(tr("Save history"));
@@ -1330,18 +1330,18 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e )
menu.addSeparator();
a = menu.addAction(tr("&Paste"), this, SLOT(paste()), QKeySequence(QString::fromLatin1("CTRL+V")));
a = menu.addAction(tr("&Paste"), this, &PythonConsole::paste, QKeySequence(QString::fromLatin1("CTRL+V")));
const QMimeData *md = QApplication::clipboard()->mimeData();
a->setEnabled( mayPasteHere && md && canInsertFromMimeData(md));
a = menu.addAction(tr("Select All"), this, SLOT(selectAll()), QKeySequence(QString::fromLatin1("CTRL+A")));
a = menu.addAction(tr("Select All"), this, &PythonConsole::selectAll, QKeySequence(QString::fromLatin1("CTRL+A")));
a->setEnabled(!document()->isEmpty());
a = menu.addAction(tr("Clear console"), this, SLOT(onClearConsole()));
a = menu.addAction(tr("Clear console"), this, &PythonConsole::onClearConsole);
a->setEnabled(!document()->isEmpty());
menu.addSeparator();
menu.addAction( tr("Insert file name..."), this, SLOT(onInsertFileName()));
menu.addAction( tr("Insert file name..."), this, &PythonConsole::onInsertFileName);
menu.addSeparator();
QAction* wrap = menu.addAction(tr("Word wrap"));

View File

@@ -150,8 +150,8 @@ void PythonEditor::contextMenuEvent ( QContextMenuEvent * e )
QMenu* menu = createStandardContextMenu();
if (!isReadOnly()) {
menu->addSeparator();
menu->addAction( tr("Comment"), this, SLOT( onComment() ), QKeySequence(QString::fromLatin1("ALT+C")));
menu->addAction( tr("Uncomment"), this, SLOT( onUncomment() ), QKeySequence(QString::fromLatin1("ALT+U")));
menu->addAction( tr("Comment"), this, &PythonEditor::onComment, QKeySequence(QString::fromLatin1("ALT+C")));
menu->addAction( tr("Uncomment"), this, &PythonEditor::onUncomment, QKeySequence(QString::fromLatin1("ALT+U")));
}
menu->exec(e->globalPos());

View File

@@ -122,7 +122,7 @@ void ActionGroup::showHide()
myDummy->setFixedSize(myGroup->size());
myDummy->show();
QTimer::singleShot(myScheme->groupFoldDelay, this, SLOT(processHide()));
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processHide);
}
else
{
@@ -130,7 +130,7 @@ void ActionGroup::showHide()
m_foldDirection = 1;
m_tempHeight = 0;
QTimer::singleShot(myScheme->groupFoldDelay, this, SLOT(processShow()));
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processShow);
}
myDummy->show();
@@ -153,7 +153,7 @@ void ActionGroup::processHide()
myDummy->setFixedHeight(m_tempHeight);
setFixedHeight(myDummy->height()+myHeader->height());
QTimer::singleShot(myScheme->groupFoldDelay, this, SLOT(processHide()));
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processHide);
setUpdatesEnabled(true);
}
@@ -178,7 +178,7 @@ void ActionGroup::processShow()
myDummy->setFixedHeight(m_tempHeight);
setFixedHeight(myDummy->height()+myHeader->height());
QTimer::singleShot(myScheme->groupFoldDelay, this, SLOT(processShow()));
QTimer::singleShot(myScheme->groupFoldDelay, this, &ActionGroup::processShow);
setUpdatesEnabled(true);
}

View File

@@ -164,7 +164,7 @@ void TaskHeader::animate()
m_opacity = qMax(0.1, m_opacity-0.05);
}
QTimer::singleShot(100, this, SLOT(animate()));
QTimer::singleShot(100, this, &TaskHeader::animate);
update();
}
@@ -177,7 +177,7 @@ void TaskHeader::enterEvent ( QEnterEvent * /*event*/ )
m_over = true;
if (isEnabled())
QTimer::singleShot(100, this, SLOT(animate()));
QTimer::singleShot(100, this, &TaskHeader::animate);
update();
}
@@ -187,7 +187,7 @@ void TaskHeader::leaveEvent ( QEvent * /*event*/ )
m_over = false;
if (isEnabled())
QTimer::singleShot(100, this, SLOT(animate()));
QTimer::singleShot(100, this, &TaskHeader::animate);
update();
}

View File

@@ -554,19 +554,19 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e )
displayMenu->setTitle(tr("Display message types"));
optionMenu->addMenu(displayMenu);
QAction* logMsg = displayMenu->addAction(tr("Normal messages"), this, SLOT(onToggleNormalMessage()));
QAction* logMsg = displayMenu->addAction(tr("Normal messages"), this, &ReportOutput::onToggleNormalMessage);
logMsg->setCheckable(true);
logMsg->setChecked(bMsg);
QAction* logAct = displayMenu->addAction(tr("Log messages"), this, SLOT(onToggleLogMessage()));
QAction* logAct = displayMenu->addAction(tr("Log messages"), this, &ReportOutput::onToggleLogMessage);
logAct->setCheckable(true);
logAct->setChecked(bLog);
QAction* wrnAct = displayMenu->addAction(tr("Warnings"), this, SLOT(onToggleWarning()));
QAction* wrnAct = displayMenu->addAction(tr("Warnings"), this, &ReportOutput::onToggleWarning);
wrnAct->setCheckable(true);
wrnAct->setChecked(bWrn);
QAction* errAct = displayMenu->addAction(tr("Errors"), this, SLOT(onToggleError()));
QAction* errAct = displayMenu->addAction(tr("Errors"), this, &ReportOutput::onToggleError);
errAct->setCheckable(true);
errAct->setChecked(bErr);
@@ -574,41 +574,41 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e )
showOnMenu->setTitle(tr("Show Report view on"));
optionMenu->addMenu(showOnMenu);
QAction* showNormAct = showOnMenu->addAction(tr("Normal messages"), this, SLOT(onToggleShowReportViewOnNormalMessage()));
QAction* showNormAct = showOnMenu->addAction(tr("Normal messages"), this, &ReportOutput::onToggleShowReportViewOnNormalMessage);
showNormAct->setCheckable(true);
showNormAct->setChecked(bShowOnNormal);
QAction* showLogAct = showOnMenu->addAction(tr("Log messages"), this, SLOT(onToggleShowReportViewOnLogMessage()));
QAction* showLogAct = showOnMenu->addAction(tr("Log messages"), this, &ReportOutput::onToggleShowReportViewOnLogMessage);
showLogAct->setCheckable(true);
showLogAct->setChecked(bShowOnLog);
QAction* showWrnAct = showOnMenu->addAction(tr("Warnings"), this, SLOT(onToggleShowReportViewOnWarning()));
QAction* showWrnAct = showOnMenu->addAction(tr("Warnings"), this, &ReportOutput::onToggleShowReportViewOnWarning);
showWrnAct->setCheckable(true);
showWrnAct->setChecked(bShowOnWarn);
QAction* showErrAct = showOnMenu->addAction(tr("Errors"), this, SLOT(onToggleShowReportViewOnError()));
QAction* showErrAct = showOnMenu->addAction(tr("Errors"), this, &ReportOutput::onToggleShowReportViewOnError);
showErrAct->setCheckable(true);
showErrAct->setChecked(bShowOnError);
optionMenu->addSeparator();
QAction* stdoutAct = optionMenu->addAction(tr("Redirect Python output"), this, SLOT(onToggleRedirectPythonStdout()));
QAction* stdoutAct = optionMenu->addAction(tr("Redirect Python output"), this, &ReportOutput::onToggleRedirectPythonStdout);
stdoutAct->setCheckable(true);
stdoutAct->setChecked(d->redirected_stdout);
QAction* stderrAct = optionMenu->addAction(tr("Redirect Python errors"), this, SLOT(onToggleRedirectPythonStderr()));
QAction* stderrAct = optionMenu->addAction(tr("Redirect Python errors"), this, &ReportOutput::onToggleRedirectPythonStderr);
stderrAct->setCheckable(true);
stderrAct->setChecked(d->redirected_stderr);
optionMenu->addSeparator();
QAction* botAct = optionMenu->addAction(tr("Go to end"), this, SLOT(onToggleGoToEnd()));
QAction* botAct = optionMenu->addAction(tr("Go to end"), this, &ReportOutput::onToggleGoToEnd);
botAct->setCheckable(true);
botAct->setChecked(gotoEnd);
// Use Qt's internal translation of the Copy & Select All commands
const char* context = "QWidgetTextControl";
QString copyStr = QCoreApplication::translate(context, "&Copy");
QAction* copy = menu->addAction(copyStr, this, SLOT(copy()), QKeySequence(QKeySequence::Copy));
QAction* copy = menu->addAction(copyStr, this, &ReportOutput::copy, QKeySequence(QKeySequence::Copy));
copy->setEnabled(textCursor().hasSelection());
QIcon icon = QIcon::fromTheme(QString::fromLatin1("edit-copy"));
if (!icon.isNull())
@@ -616,11 +616,11 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e )
menu->addSeparator();
QString selectStr = QCoreApplication::translate(context, "Select All");
menu->addAction(selectStr, this, SLOT(selectAll()), QKeySequence(QKeySequence::SelectAll));
menu->addAction(selectStr, this, &ReportOutput::selectAll, QKeySequence(QKeySequence::SelectAll));
menu->addAction(tr("Clear"), this, SLOT(clear()));
menu->addAction(tr("Clear"), this, &ReportOutput::clear);
menu->addSeparator();
menu->addAction(tr("Save As..."), this, SLOT(onSaveAs()));
menu->addAction(tr("Save As..."), this, &ReportOutput::onSaveAs);
menu->exec(e->globalPos());
delete menu;

View File

@@ -586,28 +586,35 @@ void SelectionView::onItemContextMenu(const QPoint& point)
if (!item)
return;
QMenu menu;
QAction *selectAction = menu.addAction(tr("Select only"),this,SLOT(select()));
QAction *selectAction = menu.addAction(tr("Select only"), this, [&]{
this->select(nullptr);
});
selectAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-select")));
selectAction->setToolTip(tr("Selects only this object"));
QAction *deselectAction = menu.addAction(tr("Deselect"),this,SLOT(deselect()));
QAction *deselectAction = menu.addAction(tr("Deselect"), this, &SelectionView::deselect);
deselectAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-unselectable")));
deselectAction->setToolTip(tr("Deselects this object"));
QAction *zoomAction = menu.addAction(tr("Zoom fit"),this,SLOT(zoom()));
QAction *zoomAction = menu.addAction(tr("Zoom fit"), this, &SelectionView::zoom);
zoomAction->setIcon(QIcon::fromTheme(QString::fromLatin1("zoom-fit-best")));
zoomAction->setToolTip(tr("Selects and fits this object in the 3D window"));
QAction *gotoAction = menu.addAction(tr("Go to selection"),this,SLOT(treeSelect()));
QAction *gotoAction = menu.addAction(tr("Go to selection"), this, &SelectionView::treeSelect);
gotoAction->setToolTip(tr("Selects and locates this object in the tree view"));
QAction *touchAction = menu.addAction(tr("Mark to recompute"),this,SLOT(touch()));
QAction *touchAction = menu.addAction(tr("Mark to recompute"), this, &SelectionView::touch);
touchAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-refresh")));
touchAction->setToolTip(tr("Mark this object to be recomputed"));
QAction *toPythonAction = menu.addAction(tr("To python console"),this,SLOT(toPython()));
QAction *toPythonAction = menu.addAction(tr("To python console"), this, &SelectionView::toPython);
toPythonAction->setIcon(QIcon::fromTheme(QString::fromLatin1("applications-python")));
toPythonAction->setToolTip(tr("Reveals this object and its subelements in the python console."));
QStringList elements = item->data(Qt::UserRole).toStringList();
if (elements.length() > 2) {
// subshape-specific entries
QAction *showPart = menu.addAction(tr("Duplicate subshape"),this,SLOT(showPart()));
QAction *showPart = menu.addAction(tr("Duplicate subshape"), this, &SelectionView::showPart);
showPart->setIcon(QIcon(QString::fromLatin1(":/icons/ClassBrowser/member.svg")));
showPart->setToolTip(tr("Creates a standalone copy of this subshape in the document"));
}

View File

@@ -4373,7 +4373,7 @@ void LinkLabel::onLinkActivated (const QString& s)
{
Q_UNUSED(s);
auto select = new LinkSelection(qvariant_cast<App::SubObjectT>(link));
QTimer::singleShot(50, select, SLOT(select()));
QTimer::singleShot(50, select, &LinkSelection::select);
}
void LinkLabel::onEditClicked ()