2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-02-08 15:50:06 +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.
|
2010-02-08 15:50:06 +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
|
|
|
****************************************************************************/
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-01-21 21:12:40 +01:00
|
|
|
#include "miniprojecttargetselector.h"
|
2013-09-13 10:16:25 +02:00
|
|
|
#include "kit.h"
|
|
|
|
|
#include "kitconfigwidget.h"
|
|
|
|
|
#include "kitmanager.h"
|
2010-07-13 16:36:37 +02:00
|
|
|
#include "target.h"
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2010-01-21 21:12:40 +01:00
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
#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-01-21 21:12:40 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2010-02-09 19:05:15 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2011-10-28 10:15:04 +00:00
|
|
|
#include <coreplugin/modemanager.h>
|
2010-01-21 21:12:40 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/session.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2011-09-26 14:48:12 +02:00
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2012-04-16 20:49:39 +04:00
|
|
|
#include <projectexplorer/projectmodels.h>
|
2011-09-26 14:48:12 +02:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2014-08-29 13:18:41 +02:00
|
|
|
#include <QGuiApplication>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QListWidget>
|
|
|
|
|
#include <QStatusBar>
|
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
#include <QPainter>
|
2015-04-21 18:39:38 +02:00
|
|
|
#include <QStyleFactory>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
|
|
|
|
#include <QItemDelegate>
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2013-11-27 16:53:25 +01:00
|
|
|
|
2010-02-23 16:52:03 +01:00
|
|
|
static QIcon createCenteredIcon(const QIcon &icon, const QIcon &overlay)
|
|
|
|
|
{
|
|
|
|
|
QPixmap targetPixmap;
|
2014-08-29 13:18:41 +02:00
|
|
|
const qreal appDevicePixelRatio = qApp->devicePixelRatio();
|
2013-11-27 16:53:25 +01:00
|
|
|
int deviceSpaceIconSize = Core::Constants::TARGET_ICON_SIZE * appDevicePixelRatio;
|
|
|
|
|
targetPixmap = QPixmap(deviceSpaceIconSize, deviceSpaceIconSize);
|
|
|
|
|
targetPixmap.setDevicePixelRatio(appDevicePixelRatio);
|
2010-02-23 16:52:03 +01:00
|
|
|
targetPixmap.fill(Qt::transparent);
|
2013-11-27 16:53:25 +01:00
|
|
|
QPainter painter(&targetPixmap); // painter in user space
|
2010-02-23 16:52:03 +01:00
|
|
|
|
2013-11-27 16:53:25 +01:00
|
|
|
QPixmap pixmap = icon.pixmap(Core::Constants::TARGET_ICON_SIZE); // already takes app devicePixelRatio into account
|
2014-08-29 13:18:41 +02:00
|
|
|
qreal pixmapDevicePixelRatio = pixmap.devicePixelRatio();
|
2013-11-27 16:53:25 +01:00
|
|
|
painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width() / pixmapDevicePixelRatio) / 2,
|
|
|
|
|
(Core::Constants::TARGET_ICON_SIZE - pixmap.height() / pixmapDevicePixelRatio) / 2, pixmap);
|
2010-02-23 16:52:03 +01:00
|
|
|
if (!overlay.isNull()) {
|
2013-11-27 16:53:25 +01:00
|
|
|
pixmap = overlay.pixmap(Core::Constants::TARGET_ICON_SIZE); // already takes app devicePixelRatio into account
|
|
|
|
|
pixmapDevicePixelRatio = pixmap.devicePixelRatio();
|
|
|
|
|
painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width() / pixmapDevicePixelRatio) / 2,
|
|
|
|
|
(Core::Constants::TARGET_ICON_SIZE - pixmap.height() / pixmapDevicePixelRatio) / 2, pixmap);
|
2010-02-23 16:52:03 +01:00
|
|
|
}
|
2013-11-27 16:53:25 +01:00
|
|
|
|
2010-02-23 16:52:03 +01:00
|
|
|
return QIcon(targetPixmap);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 21:12:40 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::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
|
|
|
using namespace Utils;
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2012-04-16 20:49:39 +04:00
|
|
|
static bool projectLesserThan(Project *p1, Project *p2)
|
|
|
|
|
{
|
|
|
|
|
int result = caseFriendlyCompare(p1->displayName(), p2->displayName());
|
|
|
|
|
if (result != 0)
|
|
|
|
|
return result < 0;
|
|
|
|
|
else
|
|
|
|
|
return p1 < p2;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
////////
|
|
|
|
|
// TargetSelectorDelegate
|
|
|
|
|
////////
|
2010-02-24 19:23:40 +01:00
|
|
|
class TargetSelectorDelegate : public QItemDelegate
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-08-24 17:20:19 +02:00
|
|
|
TargetSelectorDelegate(ListWidget *parent) : QItemDelegate(parent), m_listWidget(parent) { }
|
2010-02-24 19:23:40 +01:00
|
|
|
private:
|
2011-09-26 14:48:12 +02:00
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
2010-02-24 19:23:40 +01:00
|
|
|
void paint(QPainter *painter,
|
|
|
|
|
const QStyleOptionViewItem &option,
|
|
|
|
|
const QModelIndex &index) const;
|
|
|
|
|
mutable QImage selectionGradient;
|
2012-08-24 17:20:19 +02:00
|
|
|
ListWidget *m_listWidget;
|
2010-02-24 19:23:40 +01:00
|
|
|
};
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QSize TargetSelectorDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(option)
|
|
|
|
|
Q_UNUSED(index)
|
2012-08-24 17:20:19 +02:00
|
|
|
return QSize(m_listWidget->size().width(), 30);
|
2011-09-26 14:48:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-24 19:23:40 +01:00
|
|
|
void TargetSelectorDelegate::paint(QPainter *painter,
|
|
|
|
|
const QStyleOptionViewItem &option,
|
2011-09-26 14:48:12 +02:00
|
|
|
const QModelIndex &index) const
|
2010-02-24 19:23:40 +01:00
|
|
|
{
|
|
|
|
|
painter->save();
|
|
|
|
|
painter->setClipping(false);
|
|
|
|
|
|
|
|
|
|
if (selectionGradient.isNull())
|
|
|
|
|
selectionGradient.load(QLatin1String(":/projectexplorer/images/targetpanel_gradient.png"));
|
|
|
|
|
|
|
|
|
|
if (option.state & QStyle::State_Selected) {
|
2014-11-23 14:58:54 +02:00
|
|
|
const QColor color = (option.state & QStyle::State_HasFocus) ?
|
|
|
|
|
option.palette.highlight().color() :
|
|
|
|
|
option.palette.dark().color();
|
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
|
|
|
if (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
|
2014-11-23 14:58:54 +02:00
|
|
|
painter->fillRect(option.rect, color);
|
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
|
|
|
} else {
|
|
|
|
|
painter->fillRect(option.rect, color.darker(140));
|
2015-02-03 23:59:04 +02:00
|
|
|
StyleHelper::drawCornerImage(selectionGradient, painter, option.rect.adjusted(0, 0, 0, -1), 5, 5, 5, 5);
|
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
|
|
|
painter->setPen(QColor(255, 255, 255, 60));
|
|
|
|
|
painter->drawLine(option.rect.topLeft(), option.rect.topRight());
|
|
|
|
|
painter->setPen(QColor(255, 255, 255, 30));
|
|
|
|
|
painter->drawLine(option.rect.bottomLeft() - QPoint(0,1), option.rect.bottomRight() - QPoint(0,1));
|
|
|
|
|
painter->setPen(QColor(0, 0, 0, 80));
|
|
|
|
|
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
|
|
|
|
|
}
|
2010-02-24 19:23:40 +01:00
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
QFontMetrics fm(option.font);
|
|
|
|
|
QString text = index.data(Qt::DisplayRole).toString();
|
|
|
|
|
painter->setPen(QColor(255, 255, 255, 160));
|
|
|
|
|
QString elidedText = fm.elidedText(text, Qt::ElideMiddle, option.rect.width() - 12);
|
|
|
|
|
if (elidedText != text)
|
|
|
|
|
const_cast<QAbstractItemModel *>(index.model())->setData(index, text, Qt::ToolTipRole);
|
|
|
|
|
else
|
2012-01-09 16:30:33 +01:00
|
|
|
const_cast<QAbstractItemModel *>(index.model())->setData(index, QString(), Qt::ToolTipRole);
|
2011-09-26 14:48:12 +02:00
|
|
|
painter->drawText(option.rect.left() + 6, option.rect.top() + (option.rect.height() - fm.height()) / 2 + fm.ascent(), elidedText);
|
|
|
|
|
|
2010-02-24 19:23:40 +01:00
|
|
|
painter->restore();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
////////
|
|
|
|
|
// ListWidget
|
|
|
|
|
////////
|
|
|
|
|
ListWidget::ListWidget(QWidget *parent)
|
2012-08-24 17:20:19 +02:00
|
|
|
: QListWidget(parent), m_maxCount(0), m_optimalWidth(0)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
setAlternatingRowColors(false);
|
|
|
|
|
setFocusPolicy(Qt::WheelFocus);
|
2010-02-24 19:23:40 +01:00
|
|
|
setItemDelegate(new TargetSelectorDelegate(this));
|
2010-02-25 13:07:50 +01:00
|
|
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
2011-09-26 14:48:12 +02:00
|
|
|
setStyleSheet(QString::fromLatin1("QListWidget { background: #464646; border-style: none; }"));
|
|
|
|
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ListWidget::keyPressEvent(QKeyEvent *event)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (event->key() == Qt::Key_Left)
|
|
|
|
|
focusPreviousChild();
|
|
|
|
|
else if (event->key() == Qt::Key_Right)
|
|
|
|
|
focusNextChild();
|
|
|
|
|
else
|
|
|
|
|
QListWidget::keyPressEvent(event);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ListWidget::keyReleaseEvent(QKeyEvent *event)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2012-04-23 12:44:10 +02:00
|
|
|
if (event->key() != Qt::Key_Left && event->key() != Qt::Key_Right)
|
2011-09-26 14:48:12 +02:00
|
|
|
QListWidget::keyReleaseEvent(event);
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ListWidget::setMaxCount(int maxCount)
|
|
|
|
|
{
|
|
|
|
|
m_maxCount = maxCount;
|
|
|
|
|
updateGeometry();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
int ListWidget::maxCount()
|
|
|
|
|
{
|
|
|
|
|
return m_maxCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ListWidget::optimalWidth() const
|
|
|
|
|
{
|
|
|
|
|
return m_optimalWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ListWidget::setOptimalWidth(int width)
|
|
|
|
|
{
|
|
|
|
|
m_optimalWidth = width;
|
|
|
|
|
updateGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ListWidget::padding()
|
|
|
|
|
{
|
|
|
|
|
// there needs to be enough extra pixels to show a scrollbar
|
2014-07-15 17:09:31 +02:00
|
|
|
return 2 * style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, this)
|
|
|
|
|
+ style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, this)
|
|
|
|
|
+ 10;
|
2012-08-24 17:20:19 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
////////
|
|
|
|
|
// ProjectListWidget
|
|
|
|
|
////////
|
2013-09-05 12:35:19 +02:00
|
|
|
ProjectListWidget::ProjectListWidget(QWidget *parent)
|
|
|
|
|
: ListWidget(parent), m_ignoreIndexChange(false)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
2013-09-05 12:35:19 +02:00
|
|
|
QObject *sessionManager = SessionManager::instance();
|
|
|
|
|
connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
2011-09-26 14:48:12 +02:00
|
|
|
this, SLOT(addProject(ProjectExplorer::Project*)));
|
2013-09-05 12:35:19 +02:00
|
|
|
connect(sessionManager, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
|
2011-09-26 14:48:12 +02:00
|
|
|
this, SLOT(removeProject(ProjectExplorer::Project*)));
|
2013-09-05 12:35:19 +02:00
|
|
|
connect(sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
2011-09-26 14:48:12 +02:00
|
|
|
this, SLOT(changeStartupProject(ProjectExplorer::Project*)));
|
2013-09-05 12:35:19 +02:00
|
|
|
connect(sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
|
2012-04-16 19:18:26 +04:00
|
|
|
this, SLOT(projectDisplayNameChanged(ProjectExplorer::Project*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(this, SIGNAL(currentRowChanged(int)),
|
|
|
|
|
this, SLOT(setProject(int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *ProjectListWidget::itemForProject(Project *project)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
QListWidgetItem *currentItem = item(i);
|
|
|
|
|
if (currentItem->data(Qt::UserRole).value<Project*>() == project)
|
|
|
|
|
return currentItem;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
QString ProjectListWidget::fullName(Project *project)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
2014-05-02 12:22:58 +02:00
|
|
|
return tr("%1 (%2)").arg(project->displayName(), project->projectFilePath().toUserOutput());
|
2011-09-26 14:48:12 +02:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ProjectListWidget::addProject(Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_ignoreIndexChange = true;
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2012-04-16 17:06:48 +02:00
|
|
|
int pos = count();
|
2011-09-26 14:48:12 +02:00
|
|
|
for (int i=0; i < count(); ++i) {
|
|
|
|
|
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
2012-04-16 20:49:39 +04:00
|
|
|
if (projectLesserThan(project, p)) {
|
2011-09-26 14:48:12 +02:00
|
|
|
pos = i;
|
2012-04-16 20:49:39 +04:00
|
|
|
break;
|
|
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
bool useFullName = false;
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
|
|
|
|
if (p->displayName() == project->displayName()) {
|
|
|
|
|
useFullName = true;
|
|
|
|
|
item(i)->setText(fullName(p));
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QString displayName = useFullName ? fullName(project) : project->displayName();
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem();
|
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(project));
|
|
|
|
|
item->setText(displayName);
|
|
|
|
|
insertItem(pos, item);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
if (project == SessionManager::startupProject())
|
2011-09-26 14:48:12 +02:00
|
|
|
setCurrentItem(item);
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
QFontMetrics fn(font());
|
2012-11-22 18:44:04 +01:00
|
|
|
int width = fn.width(displayName) + padding();
|
2012-08-24 17:20:19 +02:00
|
|
|
if (width > optimalWidth())
|
|
|
|
|
setOptimalWidth(width);
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectListWidget::removeProject(Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *listItem = itemForProject(project);
|
|
|
|
|
delete listItem;
|
|
|
|
|
|
|
|
|
|
// Update display names
|
|
|
|
|
QString name = project->displayName();
|
|
|
|
|
int countDisplayName = 0;
|
|
|
|
|
int otherIndex = -1;
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
Project *p = item(i)->data(Qt::UserRole).value<Project *>();
|
|
|
|
|
if (p->displayName() == name) {
|
|
|
|
|
++countDisplayName;
|
|
|
|
|
otherIndex = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (countDisplayName == 1) {
|
|
|
|
|
Project *p = item(otherIndex)->data(Qt::UserRole).value<Project *>();
|
|
|
|
|
item(otherIndex)->setText(p->displayName());
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
QFontMetrics fn(font());
|
|
|
|
|
|
|
|
|
|
// recheck optimal width
|
|
|
|
|
int width = 0;
|
2012-11-22 18:44:04 +01:00
|
|
|
for (int i = 0; i < count(); ++i)
|
|
|
|
|
width = qMax(fn.width(item(i)->text()) + padding(), width);
|
2012-08-24 17:20:19 +02:00
|
|
|
setOptimalWidth(width);
|
2011-09-26 14:48:12 +02:00
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-16 19:18:26 +04:00
|
|
|
void ProjectListWidget::projectDisplayNameChanged(Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
|
|
|
|
|
int oldPos = 0;
|
|
|
|
|
bool useFullName = false;
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
|
|
|
|
if (p == project) {
|
|
|
|
|
oldPos = i;
|
|
|
|
|
} else if (p->displayName() == project->displayName()) {
|
|
|
|
|
useFullName = true;
|
|
|
|
|
item(i)->setText(fullName(p));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isCurrentItem = (oldPos == currentRow());
|
|
|
|
|
QListWidgetItem *projectItem = takeItem(oldPos);
|
|
|
|
|
|
|
|
|
|
int pos = count();
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
2012-04-16 20:49:39 +04:00
|
|
|
if (projectLesserThan(project, p)) {
|
2012-04-16 19:18:26 +04:00
|
|
|
pos = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayName = useFullName ? fullName(project) : project->displayName();
|
|
|
|
|
projectItem->setText(displayName);
|
|
|
|
|
insertItem(pos, projectItem);
|
|
|
|
|
if (isCurrentItem)
|
|
|
|
|
setCurrentRow(pos);
|
|
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
// recheck optimal width
|
|
|
|
|
QFontMetrics fn(font());
|
|
|
|
|
int width = 0;
|
2012-11-22 18:44:04 +01:00
|
|
|
for (int i = 0; i < count(); ++i)
|
|
|
|
|
width = qMax(fn.width(item(i)->text()) + padding(), width);
|
2012-08-24 17:20:19 +02:00
|
|
|
setOptimalWidth(width);
|
|
|
|
|
|
2012-04-16 19:18:26 +04:00
|
|
|
m_ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ProjectListWidget::setProject(int index)
|
2010-02-09 19:05:15 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (m_ignoreIndexChange)
|
|
|
|
|
return;
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
|
|
|
|
Project *p = item(index)->data(Qt::UserRole).value<Project *>();
|
2013-09-05 12:35:19 +02:00
|
|
|
SessionManager::setStartupProject(p);
|
2010-02-09 19:05:15 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ProjectListWidget::changeStartupProject(Project *project)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
setCurrentItem(itemForProject(project));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
/////////
|
|
|
|
|
// GenericListWidget
|
|
|
|
|
/////////
|
|
|
|
|
|
|
|
|
|
GenericListWidget::GenericListWidget(QWidget *parent)
|
|
|
|
|
: ListWidget(parent), m_ignoreIndexChange(false)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(this, SIGNAL(currentRowChanged(int)),
|
|
|
|
|
this, SLOT(rowChanged(int)));
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::setProjectConfigurations(const QList<ProjectConfiguration *> &list, ProjectConfiguration *active)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
clear();
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
|
|
|
|
disconnect(p, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(displayNameChanged()));
|
|
|
|
|
}
|
2012-08-24 17:20:19 +02:00
|
|
|
|
|
|
|
|
QFontMetrics fn(font());
|
|
|
|
|
int width = 0;
|
|
|
|
|
foreach (ProjectConfiguration *pc, list) {
|
2011-09-26 14:48:12 +02:00
|
|
|
addProjectConfiguration(pc);
|
2012-08-24 17:20:19 +02:00
|
|
|
width = qMax(width, fn.width(pc->displayName()) + padding());
|
|
|
|
|
}
|
|
|
|
|
setOptimalWidth(width);
|
2011-09-26 14:48:12 +02:00
|
|
|
setActiveProjectConfiguration(active);
|
2012-08-24 17:20:19 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
2010-04-29 16:52:31 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::setActiveProjectConfiguration(ProjectConfiguration *active)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
QListWidgetItem *item = itemForProjectConfiguration(active);
|
|
|
|
|
setCurrentItem(item);
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void GenericListWidget::addProjectConfiguration(ProjectConfiguration *pc)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
QListWidgetItem *lwi = new QListWidgetItem();
|
|
|
|
|
lwi->setText(pc->displayName());
|
|
|
|
|
lwi->setData(Qt::UserRole, QVariant::fromValue(pc));
|
|
|
|
|
|
|
|
|
|
// Figure out pos
|
|
|
|
|
int pos = count();
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
2015-07-24 15:38:32 +02:00
|
|
|
if (caseFriendlyCompare(pc->displayName(), p->displayName()) < 0) {
|
2011-09-26 14:48:12 +02:00
|
|
|
pos = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
insertItem(pos, lwi);
|
|
|
|
|
|
|
|
|
|
connect(pc, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(displayNameChanged()));
|
2012-08-24 17:20:19 +02:00
|
|
|
|
|
|
|
|
QFontMetrics fn(font());
|
|
|
|
|
int width = fn.width(pc->displayName()) + padding();
|
|
|
|
|
if (width > optimalWidth())
|
|
|
|
|
setOptimalWidth(width);
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void GenericListWidget::removeProjectConfiguration(ProjectConfiguration *pc)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
disconnect(pc, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(displayNameChanged()));
|
|
|
|
|
delete itemForProjectConfiguration(pc);
|
2012-08-24 17:20:19 +02:00
|
|
|
|
|
|
|
|
QFontMetrics fn(font());
|
|
|
|
|
int width = 0;
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
|
|
|
|
width = qMax(width, fn.width(p->displayName()) + padding());
|
|
|
|
|
}
|
|
|
|
|
setOptimalWidth(width);
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::rowChanged(int index)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (m_ignoreIndexChange)
|
|
|
|
|
return;
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
|
|
|
|
emit changeActiveProjectConfiguration(item(index)->data(Qt::UserRole).value<ProjectConfiguration *>());
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::displayNameChanged()
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = true;
|
2012-03-29 12:22:48 +02:00
|
|
|
ProjectConfiguration *activeProjectConfiguration = 0;
|
|
|
|
|
if (currentItem())
|
|
|
|
|
activeProjectConfiguration = currentItem()->data(Qt::UserRole).value<ProjectConfiguration *>();
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
ProjectConfiguration *pc = qobject_cast<ProjectConfiguration *>(sender());
|
|
|
|
|
int index = -1;
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (; i < count(); ++i) {
|
|
|
|
|
QListWidgetItem *lwi = item(i);
|
|
|
|
|
if (lwi->data(Qt::UserRole).value<ProjectConfiguration *>() == pc) {
|
|
|
|
|
index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (index == -1)
|
|
|
|
|
return;
|
|
|
|
|
QListWidgetItem *lwi = takeItem(i);
|
|
|
|
|
lwi->setText(pc->displayName());
|
|
|
|
|
int pos = count();
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
2015-07-24 15:38:32 +02:00
|
|
|
if (caseFriendlyCompare(pc->displayName(), p->displayName()) < 0) {
|
2011-09-26 14:48:12 +02:00
|
|
|
pos = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
insertItem(pos, lwi);
|
2012-03-29 12:22:48 +02:00
|
|
|
if (activeProjectConfiguration)
|
|
|
|
|
setCurrentItem(itemForProjectConfiguration(activeProjectConfiguration));
|
2012-08-24 17:20:19 +02:00
|
|
|
|
|
|
|
|
QFontMetrics fn(font());
|
|
|
|
|
int width = 0;
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
|
|
|
|
width = qMax(width, fn.width(p->displayName()) + padding());
|
|
|
|
|
}
|
|
|
|
|
setOptimalWidth(width);
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QListWidgetItem *GenericListWidget::itemForProjectConfiguration(ProjectConfiguration *pc)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
QListWidgetItem *lwi = item(i);
|
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 (lwi->data(Qt::UserRole).value<ProjectConfiguration *>() == pc)
|
2011-09-26 14:48:12 +02:00
|
|
|
return lwi;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-13 10:16:25 +02:00
|
|
|
/////////
|
|
|
|
|
// KitAreaWidget
|
|
|
|
|
/////////
|
|
|
|
|
|
|
|
|
|
KitAreaWidget::KitAreaWidget(QWidget *parent) : QWidget(parent),
|
|
|
|
|
m_layout(new QGridLayout(this)), m_kit(0)
|
|
|
|
|
{
|
|
|
|
|
m_layout->setMargin(3);
|
2015-04-21 16:35:46 +02:00
|
|
|
setAutoFillBackground(true);
|
2015-04-21 16:28:07 +02:00
|
|
|
connect(KitManager::instance(), &KitManager::kitUpdated, this, &KitAreaWidget::updateKit);
|
2015-04-21 18:39:38 +02:00
|
|
|
|
|
|
|
|
QPalette p = palette();
|
|
|
|
|
p.setColor(QPalette::Window, creatorTheme()->color(Theme::MiniProjectTargetSelectorSummaryBackgroundColor).name());
|
|
|
|
|
p.setColor(QPalette::Button, creatorTheme()->color(Theme::MiniProjectTargetSelectorSummaryBackgroundColor).name());
|
|
|
|
|
p.setColor(QPalette::ButtonText, creatorTheme()->color(Theme::MiniProjectTargetSelectorTextColor).name());
|
|
|
|
|
setPalette(p);
|
2014-10-30 13:38:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KitAreaWidget::~KitAreaWidget()
|
|
|
|
|
{
|
2013-09-13 10:16:25 +02:00
|
|
|
setKit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KitAreaWidget::setKit(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
foreach (KitConfigWidget *w, m_widgets)
|
2014-10-30 13:38:12 +01:00
|
|
|
delete(w);
|
2013-09-13 10:16:25 +02:00
|
|
|
m_widgets.clear();
|
2015-04-21 16:28:07 +02:00
|
|
|
|
|
|
|
|
if (!k)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-09-13 10:16:25 +02:00
|
|
|
foreach (QLabel *l, m_labels)
|
|
|
|
|
l->deleteLater();
|
|
|
|
|
m_labels.clear();
|
|
|
|
|
|
|
|
|
|
int row = 0;
|
|
|
|
|
foreach (KitInformation *ki, KitManager::kitInformation()) {
|
|
|
|
|
if (k && k->isMutable(ki->id())) {
|
|
|
|
|
KitConfigWidget *widget = ki->createConfigWidget(k);
|
|
|
|
|
m_widgets << widget;
|
|
|
|
|
QLabel *label = new QLabel(widget->displayName());
|
|
|
|
|
m_labels << label;
|
|
|
|
|
|
|
|
|
|
m_layout->addWidget(label, row, 0);
|
2015-04-21 18:39:38 +02:00
|
|
|
QWidget *mainWidget = widget->mainWidget();
|
|
|
|
|
// force fusion style as native style has rendering issues on windows:
|
|
|
|
|
mainWidget->setStyle(QStyleFactory::create(QLatin1String("fusion")));
|
|
|
|
|
m_layout->addWidget(mainWidget, row, 1);
|
2015-10-12 11:57:55 +02:00
|
|
|
m_layout->addWidget(widget->buttonWidget(), row, 2);
|
2013-09-13 10:16:25 +02:00
|
|
|
++row;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_kit = k;
|
|
|
|
|
|
|
|
|
|
setHidden(m_widgets.isEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KitAreaWidget::updateKit(Kit *k)
|
|
|
|
|
{
|
|
|
|
|
if (!m_kit || m_kit != k)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-10-12 12:00:09 +02:00
|
|
|
bool addedMutables = false;
|
|
|
|
|
QList<Core::Id> knownIdList = Utils::transform(m_widgets, &KitConfigWidget::kitInformationId);
|
2013-09-13 10:16:25 +02:00
|
|
|
|
|
|
|
|
foreach (KitInformation *ki, KitManager::kitInformation()) {
|
|
|
|
|
Core::Id currentId = ki->id();
|
|
|
|
|
if (m_kit->isMutable(currentId) && !knownIdList.removeOne(currentId)) {
|
2015-10-12 12:00:09 +02:00
|
|
|
addedMutables = true;
|
2013-09-13 10:16:25 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-10-12 12:00:09 +02:00
|
|
|
const bool removedMutables = !knownIdList.isEmpty();
|
2013-09-13 10:16:25 +02:00
|
|
|
|
2015-10-12 12:00:09 +02:00
|
|
|
if (addedMutables || removedMutables) {
|
|
|
|
|
// Redo whole setup if the number of mutable settings did change
|
2013-09-13 10:16:25 +02:00
|
|
|
setKit(m_kit);
|
2015-10-12 12:00:09 +02:00
|
|
|
} else {
|
|
|
|
|
// Refresh all widgets if the number of mutable settings did not change
|
|
|
|
|
foreach (KitConfigWidget *w, m_widgets)
|
|
|
|
|
w->refresh();
|
|
|
|
|
}
|
2013-09-13 10:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////
|
|
|
|
|
// MiniProjectTargetSelector
|
|
|
|
|
/////////
|
|
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
QWidget *MiniProjectTargetSelector::createTitleLabel(const QString &text)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2015-02-03 23:59:04 +02:00
|
|
|
StyledBar *bar = new StyledBar(this);
|
2011-09-26 14:48:12 +02:00
|
|
|
bar->setSingleRow(true);
|
|
|
|
|
QVBoxLayout *toolLayout = new QVBoxLayout(bar);
|
2012-08-24 17:20:19 +02:00
|
|
|
toolLayout->setContentsMargins(6, 0, 6, 0);
|
2011-09-26 14:48:12 +02:00
|
|
|
toolLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
QLabel *l = new QLabel(text);
|
|
|
|
|
QFont f = l->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
l->setFont(f);
|
|
|
|
|
toolLayout->addWidget(l);
|
|
|
|
|
|
|
|
|
|
int panelHeight = l->fontMetrics().height() + 12;
|
|
|
|
|
bar->ensurePolished(); // Required since manhattanstyle overrides height
|
|
|
|
|
bar->setFixedHeight(panelHeight);
|
|
|
|
|
return bar;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-05 12:35:19 +02:00
|
|
|
MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorAction, QWidget *parent) :
|
|
|
|
|
QWidget(parent), m_projectAction(targetSelectorAction),
|
2011-09-26 14:48:12 +02:00
|
|
|
m_project(0),
|
|
|
|
|
m_target(0),
|
|
|
|
|
m_buildConfiguration(0),
|
|
|
|
|
m_deployConfiguration(0),
|
|
|
|
|
m_runConfiguration(0),
|
|
|
|
|
m_hideOnRelease(false)
|
|
|
|
|
{
|
2014-01-07 20:38:32 +01:00
|
|
|
QPalette p;
|
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.setColor(QPalette::Text, creatorTheme()->color(Theme::MiniProjectTargetSelectorTextColor));
|
2011-09-26 14:48:12 +02:00
|
|
|
setPalette(p);
|
2010-02-24 19:23:40 +01:00
|
|
|
setProperty("panelwidget", true);
|
|
|
|
|
setContentsMargins(QMargins(0, 1, 1, 8));
|
2010-01-21 21:12:40 +01:00
|
|
|
setWindowFlags(Qt::Popup);
|
|
|
|
|
|
|
|
|
|
targetSelectorAction->setIcon(style()->standardIcon(QStyle::SP_ComputerIcon));
|
|
|
|
|
targetSelectorAction->setProperty("titledAction", true);
|
|
|
|
|
|
2013-09-13 10:16:25 +02:00
|
|
|
m_kitAreaWidget = new KitAreaWidget(this);
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_summaryLabel = new QLabel(this);
|
|
|
|
|
m_summaryLabel->setMargin(3);
|
|
|
|
|
m_summaryLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
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
|
|
|
m_summaryLabel->setStyleSheet(QString::fromLatin1("background: %1;")
|
|
|
|
|
.arg(creatorTheme()->color(Theme::MiniProjectTargetSelectorSummaryBackgroundColor).name()));
|
2011-10-28 10:15:04 +00:00
|
|
|
m_summaryLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
|
|
|
|
m_summaryLabel->setTextInteractionFlags(m_summaryLabel->textInteractionFlags() | Qt::LinksAccessibleByMouse);
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
m_listWidgets.resize(LAST);
|
|
|
|
|
m_titleWidgets.resize(LAST);
|
|
|
|
|
m_listWidgets[PROJECT] = 0; //project is not a generic list widget
|
|
|
|
|
|
|
|
|
|
m_titleWidgets[PROJECT] = createTitleLabel(tr("Project"));
|
2013-09-05 12:35:19 +02:00
|
|
|
m_projectListWidget = new ProjectListWidget(this);
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
QStringList titles;
|
2012-09-03 18:31:44 +02:00
|
|
|
titles << tr("Kit") << tr("Build")
|
2011-09-26 14:48:12 +02:00
|
|
|
<< tr("Deploy") << tr("Run");
|
|
|
|
|
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i) {
|
|
|
|
|
m_titleWidgets[i] = createTitleLabel(titles.at(i -1));
|
|
|
|
|
m_listWidgets[i] = new GenericListWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-05 12:35:19 +02:00
|
|
|
Project *startup = SessionManager::startupProject();
|
|
|
|
|
changeStartupProject(startup);
|
|
|
|
|
if (startup)
|
|
|
|
|
activeTargetChanged(startup->activeTarget());
|
2011-09-26 14:48:12 +02:00
|
|
|
|
2011-10-28 10:15:04 +00:00
|
|
|
connect(m_summaryLabel, SIGNAL(linkActivated(QString)),
|
|
|
|
|
this, SLOT(switchToProjectsMode()));
|
|
|
|
|
|
2013-09-05 12:35:19 +02:00
|
|
|
QObject *sessionManager = SessionManager::instance();
|
|
|
|
|
connect(sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
2011-09-26 14:48:12 +02:00
|
|
|
this, SLOT(changeStartupProject(ProjectExplorer::Project*)));
|
|
|
|
|
|
2013-09-05 12:35:19 +02:00
|
|
|
connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
2011-09-26 14:48:12 +02:00
|
|
|
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
2013-09-05 12:35:19 +02:00
|
|
|
connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
2011-09-26 14:48:12 +02:00
|
|
|
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
2013-09-05 12:35:19 +02:00
|
|
|
connect(sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
|
2012-04-16 19:18:26 +04:00
|
|
|
this, SLOT(updateActionAndSummary()));
|
2011-09-26 14:48:12 +02:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// for icon changes:
|
2012-09-03 18:31:44 +02:00
|
|
|
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
|
|
|
|
|
this, SLOT(kitChanged(ProjectExplorer::Kit*)));
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(m_listWidgets[TARGET], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
|
2012-03-05 22:30:59 +01:00
|
|
|
this, SLOT(setActiveTarget(ProjectExplorer::ProjectConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(m_listWidgets[BUILD], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
|
2012-03-05 22:30:59 +01:00
|
|
|
this, SLOT(setActiveBuildConfiguration(ProjectExplorer::ProjectConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(m_listWidgets[DEPLOY], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
|
2012-03-05 22:30:59 +01:00
|
|
|
this, SLOT(setActiveDeployConfiguration(ProjectExplorer::ProjectConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(m_listWidgets[RUN], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
|
2012-03-05 22:30:59 +01:00
|
|
|
this, SLOT(setActiveRunConfiguration(ProjectExplorer::ProjectConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
bool MiniProjectTargetSelector::event(QEvent *event)
|
|
|
|
|
{
|
2013-05-24 16:24:04 +02:00
|
|
|
if (event->type() == QEvent::LayoutRequest) {
|
|
|
|
|
doLayout(true);
|
|
|
|
|
return true;
|
|
|
|
|
} else if (event->type() == QEvent::ShortcutOverride) {
|
|
|
|
|
if (static_cast<QKeyEvent *>(event)->key() == Qt::Key_Escape) {
|
|
|
|
|
event->accept();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QWidget::event(event);
|
|
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// does some fancy calculations to ensure proper widths for the list widgets
|
|
|
|
|
QVector<int> MiniProjectTargetSelector::listWidgetWidths(int minSize, int maxSize)
|
|
|
|
|
{
|
|
|
|
|
QVector<int> result;
|
|
|
|
|
result.resize(LAST);
|
|
|
|
|
if (m_projectListWidget->isVisibleTo(this))
|
|
|
|
|
result[PROJECT] = m_projectListWidget->optimalWidth();
|
|
|
|
|
else
|
|
|
|
|
result[PROJECT] = -1;
|
|
|
|
|
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i) {
|
|
|
|
|
if (m_listWidgets[i]->isVisibleTo(this))
|
|
|
|
|
result[i] = m_listWidgets[i]->optimalWidth();
|
|
|
|
|
else
|
|
|
|
|
result[i] = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int totalWidth = 0;
|
|
|
|
|
// Adjust to minimum width of title
|
|
|
|
|
for (int i = PROJECT; i < LAST; ++i) {
|
|
|
|
|
if (result[i] != -1) {
|
|
|
|
|
// We want at least 100 pixels per column
|
|
|
|
|
int width = qMax(m_titleWidgets[i]->sizeHint().width(), 100);
|
|
|
|
|
if (result[i] < width)
|
|
|
|
|
result[i] = width;
|
|
|
|
|
totalWidth += result[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (totalWidth == 0) // All hidden
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
bool tooSmall;
|
|
|
|
|
if (totalWidth < minSize)
|
|
|
|
|
tooSmall = true;
|
|
|
|
|
else if (totalWidth > maxSize)
|
|
|
|
|
tooSmall = false;
|
|
|
|
|
else
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
int widthToDistribute = tooSmall ? (minSize - totalWidth)
|
|
|
|
|
: (totalWidth - maxSize);
|
|
|
|
|
QVector<int> indexes;
|
|
|
|
|
indexes.reserve(LAST);
|
|
|
|
|
for (int i = PROJECT; i < LAST; ++i)
|
|
|
|
|
if (result[i] != -1)
|
|
|
|
|
indexes.append(i);
|
|
|
|
|
|
2014-07-09 12:56:30 +02:00
|
|
|
if (tooSmall) {
|
|
|
|
|
Utils::sort(indexes, [&result](int i, int j) {
|
|
|
|
|
return result[i] < result[j];
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
Utils::sort(indexes, [&result](int i, int j) {
|
|
|
|
|
return result[i] > result[j];
|
|
|
|
|
});
|
|
|
|
|
}
|
2012-08-24 17:20:19 +02:00
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
int first = result[indexes.first()]; // biggest or smallest
|
|
|
|
|
|
|
|
|
|
// we resize the biggest columns until they are the same size as the second biggest
|
|
|
|
|
// since it looks prettiest if all the columns are the same width
|
|
|
|
|
while (true) {
|
|
|
|
|
for (; i < indexes.size(); ++i) {
|
|
|
|
|
if (result[indexes[i]] != first)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
int next = tooSmall ? INT_MAX : 0;
|
|
|
|
|
if (i < indexes.size())
|
|
|
|
|
next = result[indexes[i]];
|
|
|
|
|
|
|
|
|
|
int delta;
|
|
|
|
|
if (tooSmall)
|
|
|
|
|
delta = qMin(next - first, widthToDistribute / i);
|
|
|
|
|
else
|
|
|
|
|
delta = qMin(first - next, widthToDistribute / i);
|
|
|
|
|
|
|
|
|
|
if (delta == 0)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
if (tooSmall) {
|
|
|
|
|
for (int j = 0; j < i; ++j)
|
|
|
|
|
result[indexes[j]] += delta;
|
|
|
|
|
} else {
|
|
|
|
|
for (int j = 0; j < i; ++j)
|
|
|
|
|
result[indexes[j]] -= delta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
widthToDistribute -= delta * i;
|
|
|
|
|
if (widthToDistribute == 0)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
first = result[indexes.first()];
|
|
|
|
|
i = 0; // TODO can we do better?
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MiniProjectTargetSelector::doLayout(bool keepSize)
|
|
|
|
|
{
|
|
|
|
|
// An unconfigured project shows empty build/deploy/run sections
|
|
|
|
|
// if there's a configured project in the seesion
|
|
|
|
|
// that could be improved
|
|
|
|
|
static QStatusBar *statusBar = Core::ICore::statusBar();
|
|
|
|
|
static QWidget *actionBar = Core::ICore::mainWindow()->findChild<QWidget*>(QLatin1String("actionbar"));
|
|
|
|
|
Q_ASSERT(actionBar);
|
|
|
|
|
|
2013-09-13 10:16:25 +02:00
|
|
|
m_kitAreaWidget->move(0, 0);
|
|
|
|
|
|
|
|
|
|
int oldSummaryLabelY = m_summaryLabel->y();
|
|
|
|
|
|
2014-05-19 09:16:34 +02:00
|
|
|
int kitAreaHeight = m_kitAreaWidget->isVisibleTo(this) ? m_kitAreaWidget->sizeHint().height() : 0;
|
2013-09-13 10:16:25 +02:00
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
// 1. Calculate the summary label height
|
2013-09-13 10:16:25 +02:00
|
|
|
int summaryLabelY = 1 + kitAreaHeight;
|
|
|
|
|
|
2012-08-24 17:20:19 +02:00
|
|
|
int summaryLabelHeight = 0;
|
|
|
|
|
int oldSummaryLabelHeight = m_summaryLabel->height();
|
|
|
|
|
bool onlySummary = false;
|
|
|
|
|
// Count the number of lines
|
|
|
|
|
int visibleLineCount = m_projectListWidget->isVisibleTo(this) ? 0 : 1;
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i)
|
|
|
|
|
visibleLineCount += m_listWidgets[i]->isVisibleTo(this) ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
if (visibleLineCount == LAST) {
|
|
|
|
|
summaryLabelHeight = visibleLineCount * QFontMetrics(m_summaryLabel->font()).height()
|
|
|
|
|
+ m_summaryLabel->margin() *2;
|
|
|
|
|
onlySummary = true;
|
|
|
|
|
} else {
|
|
|
|
|
if (visibleLineCount < 3) {
|
2014-07-07 19:02:26 +02:00
|
|
|
if (Utils::anyOf(SessionManager::projects(), &Project::needsConfiguration))
|
|
|
|
|
visibleLineCount = 3;
|
2012-08-24 17:20:19 +02:00
|
|
|
}
|
|
|
|
|
if (visibleLineCount)
|
|
|
|
|
summaryLabelHeight = visibleLineCount * QFontMetrics(m_summaryLabel->font()).height()
|
|
|
|
|
+ m_summaryLabel->margin() *2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keepSize && oldSummaryLabelHeight > summaryLabelHeight)
|
|
|
|
|
summaryLabelHeight = oldSummaryLabelHeight;
|
|
|
|
|
|
|
|
|
|
m_summaryLabel->move(0, summaryLabelY);
|
|
|
|
|
|
|
|
|
|
// Height to be aligned with side bar button
|
2013-05-31 17:50:07 +02:00
|
|
|
int alignedWithActionHeight = 210;
|
|
|
|
|
if (actionBar->isVisible())
|
|
|
|
|
alignedWithActionHeight = actionBar->height() - statusBar->height();
|
2012-08-24 17:20:19 +02:00
|
|
|
int bottomMargin = 9;
|
2013-09-13 10:16:25 +02:00
|
|
|
int heightWithoutKitArea = 0;
|
2012-08-24 17:20:19 +02:00
|
|
|
|
|
|
|
|
if (!onlySummary) {
|
2014-03-04 00:12:11 +01:00
|
|
|
// list widget height
|
2012-08-24 17:20:19 +02:00
|
|
|
int maxItemCount = m_projectListWidget->maxCount();
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i)
|
|
|
|
|
maxItemCount = qMax(maxItemCount, m_listWidgets[i]->maxCount());
|
|
|
|
|
|
|
|
|
|
int titleWidgetsHeight = m_titleWidgets.first()->height();
|
|
|
|
|
if (keepSize) {
|
2013-09-13 10:16:25 +02:00
|
|
|
heightWithoutKitArea = height() - oldSummaryLabelY + 1;
|
2012-08-24 17:20:19 +02:00
|
|
|
} else {
|
|
|
|
|
// Clamp the size of the listwidgets to be
|
2014-03-04 00:12:11 +01:00
|
|
|
// at least as high as the sidebar button
|
2012-08-24 17:20:19 +02:00
|
|
|
// and at most twice as high
|
2013-09-13 10:16:25 +02:00
|
|
|
heightWithoutKitArea = summaryLabelHeight
|
|
|
|
|
+ qBound(alignedWithActionHeight,
|
|
|
|
|
maxItemCount * 30 + bottomMargin + titleWidgetsHeight,
|
|
|
|
|
alignedWithActionHeight * 2);
|
2012-08-24 17:20:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int titleY = summaryLabelY + summaryLabelHeight;
|
|
|
|
|
int listY = titleY + titleWidgetsHeight;
|
2013-09-13 10:16:25 +02:00
|
|
|
int listHeight = heightWithoutKitArea + kitAreaHeight - bottomMargin - listY + 1;
|
2012-08-24 17:20:19 +02:00
|
|
|
|
|
|
|
|
// list widget widths
|
|
|
|
|
int minWidth = qMax(m_summaryLabel->sizeHint().width(), 250);
|
2013-09-13 10:16:25 +02:00
|
|
|
minWidth = qMax(minWidth, m_kitAreaWidget->sizeHint().width());
|
2012-08-24 17:20:19 +02:00
|
|
|
if (keepSize) {
|
|
|
|
|
// Do not make the widget smaller then it was before
|
|
|
|
|
int oldTotalListWidgetWidth = m_projectListWidget->isVisibleTo(this) ?
|
|
|
|
|
m_projectListWidget->width() : 0;
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i)
|
|
|
|
|
oldTotalListWidgetWidth += m_listWidgets[i]->width();
|
|
|
|
|
minWidth = qMax(minWidth, oldTotalListWidgetWidth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVector<int> widths = listWidgetWidths(minWidth, 1000);
|
|
|
|
|
int x = 0;
|
|
|
|
|
for (int i = PROJECT; i < LAST; ++i) {
|
|
|
|
|
int optimalWidth = widths[i];
|
|
|
|
|
if (i == PROJECT) {
|
|
|
|
|
m_projectListWidget->resize(optimalWidth, listHeight);
|
|
|
|
|
m_projectListWidget->move(x, listY);
|
|
|
|
|
} else {
|
|
|
|
|
m_listWidgets[i]->resize(optimalWidth, listHeight);
|
|
|
|
|
m_listWidgets[i]->move(x, listY);
|
|
|
|
|
}
|
|
|
|
|
m_titleWidgets[i]->resize(optimalWidth, titleWidgetsHeight);
|
|
|
|
|
m_titleWidgets[i]->move(x, titleY);
|
|
|
|
|
x += optimalWidth + 1; //1 extra pixel for the separators or the right border
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_summaryLabel->resize(x - 1, summaryLabelHeight);
|
2013-09-13 10:16:25 +02:00
|
|
|
m_kitAreaWidget->resize(x - 1, kitAreaHeight);
|
|
|
|
|
setFixedSize(x, heightWithoutKitArea + kitAreaHeight);
|
2012-08-24 17:20:19 +02:00
|
|
|
} else {
|
|
|
|
|
if (keepSize)
|
2013-09-13 10:16:25 +02:00
|
|
|
heightWithoutKitArea = height() - oldSummaryLabelY + 1;
|
2012-08-24 17:20:19 +02:00
|
|
|
else
|
2013-09-13 10:16:25 +02:00
|
|
|
heightWithoutKitArea = qMax(summaryLabelHeight + bottomMargin, alignedWithActionHeight);
|
|
|
|
|
m_summaryLabel->resize(m_summaryLabel->sizeHint().width(), heightWithoutKitArea - bottomMargin);
|
|
|
|
|
m_kitAreaWidget->resize(m_kitAreaWidget->sizeHint());
|
|
|
|
|
setFixedSize(m_summaryLabel->width() + 1, heightWithoutKitArea + kitAreaHeight); //1 extra pixel for the border
|
2012-08-24 17:20:19 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-19 09:16:34 +02:00
|
|
|
QPoint moveTo = statusBar->mapToGlobal(QPoint(0,0));
|
|
|
|
|
moveTo -= QPoint(0, height());
|
|
|
|
|
move(moveTo);
|
2012-08-24 17:20:19 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::setActiveTarget(ProjectConfiguration *pc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
2015-07-28 18:29:52 +02:00
|
|
|
SessionManager::setActiveTarget(m_project, static_cast<Target *>(pc),
|
|
|
|
|
SetActive::Cascade);
|
2011-09-26 14:48:12 +02:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::setActiveBuildConfiguration(ProjectConfiguration *pc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
2015-07-28 18:29:52 +02:00
|
|
|
SessionManager::setActiveBuildConfiguration(m_target, static_cast<BuildConfiguration *>(pc), SetActive::Cascade);
|
2011-09-26 14:48:12 +02:00
|
|
|
}
|
2010-02-24 19:23:40 +01:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::setActiveDeployConfiguration(ProjectConfiguration *pc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
2015-07-28 18:29:52 +02:00
|
|
|
SessionManager::setActiveDeployConfiguration(m_target, static_cast<DeployConfiguration *>(pc), SetActive::Cascade);
|
2011-09-26 14:48:12 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::setActiveRunConfiguration(ProjectConfiguration *pc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
m_target->setActiveRunConfiguration(static_cast<RunConfiguration *>(pc));
|
|
|
|
|
}
|
2010-02-24 19:23:40 +01:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::projectAdded(Project *project)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
connect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotAddedTarget(ProjectExplorer::Target*)));
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotRemovedTarget(ProjectExplorer::Target*)));
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
foreach (Target *t, project->targets())
|
|
|
|
|
addedTarget(t);
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
updateProjectListVisible();
|
|
|
|
|
updateTargetListVisible();
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
updateRunListVisible();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::projectRemoved(Project *project)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotAddedTarget(ProjectExplorer::Target*)));
|
2011-04-12 16:35:50 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotRemovedTarget(ProjectExplorer::Target*)));
|
2011-04-12 16:35:50 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
foreach (Target *t, project->targets())
|
|
|
|
|
removedTarget(t);
|
2010-02-18 17:36:58 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
updateProjectListVisible();
|
|
|
|
|
updateTargetListVisible();
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
updateRunListVisible();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::addedTarget(Target *target)
|
2010-03-02 18:38:58 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(target, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotAddedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotRemovedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
connect(target, SIGNAL(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotAddedDeployConfiguration(ProjectExplorer::DeployConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(target, SIGNAL(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotRemovedDeployConfiguration(ProjectExplorer::DeployConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotAddedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotRemovedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
if (target->project() == m_project)
|
|
|
|
|
m_listWidgets[TARGET]->addProjectConfiguration(target);
|
|
|
|
|
|
|
|
|
|
foreach (BuildConfiguration *bc, target->buildConfigurations())
|
|
|
|
|
addedBuildConfiguration(bc);
|
|
|
|
|
foreach (DeployConfiguration *dc, target->deployConfigurations())
|
|
|
|
|
addedDeployConfiguration(dc);
|
|
|
|
|
foreach (RunConfiguration *rc, target->runConfigurations())
|
|
|
|
|
addedRunConfiguration(rc);
|
2012-08-24 16:09:41 +02:00
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::slotAddedTarget(Target *target)
|
2012-08-24 16:09:41 +02:00
|
|
|
{
|
|
|
|
|
addedTarget(target);
|
2011-09-26 14:48:12 +02:00
|
|
|
updateTargetListVisible();
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
updateRunListVisible();
|
2010-03-02 18:38:58 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::removedTarget(Target *target)
|
2011-03-30 16:33:31 +02:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(target, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotAddedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotRemovedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
disconnect(target, SIGNAL(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotAddedDeployConfiguration(ProjectExplorer::DeployConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(target, SIGNAL(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotRemovedDeployConfiguration(ProjectExplorer::DeployConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
disconnect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotAddedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
2012-08-24 16:09:41 +02:00
|
|
|
this, SLOT(slotRemovedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
if (target->project() == m_project)
|
|
|
|
|
m_listWidgets[TARGET]->removeProjectConfiguration(target);
|
|
|
|
|
|
|
|
|
|
foreach (BuildConfiguration *bc, target->buildConfigurations())
|
|
|
|
|
removedBuildConfiguration(bc);
|
|
|
|
|
foreach (DeployConfiguration *dc, target->deployConfigurations())
|
|
|
|
|
removedDeployConfiguration(dc);
|
|
|
|
|
foreach (RunConfiguration *rc, target->runConfigurations())
|
|
|
|
|
removedRunConfiguration(rc);
|
2012-08-24 16:09:41 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::slotRemovedTarget(Target *target)
|
2012-08-24 16:09:41 +02:00
|
|
|
{
|
|
|
|
|
removedTarget(target);
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
updateTargetListVisible();
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
updateRunListVisible();
|
2011-03-30 16:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-24 16:09:41 +02:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::addedBuildConfiguration(BuildConfiguration *bc)
|
2012-08-24 16:09:41 +02:00
|
|
|
{
|
|
|
|
|
if (bc->target() == m_target)
|
|
|
|
|
m_listWidgets[BUILD]->addProjectConfiguration(bc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::slotAddedBuildConfiguration(BuildConfiguration *bc)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (bc->target() == m_target)
|
|
|
|
|
m_listWidgets[BUILD]->addProjectConfiguration(bc);
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::removedBuildConfiguration(BuildConfiguration *bc)
|
2012-08-24 16:09:41 +02:00
|
|
|
{
|
|
|
|
|
if (bc->target() == m_target)
|
|
|
|
|
m_listWidgets[BUILD]->removeProjectConfiguration(bc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::slotRemovedBuildConfiguration(BuildConfiguration *bc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (bc->target() == m_target)
|
|
|
|
|
m_listWidgets[BUILD]->removeProjectConfiguration(bc);
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
}
|
2010-08-30 17:12:40 +02:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::addedDeployConfiguration(DeployConfiguration *dc)
|
2012-08-24 16:09:41 +02:00
|
|
|
{
|
|
|
|
|
if (dc->target() == m_target)
|
|
|
|
|
m_listWidgets[DEPLOY]->addProjectConfiguration(dc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::slotAddedDeployConfiguration(DeployConfiguration *dc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (dc->target() == m_target)
|
|
|
|
|
m_listWidgets[DEPLOY]->addProjectConfiguration(dc);
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
}
|
2010-08-30 17:12:40 +02:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::removedDeployConfiguration(DeployConfiguration *dc)
|
2012-08-24 16:09:41 +02:00
|
|
|
{
|
|
|
|
|
if (dc->target() == m_target)
|
|
|
|
|
m_listWidgets[DEPLOY]->removeProjectConfiguration(dc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::slotRemovedDeployConfiguration(DeployConfiguration *dc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (dc->target() == m_target)
|
|
|
|
|
m_listWidgets[DEPLOY]->removeProjectConfiguration(dc);
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
}
|
2010-08-30 17:12:40 +02:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::addedRunConfiguration(RunConfiguration *rc)
|
2012-08-24 16:09:41 +02:00
|
|
|
{
|
|
|
|
|
if (rc->target() == m_target)
|
|
|
|
|
m_listWidgets[RUN]->addProjectConfiguration(rc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::slotAddedRunConfiguration(RunConfiguration *rc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (rc->target() == m_target)
|
|
|
|
|
m_listWidgets[RUN]->addProjectConfiguration(rc);
|
|
|
|
|
updateRunListVisible();
|
|
|
|
|
}
|
2011-03-30 16:33:31 +02:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::removedRunConfiguration(RunConfiguration *rc)
|
2012-08-24 16:09:41 +02:00
|
|
|
{
|
|
|
|
|
if (rc->target() == m_target)
|
|
|
|
|
m_listWidgets[RUN]->removeProjectConfiguration(rc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::slotRemovedRunConfiguration(RunConfiguration *rc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (rc->target() == m_target)
|
|
|
|
|
m_listWidgets[RUN]->removeProjectConfiguration(rc);
|
|
|
|
|
updateRunListVisible();
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateProjectListVisible()
|
|
|
|
|
{
|
2013-09-05 12:35:19 +02:00
|
|
|
int count = SessionManager::projects().size();
|
|
|
|
|
bool visible = count > 1;
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_projectListWidget->setVisible(visible);
|
2013-09-05 12:35:19 +02:00
|
|
|
m_projectListWidget->setMaxCount(count);
|
2011-09-26 14:48:12 +02:00
|
|
|
m_titleWidgets[PROJECT]->setVisible(visible);
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
updateSummary();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateTargetListVisible()
|
|
|
|
|
{
|
|
|
|
|
int maxCount = 0;
|
2013-09-05 12:35:19 +02:00
|
|
|
foreach (Project *p, SessionManager::projects())
|
2011-09-26 14:48:12 +02:00
|
|
|
maxCount = qMax(p->targets().size(), maxCount);
|
|
|
|
|
|
|
|
|
|
bool visible = maxCount > 1;
|
|
|
|
|
m_listWidgets[TARGET]->setVisible(visible);
|
|
|
|
|
m_listWidgets[TARGET]->setMaxCount(maxCount);
|
|
|
|
|
m_titleWidgets[TARGET]->setVisible(visible);
|
|
|
|
|
updateSummary();
|
|
|
|
|
}
|
2010-08-30 17:12:40 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateBuildListVisible()
|
|
|
|
|
{
|
|
|
|
|
int maxCount = 0;
|
2013-09-05 12:35:19 +02:00
|
|
|
foreach (Project *p, SessionManager::projects())
|
2011-09-26 14:48:12 +02:00
|
|
|
foreach (Target *t, p->targets())
|
|
|
|
|
maxCount = qMax(t->buildConfigurations().size(), maxCount);
|
|
|
|
|
|
|
|
|
|
bool visible = maxCount > 1;
|
|
|
|
|
m_listWidgets[BUILD]->setVisible(visible);
|
|
|
|
|
m_listWidgets[BUILD]->setMaxCount(maxCount);
|
|
|
|
|
m_titleWidgets[BUILD]->setVisible(visible);
|
|
|
|
|
updateSummary();
|
|
|
|
|
}
|
2010-03-08 14:39:38 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateDeployListVisible()
|
|
|
|
|
{
|
|
|
|
|
int maxCount = 0;
|
2013-09-05 12:35:19 +02:00
|
|
|
foreach (Project *p, SessionManager::projects())
|
2011-09-26 14:48:12 +02:00
|
|
|
foreach (Target *t, p->targets())
|
|
|
|
|
maxCount = qMax(t->deployConfigurations().size(), maxCount);
|
|
|
|
|
|
|
|
|
|
bool visible = maxCount > 1;
|
|
|
|
|
m_listWidgets[DEPLOY]->setVisible(visible);
|
|
|
|
|
m_listWidgets[DEPLOY]->setMaxCount(maxCount);
|
|
|
|
|
m_titleWidgets[DEPLOY]->setVisible(visible);
|
|
|
|
|
updateSummary();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateRunListVisible()
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
int maxCount = 0;
|
2013-09-05 12:35:19 +02:00
|
|
|
foreach (Project *p, SessionManager::projects())
|
2011-09-26 14:48:12 +02:00
|
|
|
foreach (Target *t, p->targets())
|
|
|
|
|
maxCount = qMax(t->runConfigurations().size(), maxCount);
|
|
|
|
|
|
|
|
|
|
bool visible = maxCount > 1;
|
|
|
|
|
m_listWidgets[RUN]->setVisible(visible);
|
|
|
|
|
m_listWidgets[RUN]->setMaxCount(maxCount);
|
|
|
|
|
m_titleWidgets[RUN]->setVisible(visible);
|
|
|
|
|
updateSummary();
|
|
|
|
|
}
|
2010-08-30 14:32:23 +02:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::changeStartupProject(Project *project)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (m_project) {
|
|
|
|
|
disconnect(m_project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(activeTargetChanged(ProjectExplorer::Target*)));
|
|
|
|
|
}
|
|
|
|
|
m_project = project;
|
|
|
|
|
if (m_project) {
|
|
|
|
|
connect(m_project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(activeTargetChanged(ProjectExplorer::Target*)));
|
|
|
|
|
activeTargetChanged(m_project->activeTarget());
|
|
|
|
|
} else {
|
|
|
|
|
activeTargetChanged(0);
|
|
|
|
|
}
|
2011-03-30 16:33:31 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
if (project) {
|
|
|
|
|
QList<ProjectConfiguration *> list;
|
|
|
|
|
foreach (Target *t, project->targets())
|
|
|
|
|
list.append(t);
|
|
|
|
|
m_listWidgets[TARGET]->setProjectConfigurations(list, project->activeTarget());
|
|
|
|
|
} else {
|
|
|
|
|
m_listWidgets[TARGET]->setProjectConfigurations(QList<ProjectConfiguration *>(), 0);
|
2011-03-30 16:33:31 +02:00
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
updateActionAndSummary();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::activeTargetChanged(Target *target)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (m_target) {
|
|
|
|
|
disconnect(m_target, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
disconnect(m_target, SIGNAL(toolTipChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
2012-04-24 15:49:09 +02:00
|
|
|
disconnect(m_target, SIGNAL(iconChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(m_target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)));
|
|
|
|
|
disconnect(m_target, SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)));
|
|
|
|
|
disconnect(m_target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)));
|
2011-03-30 16:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_target = target;
|
|
|
|
|
|
2013-09-13 10:16:25 +02:00
|
|
|
m_kitAreaWidget->setKit(m_target ? m_target->kit() : 0);
|
|
|
|
|
|
2012-02-09 16:16:54 +01:00
|
|
|
m_listWidgets[TARGET]->setActiveProjectConfiguration(m_target);
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
if (m_buildConfiguration)
|
|
|
|
|
disconnect(m_buildConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
if (m_deployConfiguration)
|
|
|
|
|
disconnect(m_deployConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
|
|
|
|
|
if (m_runConfiguration)
|
|
|
|
|
disconnect(m_runConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
|
|
|
|
|
if (m_target) {
|
|
|
|
|
QList<ProjectConfiguration *> bl;
|
|
|
|
|
foreach (BuildConfiguration *bc, target->buildConfigurations())
|
|
|
|
|
bl.append(bc);
|
|
|
|
|
m_listWidgets[BUILD]->setProjectConfigurations(bl, target->activeBuildConfiguration());
|
|
|
|
|
|
|
|
|
|
QList<ProjectConfiguration *> dl;
|
|
|
|
|
foreach (DeployConfiguration *dc, target->deployConfigurations())
|
|
|
|
|
dl.append(dc);
|
|
|
|
|
m_listWidgets[DEPLOY]->setProjectConfigurations(dl, target->activeDeployConfiguration());
|
|
|
|
|
|
|
|
|
|
QList<ProjectConfiguration *> rl;
|
|
|
|
|
foreach (RunConfiguration *rc, target->runConfigurations())
|
|
|
|
|
rl.append(rc);
|
|
|
|
|
m_listWidgets[RUN]->setProjectConfigurations(rl, target->activeRunConfiguration());
|
|
|
|
|
|
|
|
|
|
m_buildConfiguration = m_target->activeBuildConfiguration();
|
|
|
|
|
if (m_buildConfiguration)
|
|
|
|
|
connect(m_buildConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_deployConfiguration = m_target->activeDeployConfiguration();
|
|
|
|
|
if (m_deployConfiguration)
|
|
|
|
|
connect(m_deployConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_runConfiguration = m_target->activeRunConfiguration();
|
|
|
|
|
if (m_runConfiguration)
|
|
|
|
|
connect(m_runConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
|
|
|
|
|
connect(m_target, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
connect(m_target, SIGNAL(toolTipChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
2012-04-24 15:49:09 +02:00
|
|
|
connect(m_target, SIGNAL(iconChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(m_target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)));
|
|
|
|
|
connect(m_target, SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)));
|
|
|
|
|
connect(m_target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)));
|
|
|
|
|
} else {
|
|
|
|
|
m_listWidgets[BUILD]->setProjectConfigurations(QList<ProjectConfiguration *>(), 0);
|
|
|
|
|
m_listWidgets[DEPLOY]->setProjectConfigurations(QList<ProjectConfiguration *>(), 0);
|
|
|
|
|
m_listWidgets[RUN]->setProjectConfigurations(QList<ProjectConfiguration *>(), 0);
|
|
|
|
|
m_buildConfiguration = 0;
|
|
|
|
|
m_deployConfiguration = 0;
|
|
|
|
|
m_runConfiguration = 0;
|
|
|
|
|
}
|
|
|
|
|
updateActionAndSummary();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void MiniProjectTargetSelector::kitChanged(Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (m_target && m_target->kit() == k)
|
2012-04-24 15:49:09 +02:00
|
|
|
updateActionAndSummary();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::activeBuildConfigurationChanged(BuildConfiguration *bc)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (m_buildConfiguration)
|
|
|
|
|
disconnect(m_buildConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_buildConfiguration = bc;
|
|
|
|
|
if (m_buildConfiguration)
|
|
|
|
|
connect(m_buildConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_listWidgets[BUILD]->setActiveProjectConfiguration(bc);
|
|
|
|
|
updateActionAndSummary();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::activeDeployConfigurationChanged(DeployConfiguration *dc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (m_deployConfiguration)
|
|
|
|
|
disconnect(m_deployConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_deployConfiguration = dc;
|
|
|
|
|
if (m_deployConfiguration)
|
|
|
|
|
connect(m_deployConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_listWidgets[DEPLOY]->setActiveProjectConfiguration(dc);
|
2012-02-09 16:16:54 +01:00
|
|
|
updateActionAndSummary();
|
2011-09-26 14:48:12 +02:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void MiniProjectTargetSelector::activeRunConfigurationChanged(RunConfiguration *rc)
|
2011-09-26 14:48:12 +02:00
|
|
|
{
|
|
|
|
|
if (m_runConfiguration)
|
|
|
|
|
disconnect(m_runConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_runConfiguration = rc;
|
|
|
|
|
if (m_runConfiguration)
|
|
|
|
|
connect(m_runConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_listWidgets[RUN]->setActiveProjectConfiguration(rc);
|
|
|
|
|
updateActionAndSummary();
|
|
|
|
|
}
|
2010-02-22 14:39:59 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::setVisible(bool visible)
|
|
|
|
|
{
|
2014-05-19 09:16:34 +02:00
|
|
|
doLayout(false);
|
2012-08-24 17:20:19 +02:00
|
|
|
QWidget::setVisible(visible);
|
|
|
|
|
m_projectAction->setChecked(visible);
|
2011-09-26 14:48:12 +02:00
|
|
|
if (visible) {
|
|
|
|
|
if (!focusWidget() || !focusWidget()->isVisibleTo(this)) { // Does the second part actually work?
|
|
|
|
|
if (m_projectListWidget->isVisibleTo(this))
|
|
|
|
|
m_projectListWidget->setFocus();
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i) {
|
|
|
|
|
if (m_listWidgets[i]->isVisibleTo(this)) {
|
|
|
|
|
m_listWidgets[i]->setFocus();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-22 14:39:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::toggleVisible()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
setVisible(!isVisible());
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::nextOrShow()
|
|
|
|
|
{
|
|
|
|
|
if (!isVisible()) {
|
|
|
|
|
show();
|
|
|
|
|
} else {
|
|
|
|
|
m_hideOnRelease = true;
|
|
|
|
|
m_earliestHidetime = QDateTime::currentDateTime().addMSecs(800);
|
|
|
|
|
if (ListWidget *lw = qobject_cast<ListWidget *>(focusWidget())) {
|
|
|
|
|
if (lw->currentRow() < lw->count() -1)
|
|
|
|
|
lw->setCurrentRow(lw->currentRow() + 1);
|
|
|
|
|
else
|
|
|
|
|
lw->setCurrentRow(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2012-04-23 13:08:34 +02:00
|
|
|
void MiniProjectTargetSelector::keyPressEvent(QKeyEvent *ke)
|
|
|
|
|
{
|
|
|
|
|
if (ke->key() == Qt::Key_Return
|
|
|
|
|
|| ke->key() == Qt::Key_Enter
|
2013-05-24 16:24:04 +02:00
|
|
|
|| ke->key() == Qt::Key_Space
|
2013-05-28 13:14:03 +02:00
|
|
|
|| ke->key() == Qt::Key_Escape) {
|
2012-04-23 13:08:34 +02:00
|
|
|
hide();
|
2013-05-28 13:14:03 +02:00
|
|
|
} else {
|
|
|
|
|
QWidget::keyPressEvent(ke);
|
|
|
|
|
}
|
2012-04-23 13:08:34 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::keyReleaseEvent(QKeyEvent *ke)
|
|
|
|
|
{
|
|
|
|
|
if (m_hideOnRelease) {
|
|
|
|
|
if (ke->modifiers() == 0
|
|
|
|
|
/*HACK this is to overcome some event inconsistencies between platforms*/
|
|
|
|
|
|| (ke->modifiers() == Qt::AltModifier
|
|
|
|
|
&& (ke->key() == Qt::Key_Alt || ke->key() == -1))) {
|
|
|
|
|
delayedHide();
|
|
|
|
|
m_hideOnRelease = false;
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2012-04-23 13:08:34 +02:00
|
|
|
if (ke->key() == Qt::Key_Return
|
|
|
|
|
|| ke->key() == Qt::Key_Enter
|
2013-05-24 16:24:04 +02:00
|
|
|
|| ke->key() == Qt::Key_Space
|
|
|
|
|
|| ke->key() == Qt::Key_Escape)
|
2012-04-23 13:08:34 +02:00
|
|
|
return;
|
2011-09-26 14:48:12 +02:00
|
|
|
QWidget::keyReleaseEvent(ke);
|
|
|
|
|
}
|
2011-04-12 16:35:50 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::delayedHide()
|
2010-04-12 18:18:45 +02:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
QDateTime current = QDateTime::currentDateTime();
|
|
|
|
|
if (m_earliestHidetime > current) {
|
|
|
|
|
// schedule for later
|
|
|
|
|
QTimer::singleShot(current.msecsTo(m_earliestHidetime) + 50, this, SLOT(delayedHide()));
|
|
|
|
|
} else {
|
|
|
|
|
hide();
|
2010-04-12 18:18:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
// This is a workaround for the problem that Windows
|
|
|
|
|
// will let the mouse events through when you click
|
|
|
|
|
// outside a popup to close it. This causes the popup
|
|
|
|
|
// to open on mouse release if you hit the button, which
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// A similar case can be found in QComboBox
|
|
|
|
|
void MiniProjectTargetSelector::mousePressEvent(QMouseEvent *e)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
setAttribute(Qt::WA_NoMouseReplay);
|
|
|
|
|
QWidget::mousePressEvent(e);
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateActionAndSummary()
|
|
|
|
|
{
|
2015-05-21 17:06:19 +02:00
|
|
|
QString projectName = QLatin1String(" ");
|
2013-01-10 15:12:39 +01:00
|
|
|
QString fileName; // contains the path if projectName is not unique
|
2010-02-04 11:54:49 +01:00
|
|
|
QString targetName;
|
2010-02-09 19:05:15 +01:00
|
|
|
QString targetToolTipText;
|
2010-02-04 11:54:49 +01:00
|
|
|
QString buildConfig;
|
2011-09-26 14:48:12 +02:00
|
|
|
QString deployConfig;
|
2010-02-04 11:54:49 +01:00
|
|
|
QString runConfig;
|
2010-03-19 18:40:00 +01:00
|
|
|
QIcon targetIcon = style()->standardIcon(QStyle::SP_ComputerIcon);
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
Project *project = SessionManager::startupProject();
|
2010-01-21 21:12:40 +01:00
|
|
|
if (project) {
|
|
|
|
|
projectName = project->displayName();
|
2013-09-05 11:46:07 +02:00
|
|
|
foreach (Project *p, SessionManager::projects()) {
|
2013-01-10 15:12:39 +01:00
|
|
|
if (p != project && p->displayName() == projectName) {
|
2014-05-02 12:22:58 +02:00
|
|
|
fileName = project->projectFilePath().toUserOutput();
|
2013-01-10 15:12:39 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-02-04 11:54:49 +01:00
|
|
|
if (Target *target = project->activeTarget()) {
|
2011-09-26 14:48:12 +02:00
|
|
|
targetName = project->activeTarget()->displayName();
|
|
|
|
|
|
|
|
|
|
if (BuildConfiguration *bc = target->activeBuildConfiguration())
|
2010-02-08 15:50:06 +01:00
|
|
|
buildConfig = bc->displayName();
|
2010-02-04 11:54:49 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
if (DeployConfiguration *dc = target->activeDeployConfiguration())
|
|
|
|
|
deployConfig = dc->displayName();
|
|
|
|
|
|
|
|
|
|
if (RunConfiguration *rc = target->activeRunConfiguration())
|
2010-02-04 11:54:49 +01:00
|
|
|
runConfig = rc->displayName();
|
2011-09-26 14:48:12 +02:00
|
|
|
|
2010-02-09 19:05:15 +01:00
|
|
|
targetToolTipText = target->toolTip();
|
2010-02-23 16:52:03 +01:00
|
|
|
targetIcon = createCenteredIcon(target->icon(), target->overlayIcon());
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
m_projectAction->setProperty("heading", projectName);
|
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 (project && project->needsConfiguration())
|
2011-10-28 10:15:04 +00:00
|
|
|
m_projectAction->setProperty("subtitle", tr("Unconfigured"));
|
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
|
2011-10-28 10:15:04 +00:00
|
|
|
m_projectAction->setProperty("subtitle", buildConfig);
|
2010-02-09 19:05:15 +01:00
|
|
|
m_projectAction->setIcon(targetIcon);
|
2011-10-28 10:15:04 +00:00
|
|
|
QStringList lines;
|
|
|
|
|
lines << tr("<b>Project:</b> %1").arg(projectName);
|
2013-01-10 15:12:39 +01:00
|
|
|
if (!fileName.isEmpty())
|
|
|
|
|
lines << tr("<b>Path:</b> %1").arg(fileName);
|
2011-10-28 10:15:04 +00:00
|
|
|
if (!targetName.isEmpty())
|
2012-10-19 17:07:26 +02:00
|
|
|
lines << tr("<b>Kit:</b> %1").arg(targetName);
|
2011-10-28 10:15:04 +00:00
|
|
|
if (!buildConfig.isEmpty())
|
|
|
|
|
lines << tr("<b>Build:</b> %1").arg(buildConfig);
|
|
|
|
|
if (!deployConfig.isEmpty())
|
|
|
|
|
lines << tr("<b>Deploy:</b> %1").arg(deployConfig);
|
|
|
|
|
if (!runConfig.isEmpty())
|
|
|
|
|
lines << tr("<b>Run:</b> %1").arg(runConfig);
|
|
|
|
|
if (!targetToolTipText.isEmpty())
|
|
|
|
|
lines << tr("%1").arg(targetToolTipText);
|
|
|
|
|
QString toolTip = tr("<html><nobr>%1</html>")
|
|
|
|
|
.arg(lines.join(QLatin1String("<br/>")));
|
|
|
|
|
m_projectAction->setToolTip(toolTip);
|
2011-09-26 14:48:12 +02:00
|
|
|
updateSummary();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateSummary()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
QString summary;
|
2013-09-05 12:35:19 +02:00
|
|
|
if (Project *startupProject = SessionManager::startupProject()) {
|
2011-09-26 14:48:12 +02:00
|
|
|
if (!m_projectListWidget->isVisibleTo(this))
|
|
|
|
|
summary.append(tr("Project: <b>%1</b><br/>").arg(startupProject->displayName()));
|
2013-09-05 12:35:19 +02:00
|
|
|
if (Target *activeTarget = startupProject->activeTarget()) {
|
2011-09-26 14:48:12 +02:00
|
|
|
if (!m_listWidgets[TARGET]->isVisibleTo(this))
|
2012-09-03 18:31:44 +02:00
|
|
|
summary.append(tr("Kit: <b>%1</b><br/>").arg( activeTarget->displayName()));
|
2011-09-26 14:48:12 +02:00
|
|
|
if (!m_listWidgets[BUILD]->isVisibleTo(this) && activeTarget->activeBuildConfiguration())
|
|
|
|
|
summary.append(tr("Build: <b>%1</b><br/>").arg(
|
|
|
|
|
activeTarget->activeBuildConfiguration()->displayName()));
|
|
|
|
|
if (!m_listWidgets[DEPLOY]->isVisibleTo(this) && activeTarget->activeDeployConfiguration())
|
|
|
|
|
summary.append(tr("Deploy: <b>%1</b><br/>").arg(
|
|
|
|
|
activeTarget->activeDeployConfiguration()->displayName()));
|
|
|
|
|
if (!m_listWidgets[RUN]->isVisibleTo(this) && activeTarget->activeRunConfiguration())
|
|
|
|
|
summary.append(tr("Run: <b>%1</b><br/>").arg(
|
|
|
|
|
activeTarget->activeRunConfiguration()->displayName()));
|
2011-10-28 10:15:04 +00:00
|
|
|
} else if (startupProject->needsConfiguration()) {
|
|
|
|
|
summary = tr("<style type=text/css>"
|
|
|
|
|
"a:link {color: rgb(128, 128, 255, 240);}</style>"
|
|
|
|
|
"The project <b>%1</b> is not yet configured<br/><br/>"
|
|
|
|
|
"You can configure it in the <a href=\"projectmode\">Projects mode</a><br/>")
|
|
|
|
|
.arg(startupProject->displayName());
|
|
|
|
|
} else {
|
|
|
|
|
if (!m_listWidgets[TARGET]->isVisibleTo(this))
|
2012-11-21 22:40:31 +02:00
|
|
|
summary.append(QLatin1String("<br/>"));
|
2011-10-28 10:15:04 +00:00
|
|
|
if (!m_listWidgets[BUILD]->isVisibleTo(this))
|
2012-11-21 22:40:31 +02:00
|
|
|
summary.append(QLatin1String("<br/>"));
|
2011-10-28 10:15:04 +00:00
|
|
|
if (!m_listWidgets[DEPLOY]->isVisibleTo(this))
|
2012-11-21 22:40:31 +02:00
|
|
|
summary.append(QLatin1String("<br/>"));
|
2011-10-28 10:15:04 +00:00
|
|
|
if (!m_listWidgets[RUN]->isVisibleTo(this))
|
2012-11-21 22:40:31 +02:00
|
|
|
summary.append(QLatin1String("<br/>"));
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
m_summaryLabel->setText(summary);
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-02-24 19:23:40 +01:00
|
|
|
void MiniProjectTargetSelector::paintEvent(QPaintEvent *)
|
|
|
|
|
{
|
|
|
|
|
QPainter painter(this);
|
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
|
|
|
painter.setBrush(creatorTheme()->color(Theme::MiniProjectTargetSelectorBackgroundColor));
|
2012-08-24 17:20:19 +02:00
|
|
|
painter.drawRect(rect());
|
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
|
|
|
painter.setPen(creatorTheme()->color(Theme::MiniProjectTargetSelectorBackgroundColor));
|
|
|
|
|
// draw border on top and right
|
2010-02-24 19:23:40 +01:00
|
|
|
painter.drawLine(rect().topLeft(), rect().topRight());
|
|
|
|
|
painter.drawLine(rect().topRight(), rect().bottomRight());
|
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
|
|
|
if (creatorTheme()->flag(Theme::DrawTargetSelectorBottom)) {
|
|
|
|
|
// draw thicker border on the bottom
|
|
|
|
|
QRect bottomRect(0, rect().height() - 8, rect().width(), 8);
|
|
|
|
|
static QImage image(QLatin1String(":/projectexplorer/images/targetpanel_bottom.png"));
|
2015-02-03 23:59:04 +02:00
|
|
|
StyleHelper::drawCornerImage(image, &painter, bottomRect, 1, 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
|
|
|
}
|
2010-02-24 19:23:40 +01:00
|
|
|
}
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
|
void MiniProjectTargetSelector::switchToProjectsMode()
|
|
|
|
|
{
|
2013-08-29 17:45:36 +02:00
|
|
|
Core::ModeManager::activateMode(Constants::MODE_SESSION);
|
2011-10-28 10:15:04 +00:00
|
|
|
hide();
|
|
|
|
|
}
|