2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-09-16 12:26:28 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-09-16 12:26:28 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-09-16 12:26:28 +02: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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-09-16 12:26:28 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
#include "outputpanemanager.h"
|
|
|
|
|
#include "outputpane.h"
|
|
|
|
|
#include "findplaceholder.h"
|
|
|
|
|
|
|
|
|
|
#include "icore.h"
|
|
|
|
|
#include "ioutputpane.h"
|
|
|
|
|
#include "modemanager.h"
|
2018-01-24 17:41:53 +01:00
|
|
|
#include "statusbarmanager.h"
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2019-06-20 17:27:10 +02:00
|
|
|
#include <coreplugin/actionmanager/commandbutton.h>
|
2010-09-16 12:26:28 +02:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2019-05-14 13:55:14 +02:00
|
|
|
#include <coreplugin/find/optionspopup.h>
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2010-09-16 12:26:28 +02:00
|
|
|
#include <utils/styledbar.h>
|
2014-08-29 17:20:39 +02:00
|
|
|
#include <utils/stylehelper.h>
|
2016-04-25 09:36:35 +02:00
|
|
|
#include <utils/proxyaction.h>
|
2010-09-16 12:26:28 +02:00
|
|
|
#include <utils/qtcassert.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>
|
2016-05-23 14:15:06 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QFocusEvent>
|
|
|
|
|
#include <QHBoxLayout>
|
2012-05-16 18:27:45 +02:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QMenu>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPainter>
|
2012-05-16 18:27:45 +02:00
|
|
|
#include <QStyle>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QStackedWidget>
|
2012-05-16 18:27:45 +02:00
|
|
|
#include <QToolButton>
|
2012-06-11 10:32:16 +02:00
|
|
|
#include <QTimeLine>
|
2010-09-16 12:26:28 +02:00
|
|
|
|
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
|
|
|
using namespace Utils;
|
2018-02-27 09:08:38 +01:00
|
|
|
using namespace Core::Internal;
|
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
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
namespace Core {
|
2018-02-27 09:08:38 +01:00
|
|
|
namespace Internal {
|
2017-12-08 17:20:48 +01:00
|
|
|
|
2018-02-27 09:08:38 +01:00
|
|
|
class OutputPaneData
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OutputPaneData(IOutputPane *pane = nullptr) : pane(pane) {}
|
|
|
|
|
|
|
|
|
|
IOutputPane *pane = nullptr;
|
|
|
|
|
Id id;
|
|
|
|
|
OutputPaneToggleButton *button = nullptr;
|
|
|
|
|
QAction *action = nullptr;
|
|
|
|
|
};
|
2017-12-08 17:20:48 +01:00
|
|
|
|
2018-02-27 09:08:38 +01:00
|
|
|
static QVector<OutputPaneData> g_outputPanes;
|
|
|
|
|
static bool g_managerConstructed = false; // For debugging reasons.
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
|
|
|
|
|
// OutputPane
|
2017-12-08 17:20:48 +01:00
|
|
|
|
|
|
|
|
IOutputPane::IOutputPane(QObject *parent)
|
2019-03-31 08:04:43 +02:00
|
|
|
: QObject(parent),
|
2019-06-20 17:27:10 +02:00
|
|
|
m_zoomInButton(new Core::CommandButton),
|
|
|
|
|
m_zoomOutButton(new Core::CommandButton)
|
2017-12-08 17:20:48 +01:00
|
|
|
{
|
2018-02-27 09:08:38 +01:00
|
|
|
// We need all pages first. Ignore latecomers and shout.
|
|
|
|
|
QTC_ASSERT(!g_managerConstructed, return);
|
|
|
|
|
g_outputPanes.append(OutputPaneData(this));
|
2019-03-31 08:04:43 +02:00
|
|
|
|
|
|
|
|
m_zoomInButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
2019-06-20 17:27:10 +02:00
|
|
|
m_zoomInButton->setCommandId(Constants::ZOOM_IN);
|
2020-11-17 15:50:11 +01:00
|
|
|
connect(m_zoomInButton, &QToolButton::clicked, this, [this] { emit zoomInRequested(1); });
|
2019-03-31 08:04:43 +02:00
|
|
|
|
|
|
|
|
m_zoomOutButton->setIcon(Utils::Icons::MINUS.icon());
|
2019-06-20 17:27:10 +02:00
|
|
|
m_zoomOutButton->setCommandId(Constants::ZOOM_OUT);
|
2020-11-17 15:50:11 +01:00
|
|
|
connect(m_zoomOutButton, &QToolButton::clicked, this, [this] { emit zoomOutRequested(1); });
|
2017-12-08 17:20:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IOutputPane::~IOutputPane()
|
|
|
|
|
{
|
2018-02-27 09:08:38 +01:00
|
|
|
const int i = Utils::indexOf(g_outputPanes, Utils::equal(&OutputPaneData::pane, this));
|
|
|
|
|
QTC_ASSERT(i >= 0, return);
|
|
|
|
|
delete g_outputPanes.at(i).button;
|
2019-10-15 14:08:02 +02:00
|
|
|
g_outputPanes.removeAt(i);
|
2019-03-31 08:04:43 +02:00
|
|
|
|
|
|
|
|
delete m_zoomInButton;
|
|
|
|
|
delete m_zoomOutButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QWidget *> IOutputPane::toolBarWidgets() const
|
|
|
|
|
{
|
2019-05-14 13:55:14 +02:00
|
|
|
QList<QWidget *> widgets;
|
|
|
|
|
if (m_filterOutputLineEdit)
|
|
|
|
|
widgets << m_filterOutputLineEdit;
|
|
|
|
|
return widgets << m_zoomInButton << m_zoomOutButton;
|
2019-03-31 08:04:43 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-08 17:55:43 +03:00
|
|
|
void IOutputPane::visibilityChanged(bool /*visible*/)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-31 08:04:43 +02:00
|
|
|
void IOutputPane::setFont(const QFont &font)
|
|
|
|
|
{
|
|
|
|
|
emit fontChanged(font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IOutputPane::setWheelZoomEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
emit wheelZoomEnabledChanged(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 13:55:14 +02:00
|
|
|
void IOutputPane::setupFilterUi(const QString &historyKey)
|
|
|
|
|
{
|
|
|
|
|
m_filterOutputLineEdit = new FancyLineEdit;
|
|
|
|
|
m_filterActionRegexp = new QAction(this);
|
|
|
|
|
m_filterActionRegexp->setCheckable(true);
|
|
|
|
|
m_filterActionRegexp->setText(tr("Use Regular Expressions"));
|
|
|
|
|
connect(m_filterActionRegexp, &QAction::toggled, this, &IOutputPane::setRegularExpressions);
|
|
|
|
|
Core::ActionManager::registerAction(m_filterActionRegexp, filterRegexpActionId());
|
|
|
|
|
|
|
|
|
|
m_filterActionCaseSensitive = new QAction(this);
|
|
|
|
|
m_filterActionCaseSensitive->setCheckable(true);
|
|
|
|
|
m_filterActionCaseSensitive->setText(tr("Case Sensitive"));
|
|
|
|
|
connect(m_filterActionCaseSensitive, &QAction::toggled, this, &IOutputPane::setCaseSensitive);
|
|
|
|
|
Core::ActionManager::registerAction(m_filterActionCaseSensitive,
|
|
|
|
|
filterCaseSensitivityActionId());
|
|
|
|
|
|
2019-11-18 13:56:59 +01:00
|
|
|
m_invertFilterAction = new QAction(this);
|
|
|
|
|
m_invertFilterAction->setCheckable(true);
|
|
|
|
|
m_invertFilterAction->setText(tr("Show Non-matching Lines"));
|
|
|
|
|
connect(m_invertFilterAction, &QAction::toggled, this, [this] {
|
|
|
|
|
m_invertFilter = m_invertFilterAction->isChecked();
|
|
|
|
|
updateFilter();
|
|
|
|
|
});
|
|
|
|
|
Core::ActionManager::registerAction(m_invertFilterAction, filterInvertedActionId());
|
|
|
|
|
|
2019-05-14 13:55:14 +02:00
|
|
|
m_filterOutputLineEdit->setPlaceholderText(tr("Filter output..."));
|
|
|
|
|
m_filterOutputLineEdit->setButtonVisible(FancyLineEdit::Left, true);
|
|
|
|
|
m_filterOutputLineEdit->setButtonIcon(FancyLineEdit::Left, Icons::MAGNIFIER.icon());
|
|
|
|
|
m_filterOutputLineEdit->setFiltering(true);
|
|
|
|
|
m_filterOutputLineEdit->setEnabled(false);
|
|
|
|
|
m_filterOutputLineEdit->setHistoryCompleter(historyKey);
|
|
|
|
|
connect(m_filterOutputLineEdit, &FancyLineEdit::textChanged,
|
|
|
|
|
this, &IOutputPane::updateFilter);
|
|
|
|
|
connect(m_filterOutputLineEdit, &FancyLineEdit::returnPressed,
|
|
|
|
|
this, &IOutputPane::updateFilter);
|
|
|
|
|
connect(m_filterOutputLineEdit, &FancyLineEdit::leftButtonClicked,
|
|
|
|
|
this, &IOutputPane::filterOutputButtonClicked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString IOutputPane::filterText() const
|
|
|
|
|
{
|
|
|
|
|
return m_filterOutputLineEdit->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IOutputPane::setFilteringEnabled(bool enable)
|
|
|
|
|
{
|
|
|
|
|
m_filterOutputLineEdit->setEnabled(enable);
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-20 17:27:10 +02:00
|
|
|
void IOutputPane::setupContext(const char *context, QWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(!m_context, return);
|
|
|
|
|
m_context = new IContext(this);
|
|
|
|
|
m_context->setContext(Context(context));
|
|
|
|
|
m_context->setWidget(widget);
|
|
|
|
|
ICore::addContextObject(m_context);
|
|
|
|
|
|
|
|
|
|
const auto zoomInAction = new QAction(this);
|
|
|
|
|
Core::ActionManager::registerAction(zoomInAction, Constants::ZOOM_IN, m_context->context());
|
2020-11-17 15:50:11 +01:00
|
|
|
connect(zoomInAction, &QAction::triggered, this, [this] { emit zoomInRequested(1); });
|
2019-06-20 17:27:10 +02:00
|
|
|
const auto zoomOutAction = new QAction(this);
|
|
|
|
|
Core::ActionManager::registerAction(zoomOutAction, Constants::ZOOM_OUT, m_context->context());
|
2020-11-17 15:50:11 +01:00
|
|
|
connect(zoomOutAction, &QAction::triggered, this, [this] { emit zoomOutRequested(1); });
|
2019-06-20 17:27:10 +02:00
|
|
|
const auto resetZoomAction = new QAction(this);
|
|
|
|
|
Core::ActionManager::registerAction(resetZoomAction, Constants::ZOOM_RESET,
|
|
|
|
|
m_context->context());
|
2020-11-17 15:50:11 +01:00
|
|
|
connect(resetZoomAction, &QAction::triggered, this, &IOutputPane::resetZoomRequested);
|
2019-06-20 17:27:10 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-31 08:04:43 +02:00
|
|
|
void IOutputPane::setZoomButtonsEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
m_zoomInButton->setEnabled(enabled);
|
|
|
|
|
m_zoomOutButton->setEnabled(enabled);
|
2017-12-08 17:20:48 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-14 13:55:14 +02:00
|
|
|
void IOutputPane::updateFilter()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(false, qDebug() << "updateFilter() needs to get re-implemented");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IOutputPane::filterOutputButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
auto popup = new Core::OptionsPopup(m_filterOutputLineEdit,
|
2019-11-18 13:56:59 +01:00
|
|
|
{filterRegexpActionId(), filterCaseSensitivityActionId(), filterInvertedActionId()});
|
2019-05-14 13:55:14 +02:00
|
|
|
popup->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IOutputPane::setRegularExpressions(bool regularExpressions)
|
|
|
|
|
{
|
|
|
|
|
m_filterRegexp = regularExpressions;
|
2019-05-15 13:56:03 +02:00
|
|
|
updateFilter();
|
2019-05-14 13:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Id IOutputPane::filterRegexpActionId() const
|
|
|
|
|
{
|
|
|
|
|
return Id("OutputFilter.RegularExpressions").withSuffix(metaObject()->className());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Id IOutputPane::filterCaseSensitivityActionId() const
|
|
|
|
|
{
|
|
|
|
|
return Id("OutputFilter.CaseSensitive").withSuffix(metaObject()->className());
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-18 13:56:59 +01:00
|
|
|
Id IOutputPane::filterInvertedActionId() const
|
|
|
|
|
{
|
|
|
|
|
return Id("OutputFilter.Invert").withSuffix(metaObject()->className());
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 13:55:14 +02:00
|
|
|
void IOutputPane::setCaseSensitive(bool caseSensitive)
|
|
|
|
|
{
|
2019-05-15 13:56:03 +02:00
|
|
|
m_filterCaseSensitivity = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
|
|
|
|
updateFilter();
|
2019-05-14 13:55:14 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2018-02-27 09:08:38 +01:00
|
|
|
const char outputPaneSettingsKeyC[] = "OutputPaneVisibility";
|
|
|
|
|
const char outputPaneIdKeyC[] = "id";
|
|
|
|
|
const char outputPaneVisibleKeyC[] = "visible";
|
|
|
|
|
const int buttonBorderWidth = 3;
|
2012-05-16 18:27:45 +02:00
|
|
|
|
2016-03-22 09:42:39 +01:00
|
|
|
static int numberAreaWidth()
|
|
|
|
|
{
|
2016-06-15 17:41:33 +02:00
|
|
|
return creatorTheme()->flag(Theme::FlatToolBars) ? 15 : 19;
|
2016-03-22 09:42:39 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
////
|
|
|
|
|
// OutputPaneManager
|
|
|
|
|
////
|
|
|
|
|
|
2018-07-21 21:11:46 +02:00
|
|
|
static OutputPaneManager *m_instance = nullptr;
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
void OutputPaneManager::create()
|
|
|
|
|
{
|
|
|
|
|
m_instance = new OutputPaneManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::destroy()
|
|
|
|
|
{
|
|
|
|
|
delete m_instance;
|
2018-07-21 21:11:46 +02:00
|
|
|
m_instance = nullptr;
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OutputPaneManager *OutputPaneManager::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::updateStatusButtons(bool visible)
|
|
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
int idx = currentIndex();
|
|
|
|
|
if (idx == -1)
|
|
|
|
|
return;
|
2018-02-27 09:08:38 +01:00
|
|
|
QTC_ASSERT(idx < g_outputPanes.size(), return);
|
|
|
|
|
const OutputPaneData &data = g_outputPanes.at(idx);
|
|
|
|
|
QTC_ASSERT(data.button, return);
|
|
|
|
|
data.button->setChecked(visible);
|
|
|
|
|
data.pane->visibilityChanged(visible);
|
2016-03-08 14:09:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::updateMaximizeButton(bool maximized)
|
|
|
|
|
{
|
|
|
|
|
if (maximized) {
|
|
|
|
|
m_instance->m_minMaxAction->setIcon(m_instance->m_minimizeIcon);
|
2022-02-25 13:59:49 +01:00
|
|
|
m_instance->m_minMaxAction->setText(tr("Minimize"));
|
2016-03-08 14:09:01 +01:00
|
|
|
} else {
|
|
|
|
|
m_instance->m_minMaxAction->setIcon(m_instance->m_maximizeIcon);
|
2022-02-25 13:59:49 +01:00
|
|
|
m_instance->m_minMaxAction->setText(tr("Maximize"));
|
2016-03-08 14:09:01 +01:00
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2018-02-27 09:08:38 +01:00
|
|
|
// Return shortcut as Alt+<number> or Cmd+<number> if number is a non-zero digit
|
|
|
|
|
static QKeySequence paneShortCut(int number)
|
|
|
|
|
{
|
|
|
|
|
if (number < 1 || number > 9)
|
|
|
|
|
return QKeySequence();
|
|
|
|
|
|
|
|
|
|
const int modifier = HostOsInfo::isMacHost() ? Qt::CTRL : Qt::ALT;
|
|
|
|
|
return QKeySequence(modifier | (Qt::Key_0 + number));
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
OutputPaneManager::OutputPaneManager(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
2012-05-16 18:27:45 +02:00
|
|
|
m_titleLabel(new QLabel),
|
|
|
|
|
m_manageButton(new OutputPaneManageButton),
|
2010-09-16 12:26:28 +02:00
|
|
|
m_closeButton(new QToolButton),
|
|
|
|
|
m_minMaxButton(new QToolButton),
|
|
|
|
|
m_outputWidgetPane(new QStackedWidget),
|
|
|
|
|
m_opToolBarWidgets(new QStackedWidget),
|
2016-08-03 17:55:54 +02:00
|
|
|
m_minimizeIcon(Utils::Icons::ARROW_DOWN.icon()),
|
2018-07-21 21:11:46 +02:00
|
|
|
m_maximizeIcon(Utils::Icons::ARROW_UP.icon())
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
|
|
|
|
setWindowTitle(tr("Output"));
|
2012-05-16 18:27:45 +02:00
|
|
|
|
|
|
|
|
m_titleLabel->setContentsMargins(5, 0, 5, 0);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2011-06-22 15:41:18 +02:00
|
|
|
m_clearAction = new QAction(this);
|
2016-08-03 17:55:54 +02:00
|
|
|
m_clearAction->setIcon(Utils::Icons::CLEAN.icon());
|
2011-06-22 15:41:18 +02:00
|
|
|
m_clearAction->setText(tr("Clear"));
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(m_clearAction, &QAction::triggered, this, &OutputPaneManager::clearPage);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
m_nextAction = new QAction(this);
|
2020-07-10 18:44:18 +09:00
|
|
|
m_nextAction->setIcon(Utils::Icons::ARROW_DOWN_TOOLBAR.icon());
|
2010-09-16 12:26:28 +02:00
|
|
|
m_nextAction->setText(tr("Next Item"));
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(m_nextAction, &QAction::triggered, this, &OutputPaneManager::slotNext);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
m_prevAction = new QAction(this);
|
2020-07-10 18:44:18 +09:00
|
|
|
m_prevAction->setIcon(Utils::Icons::ARROW_UP_TOOLBAR.icon());
|
2010-09-16 12:26:28 +02:00
|
|
|
m_prevAction->setText(tr("Previous Item"));
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(m_prevAction, &QAction::triggered, this, &OutputPaneManager::slotPrev);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
m_minMaxAction = new QAction(this);
|
|
|
|
|
m_minMaxAction->setIcon(m_maximizeIcon);
|
2022-02-25 13:59:49 +01:00
|
|
|
m_minMaxAction->setText(tr("Maximize"));
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2015-11-23 16:41:54 +01:00
|
|
|
m_closeButton->setIcon(Icons::CLOSE_SPLIT_BOTTOM.icon());
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(m_closeButton, &QAbstractButton::clicked, this, &OutputPaneManager::slotHide);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(ICore::instance(), &ICore::saveSettingsRequested, this, &OutputPaneManager::saveSettings);
|
2012-05-16 18:27:45 +02:00
|
|
|
|
2018-07-21 21:11:46 +02:00
|
|
|
auto mainlayout = new QVBoxLayout;
|
2010-09-16 12:26:28 +02:00
|
|
|
mainlayout->setSpacing(0);
|
2019-08-29 10:36:01 +02:00
|
|
|
mainlayout->setContentsMargins(0, 0, 0, 0);
|
2015-02-03 23:48:19 +02:00
|
|
|
m_toolBar = new StyledBar;
|
2018-07-21 21:11:46 +02:00
|
|
|
auto toolLayout = new QHBoxLayout(m_toolBar);
|
2019-08-29 10:36:01 +02:00
|
|
|
toolLayout->setContentsMargins(0, 0, 0, 0);
|
2010-09-16 12:26:28 +02:00
|
|
|
toolLayout->setSpacing(0);
|
2012-05-16 18:27:45 +02:00
|
|
|
toolLayout->addWidget(m_titleLabel);
|
2015-02-03 23:48:19 +02:00
|
|
|
toolLayout->addWidget(new StyledSeparator);
|
2011-06-22 15:41:18 +02:00
|
|
|
m_clearButton = new QToolButton;
|
2010-09-16 12:26:28 +02:00
|
|
|
toolLayout->addWidget(m_clearButton);
|
|
|
|
|
m_prevToolButton = new QToolButton;
|
|
|
|
|
toolLayout->addWidget(m_prevToolButton);
|
|
|
|
|
m_nextToolButton = new QToolButton;
|
|
|
|
|
toolLayout->addWidget(m_nextToolButton);
|
|
|
|
|
toolLayout->addWidget(m_opToolBarWidgets);
|
|
|
|
|
toolLayout->addWidget(m_minMaxButton);
|
|
|
|
|
toolLayout->addWidget(m_closeButton);
|
|
|
|
|
mainlayout->addWidget(m_toolBar);
|
|
|
|
|
mainlayout->addWidget(m_outputWidgetPane, 10);
|
2014-11-16 10:52:41 +02:00
|
|
|
mainlayout->addWidget(new FindToolBarPlaceHolder(this));
|
2010-09-16 12:26:28 +02:00
|
|
|
setLayout(mainlayout);
|
|
|
|
|
|
|
|
|
|
m_buttonsWidget = new QWidget;
|
2018-12-10 17:10:17 +01:00
|
|
|
m_buttonsWidget->setObjectName("OutputPaneButtons"); // used for UI introduction
|
2010-09-16 12:26:28 +02:00
|
|
|
m_buttonsWidget->setLayout(new QHBoxLayout);
|
|
|
|
|
m_buttonsWidget->layout()->setContentsMargins(5,0,0,0);
|
2016-03-22 09:42:39 +01:00
|
|
|
m_buttonsWidget->layout()->setSpacing(
|
2016-06-15 17:41:33 +02:00
|
|
|
creatorTheme()->flag(Theme::FlatToolBars) ? 9 : 4);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2018-01-24 17:41:53 +01:00
|
|
|
StatusBarManager::addStatusBarWidget(m_buttonsWidget, StatusBarManager::Second);
|
|
|
|
|
|
2020-03-04 10:44:07 +01:00
|
|
|
ActionContainer *mview = ActionManager::actionContainer(Constants::M_VIEW);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
// Window->Output Panes
|
2020-03-04 10:44:07 +01:00
|
|
|
ActionContainer *mpanes = ActionManager::createMenu(Constants::M_VIEW_PANES);
|
|
|
|
|
mview->addMenu(mpanes, Constants::G_VIEW_PANES);
|
2022-03-04 12:03:29 +01:00
|
|
|
mpanes->menu()->setTitle(tr("Out&put"));
|
2010-09-16 12:26:28 +02:00
|
|
|
mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
|
|
|
|
|
mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");
|
|
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
Command *cmd;
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
cmd = ActionManager::registerAction(m_clearAction, Constants::OUTPUTPANE_CLEAR);
|
|
|
|
|
m_clearButton->setDefaultAction(
|
|
|
|
|
ProxyAction::proxyActionWithIcon(m_clearAction, Utils::Icons::CLEAN_TOOLBAR.icon()));
|
2011-06-22 15:41:18 +02:00
|
|
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
|
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem");
|
2011-12-22 14:44:14 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
|
2016-04-25 09:36:35 +02:00
|
|
|
m_prevToolButton->setDefaultAction(
|
2020-07-10 18:44:18 +09:00
|
|
|
ProxyAction::proxyActionWithIcon(m_prevAction, Utils::Icons::ARROW_UP_TOOLBAR.icon()));
|
2010-09-16 12:26:28 +02:00
|
|
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
|
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem");
|
2016-04-25 09:36:35 +02:00
|
|
|
m_nextToolButton->setDefaultAction(
|
2020-07-10 18:44:18 +09:00
|
|
|
ProxyAction::proxyActionWithIcon(m_nextAction, Utils::Icons::ARROW_DOWN_TOOLBAR.icon()));
|
2011-12-22 14:44:14 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
|
2010-09-16 12:26:28 +02:00
|
|
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
|
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax");
|
2018-02-02 13:39:18 +01:00
|
|
|
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+9") : tr("Alt+Shift+9")));
|
2010-09-16 12:26:28 +02:00
|
|
|
cmd->setAttribute(Command::CA_UpdateText);
|
|
|
|
|
cmd->setAttribute(Command::CA_UpdateIcon);
|
|
|
|
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
2016-03-08 14:09:01 +01:00
|
|
|
connect(m_minMaxAction, &QAction::triggered, this, &OutputPaneManager::toggleMaximized);
|
2010-09-16 12:26:28 +02:00
|
|
|
m_minMaxButton->setDefaultAction(cmd->action());
|
|
|
|
|
|
2015-02-26 13:58:00 +01:00
|
|
|
mpanes->addSeparator("Coreplugin.OutputPane.ActionsGroup");
|
2021-06-18 16:27:13 +02:00
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
void OutputPaneManager::initialize()
|
|
|
|
|
{
|
|
|
|
|
ActionContainer *mpanes = ActionManager::actionContainer(Constants::M_VIEW_PANES);
|
|
|
|
|
QFontMetrics titleFm = m_instance->m_titleLabel->fontMetrics();
|
2012-05-16 18:27:45 +02:00
|
|
|
int minTitleWidth = 0;
|
|
|
|
|
|
2018-02-27 09:08:38 +01:00
|
|
|
Utils::sort(g_outputPanes, [](const OutputPaneData &d1, const OutputPaneData &d2) {
|
|
|
|
|
return d1.pane->priorityInStatusBar() > d2.pane->priorityInStatusBar();
|
2014-06-16 18:25:52 +04:00
|
|
|
});
|
2017-12-15 08:56:54 +01:00
|
|
|
const int n = g_outputPanes.size();
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
int shortcutNumber = 1;
|
2013-09-03 11:42:35 +02:00
|
|
|
const Id baseId = "QtCreator.Pane.";
|
2012-05-16 18:27:45 +02:00
|
|
|
for (int i = 0; i != n; ++i) {
|
2018-02-27 09:08:38 +01:00
|
|
|
OutputPaneData &data = g_outputPanes[i];
|
|
|
|
|
IOutputPane *outPane = data.pane;
|
2021-06-18 16:27:13 +02:00
|
|
|
const int idx = m_instance->m_outputWidgetPane->addWidget(outPane->outputWidget(m_instance));
|
2012-05-16 18:27:45 +02:00
|
|
|
QTC_CHECK(idx == i);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
connect(outPane, &IOutputPane::showPage, m_instance, [idx](int flags) {
|
|
|
|
|
m_instance->showPage(idx, flags);
|
2016-02-02 09:10:54 +02:00
|
|
|
});
|
2021-06-18 16:27:13 +02:00
|
|
|
connect(outPane, &IOutputPane::hidePage, m_instance, &OutputPaneManager::slotHide);
|
2018-02-27 09:08:38 +01:00
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
connect(outPane, &IOutputPane::togglePage, m_instance, [idx](int flags) {
|
|
|
|
|
if (OutputPanePlaceHolder::isCurrentVisible() && m_instance->currentIndex() == idx)
|
|
|
|
|
m_instance->slotHide();
|
2018-02-27 09:08:38 +01:00
|
|
|
else
|
2021-06-18 16:27:13 +02:00
|
|
|
m_instance->showPage(idx, flags);
|
2018-02-27 09:08:38 +01:00
|
|
|
});
|
|
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
connect(outPane, &IOutputPane::navigateStateUpdate, m_instance, [idx, outPane] {
|
|
|
|
|
if (m_instance->currentIndex() == idx) {
|
|
|
|
|
m_instance->m_prevAction->setEnabled(outPane->canNavigate()
|
|
|
|
|
&& outPane->canPrevious());
|
|
|
|
|
m_instance->m_nextAction->setEnabled(outPane->canNavigate() && outPane->canNext());
|
2018-02-27 09:08:38 +01:00
|
|
|
}
|
|
|
|
|
});
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
QWidget *toolButtonsContainer = new QWidget(m_instance->m_opToolBarWidgets);
|
2018-07-21 21:11:46 +02:00
|
|
|
auto toolButtonsLayout = new QHBoxLayout;
|
2019-08-29 10:36:01 +02:00
|
|
|
toolButtonsLayout->setContentsMargins(0, 0, 0, 0);
|
2010-09-16 12:26:28 +02:00
|
|
|
toolButtonsLayout->setSpacing(0);
|
2022-05-02 11:22:55 +02:00
|
|
|
const QList<QWidget *> toolBarWidgets = outPane->toolBarWidgets();
|
|
|
|
|
for (QWidget *toolButton : toolBarWidgets)
|
2010-09-16 12:26:28 +02:00
|
|
|
toolButtonsLayout->addWidget(toolButton);
|
|
|
|
|
toolButtonsLayout->addStretch(5);
|
|
|
|
|
toolButtonsContainer->setLayout(toolButtonsLayout);
|
|
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
m_instance->m_opToolBarWidgets->addWidget(toolButtonsContainer);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2019-02-11 10:32:46 +01:00
|
|
|
minTitleWidth = qMax(minTitleWidth, titleFm.horizontalAdvance(outPane->displayName()));
|
2012-05-16 18:27:45 +02:00
|
|
|
|
2013-03-19 13:51:25 +01:00
|
|
|
QString suffix = outPane->displayName().simplified();
|
|
|
|
|
suffix.remove(QLatin1Char(' '));
|
2018-02-27 09:08:38 +01:00
|
|
|
data.id = baseId.withSuffix(suffix);
|
2021-06-18 16:27:13 +02:00
|
|
|
data.action = new QAction(outPane->displayName(), m_instance);
|
2018-02-27 09:08:38 +01:00
|
|
|
Command *cmd = ActionManager::registerAction(data.action, data.id);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
|
|
|
|
|
|
2016-02-15 09:12:25 +01:00
|
|
|
cmd->setDefaultKeySequence(paneShortCut(shortcutNumber));
|
2021-06-18 16:27:13 +02:00
|
|
|
auto button = new OutputPaneToggleButton(shortcutNumber,
|
|
|
|
|
outPane->displayName(),
|
2018-02-27 09:08:38 +01:00
|
|
|
cmd->action());
|
|
|
|
|
data.button = button;
|
|
|
|
|
|
|
|
|
|
connect(outPane, &IOutputPane::flashButton, button, [button] { button->flash(); });
|
2021-06-18 16:27:13 +02:00
|
|
|
connect(outPane,
|
|
|
|
|
&IOutputPane::setBadgeNumber,
|
|
|
|
|
button,
|
|
|
|
|
&OutputPaneToggleButton::setIconBadgeNumber);
|
2018-02-27 09:08:38 +01:00
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
++shortcutNumber;
|
2021-06-18 16:27:13 +02:00
|
|
|
m_instance->m_buttonsWidget->layout()->addWidget(data.button);
|
|
|
|
|
connect(data.button, &QAbstractButton::clicked, m_instance, [i] {
|
|
|
|
|
m_instance->buttonTriggered(i);
|
|
|
|
|
});
|
2012-05-16 18:27:45 +02:00
|
|
|
|
|
|
|
|
bool visible = outPane->priorityInStatusBar() != -1;
|
2018-02-27 09:08:38 +01:00
|
|
|
data.button->setVisible(visible);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
connect(data.action, &QAction::triggered, m_instance, [i] {
|
|
|
|
|
m_instance->shortcutTriggered(i);
|
2018-02-27 09:08:38 +01:00
|
|
|
});
|
2010-09-17 13:50:17 +02:00
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
m_instance->m_titleLabel->setMinimumWidth(
|
|
|
|
|
minTitleWidth + m_instance->m_titleLabel->contentsMargins().left()
|
|
|
|
|
+ m_instance->m_titleLabel->contentsMargins().right());
|
|
|
|
|
m_instance->m_buttonsWidget->layout()->addWidget(m_instance->m_manageButton);
|
|
|
|
|
connect(m_instance->m_manageButton,
|
|
|
|
|
&QAbstractButton::clicked,
|
|
|
|
|
m_instance,
|
|
|
|
|
&OutputPaneManager::popupMenu);
|
2012-05-16 18:27:45 +02:00
|
|
|
|
2021-06-18 16:27:13 +02:00
|
|
|
m_instance->readSettings();
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-21 21:11:46 +02:00
|
|
|
OutputPaneManager::~OutputPaneManager() = default;
|
2018-02-27 09:08:38 +01:00
|
|
|
|
|
|
|
|
void OutputPaneManager::shortcutTriggered(int idx)
|
|
|
|
|
{
|
|
|
|
|
IOutputPane *outputPane = g_outputPanes.at(idx).pane;
|
2012-05-16 18:27:45 +02:00
|
|
|
// Now check the special case, the output window is already visible,
|
|
|
|
|
// we are already on that page but the outputpane doesn't have focus
|
|
|
|
|
// then just give it focus.
|
|
|
|
|
int current = currentIndex();
|
|
|
|
|
if (OutputPanePlaceHolder::isCurrentVisible() && current == idx) {
|
2019-10-22 17:25:33 +02:00
|
|
|
if ((!m_outputWidgetPane->isActiveWindow() || !outputPane->hasFocus())
|
|
|
|
|
&& outputPane->canFocus()) {
|
2012-05-16 18:27:45 +02:00
|
|
|
outputPane->setFocus();
|
2013-05-07 11:39:45 +02:00
|
|
|
ICore::raiseWindow(m_outputWidgetPane);
|
|
|
|
|
} else {
|
2012-05-16 18:27:45 +02:00
|
|
|
slotHide();
|
2013-05-07 11:39:45 +02:00
|
|
|
}
|
2012-05-16 18:27:45 +02:00
|
|
|
} else {
|
|
|
|
|
// Else do the same as clicking on the button does.
|
|
|
|
|
buttonTriggered(idx);
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 14:09:01 +01:00
|
|
|
int OutputPaneManager::outputPaneHeightSetting()
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
2016-03-08 14:09:01 +01:00
|
|
|
return m_instance->m_outputPaneHeightSetting;
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2016-03-08 14:09:01 +01:00
|
|
|
void OutputPaneManager::setOutputPaneHeightSetting(int value)
|
|
|
|
|
{
|
|
|
|
|
m_instance->m_outputPaneHeightSetting = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::toggleMaximized()
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
OutputPanePlaceHolder *ph = OutputPanePlaceHolder::getCurrent();
|
|
|
|
|
QTC_ASSERT(ph, return);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
if (!ph->isVisible()) // easier than disabling/enabling the action
|
2010-09-16 12:26:28 +02:00
|
|
|
return;
|
2016-03-08 14:09:01 +01:00
|
|
|
ph->setMaximized(!ph->isMaximized());
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
void OutputPaneManager::buttonTriggered(int idx)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(idx >= 0, return);
|
|
|
|
|
if (idx == currentIndex() && OutputPanePlaceHolder::isCurrentVisible()) {
|
2010-09-16 12:26:28 +02:00
|
|
|
// we should toggle and the page is already visible and we are actually closeable
|
|
|
|
|
slotHide();
|
|
|
|
|
} else {
|
2012-09-13 15:50:06 +02:00
|
|
|
showPage(idx, IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
void OutputPaneManager::readSettings()
|
|
|
|
|
{
|
|
|
|
|
QSettings *settings = ICore::settings();
|
|
|
|
|
int num = settings->beginReadArray(QLatin1String(outputPaneSettingsKeyC));
|
|
|
|
|
for (int i = 0; i < num; ++i) {
|
|
|
|
|
settings->setArrayIndex(i);
|
2018-02-27 09:08:38 +01:00
|
|
|
Id id = Id::fromSetting(settings->value(QLatin1String(outputPaneIdKeyC)));
|
|
|
|
|
const int idx = Utils::indexOf(g_outputPanes, Utils::equal(&OutputPaneData::id, id));
|
2018-04-24 14:07:17 +02:00
|
|
|
if (idx < 0) // happens for e.g. disabled plugins (with outputpanes) that were loaded before
|
|
|
|
|
continue;
|
2018-02-27 09:08:38 +01:00
|
|
|
const bool visible = settings->value(QLatin1String(outputPaneVisibleKeyC)).toBool();
|
|
|
|
|
g_outputPanes[idx].button->setVisible(visible);
|
2012-05-16 18:27:45 +02:00
|
|
|
}
|
|
|
|
|
settings->endArray();
|
|
|
|
|
|
2016-03-08 14:09:01 +01:00
|
|
|
m_outputPaneHeightSetting = settings->value(QLatin1String("OutputPanePlaceHolder/Height"), 0).toInt();
|
2012-05-16 18:27:45 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
void OutputPaneManager::slotNext()
|
|
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
int idx = currentIndex();
|
2010-09-16 12:26:28 +02:00
|
|
|
ensurePageVisible(idx);
|
2018-02-27 09:08:38 +01:00
|
|
|
IOutputPane *out = g_outputPanes.at(idx).pane;
|
2010-09-16 12:26:28 +02:00
|
|
|
if (out->canNext())
|
|
|
|
|
out->goToNext();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::slotPrev()
|
|
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
int idx = currentIndex();
|
2010-09-16 12:26:28 +02:00
|
|
|
ensurePageVisible(idx);
|
2018-02-27 09:08:38 +01:00
|
|
|
IOutputPane *out = g_outputPanes.at(idx).pane;
|
2010-09-16 12:26:28 +02:00
|
|
|
if (out->canPrevious())
|
|
|
|
|
out->goToPrev();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::slotHide()
|
|
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
OutputPanePlaceHolder *ph = OutputPanePlaceHolder::getCurrent();
|
|
|
|
|
if (ph) {
|
2020-04-09 13:53:04 +02:00
|
|
|
emit ph->visibilityChangeRequested(false);
|
2012-05-16 18:27:45 +02:00
|
|
|
ph->setVisible(false);
|
|
|
|
|
int idx = currentIndex();
|
|
|
|
|
QTC_ASSERT(idx >= 0, return);
|
2018-02-27 09:08:38 +01:00
|
|
|
g_outputPanes.at(idx).button->setChecked(false);
|
|
|
|
|
g_outputPanes.at(idx).pane->visibilityChanged(false);
|
2014-11-16 10:52:41 +02:00
|
|
|
if (IEditor *editor = EditorManager::currentEditor()) {
|
2011-12-01 13:03:08 +01:00
|
|
|
QWidget *w = editor->widget()->focusWidget();
|
|
|
|
|
if (!w)
|
|
|
|
|
w = editor->widget();
|
|
|
|
|
w->setFocus();
|
|
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::ensurePageVisible(int idx)
|
|
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
//int current = currentIndex();
|
|
|
|
|
//if (current != idx)
|
|
|
|
|
// m_outputWidgetPane->setCurrentIndex(idx);
|
|
|
|
|
setCurrentIndex(idx);
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-13 15:50:06 +02:00
|
|
|
void OutputPaneManager::showPage(int idx, int flags)
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
QTC_ASSERT(idx >= 0, return);
|
2012-09-13 15:50:06 +02:00
|
|
|
OutputPanePlaceHolder *ph = OutputPanePlaceHolder::getCurrent();
|
|
|
|
|
|
|
|
|
|
if (!ph && flags & IOutputPane::ModeSwitch) {
|
2012-05-16 18:27:45 +02:00
|
|
|
// In this mode we don't have a placeholder
|
|
|
|
|
// switch to the output mode and switch the page
|
|
|
|
|
ModeManager::activateMode(Id(Constants::MODE_EDIT));
|
2012-09-13 15:50:06 +02:00
|
|
|
ph = OutputPanePlaceHolder::getCurrent();
|
2012-05-16 18:27:45 +02:00
|
|
|
}
|
2012-09-13 15:50:06 +02:00
|
|
|
|
2013-10-24 19:19:42 +02:00
|
|
|
bool onlyFlash = !ph
|
2018-02-27 09:08:38 +01:00
|
|
|
|| (g_outputPanes.at(currentIndex()).pane->hasFocus()
|
2013-10-24 19:19:42 +02:00
|
|
|
&& !(flags & IOutputPane::WithFocus)
|
|
|
|
|
&& idx != currentIndex());
|
|
|
|
|
|
|
|
|
|
if (onlyFlash) {
|
2018-02-27 09:08:38 +01:00
|
|
|
g_outputPanes.at(idx).button->flash();
|
2013-10-24 19:19:42 +02:00
|
|
|
} else {
|
2020-04-09 13:53:04 +02:00
|
|
|
emit ph->visibilityChangeRequested(true);
|
2012-05-16 18:27:45 +02:00
|
|
|
// make the page visible
|
|
|
|
|
ph->setVisible(true);
|
2013-10-24 19:19:42 +02:00
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
ensurePageVisible(idx);
|
2018-02-27 09:08:38 +01:00
|
|
|
IOutputPane *out = g_outputPanes.at(idx).pane;
|
2015-03-19 17:10:10 +01:00
|
|
|
if (flags & IOutputPane::WithFocus) {
|
|
|
|
|
if (out->canFocus())
|
|
|
|
|
out->setFocus();
|
2013-05-07 11:39:45 +02:00
|
|
|
ICore::raiseWindow(m_outputWidgetPane);
|
|
|
|
|
}
|
2012-09-13 15:50:06 +02:00
|
|
|
|
|
|
|
|
if (flags & IOutputPane::EnsureSizeHint)
|
|
|
|
|
ph->ensureSizeHintAsMinimum();
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::focusInEvent(QFocusEvent *e)
|
|
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
if (QWidget *w = m_outputWidgetPane->currentWidget())
|
|
|
|
|
w->setFocus(e->reason());
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
void OutputPaneManager::setCurrentIndex(int idx)
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
static int lastIndex = -1;
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
if (lastIndex != -1) {
|
2018-02-27 09:08:38 +01:00
|
|
|
g_outputPanes.at(lastIndex).button->setChecked(false);
|
|
|
|
|
g_outputPanes.at(lastIndex).pane->visibilityChanged(false);
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
if (idx != -1) {
|
2010-09-16 12:26:28 +02:00
|
|
|
m_outputWidgetPane->setCurrentIndex(idx);
|
|
|
|
|
m_opToolBarWidgets->setCurrentIndex(idx);
|
|
|
|
|
|
2019-02-28 14:49:34 +01:00
|
|
|
OutputPaneData &data = g_outputPanes[idx];
|
|
|
|
|
IOutputPane *pane = data.pane;
|
|
|
|
|
data.button->show();
|
2012-05-16 18:27:45 +02:00
|
|
|
pane->visibilityChanged(true);
|
|
|
|
|
|
|
|
|
|
bool canNavigate = pane->canNavigate();
|
|
|
|
|
m_prevAction->setEnabled(canNavigate && pane->canPrevious());
|
|
|
|
|
m_nextAction->setEnabled(canNavigate && pane->canNext());
|
2018-02-27 09:08:38 +01:00
|
|
|
g_outputPanes.at(idx).button->setChecked(OutputPanePlaceHolder::isCurrentVisible());
|
2012-05-16 18:27:45 +02:00
|
|
|
m_titleLabel->setText(pane->displayName());
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
lastIndex = idx;
|
|
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
void OutputPaneManager::popupMenu()
|
|
|
|
|
{
|
|
|
|
|
QMenu menu;
|
|
|
|
|
int idx = 0;
|
2018-02-27 09:08:38 +01:00
|
|
|
for (OutputPaneData &data : g_outputPanes) {
|
|
|
|
|
QAction *act = menu.addAction(data.pane->displayName());
|
2012-05-16 18:27:45 +02:00
|
|
|
act->setCheckable(true);
|
2021-10-17 11:38:11 +03:00
|
|
|
act->setChecked(data.button->isPaneVisible());
|
2012-05-16 18:27:45 +02:00
|
|
|
act->setData(idx);
|
|
|
|
|
++idx;
|
|
|
|
|
}
|
|
|
|
|
QAction *result = menu.exec(QCursor::pos());
|
|
|
|
|
if (!result)
|
|
|
|
|
return;
|
|
|
|
|
idx = result->data().toInt();
|
2018-02-27 09:08:38 +01:00
|
|
|
QTC_ASSERT(idx >= 0 && idx < g_outputPanes.size(), return);
|
|
|
|
|
OutputPaneData &data = g_outputPanes[idx];
|
2021-10-17 11:38:11 +03:00
|
|
|
if (data.button->isPaneVisible()) {
|
2018-02-27 09:08:38 +01:00
|
|
|
data.pane->visibilityChanged(false);
|
|
|
|
|
data.button->setChecked(false);
|
|
|
|
|
data.button->hide();
|
2012-05-16 18:27:45 +02:00
|
|
|
} else {
|
2012-09-13 15:50:06 +02:00
|
|
|
showPage(idx, IOutputPane::ModeSwitch);
|
2012-05-16 18:27:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
void OutputPaneManager::saveSettings() const
|
|
|
|
|
{
|
|
|
|
|
QSettings *settings = ICore::settings();
|
2018-02-27 09:08:38 +01:00
|
|
|
const int n = g_outputPanes.size();
|
|
|
|
|
settings->beginWriteArray(QLatin1String(outputPaneSettingsKeyC), n);
|
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
|
const OutputPaneData &data = g_outputPanes.at(i);
|
2012-05-16 18:27:45 +02:00
|
|
|
settings->setArrayIndex(i);
|
2018-02-27 09:08:38 +01:00
|
|
|
settings->setValue(QLatin1String(outputPaneIdKeyC), data.id.toSetting());
|
2021-10-17 11:38:11 +03:00
|
|
|
settings->setValue(QLatin1String(outputPaneVisibleKeyC), data.button->isPaneVisible());
|
2012-05-16 18:27:45 +02:00
|
|
|
}
|
|
|
|
|
settings->endArray();
|
2016-03-08 14:09:01 +01:00
|
|
|
int heightSetting = m_outputPaneHeightSetting;
|
|
|
|
|
// update if possible
|
|
|
|
|
if (OutputPanePlaceHolder *curr = OutputPanePlaceHolder::getCurrent())
|
|
|
|
|
heightSetting = curr->nonMaximizedSize();
|
|
|
|
|
settings->setValue(QLatin1String("OutputPanePlaceHolder/Height"), heightSetting);
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneManager::clearPage()
|
|
|
|
|
{
|
2012-05-16 18:27:45 +02:00
|
|
|
int idx = currentIndex();
|
|
|
|
|
if (idx >= 0)
|
2018-02-27 09:08:38 +01:00
|
|
|
g_outputPanes.at(idx).pane->clearContents();
|
2012-05-16 18:27:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int OutputPaneManager::currentIndex() const
|
|
|
|
|
{
|
|
|
|
|
return m_outputWidgetPane->currentIndex();
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// OutputPaneToolButton
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
OutputPaneToggleButton::OutputPaneToggleButton(int number, const QString &text,
|
|
|
|
|
QAction *action, QWidget *parent)
|
2011-07-26 14:32:34 +02:00
|
|
|
: QToolButton(parent)
|
2010-09-16 12:26:28 +02:00
|
|
|
, m_number(QString::number(number))
|
|
|
|
|
, m_text(text)
|
|
|
|
|
, m_action(action)
|
2012-06-11 10:32:16 +02:00
|
|
|
, m_flashTimer(new QTimeLine(1000, this))
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
|
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
setCheckable(true);
|
2011-07-26 14:32:34 +02:00
|
|
|
QFont fnt = QApplication::font();
|
|
|
|
|
setFont(fnt);
|
2010-09-16 12:26:28 +02:00
|
|
|
if (m_action)
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(m_action, &QAction::changed, this, &OutputPaneToggleButton::updateToolTip);
|
2012-06-11 10:32:16 +02:00
|
|
|
|
|
|
|
|
m_flashTimer->setDirection(QTimeLine::Forward);
|
2020-07-16 11:48:35 +02:00
|
|
|
m_flashTimer->setEasingCurve(QEasingCurve::SineCurve);
|
2012-06-11 10:32:16 +02:00
|
|
|
m_flashTimer->setFrameRange(0, 92);
|
2019-02-26 09:40:49 +01:00
|
|
|
auto updateSlot = QOverload<>::of(&QWidget::update);
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(m_flashTimer, &QTimeLine::valueChanged, this, updateSlot);
|
|
|
|
|
connect(m_flashTimer, &QTimeLine::finished, this, updateSlot);
|
2016-03-22 09:50:39 +01:00
|
|
|
updateToolTip();
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneToggleButton::updateToolTip()
|
|
|
|
|
{
|
2016-03-22 09:50:39 +01:00
|
|
|
QTC_ASSERT(m_action, return);
|
2010-09-16 12:26:28 +02:00
|
|
|
setToolTip(m_action->toolTip());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSize OutputPaneToggleButton::sizeHint() const
|
|
|
|
|
{
|
|
|
|
|
ensurePolished();
|
|
|
|
|
|
|
|
|
|
QSize s = fontMetrics().size(Qt::TextSingleLine, m_text);
|
|
|
|
|
|
2014-08-29 17:20:39 +02:00
|
|
|
// Expand to account for border image
|
2016-03-22 09:42:39 +01:00
|
|
|
s.rwidth() += numberAreaWidth() + 1 + buttonBorderWidth + buttonBorderWidth;
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2014-08-29 17:20:39 +02:00
|
|
|
if (!m_badgeNumberLabel.text().isNull())
|
|
|
|
|
s.rwidth() += m_badgeNumberLabel.sizeHint().width() + 1;
|
2012-06-14 16:33:10 +02:00
|
|
|
|
2020-06-19 12:57:52 +02:00
|
|
|
return s;
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2014-08-29 17:20:39 +02:00
|
|
|
void OutputPaneToggleButton::paintEvent(QPaintEvent*)
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
|
|
|
|
const QFontMetrics fm = fontMetrics();
|
|
|
|
|
const int baseLine = (height() - fm.height() + 1) / 2 + fm.ascent();
|
2019-02-11 10:32:46 +01:00
|
|
|
const int numberWidth = fm.horizontalAdvance(m_number);
|
2010-09-16 12:26:28 +02:00
|
|
|
|
|
|
|
|
QPainter p(this);
|
2014-08-29 17:20:39 +02:00
|
|
|
|
|
|
|
|
QStyleOption styleOption;
|
|
|
|
|
styleOption.initFrom(this);
|
2015-02-03 23:48:19 +02:00
|
|
|
const bool hovered = !HostOsInfo::isMacHost() && (styleOption.state & QStyle::State_MouseOver);
|
2014-08-29 17:20:39 +02:00
|
|
|
|
2016-06-15 17:41:33 +02:00
|
|
|
if (creatorTheme()->flag(Theme::FlatToolBars)) {
|
2016-03-16 10:18:21 +01:00
|
|
|
Theme::Color c = Theme::BackgroundColorDark;
|
|
|
|
|
|
|
|
|
|
if (hovered)
|
|
|
|
|
c = Theme::BackgroundColorHover;
|
|
|
|
|
else if (isDown() || isChecked())
|
|
|
|
|
c = Theme::BackgroundColorSelected;
|
|
|
|
|
|
|
|
|
|
if (c != Theme::BackgroundColorDark)
|
|
|
|
|
p.fillRect(rect(), creatorTheme()->color(c));
|
2016-06-15 17:41:33 +02:00
|
|
|
} else {
|
2018-07-21 21:11:46 +02:00
|
|
|
const QImage *image = nullptr;
|
2016-07-08 16:20:50 +02:00
|
|
|
if (isDown()) {
|
|
|
|
|
static const QImage pressed(
|
2016-10-07 12:44:39 +02:00
|
|
|
StyleHelper::dpiSpecificImageFile(":/utils/images/panel_button_pressed.png"));
|
2016-07-08 16:20:50 +02:00
|
|
|
image = &pressed;
|
|
|
|
|
} else if (isChecked()) {
|
|
|
|
|
if (hovered) {
|
|
|
|
|
static const QImage checkedHover(
|
2016-10-07 12:44:39 +02:00
|
|
|
StyleHelper::dpiSpecificImageFile(":/utils/images/panel_button_checked_hover.png"));
|
2016-07-08 16:20:50 +02:00
|
|
|
image = &checkedHover;
|
|
|
|
|
} else {
|
|
|
|
|
static const QImage checked(
|
2016-10-07 12:44:39 +02:00
|
|
|
StyleHelper::dpiSpecificImageFile(":/utils/images/panel_button_checked.png"));
|
2016-07-08 16:20:50 +02:00
|
|
|
image = &checked;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (hovered) {
|
|
|
|
|
static const QImage hover(
|
2016-10-07 12:44:39 +02:00
|
|
|
StyleHelper::dpiSpecificImageFile(":/utils/images/panel_button_hover.png"));
|
2016-07-08 16:20:50 +02:00
|
|
|
image = &hover;
|
|
|
|
|
} else {
|
|
|
|
|
static const QImage button(
|
2016-10-07 12:44:39 +02:00
|
|
|
StyleHelper::dpiSpecificImageFile(":/utils/images/panel_button.png"));
|
2016-07-08 16:20:50 +02:00
|
|
|
image = &button;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-15 17:41:33 +02:00
|
|
|
if (image)
|
|
|
|
|
StyleHelper::drawCornerImage(*image, &p, rect(), numberAreaWidth(), buttonBorderWidth, buttonBorderWidth, buttonBorderWidth);
|
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
|
|
|
}
|
2014-08-29 17:20:39 +02:00
|
|
|
|
|
|
|
|
if (m_flashTimer->state() == QTimeLine::Running)
|
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
|
|
|
{
|
|
|
|
|
QColor c = creatorTheme()->color(Theme::OutputPaneButtonFlashColor);
|
|
|
|
|
c.setAlpha (m_flashTimer->currentFrame());
|
2016-06-15 17:41:33 +02:00
|
|
|
QRect r = creatorTheme()->flag(Theme::FlatToolBars)
|
2016-03-22 09:42:39 +01:00
|
|
|
? rect() : rect().adjusted(numberAreaWidth(), 1, -1, -1);
|
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
|
|
|
p.fillRect(r, c);
|
|
|
|
|
}
|
2014-08-29 17:20:39 +02:00
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
p.setFont(font());
|
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
|
|
|
p.setPen(creatorTheme()->color(Theme::OutputPaneToggleButtonTextColorChecked));
|
2016-03-22 09:42:39 +01:00
|
|
|
p.drawText((numberAreaWidth() - numberWidth) / 2, baseLine, m_number);
|
2010-09-16 12:26:28 +02:00
|
|
|
if (!isChecked())
|
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
|
|
|
p.setPen(creatorTheme()->color(Theme::OutputPaneToggleButtonTextColorUnchecked));
|
2016-03-22 09:42:39 +01:00
|
|
|
int leftPart = numberAreaWidth() + buttonBorderWidth;
|
2014-08-29 17:20:39 +02:00
|
|
|
int labelWidth = 0;
|
|
|
|
|
if (!m_badgeNumberLabel.text().isEmpty()) {
|
|
|
|
|
const QSize labelSize = m_badgeNumberLabel.sizeHint();
|
|
|
|
|
labelWidth = labelSize.width() + 3;
|
|
|
|
|
m_badgeNumberLabel.paint(&p, width() - labelWidth, (height() - labelSize.height()) / 2, isChecked());
|
|
|
|
|
}
|
2012-06-14 16:33:10 +02:00
|
|
|
p.drawText(leftPart, baseLine, fm.elidedText(m_text, Qt::ElideRight, width() - leftPart - 1 - labelWidth));
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-11 10:32:16 +02:00
|
|
|
void OutputPaneToggleButton::checkStateSet()
|
|
|
|
|
{
|
|
|
|
|
//Stop flashing when button is checked
|
|
|
|
|
QToolButton::checkStateSet();
|
|
|
|
|
m_flashTimer->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OutputPaneToggleButton::flash(int count)
|
|
|
|
|
{
|
2012-09-11 18:17:51 +02:00
|
|
|
setVisible(true);
|
2012-06-11 10:32:16 +02:00
|
|
|
//Start flashing if button is not checked
|
|
|
|
|
if (!isChecked()) {
|
|
|
|
|
m_flashTimer->setLoopCount(count);
|
|
|
|
|
if (m_flashTimer->state() != QTimeLine::Running)
|
|
|
|
|
m_flashTimer->start();
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-14 16:33:10 +02:00
|
|
|
void OutputPaneToggleButton::setIconBadgeNumber(int number)
|
|
|
|
|
{
|
2014-09-11 07:40:47 +02:00
|
|
|
QString text = (number ? QString::number(number) : QString());
|
|
|
|
|
m_badgeNumberLabel.setText(text);
|
2012-06-14 16:33:10 +02:00
|
|
|
updateGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-17 11:38:11 +03:00
|
|
|
bool OutputPaneToggleButton::isPaneVisible() const
|
|
|
|
|
{
|
|
|
|
|
return isVisibleTo(parentWidget());
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-16 18:27:45 +02:00
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// OutputPaneManageButton
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
OutputPaneManageButton::OutputPaneManageButton()
|
|
|
|
|
{
|
|
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
setCheckable(true);
|
2016-03-04 12:08:26 +01:00
|
|
|
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
2012-05-16 18:27:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSize OutputPaneManageButton::sizeHint() const
|
|
|
|
|
{
|
|
|
|
|
ensurePolished();
|
2020-06-19 12:57:52 +02:00
|
|
|
return QSize(numberAreaWidth(), 16);
|
2012-05-16 18:27:45 +02:00
|
|
|
}
|
|
|
|
|
|
2014-08-29 17:20:39 +02:00
|
|
|
void OutputPaneManageButton::paintEvent(QPaintEvent*)
|
2012-05-16 18:27:45 +02:00
|
|
|
{
|
|
|
|
|
QPainter p(this);
|
2016-06-15 17:41:33 +02:00
|
|
|
if (!creatorTheme()->flag(Theme::FlatToolBars)) {
|
2016-10-07 12:44:39 +02:00
|
|
|
static const QImage button(StyleHelper::dpiSpecificImageFile(QStringLiteral(":/utils/images/panel_manage_button.png")));
|
2015-02-03 23:48:19 +02:00
|
|
|
StyleHelper::drawCornerImage(button, &p, rect(), buttonBorderWidth, buttonBorderWidth, buttonBorderWidth, buttonBorderWidth);
|
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
|
|
|
}
|
2012-05-16 18:27:45 +02:00
|
|
|
QStyle *s = style();
|
|
|
|
|
QStyleOption arrowOpt;
|
|
|
|
|
arrowOpt.initFrom(this);
|
2014-08-29 17:20:39 +02:00
|
|
|
arrowOpt.rect = QRect(6, rect().center().y() - 3, 8, 8);
|
2012-05-16 18:27:45 +02:00
|
|
|
arrowOpt.rect.translate(0, -3);
|
|
|
|
|
s->drawPrimitive(QStyle::PE_IndicatorArrowUp, &arrowOpt, &p, this);
|
|
|
|
|
arrowOpt.rect.translate(0, 6);
|
|
|
|
|
s->drawPrimitive(QStyle::PE_IndicatorArrowDown, &arrowOpt, &p, this);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-29 17:20:39 +02:00
|
|
|
BadgeLabel::BadgeLabel()
|
|
|
|
|
{
|
|
|
|
|
m_font = QApplication::font();
|
|
|
|
|
m_font.setBold(true);
|
|
|
|
|
m_font.setPixelSize(11);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BadgeLabel::paint(QPainter *p, int x, int y, bool isChecked)
|
|
|
|
|
{
|
|
|
|
|
const QRectF rect(QRect(QPoint(x, y), m_size));
|
|
|
|
|
p->save();
|
|
|
|
|
|
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
|
|
|
p->setBrush(creatorTheme()->color(isChecked? Theme::BadgeLabelBackgroundColorChecked
|
|
|
|
|
: Theme::BadgeLabelBackgroundColorUnchecked));
|
2014-08-29 17:20:39 +02:00
|
|
|
p->setPen(Qt::NoPen);
|
|
|
|
|
p->setRenderHint(QPainter::Antialiasing, true);
|
|
|
|
|
p->drawRoundedRect(rect, m_padding, m_padding, Qt::AbsoluteSize);
|
|
|
|
|
|
|
|
|
|
p->setFont(m_font);
|
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
|
|
|
p->setPen(creatorTheme()->color(isChecked ? Theme::BadgeLabelTextColorChecked
|
|
|
|
|
: Theme::BadgeLabelTextColorUnchecked));
|
2014-08-29 17:20:39 +02:00
|
|
|
p->drawText(rect, Qt::AlignCenter, m_text);
|
|
|
|
|
|
|
|
|
|
p->restore();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 07:37:12 +02:00
|
|
|
void BadgeLabel::setText(const QString &text)
|
2014-08-29 17:20:39 +02:00
|
|
|
{
|
|
|
|
|
m_text = text;
|
|
|
|
|
calculateSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BadgeLabel::text() const
|
|
|
|
|
{
|
|
|
|
|
return m_text;
|
|
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2014-08-29 17:20:39 +02:00
|
|
|
QSize BadgeLabel::sizeHint() const
|
|
|
|
|
{
|
|
|
|
|
return m_size;
|
|
|
|
|
}
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2014-08-29 17:20:39 +02:00
|
|
|
void BadgeLabel::calculateSize()
|
|
|
|
|
{
|
|
|
|
|
const QFontMetrics fm(m_font);
|
|
|
|
|
m_size = fm.size(Qt::TextSingleLine, m_text);
|
|
|
|
|
m_size.setWidth(m_size.width() + m_padding * 1.5);
|
|
|
|
|
m_size.setHeight(2 * m_padding + 1); // Needs to be uneven for pixel perfect vertical centering in the button
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Core
|