From 23ba1ea23ecbe0c4bc7cfb2fa31623d67a7d8848 Mon Sep 17 00:00:00 2001 From: con <qtc-committer@nokia.com> Date: Wed, 30 Jun 2010 15:29:48 +0200 Subject: [PATCH] Don't show the full file name in the reload prompt by default. Because paths can get long, and text wrapping in QMessageBox will do the wrong thing. Put the full file name into the details of the message box. Task-number: QTCREATORBUG-1708 --- src/libs/utils/reloadpromptutils.cpp | 20 +++++++++++++------- src/libs/utils/reloadpromptutils.h | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/libs/utils/reloadpromptutils.cpp b/src/libs/utils/reloadpromptutils.cpp index 23678a9a418..c4463b7e07e 100644 --- a/src/libs/utils/reloadpromptutils.cpp +++ b/src/libs/utils/reloadpromptutils.cpp @@ -46,19 +46,25 @@ QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer if (modified) msg = QCoreApplication::translate("Utils::reloadPrompt", - "The unsaved file %1 has been changed outside Qt Creator. Do you want to reload it and discard your changes?").arg(QDir::toNativeSeparators(fileName)); + "The unsaved file <i>%1</i> has been changed outside Qt Creator. Do you want to reload it and discard your changes?"); else msg = QCoreApplication::translate("Utils::reloadPrompt", - "The file %1 has changed outside Qt Creator. Do you want to reload it?").arg(QDir::toNativeSeparators(fileName)); - return reloadPrompt(title, msg, parent); + "The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it?"); + msg = msg.arg(QFileInfo(fileName).fileName()); + return reloadPrompt(title, msg, QDir::toNativeSeparators(fileName), parent); } QTCREATOR_UTILS_EXPORT Utils::ReloadPromptAnswer - Utils::reloadPrompt(const QString &title, const QString &prompt, QWidget *parent) + Utils::reloadPrompt(const QString &title, const QString &prompt, const QString &details, QWidget *parent) { - switch (QMessageBox::question(parent, title, prompt, - QMessageBox::Yes|QMessageBox::YesToAll|QMessageBox::No|QMessageBox::NoToAll, - QMessageBox::YesToAll)) { + QMessageBox msg(parent); + msg.setStandardButtons(QMessageBox::Yes|QMessageBox::YesToAll|QMessageBox::No|QMessageBox::NoToAll); + msg.setDefaultButton(QMessageBox::YesToAll); + msg.setWindowTitle(title); + msg.setText(prompt); + msg.setDetailedText(details); + + switch (msg.exec()) { case QMessageBox::Yes: return ReloadCurrent; case QMessageBox::YesToAll: diff --git a/src/libs/utils/reloadpromptutils.h b/src/libs/utils/reloadpromptutils.h index 8f0d3ad258c..5b379cb57fd 100644 --- a/src/libs/utils/reloadpromptutils.h +++ b/src/libs/utils/reloadpromptutils.h @@ -42,7 +42,7 @@ namespace Utils { enum ReloadPromptAnswer { ReloadCurrent, ReloadAll, ReloadSkipCurrent, ReloadNone }; QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &fileName, bool modified, QWidget *parent); -QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &title, const QString &prompt, QWidget *parent); +QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &title, const QString &prompt, const QString &details, QWidget *parent); enum FileDeletedPromptAnswer { FileDeletedClose, FileDeletedSaveAs, FileDeletedSave }; -- GitLab