Commit 3624a663 authored by Alessandro Portale's avatar Alessandro Portale

Reduce usage of qApp in favor of static function calls

Q*Application classes have unusually many static functions. In many
cases in our code, these functions are unnecessarily called as instance
functions, using the qApp helper.

This patch replaces many occurencies of qApp with the according
Q*Application classname.

Change-Id: I6099a419fa7bf969891269c37ed7a9e817ef5124
Reviewed-by: default avatarhjk <hjk@qt.io>
parent 07884645
......@@ -142,7 +142,7 @@ QPixmap DetailsWidget::createBackground(const QSize &size, int topHeight, QWidge
QRect topRect(0, 0, size.width(), topHeight);
QRect fullRect(0, 0, size.width(), size.height());
if (HostOsInfo::isMacHost())
p.fillRect(fullRect, qApp->palette().window().color());
p.fillRect(fullRect, QApplication::palette().window().color());
else
p.fillRect(fullRect, creatorTheme()->color(Theme::DetailsWidgetBackgroundColor));
......
......@@ -43,7 +43,7 @@ namespace Utils {
QAction *execMenuAtWidget(QMenu *menu, QWidget *widget)
{
QPoint p;
QRect screen = qApp->desktop()->availableGeometry(widget);
QRect screen = QApplication::desktop()->availableGeometry(widget);
QSize sh = menu->sizeHint();
QRect rect = widget->rect();
if (widget->isRightToLeft()) {
......
......@@ -83,7 +83,7 @@ qreal StyleHelper::sidebarFontSize()
QColor StyleHelper::notTooBrightHighlightColor()
{
QColor highlightColor = qApp->palette().highlight().color();
QColor highlightColor = QApplication::palette().highlight().color();
if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0)
highlightColor.setHsvF(highlightColor.hsvHueF(), 0.1 + highlightColor.saturationF() * 2.0, highlightColor.valueF());
return highlightColor;
......@@ -101,7 +101,6 @@ QPalette StyleHelper::sidebarFontPalette(const QPalette &original)
QColor StyleHelper::panelTextColor(bool lightColored)
{
//qApp->palette().highlightedText().color();
if (!lightColored)
return Qt::white;
else
......
......@@ -34,7 +34,7 @@
#include <QString>
#include <QColor>
#include <QApplication>
#include <QGuiApplication>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QWidget>
......@@ -296,7 +296,7 @@ void ToolTip::placeTip(const QPoint &pos, QWidget *w)
bool ToolTip::eventFilter(QObject *o, QEvent *event)
{
if (m_tip && event->type() == QEvent::ApplicationStateChange
&& qApp->applicationState() != Qt::ApplicationActive) {
&& QGuiApplication::applicationState() != Qt::ApplicationActive) {
hideTipImmediately();
}
......@@ -316,7 +316,7 @@ bool ToolTip::eventFilter(QObject *o, QEvent *event)
}
break;
case QEvent::Leave:
if (o == m_tip && !m_tip->isAncestorOf(qApp->focusWidget()))
if (o == m_tip && !m_tip->isAncestorOf(QApplication::focusWidget()))
hideTipWithDelay();
break;
case QEvent::Enter:
......
......@@ -434,7 +434,7 @@ BinEditorFactory::BinEditorFactory(BinEditorPlugin *owner) :
m_owner(owner)
{
setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_BINEDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_BINEDITOR_DISPLAY_NAME));
addMimeType(Constants::C_BINEDITOR_MIMETYPE);
}
......
......@@ -62,7 +62,7 @@ CMakeListsNode::CMakeListsNode(const Utils::FileName &cmakeListPath) :
static QIcon folderIcon;
if (folderIcon.isNull()) {
const QIcon overlayIcon(Constants::FILEOVERLAY_CMAKE);
QPixmap dirPixmap = qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(QSize(16, 16));
QPixmap dirPixmap = QApplication::style()->standardIcon(QStyle::SP_DirIcon).pixmap(QSize(16, 16));
folderIcon.addPixmap(Core::FileIconProvider::overlayIcon(dirPixmap, overlayIcon));
}
......
......@@ -505,7 +505,7 @@ void SettingsDialog::createGui()
m_headerLabel->setFont(headerLabelFont);
QHBoxLayout *headerHLayout = new QHBoxLayout;
const int leftMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
const int leftMargin = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
headerHLayout->addSpacerItem(new QSpacerItem(leftMargin, 0, QSizePolicy::Fixed, QSizePolicy::Ignored));
headerHLayout->addWidget(m_headerLabel);
......
......@@ -200,8 +200,8 @@ void ShortcutButton::handleToggleChange(bool toogleState)
updateText();
m_keyNum = m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0;
if (toogleState) {
if (qApp->focusWidget())
qApp->focusWidget()->clearFocus(); // funny things happen otherwise
if (QApplication::focusWidget())
QApplication::focusWidget()->clearFocus(); // funny things happen otherwise
qApp->installEventFilter(this);
} else {
qApp->removeEventFilter(this);
......
......@@ -822,10 +822,10 @@ void EditorManagerPrivate::doEscapeKeyFocusMoveMagic()
// otherwise (i.e. mode is edit mode)
// hide extra views (find, help, output)
QWidget *activeWindow = qApp->activeWindow();
QWidget *activeWindow = QApplication::activeWindow();
if (!activeWindow)
return;
QWidget *focus = qApp->focusWidget();
QWidget *focus = QApplication::focusWidget();
EditorView *editorView = currentEditorView();
bool editorViewActive = (focus && focus == editorView->focusWidget());
bool editorViewVisible = editorView->isVisible();
......@@ -886,7 +886,7 @@ void EditorManagerPrivate::showPopupOrSelectDocument()
if (QApplication::keyboardModifiers() == Qt::NoModifier) {
windowPopup()->selectAndHide();
} else {
QWidget *activeWindow = qApp->activeWindow();
QWidget *activeWindow = QApplication::activeWindow();
// decide where to show the popup
// if the active window has editors, we want that editor area as a reference
// TODO: this does not work correctly with multiple editor areas in the same window
......@@ -1388,7 +1388,7 @@ bool EditorManagerPrivate::closeEditors(const QList<IEditor*> &editors, CloseFla
removeEditor(editor, flag != CloseFlag::Suspend);
if (EditorView *view = viewForEditor(editor)) {
if (qApp->focusWidget() && qApp->focusWidget() == editor->widget()->focusWidget())
if (QApplication::focusWidget() && QApplication::focusWidget() == editor->widget()->focusWidget())
focusView = view;
if (editor == view->currentEditor())
closedViews += view;
......@@ -1930,7 +1930,7 @@ void EditorManagerPrivate::handleDocumentStateChange()
void EditorManagerPrivate::editorAreaDestroyed(QObject *area)
{
QWidget *activeWin = qApp->activeWindow();
QWidget *activeWin = QApplication::activeWindow();
EditorArea *newActiveArea = 0;
for (int i = 0; i < d->m_editorAreas.size(); ++i) {
EditorArea *r = d->m_editorAreas.at(i);
......
......@@ -68,7 +68,7 @@ class FileIconProviderImplementation : public QFileIconProvider
{
public:
FileIconProviderImplementation()
: m_unknownFileIcon(qApp->style()->standardIcon(QStyle::SP_FileIcon))
: m_unknownFileIcon(QApplication::style()->standardIcon(QStyle::SP_FileIcon))
{}
QIcon icon(const QFileInfo &info) const override;
......@@ -184,7 +184,7 @@ QPixmap overlayIcon(const QPixmap &baseIcon, const QIcon &overlayIcon)
*/
QPixmap overlayIcon(QStyle::StandardPixmap baseIcon, const QIcon &overlay, const QSize &size)
{
return overlayIcon(qApp->style()->standardIcon(baseIcon).pixmap(size), overlay);
return overlayIcon(QApplication::style()->standardIcon(baseIcon).pixmap(size), overlay);
}
/*!
......
......@@ -742,7 +742,7 @@ FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const
bool FindToolBar::toolBarHasFocus() const
{
return qApp->focusWidget() == focusWidget();
return QApplication::focusWidget() == focusWidget();
}
bool FindToolBar::canShowAllControls(bool replaceIsVisible) const
......
......@@ -916,7 +916,7 @@ void MainWindow::updateFocusWidget(QWidget *old, QWidget *now)
return;
QList<IContext *> newContext;
if (QWidget *p = qApp->focusWidget()) {
if (QWidget *p = QApplication::focusWidget()) {
IContext *context = nullptr;
while (p) {
context = m_contextWidgets.value(p);
......@@ -927,7 +927,7 @@ void MainWindow::updateFocusWidget(QWidget *old, QWidget *now)
}
// ignore toplevels that define no context, like popups without parent
if (!newContext.isEmpty() || qApp->focusWidget() == focusWidget())
if (!newContext.isEmpty() || QApplication::focusWidget() == focusWidget())
updateContextObject(newContext);
}
......
......@@ -309,7 +309,7 @@ VariableChooserPrivate::VariableChooserPrivate(VariableChooser *parent)
this, &VariableChooserPrivate::handleItemActivated);
connect(qobject_cast<QApplication *>(qApp), &QApplication::focusChanged,
this, &VariableChooserPrivate::updateCurrentEditor);
updateCurrentEditor(0, qApp->focusWidget());
updateCurrentEditor(0, QApplication::focusWidget());
}
void VariableGroupItem::populateGroup(MacroExpander *expander)
......
......@@ -241,7 +241,7 @@ void CodepasterPlugin::post(PasteSources pasteSources)
textFromCurrentEditor(&data, &mimeType);
if (data.isEmpty() && (pasteSources & PasteClipboard)) {
QString subType = QStringLiteral("plain");
data = qApp->clipboard()->text(subType, QClipboard::Clipboard);
data = QGuiApplication::clipboard()->text(subType, QClipboard::Clipboard);
}
post(data, mimeType);
}
......
......@@ -63,13 +63,13 @@ public:
? file.open(stdin, QIODevice::ReadOnly) : file.open(QIODevice::ReadOnly);
if (!success) {
std::cerr << "Error: Failed to open file to paste from." << std::endl;
qApp->exit(EXIT_FAILURE);
QCoreApplication::exit(EXIT_FAILURE);
return;
}
const QString content = QString::fromLocal8Bit(file.readAll());
if (content.isEmpty()) {
std::cerr << "Empty input, aborting." << std::endl;
qApp->exit(EXIT_FAILURE);
QCoreApplication::exit(EXIT_FAILURE);
return;
}
connect(m_protocol.data(), &Protocol::pasteDone, this, &PasteReceiver::handlePasteDone);
......@@ -80,7 +80,7 @@ private:
void handlePasteDone(const QString &link)
{
std::cout << qPrintable(link) << std::endl;
qApp->quit();
QCoreApplication::quit();
}
const QString m_filePath;
......
......@@ -83,7 +83,7 @@ public:
CppEditorFactory()
{
setId(Constants::CPPEDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Constants::CPPEDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::CPPEDITOR_DISPLAY_NAME));
addMimeType(CppTools::Constants::C_SOURCE_MIMETYPE);
addMimeType(CppTools::Constants::C_HEADER_MIMETYPE);
addMimeType(CppTools::Constants::CPP_SOURCE_MIMETYPE);
......
......@@ -1269,7 +1269,7 @@ static QString variableToolTip(const QString &name, const QString &type, quint64
void WatchModel::grabWidget()
{
qApp->setOverrideCursor(Qt::CrossCursor);
QGuiApplication::setOverrideCursor(Qt::CrossCursor);
m_grabWidgetTimerId = startTimer(30);
ICore::mainWindow()->grabMouse();
}
......@@ -1302,7 +1302,7 @@ void WatchModel::timerEvent(QTimerEvent *event)
void WatchModel::ungrabWidget()
{
ICore::mainWindow()->releaseMouse();
qApp->restoreOverrideCursor();
QGuiApplication::restoreOverrideCursor();
killTimer(m_grabWidgetTimerId);
m_grabWidgetTimerId = -1;
}
......
......@@ -43,7 +43,7 @@ namespace Internal {
FormEditorFactory::FormEditorFactory()
{
setId(K_DESIGNER_XML_EDITOR_ID);
setDisplayName(qApp->translate("Designer", C_DESIGNER_XML_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("Designer", C_DESIGNER_XML_DISPLAY_NAME));
addMimeType(FORM_MIMETYPE);
FileIconProvider::registerIconOverlayForSuffix(ProjectExplorer::Constants::FILEOVERLAY_UI, "ui");
......
......@@ -49,7 +49,7 @@
#include <utils/mimetypes/mimedatabase.h>
#include <QAction>
#include <QApplication>
#include <QCoreApplication>
#include <QDebug>
#include <QFileInfo>
#include <QLibraryInfo>
......@@ -108,7 +108,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
const QString &trFile = QLatin1String("designer_") + locale;
if (qtr->load(trFile, qtTrPath) || qtr->load(trFile, creatorTrPath))
qApp->installTranslator(qtr);
QCoreApplication::installTranslator(qtr);
}
error->clear();
return true;
......
......@@ -38,7 +38,7 @@ DiffEditorFactory::DiffEditorFactory(QObject *parent)
: IEditorFactory(parent)
{
setId(Constants::DIFF_EDITOR_ID);
setDisplayName(qApp->translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME));
addMimeType(Constants::DIFF_EDITOR_MIMETYPE);
}
......
......@@ -116,7 +116,7 @@ GenericProjectWizard::GenericProjectWizard()
QPixmap icon(22, 22);
icon.fill(Qt::transparent);
QPainter p(&icon);
p.drawPixmap(3, 3, 16, 16, qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(16));
p.drawPixmap(3, 3, 16, 16, QApplication::style()->standardIcon(QStyle::SP_DirIcon).pixmap(16));
setIcon(icon);
}
setDisplayName(tr("Import Existing Project"));
......
......@@ -312,7 +312,7 @@ AssistInterface *GlslEditorWidget::createAssistInterface(
GlslEditorFactory::GlslEditorFactory()
{
setId(Constants::C_GLSLEDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_GLSLEDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_GLSLEDITOR_DISPLAY_NAME));
addMimeType(Constants::GLSL_MIMETYPE);
addMimeType(Constants::GLSL_MIMETYPE_VERT);
addMimeType(Constants::GLSL_MIMETYPE_FRAG);
......
......@@ -136,9 +136,9 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
const QString &trFile = QLatin1String("assistant_") + locale;
const QString &helpTrFile = QLatin1String("qt_help_") + locale;
if (qtr->load(trFile, qtTrPath) || qtr->load(trFile, creatorTrPath))
qApp->installTranslator(qtr);
QCoreApplication::installTranslator(qtr);
if (qhelptr->load(helpTrFile, qtTrPath) || qhelptr->load(helpTrFile, creatorTrPath))
qApp->installTranslator(qhelptr);
QCoreApplication::installTranslator(qhelptr);
}
m_helpManager = new LocalHelpManager(this);
......@@ -448,9 +448,9 @@ void HelpPlugin::modeChanged(Core::Id mode, Core::Id old)
{
Q_UNUSED(old)
if (mode == m_mode->id()) {
qApp->setOverrideCursor(Qt::WaitCursor);
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
doSetupIfNeeded();
qApp->restoreOverrideCursor();
QGuiApplication::restoreOverrideCursor();
}
}
......
......@@ -35,7 +35,7 @@
#include <QFileInfo>
#include <QUrl>
#include <QApplication>
#include <QGuiApplication>
#include <QDesktopServices>
#include <QMouseEvent>
......@@ -156,12 +156,12 @@ void HelpViewer::home()
void HelpViewer::slotLoadStarted()
{
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
}
void HelpViewer::slotLoadFinished()
{
qApp->restoreOverrideCursor();
QGuiApplication::restoreOverrideCursor();
emit sourceChanged(source());
emit loadFinished();
}
......
......@@ -184,13 +184,13 @@ void SearchWidget::search() const
void SearchWidget::searchingStarted()
{
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
}
void SearchWidget::searchingFinished(int hits)
{
Q_UNUSED(hits)
qApp->restoreOverrideCursor();
QGuiApplication::restoreOverrideCursor();
}
void SearchWidget::indexingStarted()
......
......@@ -40,7 +40,7 @@ ImageViewerFactory::ImageViewerFactory(QObject *parent) :
Core::IEditorFactory(parent)
{
setId(Constants::IMAGEVIEWER_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME));
const QList<QByteArray> supportedMimeTypes = QImageReader::supportedMimeTypes();
foreach (const QByteArray &format, supportedMimeTypes)
......
......@@ -29,7 +29,7 @@
#include "actionhandler.h"
#include "modeleditor.h"
#include <QApplication>
#include <QCoreApplication>
namespace ModelEditor {
namespace Internal {
......@@ -46,7 +46,7 @@ ModelEditorFactory::ModelEditorFactory(UiController *uiController, QObject *pare
d(new ModelEditorFactoryPrivate())
{
setId(Constants::MODEL_EDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Constants::MODEL_EDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::MODEL_EDITOR_DISPLAY_NAME));
addMimeType(Constants::MIME_TYPE_MODEL);
d->uiController = uiController;
d->actionHandler = new ActionHandler(Core::Context(Constants::MODEL_EDITOR_ID), this);
......
......@@ -631,9 +631,9 @@ IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, const
void PerforcePlugin::printPendingChanges()
{
qApp->setOverrideCursor(Qt::WaitCursor);
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
PendingChangesDialog dia(pendingChangesData(), ICore::mainWindow());
qApp->restoreOverrideCursor();
QGuiApplication::restoreOverrideCursor();
if (dia.exec() == QDialog::Accepted) {
const int i = dia.changeNumber();
QStringList args(QLatin1String("submit"));
......
......@@ -165,7 +165,7 @@ GDB 32bit | Api | Api | N/A | Win32
+ Utils::winErrorMessage(GetLastError()));
break;
}
bool creatorIs64Bit = Utils::is64BitWindowsBinary(qApp->applicationFilePath());
bool creatorIs64Bit = Utils::is64BitWindowsBinary(QCoreApplication::applicationFilePath());
if (!is64BitSystem
|| si == NoSpecialInterrupt
|| (si == Win64Interrupt && creatorIs64Bit)
......
......@@ -369,7 +369,7 @@ QWidget *SpacerField::createWidget(const QString &displayName, JsonFieldPage *pa
{
Q_UNUSED(displayName);
Q_UNUSED(page);
int size = qApp->style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing) * m_factor;
int size = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing) * m_factor;
auto w = new QWidget();
w->setMinimumSize(size, size);
......
......@@ -28,7 +28,7 @@
#ifdef Q_OS_WIN
#include <windows.h>
#include <QApplication>
#include <QCoreApplication>
#include <QTime>
/*!
......@@ -64,7 +64,7 @@ WinDebugInterface::WinDebugInterface(QObject *parent) :
QThread(parent)
{
m_instance = this;
m_creatorPid = qApp->applicationPid();
m_creatorPid = QCoreApplication::applicationPid();
setObjectName(QLatin1String("WinDebugInterfaceThread"));
}
......
......@@ -171,7 +171,7 @@ static TextDocument *createProFileDocument()
ProFileEditorFactory::ProFileEditorFactory()
{
setId(Constants::PROFILE_EDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Constants::PROFILE_EDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::PROFILE_EDITOR_DISPLAY_NAME));
addMimeType(Constants::PROFILE_MIMETYPE);
addMimeType(Constants::PROINCLUDEFILE_MIMETYPE);
addMimeType(Constants::PROFEATUREFILE_MIMETYPE);
......
......@@ -105,7 +105,7 @@ QmakeStaticData::QmakeStaticData()
// Overlay the SP_DirIcon with the custom icons
const QSize desiredSize = QSize(16, 16);
const QPixmap dirPixmap = qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(desiredSize);
const QPixmap dirPixmap = QApplication::style()->standardIcon(QStyle::SP_DirIcon).pixmap(desiredSize);
for (unsigned i = 0 ; i < count; ++i) {
const QIcon overlayIcon(QLatin1String(fileTypeDataStorage[i].icon));
QIcon folderIcon;
......
......@@ -135,7 +135,7 @@ SimpleProjectWizard::SimpleProjectWizard()
QPixmap icon(22, 22);
icon.fill(Qt::transparent);
QPainter p(&icon);
p.drawPixmap(3, 3, 16, 16, qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(16));
p.drawPixmap(3, 3, 16, 16, QApplication::style()->standardIcon(QStyle::SP_DirIcon).pixmap(16));
setIcon(icon);
}
setDisplayName(tr("Import as qmake Project (Limited Functionality)"));
......
......@@ -1030,7 +1030,7 @@ bool QmlJSEditor::isDesignModePreferred() const
QmlJSEditorFactory::QmlJSEditorFactory()
{
setId(Constants::C_QMLJSEDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME));
addMimeType(QmlJSTools::Constants::QML_MIMETYPE);
addMimeType(QmlJSTools::Constants::QMLPROJECT_MIMETYPE);
......
......@@ -124,11 +124,11 @@ void FlameGraphViewTest::testContextMenu()
int menuClicks = 0;
connect(&timer, &QTimer::timeout, this, [&]() {
auto activePopup = qApp->activePopupWidget();
auto activePopup = QApplication::activePopupWidget();
if (!activePopup || !activePopup->windowHandle()->isExposed()) {
QContextMenuEvent *event = new QContextMenuEvent(QContextMenuEvent::Mouse,
QPoint(250, 250));
qApp->postEvent(&view, event);
QCoreApplication::postEvent(&view, event);
return;
}
......
......@@ -73,7 +73,7 @@ void LocalQmlProfilerRunnerTest::testRunner1()
QTRY_VERIFY_WITH_TIMEOUT(!running, 10000);
configuration.socket = connection.analyzerSocket = LocalQmlProfilerRunner::findFreeSocket();
configuration.debuggee.executable = qApp->applicationFilePath();
configuration.debuggee.executable = QCoreApplication::applicationFilePath();
// comma is used to specify a test function. In this case, an invalid one.
configuration.debuggee.commandLineArguments = QString("-test QmlProfiler,");
......
......@@ -45,7 +45,7 @@ ResourceEditorFactory::ResourceEditorFactory(ResourceEditorPlugin *plugin) :
{
setId(RESOURCEEDITOR_ID);
setMimeTypes(QStringList(QLatin1String(C_RESOURCE_MIMETYPE)));
setDisplayName(qApp->translate("OpenWith::Editors", C_RESOURCEEDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", C_RESOURCEEDITOR_DISPLAY_NAME));
Core::FileIconProvider::registerIconOverlayForSuffix(
ProjectExplorer::Constants::FILEOVERLAY_QRC, "qrc");
......
......@@ -621,7 +621,7 @@ bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
if (ke->text().length() == 1
&& d->m_completionListView->currentIndex().isValid()
&& qApp->focusWidget() == o) {
&& QApplication::focusWidget() == o) {
const QChar &typedChar = ke->text().at(0);
AssistProposalItemInterface *item =
d->m_model->proposalItem(d->m_completionListView->currentIndex().row());
......
......@@ -58,7 +58,7 @@ PlainTextEditorFactory::PlainTextEditorFactory()
QTC_CHECK(!m_instance);
m_instance = this;
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
addMimeType(QLatin1String("text/css")); // for some reason freedesktop thinks css is text/x-csrc
addHoverHandler(new BaseHoverHandler);
......
......@@ -3488,7 +3488,7 @@ void TextEditorWidgetPrivate::disableBlockSelection(BlockSelectionUpdateKind kin
void TextEditorWidgetPrivate::resetCursorFlashTimer()
{
m_cursorVisible = true;
const int flashTime = qApp->cursorFlashTime();
const int flashTime = QApplication::cursorFlashTime();
if (flashTime > 0) {
m_cursorFlashTimer.stop();
m_cursorFlashTimer.start(flashTime / 2, q);
......
......@@ -25,7 +25,7 @@
#ifdef WITH_TESTS
#include <QApplication>
#include <QGuiApplication>
#include <QClipboard>
#include <QString>
#include <QtTest/QtTest>
......@@ -493,7 +493,7 @@ void Internal::TextEditorPlugin::testBlockSelectionCopy()
editorWidget->update();
editorWidget->copy();
QCOMPARE(qApp->clipboard()->text(), copiedText);
QCOMPARE(QGuiApplication::clipboard()->text(), copiedText);
}
Core::EditorManager::closeDocument(editor->document(), false);
}
......
......@@ -78,7 +78,7 @@ void CompilerOutputProcessor::start()
this, &CompilerOutputProcessor::handleTask);
while (!m_source.atEnd())
parser.stdError(QString::fromLocal8Bit(m_source.readLine().trimmed()));
qApp->quit();
QCoreApplication::quit();
}
void CompilerOutputProcessor::handleTask(const ProjectExplorer::Task &task)
......
......@@ -378,7 +378,7 @@ static QString example()
#else
QString::fromLatin1("$ echo \"int foo() {}\" | ./%1 && xdg-open %2.ast.png")
#endif
.arg(QFileInfo(qApp->arguments().at(0)).fileName(), QLatin1String(PATH_STDIN_FILE));
.arg(QFileInfo(QCoreApplication::arguments().at(0)).fileName(), QLatin1String(PATH_STDIN_FILE));
}
static QString parseModeToString(Document::ParseMode parseMode)
......@@ -474,7 +474,7 @@ static Document::Ptr parse(const QString &fileName, const QByteArray &source,
static void printUsage()
{
std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName())
std::cout << "Usage: " << qPrintable(QFileInfo(QCoreApplication::arguments().at(0)).fileName())
<< " [-v] [-p ast] <file1> <file2> ...\n\n";
std::cout
......
......@@ -54,7 +54,7 @@ using namespace CPlusPlus;
void printUsage()
{
std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName())
std::cout << "Usage: " << qPrintable(QFileInfo(QCoreApplication::arguments().at(0)).fileName())
<< " [-v] <file1> <file2> ...\n\n"
<< "Run the parser with the given files.\n";
}
......
......@@ -422,7 +422,7 @@ protected:
void printUsage()
{
std::cout << "Usage: " << qPrintable(QFileInfo(qApp->arguments().at(0)).fileName())
std::cout << "Usage: " << qPrintable(QFileInfo(QCoreApplication::arguments().at(0)).fileName())
<< " [-v] [path to AST.h]\n\n"
<< "Print a visitor class based on AST.h to stdout.\n\n";
const QString defaulPath = QFileInfo(QLatin1String(PATH_AST_H)).canonicalFilePath();
......
......@@ -1692,7 +1692,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir)
void printUsage()
{
const QByteArray executable = QFileInfo(qApp->arguments().first()).fileName().toLatin1();
const QByteArray executable = QFileInfo(QCoreApplication::arguments().first()).fileName().toLatin1();
std::cout << "Usage: " << executable.constData() << "\n"
<< " " << executable.constData() << " <frontend-dir> <dumpers-file>"
<< "\n\n"
......
......@@ -177,5 +177,5 @@ void CrashHandlerDialog::close()
{
if (m_ui->restartAppCheckBox->isEnabled() && m_ui->restartAppCheckBox->isChecked())
m_crashHandler->restartApplication();
qApp->quit();
QCoreApplication::quit();
}
......@@ -104,7 +104,7 @@ CrashHandlerSetup::CrashHandlerSetup(const QString &appName,
disableRestartOptionC = "--disable-restart";
const QString execDirPath = executableDirPath.isEmpty()
? qApp->applicationDirPath()