2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
2012-01-18 23:25:34 +01:00
|
|
|
#include "icore.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "coreconstants.h"
|
2014-09-12 14:25:51 +02:00
|
|
|
#include "jsexpander.h"
|
2011-01-06 18:26:09 +01:00
|
|
|
#include "toolsettings.h"
|
2011-02-22 15:11:50 +01:00
|
|
|
#include "mimetypesettings.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "fancytabwidget.h"
|
2012-02-14 16:43:51 +01:00
|
|
|
#include "documentmanager.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "generalsettings.h"
|
Implement theming for QtCreator
Adds a 'Theme' tab to the environment settings and a '-theme' command
line option.
A theme is a combination of colors, gradients, flags and style
information.
There are two themes:
- 'default': preserves the current default look
- 'dark': uses a more flat for many widgets, dark color theme
for everything
This does not use a stylesheet (too limited), but rather sets
the palette via C++ and modifies drawing behavior.
Overall, the look is more flat (removed some gradients and bevels).
Tested on Ubuntu 14.04 using Qt 5.4 and running on a KDE
Desktop (Oxygen base style).
For a screenshot, see
https://gist.github.com/thorbenk/5ab06bea726de0aa7473
Changes:
- Introduce class Theme, defining the interface how to access theme
specific settings. The class reads a .creatortheme file (INI file, via
QSettings)
- Define named colors in the [Palette] section
(see dark.creatortheme for example usage)
- Use either named colors of AARRGGBB (hex) in the [Colors]
section
- A file ending with .creatortheme may be supplied
to the '-theme' command line option
- A global Theme instance can be accessed via creatorTheme()
- Query colors, gradients, icons and flags from the theme
were possible (TODO: use this in more places...)
- There are very many color roles. It seems better to me
to describe the role clearly, and then to consolidate later
in the actual theme by assigning the same color.
For example, one can set the text color of the output pane button
individualy.
- Many elements are also drawn differently.
For the dark theme, I wanted to have a flatter look.
- Introduce Theme::WidgetStyle enum, for now {Original, Flat}.
- The theme specifies which kind of widget style it wants.
- The drawing code queries the theme's style flag and
switches between the original, gradient based look and
the new, flat look.
- Create some custom icons which look better on dark background
(wip, currently folder/file icons)
- Let ManhattanStyle draw some elements for non-panelwidgets, too
(open/close arrows in QTreeView, custom folder/file icons)
- For the welcomescreen, pass the WelcomeTheme class.
WelcomeTheme exposes theme colors as Q_PROPERTY accessible from
.qml
- Themes can be modified via the 'Themes' tab in the environment
settings.
TODO:
* Unify image handling
* Avoid style name references
* Fix gradients
Change-Id: I92c2050ab0fb327649ea1eff4adec973d2073944
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-10-14 19:09:48 +02:00
|
|
|
#include "themesettings.h"
|
2010-06-11 13:11:37 +02:00
|
|
|
#include "helpmanager.h"
|
2012-02-14 16:43:51 +01:00
|
|
|
#include "idocumentfactory.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "messagemanager.h"
|
|
|
|
|
#include "modemanager.h"
|
2010-09-16 12:26:28 +02:00
|
|
|
#include "outputpanemanager.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "plugindialog.h"
|
|
|
|
|
#include "vcsmanager.h"
|
|
|
|
|
#include "versiondialog.h"
|
2009-12-09 11:05:18 +01:00
|
|
|
#include "statusbarmanager.h"
|
2011-09-05 16:10:37 +02:00
|
|
|
#include "id.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "manhattanstyle.h"
|
|
|
|
|
#include "navigationwidget.h"
|
|
|
|
|
#include "rightpane.h"
|
|
|
|
|
#include "editormanager/ieditorfactory.h"
|
2009-12-08 19:14:39 +01:00
|
|
|
#include "statusbarwidget.h"
|
2015-08-14 13:25:31 +02:00
|
|
|
#include "systemsettings.h"
|
2011-08-17 12:54:58 +02:00
|
|
|
#include "externaltoolmanager.h"
|
2010-02-22 14:28:37 +01:00
|
|
|
#include "editormanager/systemeditor.h"
|
2014-07-17 17:04:02 +02:00
|
|
|
#include "windowsupport.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-08-30 15:57:00 +02:00
|
|
|
#include <app/app_version.h>
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager_p.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
|
|
|
|
#include <coreplugin/dialogs/newdialog.h>
|
|
|
|
|
#include <coreplugin/dialogs/settingsdialog.h>
|
|
|
|
|
#include <coreplugin/dialogs/shortcutsettings.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2014-07-18 17:11:57 +02:00
|
|
|
#include <coreplugin/editormanager/editormanager_p.h>
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/icorelistener.h>
|
2010-07-15 12:24:03 +02:00
|
|
|
#include <coreplugin/inavigationwidgetfactory.h>
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <coreplugin/progressmanager/progressmanager_p.h>
|
|
|
|
|
#include <coreplugin/progressmanager/progressview.h>
|
2009-05-19 19:20:53 +02:00
|
|
|
#include <coreplugin/settingsdatabase.h>
|
2015-02-18 18:00:28 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2014-09-12 12:52:34 +02:00
|
|
|
#include <utils/algorithm.h>
|
2012-08-23 13:47:15 +02:00
|
|
|
#include <utils/historycompleter.h>
|
2012-11-06 16:00:38 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2015-02-04 09:32:46 +01:00
|
|
|
#include <utils/mimetypes/mimedatabase.h>
|
2014-06-27 15:15:09 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2009-07-15 12:38:45 +02:00
|
|
|
#include <utils/stylehelper.h>
|
Implement theming for QtCreator
Adds a 'Theme' tab to the environment settings and a '-theme' command
line option.
A theme is a combination of colors, gradients, flags and style
information.
There are two themes:
- 'default': preserves the current default look
- 'dark': uses a more flat for many widgets, dark color theme
for everything
This does not use a stylesheet (too limited), but rather sets
the palette via C++ and modifies drawing behavior.
Overall, the look is more flat (removed some gradients and bevels).
Tested on Ubuntu 14.04 using Qt 5.4 and running on a KDE
Desktop (Oxygen base style).
For a screenshot, see
https://gist.github.com/thorbenk/5ab06bea726de0aa7473
Changes:
- Introduce class Theme, defining the interface how to access theme
specific settings. The class reads a .creatortheme file (INI file, via
QSettings)
- Define named colors in the [Palette] section
(see dark.creatortheme for example usage)
- Use either named colors of AARRGGBB (hex) in the [Colors]
section
- A file ending with .creatortheme may be supplied
to the '-theme' command line option
- A global Theme instance can be accessed via creatorTheme()
- Query colors, gradients, icons and flags from the theme
were possible (TODO: use this in more places...)
- There are very many color roles. It seems better to me
to describe the role clearly, and then to consolidate later
in the actual theme by assigning the same color.
For example, one can set the text color of the output pane button
individualy.
- Many elements are also drawn differently.
For the dark theme, I wanted to have a flatter look.
- Introduce Theme::WidgetStyle enum, for now {Original, Flat}.
- The theme specifies which kind of widget style it wants.
- The drawing code queries the theme's style flag and
switches between the original, gradient based look and
the new, flat look.
- Create some custom icons which look better on dark background
(wip, currently folder/file icons)
- Let ManhattanStyle draw some elements for non-panelwidgets, too
(open/close arrows in QTreeView, custom folder/file icons)
- For the welcomescreen, pass the WelcomeTheme class.
WelcomeTheme exposes theme colors as Q_PROPERTY accessible from
.qml
- Themes can be modified via the 'Themes' tab in the environment
settings.
TODO:
* Unify image handling
* Avoid style name references
* Fix gradients
Change-Id: I92c2050ab0fb327649ea1eff4adec973d2073944
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-10-14 19:09:48 +02:00
|
|
|
#include <utils/theme/theme.h>
|
2010-07-13 16:42:36 +02:00
|
|
|
#include <utils/stringutils.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QCloseEvent>
|
2015-02-18 18:00:28 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QMenuBar>
|
2015-02-18 18:00:28 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPrinter>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPushButton>
|
2015-02-18 18:00:28 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QStatusBar>
|
2012-10-19 13:01:52 +02:00
|
|
|
#include <QStyleFactory>
|
2015-02-18 18:00:28 +01:00
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QUrl>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-03-04 16:07:44 +01:00
|
|
|
using namespace ExtensionSystem;
|
2015-02-18 18:00:28 +01:00
|
|
|
using namespace Utils;
|
2014-03-04 16:07:44 +01:00
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
namespace Internal {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-02-10 10:56:22 +01:00
|
|
|
enum { debugMainWindow = 0 };
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
MainWindow::MainWindow() :
|
2015-02-18 18:00:28 +01:00
|
|
|
AppMainWindow(),
|
2012-01-18 23:25:34 +01:00
|
|
|
m_coreImpl(new ICore(this)),
|
2015-08-07 17:21:38 +02:00
|
|
|
m_lowPrioAdditionalContexts(Constants::C_GLOBAL),
|
2014-03-04 16:07:44 +01:00
|
|
|
m_settingsDatabase(new SettingsDatabase(QFileInfo(PluginManager::settings()->fileName()).path(),
|
2009-05-19 19:20:53 +02:00
|
|
|
QLatin1String("QtCreator"),
|
|
|
|
|
this)),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_printer(0),
|
2014-07-17 17:04:02 +02:00
|
|
|
m_windowSupport(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_editorManager(0),
|
2011-01-21 10:58:06 +01:00
|
|
|
m_externalToolManager(0),
|
2013-09-03 15:18:37 +02:00
|
|
|
m_progressManager(new ProgressManagerPrivate),
|
2014-10-13 12:49:05 +02:00
|
|
|
m_jsExpander(new JsExpander),
|
2010-12-07 17:34:43 +01:00
|
|
|
m_vcsManager(new VcsManager),
|
2009-12-09 11:05:18 +01:00
|
|
|
m_statusBarManager(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_modeManager(0),
|
2010-06-11 13:11:37 +02:00
|
|
|
m_helpManager(new HelpManager),
|
2013-04-11 12:22:10 +02:00
|
|
|
m_modeStack(new FancyTabWidget(this)),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_navigationWidget(0),
|
|
|
|
|
m_rightPaneWidget(0),
|
2008-12-03 17:38:53 +01:00
|
|
|
m_versionDialog(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_generalSettings(new GeneralSettings),
|
2015-08-14 13:25:31 +02:00
|
|
|
m_systemSettings(new SystemSettings),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_shortcutSettings(new ShortcutSettings),
|
2011-01-06 18:26:09 +01:00
|
|
|
m_toolSettings(new ToolSettings),
|
2011-02-22 15:11:50 +01:00
|
|
|
m_mimeTypeSettings(new MimeTypeSettings),
|
2010-02-22 14:28:37 +01:00
|
|
|
m_systemEditor(new SystemEditor),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_focusToEditor(0),
|
|
|
|
|
m_newAction(0),
|
|
|
|
|
m_openAction(0),
|
|
|
|
|
m_openWithAction(0),
|
|
|
|
|
m_saveAllAction(0),
|
|
|
|
|
m_exitAction(0),
|
|
|
|
|
m_optionsAction(0),
|
|
|
|
|
m_toggleSideBarAction(0),
|
|
|
|
|
m_toggleSideBarButton(new QToolButton)
|
|
|
|
|
{
|
2012-02-14 16:43:51 +01:00
|
|
|
(void) new DocumentManager(this);
|
2009-01-26 14:13:15 +01:00
|
|
|
OutputPaneManager::create();
|
|
|
|
|
|
2015-02-18 18:00:28 +01:00
|
|
|
HistoryCompleter::setSettings(PluginManager::settings());
|
2012-08-23 13:47:15 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
setWindowTitle(tr("Qt Creator"));
|
2015-02-18 18:00:28 +01:00
|
|
|
if (HostOsInfo::isLinuxHost())
|
2012-11-06 16:00:38 +01:00
|
|
|
QApplication::setWindowIcon(QIcon(QLatin1String(Constants::ICON_QTLOGO_128)));
|
2009-01-26 15:46:11 +01:00
|
|
|
QCoreApplication::setApplicationName(QLatin1String("QtCreator"));
|
2014-11-16 10:52:41 +02:00
|
|
|
QCoreApplication::setApplicationVersion(QLatin1String(Constants::IDE_VERSION_LONG));
|
2011-11-23 16:56:50 +01:00
|
|
|
QCoreApplication::setOrganizationName(QLatin1String(Constants::IDE_SETTINGSVARIANT_STR));
|
2010-07-30 22:16:59 +02:00
|
|
|
QString baseName = QApplication::style()->objectName();
|
2014-11-04 11:17:42 +02:00
|
|
|
// Sometimes we get the standard windows 95 style as a fallback
|
2015-02-18 18:00:28 +01:00
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()
|
2014-11-04 11:17:42 +02:00
|
|
|
&& baseName == QLatin1String("windows")) {
|
|
|
|
|
baseName = QLatin1String("fusion");
|
2009-01-26 15:46:11 +01:00
|
|
|
}
|
2014-10-20 22:32:55 +02:00
|
|
|
|
|
|
|
|
// if the user has specified as base style in the theme settings,
|
|
|
|
|
// prefer that
|
|
|
|
|
const QStringList available = QStyleFactory::keys();
|
|
|
|
|
foreach (const QString &s, Utils::creatorTheme()->preferredStyles()) {
|
|
|
|
|
if (available.contains(s, Qt::CaseInsensitive)) {
|
|
|
|
|
baseName = s;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QApplication::setStyle(new ManhattanStyle(baseName));
|
2009-01-26 15:46:11 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
setDockNestingEnabled(true);
|
|
|
|
|
|
|
|
|
|
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
|
|
|
|
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
|
|
|
|
|
|
2013-04-11 12:22:10 +02:00
|
|
|
m_modeManager = new ModeManager(this, m_modeStack);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
registerDefaultContainers();
|
|
|
|
|
registerDefaultActions();
|
|
|
|
|
|
|
|
|
|
m_navigationWidget = new NavigationWidget(m_toggleSideBarAction);
|
|
|
|
|
m_rightPaneWidget = new RightPaneWidget();
|
|
|
|
|
|
2009-12-09 11:05:18 +01:00
|
|
|
m_statusBarManager = new StatusBarManager(this);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_messageManager = new MessageManager;
|
2012-01-24 15:36:40 +01:00
|
|
|
m_editorManager = new EditorManager(this);
|
|
|
|
|
m_externalToolManager = new ExternalToolManager();
|
2008-12-02 12:01:29 +01:00
|
|
|
setCentralWidget(m_modeStack);
|
|
|
|
|
|
2013-03-22 14:14:21 +01:00
|
|
|
m_progressManager->progressView()->setParent(this);
|
|
|
|
|
m_progressManager->progressView()->setReferenceWidget(m_modeStack->statusBar());
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)),
|
|
|
|
|
this, SLOT(updateFocusWidget(QWidget*,QWidget*)));
|
|
|
|
|
// Add a small Toolbutton for toggling the navigation widget
|
|
|
|
|
statusBar()->insertPermanentWidget(0, m_toggleSideBarButton);
|
|
|
|
|
|
|
|
|
|
// setUnifiedTitleAndToolBarOnMac(true);
|
2015-02-18 18:00:28 +01:00
|
|
|
//if (HostOsInfo::isAnyUnixHost())
|
2013-03-14 10:44:46 +01:00
|
|
|
//signal(SIGINT, handleSigInt);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
statusBar()->setProperty("p_styled", true);
|
2014-07-07 16:16:49 +02:00
|
|
|
|
2015-06-04 12:35:59 +02:00
|
|
|
auto dropSupport = new DropSupport(this, [](QDropEvent *event, DropSupport *) {
|
2014-09-04 20:43:09 +02:00
|
|
|
return event->source() == 0; // only accept drops from the "outside" (e.g. file manager)
|
|
|
|
|
});
|
2015-06-04 12:35:59 +02:00
|
|
|
connect(dropSupport, &DropSupport::filesDropped,
|
2014-09-12 12:52:34 +02:00
|
|
|
this, &MainWindow::openDroppedFiles);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-01-20 15:38:51 +01:00
|
|
|
void MainWindow::setSidebarVisible(bool visible)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
if (NavigationWidgetPlaceHolder::current()) {
|
2009-01-20 15:38:51 +01:00
|
|
|
if (m_navigationWidget->isSuppressed() && visible) {
|
2008-12-02 12:01:29 +01:00
|
|
|
m_navigationWidget->setShown(true);
|
|
|
|
|
m_navigationWidget->setSuppressed(false);
|
|
|
|
|
} else {
|
2009-01-20 15:38:51 +01:00
|
|
|
m_navigationWidget->setShown(visible);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::setSuppressNavigationWidget(bool suppress)
|
|
|
|
|
{
|
2009-01-20 17:14:00 +01:00
|
|
|
if (NavigationWidgetPlaceHolder::current())
|
2008-12-02 12:01:29 +01:00
|
|
|
m_navigationWidget->setSuppressed(suppress);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-25 18:44:54 +01:00
|
|
|
void MainWindow::setOverrideColor(const QColor &color)
|
|
|
|
|
{
|
|
|
|
|
m_overrideColor = color;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
2014-07-22 10:41:28 +02:00
|
|
|
// explicitly delete window support, because that calls methods from ICore that call methods
|
|
|
|
|
// from mainwindow, so mainwindow still needs to be alive
|
|
|
|
|
delete m_windowSupport;
|
|
|
|
|
m_windowSupport = 0;
|
|
|
|
|
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::removeObject(m_shortcutSettings);
|
|
|
|
|
PluginManager::removeObject(m_generalSettings);
|
2015-08-14 13:25:31 +02:00
|
|
|
PluginManager::removeObject(m_systemSettings);
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::removeObject(m_toolSettings);
|
|
|
|
|
PluginManager::removeObject(m_mimeTypeSettings);
|
|
|
|
|
PluginManager::removeObject(m_systemEditor);
|
2011-01-21 10:58:06 +01:00
|
|
|
delete m_externalToolManager;
|
|
|
|
|
m_externalToolManager = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_messageManager;
|
|
|
|
|
m_messageManager = 0;
|
|
|
|
|
delete m_shortcutSettings;
|
|
|
|
|
m_shortcutSettings = 0;
|
|
|
|
|
delete m_generalSettings;
|
|
|
|
|
m_generalSettings = 0;
|
2015-08-14 13:25:31 +02:00
|
|
|
delete m_systemSettings;
|
|
|
|
|
m_systemSettings = 0;
|
2011-01-06 18:26:09 +01:00
|
|
|
delete m_toolSettings;
|
|
|
|
|
m_toolSettings = 0;
|
2011-02-22 15:11:50 +01:00
|
|
|
delete m_mimeTypeSettings;
|
|
|
|
|
m_mimeTypeSettings = 0;
|
2010-02-22 14:28:37 +01:00
|
|
|
delete m_systemEditor;
|
|
|
|
|
m_systemEditor = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_printer;
|
|
|
|
|
m_printer = 0;
|
|
|
|
|
delete m_vcsManager;
|
|
|
|
|
m_vcsManager = 0;
|
2009-12-09 11:05:18 +01:00
|
|
|
//we need to delete editormanager and statusbarmanager explicitly before the end of the destructor,
|
2008-12-02 12:01:29 +01:00
|
|
|
//because they might trigger stuff that tries to access data from editorwindow, like removeContextWidget
|
|
|
|
|
|
|
|
|
|
// All modes are now gone
|
2009-01-26 14:13:15 +01:00
|
|
|
OutputPaneManager::destroy();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-26 14:13:15 +01:00
|
|
|
// Now that the OutputPaneManager is gone, is a good time to delete the view
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::removeObject(m_outputView);
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_outputView;
|
|
|
|
|
|
|
|
|
|
delete m_editorManager;
|
|
|
|
|
m_editorManager = 0;
|
|
|
|
|
delete m_progressManager;
|
|
|
|
|
m_progressManager = 0;
|
2013-03-22 14:14:21 +01:00
|
|
|
delete m_statusBarManager;
|
|
|
|
|
m_statusBarManager = 0;
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::removeObject(m_coreImpl);
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_coreImpl;
|
|
|
|
|
m_coreImpl = 0;
|
|
|
|
|
|
|
|
|
|
delete m_rightPaneWidget;
|
|
|
|
|
m_rightPaneWidget = 0;
|
|
|
|
|
|
|
|
|
|
delete m_modeManager;
|
|
|
|
|
m_modeManager = 0;
|
2010-06-11 13:11:37 +02:00
|
|
|
|
|
|
|
|
delete m_helpManager;
|
|
|
|
|
m_helpManager = 0;
|
2014-09-12 14:25:51 +02:00
|
|
|
delete m_jsExpander;
|
|
|
|
|
m_jsExpander = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-01-26 14:25:03 +01:00
|
|
|
bool MainWindow::init(QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(errorMessage)
|
2009-01-26 14:25:03 +01:00
|
|
|
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::addObject(m_coreImpl);
|
2009-12-09 11:05:18 +01:00
|
|
|
m_statusBarManager->init();
|
2008-12-02 12:01:29 +01:00
|
|
|
m_modeManager->init();
|
2013-03-22 14:14:21 +01:00
|
|
|
m_progressManager->init(); // needs the status bar manager
|
2009-12-15 16:42:56 +01:00
|
|
|
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::addObject(m_generalSettings);
|
2015-08-14 13:25:31 +02:00
|
|
|
PluginManager::addObject(m_systemSettings);
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::addObject(m_shortcutSettings);
|
|
|
|
|
PluginManager::addObject(m_toolSettings);
|
|
|
|
|
PluginManager::addObject(m_mimeTypeSettings);
|
|
|
|
|
PluginManager::addObject(m_systemEditor);
|
2010-02-22 14:28:37 +01:00
|
|
|
|
2009-01-26 14:13:15 +01:00
|
|
|
// Add widget to the bottom, we create the view here instead of inside the
|
2010-01-11 10:22:55 +01:00
|
|
|
// OutputPaneManager, since the StatusBarManager needs to be initialized before
|
2014-11-16 10:52:41 +02:00
|
|
|
m_outputView = new StatusBarWidget;
|
2009-01-26 14:49:26 +01:00
|
|
|
m_outputView->setWidget(OutputPaneManager::instance()->buttonsWidget());
|
2014-11-16 10:52:41 +02:00
|
|
|
m_outputView->setPosition(StatusBarWidget::Second);
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::addObject(m_outputView);
|
2013-09-05 01:52:17 +02:00
|
|
|
MessageManager::init();
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::extensionsInitialized()
|
|
|
|
|
{
|
2015-02-04 16:29:42 +01:00
|
|
|
MimeTypeSettings::restoreSettings();
|
2014-07-17 17:04:02 +02:00
|
|
|
m_windowSupport = new WindowSupport(this, Context("Core.MainWindow"));
|
2014-07-18 10:35:17 +02:00
|
|
|
m_windowSupport->setCloseActionEnabled(false);
|
2009-12-09 11:05:18 +01:00
|
|
|
m_statusBarManager->extensionsInitalized();
|
2009-01-26 14:13:15 +01:00
|
|
|
OutputPaneManager::instance()->init();
|
2009-11-11 14:32:54 +01:00
|
|
|
m_vcsManager->extensionsInitialized();
|
2015-02-03 23:48:19 +02:00
|
|
|
m_navigationWidget->setFactories(PluginManager::getObjects<INavigationWidgetFactory>());
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
readSettings();
|
|
|
|
|
updateContext();
|
|
|
|
|
|
2009-06-12 18:06:34 +02:00
|
|
|
emit m_coreImpl->coreAboutToOpen();
|
2014-02-25 15:33:00 +02:00
|
|
|
// Delay restoreWindowState, since it is overridden by LayoutRequest event
|
|
|
|
|
QTimer::singleShot(0, this, SLOT(restoreWindowState()));
|
2014-02-27 13:45:39 +01:00
|
|
|
QTimer::singleShot(0, m_coreImpl, SIGNAL(coreOpened()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
|
{
|
2012-08-17 09:09:15 +02:00
|
|
|
ICore::saveSettings();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Save opened files
|
2014-01-21 13:25:19 +01:00
|
|
|
if (!DocumentManager::saveAllModifiedDocuments()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
event->ignore();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QList<ICoreListener *> listeners =
|
2015-02-03 23:48:19 +02:00
|
|
|
PluginManager::getObjects<ICoreListener>();
|
2008-12-02 12:01:29 +01:00
|
|
|
foreach (ICoreListener *listener, listeners) {
|
|
|
|
|
if (!listener->coreAboutToClose()) {
|
|
|
|
|
event->ignore();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit m_coreImpl->coreAboutToClose();
|
2010-08-11 14:59:04 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
writeSettings();
|
2010-08-11 14:59:04 +02:00
|
|
|
|
|
|
|
|
m_navigationWidget->closeSubWidgets();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
event->accept();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-04 12:35:59 +02:00
|
|
|
void MainWindow::openDroppedFiles(const QList<DropSupport::FileSpec> &files)
|
2010-12-10 14:49:06 +01:00
|
|
|
{
|
2013-04-15 12:53:34 +02:00
|
|
|
raiseWindow();
|
2014-09-12 12:52:34 +02:00
|
|
|
QStringList filePaths = Utils::transform(files,
|
2015-06-04 12:35:59 +02:00
|
|
|
[](const DropSupport::FileSpec &spec) -> QString {
|
2014-09-12 12:52:34 +02:00
|
|
|
return spec.filePath;
|
|
|
|
|
});
|
|
|
|
|
openFiles(filePaths, ICore::SwitchMode);
|
2010-12-10 14:49:06 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
IContext *MainWindow::currentContextObject() const
|
|
|
|
|
{
|
2013-05-07 19:03:22 +02:00
|
|
|
return m_activeContext.isEmpty() ? 0 : m_activeContext.first();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStatusBar *MainWindow::statusBar() const
|
|
|
|
|
{
|
|
|
|
|
return m_modeStack->statusBar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::registerDefaultContainers()
|
|
|
|
|
{
|
2012-05-24 13:49:06 +02:00
|
|
|
ActionContainer *menubar = ActionManager::createMenuBar(Constants::MENU_BAR);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-18 18:00:28 +01:00
|
|
|
if (!HostOsInfo::isMacHost()) // System menu bar on Mac
|
2012-11-06 16:00:38 +01:00
|
|
|
setMenuBar(menubar->menuBar());
|
2008-12-02 12:01:29 +01:00
|
|
|
menubar->appendGroup(Constants::G_FILE);
|
|
|
|
|
menubar->appendGroup(Constants::G_EDIT);
|
|
|
|
|
menubar->appendGroup(Constants::G_VIEW);
|
|
|
|
|
menubar->appendGroup(Constants::G_TOOLS);
|
|
|
|
|
menubar->appendGroup(Constants::G_WINDOW);
|
|
|
|
|
menubar->appendGroup(Constants::G_HELP);
|
|
|
|
|
|
2009-01-23 13:03:36 +01:00
|
|
|
// File Menu
|
2012-05-24 13:49:06 +02:00
|
|
|
ActionContainer *filemenu = ActionManager::createMenu(Constants::M_FILE);
|
2008-12-02 12:01:29 +01:00
|
|
|
menubar->addMenu(filemenu, Constants::G_FILE);
|
|
|
|
|
filemenu->menu()->setTitle(tr("&File"));
|
|
|
|
|
filemenu->appendGroup(Constants::G_FILE_NEW);
|
|
|
|
|
filemenu->appendGroup(Constants::G_FILE_OPEN);
|
|
|
|
|
filemenu->appendGroup(Constants::G_FILE_PROJECT);
|
|
|
|
|
filemenu->appendGroup(Constants::G_FILE_SAVE);
|
|
|
|
|
filemenu->appendGroup(Constants::G_FILE_CLOSE);
|
|
|
|
|
filemenu->appendGroup(Constants::G_FILE_PRINT);
|
|
|
|
|
filemenu->appendGroup(Constants::G_FILE_OTHER);
|
2015-02-18 18:00:28 +01:00
|
|
|
connect(filemenu->menu(), &QMenu::aboutToShow, this, &MainWindow::aboutToShowRecentFiles);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
|
2009-01-23 13:03:36 +01:00
|
|
|
// Edit Menu
|
2012-05-24 13:49:06 +02:00
|
|
|
ActionContainer *medit = ActionManager::createMenu(Constants::M_EDIT);
|
2008-12-02 12:01:29 +01:00
|
|
|
menubar->addMenu(medit, Constants::G_EDIT);
|
|
|
|
|
medit->menu()->setTitle(tr("&Edit"));
|
|
|
|
|
medit->appendGroup(Constants::G_EDIT_UNDOREDO);
|
|
|
|
|
medit->appendGroup(Constants::G_EDIT_COPYPASTE);
|
|
|
|
|
medit->appendGroup(Constants::G_EDIT_SELECTALL);
|
2009-01-20 09:48:50 +01:00
|
|
|
medit->appendGroup(Constants::G_EDIT_ADVANCED);
|
2009-01-13 19:02:54 +01:00
|
|
|
medit->appendGroup(Constants::G_EDIT_FIND);
|
2008-12-02 12:01:29 +01:00
|
|
|
medit->appendGroup(Constants::G_EDIT_OTHER);
|
|
|
|
|
|
2009-01-23 13:03:36 +01:00
|
|
|
// Tools Menu
|
2012-05-24 13:49:06 +02:00
|
|
|
ActionContainer *ac = ActionManager::createMenu(Constants::M_TOOLS);
|
2008-12-02 12:01:29 +01:00
|
|
|
menubar->addMenu(ac, Constants::G_TOOLS);
|
|
|
|
|
ac->menu()->setTitle(tr("&Tools"));
|
|
|
|
|
|
2009-01-23 13:03:36 +01:00
|
|
|
// Window Menu
|
2012-05-24 13:49:06 +02:00
|
|
|
ActionContainer *mwindow = ActionManager::createMenu(Constants::M_WINDOW);
|
2008-12-02 12:01:29 +01:00
|
|
|
menubar->addMenu(mwindow, Constants::G_WINDOW);
|
|
|
|
|
mwindow->menu()->setTitle(tr("&Window"));
|
|
|
|
|
mwindow->appendGroup(Constants::G_WINDOW_SIZE);
|
2010-04-20 16:46:35 +02:00
|
|
|
mwindow->appendGroup(Constants::G_WINDOW_VIEWS);
|
2008-12-02 12:01:29 +01:00
|
|
|
mwindow->appendGroup(Constants::G_WINDOW_PANES);
|
|
|
|
|
mwindow->appendGroup(Constants::G_WINDOW_SPLIT);
|
|
|
|
|
mwindow->appendGroup(Constants::G_WINDOW_NAVIGATE);
|
2014-08-25 17:28:25 +02:00
|
|
|
mwindow->appendGroup(Constants::G_WINDOW_LIST);
|
2008-12-02 12:01:29 +01:00
|
|
|
mwindow->appendGroup(Constants::G_WINDOW_OTHER);
|
|
|
|
|
|
2009-01-23 13:03:36 +01:00
|
|
|
// Help Menu
|
2012-05-24 13:49:06 +02:00
|
|
|
ac = ActionManager::createMenu(Constants::M_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
menubar->addMenu(ac, Constants::G_HELP);
|
|
|
|
|
ac->menu()->setTitle(tr("&Help"));
|
2009-01-13 19:02:54 +01:00
|
|
|
ac->appendGroup(Constants::G_HELP_HELP);
|
2014-01-24 09:51:52 +01:00
|
|
|
ac->appendGroup(Constants::G_HELP_SUPPORT);
|
2009-01-13 19:02:54 +01:00
|
|
|
ac->appendGroup(Constants::G_HELP_ABOUT);
|
2015-05-19 15:15:15 +02:00
|
|
|
ac->appendGroup(Constants::G_HELP_UPDATES);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::registerDefaultActions()
|
|
|
|
|
{
|
2012-05-24 13:49:06 +02:00
|
|
|
ActionContainer *mfile = ActionManager::actionContainer(Constants::M_FILE);
|
|
|
|
|
ActionContainer *medit = ActionManager::actionContainer(Constants::M_EDIT);
|
|
|
|
|
ActionContainer *mtools = ActionManager::actionContainer(Constants::M_TOOLS);
|
|
|
|
|
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
|
|
|
|
|
ActionContainer *mhelp = ActionManager::actionContainer(Constants::M_HELP);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// File menu separators
|
2015-02-26 13:58:00 +01:00
|
|
|
mfile->addSeparator(Constants::G_FILE_SAVE);
|
|
|
|
|
mfile->addSeparator(Constants::G_FILE_PRINT);
|
|
|
|
|
mfile->addSeparator(Constants::G_FILE_CLOSE);
|
|
|
|
|
mfile->addSeparator(Constants::G_FILE_OTHER);
|
2008-12-02 12:01:29 +01:00
|
|
|
// Edit menu separators
|
2015-02-26 13:58:00 +01:00
|
|
|
medit->addSeparator(Constants::G_EDIT_COPYPASTE);
|
|
|
|
|
medit->addSeparator(Constants::G_EDIT_SELECTALL);
|
|
|
|
|
medit->addSeparator(Constants::G_EDIT_FIND);
|
|
|
|
|
medit->addSeparator(Constants::G_EDIT_ADVANCED);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Return to editor shortcut: Note this requires Qt to fix up
|
2008-12-02 12:01:29 +01:00
|
|
|
// handling of shortcut overrides in menus, item views, combos....
|
2014-02-28 17:33:48 +01:00
|
|
|
m_focusToEditor = new QAction(tr("Return to Editor"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
Command *cmd = ActionManager::registerAction(m_focusToEditor, Constants::S_RETURNTOEDITOR);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
|
2014-02-28 17:33:48 +01:00
|
|
|
connect(m_focusToEditor, SIGNAL(triggered()), this, SLOT(setFocusToEditor()));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// New File Action
|
2012-06-05 14:22:20 +02:00
|
|
|
QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE)));
|
2010-03-17 14:58:27 +01:00
|
|
|
m_newAction = new QAction(icon, tr("&New File or Project..."), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_newAction, Constants::NEW);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::New);
|
|
|
|
|
mfile->addAction(cmd, Constants::G_FILE_NEW);
|
2015-06-01 23:40:38 +03:00
|
|
|
connect(m_newAction, &QAction::triggered, this, [this]() {
|
2015-05-29 13:24:02 +02:00
|
|
|
ICore::showNewItemDialog(tr("New File or Project", "Title of dialog"),
|
|
|
|
|
IWizardFactory::allWizardFactories(), QString());
|
|
|
|
|
});
|
|
|
|
|
connect(ICore::instance(), &ICore::newItemDialogRunningChanged, m_newAction, [this]() {
|
|
|
|
|
m_newAction->setEnabled(!ICore::isNewItemDialogRunning());
|
|
|
|
|
});
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Open Action
|
2011-12-22 14:44:14 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("document-open"), QIcon(QLatin1String(Constants::ICON_OPENFILE)));
|
2010-03-17 14:58:27 +01:00
|
|
|
m_openAction = new QAction(icon, tr("&Open File or Project..."), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_openAction, Constants::OPEN);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Open);
|
|
|
|
|
mfile->addAction(cmd, Constants::G_FILE_OPEN);
|
|
|
|
|
connect(m_openAction, SIGNAL(triggered()), this, SLOT(openFile()));
|
|
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Open With Action
|
2009-11-12 15:48:59 +01:00
|
|
|
m_openWithAction = new QAction(tr("Open File &With..."), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_openWithAction, Constants::OPEN_WITH);
|
2008-12-02 12:01:29 +01:00
|
|
|
mfile->addAction(cmd, Constants::G_FILE_OPEN);
|
|
|
|
|
connect(m_openWithAction, SIGNAL(triggered()), this, SLOT(openFileWith()));
|
|
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// File->Recent Files Menu
|
2012-05-24 13:49:06 +02:00
|
|
|
ActionContainer *ac = ActionManager::createMenu(Constants::M_FILE_RECENTFILES);
|
2008-12-02 12:01:29 +01:00
|
|
|
mfile->addMenu(ac, Constants::G_FILE_OPEN);
|
2009-11-12 15:48:59 +01:00
|
|
|
ac->menu()->setTitle(tr("Recent &Files"));
|
2010-12-16 11:49:47 +01:00
|
|
|
ac->setOnAllDisabledBehavior(ActionContainer::Show);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Save Action
|
2011-12-22 14:44:14 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("document-save"), QIcon(QLatin1String(Constants::ICON_SAVEFILE)));
|
2010-03-17 14:58:27 +01:00
|
|
|
QAction *tmpaction = new QAction(icon, tr("&Save"), this);
|
2011-01-31 15:18:16 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::SAVE);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Save);
|
2009-01-14 13:17:53 +01:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
2012-01-06 17:13:18 +01:00
|
|
|
cmd->setDescription(tr("Save"));
|
2008-12-02 12:01:29 +01:00
|
|
|
mfile->addAction(cmd, Constants::G_FILE_SAVE);
|
|
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Save As Action
|
2010-03-19 15:25:20 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("document-save-as"));
|
|
|
|
|
tmpaction = new QAction(icon, tr("Save &As..."), this);
|
2011-01-31 15:18:16 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+S") : QString()));
|
2009-01-14 13:17:53 +01:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
2012-01-06 17:13:18 +01:00
|
|
|
cmd->setDescription(tr("Save As..."));
|
2008-12-02 12:01:29 +01:00
|
|
|
mfile->addAction(cmd, Constants::G_FILE_SAVE);
|
|
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// SaveAll Action
|
2008-12-02 12:01:29 +01:00
|
|
|
m_saveAllAction = new QAction(tr("Save A&ll"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_saveAllAction, Constants::SAVEALL);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("Ctrl+Shift+S")));
|
2008-12-02 12:01:29 +01:00
|
|
|
mfile->addAction(cmd, Constants::G_FILE_SAVE);
|
|
|
|
|
connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll()));
|
|
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Print Action
|
2010-03-17 14:58:27 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("document-print"));
|
|
|
|
|
tmpaction = new QAction(icon, tr("&Print..."), this);
|
2011-01-31 15:18:16 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::PRINT);
|
2010-04-27 10:48:13 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Print);
|
2008-12-02 12:01:29 +01:00
|
|
|
mfile->addAction(cmd, Constants::G_FILE_PRINT);
|
|
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Exit Action
|
2010-03-19 15:25:20 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("application-exit"));
|
|
|
|
|
m_exitAction = new QAction(icon, tr("E&xit"), this);
|
2014-11-07 11:41:07 +01:00
|
|
|
m_exitAction->setMenuRole(QAction::QuitRole);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Q")));
|
|
|
|
|
mfile->addAction(cmd, Constants::G_FILE_OTHER);
|
|
|
|
|
connect(m_exitAction, SIGNAL(triggered()), this, SLOT(exit()));
|
|
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Undo Action
|
2011-12-22 14:44:14 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("edit-undo"), QIcon(QLatin1String(Constants::ICON_UNDO)));
|
2010-03-17 14:58:27 +01:00
|
|
|
tmpaction = new QAction(icon, tr("&Undo"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::UNDO);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Undo);
|
2009-01-14 13:17:53 +01:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
2012-01-06 17:13:18 +01:00
|
|
|
cmd->setDescription(tr("Undo"));
|
2008-12-02 12:01:29 +01:00
|
|
|
medit->addAction(cmd, Constants::G_EDIT_UNDOREDO);
|
2009-03-03 17:19:34 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Redo Action
|
2011-12-22 14:44:14 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("edit-redo"), QIcon(QLatin1String(Constants::ICON_REDO)));
|
2010-03-17 14:58:27 +01:00
|
|
|
tmpaction = new QAction(icon, tr("&Redo"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::REDO);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Redo);
|
2009-01-14 13:17:53 +01:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
2012-01-06 17:13:18 +01:00
|
|
|
cmd->setDescription(tr("Redo"));
|
2008-12-02 12:01:29 +01:00
|
|
|
medit->addAction(cmd, Constants::G_EDIT_UNDOREDO);
|
2009-03-03 17:19:34 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Cut Action
|
2011-12-22 14:44:14 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("edit-cut"), QIcon(QLatin1String(Constants::ICON_CUT)));
|
2010-03-17 14:58:27 +01:00
|
|
|
tmpaction = new QAction(icon, tr("Cu&t"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::CUT);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Cut);
|
|
|
|
|
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
|
2009-03-03 17:19:34 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Copy Action
|
2011-12-22 14:44:14 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("edit-copy"), QIcon(QLatin1String(Constants::ICON_COPY)));
|
2010-03-17 14:58:27 +01:00
|
|
|
tmpaction = new QAction(icon, tr("&Copy"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::COPY);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Copy);
|
|
|
|
|
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
|
2009-03-03 17:19:34 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Paste Action
|
2011-12-22 14:44:14 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("edit-paste"), QIcon(QLatin1String(Constants::ICON_PASTE)));
|
2010-03-17 14:58:27 +01:00
|
|
|
tmpaction = new QAction(icon, tr("&Paste"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::PASTE);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Paste);
|
|
|
|
|
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
|
2009-03-03 17:19:34 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Select All
|
2010-03-19 15:25:20 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("edit-select-all"));
|
2011-03-22 12:14:44 +01:00
|
|
|
tmpaction = new QAction(icon, tr("Select &All"), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::SelectAll);
|
|
|
|
|
medit->addAction(cmd, Constants::G_EDIT_SELECTALL);
|
2009-03-03 17:19:34 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Goto Action
|
2010-03-19 15:25:20 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("go-jump"));
|
2011-07-19 14:46:47 +02:00
|
|
|
tmpaction = new QAction(icon, tr("&Go to Line..."), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::GOTO);
|
2008-12-02 12:01:29 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+L")));
|
|
|
|
|
medit->addAction(cmd, Constants::G_EDIT_OTHER);
|
2009-03-03 17:19:34 +01:00
|
|
|
tmpaction->setEnabled(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Options Action
|
2010-12-15 14:34:09 +01:00
|
|
|
mtools->appendGroup(Constants::G_TOOLS_OPTIONS);
|
2015-02-26 13:58:00 +01:00
|
|
|
mtools->addSeparator(Constants::G_TOOLS_OPTIONS);
|
Implement theming for QtCreator
Adds a 'Theme' tab to the environment settings and a '-theme' command
line option.
A theme is a combination of colors, gradients, flags and style
information.
There are two themes:
- 'default': preserves the current default look
- 'dark': uses a more flat for many widgets, dark color theme
for everything
This does not use a stylesheet (too limited), but rather sets
the palette via C++ and modifies drawing behavior.
Overall, the look is more flat (removed some gradients and bevels).
Tested on Ubuntu 14.04 using Qt 5.4 and running on a KDE
Desktop (Oxygen base style).
For a screenshot, see
https://gist.github.com/thorbenk/5ab06bea726de0aa7473
Changes:
- Introduce class Theme, defining the interface how to access theme
specific settings. The class reads a .creatortheme file (INI file, via
QSettings)
- Define named colors in the [Palette] section
(see dark.creatortheme for example usage)
- Use either named colors of AARRGGBB (hex) in the [Colors]
section
- A file ending with .creatortheme may be supplied
to the '-theme' command line option
- A global Theme instance can be accessed via creatorTheme()
- Query colors, gradients, icons and flags from the theme
were possible (TODO: use this in more places...)
- There are very many color roles. It seems better to me
to describe the role clearly, and then to consolidate later
in the actual theme by assigning the same color.
For example, one can set the text color of the output pane button
individualy.
- Many elements are also drawn differently.
For the dark theme, I wanted to have a flatter look.
- Introduce Theme::WidgetStyle enum, for now {Original, Flat}.
- The theme specifies which kind of widget style it wants.
- The drawing code queries the theme's style flag and
switches between the original, gradient based look and
the new, flat look.
- Create some custom icons which look better on dark background
(wip, currently folder/file icons)
- Let ManhattanStyle draw some elements for non-panelwidgets, too
(open/close arrows in QTreeView, custom folder/file icons)
- For the welcomescreen, pass the WelcomeTheme class.
WelcomeTheme exposes theme colors as Q_PROPERTY accessible from
.qml
- Themes can be modified via the 'Themes' tab in the environment
settings.
TODO:
* Unify image handling
* Avoid style name references
* Fix gradients
Change-Id: I92c2050ab0fb327649ea1eff4adec973d2073944
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-10-14 19:09:48 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
m_optionsAction = new QAction(tr("&Options..."), this);
|
2014-11-07 11:41:07 +01:00
|
|
|
m_optionsAction->setMenuRole(QAction::PreferencesRole);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS);
|
2014-11-07 11:41:07 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence::Preferences);
|
2010-12-15 14:34:09 +01:00
|
|
|
mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS);
|
2008-12-02 12:01:29 +01:00
|
|
|
connect(m_optionsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog()));
|
|
|
|
|
|
2015-02-26 13:58:00 +01:00
|
|
|
mwindow->addSeparator(Constants::G_WINDOW_LIST);
|
2014-08-25 17:28:25 +02:00
|
|
|
|
2012-05-23 13:25:51 +02:00
|
|
|
if (UseMacShortcuts) {
|
|
|
|
|
// Minimize Action
|
2014-07-17 17:04:02 +02:00
|
|
|
QAction *minimizeAction = new QAction(tr("Minimize"), this);
|
|
|
|
|
minimizeAction->setEnabled(false); // actual implementation in WindowSupport
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M")));
|
|
|
|
|
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
|
|
|
|
|
|
|
|
|
// Zoom Action
|
2014-07-17 17:04:02 +02:00
|
|
|
QAction *zoomAction = new QAction(tr("Zoom"), this);
|
|
|
|
|
zoomAction->setEnabled(false); // actual implementation in WindowSupport
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(zoomAction, Constants::ZOOM_WINDOW);
|
2012-05-23 13:25:51 +02:00
|
|
|
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
2014-07-10 16:57:28 +02:00
|
|
|
}
|
2012-05-23 13:25:51 +02:00
|
|
|
|
2014-07-10 16:57:28 +02:00
|
|
|
// Full Screen Action
|
2014-07-17 17:04:02 +02:00
|
|
|
QAction *toggleFullScreenAction = new QAction(tr("Full Screen"), this);
|
2015-02-18 18:00:28 +01:00
|
|
|
toggleFullScreenAction->setCheckable(!HostOsInfo::isMacHost());
|
2014-07-17 17:04:02 +02:00
|
|
|
toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN);
|
2014-07-10 16:57:28 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11")));
|
2015-02-18 18:00:28 +01:00
|
|
|
if (HostOsInfo::isMacHost())
|
2014-07-10 16:57:28 +02:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
|
|
|
|
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
|
|
|
|
|
2014-07-18 10:35:17 +02:00
|
|
|
if (UseMacShortcuts) {
|
2015-02-26 13:58:00 +01:00
|
|
|
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-07-18 10:35:17 +02:00
|
|
|
QAction *closeAction = new QAction(tr("Close Window"), this);
|
|
|
|
|
closeAction->setEnabled(false);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(closeAction, Constants::CLOSE_WINDOW);
|
2014-07-18 10:35:17 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Meta+W")));
|
|
|
|
|
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
|
|
|
|
|
|
2015-02-26 13:58:00 +01:00
|
|
|
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
|
2014-07-18 10:35:17 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// Show Sidebar Action
|
2011-12-22 14:44:14 +01:00
|
|
|
m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Constants::ICON_TOGGLE_SIDEBAR)),
|
2015-04-23 23:57:48 +03:00
|
|
|
QCoreApplication::translate("Core", Constants::TR_SHOW_SIDEBAR),
|
|
|
|
|
this);
|
2009-01-06 17:03:08 +01:00
|
|
|
m_toggleSideBarAction->setCheckable(true);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR);
|
2009-12-08 18:29:44 +01:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
2012-05-23 13:25:51 +02:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0")));
|
2015-02-18 18:00:28 +01:00
|
|
|
connect(m_toggleSideBarAction, &QAction::triggered, this, &MainWindow::setSidebarVisible);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_toggleSideBarButton->setDefaultAction(cmd->action());
|
2010-04-20 16:46:35 +02:00
|
|
|
mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_toggleSideBarAction->setEnabled(false);
|
|
|
|
|
|
2013-04-11 12:22:10 +02:00
|
|
|
// Show Mode Selector Action
|
|
|
|
|
m_toggleModeSelectorAction = new QAction(tr("Show Mode Selector"), this);
|
|
|
|
|
m_toggleModeSelectorAction->setCheckable(true);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_toggleModeSelectorAction, Constants::TOGGLE_MODE_SELECTOR);
|
2015-02-18 18:00:28 +01:00
|
|
|
connect(m_toggleModeSelectorAction, &QAction::triggered, ModeManager::instance(), &ModeManager::setModeSelectorVisible);
|
2013-04-11 12:22:10 +02:00
|
|
|
mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS);
|
2012-11-06 16:00:38 +01:00
|
|
|
|
2010-04-20 16:46:35 +02:00
|
|
|
// Window->Views
|
2012-05-24 13:49:06 +02:00
|
|
|
ActionContainer *mviews = ActionManager::createMenu(Constants::M_WINDOW_VIEWS);
|
2010-04-20 16:46:35 +02:00
|
|
|
mwindow->addMenu(mviews, Constants::G_WINDOW_VIEWS);
|
|
|
|
|
mviews->menu()->setTitle(tr("&Views"));
|
|
|
|
|
|
2014-01-24 09:51:52 +01:00
|
|
|
// "Help" separators
|
2015-02-26 13:58:00 +01:00
|
|
|
mhelp->addSeparator(Constants::G_HELP_SUPPORT);
|
2015-02-18 18:00:28 +01:00
|
|
|
if (!HostOsInfo::isMacHost())
|
2015-02-26 13:58:00 +01:00
|
|
|
mhelp->addSeparator(Constants::G_HELP_ABOUT);
|
2014-01-24 09:51:52 +01:00
|
|
|
|
2009-01-22 14:56:27 +01:00
|
|
|
// About IDE Action
|
2010-03-19 15:25:20 +01:00
|
|
|
icon = QIcon::fromTheme(QLatin1String("help-about"));
|
2015-02-18 18:00:28 +01:00
|
|
|
if (HostOsInfo::isMacHost())
|
2012-11-06 16:00:38 +01:00
|
|
|
tmpaction = new QAction(icon, tr("About &Qt Creator"), this); // it's convention not to add dots to the about menu
|
|
|
|
|
else
|
|
|
|
|
tmpaction = new QAction(icon, tr("About &Qt Creator..."), this);
|
2014-11-07 11:41:07 +01:00
|
|
|
tmpaction->setMenuRole(QAction::AboutRole);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR);
|
2013-02-27 01:07:13 +01:00
|
|
|
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
|
|
|
|
tmpaction->setEnabled(true);
|
2015-02-18 18:00:28 +01:00
|
|
|
connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutQtCreator);
|
2009-09-11 14:37:17 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
//About Plugins Action
|
|
|
|
|
tmpaction = new QAction(tr("About &Plugins..."), this);
|
2014-11-07 11:41:07 +01:00
|
|
|
tmpaction->setMenuRole(QAction::ApplicationSpecificRole);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS);
|
2013-02-27 01:07:13 +01:00
|
|
|
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
|
|
|
|
tmpaction->setEnabled(true);
|
2015-02-18 18:00:28 +01:00
|
|
|
connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutPlugins);
|
2009-01-22 14:56:27 +01:00
|
|
|
// About Qt Action
|
2008-12-02 12:01:29 +01:00
|
|
|
// tmpaction = new QAction(tr("About &Qt..."), this);
|
2015-02-19 11:35:47 +01:00
|
|
|
// cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT);
|
2008-12-02 12:01:29 +01:00
|
|
|
// mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
|
|
|
|
// tmpaction->setEnabled(true);
|
|
|
|
|
// connect(tmpaction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
|
|
|
|
// About sep
|
2015-02-18 18:00:28 +01:00
|
|
|
if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu
|
2012-11-06 16:00:38 +01:00
|
|
|
tmpaction = new QAction(this);
|
|
|
|
|
tmpaction->setSeparator(true);
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About");
|
2012-11-06 16:00:38 +01:00
|
|
|
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::openFile()
|
|
|
|
|
{
|
2013-08-30 15:22:09 +02:00
|
|
|
openFiles(EditorManager::getOpenFileNames(), ICore::SwitchMode);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
static IDocumentFactory *findDocumentFactory(const QList<IDocumentFactory*> &fileFactories,
|
2008-12-02 12:01:29 +01:00
|
|
|
const QFileInfo &fi)
|
|
|
|
|
{
|
2015-02-18 18:00:28 +01:00
|
|
|
MimeDatabase mdb;
|
|
|
|
|
const MimeType mt = mdb.mimeTypeForFile(fi);
|
2015-02-04 09:32:46 +01:00
|
|
|
if (mt.isValid()) {
|
|
|
|
|
const QString typeName = mt.name();
|
2012-02-14 16:43:51 +01:00
|
|
|
foreach (IDocumentFactory *factory, fileFactories) {
|
2015-02-04 09:32:46 +01:00
|
|
|
if (factory->mimeTypes().contains(typeName))
|
2008-12-02 12:01:29 +01:00
|
|
|
return factory;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-11 18:15:49 +02:00
|
|
|
/*! Either opens \a fileNames with editors or loads a project.
|
|
|
|
|
*
|
|
|
|
|
* \a flags can be used to stop on first failure, indicate that a file name
|
|
|
|
|
* might include line numbers and/or switch mode to edit mode.
|
|
|
|
|
*
|
2015-03-09 10:59:58 +02:00
|
|
|
* \a workingDirectory is used when files are opened by a remote client, since
|
|
|
|
|
* the file names are relative to the client working directory.
|
|
|
|
|
*
|
2013-03-11 18:15:49 +02:00
|
|
|
* \returns the first opened document. Required to support the -block flag
|
|
|
|
|
* for client mode.
|
|
|
|
|
*
|
|
|
|
|
* \sa IPlugin::remoteArguments()
|
|
|
|
|
*/
|
2015-03-09 10:59:58 +02:00
|
|
|
IDocument *MainWindow::openFiles(const QStringList &fileNames,
|
|
|
|
|
ICore::OpenFilesFlags flags,
|
|
|
|
|
const QString &workingDirectory)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-02-03 23:48:19 +02:00
|
|
|
QList<IDocumentFactory*> documentFactories = PluginManager::getObjects<IDocumentFactory>();
|
2013-03-11 18:15:49 +02:00
|
|
|
IDocument *res = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
foreach (const QString &fileName, fileNames) {
|
2015-03-09 10:59:58 +02:00
|
|
|
const QDir workingDir(workingDirectory.isEmpty() ? QDir::currentPath() : workingDirectory);
|
|
|
|
|
const QFileInfo fi(workingDir, fileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
const QString absoluteFilePath = fi.absoluteFilePath();
|
2014-07-17 13:36:33 +02:00
|
|
|
if (IDocumentFactory *documentFactory = findDocumentFactory(documentFactories, fi)) {
|
2013-03-11 18:15:49 +02:00
|
|
|
IDocument *document = documentFactory->open(absoluteFilePath);
|
|
|
|
|
if (!document) {
|
|
|
|
|
if (flags & ICore::StopOnLoadFail)
|
|
|
|
|
return res;
|
|
|
|
|
} else {
|
|
|
|
|
if (!res)
|
|
|
|
|
res = document;
|
|
|
|
|
if (flags & ICore::SwitchMode)
|
2014-11-16 10:52:41 +02:00
|
|
|
ModeManager::activateMode(Id(Constants::MODE_EDIT));
|
2013-03-11 18:15:49 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
} else {
|
2010-09-23 12:32:22 +02:00
|
|
|
QFlags<EditorManager::OpenEditorFlag> emFlags;
|
2015-03-05 17:43:11 -07:00
|
|
|
if (flags & ICore::CanContainLineAndColumnNumbers)
|
|
|
|
|
emFlags |= EditorManager::CanContainLineAndColumnNumber;
|
2013-03-11 18:15:49 +02:00
|
|
|
IEditor *editor = EditorManager::openEditor(absoluteFilePath, Id(), emFlags);
|
|
|
|
|
if (!editor) {
|
|
|
|
|
if (flags & ICore::StopOnLoadFail)
|
|
|
|
|
return res;
|
|
|
|
|
} else if (!res) {
|
|
|
|
|
res = editor->document();
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-03-11 18:15:49 +02:00
|
|
|
return res;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::setFocusToEditor()
|
|
|
|
|
{
|
2014-07-18 17:11:57 +02:00
|
|
|
EditorManagerPrivate::doEscapeKeyFocusMoveMagic();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-23 11:07:38 +01:00
|
|
|
bool MainWindow::showOptionsDialog(Id page, QWidget *parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-12 14:41:24 +01:00
|
|
|
emit m_coreImpl->optionsDialogRequested();
|
2009-03-18 16:43:01 +01:00
|
|
|
if (!parent)
|
2014-07-14 14:47:24 +02:00
|
|
|
parent = ICore::dialogParent();
|
2015-02-23 11:07:38 +01:00
|
|
|
SettingsDialog *dialog = SettingsDialog::getSettingsDialog(parent, page);
|
2010-07-01 17:12:20 +02:00
|
|
|
return dialog->execDialog();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::saveAll()
|
|
|
|
|
{
|
2014-01-26 08:41:07 +02:00
|
|
|
DocumentManager::saveAllModifiedDocumentsSilently();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::exit()
|
|
|
|
|
{
|
|
|
|
|
// this function is most likely called from a user action
|
|
|
|
|
// that is from an event handler of an object
|
|
|
|
|
// since on close we are going to delete everything
|
|
|
|
|
// so to prevent the deleting of that object we
|
|
|
|
|
// just append it
|
|
|
|
|
QTimer::singleShot(0, this, SLOT(close()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::openFileWith()
|
|
|
|
|
{
|
2013-08-30 15:22:09 +02:00
|
|
|
foreach (const QString &fileName, EditorManager::getOpenFileNames()) {
|
2009-05-19 14:54:52 +02:00
|
|
|
bool isExternal;
|
2014-07-18 17:11:57 +02:00
|
|
|
const Id editorId = EditorManagerPrivate::getOpenWithEditorId(fileName, &isExternal);
|
2011-09-07 09:26:29 +02:00
|
|
|
if (!editorId.isValid())
|
2008-12-02 12:01:29 +01:00
|
|
|
continue;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (isExternal)
|
2012-05-08 09:43:14 +02:00
|
|
|
EditorManager::openExternalEditor(fileName, editorId);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2015-05-20 14:27:36 +02:00
|
|
|
EditorManagerPrivate::openEditorWith(fileName, editorId);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IContext *MainWindow::contextObject(QWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
return m_contextWidgets.value(widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::addContextObject(IContext *context)
|
|
|
|
|
{
|
|
|
|
|
if (!context)
|
|
|
|
|
return;
|
|
|
|
|
QWidget *widget = context->widget();
|
|
|
|
|
if (m_contextWidgets.contains(widget))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_contextWidgets.insert(widget, context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::removeContextObject(IContext *context)
|
|
|
|
|
{
|
|
|
|
|
if (!context)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QWidget *widget = context->widget();
|
|
|
|
|
if (!m_contextWidgets.contains(widget))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_contextWidgets.remove(widget);
|
2013-05-07 19:03:22 +02:00
|
|
|
if (m_activeContext.removeAll(context) > 0)
|
|
|
|
|
updateContextObject(m_activeContext);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::updateFocusWidget(QWidget *old, QWidget *now)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(old)
|
2009-04-22 17:36:32 +02:00
|
|
|
|
2010-06-11 14:48:08 +02:00
|
|
|
// Prevent changing the context object just because the menu or a menu item is activated
|
|
|
|
|
if (qobject_cast<QMenuBar*>(now) || qobject_cast<QMenu*>(now))
|
2009-04-22 17:36:32 +02:00
|
|
|
return;
|
|
|
|
|
|
2013-05-07 19:03:22 +02:00
|
|
|
QList<IContext *> newContext;
|
2012-10-23 15:59:37 +02:00
|
|
|
if (QWidget *p = qApp->focusWidget()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
IContext *context = 0;
|
|
|
|
|
while (p) {
|
|
|
|
|
context = m_contextWidgets.value(p);
|
2013-05-07 19:03:22 +02:00
|
|
|
if (context)
|
|
|
|
|
newContext.append(context);
|
2008-12-02 12:01:29 +01:00
|
|
|
p = p->parentWidget();
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-02-25 15:36:58 +01:00
|
|
|
|
|
|
|
|
// ignore toplevels that define no context, like popups without parent
|
2013-05-07 19:03:22 +02:00
|
|
|
if (!newContext.isEmpty() || qApp->focusWidget() == focusWidget())
|
2013-02-25 15:36:58 +01:00
|
|
|
updateContextObject(newContext);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-07 19:03:22 +02:00
|
|
|
void MainWindow::updateContextObject(const QList<IContext *> &context)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-02-04 14:59:41 +01:00
|
|
|
emit m_coreImpl->contextAboutToChange(context);
|
2008-12-02 12:01:29 +01:00
|
|
|
m_activeContext = context;
|
2011-02-04 14:59:41 +01:00
|
|
|
updateContext();
|
2013-05-07 19:03:22 +02:00
|
|
|
if (debugMainWindow) {
|
|
|
|
|
qDebug() << "new context objects =" << context;
|
|
|
|
|
foreach (IContext *c, context)
|
|
|
|
|
qDebug() << (c ? c->widget() : 0) << (c ? c->widget()->metaObject()->className() : 0);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-28 16:59:03 +02:00
|
|
|
void MainWindow::aboutToShutdown()
|
2009-06-23 14:59:01 +02:00
|
|
|
{
|
|
|
|
|
disconnect(QApplication::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)),
|
|
|
|
|
this, SLOT(updateFocusWidget(QWidget*,QWidget*)));
|
2013-05-07 19:03:22 +02:00
|
|
|
m_activeContext.clear();
|
2010-07-13 13:36:47 +02:00
|
|
|
hide();
|
2009-06-23 14:59:01 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char settingsGroup[] = "MainWindow";
|
|
|
|
|
static const char colorKey[] = "Color";
|
|
|
|
|
static const char windowGeometryKey[] = "WindowGeometry";
|
|
|
|
|
static const char windowStateKey[] = "WindowState";
|
2013-04-11 12:22:10 +02:00
|
|
|
static const char modeSelectorVisibleKey[] = "ModeSelectorVisible";
|
2010-11-02 13:41:03 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void MainWindow::readSettings()
|
|
|
|
|
{
|
2014-03-04 16:07:44 +01:00
|
|
|
QSettings *settings = PluginManager::settings();
|
|
|
|
|
settings->beginGroup(QLatin1String(settingsGroup));
|
2009-04-16 10:27:25 +02:00
|
|
|
|
2010-03-16 10:22:26 +01:00
|
|
|
if (m_overrideColor.isValid()) {
|
2015-02-18 18:00:28 +01:00
|
|
|
StyleHelper::setBaseColor(m_overrideColor);
|
2010-03-16 10:22:26 +01:00
|
|
|
// Get adapted base color.
|
2015-02-18 18:00:28 +01:00
|
|
|
m_overrideColor = StyleHelper::baseColor();
|
2010-03-16 10:22:26 +01:00
|
|
|
} else {
|
2015-02-18 18:00:28 +01:00
|
|
|
StyleHelper::setBaseColor(settings->value(QLatin1String(colorKey),
|
|
|
|
|
QColor(StyleHelper::DEFAULT_BASE_COLOR)).value<QColor>());
|
2010-03-16 10:22:26 +01:00
|
|
|
}
|
2009-04-16 10:27:25 +02:00
|
|
|
|
2014-03-04 16:07:44 +01:00
|
|
|
bool modeSelectorVisible = settings->value(QLatin1String(modeSelectorVisibleKey), true).toBool();
|
2013-08-29 17:45:36 +02:00
|
|
|
ModeManager::setModeSelectorVisible(modeSelectorVisible);
|
2013-04-11 12:22:10 +02:00
|
|
|
m_toggleModeSelectorAction->setChecked(modeSelectorVisible);
|
|
|
|
|
|
2014-03-04 16:07:44 +01:00
|
|
|
settings->endGroup();
|
2009-04-16 10:27:25 +02:00
|
|
|
|
2014-07-18 17:11:57 +02:00
|
|
|
EditorManagerPrivate::readSettings();
|
2014-03-04 16:07:44 +01:00
|
|
|
m_navigationWidget->restoreSettings(settings);
|
|
|
|
|
m_rightPaneWidget->readSettings(settings);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::writeSettings()
|
|
|
|
|
{
|
2014-03-04 16:07:44 +01:00
|
|
|
QSettings *settings = PluginManager::settings();
|
|
|
|
|
settings->beginGroup(QLatin1String(settingsGroup));
|
2009-04-16 10:27:25 +02:00
|
|
|
|
2015-02-18 18:00:28 +01:00
|
|
|
if (!(m_overrideColor.isValid() && StyleHelper::baseColor() == m_overrideColor))
|
|
|
|
|
settings->setValue(QLatin1String(colorKey), StyleHelper::requestedBaseColor());
|
2009-04-16 10:27:25 +02:00
|
|
|
|
2015-03-26 11:34:14 +01:00
|
|
|
// On OS X applications usually do not restore their full screen state.
|
|
|
|
|
// To be able to restore the correct non-full screen geometry, we have to put
|
|
|
|
|
// the window out of full screen before saving the geometry.
|
|
|
|
|
// Works around QTBUG-45241
|
|
|
|
|
if (Utils::HostOsInfo::isMacHost() && isFullScreen())
|
|
|
|
|
setWindowState(windowState() & ~Qt::WindowFullScreen);
|
2014-03-04 16:07:44 +01:00
|
|
|
settings->setValue(QLatin1String(windowGeometryKey), saveGeometry());
|
|
|
|
|
settings->setValue(QLatin1String(windowStateKey), saveState());
|
|
|
|
|
settings->setValue(QLatin1String(modeSelectorVisibleKey), ModeManager::isModeSelectorVisible());
|
2009-04-16 10:27:25 +02:00
|
|
|
|
2014-03-04 16:07:44 +01:00
|
|
|
settings->endGroup();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
DocumentManager::saveSettings();
|
2015-03-16 17:19:24 +01:00
|
|
|
ActionManager::saveSettings();
|
2014-07-18 17:11:57 +02:00
|
|
|
EditorManagerPrivate::saveSettings();
|
2014-03-04 16:07:44 +01:00
|
|
|
m_navigationWidget->saveSettings(settings);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2015-08-07 17:21:38 +02:00
|
|
|
void MainWindow::updateAdditionalContexts(const Context &remove, const Context &add,
|
|
|
|
|
ICore::ContextPriority priority)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-01-11 13:34:31 +01:00
|
|
|
foreach (const Id id, remove) {
|
|
|
|
|
if (!id.isValid())
|
2010-03-22 18:05:22 +01:00
|
|
|
continue;
|
2015-08-07 17:21:38 +02:00
|
|
|
int index = m_lowPrioAdditionalContexts.indexOf(id);
|
|
|
|
|
if (index != -1)
|
|
|
|
|
m_lowPrioAdditionalContexts.removeAt(index);
|
|
|
|
|
index = m_highPrioAdditionalContexts.indexOf(id);
|
2010-03-22 18:05:22 +01:00
|
|
|
if (index != -1)
|
2015-08-07 17:21:38 +02:00
|
|
|
m_highPrioAdditionalContexts.removeAt(index);
|
2010-03-22 18:05:22 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-01-11 13:34:31 +01:00
|
|
|
foreach (const Id id, add) {
|
|
|
|
|
if (!id.isValid())
|
2010-03-22 18:05:22 +01:00
|
|
|
continue;
|
2015-08-07 17:21:38 +02:00
|
|
|
Context &cref = (priority == ICore::ContextPriority::High ? m_highPrioAdditionalContexts
|
|
|
|
|
: m_lowPrioAdditionalContexts);
|
|
|
|
|
if (!cref.contains(id))
|
|
|
|
|
cref.prepend(id);
|
2010-03-22 18:05:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateContext();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::updateContext()
|
|
|
|
|
{
|
2015-08-07 17:21:38 +02:00
|
|
|
Context contexts = m_highPrioAdditionalContexts;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-05-07 19:03:22 +02:00
|
|
|
foreach (IContext *context, m_activeContext)
|
|
|
|
|
contexts.add(context->context());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-08-07 17:21:38 +02:00
|
|
|
contexts.add(m_lowPrioAdditionalContexts);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-06-25 12:56:16 +02:00
|
|
|
Context uniquecontexts;
|
2010-06-25 18:05:09 +02:00
|
|
|
for (int i = 0; i < contexts.size(); ++i) {
|
2013-01-11 13:34:31 +01:00
|
|
|
const Id id = contexts.at(i);
|
|
|
|
|
if (!uniquecontexts.contains(id))
|
|
|
|
|
uniquecontexts.add(id);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-06 14:00:34 +01:00
|
|
|
ActionManager::setContext(uniquecontexts);
|
2015-09-22 09:17:59 +02:00
|
|
|
emit m_coreImpl->contextChanged(uniquecontexts);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::aboutToShowRecentFiles()
|
|
|
|
|
{
|
2015-02-18 18:00:28 +01:00
|
|
|
ActionContainer *aci = ActionManager::actionContainer(Constants::M_FILE_RECENTFILES);
|
2014-05-19 18:28:48 +03:00
|
|
|
QMenu *menu = aci->menu();
|
|
|
|
|
menu->clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
bool hasRecentFiles = false;
|
2012-02-14 16:43:51 +01:00
|
|
|
foreach (const DocumentManager::RecentFile &file, DocumentManager::recentFiles()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
hasRecentFiles = true;
|
2014-05-19 18:28:48 +03:00
|
|
|
QAction *action = menu->addAction(
|
2010-12-09 11:37:58 +01:00
|
|
|
QDir::toNativeSeparators(Utils::withTildeHomePath(file.first)));
|
2015-02-18 18:00:28 +01:00
|
|
|
connect(action, &QAction::triggered, this, [file] {
|
|
|
|
|
EditorManager::openEditor(file.first, file.second);
|
|
|
|
|
});
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2014-05-19 18:28:48 +03:00
|
|
|
menu->setEnabled(hasRecentFiles);
|
2011-06-20 11:01:23 +02:00
|
|
|
|
|
|
|
|
// add the Clear Menu item
|
|
|
|
|
if (hasRecentFiles) {
|
2014-05-19 18:28:48 +03:00
|
|
|
menu->addSeparator();
|
|
|
|
|
QAction *action = menu->addAction(QCoreApplication::translate(
|
2014-11-16 10:52:41 +02:00
|
|
|
"Core", Constants::TR_CLEAR_MENU));
|
2015-02-18 18:00:28 +01:00
|
|
|
connect(action, &QAction::triggered,
|
|
|
|
|
DocumentManager::instance(), &DocumentManager::clearRecentFiles);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::aboutQtCreator()
|
|
|
|
|
{
|
2008-12-03 17:38:53 +01:00
|
|
|
if (!m_versionDialog) {
|
|
|
|
|
m_versionDialog = new VersionDialog(this);
|
2015-02-18 18:00:28 +01:00
|
|
|
connect(m_versionDialog, &QDialog::finished,
|
|
|
|
|
this, &MainWindow::destroyVersionDialog);
|
2008-12-03 17:38:53 +01:00
|
|
|
}
|
|
|
|
|
m_versionDialog->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::destroyVersionDialog()
|
|
|
|
|
{
|
|
|
|
|
if (m_versionDialog) {
|
|
|
|
|
m_versionDialog->deleteLater();
|
|
|
|
|
m_versionDialog = 0;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::aboutPlugins()
|
|
|
|
|
{
|
2009-01-26 14:30:04 +01:00
|
|
|
PluginDialog dialog(this);
|
2008-12-02 12:01:29 +01:00
|
|
|
dialog.exec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPrinter *MainWindow::printer() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_printer)
|
|
|
|
|
m_printer = new QPrinter(QPrinter::HighResolution);
|
2009-04-16 10:27:25 +02:00
|
|
|
return m_printer;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-01-19 14:12:39 +01:00
|
|
|
|
2009-10-08 17:23:27 +02:00
|
|
|
// Display a warning with an additional button to open
|
|
|
|
|
// the debugger settings dialog if settingsId is nonempty.
|
|
|
|
|
|
|
|
|
|
bool MainWindow::showWarningWithOptions(const QString &title,
|
|
|
|
|
const QString &text,
|
|
|
|
|
const QString &details,
|
2012-12-29 01:31:08 +01:00
|
|
|
Id settingsId,
|
2009-10-08 17:23:27 +02:00
|
|
|
QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
if (parent == 0)
|
|
|
|
|
parent = this;
|
|
|
|
|
QMessageBox msgBox(QMessageBox::Warning, title, text,
|
|
|
|
|
QMessageBox::Ok, parent);
|
2011-02-25 09:34:31 +01:00
|
|
|
if (!details.isEmpty())
|
2009-10-08 17:23:27 +02:00
|
|
|
msgBox.setDetailedText(details);
|
|
|
|
|
QAbstractButton *settingsButton = 0;
|
2015-02-23 11:07:38 +01:00
|
|
|
if (settingsId.isValid())
|
2009-10-08 17:23:27 +02:00
|
|
|
settingsButton = msgBox.addButton(tr("Settings..."), QMessageBox::AcceptRole);
|
|
|
|
|
msgBox.exec();
|
2012-12-29 01:31:08 +01:00
|
|
|
if (settingsButton && msgBox.clickedButton() == settingsButton)
|
2015-02-23 11:07:38 +01:00
|
|
|
return showOptionsDialog(settingsId);
|
2009-10-08 17:23:27 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2014-01-12 09:08:18 +02:00
|
|
|
|
|
|
|
|
void MainWindow::restoreWindowState()
|
|
|
|
|
{
|
2014-03-04 16:07:44 +01:00
|
|
|
QSettings *settings = PluginManager::settings();
|
|
|
|
|
settings->beginGroup(QLatin1String(settingsGroup));
|
|
|
|
|
if (!restoreGeometry(settings->value(QLatin1String(windowGeometryKey)).toByteArray()))
|
2014-01-12 09:08:18 +02:00
|
|
|
resize(1008, 700); // size without window decoration
|
2014-03-04 16:07:44 +01:00
|
|
|
restoreState(settings->value(QLatin1String(windowStateKey)).toByteArray());
|
|
|
|
|
settings->endGroup();
|
2014-03-03 10:44:40 +01:00
|
|
|
show();
|
2014-02-27 17:26:04 +01:00
|
|
|
m_statusBarManager->restoreSettings();
|
2014-01-12 09:08:18 +02:00
|
|
|
}
|
2014-03-04 16:07:44 +01:00
|
|
|
|
2014-06-27 15:15:09 +02:00
|
|
|
void MainWindow::newItemDialogFinished()
|
|
|
|
|
{
|
|
|
|
|
m_newAction->setEnabled(true);
|
|
|
|
|
// fire signal when the dialog is actually destroyed
|
|
|
|
|
QTimer::singleShot(0, this, SIGNAL(newItemDialogRunningChanged()));
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-04 16:07:44 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Core
|