Commit 5221d5f0 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

QmlDesigner: Use Qt5-style connect

+ De-slot where possible

Change-Id: Ibd2edbef7b7712aba20593bd0417940e828e0c9c
Reviewed-by: Thomas Hartmann's avatarThomas Hartmann <thomas.hartmann@qt.io>
parent f87c1eba
......@@ -76,7 +76,7 @@ SelectionContext AbstractAction::selectionContext() const
DefaultAction::DefaultAction(const QString &description)
: QAction(description, 0)
{
connect(this, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool)));
connect(this, &DefaultAction::triggered, this, &DefaultAction::actionTriggered);
}
void DefaultAction::actionTriggered(bool enable)
......
......@@ -39,13 +39,13 @@ class QMLDESIGNERCORE_EXPORT DefaultAction : public QAction
public:
DefaultAction(const QString &description);
signals:
void triggered(bool checked, const SelectionContext &selectionContext);
public slots: //virtual function instead of slot
// virtual function instead of slot
virtual void actionTriggered(bool enable);
void setSelectionContext(const SelectionContext &selectionContext);
signals:
void triggered(bool checked, const SelectionContext &selectionContext);
protected:
SelectionContext m_selectionContext;
};
......
......@@ -46,10 +46,8 @@ public:
Utils::CrumblePath *crumblePath();
private slots:
void onCrumblePathElementClicked(const QVariant &data);
private:
void onCrumblePathElementClicked(const QVariant &data);
void updateVisibility();
void showSaveDialog();
......
......@@ -107,7 +107,6 @@ public:
: DefaultAction(description), m_action(action)
{ }
public /*slots*/:
virtual void actionTriggered(bool b)
{
m_selectionContext.setToggled(b);
......
......@@ -36,7 +36,8 @@ namespace Internal {
DebugViewWidget::DebugViewWidget(QWidget *parent) : QWidget(parent)
{
m_ui.setupUi(this);
connect(m_ui.enabledCheckBox, SIGNAL(toggled(bool)), this, SLOT(enabledCheckBoxToggled(bool)));
connect(m_ui.enabledCheckBox, &QAbstractButton::toggled,
this, &DebugViewWidget::enabledCheckBoxToggled);
}
void DebugViewWidget::addLogMessage(const QString &topic, const QString &message, bool highlight)
......
......@@ -45,7 +45,6 @@ public:
void setDebugViewEnabled(bool b);
public slots:
void enabledCheckBoxToggled(bool b);
private:
......
......@@ -64,7 +64,8 @@ QWidget *BackgroundAction::createWidget(QWidget *parent)
}
comboBox->setCurrentIndex(0);
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitBackgroundChanged(int)));
connect(comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &BackgroundAction::emitBackgroundChanged);
comboBox->setProperty("hideborder", true);
comboBox->setToolTip(tr("Set the color of the canvas."));
......
......@@ -46,7 +46,7 @@ signals:
protected:
QWidget *createWidget(QWidget *parent);
private slots:
private:
void emitBackgroundChanged(int index);
private:
......
......@@ -84,7 +84,6 @@ public:
void highlightBoundingRect(FormEditorItem *formEditorItem);
public slots:
void setShowBoundingRects(bool show);
bool showBoundingRects() const;
......
......@@ -607,7 +607,7 @@ bool FormEditorView::isMoveToolAvailable() const
void FormEditorView::reset()
{
QTimer::singleShot(200, this, SLOT(delayedReset()));
QTimer::singleShot(200, this, &FormEditorView::delayedReset);
}
void FormEditorView::delayedReset()
......
......@@ -120,8 +120,6 @@ public:
protected:
void reset();
protected slots:
void delayedReset();
bool isMoveToolAvailable() const;
......
......@@ -120,13 +120,15 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
m_rootWidthAction = new LineEditAction(tr("Override Width"), this);
m_rootWidthAction->setToolTip(tr("Override width of root item."));
connect(m_rootWidthAction.data(), SIGNAL(textChanged(QString)), this, SLOT(changeRootItemWidth(QString)));
connect(m_rootWidthAction.data(), &LineEditAction::textChanged,
this, &FormEditorWidget::changeRootItemWidth);
addAction(m_rootWidthAction.data());
upperActions.append(m_rootWidthAction.data());
m_rootHeightAction = new LineEditAction(tr("Override Height"), this);
m_rootHeightAction->setToolTip(tr("Override height of root item."));
connect(m_rootHeightAction.data(), SIGNAL(textChanged(QString)), this, SLOT(changeRootItemHeight(QString)));
connect(m_rootHeightAction.data(), &LineEditAction::textChanged,
this, &FormEditorWidget::changeRootItemHeight);
addAction(m_rootHeightAction.data());
upperActions.append(m_rootHeightAction.data());
......@@ -150,7 +152,8 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
m_toolBox->addRightSideAction(m_backgroundAction.data());
m_zoomAction = new ZoomAction(m_toolActionGroup.data());
connect(m_zoomAction.data(), SIGNAL(zoomLevelChanged(double)), SLOT(setZoomLevel(double)));
connect(m_zoomAction.data(), &ZoomAction::zoomLevelChanged,
this, &FormEditorWidget::setZoomLevel);
addAction(m_zoomAction.data());
upperActions.append(m_zoomAction.data());
m_toolBox->addRightSideAction(m_zoomAction.data());
......@@ -159,7 +162,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
m_resetAction->setShortcut(Qt::Key_R);
m_resetAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
m_resetAction->setIcon(Utils::Icons::RESET_TOOLBAR.icon());
connect(m_resetAction.data(), SIGNAL(triggered(bool)), this, SLOT(resetNodeInstanceView()));
connect(m_resetAction.data(), &QAction::triggered, this, &FormEditorWidget::resetNodeInstanceView);
addAction(m_resetAction.data());
upperActions.append(m_resetAction.data());
m_toolBox->addRightSideAction(m_resetAction.data());
......
......@@ -88,7 +88,7 @@ protected:
QActionGroup *toolActionGroup() const;
DocumentWarningWidget *errorWidget();
private slots:
private:
void changeTransformTool(bool checked);
void setZoomLevel(double zoomLevel);
void changeRootItemWidth(const QString &widthText);
......
......@@ -57,9 +57,9 @@ QWidget *LineEditAction::createWidget(QWidget *parent)
lineEdit->setFont(font);
lineEdit->setValidator(new QIntValidator(0, 4096, this));
connect(lineEdit, SIGNAL(textEdited(QString)), this, SIGNAL(textChanged(QString)));
connect(this, SIGNAL(lineEditTextClear()), lineEdit, SLOT(clear()));
connect(this, SIGNAL(lineEditTextChange(QString)), lineEdit, SLOT(setText(QString)));
connect(lineEdit, &QLineEdit::textEdited, this, &LineEditAction::textChanged);
connect(this, &LineEditAction::lineEditTextClear, lineEdit, &QLineEdit::clear);
connect(this, &LineEditAction::lineEditTextChange, lineEdit, &QLineEdit::setText);
return lineEdit;
}
......
......@@ -59,7 +59,8 @@ QWidget *NumberSeriesAction::createWidget(QWidget *parent)
comboBox->setModel(m_comboBoxModel.data());
comboBox->setCurrentIndex(m_comboBoxModelIndex);
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitValueChanged(int)));
connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &NumberSeriesAction::emitValueChanged);
return comboBox;
}
......
......@@ -50,7 +50,7 @@ protected:
signals:
void valueChanged(const QVariant &value);
private slots:
private:
void emitValueChanged(int index);
private:
......
......@@ -91,8 +91,9 @@ QWidget *ZoomAction::createWidget(QWidget *parent)
}
comboBox->setCurrentIndex(8);
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitZoomLevelChanged(int)));
connect(this, SIGNAL(indexChanged(int)), comboBox, SLOT(setCurrentIndex(int)));
connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &ZoomAction::emitZoomLevelChanged);
connect(this, &ZoomAction::indexChanged, comboBox, &QComboBox::setCurrentIndex);
comboBox->setProperty("hideborder", true);
return comboBox;
......
......@@ -51,7 +51,8 @@ protected:
signals:
void zoomLevelChanged(double zoom);
void indexChanged(int);
private slots:
private:
void emitZoomLevelChanged(int index);
private:
......
......@@ -47,7 +47,7 @@ ImportLabel::ImportLabel(QWidget *parent) :
m_removeButton->setFocusPolicy(Qt::NoFocus);
m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_removeButton->setToolTip(tr("Remove Import"));
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(emitRemoveImport()));
connect(m_removeButton, &QAbstractButton::clicked, this, [this] { emit removeImport(m_import); });
layout->addWidget(m_removeButton);
m_importLabel = new QLabel(this);
......@@ -75,9 +75,4 @@ void ImportLabel::setReadOnly(bool readOnly) const
: Utils::Icons::CLOSE_TOOLBAR.icon());
}
void ImportLabel::emitRemoveImport()
{
emit removeImport(m_import);
}
} // namespace QmlDesigner
......@@ -45,9 +45,6 @@ public:
signals:
void removeImport(const Import &import);
private slots:
void emitRemoveImport();
private:
Import m_import;
QLabel *m_importLabel;
......
......@@ -52,8 +52,8 @@ WidgetInfo ImportManagerView::widgetInfo()
{
if (m_importsWidget == 0) {
m_importsWidget = new ImportsWidget;
connect(m_importsWidget, SIGNAL(removeImport(Import)), this, SLOT(removeImport(Import)));
connect(m_importsWidget, SIGNAL(addImport(Import)), this, SLOT(addImport(Import)));
connect(m_importsWidget.data(), &ImportsWidget::removeImport, this, &ImportManagerView::removeImport);
connect(m_importsWidget.data(), &ImportsWidget::addImport, this, &ImportManagerView::addImport);
if (model())
m_importsWidget->setImports(model()->imports());
......
......@@ -50,7 +50,7 @@ public:
void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) override;
private slots:
private:
void removeImport(const Import &import);
void addImport(const Import &import);
......
......@@ -39,7 +39,8 @@ ImportsWidget::ImportsWidget(QWidget *parent) :
{
setWindowTitle(tr("Import Manager"));
m_addImportComboBox = new ImportManagerComboBox(this);
connect(m_addImportComboBox, SIGNAL(activated(int)), this, SLOT(addSelectedImport(int)));
connect(m_addImportComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
this, &ImportsWidget::addSelectedImport);
}
void ImportsWidget::removeImports()
......@@ -126,7 +127,7 @@ void ImportsWidget::setImports(const QList<Import> &imports)
ImportLabel *importLabel = new ImportLabel(this);
importLabel->setImport(import);
m_importLabels.append(importLabel);
connect(importLabel, SIGNAL(removeImport(Import)), this, SIGNAL(removeImport(Import)));
connect(importLabel, &ImportLabel::removeImport, this, &ImportsWidget::removeImport);
}
updateLayout();
......
......@@ -59,7 +59,7 @@ signals:
protected:
void updateLayout();
private slots:
private:
void addSelectedImport(int addImportComboBoxIndex);
private:
......
......@@ -53,8 +53,9 @@ QWidget *ComponentAction::createWidget(QWidget *parent)
comboBox->setToolTip(tr("Edit sub components defined in this file."));
comboBox->setModel(m_componentView->standardItemModel());
comboBox->setCurrentIndex(-1);
connect(comboBox, SIGNAL(activated(int)), SLOT(emitCurrentComponentChanged(int)));
connect(this, SIGNAL(currentIndexChanged(int)), comboBox, SLOT(setCurrentIndex(int)));
connect(comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
this, &ComponentAction::emitCurrentComponentChanged);
connect(this, &ComponentAction::currentIndexChanged, comboBox, &QComboBox::setCurrentIndex);
return comboBox;
}
......
......@@ -44,7 +44,7 @@ class ComponentAction : public QWidgetAction
public:
ComponentAction(ComponentView *componentView);
void setCurrentIndex(int index);
void emitCurrentComponentChanged(int index);
protected:
QWidget *createWidget(QWidget *parent);
......@@ -54,9 +54,6 @@ signals:
void changedToMaster();
void currentIndexChanged(int index);
public slots:
void emitCurrentComponentChanged(int index);
private:
QPointer<ComponentView> m_componentView;
bool dontEmitCurrentComponentChanged;
......
......@@ -235,12 +235,12 @@ void DesignDocument::loadDocument(QPlainTextEdit *edit)
{
Q_CHECK_PTR(edit);
connect(edit, SIGNAL(undoAvailable(bool)),
this, SIGNAL(undoAvailable(bool)));
connect(edit, SIGNAL(redoAvailable(bool)),
this, SIGNAL(redoAvailable(bool)));
connect(edit, SIGNAL(modificationChanged(bool)),
this, SIGNAL(dirtyStateChanged(bool)));
connect(edit, &QPlainTextEdit::undoAvailable,
this, &DesignDocument::undoAvailable);
connect(edit, &QPlainTextEdit::redoAvailable,
this, &DesignDocument::redoAvailable);
connect(edit, &QPlainTextEdit::modificationChanged,
this, &DesignDocument::dirtyStateChanged);
m_documentTextModifier.reset(new BaseTextEditModifier(dynamic_cast<TextEditor::TextEditorWidget*>(plainTextEdit())));
......
......@@ -106,7 +106,7 @@ signals:
void designDocumentClosed();
void qmlErrorsChanged(const QList<DocumentMessage> &errors);
public slots:
public:
void deleteSelected();
void copySelected();
void cutSelected();
......@@ -119,10 +119,9 @@ public slots:
void changeToSubComponent(const ModelNode &componentNode);
void changeToMaster();
private slots:
private: // functions
void updateFileName(const Utils::FileName &oldFileName, const Utils::FileName &newFileName);
private: // functions
void changeToInFileComponentModel(ComponentTextModifier *textModifer);
void updateQrcFiles();
......
......@@ -43,7 +43,6 @@ class StackedUtilityPanelController : public UtilityPanelController
public:
StackedUtilityPanelController(QObject* parent = 0);
public slots:
void show(DesignDocument* DesignDocument);
void close(DesignDocument* DesignDocument);
......
......@@ -69,7 +69,6 @@ public:
ItemLibrarySection *sectionByName(const QString &sectionName);
public slots:
void setSearchText(const QString &searchText);
void setExpanded(bool, const QString &section);
......
......@@ -100,8 +100,8 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
tabBar->addTab(tr("Resources", "Title of library resources view"));
tabBar->addTab(tr("Imports", "Title of library imports view"));
tabBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(setCurrentIndexOfStackedWidget(int)));
connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(updateSearch()));
connect(tabBar, &QTabBar::currentChanged, this, &ItemLibraryWidget::setCurrentIndexOfStackedWidget);
connect(tabBar, &QTabBar::currentChanged, this, &ItemLibraryWidget::updateSearch);
m_filterLineEdit = new Utils::FancyLineEdit(this);
m_filterLineEdit->setObjectName(QStringLiteral("itemLibrarySearchInput"));
......@@ -119,7 +119,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
lineEditLayout->addWidget(m_filterLineEdit.data(), 1, 1, 1, 1);
lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 2);
connect(m_filterLineEdit.data(), SIGNAL(filterChanged(QString)), this, SLOT(setSearchFilter(QString)));
connect(m_filterLineEdit.data(), &Utils::FancyLineEdit::filterChanged, this, &ItemLibraryWidget::setSearchFilter);
m_stackedWidget = new QStackedWidget(this);
......@@ -145,9 +145,9 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
m_resourcesView->setStyleSheet(Theme::replaceCssColors(QString::fromUtf8(Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/scrollbar.css")))));
m_qmlSourceUpdateShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F5), this);
connect(m_qmlSourceUpdateShortcut, SIGNAL(activated()), this, SLOT(reloadQmlSource()));
connect(m_qmlSourceUpdateShortcut, &QShortcut::activated, this, &ItemLibraryWidget::reloadQmlSource);
connect(&m_compressionTimer, SIGNAL(timeout()), this, SLOT(updateModel()));
connect(&m_compressionTimer, &QTimer::timeout, this, &ItemLibraryWidget::updateModel);
// init the first load of the QML UI elements
reloadQmlSource();
......@@ -159,12 +159,12 @@ void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
return;
if (m_itemLibraryInfo)
disconnect(m_itemLibraryInfo.data(), SIGNAL(entriesChanged()),
this, SLOT(delayedUpdateModel()));
disconnect(m_itemLibraryInfo.data(), &ItemLibraryInfo::entriesChanged,
this, &ItemLibraryWidget::delayedUpdateModel);
m_itemLibraryInfo = itemLibraryInfo;
if (itemLibraryInfo)
connect(m_itemLibraryInfo.data(), SIGNAL(entriesChanged()),
this, SLOT(delayedUpdateModel()));
connect(m_itemLibraryInfo.data(), &ItemLibraryInfo::entriesChanged,
this, &ItemLibraryWidget::delayedUpdateModel);
delayedUpdateModel();
}
......
......@@ -75,7 +75,6 @@ public:
static QString qmlSourcesPath();
void clearSearchFilter();
public slots:
void setSearchFilter(const QString &searchFilter);
void delayedUpdateModel();
void updateModel();
......@@ -94,7 +93,7 @@ protected:
signals:
void itemActivated(const QString& itemName);
private slots:
private:
void setCurrentIndexOfStackedWidget(int index);
void reloadQmlSource();
......
......@@ -115,8 +115,8 @@ NavigatorTreeModel::NavigatorTreeModel(QObject *parent)
setColumnCount(2);
# endif
connect(this, SIGNAL(itemChanged(QStandardItem*)),
this, SLOT(handleChangedItem(QStandardItem*)));
connect(this, &QStandardItemModel::itemChanged,
this, &NavigatorTreeModel::handleChangedItem);
}
NavigatorTreeModel::~NavigatorTreeModel()
......
......@@ -123,10 +123,9 @@ public:
ItemRow itemRowForNode(const ModelNode &node);
bool blockItemChangedSignal(bool block);
private slots:
private:
void handleChangedItem(QStandardItem *item);
private:
ItemRow createItemRow(const ModelNode &node);
void updateItemRow(const ModelNode &node, ItemRow row);
void handleChangedIdItem(QStandardItem *idItem, ModelNode &modelNode);
......
......@@ -74,12 +74,12 @@ NavigatorView::NavigatorView(QObject* parent) :
m_widget->setTreeModel(m_treeModel.data());
connect(treeWidget()->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(changeSelection(QItemSelection,QItemSelection)));
connect(treeWidget()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &NavigatorView::changeSelection);
connect(m_widget.data(), SIGNAL(leftButtonClicked()), this, SLOT(leftButtonClicked()));
connect(m_widget.data(), SIGNAL(rightButtonClicked()), this, SLOT(rightButtonClicked()));
connect(m_widget.data(), SIGNAL(downButtonClicked()), this, SLOT(downButtonClicked()));
connect(m_widget.data(), SIGNAL(upButtonClicked()), this, SLOT(upButtonClicked()));
connect(m_widget.data(), &NavigatorWidget::leftButtonClicked, this, &NavigatorView::leftButtonClicked);
connect(m_widget.data(), &NavigatorWidget::rightButtonClicked, this, &NavigatorView::rightButtonClicked);
connect(m_widget.data(), &NavigatorWidget::downButtonClicked, this, &NavigatorView::downButtonClicked);
connect(m_widget.data(), &NavigatorWidget::upButtonClicked, this, &NavigatorView::upButtonClicked);
treeWidget()->setIndentation(treeWidget()->indentation() * 0.5);
......
......@@ -74,7 +74,7 @@ public:
void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, PropertyChangeFlags) override;
private slots:
private:
void changeSelection(const QItemSelection &selected, const QItemSelection &deselected);
void updateItemSelection();
void changeToComponent(const QModelIndex &index);
......
......@@ -82,25 +82,25 @@ QList<QToolButton *> NavigatorWidget::createToolBarWidgets()
buttons.last()->setIcon(Icons::ARROW_LEFT.icon());
buttons.last()->setToolTip(tr("Become last sibling of parent (CTRL + Left)."));
buttons.last()->setShortcut(QKeySequence(Qt::Key_Left | Qt::CTRL));
connect(buttons.last(), SIGNAL(clicked()), this, SIGNAL(leftButtonClicked()));
connect(buttons.last(), &QAbstractButton::clicked, this, &NavigatorWidget::leftButtonClicked);
buttons.append(new QToolButton());
buttons.last()->setIcon(Icons::ARROW_RIGHT.icon());
buttons.last()->setToolTip(tr("Become child of last sibling (CTRL + Right)."));
buttons.last()->setShortcut(QKeySequence(Qt::Key_Right | Qt::CTRL));
connect(buttons.last(), SIGNAL(clicked()), this, SIGNAL(rightButtonClicked()));
connect(buttons.last(), &QAbstractButton::clicked, this, &NavigatorWidget::rightButtonClicked);
buttons.append(new QToolButton());
buttons.last()->setIcon(Icons::ARROW_DOWN.icon());
buttons.last()->setToolTip(tr("Move down (CTRL + Down)."));
buttons.last()->setShortcut(QKeySequence(Qt::Key_Down | Qt::CTRL));
connect(buttons.last(), SIGNAL(clicked()), this, SIGNAL(downButtonClicked()));
connect(buttons.last(), &QAbstractButton::clicked, this, &NavigatorWidget::downButtonClicked);
buttons.append(new QToolButton());
buttons.last()->setIcon(Icons::ARROW_UP.icon());
buttons.last()->setToolTip(tr("Move up (CTRL + Up)."));
buttons.last()->setShortcut(QKeySequence(Qt::Key_Up | Qt::CTRL));
connect(buttons.last(), SIGNAL(clicked()), this, SIGNAL(upButtonClicked()));
connect(buttons.last(), &QAbstractButton::clicked, this, &NavigatorWidget::upButtonClicked);
return buttons;
}
......
......@@ -65,8 +65,6 @@ signals:
void modelNodeBackendChanged();
void fileModelChanged();
public slots:
private:
QVariant modelNodeBackend() const;
......
......@@ -69,8 +69,6 @@ signals:
void anchorBackendChanged();