diff --git a/src/plugins/resourceeditor/qrceditor/qrceditor.cpp b/src/plugins/resourceeditor/qrceditor/qrceditor.cpp index 912b101d349..d49158858e9 100644 --- a/src/plugins/resourceeditor/qrceditor/qrceditor.cpp +++ b/src/plugins/resourceeditor/qrceditor/qrceditor.cpp @@ -51,31 +51,28 @@ QrcEditor::QrcEditor(RelativeResourceModel *model, QWidget *parent) m_treeview->setFrameStyle(QFrame::NoFrame); layout->addWidget(m_treeview); - connect(m_ui.removeButton, SIGNAL(clicked()), this, SLOT(onRemove())); + connect(m_ui.removeButton, &QAbstractButton::clicked, this, &QrcEditor::onRemove); connect(m_ui.removeNonExistingButton, &QPushButton::clicked, this, &QrcEditor::onRemoveNonExisting); // 'Add' button with menu QMenu *addMenu = new QMenu(this); - m_addFileAction = addMenu->addAction(tr("Add Files"), this, SLOT(onAddFiles())); - addMenu->addAction(tr("Add Prefix"), this, SLOT(onAddPrefix())); + m_addFileAction = addMenu->addAction(tr("Add Files")); + connect(m_addFileAction, &QAction::triggered, this, &QrcEditor::onAddFiles); + connect(addMenu->addAction(tr("Add Prefix")), &QAction::triggered, + this, &QrcEditor::onAddPrefix); m_ui.addButton->setMenu(addMenu); - connect(m_treeview, SIGNAL(removeItem()), this, SLOT(onRemove())); - connect(m_treeview->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(updateCurrent())); - connect(m_treeview, SIGNAL(itemActivated(QString)), - this, SIGNAL(itemActivated(QString))); - connect(m_treeview, SIGNAL(showContextMenu(QPoint,QString)), - this, SIGNAL(showContextMenu(QPoint,QString))); + connect(m_treeview, &ResourceView::removeItem, this, &QrcEditor::onRemove); + connect(m_treeview->selectionModel(), &QItemSelectionModel::currentChanged, + this, &QrcEditor::updateCurrent); + connect(m_treeview, &ResourceView::itemActivated, this, &QrcEditor::itemActivated); + connect(m_treeview, &ResourceView::contextMenuShown, this, &QrcEditor::showContextMenu); m_treeview->setFocus(); - connect(m_ui.aliasText, SIGNAL(textEdited(QString)), - this, SLOT(onAliasChanged(QString))); - connect(m_ui.prefixText, SIGNAL(textEdited(QString)), - this, SLOT(onPrefixChanged(QString))); - connect(m_ui.languageText, SIGNAL(textEdited(QString)), - this, SLOT(onLanguageChanged(QString))); + connect(m_ui.aliasText, &QLineEdit::textEdited, this, &QrcEditor::onAliasChanged); + connect(m_ui.prefixText, &QLineEdit::textEdited, this, &QrcEditor::onPrefixChanged); + connect(m_ui.languageText, &QLineEdit::textEdited, this, &QrcEditor::onLanguageChanged); // Prevent undo command merging after a switch of focus: // (0) The initial text is "Green". @@ -85,15 +82,15 @@ QrcEditor::QrcEditor(RelativeResourceModel *model, QWidget *parent) // --> text now is "Red is a color." // (4) The user hits undo --> text now is "Green is a color." // Without calling advanceMergeId() it would have been "Green", instead. - connect(m_ui.aliasText, SIGNAL(editingFinished()), - m_treeview, SLOT(advanceMergeId())); - connect(m_ui.prefixText, SIGNAL(editingFinished()), - m_treeview, SLOT(advanceMergeId())); - connect(m_ui.languageText, SIGNAL(editingFinished()), - m_treeview, SLOT(advanceMergeId())); + connect(m_ui.aliasText, &QLineEdit::editingFinished, + m_treeview, &ResourceView::advanceMergeId); + connect(m_ui.prefixText, &QLineEdit::editingFinished, + m_treeview, &ResourceView::advanceMergeId); + connect(m_ui.languageText, &QLineEdit::editingFinished, + m_treeview, &ResourceView::advanceMergeId); - connect(&m_history, SIGNAL(canRedoChanged(bool)), this, SLOT(updateHistoryControls())); - connect(&m_history, SIGNAL(canUndoChanged(bool)), this, SLOT(updateHistoryControls())); + connect(&m_history, &QUndoStack::canRedoChanged, this, &QrcEditor::updateHistoryControls); + connect(&m_history, &QUndoStack::canUndoChanged, this, &QrcEditor::updateHistoryControls); Aggregation::Aggregate * agg = new Aggregation::Aggregate; agg->add(m_treeview); diff --git a/src/plugins/resourceeditor/qrceditor/qrceditor.h b/src/plugins/resourceeditor/qrceditor/qrceditor.h index 512d35a2ac2..4f31bd24bcc 100644 --- a/src/plugins/resourceeditor/qrceditor/qrceditor.h +++ b/src/plugins/resourceeditor/qrceditor/qrceditor.h @@ -54,18 +54,20 @@ public: QString currentResourcePath() const; + void onUndo(); + void onRedo(); + signals: void itemActivated(const QString &fileName); void showContextMenu(const QPoint &globalPos, const QString &fileName); + void undoStackChanged(bool canUndo, bool canRedo); -private slots: +private: void updateCurrent(); void updateHistoryControls(); -private: void resolveLocationIssues(QStringList &files); -private slots: void onAliasChanged(const QString &alias); void onPrefixChanged(const QString &prefix); void onLanguageChanged(const QString &language); @@ -74,14 +76,6 @@ private slots: void onAddFiles(); void onAddPrefix(); -signals: - void undoStackChanged(bool canUndo, bool canRedo); - -public slots: - void onUndo(); - void onRedo(); - -private: Ui::QrcEditor m_ui; QUndoStack m_history; ResourceView *m_treeview; diff --git a/src/plugins/resourceeditor/qrceditor/resourceview.cpp b/src/plugins/resourceeditor/qrceditor/resourceview.cpp index 32117825648..5af851e61dc 100644 --- a/src/plugins/resourceeditor/qrceditor/resourceview.cpp +++ b/src/plugins/resourceeditor/qrceditor/resourceview.cpp @@ -57,10 +57,8 @@ ResourceView::ResourceView(RelativeResourceModel *model, QUndoStack *history, QW header()->hide(); - connect(this, SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(showContextMenu(QPoint))); - connect(this, SIGNAL(activated(QModelIndex)), - this, SLOT(itemActivated(QModelIndex))); + connect(this, &QWidget::customContextMenuRequested, this, &ResourceView::showContextMenu); + connect(this, &QAbstractItemView::activated, this, &ResourceView::onItemActivated); } ResourceView::~ResourceView() @@ -276,7 +274,7 @@ void ResourceView::changeValue(const QModelIndex &nodeIndex, NodeProperty proper } } -void ResourceView::itemActivated(const QModelIndex &index) +void ResourceView::onItemActivated(const QModelIndex &index) { const QString fileName = m_qrcModel->file(index); if (fileName.isEmpty()) @@ -290,7 +288,7 @@ void ResourceView::showContextMenu(const QPoint &pos) const QString fileName = m_qrcModel->file(index); if (fileName.isEmpty()) return; - emit showContextMenu(mapToGlobal(pos), fileName); + emit contextMenuShown(mapToGlobal(pos), fileName); } void ResourceView::advanceMergeId() diff --git a/src/plugins/resourceeditor/qrceditor/resourceview.h b/src/plugins/resourceeditor/qrceditor/resourceview.h index 59e4d434188..aeeb2441d48 100644 --- a/src/plugins/resourceeditor/qrceditor/resourceview.h +++ b/src/plugins/resourceeditor/qrceditor/resourceview.h @@ -81,29 +81,25 @@ public: void refresh(); -public slots: void setCurrentAlias(const QString &before, const QString &after); void setCurrentPrefix(const QString &before, const QString &after); void setCurrentLanguage(const QString &before, const QString &after); void advanceMergeId(); + QString getCurrentValue(NodeProperty property) const; + void changeValue(const QModelIndex &nodeIndex, NodeProperty property, const QString &value); + protected: void keyPressEvent(QKeyEvent *e); signals: void removeItem(); void itemActivated(const QString &fileName); - void showContextMenu(const QPoint &globalPos, const QString &fileName); - -public: - QString getCurrentValue(NodeProperty property) const; - void changeValue(const QModelIndex &nodeIndex, NodeProperty property, const QString &value); - -private slots: - void itemActivated(const QModelIndex &index); - void showContextMenu(const QPoint &pos); + void contextMenuShown(const QPoint &globalPos, const QString &fileName); private: + void onItemActivated(const QModelIndex &index); + void showContextMenu(const QPoint &pos); void addUndoCommand(const QModelIndex &nodeIndex, NodeProperty property, const QString &before, const QString &after); diff --git a/src/plugins/resourceeditor/qrceditor/test/mainwindow.cpp b/src/plugins/resourceeditor/qrceditor/test/mainwindow.cpp index 720b35eb909..5de60a50d63 100644 --- a/src/plugins/resourceeditor/qrceditor/test/mainwindow.cpp +++ b/src/plugins/resourceeditor/qrceditor/test/mainwindow.cpp @@ -41,13 +41,13 @@ MainWindow::MainWindow() : QMenu* fMenu = menuBar()->addMenu(QLatin1String("File")); QAction* oa = fMenu->addAction(QLatin1String("Open...")); - connect(oa, SIGNAL(triggered()), this, SLOT(slotOpen())); + connect(oa, &QAction::triggered, this, &MainWindow::slotOpen); QAction* sa = fMenu->addAction(QLatin1String("Save")); - connect(sa, SIGNAL(triggered()), this, SLOT(slotSave())); + connect(sa, &QAction::triggered, this, &MainWindow::slotSave); QAction* xa = fMenu->addAction(QLatin1String("Exit!")); - connect(xa, SIGNAL(triggered()), this, SLOT(close())); + connect(xa, &QAction::triggered, this, &QWidget::close); QWidget *cw = new QWidget(); diff --git a/src/plugins/resourceeditor/qrceditor/test/mainwindow.h b/src/plugins/resourceeditor/qrceditor/test/mainwindow.h index a6e619c7e08..d47b43e3749 100644 --- a/src/plugins/resourceeditor/qrceditor/test/mainwindow.h +++ b/src/plugins/resourceeditor/qrceditor/test/mainwindow.h @@ -36,10 +36,9 @@ class MainWindow : public QMainWindow public: MainWindow(); -private slots: +private: void slotOpen(); void slotSave(); -private: SharedTools::QrcEditor *m_qrcEditor; }; diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp index e1935136941..83d123cbefa 100644 --- a/src/plugins/resourceeditor/resourceeditorplugin.cpp +++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp @@ -92,10 +92,10 @@ public: layout->addWidget(buttons); - connect(buttons, SIGNAL(accepted()), - this, SLOT(accept())); - connect(buttons, SIGNAL(rejected()), - this, SLOT(reject())); + connect(buttons, &QDialogButtonBox::accepted, + this, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, + this, &QDialog::reject); } QString prefix() const { @@ -134,9 +134,9 @@ bool ResourceEditorPlugin::initialize(const QStringList &arguments, QString *err Core::ActionManager::registerAction(m_undoAction, Core::Constants::UNDO, context); Core::ActionManager::registerAction(m_redoAction, Core::Constants::REDO, context); Core::ActionManager::registerAction(m_refreshAction, Constants::REFRESH, context); - connect(m_undoAction, SIGNAL(triggered()), this, SLOT(onUndo())); - connect(m_redoAction, SIGNAL(triggered()), this, SLOT(onRedo())); - connect(m_refreshAction, SIGNAL(triggered()), this, SLOT(onRefresh())); + connect(m_undoAction, &QAction::triggered, this, &ResourceEditorPlugin::onUndo); + connect(m_redoAction, &QAction::triggered, this, &ResourceEditorPlugin::onRedo); + connect(m_refreshAction, &QAction::triggered, this, &ResourceEditorPlugin::onRefresh); Core::Context projectTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE); Core::ActionContainer *folderContextMenu = @@ -148,17 +148,17 @@ bool ResourceEditorPlugin::initialize(const QStringList &arguments, QString *err m_addPrefix = new QAction(tr("Add Prefix..."), this); command = Core::ActionManager::registerAction(m_addPrefix, Constants::C_ADD_PREFIX, projectTreeContext); folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES); - connect(m_addPrefix, SIGNAL(triggered()), this, SLOT(addPrefixContextMenu())); + connect(m_addPrefix, &QAction::triggered, this, &ResourceEditorPlugin::addPrefixContextMenu); m_renamePrefix = new QAction(tr("Change Prefix..."), this); command = Core::ActionManager::registerAction(m_renamePrefix, Constants::C_RENAME_PREFIX, projectTreeContext); folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES); - connect(m_renamePrefix, SIGNAL(triggered()), this, SLOT(renamePrefixContextMenu())); + connect(m_renamePrefix, &QAction::triggered, this, &ResourceEditorPlugin::renamePrefixContextMenu); m_removePrefix = new QAction(tr("Remove Prefix..."), this); command = Core::ActionManager::registerAction(m_removePrefix, Constants::C_REMOVE_PREFIX, projectTreeContext); folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES); - connect(m_removePrefix, SIGNAL(triggered()), this, SLOT(removePrefixContextMenu())); + connect(m_removePrefix, &QAction::triggered, this, &ResourceEditorPlugin::removePrefixContextMenu); m_removeNonExisting = new QAction(tr("Remove Missing Files"), this); command = Core::ActionManager::registerAction(m_removeNonExisting, Constants::C_REMOVE_NON_EXISTING, projectTreeContext); @@ -168,17 +168,17 @@ bool ResourceEditorPlugin::initialize(const QStringList &arguments, QString *err m_renameResourceFile = new QAction(tr("Rename..."), this); command = Core::ActionManager::registerAction(m_renameResourceFile, Constants::C_RENAME_FILE, projectTreeContext); folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES); - connect(m_renameResourceFile, SIGNAL(triggered()), this, SLOT(renameFileContextMenu())); + connect(m_renameResourceFile, &QAction::triggered, this, &ResourceEditorPlugin::renameFileContextMenu); m_removeResourceFile = new QAction(tr("Remove File..."), this); command = Core::ActionManager::registerAction(m_removeResourceFile, Constants::C_REMOVE_FILE, projectTreeContext); folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES); - connect(m_removeResourceFile, SIGNAL(triggered()), this, SLOT(removeFileContextMenu())); + connect(m_removeResourceFile, &QAction::triggered, this, &ResourceEditorPlugin::removeFileContextMenu); m_openInEditor = new QAction(tr("Open in Editor"), this); command = Core::ActionManager::registerAction(m_openInEditor, Constants::C_OPEN_EDITOR, projectTreeContext); folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES); - connect(m_openInEditor, SIGNAL(triggered()), this, SLOT(openEditorContextMenu())); + connect(m_openInEditor, &QAction::triggered, this, &ResourceEditorPlugin::openEditorContextMenu); m_openWithMenu = new QMenu(tr("Open With"), folderContextMenu->menu()); folderContextMenu->menu()->insertMenu( @@ -189,13 +189,13 @@ bool ResourceEditorPlugin::initialize(const QStringList &arguments, QString *err command = Core::ActionManager::registerAction(m_copyPath, Constants::C_COPY_PATH, projectTreeContext); command->setAttribute(Core::Command::CA_UpdateText); fileContextMenu->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER); - connect(m_copyPath, SIGNAL(triggered()), this, SLOT(copyPathContextMenu())); + connect(m_copyPath, &QAction::triggered, this, &ResourceEditorPlugin::copyPathContextMenu); m_copyUrl = new Utils::ParameterAction(QString(), tr("Copy url \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); command = Core::ActionManager::registerAction(m_copyUrl, Constants::C_COPY_URL, projectTreeContext); command->setAttribute(Core::Command::CA_UpdateText); fileContextMenu->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER); - connect(m_copyUrl, SIGNAL(triggered()), this, SLOT(copyUrlContextMenu())); + connect(m_copyUrl, &QAction::triggered, this, &ResourceEditorPlugin::copyUrlContextMenu); m_addPrefix->setEnabled(false); m_removePrefix->setEnabled(false); diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp index d2ae19f0f39..2058c3a2eaf 100644 --- a/src/plugins/resourceeditor/resourceeditorw.cpp +++ b/src/plugins/resourceeditor/resourceeditorw.cpp @@ -86,7 +86,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context, Core::CommandButton *refreshButton = new Core::CommandButton(Constants::REFRESH, m_toolBar); refreshButton->setIcon(QIcon(QLatin1String(":/texteditor/images/finddocuments.png"))); - connect(refreshButton, SIGNAL(clicked()), this, SLOT(onRefresh())); + connect(refreshButton, &QAbstractButton::clicked, this, &ResourceEditorW::onRefresh); m_toolBar->addWidget(refreshButton); m_resourceEditor->setResourceDragEnabled(true); @@ -97,12 +97,12 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context, connect(m_resourceDocument, &ResourceEditorDocument::loaded, m_resourceEditor, &QrcEditor::loaded); - connect(m_resourceEditor, SIGNAL(undoStackChanged(bool,bool)), - this, SLOT(onUndoStackChanged(bool,bool))); - connect(m_resourceEditor, SIGNAL(showContextMenu(QPoint,QString)), - this, SLOT(showContextMenu(QPoint,QString))); - connect(m_resourceEditor, SIGNAL(itemActivated(QString)), - this, SLOT(openFile(QString))); + connect(m_resourceEditor, &QrcEditor::undoStackChanged, + this, &ResourceEditorW::onUndoStackChanged); + connect(m_resourceEditor, &QrcEditor::showContextMenu, + this, &ResourceEditorW::showContextMenu); + connect(m_resourceEditor, &QrcEditor::itemActivated, + this, &ResourceEditorW::openFile); connect(m_resourceEditor->commandHistory(), &QUndoStack::indexChanged, m_resourceDocument, [this]() { m_resourceDocument->setShouldAutoSave(true); }); if (debugResourceEditorW)