Changeset View
Changeset View
Standalone View
Standalone View
shell/sourceformattercontroller.cpp
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | 101 | { | |||
---|---|---|---|---|---|
113 | 113 | | |||
114 | m_formatLine = actionCollection()->addAction(QStringLiteral("edit_reformat_line")); | 114 | m_formatLine = actionCollection()->addAction(QStringLiteral("edit_reformat_line")); | ||
115 | m_formatLine->setText(i18n("Reformat Line")); | 115 | m_formatLine->setText(i18n("Reformat Line")); | ||
116 | m_formatLine->setToolTip(i18n("Reformat current line using AStyle")); | 116 | m_formatLine->setToolTip(i18n("Reformat current line using AStyle")); | ||
117 | m_formatLine->setWhatsThis(i18n("Source reformatting of line under cursor using <b>astyle</b> library.")); | 117 | m_formatLine->setWhatsThis(i18n("Source reformatting of line under cursor using <b>astyle</b> library.")); | ||
118 | connect(m_formatLine, &QAction::triggered, this, &SourceFormatterController::beautifyLine); | 118 | connect(m_formatLine, &QAction::triggered, this, &SourceFormatterController::beautifyLine); | ||
119 | 119 | | |||
120 | m_formatFilesAction = actionCollection()->addAction(QStringLiteral("tools_astyle")); | 120 | m_formatFilesAction = actionCollection()->addAction(QStringLiteral("tools_astyle")); | ||
121 | m_formatFilesAction->setText(i18n("Format Files")); | 121 | m_formatFilesAction->setText(i18n("Reformat Files...")); | ||
122 | m_formatFilesAction->setToolTip(i18n("Format file(s) using the current theme")); | 122 | m_formatFilesAction->setToolTip(i18n("Format file(s) using the current theme")); | ||
123 | m_formatFilesAction->setWhatsThis(i18n("Formatting functionality using <b>astyle</b> library.")); | 123 | m_formatFilesAction->setWhatsThis(i18n("Formatting functionality using <b>astyle</b> library.")); | ||
124 | connect(m_formatFilesAction, &QAction::triggered, this, static_cast<void(SourceFormatterController::*)()>(&SourceFormatterController::formatFiles)); | 124 | connect(m_formatFilesAction, &QAction::triggered, this, static_cast<void(SourceFormatterController::*)()>(&SourceFormatterController::formatFiles)); | ||
125 | 125 | | |||
126 | // connect to both documentActivated & documentClosed, | 126 | // connect to both documentActivated & documentClosed, | ||
127 | // otherwise we miss when the last document was closed | 127 | // otherwise we miss when the last document was closed | ||
128 | connect(Core::self()->documentController(), &IDocumentController::documentActivated, | 128 | connect(Core::self()->documentController(), &IDocumentController::documentActivated, | ||
129 | this, &SourceFormatterController::updateFormatTextAction); | 129 | this, &SourceFormatterController::updateFormatTextAction); | ||
▲ Show 20 Lines • Show All 420 Lines • ▼ Show 20 Line(s) | 549 | foreach(KDevelop::ProjectTargetItem *f, item->targetList()) { | |||
550 | foreach(KDevelop::ProjectFileItem *child, f->fileList()) | 550 | foreach(KDevelop::ProjectFileItem *child, f->fileList()) | ||
551 | m_urls.append(child->path().toUrl()); | 551 | m_urls.append(child->path().toUrl()); | ||
552 | } | 552 | } | ||
553 | foreach(KDevelop::ProjectFileItem *f, item->fileList()) | 553 | foreach(KDevelop::ProjectFileItem *f, item->fileList()) | ||
554 | m_urls.append(f->path().toUrl()); | 554 | m_urls.append(f->path().toUrl()); | ||
555 | } | 555 | } | ||
556 | 556 | | |||
557 | auto win = ICore::self()->uiController()->activeMainWindow()->window(); | 557 | auto win = ICore::self()->uiController()->activeMainWindow()->window(); | ||
558 | auto reply = QMessageBox::question(win, i18n("Reformat files?"), i18n("Reformat all files in the selected folder?")); | 558 | | ||
559 | if ( reply == QMessageBox::Yes ) { | 559 | QMessageBox msgBox(QMessageBox::Question, i18n("Reformat files?"), | ||
560 | i18n("Reformat all files in the selected folder?"), | ||||
561 | QMessageBox::Ok|QMessageBox::Cancel, win); | ||||
562 | msgBox.setDefaultButton(QMessageBox::Cancel); | ||||
563 | auto okButton = msgBox.button(QMessageBox::Ok); | ||||
564 | okButton->setText(i18n("Reformat")); | ||||
565 | msgBox.exec(); | ||||
566 | | ||||
567 | if (msgBox.clickedButton() == okButton) { | ||||
560 | formatFiles(m_urls); | 568 | formatFiles(m_urls); | ||
561 | } | 569 | } | ||
562 | } | 570 | } | ||
563 | 571 | | |||
564 | void SourceFormatterController::formatFiles(QList<QUrl> &list) | 572 | void SourceFormatterController::formatFiles(QList<QUrl> &list) | ||
565 | { | 573 | { | ||
566 | //! \todo IStatus | 574 | //! \todo IStatus | ||
567 | for (int fileCount = 0; fileCount < list.size(); fileCount++) { | 575 | for (int fileCount = 0; fileCount < list.size(); fileCount++) { | ||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |