Merge remote-tracking branch 'origin/2.8'

Conflicts:
	qtcreator.pri
	qtcreator.qbs

Change-Id: I1aa7506519e0f461f33921ca20ce1b51adb5783f
This commit is contained in:
Eike Ziller
2013-06-27 14:24:57 +02:00
71 changed files with 767 additions and 404 deletions

View File

@@ -31,7 +31,7 @@ QtcPlugin {
]
}
cpp.frameworks: qbs.targetOS.contains("mac") ? ["AppKit"] : undefined
cpp.frameworks: qbs.targetOS.contains("osx") ? ["AppKit"] : undefined
files: [
"basefilewizard.cpp",
@@ -241,7 +241,7 @@ QtcPlugin {
Group {
name: "ProgressManager_mac"
condition: qbs.targetOS.contains("mac")
condition: qbs.targetOS.contains("osx")
files: [
"macfullscreen.h",
"macfullscreen.mm",
@@ -251,7 +251,7 @@ QtcPlugin {
Group {
name: "ProgressManager_x11"
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("mac")
condition: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("osx")
files: [
"progressmanager/progressmanager_x11.cpp",
]

View File

@@ -29,10 +29,14 @@
#include "editormanager.h"
#include "editorview.h"
#include "findplaceholder.h"
#include "openeditorswindow.h"
#include "openeditorsview.h"
#include "openeditorsmodel.h"
#include "openwithdialog.h"
#include "outputpane.h"
#include "outputpanemanager.h"
#include "rightpane.h"
#include "documentmanager.h"
#include "icore.h"
#include "ieditor.h"
@@ -852,6 +856,99 @@ void EditorManager::addNativeDirActions(QMenu *contextMenu, const QModelIndex &e
contextMenu->addAction(d->m_openTerminalAction);
}
static void setFocusToEditorViewAndUnmaximizePanes(EditorView *view)
{
QWidget *w = 0;
if (view->currentEditor()) {
w = view->currentEditor()->widget()->focusWidget();
if (!w)
w = view->currentEditor()->widget();
} else {
w = view->focusWidget();
if (!w)
w = view;
}
w->setFocus();
ICore::raiseWindow(w);
if (OutputPanePlaceHolder::getCurrent()
&& OutputPanePlaceHolder::getCurrent()->window() == view->window()) {
// unmaximize output pane if necessary
if (OutputPanePlaceHolder::getCurrent()
&& OutputPanePlaceHolder::getCurrent()->isVisible()
&& OutputPanePlaceHolder::getCurrent()->isMaximized())
OutputPanePlaceHolder::getCurrent()->unmaximize();
}
}
/*!
Implements the logic of the escape key shortcut (ReturnToEditor).
Should only be called by the shortcut handler.
\internal
*/
void EditorManager::doEscapeKeyFocusMoveMagic()
{
// use cases to cover:
// 1. if app focus is in mode or external window without editor view (e.g. Projects, ext. Help)
// activate & raise the current editor view (can be external)
// if that is in edit mode
// activate edit mode and unmaximize output pane
// 2. if app focus is in external window with editor view
// hide find if necessary
// 2. if app focus is in mode with editor view
// if current editor view is in external window
// raise and activate current editor view
// otherwise if the current editor view is not app focus
// move focus to editor view in mode and unmaximize output pane
// otherwise if the current view is app focus
// if mode is not edit mode
// if there are extra views (find, help, output)
// hide them
// otherwise
// activate edit mode and unmaximize output pane
// otherwise (i.e. mode is edit mode)
// hide extra views (find, help, output)
EditorView *editorView = currentEditorView();
bool editorViewActive = (qApp->focusWidget() == editorView->focusWidget());
bool editorViewVisible = editorView->isVisible();
if (!editorViewActive && editorViewVisible) {
setFocusToEditorViewAndUnmaximizePanes(editorView);
return;
}
if (!editorViewActive && !editorViewVisible) {
// assumption is that editorView is in main window then
ModeManager::activateMode(Id(Constants::MODE_EDIT));
QTC_CHECK(editorView->isVisible());
setFocusToEditorViewAndUnmaximizePanes(editorView);
return;
}
if (editorViewActive) {
QTC_CHECK(editorViewVisible);
bool stuffHidden = false;
QWidget *findPane = FindToolBarPlaceHolder::getCurrent();
if (findPane && findPane->isVisibleTo(editorView)) {
findPane->hide();
stuffHidden = true;
}
QWidget *outputPane = OutputPanePlaceHolder::getCurrent();
if (outputPane && outputPane->isVisibleTo(editorView)) {
OutputPaneManager::instance()->slotHide();
stuffHidden = true;
}
QWidget *rightPane = RightPanePlaceHolder::current();
if (rightPane && rightPane->isVisibleTo(editorView)) {
RightPaneWidget::instance()->setShown(false);
stuffHidden = true;
}
if (!stuffHidden && editorView->window() == ICore::mainWindow()) {
// we are in a editor view and there's nothing to hide, switch to edit
ModeManager::activateMode(Id(Constants::MODE_EDIT));
// next call works only because editor views in main window are shared between modes
setFocusToEditorViewAndUnmaximizePanes(editorView);
}
}
}
void EditorManager::saveDocumentFromContextMenu()
{
IEditor *editor = d->m_contextMenuEditorIndex.data(Qt::UserRole).value<Core::IEditor*>();

View File

@@ -210,6 +210,7 @@ public slots:
void revertToSaved(Core::IEditor *editor);
void closeEditor();
void closeOtherEditors();
void doEscapeKeyFocusMoveMagic();
private slots:
void gotoNextDocHistory();

View File

@@ -48,7 +48,6 @@
#include "mimedatabase.h"
#include "newdialog.h"
#include "outputpanemanager.h"
#include "outputpane.h"
#include "plugindialog.h"
#include "progressmanager_p.h"
#include "progressview.h"
@@ -73,7 +72,6 @@
#endif
#include <app/app_version.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/icorelistener.h>
#include <coreplugin/inavigationwidgetfactory.h>
#include <coreplugin/settingsdatabase.h>
@@ -877,48 +875,7 @@ IDocument *MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesF
void MainWindow::setFocusToEditor()
{
bool focusWasMovedToEditor = false;
// give focus to the editor if we have one
if (IEditor *editor = EditorManager::currentEditor()) {
if (qApp->focusWidget() != editor->widget()->focusWidget()) {
QWidget *w = editor->widget()->focusWidget();
if (!w)
w = editor->widget();
w->setFocus();
focusWasMovedToEditor = w->hasFocus();
}
}
// check for some maximized pane which we want to unmaximize
if (OutputPanePlaceHolder::getCurrent()
&& OutputPanePlaceHolder::getCurrent()->isVisible()
&& OutputPanePlaceHolder::getCurrent()->isMaximized()) {
OutputPanePlaceHolder::getCurrent()->unmaximize();
return;
}
if (focusWasMovedToEditor)
return;
// check for some visible bar which we want to hide
bool stuffVisible =
(FindToolBarPlaceHolder::getCurrent() &&
FindToolBarPlaceHolder::getCurrent()->isVisible())
|| (OutputPanePlaceHolder::getCurrent() &&
OutputPanePlaceHolder::getCurrent()->isVisible())
|| (RightPanePlaceHolder::current() &&
RightPanePlaceHolder::current()->isVisible());
if (stuffVisible) {
if (FindToolBarPlaceHolder::getCurrent())
FindToolBarPlaceHolder::getCurrent()->hide();
OutputPaneManager::instance()->slotHide();
RightPaneWidget::instance()->setShown(false);
return;
}
// switch to edit mode if necessary
ModeManager::activateMode(Id(Constants::MODE_EDIT));
m_editorManager->doEscapeKeyFocusMoveMagic();
}
void MainWindow::showNewItemDialog(const QString &title,

View File

@@ -287,8 +287,8 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
}
return versionControl;
} else {
InfoBar *infoBar = curDocument->infoBar();
if (infoBar->canInfoBeAdded(vcsWarning)) {
InfoBar *infoBar = curDocument ? curDocument->infoBar() : 0;
if (infoBar && infoBar->canInfoBeAdded(vcsWarning)) {
InfoBarEntry info(vcsWarning,
tr("%1 repository was detected but %1 is not configured.")
.arg(versionControl->displayName()),

View File

@@ -36,6 +36,7 @@
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QKeyEvent>
#include <QLabel>
#include <QPushButton>
@@ -97,3 +98,15 @@ VersionDialog::VersionDialog(QWidget *parent)
layout->addWidget(copyRightLabel, 0, 1, 4, 4);
layout->addWidget(buttonBox, 4, 0, 1, 5);
}
bool VersionDialog::event(QEvent *event)
{
if (event->type() == QEvent::ShortcutOverride) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
return true;
}
}
return QDialog::event(event);
}

View File

@@ -32,6 +32,10 @@
#include <QDialog>
QT_BEGIN_NAMESPACE
class QEvent;
QT_END_NAMESPACE
namespace Core {
namespace Internal {
@@ -40,6 +44,9 @@ class VersionDialog : public QDialog
Q_OBJECT
public:
explicit VersionDialog(QWidget *parent);
bool event(QEvent *event);
};
} // namespace Internal