mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Merged in filnet/librepilot/LP-491_upgrade_to_qt_5_8 (pull request #404)
LP-491 upgrade to qt 5 8 Approved-by: Alessio Morale <alessiomorale@gmail.com> Approved-by: Lalanne Laurent <f5soh@free.fr> Approved-by: Philippe Renon <philippe_renon@yahoo.fr> Approved-by: Brian Webb <webbbn@gmail.com>
This commit is contained in:
commit
a9ca744293
@ -286,7 +286,7 @@ void systemInit()
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
}
|
||||
|
||||
static FileLogger *logger;
|
||||
static FileLogger *logger = NULL;
|
||||
|
||||
void mainMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
@ -295,14 +295,27 @@ void mainMessageOutput(QtMsgType type, const QMessageLogContext &context, const
|
||||
|
||||
Q_DECLARE_METATYPE(QtMsgType)
|
||||
|
||||
void logInit(QString fileName)
|
||||
void logInit(QString &fileName)
|
||||
{
|
||||
qRegisterMetaType<QtMsgType>();
|
||||
qInstallMessageHandler(mainMessageOutput);
|
||||
logger = new FileLogger();
|
||||
if (!logger->start(fileName)) {
|
||||
logger = new FileLogger(fileName);
|
||||
if (!logger->start()) {
|
||||
delete logger;
|
||||
logger = NULL;
|
||||
displayError(msgLogfileOpenFailed(fileName));
|
||||
return;
|
||||
}
|
||||
qInstallMessageHandler(mainMessageOutput);
|
||||
}
|
||||
|
||||
void logDeinit()
|
||||
{
|
||||
if (!logger) {
|
||||
return;
|
||||
}
|
||||
qInstallMessageHandler(0);
|
||||
delete logger;
|
||||
logger = NULL;
|
||||
}
|
||||
|
||||
AppOptions options()
|
||||
@ -618,9 +631,7 @@ int main(int argc, char * *argv)
|
||||
|
||||
qDebug() << "main - GCS ran for" << timer.elapsed() << "ms";
|
||||
|
||||
if (logger) {
|
||||
delete logger;
|
||||
}
|
||||
logDeinit();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ class qsspt;
|
||||
class opHID_hidapi;
|
||||
|
||||
namespace DFU {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
||||
Q_NAMESPACE
|
||||
#endif
|
||||
enum TransferTypes {
|
||||
FW,
|
||||
Descript
|
||||
|
@ -53,6 +53,7 @@ osg:win32 {
|
||||
librtmp-1.dll \
|
||||
libgmp-10.dll \
|
||||
libgnutls-30.dll \
|
||||
libunistring-2.dll \
|
||||
libp11-kit-0.dll \
|
||||
libffi-6.dll \
|
||||
libtasn1-6.dll \
|
||||
@ -192,7 +193,8 @@ osgearth:win32 {
|
||||
libosgEarthAnnotation$${DS}.dll \
|
||||
libosgEarthFeatures$${DS}.dll \
|
||||
libosgEarthSymbology$${DS}.dll \
|
||||
libosgEarthUtil$${DS}.dll
|
||||
libosgEarthUtil$${DS}.dll \
|
||||
libprotobuf.dll
|
||||
|
||||
# gdal
|
||||
OSGEARTH_LIBS += \
|
||||
|
@ -1,316 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancylineedit.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fancylineedit.h"
|
||||
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QString>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QLabel>
|
||||
|
||||
enum { margin = 6 };
|
||||
|
||||
namespace Utils {
|
||||
static inline QString sideToStyleSheetString(FancyLineEdit::Side side)
|
||||
{
|
||||
return side == FancyLineEdit::Left ? QLatin1String("left") : QLatin1String("right");
|
||||
}
|
||||
|
||||
// Format style sheet for the label containing the pixmap. It has a margin on
|
||||
// the outer side of the whole FancyLineEdit.
|
||||
static QString labelStyleSheet(FancyLineEdit::Side side)
|
||||
{
|
||||
QString rc = QLatin1String("QLabel { margin-");
|
||||
|
||||
rc += sideToStyleSheetString(side);
|
||||
rc += QLatin1String(": ");
|
||||
rc += QString::number(margin);
|
||||
rc += QLatin1Char('}');
|
||||
return rc;
|
||||
}
|
||||
|
||||
// --------- FancyLineEditPrivate as QObject with label
|
||||
// event filter
|
||||
|
||||
class FancyLineEditPrivate : public QObject {
|
||||
public:
|
||||
explicit FancyLineEditPrivate(QLineEdit *parent);
|
||||
|
||||
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
const QString m_leftLabelStyleSheet;
|
||||
const QString m_rightLabelStyleSheet;
|
||||
|
||||
QLineEdit *m_lineEdit;
|
||||
QPixmap m_pixmap;
|
||||
QMenu *m_menu;
|
||||
QLabel *m_menuLabel;
|
||||
FancyLineEdit::Side m_side;
|
||||
bool m_useLayoutDirection;
|
||||
bool m_menuTabFocusTrigger;
|
||||
QString m_hintText;
|
||||
bool m_showingHintText;
|
||||
};
|
||||
|
||||
|
||||
FancyLineEditPrivate::FancyLineEditPrivate(QLineEdit *parent) :
|
||||
QObject(parent),
|
||||
m_leftLabelStyleSheet(labelStyleSheet(FancyLineEdit::Left)),
|
||||
m_rightLabelStyleSheet(labelStyleSheet(FancyLineEdit::Right)),
|
||||
m_lineEdit(parent),
|
||||
m_menu(0),
|
||||
m_menuLabel(0),
|
||||
m_side(FancyLineEdit::Left),
|
||||
m_useLayoutDirection(false),
|
||||
m_menuTabFocusTrigger(false),
|
||||
m_showingHintText(false)
|
||||
{}
|
||||
|
||||
bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (!m_menu || obj != m_menuLabel) {
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
const QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||
m_menu->exec(me->globalPos());
|
||||
return true;
|
||||
}
|
||||
case QEvent::FocusIn:
|
||||
if (m_menuTabFocusTrigger) {
|
||||
m_lineEdit->setFocus();
|
||||
m_menu->exec(m_menuLabel->mapToGlobal(m_menuLabel->rect().center()));
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
// --------- FancyLineEdit
|
||||
FancyLineEdit::FancyLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent),
|
||||
m_d(new FancyLineEditPrivate(this))
|
||||
{
|
||||
m_d->m_menuLabel = new QLabel(this);
|
||||
m_d->m_menuLabel->installEventFilter(m_d);
|
||||
updateMenuLabel();
|
||||
showHintText();
|
||||
}
|
||||
|
||||
FancyLineEdit::~FancyLineEdit()
|
||||
{}
|
||||
|
||||
// Position the menu label left or right according to size.
|
||||
// Called when switching side and from resizeEvent.
|
||||
void FancyLineEdit::positionMenuLabel()
|
||||
{
|
||||
switch (side()) {
|
||||
case Left:
|
||||
m_d->m_menuLabel->setGeometry(0, 0, m_d->m_pixmap.width() + margin, height());
|
||||
break;
|
||||
case Right:
|
||||
m_d->m_menuLabel->setGeometry(width() - m_d->m_pixmap.width() - margin, 0,
|
||||
m_d->m_pixmap.width() + margin, height());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FancyLineEdit::updateStyleSheet(Side side)
|
||||
{
|
||||
// Udate the LineEdit style sheet. Make room for the label on the
|
||||
// respective side and set color according to whether we are showing the
|
||||
// hint text
|
||||
QString sheet = QLatin1String("QLineEdit{ padding-");
|
||||
|
||||
sheet += sideToStyleSheetString(side);
|
||||
sheet += QLatin1String(": ");
|
||||
sheet += QString::number(m_d->m_pixmap.width() + margin);
|
||||
sheet += QLatin1Char(';');
|
||||
if (m_d->m_showingHintText) {
|
||||
sheet += QLatin1String(" color: #BBBBBB;");
|
||||
}
|
||||
sheet += QLatin1Char('}');
|
||||
setStyleSheet(sheet);
|
||||
}
|
||||
|
||||
void FancyLineEdit::updateMenuLabel()
|
||||
{
|
||||
m_d->m_menuLabel->setPixmap(m_d->m_pixmap);
|
||||
const Side s = side();
|
||||
switch (s) {
|
||||
case Left:
|
||||
m_d->m_menuLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||
m_d->m_menuLabel->setStyleSheet(m_d->m_leftLabelStyleSheet);
|
||||
break;
|
||||
case Right:
|
||||
m_d->m_menuLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
|
||||
m_d->m_menuLabel->setStyleSheet(m_d->m_rightLabelStyleSheet);
|
||||
break;
|
||||
}
|
||||
updateStyleSheet(s);
|
||||
positionMenuLabel();
|
||||
}
|
||||
|
||||
void FancyLineEdit::setSide(Side side)
|
||||
{
|
||||
m_d->m_side = side;
|
||||
updateMenuLabel();
|
||||
}
|
||||
|
||||
FancyLineEdit::Side FancyLineEdit::side() const
|
||||
{
|
||||
if (m_d->m_useLayoutDirection) {
|
||||
return qApp->layoutDirection() == Qt::LeftToRight ? Left : Right;
|
||||
}
|
||||
return m_d->m_side;
|
||||
}
|
||||
|
||||
void FancyLineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
positionMenuLabel();
|
||||
}
|
||||
|
||||
void FancyLineEdit::setPixmap(const QPixmap &pixmap)
|
||||
{
|
||||
m_d->m_pixmap = pixmap;
|
||||
updateMenuLabel();
|
||||
}
|
||||
|
||||
QPixmap FancyLineEdit::pixmap() const
|
||||
{
|
||||
return m_d->m_pixmap;
|
||||
}
|
||||
|
||||
void FancyLineEdit::setMenu(QMenu *menu)
|
||||
{
|
||||
m_d->m_menu = menu;
|
||||
}
|
||||
|
||||
QMenu *FancyLineEdit::menu() const
|
||||
{
|
||||
return m_d->m_menu;
|
||||
}
|
||||
|
||||
bool FancyLineEdit::useLayoutDirection() const
|
||||
{
|
||||
return m_d->m_useLayoutDirection;
|
||||
}
|
||||
|
||||
void FancyLineEdit::setUseLayoutDirection(bool v)
|
||||
{
|
||||
m_d->m_useLayoutDirection = v;
|
||||
}
|
||||
|
||||
bool FancyLineEdit::isSideStored() const
|
||||
{
|
||||
return !m_d->m_useLayoutDirection;
|
||||
}
|
||||
|
||||
bool FancyLineEdit::hasMenuTabFocusTrigger() const
|
||||
{
|
||||
return m_d->m_menuTabFocusTrigger;
|
||||
}
|
||||
|
||||
void FancyLineEdit::setMenuTabFocusTrigger(bool v)
|
||||
{
|
||||
if (m_d->m_menuTabFocusTrigger == v) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_d->m_menuTabFocusTrigger = v;
|
||||
m_d->m_menuLabel->setFocusPolicy(v ? Qt::TabFocus : Qt::NoFocus);
|
||||
}
|
||||
|
||||
QString FancyLineEdit::hintText() const
|
||||
{
|
||||
return m_d->m_hintText;
|
||||
}
|
||||
|
||||
void FancyLineEdit::setHintText(const QString &ht)
|
||||
{
|
||||
// Updating magic to make the property work in Designer.
|
||||
if (ht == m_d->m_hintText) {
|
||||
return;
|
||||
}
|
||||
hideHintText();
|
||||
m_d->m_hintText = ht;
|
||||
if (!hasFocus() && !ht.isEmpty()) {
|
||||
showHintText();
|
||||
}
|
||||
}
|
||||
|
||||
void FancyLineEdit::showHintText()
|
||||
{
|
||||
if (!m_d->m_showingHintText && text().isEmpty() && !m_d->m_hintText.isEmpty()) {
|
||||
m_d->m_showingHintText = true;
|
||||
setText(m_d->m_hintText);
|
||||
updateStyleSheet(side());
|
||||
}
|
||||
}
|
||||
|
||||
void FancyLineEdit::hideHintText()
|
||||
{
|
||||
if (m_d->m_showingHintText && !m_d->m_hintText.isEmpty()) {
|
||||
m_d->m_showingHintText = false;
|
||||
setText(QString());
|
||||
updateStyleSheet(side());
|
||||
}
|
||||
}
|
||||
|
||||
void FancyLineEdit::focusInEvent(QFocusEvent *e)
|
||||
{
|
||||
hideHintText();
|
||||
QLineEdit::focusInEvent(e);
|
||||
}
|
||||
|
||||
void FancyLineEdit::focusOutEvent(QFocusEvent *e)
|
||||
{
|
||||
// Focus out: Switch to displaying the hint text unless
|
||||
// there is user input
|
||||
showHintText();
|
||||
QLineEdit::focusOutEvent(e);
|
||||
}
|
||||
|
||||
bool FancyLineEdit::isShowingHintText() const
|
||||
{
|
||||
return m_d->m_showingHintText;
|
||||
}
|
||||
|
||||
QString FancyLineEdit::typedText() const
|
||||
{
|
||||
return m_d->m_showingHintText ? QString() : text();
|
||||
}
|
||||
} // namespace Utils
|
@ -1,105 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancylineedit.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FANCYLINEEDIT_H
|
||||
#define FANCYLINEEDIT_H
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
namespace Utils {
|
||||
class FancyLineEditPrivate;
|
||||
|
||||
/* A line edit with an embedded pixmap on one side that is connected to
|
||||
* a menu. Additionally, it can display a grayed hintText (like "Type Here to")
|
||||
* when not focussed and empty. When connecting to the changed signals and
|
||||
* querying text, one has to be aware that the text is set to that hint
|
||||
* text if isShowingHintText() returns true (that is, does not contain
|
||||
* valid user input).
|
||||
*/
|
||||
class QTCREATOR_UTILS_EXPORT FancyLineEdit : public QLineEdit {
|
||||
Q_DISABLE_COPY(FancyLineEdit)
|
||||
Q_OBJECT Q_ENUMS(Side)
|
||||
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE true)
|
||||
Q_PROPERTY(Side side READ side WRITE setSide DESIGNABLE isSideStored STORED isSideStored)
|
||||
Q_PROPERTY(bool useLayoutDirection READ useLayoutDirection WRITE setUseLayoutDirection DESIGNABLE true)
|
||||
Q_PROPERTY(bool menuTabFocusTrigger READ hasMenuTabFocusTrigger WRITE setMenuTabFocusTrigger DESIGNABLE true)
|
||||
Q_PROPERTY(QString hintText READ hintText WRITE setHintText DESIGNABLE true)
|
||||
|
||||
public:
|
||||
enum Side { Left, Right };
|
||||
|
||||
explicit FancyLineEdit(QWidget *parent = 0);
|
||||
~FancyLineEdit();
|
||||
|
||||
QPixmap pixmap() const;
|
||||
|
||||
void setMenu(QMenu *menu);
|
||||
QMenu *menu() const;
|
||||
|
||||
void setSide(Side side);
|
||||
Side side() const;
|
||||
|
||||
bool useLayoutDirection() const;
|
||||
void setUseLayoutDirection(bool v);
|
||||
|
||||
// Set whether tabbing in will trigger the menu.
|
||||
bool hasMenuTabFocusTrigger() const;
|
||||
void setMenuTabFocusTrigger(bool v);
|
||||
|
||||
// Hint text that is displayed when no focus is set.
|
||||
QString hintText() const;
|
||||
|
||||
bool isShowingHintText() const;
|
||||
|
||||
// Convenience for accessing the text that returns "" in case of isShowingHintText().
|
||||
QString typedText() const;
|
||||
|
||||
public slots:
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
void setHintText(const QString &ht);
|
||||
void showHintText();
|
||||
void hideHintText();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *e);
|
||||
virtual void focusInEvent(QFocusEvent *e);
|
||||
virtual void focusOutEvent(QFocusEvent *e);
|
||||
|
||||
private:
|
||||
bool isSideStored() const;
|
||||
void updateMenuLabel();
|
||||
void positionMenuLabel();
|
||||
void updateStyleSheet(Side side);
|
||||
|
||||
FancyLineEditPrivate *m_d;
|
||||
};
|
||||
} // namespace Utils
|
||||
|
||||
#endif // FANCYLINEEDIT_H
|
@ -1,337 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancymainwindow.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fancymainwindow.h"
|
||||
|
||||
#include "qtcassert.h"
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QDockWidget>
|
||||
#include <QSettings>
|
||||
|
||||
static const char lockedKeyC[] = "Locked";
|
||||
static const char stateKeyC[] = "State";
|
||||
static const int settingsVersion = 2;
|
||||
static const char dockWidgetActiveState[] = "DockWidgetActiveState";
|
||||
|
||||
namespace Utils {
|
||||
/*! \class Utils::FancyMainWindow
|
||||
|
||||
\brief MainWindow with dock widgets and additional "lock" functionality
|
||||
(locking the dock widgets in place) and "reset layout" functionality.
|
||||
|
||||
The dock actions and the additional actions should be accessible
|
||||
in a Window-menu.
|
||||
*/
|
||||
|
||||
struct FancyMainWindowPrivate {
|
||||
FancyMainWindowPrivate();
|
||||
|
||||
bool m_locked;
|
||||
bool m_handleDockVisibilityChanges;
|
||||
|
||||
QAction m_menuSeparator1;
|
||||
QAction m_toggleLockedAction;
|
||||
QAction m_menuSeparator2;
|
||||
QAction m_resetLayoutAction;
|
||||
QDockWidget *m_toolBarDockWidget;
|
||||
};
|
||||
|
||||
FancyMainWindowPrivate::FancyMainWindowPrivate() :
|
||||
m_locked(true),
|
||||
m_handleDockVisibilityChanges(true),
|
||||
m_menuSeparator1(0),
|
||||
m_toggleLockedAction(FancyMainWindow::tr("Locked"), 0),
|
||||
m_menuSeparator2(0),
|
||||
m_resetLayoutAction(FancyMainWindow::tr("Reset to Default Layout"), 0),
|
||||
m_toolBarDockWidget(0)
|
||||
{
|
||||
m_toggleLockedAction.setCheckable(true);
|
||||
m_toggleLockedAction.setChecked(m_locked);
|
||||
m_menuSeparator1.setSeparator(true);
|
||||
m_menuSeparator2.setSeparator(true);
|
||||
}
|
||||
|
||||
FancyMainWindow::FancyMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent), d(new FancyMainWindowPrivate)
|
||||
{
|
||||
connect(&d->m_toggleLockedAction, SIGNAL(toggled(bool)),
|
||||
this, SLOT(setLocked(bool)));
|
||||
connect(&d->m_resetLayoutAction, SIGNAL(triggered()),
|
||||
this, SIGNAL(resetLayout()));
|
||||
}
|
||||
|
||||
FancyMainWindow::~FancyMainWindow()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QDockWidget *FancyMainWindow::addDockForWidget(QWidget *widget)
|
||||
{
|
||||
QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), this);
|
||||
|
||||
dockWidget->setWidget(widget);
|
||||
// Set an object name to be used in settings, derive from widget name
|
||||
const QString objectName = widget->objectName();
|
||||
if (objectName.isEmpty()) {
|
||||
dockWidget->setObjectName(QLatin1String("dockWidget") + QString::number(dockWidgets().size() + 1));
|
||||
} else {
|
||||
dockWidget->setObjectName(objectName + QLatin1String("DockWidget"));
|
||||
}
|
||||
connect(dockWidget->toggleViewAction(), SIGNAL(triggered()),
|
||||
this, SLOT(onDockActionTriggered()), Qt::QueuedConnection);
|
||||
connect(dockWidget, SIGNAL(visibilityChanged(bool)),
|
||||
this, SLOT(onDockVisibilityChange(bool)));
|
||||
connect(dockWidget, SIGNAL(topLevelChanged(bool)),
|
||||
this, SLOT(onTopLevelChanged()));
|
||||
dockWidget->setProperty(dockWidgetActiveState, true);
|
||||
updateDockWidget(dockWidget);
|
||||
return dockWidget;
|
||||
}
|
||||
|
||||
void FancyMainWindow::updateDockWidget(QDockWidget *dockWidget)
|
||||
{
|
||||
const QDockWidget::DockWidgetFeatures features =
|
||||
(d->m_locked) ? QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable
|
||||
: QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable;
|
||||
|
||||
if (dockWidget->property("managed_dockwidget").isNull()) { // for the debugger tool bar
|
||||
QWidget *titleBarWidget = dockWidget->titleBarWidget();
|
||||
if (d->m_locked && !titleBarWidget && !dockWidget->isFloating()) {
|
||||
titleBarWidget = new QWidget(dockWidget);
|
||||
} else if ((!d->m_locked || dockWidget->isFloating()) && titleBarWidget) {
|
||||
delete titleBarWidget;
|
||||
titleBarWidget = 0;
|
||||
}
|
||||
dockWidget->setTitleBarWidget(titleBarWidget);
|
||||
}
|
||||
dockWidget->setFeatures(features);
|
||||
}
|
||||
|
||||
void FancyMainWindow::onDockActionTriggered()
|
||||
{
|
||||
QDockWidget *dw = qobject_cast<QDockWidget *>(sender()->parent());
|
||||
|
||||
if (dw) {
|
||||
if (dw->isVisible()) {
|
||||
dw->raise();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FancyMainWindow::onDockVisibilityChange(bool visible)
|
||||
{
|
||||
if (d->m_handleDockVisibilityChanges) {
|
||||
sender()->setProperty(dockWidgetActiveState, visible);
|
||||
}
|
||||
}
|
||||
|
||||
void FancyMainWindow::onTopLevelChanged()
|
||||
{
|
||||
updateDockWidget(qobject_cast<QDockWidget *>(sender()));
|
||||
}
|
||||
|
||||
void FancyMainWindow::setTrackingEnabled(bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
d->m_handleDockVisibilityChanges = true;
|
||||
foreach(QDockWidget * dockWidget, dockWidgets())
|
||||
dockWidget->setProperty(dockWidgetActiveState, dockWidget->isVisible());
|
||||
} else {
|
||||
d->m_handleDockVisibilityChanges = false;
|
||||
}
|
||||
}
|
||||
|
||||
void FancyMainWindow::setLocked(bool locked)
|
||||
{
|
||||
d->m_locked = locked;
|
||||
foreach(QDockWidget * dockWidget, dockWidgets()) {
|
||||
updateDockWidget(dockWidget);
|
||||
}
|
||||
}
|
||||
|
||||
void FancyMainWindow::hideEvent(QHideEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
handleVisibilityChanged(false);
|
||||
}
|
||||
|
||||
void FancyMainWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
handleVisibilityChanged(true);
|
||||
}
|
||||
|
||||
void FancyMainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu *menu = createPopupMenu();
|
||||
|
||||
menu->exec(event->globalPos());
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void FancyMainWindow::handleVisibilityChanged(bool visible)
|
||||
{
|
||||
d->m_handleDockVisibilityChanges = false;
|
||||
foreach(QDockWidget * dockWidget, dockWidgets()) {
|
||||
if (dockWidget->isFloating()) {
|
||||
dockWidget->setVisible(visible
|
||||
&& dockWidget->property(dockWidgetActiveState).toBool());
|
||||
}
|
||||
}
|
||||
if (visible) {
|
||||
d->m_handleDockVisibilityChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
void FancyMainWindow::saveSettings(QSettings *settings) const
|
||||
{
|
||||
QHash<QString, QVariant> hash = saveSettings();
|
||||
QHashIterator<QString, QVariant> it(hash);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
settings->setValue(it.key(), it.value());
|
||||
}
|
||||
}
|
||||
|
||||
void FancyMainWindow::restoreSettings(const QSettings *settings)
|
||||
{
|
||||
QHash<QString, QVariant> hash;
|
||||
foreach(const QString &key, settings->childKeys()) {
|
||||
hash.insert(key, settings->value(key));
|
||||
}
|
||||
restoreSettings(hash);
|
||||
}
|
||||
|
||||
QHash<QString, QVariant> FancyMainWindow::saveSettings() const
|
||||
{
|
||||
QHash<QString, QVariant> settings;
|
||||
settings.insert(QLatin1String(stateKeyC), saveState(settingsVersion));
|
||||
settings.insert(QLatin1String(lockedKeyC), d->m_locked);
|
||||
foreach(QDockWidget * dockWidget, dockWidgets()) {
|
||||
settings.insert(dockWidget->objectName(),
|
||||
dockWidget->property(dockWidgetActiveState));
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
void FancyMainWindow::restoreSettings(const QHash<QString, QVariant> &settings)
|
||||
{
|
||||
QByteArray ba = settings.value(QLatin1String(stateKeyC), QByteArray()).toByteArray();
|
||||
|
||||
if (!ba.isEmpty()) {
|
||||
restoreState(ba, settingsVersion);
|
||||
}
|
||||
d->m_locked = settings.value(QLatin1String("Locked"), true).toBool();
|
||||
d->m_toggleLockedAction.setChecked(d->m_locked);
|
||||
foreach(QDockWidget * widget, dockWidgets()) {
|
||||
widget->setProperty(dockWidgetActiveState,
|
||||
settings.value(widget->objectName(), false));
|
||||
}
|
||||
}
|
||||
|
||||
QList<QDockWidget *> FancyMainWindow::dockWidgets() const
|
||||
{
|
||||
return findChildren<QDockWidget *>();
|
||||
}
|
||||
|
||||
bool FancyMainWindow::isLocked() const
|
||||
{
|
||||
return d->m_locked;
|
||||
}
|
||||
|
||||
static bool actionLessThan(const QAction *action1, const QAction *action2)
|
||||
{
|
||||
QTC_ASSERT(action1, return true);
|
||||
QTC_ASSERT(action2, return false);
|
||||
return action1->text().toLower() < action2->text().toLower();
|
||||
}
|
||||
|
||||
QMenu *FancyMainWindow::createPopupMenu()
|
||||
{
|
||||
QList<QAction *> actions;
|
||||
QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>();
|
||||
for (int i = 0; i < dockwidgets.size(); ++i) {
|
||||
QDockWidget *dockWidget = dockwidgets.at(i);
|
||||
if (dockWidget->property("managed_dockwidget").isNull()
|
||||
&& dockWidget->parentWidget() == this) {
|
||||
actions.append(dockwidgets.at(i)->toggleViewAction());
|
||||
}
|
||||
}
|
||||
qSort(actions.begin(), actions.end(), actionLessThan);
|
||||
QMenu *menu = new QMenu(this);
|
||||
foreach(QAction * action, actions)
|
||||
menu->addAction(action);
|
||||
menu->addAction(&d->m_menuSeparator1);
|
||||
menu->addAction(&d->m_toggleLockedAction);
|
||||
menu->addAction(&d->m_menuSeparator2);
|
||||
menu->addAction(&d->m_resetLayoutAction);
|
||||
return menu;
|
||||
}
|
||||
|
||||
QAction *FancyMainWindow::menuSeparator1() const
|
||||
{
|
||||
return &d->m_menuSeparator1;
|
||||
}
|
||||
|
||||
QAction *FancyMainWindow::toggleLockedAction() const
|
||||
{
|
||||
return &d->m_toggleLockedAction;
|
||||
}
|
||||
|
||||
QAction *FancyMainWindow::menuSeparator2() const
|
||||
{
|
||||
return &d->m_menuSeparator2;
|
||||
}
|
||||
|
||||
QAction *FancyMainWindow::resetLayoutAction() const
|
||||
{
|
||||
return &d->m_resetLayoutAction;
|
||||
}
|
||||
|
||||
void FancyMainWindow::setDockActionsVisible(bool v)
|
||||
{
|
||||
foreach(const QDockWidget * dockWidget, dockWidgets())
|
||||
dockWidget->toggleViewAction()->setVisible(v);
|
||||
d->m_toggleLockedAction.setVisible(v);
|
||||
d->m_menuSeparator1.setVisible(v);
|
||||
d->m_menuSeparator2.setVisible(v);
|
||||
d->m_resetLayoutAction.setVisible(v);
|
||||
}
|
||||
|
||||
QDockWidget *FancyMainWindow::toolBarDockWidget() const
|
||||
{
|
||||
return d->m_toolBarDockWidget;
|
||||
}
|
||||
|
||||
void FancyMainWindow::setToolBarDockWidget(QDockWidget *dock)
|
||||
{
|
||||
d->m_toolBarDockWidget = dock;
|
||||
}
|
||||
} // namespace Utils
|
@ -1,102 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancymainwindow.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FANCYMAINWINDOW_H
|
||||
#define FANCYMAINWINDOW_H
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
struct FancyMainWindowPrivate;
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT FancyMainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FancyMainWindow(QWidget *parent = 0);
|
||||
virtual ~FancyMainWindow();
|
||||
|
||||
/* The widget passed in should have an objectname set
|
||||
* which will then be used as key for QSettings. */
|
||||
QDockWidget *addDockForWidget(QWidget *widget);
|
||||
QList<QDockWidget *> dockWidgets() const;
|
||||
|
||||
void setTrackingEnabled(bool enabled);
|
||||
bool isLocked() const;
|
||||
|
||||
void saveSettings(QSettings *settings) const;
|
||||
void restoreSettings(const QSettings *settings);
|
||||
QHash<QString, QVariant> saveSettings() const;
|
||||
void restoreSettings(const QHash<QString, QVariant> &settings);
|
||||
|
||||
// Additional context menu actions
|
||||
QAction *menuSeparator1() const;
|
||||
QAction *toggleLockedAction() const;
|
||||
QAction *menuSeparator2() const;
|
||||
QAction *resetLayoutAction() const;
|
||||
|
||||
// Overwritten to add locked/reset.
|
||||
virtual QMenu *createPopupMenu();
|
||||
|
||||
|
||||
QDockWidget *toolBarDockWidget() const;
|
||||
void setToolBarDockWidget(QDockWidget *dock);
|
||||
|
||||
signals:
|
||||
// Emitted by resetLayoutAction(). Connect to a slot
|
||||
// restoring the default layout.
|
||||
void resetLayout();
|
||||
|
||||
public slots:
|
||||
void setLocked(bool locked);
|
||||
void setDockActionsVisible(bool v);
|
||||
|
||||
protected:
|
||||
void hideEvent(QHideEvent *event);
|
||||
void showEvent(QShowEvent *event);
|
||||
void contextMenuEvent(QContextMenuEvent *event);
|
||||
private slots:
|
||||
void onDockActionTriggered();
|
||||
void onDockVisibilityChange(bool);
|
||||
void onTopLevelChanged();
|
||||
|
||||
private:
|
||||
void updateDockWidget(QDockWidget *dockWidget);
|
||||
void handleVisibilityChanged(bool visible);
|
||||
|
||||
FancyMainWindowPrivate *d;
|
||||
};
|
||||
} // namespace Utils
|
||||
|
||||
#endif // FANCYMAINWINDOW_H
|
@ -39,40 +39,34 @@
|
||||
class QTCREATOR_UTILS_EXPORT FileLogger : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QTextStream * logStream;
|
||||
QThread *loggerThread;
|
||||
bool started;
|
||||
|
||||
public:
|
||||
FileLogger() : QObject(), logStream(NULL), loggerThread(NULL), started(false)
|
||||
FileLogger(QString &fileName) : QObject(), file(fileName), logStream(NULL), loggerThread(NULL), started(false)
|
||||
{}
|
||||
|
||||
virtual ~FileLogger()
|
||||
{
|
||||
qDebug() << "~FileLogger";
|
||||
stop();
|
||||
if (logStream) {
|
||||
delete logStream;
|
||||
}
|
||||
delete logStream;
|
||||
logStream = NULL;
|
||||
}
|
||||
|
||||
public:
|
||||
bool start(const QString &fileName)
|
||||
bool start()
|
||||
{
|
||||
if (started) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile *file = new QFile(fileName);
|
||||
if (!file->open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logStream = new QTextStream(file);
|
||||
logStream = new QTextStream(&file);
|
||||
|
||||
loggerThread = new QThread(this);
|
||||
moveToThread(loggerThread);
|
||||
loggerThread->start();
|
||||
// loggerThread = new QThread(this);
|
||||
moveToThread(&loggerThread);
|
||||
// connect(&loggerThread, &QThread::finished, this, &QObject::deleteLater);
|
||||
loggerThread.start();
|
||||
|
||||
started = true;
|
||||
|
||||
@ -93,6 +87,9 @@ public:
|
||||
QMetaObject::invokeMethod(this, "doLog", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(QtMsgType, type), Q_ARG(const QString &, msg));
|
||||
|
||||
loggerThread.quit();
|
||||
loggerThread.wait();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -138,4 +135,10 @@ private slots:
|
||||
out << msg << '\n';
|
||||
out.flush();
|
||||
}
|
||||
|
||||
private:
|
||||
QFile file;
|
||||
QTextStream *logStream;
|
||||
QThread loggerThread;
|
||||
bool started;
|
||||
};
|
||||
|
@ -27,7 +27,6 @@ SOURCES += \
|
||||
newclasswidget.cpp \
|
||||
classnamevalidatinglineedit.cpp \
|
||||
linecolumnlabel.cpp \
|
||||
fancylineedit.cpp \
|
||||
qtcolorbutton.cpp \
|
||||
savedaction.cpp \
|
||||
submiteditorwidget.cpp \
|
||||
@ -42,7 +41,6 @@ SOURCES += \
|
||||
stylehelper.cpp \
|
||||
welcomemodetreewidget.cpp \
|
||||
iwelcomepage.cpp \
|
||||
fancymainwindow.cpp \
|
||||
detailsbutton.cpp \
|
||||
detailswidget.cpp \
|
||||
coordinateconversions.cpp \
|
||||
@ -89,7 +87,6 @@ HEADERS += \
|
||||
newclasswidget.h \
|
||||
classnamevalidatinglineedit.h \
|
||||
linecolumnlabel.h \
|
||||
fancylineedit.h \
|
||||
qtcolorbutton.h \
|
||||
savedaction.h \
|
||||
submiteditorwidget.h \
|
||||
@ -106,7 +103,6 @@ HEADERS += \
|
||||
stylehelper.h \
|
||||
welcomemodetreewidget.h \
|
||||
iwelcomepage.h \
|
||||
fancymainwindow.h \
|
||||
detailsbutton.h \
|
||||
detailswidget.h \
|
||||
coordinateconversions.h \
|
||||
|
@ -19,7 +19,6 @@ HEADERS += \
|
||||
configgadgetwidget.h \
|
||||
configgadgetfactory.h \
|
||||
configgadget.h \
|
||||
fancytabwidget.h \
|
||||
configinputwidget.h \
|
||||
configoutputwidget.h \
|
||||
configvehicletypewidget.h \
|
||||
@ -68,7 +67,6 @@ SOURCES += \
|
||||
configgadgetwidget.cpp \
|
||||
configgadgetfactory.cpp \
|
||||
configgadget.cpp \
|
||||
fancytabwidget.cpp \
|
||||
configinputwidget.cpp \
|
||||
configoutputwidget.cpp \
|
||||
configvehicletypewidget.cpp \
|
||||
|
@ -1,502 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancytabwidget.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtPlugin>
|
||||
#include <QColorDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
// #include <QWindowsStyle>
|
||||
#include <QPainter>
|
||||
#include <QSplitter>
|
||||
#include <QStackedLayout>
|
||||
#include <QStatusBar>
|
||||
#include <QToolButton>
|
||||
#include <QToolTip>
|
||||
|
||||
const int FancyTabBar::m_rounding = 22;
|
||||
const int FancyTabBar::m_textPadding = 4;
|
||||
|
||||
FancyTabBar::FancyTabBar(QWidget *parent, bool isVertical)
|
||||
: QWidget(parent)
|
||||
{
|
||||
verticalTabs = isVertical;
|
||||
setIconSize(16);
|
||||
m_hoverIndex = -1;
|
||||
m_currentIndex = 0;
|
||||
if (isVertical) {
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
} else {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
// setStyle(new QWindowsStyle);
|
||||
setMinimumWidth(qMax(2 * m_rounding, 40));
|
||||
setAttribute(Qt::WA_Hover, true);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
m_hoverControl.setFrameRange(0, 20);
|
||||
m_hoverControl.setDuration(130);
|
||||
m_hoverControl.setCurveShape(QTimeLine::EaseInCurve);
|
||||
connect(&m_hoverControl, SIGNAL(frameChanged(int)), this, SLOT(updateHover()));
|
||||
setMouseTracking(true); // Needed for hover events
|
||||
}
|
||||
|
||||
FancyTabBar::~FancyTabBar()
|
||||
{
|
||||
delete style();
|
||||
}
|
||||
|
||||
QSize FancyTabBar::tabSizeHint(bool minimum) const
|
||||
{
|
||||
QFont boldFont(font());
|
||||
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
QFontMetrics fm(boldFont);
|
||||
int spacing = 6;
|
||||
int width = 90 + spacing + 2;
|
||||
|
||||
int iconHeight = minimum ? 0 : iconSize;
|
||||
return QSize(width, iconHeight + spacing + fm.height());
|
||||
}
|
||||
|
||||
void FancyTabBar::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (i != currentIndex()) {
|
||||
paintTab(&p, i);
|
||||
}
|
||||
}
|
||||
|
||||
// paint active tab last, since it overlaps the neighbors
|
||||
paintTab(&p, currentIndex());
|
||||
}
|
||||
|
||||
// Handle hover events for mouse fade ins
|
||||
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (!m_hoverRect.contains(e->pos())) {
|
||||
int newHover = -1;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
QRect area = tabRect(i);
|
||||
if (area.contains(e->pos())) {
|
||||
newHover = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_hoverControl.stop();
|
||||
m_hoverIndex = newHover;
|
||||
update(m_hoverRect);
|
||||
m_hoverRect = QRect();
|
||||
|
||||
if (m_hoverIndex >= 0) {
|
||||
m_hoverRect = tabRect(m_hoverIndex);
|
||||
m_hoverControl.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FancyTabBar::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ToolTip) {
|
||||
if (m_hoverIndex >= 0 && m_hoverIndex < m_tabs.count()) {
|
||||
QString tt = tabToolTip(m_hoverIndex);
|
||||
if (!tt.isEmpty()) {
|
||||
QToolTip::showText(static_cast<QHelpEvent *>(event)->globalPos(), tt, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void FancyTabBar::updateHover()
|
||||
{
|
||||
update(m_hoverRect);
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::enterEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
m_hoverRect = QRect();
|
||||
m_hoverIndex = -1;
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::leaveEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
if (m_hoverIndex >= 0) {
|
||||
m_hoverIndex = -1;
|
||||
update(m_hoverRect);
|
||||
m_hoverRect = QRect();
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabBar::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_tabs[index].icon = icon;
|
||||
m_tabs[index].text = label;
|
||||
}
|
||||
|
||||
QSize FancyTabBar::sizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
|
||||
if (verticalTabs) {
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
}
|
||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
||||
}
|
||||
|
||||
QSize FancyTabBar::minimumSizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint(true);
|
||||
|
||||
if (verticalTabs) {
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
}
|
||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
||||
}
|
||||
|
||||
QRect FancyTabBar::tabRect(int index) const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
|
||||
if (verticalTabs) {
|
||||
if (sh.height() * m_tabs.count() > height()) {
|
||||
sh.setHeight(height() / m_tabs.count());
|
||||
}
|
||||
|
||||
return QRect(0, index * sh.height(), sh.width(), sh.height());
|
||||
}
|
||||
|
||||
if (sh.width() * m_tabs.count() > width()) {
|
||||
sh.setWidth(width() / m_tabs.count());
|
||||
}
|
||||
|
||||
return QRect(index * sh.width(), 0, sh.width(), sh.height());
|
||||
}
|
||||
|
||||
void FancyTabBar::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
e->accept();
|
||||
for (int i = 0; i < m_tabs.count(); ++i) {
|
||||
if (tabRect(i).contains(e->pos())) {
|
||||
setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QRect rect = tabRect(tabIndex);
|
||||
|
||||
bool selected = (tabIndex == m_currentIndex);
|
||||
bool hover = (tabIndex == m_hoverIndex);
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
hover = false; // Dont hover on Mac
|
||||
#endif
|
||||
|
||||
QColor background = QColor(0, 0, 0, 10);
|
||||
QColor hoverColor;
|
||||
|
||||
if (hover) {
|
||||
hoverColor = QColor(255, 255, 255, m_hoverControl.currentFrame());
|
||||
}
|
||||
|
||||
QColor light = QColor(255, 255, 255, 40);
|
||||
QColor dark = QColor(0, 0, 0, 60);
|
||||
|
||||
if (selected) {
|
||||
QLinearGradient selectedGradient(rect.bottomRight(), QPoint(rect.center().x(), rect.top()));
|
||||
selectedGradient.setColorAt(0, Qt::white);
|
||||
selectedGradient.setColorAt(0.3, Qt::white);
|
||||
selectedGradient.setColorAt(0.7, QColor(210, 210, 220)); // give a blue-ish color
|
||||
|
||||
painter->fillRect(rect, selectedGradient);
|
||||
painter->setPen(QColor(200, 200, 200));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->setPen(QColor(150, 160, 200));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
} else {
|
||||
painter->fillRect(rect, background);
|
||||
if (hover) {
|
||||
painter->fillRect(rect, hoverColor);
|
||||
}
|
||||
painter->setPen(QPen(light, 0));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->setPen(QPen(dark, 0));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
}
|
||||
|
||||
QString tabText(this->tabText(tabIndex));
|
||||
QRect tabTextRect(tabRect(tabIndex));
|
||||
QRect tabIconRect(tabTextRect);
|
||||
QFont boldFont(painter->font());
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
painter->setFont(boldFont);
|
||||
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(30, 30, 30, 80));
|
||||
int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::ElideRight | Qt::TextWordWrap;
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
|
||||
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
|
||||
tabIconRect.adjust(0, 4, 0, -textHeight);
|
||||
int iconSize = qMin(tabIconRect.width(), tabIconRect.height());
|
||||
if (iconSize > 4) {
|
||||
style()->drawItemPixmap(painter, tabIconRect, Qt::AlignCenter | Qt::AlignVCenter,
|
||||
tabIcon(tabIndex).pixmap(tabIconRect.size()));
|
||||
}
|
||||
painter->translate(0, -1);
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void FancyTabBar::setCurrentIndex(int index)
|
||||
{
|
||||
bool proceed = true;
|
||||
emit aboutToChange(&proceed);
|
||||
|
||||
if (!proceed) {
|
||||
return;
|
||||
}
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
emit currentChanged(index);
|
||||
}
|
||||
|
||||
//////
|
||||
// FancyColorButton
|
||||
//////
|
||||
|
||||
class FancyColorButton : public QWidget {
|
||||
public:
|
||||
FancyColorButton(QWidget *parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
void mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
if (ev->modifiers() & Qt::ShiftModifier) {
|
||||
Utils::StyleHelper::setBaseColor(QColorDialog::getColor(Utils::StyleHelper::baseColor(), m_parent));
|
||||
}
|
||||
}
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
};
|
||||
|
||||
//////
|
||||
// FancyTabWidget
|
||||
//////
|
||||
|
||||
FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_tabBar = new FancyTabBar(this, isVertical);
|
||||
m_selectionWidget = new QWidget(this);
|
||||
QBoxLayout *selectionLayout;
|
||||
if (isVertical) {
|
||||
selectionLayout = new QVBoxLayout;
|
||||
} else {
|
||||
selectionLayout = new QHBoxLayout;
|
||||
}
|
||||
selectionLayout->setSpacing(0);
|
||||
selectionLayout->setMargin(0);
|
||||
|
||||
Utils::StyledBar *bar = new Utils::StyledBar;
|
||||
QBoxLayout *layout;
|
||||
if (isVertical) {
|
||||
layout = new QHBoxLayout(bar);
|
||||
} else {
|
||||
layout = new QVBoxLayout(bar);
|
||||
}
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(new FancyColorButton(this));
|
||||
selectionLayout->addWidget(bar);
|
||||
|
||||
selectionLayout->addWidget(m_tabBar, 1);
|
||||
m_selectionWidget->setLayout(selectionLayout);
|
||||
if (isVertical) {
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
} else {
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
m_cornerWidgetContainer = new QWidget(this);
|
||||
if (isVertical) {
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
} else {
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||
}
|
||||
m_cornerWidgetContainer->setAutoFillBackground(false);
|
||||
|
||||
QBoxLayout *cornerWidgetLayout;
|
||||
if (isVertical) {
|
||||
cornerWidgetLayout = new QVBoxLayout;
|
||||
} else {
|
||||
cornerWidgetLayout = new QHBoxLayout;
|
||||
}
|
||||
cornerWidgetLayout->setSpacing(0);
|
||||
cornerWidgetLayout->setMargin(0);
|
||||
cornerWidgetLayout->addStretch();
|
||||
m_cornerWidgetContainer->setLayout(cornerWidgetLayout);
|
||||
|
||||
selectionLayout->addWidget(m_cornerWidgetContainer, 0);
|
||||
|
||||
m_modesStack = new QStackedLayout;
|
||||
m_statusBar = new QStatusBar;
|
||||
m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addLayout(m_modesStack);
|
||||
if (!isVertical) {
|
||||
vlayout->addWidget(m_selectionWidget);
|
||||
}
|
||||
// vlayout->addWidget(m_statusBar); //status bar is not used for now
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(1);
|
||||
if (isVertical) {
|
||||
mainLayout->addWidget(m_selectionWidget);
|
||||
}
|
||||
mainLayout->addLayout(vlayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(showWidget(int)));
|
||||
}
|
||||
|
||||
void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_modesStack->insertWidget(index, tab);
|
||||
m_tabBar->insertTab(index, icon, label);
|
||||
}
|
||||
|
||||
void FancyTabWidget::removeTab(int index)
|
||||
{
|
||||
m_modesStack->removeWidget(m_modesStack->widget(index));
|
||||
m_tabBar->removeTab(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_tabBar->updateTabNameIcon(index, icon, label);
|
||||
m_tabBar->repaint();
|
||||
}
|
||||
|
||||
|
||||
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
|
||||
{
|
||||
QPalette pal = m_tabBar->palette();
|
||||
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_tabBar->setPalette(pal);
|
||||
pal = m_cornerWidgetContainer->palette();
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_cornerWidgetContainer->setPalette(pal);
|
||||
}
|
||||
|
||||
void FancyTabWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
QRect rect = m_selectionWidget->geometry().adjusted(0, 0, 1, 0);
|
||||
rect = style()->visualRect(layoutDirection(), geometry(), rect);
|
||||
Utils::StyleHelper::verticalGradient(&p, rect, rect);
|
||||
p.setPen(Utils::StyleHelper::borderColor());
|
||||
p.drawLine(rect.topLeft(), rect.topRight());
|
||||
}
|
||||
|
||||
void FancyTabWidget::insertCornerWidget(int pos, QWidget *widget)
|
||||
{
|
||||
QHBoxLayout *layout = static_cast<QHBoxLayout *>(m_cornerWidgetContainer->layout());
|
||||
|
||||
layout->insertWidget(pos, widget);
|
||||
}
|
||||
|
||||
int FancyTabWidget::cornerWidgetCount() const
|
||||
{
|
||||
return m_cornerWidgetContainer->layout()->count();
|
||||
}
|
||||
|
||||
void FancyTabWidget::addCornerWidget(QWidget *widget)
|
||||
{
|
||||
m_cornerWidgetContainer->layout()->addWidget(widget);
|
||||
}
|
||||
|
||||
int FancyTabWidget::currentIndex() const
|
||||
{
|
||||
return m_tabBar->currentIndex();
|
||||
}
|
||||
|
||||
QStatusBar *FancyTabWidget::statusBar() const
|
||||
{
|
||||
return m_statusBar;
|
||||
}
|
||||
|
||||
void FancyTabWidget::setCurrentIndex(int index)
|
||||
{
|
||||
m_tabBar->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::showWidget(int index)
|
||||
{
|
||||
emit currentAboutToShow(index);
|
||||
|
||||
m_modesStack->setCurrentIndex(index);
|
||||
emit currentChanged(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::setTabToolTip(int index, const QString &toolTip)
|
||||
{
|
||||
m_tabBar->setTabToolTip(index, toolTip);
|
||||
}
|
||||
QWidget *FancyTabWidget::currentWidget()
|
||||
{
|
||||
return m_modesStack->currentWidget();
|
||||
}
|
@ -1,179 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancytabwidget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FANCYTABWIDGET_H
|
||||
#define FANCYTABWIDGET_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QTabBar>
|
||||
#include <QStyleOptionTabV2>
|
||||
#include <QtCore/QTimeLine>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPainter;
|
||||
class QStackedLayout;
|
||||
class QStatusBar;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
struct FancyTab {
|
||||
QIcon icon;
|
||||
QString text;
|
||||
QString toolTip;
|
||||
};
|
||||
|
||||
class FancyTabBar : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabBar(QWidget *parent = 0, bool isVertical = false);
|
||||
~FancyTabBar();
|
||||
|
||||
bool event(QEvent *event);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void paintTab(QPainter *painter, int tabIndex) const;
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
void insertTab(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
FancyTab tab;
|
||||
|
||||
tab.icon = icon;
|
||||
tab.text = label;
|
||||
m_tabs.insert(index, tab);
|
||||
}
|
||||
void removeTab(int index)
|
||||
{
|
||||
m_tabs.removeAt(index);
|
||||
}
|
||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
||||
void setCurrentIndex(int index);
|
||||
int currentIndex() const
|
||||
{
|
||||
return m_currentIndex;
|
||||
}
|
||||
|
||||
void setTabToolTip(int index, QString toolTip)
|
||||
{
|
||||
m_tabs[index].toolTip = toolTip;
|
||||
}
|
||||
QString tabToolTip(int index) const
|
||||
{
|
||||
return m_tabs.at(index).toolTip;
|
||||
}
|
||||
|
||||
void setIconSize(int s)
|
||||
{
|
||||
iconSize = s;
|
||||
}
|
||||
QIcon tabIcon(int index) const
|
||||
{
|
||||
return m_tabs.at(index).icon;
|
||||
}
|
||||
QString tabText(int index) const
|
||||
{
|
||||
return m_tabs.at(index).text;
|
||||
}
|
||||
int count() const
|
||||
{
|
||||
return m_tabs.count();
|
||||
}
|
||||
QRect tabRect(int index) const;
|
||||
|
||||
|
||||
signals:
|
||||
void currentChanged(int);
|
||||
void aboutToChange(bool *);
|
||||
|
||||
public slots:
|
||||
void updateHover();
|
||||
|
||||
private:
|
||||
static const int m_rounding;
|
||||
static const int m_textPadding;
|
||||
QTimeLine m_hoverControl;
|
||||
QRect m_hoverRect;
|
||||
int m_hoverIndex;
|
||||
int m_currentIndex;
|
||||
int iconSize;
|
||||
QList<FancyTab> m_tabs;
|
||||
bool verticalTabs;
|
||||
|
||||
QSize tabSizeHint(bool minimum = false) const;
|
||||
};
|
||||
|
||||
class FancyTabWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabWidget(QWidget *parent = 0, bool isVertical = false);
|
||||
FancyTabBar *m_tabBar;
|
||||
void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
|
||||
void removeTab(int index);
|
||||
void setBackgroundBrush(const QBrush &brush);
|
||||
void addCornerWidget(QWidget *widget);
|
||||
void insertCornerWidget(int pos, QWidget *widget);
|
||||
int cornerWidgetCount() const;
|
||||
void setTabToolTip(int index, const QString &toolTip);
|
||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
||||
void setIconSize(int s)
|
||||
{
|
||||
m_tabBar->setIconSize(s);
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
int currentIndex() const;
|
||||
QStatusBar *statusBar() const;
|
||||
|
||||
QWidget *currentWidget();
|
||||
signals:
|
||||
void currentAboutToShow(int index);
|
||||
void currentChanged(int index);
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(int index);
|
||||
|
||||
private slots:
|
||||
void showWidget(int index);
|
||||
|
||||
private:
|
||||
QWidget *m_cornerWidgetContainer;
|
||||
QStackedLayout *m_modesStack;
|
||||
QWidget *m_selectionWidget;
|
||||
QStatusBar *m_statusBar;
|
||||
};
|
||||
|
||||
|
||||
#endif // FANCYTABWIDGET_H
|
@ -24,9 +24,6 @@ DEPENDPATH += \
|
||||
|
||||
SOURCES += \
|
||||
mainwindow.cpp \
|
||||
tabpositionindicator.cpp \
|
||||
fancyactionbar.cpp \
|
||||
fancytabwidget.cpp \
|
||||
generalsettings.cpp \
|
||||
uniqueidmanager.cpp \
|
||||
messagemanager.cpp \
|
||||
@ -49,11 +46,7 @@ SOURCES += \
|
||||
modemanager.cpp \
|
||||
coreimpl.cpp \
|
||||
plugindialog.cpp \
|
||||
manhattanstyle.cpp \
|
||||
minisplitter.cpp \
|
||||
styleanimator.cpp \
|
||||
rightpane.cpp \
|
||||
sidebar.cpp \
|
||||
mimedatabase.cpp \
|
||||
icore.cpp \
|
||||
dialogs/ioptionspage.cpp \
|
||||
@ -72,9 +65,6 @@ SOURCES += \
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
tabpositionindicator.h \
|
||||
fancyactionbar.h \
|
||||
fancytabwidget.h \
|
||||
generalsettings.h \
|
||||
uniqueidmanager.h \
|
||||
messagemanager.h \
|
||||
@ -112,11 +102,7 @@ HEADERS += \
|
||||
modemanager.h \
|
||||
coreimpl.h \
|
||||
plugindialog.h \
|
||||
manhattanstyle.h \
|
||||
minisplitter.h \
|
||||
styleanimator.h \
|
||||
rightpane.h \
|
||||
sidebar.h \
|
||||
mimedatabase.h \
|
||||
settingsdatabase.h \
|
||||
eventfilteringmainwindow.h \
|
||||
@ -139,8 +125,7 @@ FORMS += \
|
||||
workspacesettings.ui
|
||||
|
||||
RESOURCES += \
|
||||
core.qrc \
|
||||
fancyactionbar.qrc
|
||||
core.qrc
|
||||
|
||||
unix:!macx {
|
||||
images.files = images/librepilot_logo_*.png
|
||||
|
@ -1,182 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancyactionbar.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fancyactionbar.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPainter>
|
||||
#include <QPicture>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QAction>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Internal;
|
||||
|
||||
static const char *const svgIdButtonBase = "ButtonBase";
|
||||
static const char *const svgIdButtonNormalBase = "ButtonNormalBase";
|
||||
static const char *const svgIdButtonNormalOverlay = "ButtonNormalOverlay";
|
||||
static const char *const svgIdButtonPressedBase = "ButtonPressedBase";
|
||||
static const char *const svgIdButtonPressedOverlay = "ButtonPressedOverlay";
|
||||
static const char *const svgIdButtonDisabledOverlay = "ButtonDisabledOverlay";
|
||||
static const char *const svgIdButtonHoverOverlay = "ButtonHoverOverlay";
|
||||
|
||||
static const char *const elementsSvgIds[] = {
|
||||
svgIdButtonBase,
|
||||
svgIdButtonNormalBase,
|
||||
svgIdButtonNormalOverlay,
|
||||
svgIdButtonPressedBase,
|
||||
svgIdButtonPressedOverlay,
|
||||
svgIdButtonDisabledOverlay,
|
||||
svgIdButtonHoverOverlay
|
||||
};
|
||||
|
||||
const QMap<QString, QPicture> &buttonElementsMap()
|
||||
{
|
||||
static QMap<QString, QPicture> result;
|
||||
|
||||
if (result.isEmpty()) {
|
||||
QSvgRenderer renderer(QLatin1String(":/fancyactionbar/images/fancytoolbutton.svg"));
|
||||
for (size_t i = 0; i < sizeof(elementsSvgIds) / sizeof(elementsSvgIds[0]); i++) {
|
||||
QString elementId(elementsSvgIds[i]);
|
||||
QPicture elementPicture;
|
||||
QPainter elementPainter(&elementPicture);
|
||||
renderer.render(&elementPainter, elementId);
|
||||
result.insert(elementId, elementPicture);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
FancyToolButton::FancyToolButton(QWidget *parent)
|
||||
: QToolButton(parent)
|
||||
, m_buttonElements(buttonElementsMap())
|
||||
{
|
||||
setAttribute(Qt::WA_Hover, true);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
void FancyToolButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
QSize sh(sizeHint());
|
||||
double scale = (double)height() / sh.height();
|
||||
if (scale < 1) {
|
||||
p.save();
|
||||
p.scale(1, scale);
|
||||
}
|
||||
p.drawPicture(0, 0, m_buttonElements.value(svgIdButtonBase));
|
||||
p.drawPicture(0, 0, m_buttonElements.value(isDown() ? svgIdButtonPressedBase : svgIdButtonNormalBase));
|
||||
#ifndef Q_WS_MAC // Mac UIs usually don't hover
|
||||
if (underMouse() && isEnabled()) {
|
||||
p.drawPicture(0, 0, m_buttonElements.value(svgIdButtonHoverOverlay));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (scale < 1) {
|
||||
p.restore();
|
||||
}
|
||||
|
||||
if (!icon().isNull()) {
|
||||
icon().paint(&p, rect());
|
||||
} else {
|
||||
const int margin = 4;
|
||||
p.drawText(rect().adjusted(margin, margin, -margin, -margin), Qt::AlignCenter | Qt::TextWordWrap, text());
|
||||
}
|
||||
|
||||
if (scale < 1) {
|
||||
p.scale(1, scale);
|
||||
}
|
||||
|
||||
if (isEnabled()) {
|
||||
p.drawPicture(0, 0, m_buttonElements.value(isDown() ?
|
||||
svgIdButtonPressedOverlay : svgIdButtonNormalOverlay));
|
||||
} else {
|
||||
p.drawPicture(0, 0, m_buttonElements.value(svgIdButtonDisabledOverlay));
|
||||
}
|
||||
}
|
||||
|
||||
void FancyActionBar::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
}
|
||||
|
||||
QSize FancyToolButton::sizeHint() const
|
||||
{
|
||||
return m_buttonElements.value(svgIdButtonBase).boundingRect().size();
|
||||
}
|
||||
|
||||
QSize FancyToolButton::minimumSizeHint() const
|
||||
{
|
||||
return QSize(8, 8);
|
||||
}
|
||||
|
||||
FancyActionBar::FancyActionBar(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_actionsLayout = new QVBoxLayout;
|
||||
|
||||
QHBoxLayout *centeringLayout = new QHBoxLayout;
|
||||
centeringLayout->addStretch();
|
||||
centeringLayout->addLayout(m_actionsLayout);
|
||||
centeringLayout->addStretch();
|
||||
setLayout(centeringLayout);
|
||||
}
|
||||
|
||||
void FancyActionBar::insertAction(int index, QAction *action, QMenu *menu)
|
||||
{
|
||||
FancyToolButton *toolButton = new FancyToolButton(this);
|
||||
|
||||
toolButton->setDefaultAction(action);
|
||||
if (menu) {
|
||||
toolButton->setMenu(menu);
|
||||
toolButton->setPopupMode(QToolButton::DelayedPopup);
|
||||
|
||||
// execute action also if a context menu item is select
|
||||
connect(toolButton, SIGNAL(triggered(QAction *)),
|
||||
this, SLOT(toolButtonContextMenuActionTriggered(QAction *)),
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
m_actionsLayout->insertWidget(index, toolButton);
|
||||
}
|
||||
|
||||
/*
|
||||
This slot is invoked when a context menu action of a tool button is triggered.
|
||||
In this case we also want to trigger the default action of the button.
|
||||
|
||||
This allows the user e.g. to select and run a specific run configuration with one click.
|
||||
*/
|
||||
void FancyActionBar::toolButtonContextMenuActionTriggered(QAction *action)
|
||||
{
|
||||
if (QToolButton * button = qobject_cast<QToolButton *>(sender())) {
|
||||
if (action != button->defaultAction()) {
|
||||
button->defaultAction()->trigger();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancyactionbar.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @brief
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FANCYACTIONBAR_H
|
||||
#define FANCYACTIONBAR_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QToolButton>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMenu;
|
||||
class QVBoxLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
class FancyToolButton : public QToolButton {
|
||||
public:
|
||||
FancyToolButton(QWidget *parent = 0);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
private:
|
||||
const QMap<QString, QPicture> &m_buttonElements;
|
||||
};
|
||||
|
||||
class FancyActionBar : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyActionBar(QWidget *parent = 0);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void insertAction(int index, QAction *action, QMenu *menu = 0);
|
||||
|
||||
private slots:
|
||||
void toolButtonContextMenuActionTriggered(QAction *);
|
||||
private:
|
||||
QVBoxLayout *m_actionsLayout;
|
||||
};
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // FANCYACTIONBAR_H
|
@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/fancyactionbar">
|
||||
<file>images/fancytoolbutton.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -1,547 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancytabwidget.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QColorDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QStyleFactory>
|
||||
#include <QPainter>
|
||||
#include <QStackedLayout>
|
||||
#include <QStatusBar>
|
||||
#include <QToolTip>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Internal;
|
||||
|
||||
const int FancyTabBar::m_rounding = 22;
|
||||
const int FancyTabBar::m_textPadding = 4;
|
||||
|
||||
void FancyTab::fadeIn()
|
||||
{
|
||||
animator.stop();
|
||||
animator.setDuration(80);
|
||||
animator.setEndValue(40);
|
||||
animator.start();
|
||||
}
|
||||
|
||||
void FancyTab::fadeOut()
|
||||
{
|
||||
animator.stop();
|
||||
animator.setDuration(160);
|
||||
animator.setEndValue(0);
|
||||
animator.start();
|
||||
}
|
||||
|
||||
void FancyTab::setFader(float value)
|
||||
{
|
||||
m_fader = value;
|
||||
tabbar->update();
|
||||
}
|
||||
|
||||
FancyTabBar::FancyTabBar(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_hoverIndex = -1;
|
||||
m_currentIndex = -1;
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
setStyle(QStyleFactory::create(QLatin1String("windows")));
|
||||
setMinimumWidth(qMax(2 * m_rounding, 40));
|
||||
setAttribute(Qt::WA_Hover, true);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setMouseTracking(true); // Needed for hover events
|
||||
m_triggerTimer.setSingleShot(true);
|
||||
|
||||
// We use a zerotimer to keep the sidebar responsive
|
||||
connect(&m_triggerTimer, SIGNAL(timeout()), this, SLOT(emitCurrentIndex()));
|
||||
}
|
||||
|
||||
FancyTabBar::~FancyTabBar()
|
||||
{
|
||||
delete style();
|
||||
}
|
||||
|
||||
QSize FancyTabBar::tabSizeHint(bool minimum) const
|
||||
{
|
||||
QFont boldFont(font());
|
||||
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
QFontMetrics fm(boldFont);
|
||||
int spacing = 8;
|
||||
int width = 60 + spacing + 2;
|
||||
int maxLabelwidth = 0;
|
||||
for (int tab = 0; tab < count(); ++tab) {
|
||||
int width = fm.width(tabText(tab));
|
||||
if (width > maxLabelwidth) {
|
||||
maxLabelwidth = width;
|
||||
}
|
||||
}
|
||||
int iconHeight = minimum ? 0 : 32;
|
||||
return QSize(qMax(width, maxLabelwidth + 4), iconHeight + spacing + fm.height());
|
||||
}
|
||||
|
||||
void FancyTabBar::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (i != currentIndex()) {
|
||||
paintTab(&p, i);
|
||||
}
|
||||
}
|
||||
|
||||
// paint active tab last, since it overlaps the neighbors
|
||||
if (currentIndex() != -1) {
|
||||
paintTab(&p, currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
// Handle hover events for mouse fade ins
|
||||
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
int newHover = -1;
|
||||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
QRect area = tabRect(i);
|
||||
if (area.contains(e->pos())) {
|
||||
newHover = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newHover == m_hoverIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (validIndex(m_hoverIndex)) {
|
||||
m_tabs[m_hoverIndex]->fadeOut();
|
||||
}
|
||||
|
||||
m_hoverIndex = newHover;
|
||||
|
||||
if (validIndex(m_hoverIndex)) {
|
||||
m_tabs[m_hoverIndex]->fadeIn();
|
||||
m_hoverRect = tabRect(m_hoverIndex);
|
||||
}
|
||||
}
|
||||
|
||||
bool FancyTabBar::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ToolTip) {
|
||||
if (validIndex(m_hoverIndex)) {
|
||||
QString tt = tabToolTip(m_hoverIndex);
|
||||
if (!tt.isEmpty()) {
|
||||
QToolTip::showText(static_cast<QHelpEvent *>(event)->globalPos(), tt, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::enterEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
m_hoverRect = QRect();
|
||||
m_hoverIndex = -1;
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::leaveEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
m_hoverIndex = -1;
|
||||
m_hoverRect = QRect();
|
||||
for (int i = 0; i < m_tabs.count(); ++i) {
|
||||
m_tabs[i]->fadeOut();
|
||||
}
|
||||
}
|
||||
|
||||
QSize FancyTabBar::sizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
}
|
||||
|
||||
QSize FancyTabBar::minimumSizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint(true);
|
||||
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
}
|
||||
|
||||
QRect FancyTabBar::tabRect(int index) const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
|
||||
if (sh.height() * m_tabs.count() > height()) {
|
||||
sh.setHeight(height() / m_tabs.count());
|
||||
}
|
||||
|
||||
return QRect(0, index * sh.height(), sh.width(), sh.height());
|
||||
}
|
||||
|
||||
// This keeps the sidebar responsive since
|
||||
// we get a repaint before loading the
|
||||
// mode itself
|
||||
void FancyTabBar::emitCurrentIndex()
|
||||
{
|
||||
emit currentChanged(m_currentIndex);
|
||||
}
|
||||
|
||||
void FancyTabBar::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
e->accept();
|
||||
for (int index = 0; index < m_tabs.count(); ++index) {
|
||||
if (tabRect(index).contains(e->pos())) {
|
||||
if (isTabEnabled(index)) {
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
m_triggerTimer.start(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
{
|
||||
if (!validIndex(tabIndex)) {
|
||||
qWarning("invalid index");
|
||||
return;
|
||||
}
|
||||
painter->save();
|
||||
|
||||
QRect rect = tabRect(tabIndex);
|
||||
bool selected = (tabIndex == m_currentIndex);
|
||||
bool enabled = isTabEnabled(tabIndex);
|
||||
|
||||
if (selected) {
|
||||
// background
|
||||
painter->save();
|
||||
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||
grad.setColorAt(0, QColor(255, 255, 255, 140));
|
||||
grad.setColorAt(1, QColor(255, 255, 255, 210));
|
||||
painter->fillRect(rect.adjusted(0, 0, 0, -1), grad);
|
||||
painter->restore();
|
||||
|
||||
// shadows
|
||||
painter->setPen(QColor(0, 0, 0, 110));
|
||||
painter->drawLine(rect.topLeft() + QPoint(1, -1), rect.topRight() - QPoint(0, 1));
|
||||
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
painter->setPen(QColor(0, 0, 0, 40));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
|
||||
// highlights
|
||||
painter->setPen(QColor(255, 255, 255, 50));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0, 2));
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0, 1));
|
||||
painter->setPen(QColor(255, 255, 255, 40));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
|
||||
painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(0, -1), rect.bottomRight() - QPoint(0, 1));
|
||||
}
|
||||
|
||||
QString tabText(this->tabText(tabIndex));
|
||||
QRect tabTextRect(rect);
|
||||
const bool drawIcon = rect.height() > 36;
|
||||
QRect tabIconRect(tabTextRect);
|
||||
tabTextRect.translate(0, drawIcon ? -2 : 1);
|
||||
QFont boldFont(painter->font());
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
painter->setFont(boldFont);
|
||||
painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
|
||||
const int textFlags = Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap;
|
||||
if (enabled) {
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
|
||||
} else {
|
||||
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
|
||||
}
|
||||
if (!Utils::HostOsInfo::isMacHost() && !selected && enabled) {
|
||||
painter->save();
|
||||
int fader = int(m_tabs[tabIndex]->fader());
|
||||
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||
grad.setColorAt(0, Qt::transparent);
|
||||
grad.setColorAt(0.5, QColor(255, 255, 255, fader));
|
||||
grad.setColorAt(1, Qt::transparent);
|
||||
painter->fillRect(rect, grad);
|
||||
painter->setPen(QPen(grad, 1.0));
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
painter->setOpacity(0.7);
|
||||
}
|
||||
|
||||
if (drawIcon) {
|
||||
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
|
||||
tabIconRect.adjust(0, 4, 0, -textHeight);
|
||||
Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
|
||||
}
|
||||
|
||||
painter->translate(0, -1);
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void FancyTabBar::setCurrentIndex(int index)
|
||||
{
|
||||
if (isTabEnabled(index)) {
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
emit currentChanged(m_currentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabBar::setTabEnabled(int index, bool enable)
|
||||
{
|
||||
Q_ASSERT(index < m_tabs.size());
|
||||
Q_ASSERT(index >= 0);
|
||||
|
||||
if (index < m_tabs.size() && index >= 0) {
|
||||
m_tabs[index]->enabled = enable;
|
||||
update(tabRect(index));
|
||||
}
|
||||
}
|
||||
|
||||
bool FancyTabBar::isTabEnabled(int index) const
|
||||
{
|
||||
Q_ASSERT(index < m_tabs.size());
|
||||
Q_ASSERT(index >= 0);
|
||||
|
||||
if (index < m_tabs.size() && index >= 0) {
|
||||
return m_tabs[index]->enabled;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//////
|
||||
// FancyColorButton
|
||||
//////
|
||||
|
||||
class FancyColorButton : public QWidget {
|
||||
public:
|
||||
FancyColorButton(QWidget *parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
void mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
if (ev->modifiers() & Qt::ShiftModifier) {
|
||||
QColor color = QColorDialog::getColor(Utils::StyleHelper::requestedBaseColor(), m_parent);
|
||||
if (color.isValid()) {
|
||||
Utils::StyleHelper::setBaseColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
};
|
||||
|
||||
//////
|
||||
// FancyTabWidget
|
||||
//////
|
||||
|
||||
FancyTabWidget::FancyTabWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_tabBar = new FancyTabBar(this);
|
||||
|
||||
m_selectionWidget = new QWidget(this);
|
||||
QVBoxLayout *selectionLayout = new QVBoxLayout;
|
||||
selectionLayout->setSpacing(0);
|
||||
selectionLayout->setMargin(0);
|
||||
|
||||
Utils::StyledBar *bar = new Utils::StyledBar;
|
||||
QHBoxLayout *layout = new QHBoxLayout(bar);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(new FancyColorButton(this));
|
||||
selectionLayout->addWidget(bar);
|
||||
|
||||
selectionLayout->addWidget(m_tabBar, 1);
|
||||
m_selectionWidget->setLayout(selectionLayout);
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
|
||||
m_cornerWidgetContainer = new QWidget(this);
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
m_cornerWidgetContainer->setAutoFillBackground(false);
|
||||
|
||||
QVBoxLayout *cornerWidgetLayout = new QVBoxLayout;
|
||||
cornerWidgetLayout->setSpacing(0);
|
||||
cornerWidgetLayout->setMargin(0);
|
||||
cornerWidgetLayout->addStretch();
|
||||
m_cornerWidgetContainer->setLayout(cornerWidgetLayout);
|
||||
|
||||
selectionLayout->addWidget(m_cornerWidgetContainer, 0);
|
||||
|
||||
m_modesStack = new QStackedLayout;
|
||||
m_statusBar = new QStatusBar;
|
||||
m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addLayout(m_modesStack);
|
||||
vlayout->addWidget(m_statusBar);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(1);
|
||||
mainLayout->addWidget(m_selectionWidget);
|
||||
mainLayout->addLayout(vlayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(showWidget(int)));
|
||||
}
|
||||
|
||||
void FancyTabWidget::setSelectionWidgetVisible(bool visible)
|
||||
{
|
||||
m_selectionWidget->setVisible(visible);
|
||||
}
|
||||
|
||||
bool FancyTabWidget::isSelectionWidgetVisible() const
|
||||
{
|
||||
return m_selectionWidget->isVisible();
|
||||
}
|
||||
|
||||
void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label)
|
||||
{
|
||||
m_modesStack->insertWidget(index, tab);
|
||||
m_tabBar->insertTab(index, icon, label);
|
||||
}
|
||||
|
||||
void FancyTabWidget::removeTab(int index)
|
||||
{
|
||||
m_modesStack->removeWidget(m_modesStack->widget(index));
|
||||
m_tabBar->removeTab(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
|
||||
{
|
||||
QPalette pal = m_tabBar->palette();
|
||||
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_tabBar->setPalette(pal);
|
||||
pal = m_cornerWidgetContainer->palette();
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_cornerWidgetContainer->setPalette(pal);
|
||||
}
|
||||
|
||||
void FancyTabWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
if (m_selectionWidget->isVisible()) {
|
||||
QPainter painter(this);
|
||||
|
||||
QRect rect = m_selectionWidget->rect().adjusted(0, 0, 1, 0);
|
||||
rect = style()->visualRect(layoutDirection(), geometry(), rect);
|
||||
Utils::StyleHelper::verticalGradient(&painter, rect, rect);
|
||||
painter.setPen(Utils::StyleHelper::borderColor());
|
||||
painter.drawLine(rect.topRight(), rect.bottomRight());
|
||||
|
||||
QColor light = Utils::StyleHelper::sidebarHighlight();
|
||||
painter.setPen(light);
|
||||
painter.drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabWidget::insertCornerWidget(int pos, QWidget *widget)
|
||||
{
|
||||
QVBoxLayout *layout = static_cast<QVBoxLayout *>(m_cornerWidgetContainer->layout());
|
||||
|
||||
layout->insertWidget(pos, widget);
|
||||
}
|
||||
|
||||
int FancyTabWidget::cornerWidgetCount() const
|
||||
{
|
||||
return m_cornerWidgetContainer->layout()->count();
|
||||
}
|
||||
|
||||
void FancyTabWidget::addCornerWidget(QWidget *widget)
|
||||
{
|
||||
m_cornerWidgetContainer->layout()->addWidget(widget);
|
||||
}
|
||||
|
||||
int FancyTabWidget::currentIndex() const
|
||||
{
|
||||
return m_tabBar->currentIndex();
|
||||
}
|
||||
|
||||
QStatusBar *FancyTabWidget::statusBar() const
|
||||
{
|
||||
return m_statusBar;
|
||||
}
|
||||
|
||||
void FancyTabWidget::setCurrentIndex(int index)
|
||||
{
|
||||
if (m_tabBar->isTabEnabled(index)) {
|
||||
m_tabBar->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabWidget::showWidget(int index)
|
||||
{
|
||||
emit currentAboutToShow(index);
|
||||
|
||||
m_modesStack->setCurrentIndex(index);
|
||||
emit currentChanged(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::setTabToolTip(int index, const QString &toolTip)
|
||||
{
|
||||
m_tabBar->setTabToolTip(index, toolTip);
|
||||
}
|
||||
|
||||
void FancyTabWidget::setTabEnabled(int index, bool enable)
|
||||
{
|
||||
m_tabBar->setTabEnabled(index, enable);
|
||||
}
|
||||
|
||||
bool FancyTabWidget::isTabEnabled(int index) const
|
||||
{
|
||||
return m_tabBar->isTabEnabled(index);
|
||||
}
|
@ -1,208 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file fancytabwidget.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef FANCYTABWIDGET_H
|
||||
#define FANCYTABWIDGET_H
|
||||
|
||||
#include <QIcon>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPainter;
|
||||
class QStackedLayout;
|
||||
class QStatusBar;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
class FancyTab : public QObject {
|
||||
Q_OBJECT Q_PROPERTY(float fader READ fader WRITE setFader)
|
||||
public:
|
||||
FancyTab(QWidget *tabbar) : enabled(false), tabbar(tabbar), m_fader(0)
|
||||
{
|
||||
animator.setPropertyName("fader");
|
||||
animator.setTargetObject(this);
|
||||
}
|
||||
float fader()
|
||||
{
|
||||
return m_fader;
|
||||
}
|
||||
void setFader(float value);
|
||||
|
||||
void fadeIn();
|
||||
void fadeOut();
|
||||
|
||||
QIcon icon;
|
||||
QString text;
|
||||
QString toolTip;
|
||||
bool enabled;
|
||||
|
||||
private:
|
||||
QPropertyAnimation animator;
|
||||
QWidget *tabbar;
|
||||
float m_fader;
|
||||
};
|
||||
|
||||
class FancyTabBar : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabBar(QWidget *parent = 0);
|
||||
~FancyTabBar();
|
||||
|
||||
bool event(QEvent *event);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void paintTab(QPainter *painter, int tabIndex) const;
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
bool validIndex(int index) const
|
||||
{
|
||||
return index >= 0 && index < m_tabs.count();
|
||||
}
|
||||
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
void setTabEnabled(int index, bool enable);
|
||||
bool isTabEnabled(int index) const;
|
||||
|
||||
void insertTab(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
FancyTab *tab = new FancyTab(this);
|
||||
|
||||
tab->icon = icon;
|
||||
tab->text = label;
|
||||
m_tabs.insert(index, tab);
|
||||
updateGeometry();
|
||||
}
|
||||
void setEnabled(int index, bool enabled);
|
||||
void removeTab(int index)
|
||||
{
|
||||
FancyTab *tab = m_tabs.takeAt(index);
|
||||
|
||||
delete tab;
|
||||
updateGeometry();
|
||||
}
|
||||
void setCurrentIndex(int index);
|
||||
int currentIndex() const
|
||||
{
|
||||
return m_currentIndex;
|
||||
}
|
||||
|
||||
void setTabToolTip(int index, QString toolTip)
|
||||
{
|
||||
m_tabs[index]->toolTip = toolTip;
|
||||
}
|
||||
QString tabToolTip(int index) const
|
||||
{
|
||||
return m_tabs.at(index)->toolTip;
|
||||
}
|
||||
|
||||
QIcon tabIcon(int index) const
|
||||
{
|
||||
return m_tabs.at(index)->icon;
|
||||
}
|
||||
QString tabText(int index) const
|
||||
{
|
||||
return m_tabs.at(index)->text;
|
||||
}
|
||||
int count() const
|
||||
{
|
||||
return m_tabs.count();
|
||||
}
|
||||
QRect tabRect(int index) const;
|
||||
|
||||
signals:
|
||||
void currentChanged(int);
|
||||
|
||||
public slots:
|
||||
void emitCurrentIndex();
|
||||
|
||||
private:
|
||||
static const int m_rounding;
|
||||
static const int m_textPadding;
|
||||
QRect m_hoverRect;
|
||||
int m_hoverIndex;
|
||||
int m_currentIndex;
|
||||
QList<FancyTab *> m_tabs;
|
||||
QTimer m_triggerTimer;
|
||||
QSize tabSizeHint(bool minimum = false) const;
|
||||
};
|
||||
|
||||
class FancyTabWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabWidget(QWidget *parent = 0);
|
||||
|
||||
void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
|
||||
void removeTab(int index);
|
||||
void setBackgroundBrush(const QBrush &brush);
|
||||
void addCornerWidget(QWidget *widget);
|
||||
void insertCornerWidget(int pos, QWidget *widget);
|
||||
int cornerWidgetCount() const;
|
||||
void setTabToolTip(int index, const QString &toolTip);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
int currentIndex() const;
|
||||
QStatusBar *statusBar() const;
|
||||
|
||||
void setTabEnabled(int index, bool enable);
|
||||
bool isTabEnabled(int index) const;
|
||||
|
||||
bool isSelectionWidgetVisible() const;
|
||||
|
||||
signals:
|
||||
void currentAboutToShow(int index);
|
||||
void currentChanged(int index);
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(int index);
|
||||
void setSelectionWidgetVisible(bool visible);
|
||||
|
||||
private slots:
|
||||
void showWidget(int index);
|
||||
|
||||
private:
|
||||
FancyTabBar *m_tabBar;
|
||||
QWidget *m_cornerWidgetContainer;
|
||||
QStackedLayout *m_modesStack;
|
||||
QWidget *m_selectionWidget;
|
||||
QStatusBar *m_statusBar;
|
||||
};
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // FANCYTABWIDGET_H
|
@ -1,539 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="64"
|
||||
height="64"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
version="1.0"
|
||||
sodipodi:docname="fancytoolbutton.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
||||
sodipodi:docbase="C:\depot\ide\research\modes\src\plugins\coreplugin\images"
|
||||
style="display:inline">
|
||||
<defs
|
||||
id="defs4">
|
||||
<linearGradient
|
||||
id="linearGradient3213">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0.21969697;"
|
||||
offset="0"
|
||||
id="stop3215" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0.0530303;"
|
||||
offset="1"
|
||||
id="stop3217" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3227">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0.13559322;"
|
||||
offset="0"
|
||||
id="stop3229" />
|
||||
<stop
|
||||
style="stop-color:#3a3a3a;stop-opacity:0.11016949;"
|
||||
offset="1"
|
||||
id="stop3231" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3284">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0.62931037;"
|
||||
offset="0"
|
||||
id="stop3286" />
|
||||
<stop
|
||||
style="stop-color:#a3a3a3;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop3288" />
|
||||
</linearGradient>
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 32 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="64 : 32 : 1"
|
||||
inkscape:persp3d-origin="32 : 21.333333 : 1"
|
||||
id="perspective62" />
|
||||
<linearGradient
|
||||
id="linearGradient3299">
|
||||
<stop
|
||||
id="stop3301"
|
||||
offset="0"
|
||||
style="stop-color:#ffffff;stop-opacity:0.31384614;" />
|
||||
<stop
|
||||
id="stop3303"
|
||||
offset="1"
|
||||
style="stop-color:#ffffff;stop-opacity:0.15686275;" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3293">
|
||||
<stop
|
||||
id="stop3295"
|
||||
offset="0"
|
||||
style="stop-color:#ffffff;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3297"
|
||||
offset="1"
|
||||
style="stop-color:#000000;stop-opacity:0.02157165;" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3218">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0.78431374;"
|
||||
offset="0"
|
||||
id="stop3220" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop3222" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3204">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0;"
|
||||
offset="0"
|
||||
id="stop3206" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:0.25098041;"
|
||||
offset="1"
|
||||
id="stop3208" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3162">
|
||||
<stop
|
||||
style="stop-color:#424242;stop-opacity:0.13793103;"
|
||||
offset="0"
|
||||
id="stop3164" />
|
||||
<stop
|
||||
style="stop-color:#f0f0f0;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop3166" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3204"
|
||||
id="linearGradient3210"
|
||||
x1="32"
|
||||
y1="32"
|
||||
x2="32"
|
||||
y2="61"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3218"
|
||||
id="linearGradient3224"
|
||||
x1="24"
|
||||
y1="1.9999999"
|
||||
x2="24"
|
||||
y2="31.571428"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3162"
|
||||
id="linearGradient3267"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="32"
|
||||
y1="64"
|
||||
x2="32"
|
||||
y2="0" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3218"
|
||||
id="linearGradient3271"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="24"
|
||||
y1="1.9999999"
|
||||
x2="24"
|
||||
y2="31.571428" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3299"
|
||||
id="radialGradient3283"
|
||||
cx="32"
|
||||
cy="32"
|
||||
fx="32"
|
||||
fy="32"
|
||||
r="29"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3213"
|
||||
id="radialGradient2210"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
cx="32"
|
||||
cy="32"
|
||||
fx="32"
|
||||
fy="32"
|
||||
r="29"
|
||||
gradientTransform="matrix(0.962963,0,0,0.9444445,1.1851851,1.7777776)" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3218"
|
||||
id="radialGradient4673"
|
||||
cx="24"
|
||||
cy="-2.0519459"
|
||||
fx="24"
|
||||
fy="-2.0519459"
|
||||
r="18"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.8095239,-6.9383612e-8,5.1646454e-8,1.8333332,-19.428571,1.7619038)" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3218"
|
||||
id="radialGradient4675"
|
||||
cx="24"
|
||||
cy="-0.72727227"
|
||||
fx="24"
|
||||
fy="-0.72727227"
|
||||
r="18"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.8095238,0,0,1.8333332,-19.42857,-1.6666668)" />
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3227"
|
||||
id="radialGradient3233"
|
||||
cx="48.656292"
|
||||
cy="51.519093"
|
||||
fx="48.656292"
|
||||
fy="51.519093"
|
||||
r="29.444443"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#3e5e7e"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
gridtolerance="10000"
|
||||
guidetolerance="10"
|
||||
objecttolerance="10"
|
||||
inkscape:pageopacity="1"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="5.6568542"
|
||||
inkscape:cx="-11.541044"
|
||||
inkscape:cy="27.695432"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="LayerPressed"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1551"
|
||||
inkscape:window-height="972"
|
||||
inkscape:window-x="103"
|
||||
inkscape:window-y="25"
|
||||
showguides="true"
|
||||
inkscape:guide-bbox="true"
|
||||
inkscape:grid-points="true"
|
||||
inkscape:snap-nodes="true"
|
||||
inkscape:snap-global="false"
|
||||
inkscape:snap-intersection-grid-guide="false">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid2388"
|
||||
spacingx="0.5px"
|
||||
spacingy="0.5px"
|
||||
empspacing="4"
|
||||
dotted="false"
|
||||
enabled="true"
|
||||
visible="false" />
|
||||
<sodipodi:guide
|
||||
orientation="1,0"
|
||||
position="32,44.910714"
|
||||
id="guide3214" />
|
||||
<sodipodi:guide
|
||||
orientation="horizontal"
|
||||
position="32.880465,29.521708"
|
||||
id="guide2214" />
|
||||
<inkscape:grid
|
||||
id="GridFromPre046Settings"
|
||||
type="xygrid"
|
||||
originx="0px"
|
||||
originy="0px"
|
||||
spacingx="1px"
|
||||
spacingy="1px"
|
||||
color="#0000ff"
|
||||
empcolor="#0000ff"
|
||||
opacity="0.2"
|
||||
empopacity="0.4"
|
||||
empspacing="1"
|
||||
visible="true"
|
||||
enabled="false" />
|
||||
<sodipodi:guide
|
||||
orientation="0,1"
|
||||
position="45.749998,96.999996"
|
||||
id="guide4677" />
|
||||
<sodipodi:guide
|
||||
orientation="1,0"
|
||||
position="69.999997,64.124997"
|
||||
id="guide4679" />
|
||||
<sodipodi:guide
|
||||
orientation="0,1"
|
||||
position="14.437499,62"
|
||||
id="guide4681" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
<dc:date />
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title />
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<dc:rights>
|
||||
<cc:Agent>
|
||||
<dc:title />
|
||||
</cc:Agent>
|
||||
</dc:rights>
|
||||
<dc:publisher>
|
||||
<cc:Agent>
|
||||
<dc:title />
|
||||
</cc:Agent>
|
||||
</dc:publisher>
|
||||
<dc:identifier />
|
||||
<dc:source />
|
||||
<dc:relation />
|
||||
<dc:language />
|
||||
<dc:subject>
|
||||
<rdf:Bag />
|
||||
</dc:subject>
|
||||
<dc:coverage />
|
||||
<dc:description />
|
||||
<dc:contributor>
|
||||
<cc:Agent>
|
||||
<dc:title />
|
||||
</cc:Agent>
|
||||
</dc:contributor>
|
||||
<cc:license
|
||||
rdf:resource="" />
|
||||
</cc:Work>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="LayerBase"
|
||||
inkscape:label="LayerBase"
|
||||
style="display:none">
|
||||
<g
|
||||
style="fill:none;stroke:url(#radialGradient3233);stroke-width:2.17741656;stroke-miterlimit:4;stroke-dasharray:none;display:inline"
|
||||
id="ButtonBase"
|
||||
transform="matrix(0.6792453,0,0,0.6792453,10.26415,10.26415)">
|
||||
<path
|
||||
d="M 61.444443,32 A 29.444443,29.444443 0 1 1 60.441148,24.379217"
|
||||
sodipodi:ry="29.444443"
|
||||
sodipodi:rx="29.444443"
|
||||
sodipodi:cy="32"
|
||||
sodipodi:cx="32"
|
||||
id="path3257"
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#radialGradient3233);stroke-width:2.17741656;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc"
|
||||
sodipodi:start="0"
|
||||
sodipodi:end="6.0213859"
|
||||
sodipodi:open="true" />
|
||||
<path
|
||||
transform="matrix(0.9498207,0,0,0.9498207,1.6057361,1.6057361)"
|
||||
d="M 63,32 A 31,31 0 1 1 1,32 A 31,31 0 1 1 63,32 z"
|
||||
sodipodi:ry="31"
|
||||
sodipodi:rx="31"
|
||||
sodipodi:cy="32"
|
||||
sodipodi:cx="32"
|
||||
id="path3259"
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#radialGradient3233);stroke-width:2.7574501;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
transform="matrix(0.9,0,0,0.9,3.1999999,3.1999999)"
|
||||
d="M 62,32 A 30,30 0 1 1 2,32 A 30,30 0 1 1 62,32 z"
|
||||
sodipodi:ry="30"
|
||||
sodipodi:rx="30"
|
||||
sodipodi:cy="32"
|
||||
sodipodi:cx="32"
|
||||
id="path3281"
|
||||
style="opacity:1;fill:none;fill-opacity:0.62672813;fill-rule:evenodd;stroke:#2b2b2b;stroke-width:1.92861104;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.50228307"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="LayerPressed"
|
||||
inkscape:label="LayerPressed"
|
||||
style="display:inline">
|
||||
<g
|
||||
id="ButtonPressedBase"
|
||||
transform="matrix(0.6792453,0,0,0.6792453,10.26415,10.26415)">
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect4724"
|
||||
width="64"
|
||||
height="64"
|
||||
x="0"
|
||||
y="0" />
|
||||
<path
|
||||
transform="matrix(0.9310345,0,0,0.9310345,2.2068967,2.2068968)"
|
||||
d="M 61,32 A 29,29 0 1 1 3,32 A 29,29 0 1 1 61,32 z"
|
||||
sodipodi:ry="29"
|
||||
sodipodi:rx="29"
|
||||
sodipodi:cy="32"
|
||||
sodipodi:cx="32"
|
||||
id="path3263"
|
||||
style="opacity:1;fill:url(#radialGradient2210);fill-opacity:1.0;fill-rule:evenodd;stroke:none;stroke-width:0.10000000000000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc" />
|
||||
<path
|
||||
transform="matrix(1.4166666,0,0,1.4027778,-1.9999995,3.1944446)"
|
||||
d="M 42,20 A 18,18 0 1 1 6,20 A 18,18 0 1 1 42,20 z"
|
||||
sodipodi:ry="18"
|
||||
sodipodi:rx="18"
|
||||
sodipodi:cy="20"
|
||||
sodipodi:cx="24"
|
||||
id="path3209"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:0;fill-rule:evenodd;stroke:none;stroke-width:0.1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
<g
|
||||
id="ButtonPressedOverlay"
|
||||
transform="matrix(0.6792453,0,0,0.6792453,10.26415,12.739024)"
|
||||
style="opacity:0.56682028">
|
||||
<rect
|
||||
y="0"
|
||||
x="0"
|
||||
height="64"
|
||||
width="64"
|
||||
id="rect3182"
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="opacity:0.47465436999999999;fill:url(#radialGradient4675);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.10000000000000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
|
||||
id="path3226"
|
||||
sodipodi:cx="24"
|
||||
sodipodi:cy="20"
|
||||
sodipodi:rx="18"
|
||||
sodipodi:ry="18"
|
||||
d="M 42,20 A 18,18 0 1 1 6,20 A 18,18 0 1 1 42,20 z"
|
||||
transform="matrix(1.1666668,0,0,1,3.9999975,4.9999993)" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
inkscape:label="LayerNormal"
|
||||
inkscape:groupmode="layer"
|
||||
id="LayerNormal"
|
||||
style="display:none">
|
||||
<g
|
||||
style="display:inline"
|
||||
id="ButtonNormalBase"
|
||||
transform="matrix(0.6792453,0,0,0.7011564,10.26415,10.26415)">
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect4730"
|
||||
width="64"
|
||||
height="64"
|
||||
x="0"
|
||||
y="0"
|
||||
ry="0" />
|
||||
<path
|
||||
transform="matrix(1.4722222,0,0,1.4444445,-3.3333336,2.1111101)"
|
||||
d="M 42,20 A 18,18 0 1 1 6,20 A 18,18 0 1 1 42,20 z"
|
||||
sodipodi:ry="18"
|
||||
sodipodi:rx="18"
|
||||
sodipodi:cy="20"
|
||||
sodipodi:cx="24"
|
||||
id="path4734"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:0.1254902;fill-rule:evenodd;stroke:none;stroke-width:0.1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
<g
|
||||
id="ButtonNormalOverlay"
|
||||
style="display:inline"
|
||||
transform="matrix(0.6792453,0,0,0.6792453,10.528302,9.6981123)">
|
||||
<rect
|
||||
ry="0"
|
||||
y="0"
|
||||
x="0"
|
||||
height="64"
|
||||
width="64"
|
||||
id="rect2202"
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="opacity:1;fill:url(#radialGradient4673);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path3188"
|
||||
sodipodi:cx="24"
|
||||
sodipodi:cy="20"
|
||||
sodipodi:rx="18"
|
||||
sodipodi:ry="18"
|
||||
d="M 42,20 A 18,18 0 1 1 6,20 A 18,18 0 1 1 42,20 z"
|
||||
transform="matrix(1.1666667,0,0,1.0000001,3.9999997,3.9999987)" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="LayerDisabled"
|
||||
inkscape:label="LayerDisabled"
|
||||
style="display:none">
|
||||
<g
|
||||
id="ButtonDisabledOverlay"
|
||||
transform="matrix(0.6792453,0,0,0.6792453,10.26415,10.26415)">
|
||||
<rect
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect2247"
|
||||
width="64"
|
||||
height="64"
|
||||
x="0"
|
||||
y="0"
|
||||
ry="0" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="opacity:1;fill:#808080;fill-opacity:0.17351595;fill-rule:evenodd;stroke:none;stroke-width:0.1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path2250"
|
||||
sodipodi:cx="32"
|
||||
sodipodi:cy="32"
|
||||
sodipodi:rx="30"
|
||||
sodipodi:ry="30"
|
||||
d="M 62,32 A 30,30 0 1 1 2,32 A 30,30 0 1 1 62,32 z"
|
||||
transform="matrix(0.9,0,0,0.9,3.2,3.2)" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="LayerButtonHover"
|
||||
inkscape:label="LayerButtonHover"
|
||||
style="display:none">
|
||||
<g
|
||||
id="ButtonHoverOverlay"
|
||||
transform="matrix(0.6792453,0,0,0.6792453,10.26415,10.26415)">
|
||||
<rect
|
||||
ry="0"
|
||||
y="0"
|
||||
x="0"
|
||||
height="64"
|
||||
width="64"
|
||||
id="rect2209"
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
transform="matrix(0.9,0,0,0.9,3.2,3.2)"
|
||||
d="M 62,32 A 30,30 0 1 1 2,32 A 30,30 0 1 1 62,32 z"
|
||||
sodipodi:ry="30"
|
||||
sodipodi:rx="30"
|
||||
sodipodi:cy="32"
|
||||
sodipodi:cx="32"
|
||||
id="path2211"
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:0.04020099;fill-rule:evenodd;stroke:none;stroke-width:0.1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 17 KiB |
@ -54,7 +54,6 @@
|
||||
|
||||
#include <qstylefactory.h>
|
||||
|
||||
#include "rightpane.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "threadmanager.h"
|
||||
#include "uniqueidmanager.h"
|
||||
|
@ -57,7 +57,6 @@ class ConnectionManager;
|
||||
class MessageManager;
|
||||
class MimeDatabase;
|
||||
class ModeManager;
|
||||
class RightPaneWidget;
|
||||
class SettingsDatabase;
|
||||
class UniqueIDManager;
|
||||
class VariableManager;
|
||||
@ -70,7 +69,6 @@ class UAVGadgetInstanceManager;
|
||||
namespace Internal {
|
||||
class ActionManagerPrivate;
|
||||
class CoreImpl;
|
||||
class FancyTabWidget;
|
||||
class GeneralSettings;
|
||||
class ShortcutSettings;
|
||||
class WorkspaceSettings;
|
||||
|
@ -1,1038 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file manhattanstyle.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "manhattanstyle.h"
|
||||
|
||||
#include "styleanimator.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
#include <utils/fancymainwindow.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QDockWidget>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMenuBar>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QStatusBar>
|
||||
#include <QStyleFactory>
|
||||
#include <QStyleOption>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
|
||||
// We define a currently unused state for indicating animations
|
||||
const QStyle::State State_Animating = QStyle::State(0x00000040);
|
||||
|
||||
// Because designer needs to disable this for widget previews
|
||||
// we have a custom property that is inherited
|
||||
bool styleEnabled(const QWidget *widget)
|
||||
{
|
||||
const QWidget *p = widget;
|
||||
|
||||
while (p) {
|
||||
if (p->property("_q_custom_style_disabled").toBool()) {
|
||||
return false;
|
||||
}
|
||||
p = p->parentWidget();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Consider making this a QStyle state
|
||||
bool panelWidget(const QWidget *widget)
|
||||
{
|
||||
if (!widget) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do not style dialogs or explicitly ignored widgets
|
||||
if ((widget->window()->windowFlags() & Qt::WindowType_Mask) == Qt::Dialog) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (qobject_cast<const Utils::FancyMainWindow *>(widget)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (qobject_cast<const QTabBar *>(widget)) {
|
||||
return styleEnabled(widget);
|
||||
}
|
||||
|
||||
const QWidget *p = widget;
|
||||
while (p) {
|
||||
if (qobject_cast<const QToolBar *>(p) ||
|
||||
qobject_cast<const QStatusBar *>(p) ||
|
||||
qobject_cast<const QMenuBar *>(p) ||
|
||||
p->property("panelwidget").toBool()) {
|
||||
return styleEnabled(widget);
|
||||
}
|
||||
p = p->parentWidget();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Consider making this a QStyle state
|
||||
bool lightColored(const QWidget *widget)
|
||||
{
|
||||
if (!widget) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't style dialogs or explicitly ignored widgets
|
||||
if ((widget->window()->windowFlags() & Qt::WindowType_Mask) == Qt::Dialog) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const QWidget *p = widget;
|
||||
while (p) {
|
||||
if (p->property("lightColored").toBool()) {
|
||||
return true;
|
||||
}
|
||||
p = p->parentWidget();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class ManhattanStylePrivate {
|
||||
public:
|
||||
explicit ManhattanStylePrivate();
|
||||
void init();
|
||||
|
||||
public:
|
||||
const QImage lineeditImage;
|
||||
const QImage lineeditImage_disabled;
|
||||
const QPixmap extButtonPixmap;
|
||||
const QPixmap closeButtonPixmap;
|
||||
StyleAnimator animator;
|
||||
};
|
||||
|
||||
ManhattanStylePrivate::ManhattanStylePrivate() :
|
||||
lineeditImage(QLatin1String(":/core/images/inputfield.png")),
|
||||
lineeditImage_disabled(QLatin1String(":/core/images/inputfield_disabled.png")),
|
||||
extButtonPixmap(QLatin1String(":/core/images/extension.png")),
|
||||
closeButtonPixmap(QLatin1String(Core::Constants::ICON_CLOSE))
|
||||
{}
|
||||
|
||||
ManhattanStyle::ManhattanStyle(const QString &baseStyleName)
|
||||
: QProxyStyle(QStyleFactory::create(baseStyleName)),
|
||||
d(new ManhattanStylePrivate())
|
||||
{}
|
||||
|
||||
ManhattanStyle::~ManhattanStyle()
|
||||
{
|
||||
delete d;
|
||||
d = 0;
|
||||
}
|
||||
|
||||
QPixmap ManhattanStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
|
||||
{
|
||||
return QProxyStyle::generatedIconPixmap(iconMode, pixmap, opt);
|
||||
}
|
||||
|
||||
QSize ManhattanStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
|
||||
const QSize &size, const QWidget *widget) const
|
||||
{
|
||||
QSize newSize = QProxyStyle::sizeFromContents(type, option, size, widget);
|
||||
|
||||
if (type == CT_Splitter && widget && widget->property("minisplitter").toBool()) {
|
||||
return QSize(1, 1);
|
||||
} else if (type == CT_ComboBox && panelWidget(widget)) {
|
||||
newSize += QSize(14, 0);
|
||||
}
|
||||
return newSize;
|
||||
}
|
||||
|
||||
QRect ManhattanStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
|
||||
{
|
||||
return QProxyStyle::subElementRect(element, option, widget);
|
||||
}
|
||||
|
||||
QRect ManhattanStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
|
||||
SubControl subControl, const QWidget *widget) const
|
||||
{
|
||||
return QProxyStyle::subControlRect(control, option, subControl, widget);
|
||||
}
|
||||
|
||||
QStyle::SubControl ManhattanStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
||||
const QPoint &pos, const QWidget *widget) const
|
||||
{
|
||||
return QProxyStyle::hitTestComplexControl(control, option, pos, widget);
|
||||
}
|
||||
|
||||
int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
retval = QProxyStyle::pixelMetric(metric, option, widget);
|
||||
switch (metric) {
|
||||
case PM_SplitterWidth:
|
||||
if (widget && widget->property("minisplitter").toBool()) {
|
||||
retval = 1;
|
||||
}
|
||||
break;
|
||||
case PM_ToolBarIconSize:
|
||||
if (panelWidget(widget)) {
|
||||
retval = 16;
|
||||
}
|
||||
break;
|
||||
case PM_DockWidgetHandleExtent:
|
||||
case PM_DockWidgetSeparatorExtent:
|
||||
return 1;
|
||||
|
||||
case PM_MenuPanelWidth:
|
||||
case PM_MenuBarHMargin:
|
||||
case PM_MenuBarVMargin:
|
||||
case PM_ToolBarFrameWidth:
|
||||
if (panelWidget(widget)) {
|
||||
retval = 1;
|
||||
}
|
||||
break;
|
||||
case PM_ButtonShiftVertical:
|
||||
case PM_ButtonShiftHorizontal:
|
||||
case PM_MenuBarPanelWidth:
|
||||
case PM_ToolBarItemMargin:
|
||||
case PM_ToolBarItemSpacing:
|
||||
if (panelWidget(widget)) {
|
||||
retval = 0;
|
||||
}
|
||||
break;
|
||||
case PM_DefaultFrameWidth:
|
||||
if (qobject_cast<const QLineEdit *>(widget) && panelWidget(widget)) {
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
QPalette ManhattanStyle::standardPalette() const
|
||||
{
|
||||
return QProxyStyle::standardPalette();
|
||||
}
|
||||
|
||||
void ManhattanStyle::polish(QApplication *app)
|
||||
{
|
||||
return QProxyStyle::polish(app);
|
||||
}
|
||||
|
||||
void ManhattanStyle::unpolish(QApplication *app)
|
||||
{
|
||||
return QProxyStyle::unpolish(app);
|
||||
}
|
||||
|
||||
QPalette panelPalette(const QPalette &oldPalette, bool lightColored = false)
|
||||
{
|
||||
QColor color = Utils::StyleHelper::panelTextColor(lightColored);
|
||||
QPalette pal = oldPalette;
|
||||
|
||||
pal.setBrush(QPalette::All, QPalette::WindowText, color);
|
||||
pal.setBrush(QPalette::All, QPalette::ButtonText, color);
|
||||
pal.setBrush(QPalette::All, QPalette::Foreground, color);
|
||||
color.setAlpha(100);
|
||||
pal.setBrush(QPalette::Disabled, QPalette::WindowText, color);
|
||||
pal.setBrush(QPalette::Disabled, QPalette::ButtonText, color);
|
||||
pal.setBrush(QPalette::Disabled, QPalette::Foreground, color);
|
||||
return pal;
|
||||
}
|
||||
|
||||
void ManhattanStyle::polish(QWidget *widget)
|
||||
{
|
||||
QProxyStyle::polish(widget);
|
||||
|
||||
// OxygenStyle forces a rounded widget mask on toolbars and dock widgets
|
||||
if (baseStyle()->inherits("OxygenStyle") || baseStyle()->inherits("Oxygen::Style")) {
|
||||
if (qobject_cast<QToolBar *>(widget) || qobject_cast<QDockWidget *>(widget)) {
|
||||
widget->removeEventFilter(baseStyle());
|
||||
widget->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
if (panelWidget(widget)) {
|
||||
// Oxygen and possibly other styles override this
|
||||
if (qobject_cast<QDockWidget *>(widget)) {
|
||||
widget->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
|
||||
if (qobject_cast<QToolButton *>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
||||
} else if (qobject_cast<QLineEdit *>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
||||
} else if (qobject_cast<QLabel *>(widget)) {
|
||||
widget->setPalette(panelPalette(widget->palette()));
|
||||
} else if (widget->property("panelwidget_singlerow").toBool()) {
|
||||
widget->setFixedHeight(Utils::StyleHelper::navigationWidgetHeight());
|
||||
} else if (qobject_cast<QStatusBar *>(widget)) {
|
||||
widget->setFixedHeight(Utils::StyleHelper::navigationWidgetHeight() + 2);
|
||||
} else if (qobject_cast<QComboBox *>(widget)) {
|
||||
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ManhattanStyle::unpolish(QWidget *widget)
|
||||
{
|
||||
QProxyStyle::unpolish(widget);
|
||||
|
||||
if (panelWidget(widget)) {
|
||||
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, false);
|
||||
if (qobject_cast<QTabBar *>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
} else if (qobject_cast<QToolBar *>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
} else if (qobject_cast<QComboBox *>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ManhattanStyle::polish(QPalette &pal)
|
||||
{
|
||||
QProxyStyle::polish(pal);
|
||||
}
|
||||
|
||||
QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
|
||||
{
|
||||
QIcon icon;
|
||||
|
||||
switch (standardIcon) {
|
||||
case QStyle::SP_TitleBarCloseButton:
|
||||
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
||||
return QIcon(standardPixmap(standardIcon, option, widget));
|
||||
|
||||
default:
|
||||
icon = baseStyle()->standardIcon(standardIcon, option, widget);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
|
||||
const QWidget *widget) const
|
||||
{
|
||||
if (widget && !panelWidget(widget)) {
|
||||
return QProxyStyle::standardPixmap(standardPixmap, opt, widget);
|
||||
}
|
||||
|
||||
QPixmap pixmap;
|
||||
switch (standardPixmap) {
|
||||
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
||||
pixmap = d->extButtonPixmap;
|
||||
break;
|
||||
case QStyle::SP_TitleBarCloseButton:
|
||||
pixmap = d->closeButtonPixmap;
|
||||
break;
|
||||
default:
|
||||
pixmap = QProxyStyle::standardPixmap(standardPixmap, opt, widget);
|
||||
break;
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
|
||||
QStyleHintReturn *returnData) const
|
||||
{
|
||||
int ret = QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||
|
||||
switch (hint) {
|
||||
// Make project explorer alternate rows all the way
|
||||
case QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea:
|
||||
if (widget && widget->property("AlternateEmpty").toBool()) {
|
||||
ret = true;
|
||||
}
|
||||
break;
|
||||
case QStyle::SH_EtchDisabledText:
|
||||
if (panelWidget(widget)) {
|
||||
ret = false;
|
||||
}
|
||||
break;
|
||||
case QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren:
|
||||
ret = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
|
||||
QPainter *painter, const QWidget *widget) const
|
||||
{
|
||||
if (!panelWidget(widget)) {
|
||||
return QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||
}
|
||||
|
||||
bool animating = (option->state & State_Animating);
|
||||
int state = option->state;
|
||||
QRect rect = option->rect;
|
||||
QRect oldRect;
|
||||
QRect newRect;
|
||||
if (widget && (element == PE_PanelButtonTool) && !animating) {
|
||||
QWidget *w = const_cast<QWidget *> (widget);
|
||||
int oldState = w->property("_q_stylestate").toInt();
|
||||
oldRect = w->property("_q_stylerect").toRect();
|
||||
newRect = w->rect();
|
||||
w->setProperty("_q_stylestate", (int)option->state);
|
||||
w->setProperty("_q_stylerect", w->rect());
|
||||
|
||||
// Determine the animated transition
|
||||
bool doTransition = ((state & State_On) != (oldState & State_On) ||
|
||||
(state & State_MouseOver) != (oldState & State_MouseOver));
|
||||
if (oldRect != newRect) {
|
||||
doTransition = false;
|
||||
d->animator.stopAnimation(widget);
|
||||
}
|
||||
|
||||
if (doTransition) {
|
||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
Animation *anim = d->animator.widgetAnimation(widget);
|
||||
QStyleOption opt = *option;
|
||||
opt.state = (QStyle::State)oldState;
|
||||
opt.state |= State_Animating;
|
||||
startImage.fill(0);
|
||||
Transition *t = new Transition;
|
||||
t->setWidget(w);
|
||||
QPainter startPainter(&startImage);
|
||||
if (!anim) {
|
||||
drawPrimitive(element, &opt, &startPainter, widget);
|
||||
} else {
|
||||
anim->paint(&startPainter, &opt);
|
||||
d->animator.stopAnimation(widget);
|
||||
}
|
||||
QStyleOption endOpt = *option;
|
||||
endOpt.state |= State_Animating;
|
||||
t->setStartImage(startImage);
|
||||
d->animator.startAnimation(t);
|
||||
endImage.fill(0);
|
||||
QPainter endPainter(&endImage);
|
||||
drawPrimitive(element, &endOpt, &endPainter, widget);
|
||||
t->setEndImage(endImage);
|
||||
if (oldState & State_MouseOver) {
|
||||
t->setDuration(150);
|
||||
} else {
|
||||
t->setDuration(75);
|
||||
}
|
||||
t->setStartTime(QTime::currentTime());
|
||||
}
|
||||
}
|
||||
|
||||
switch (element) {
|
||||
case PE_IndicatorDockWidgetResizeHandle:
|
||||
painter->fillRect(option->rect, Utils::StyleHelper::borderColor());
|
||||
break;
|
||||
case PE_FrameDockWidget:
|
||||
QCommonStyle::drawPrimitive(element, option, painter, widget);
|
||||
break;
|
||||
case PE_PanelLineEdit:
|
||||
{
|
||||
painter->save();
|
||||
|
||||
// Fill the line edit background
|
||||
QRect filledRect = option->rect.adjusted(1, 1, -1, -1);
|
||||
painter->setBrushOrigin(filledRect.topLeft());
|
||||
painter->fillRect(filledRect, option->palette.base());
|
||||
|
||||
if (option->state & State_Enabled) {
|
||||
Utils::StyleHelper::drawCornerImage(d->lineeditImage, painter, option->rect, 5, 5, 5, 5);
|
||||
} else {
|
||||
Utils::StyleHelper::drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 5, 5, 5, 5);
|
||||
}
|
||||
|
||||
if (option->state & State_HasFocus || option->state & State_MouseOver) {
|
||||
QColor hover = Utils::StyleHelper::baseColor();
|
||||
if (state & State_HasFocus) {
|
||||
hover.setAlpha(100);
|
||||
} else {
|
||||
hover.setAlpha(50);
|
||||
}
|
||||
|
||||
painter->setPen(QPen(hover, 1));
|
||||
painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
case PE_FrameStatusBarItem:
|
||||
break;
|
||||
|
||||
case PE_PanelButtonTool:
|
||||
{
|
||||
Animation *anim = d->animator.widgetAnimation(widget);
|
||||
if (!animating && anim) {
|
||||
anim->paint(painter, option);
|
||||
} else {
|
||||
bool pressed = option->state & State_Sunken || option->state & State_On;
|
||||
QColor shadow(0, 0, 0, 30);
|
||||
painter->setPen(shadow);
|
||||
if (pressed) {
|
||||
QColor shade(0, 0, 0, 40);
|
||||
painter->fillRect(rect, shade);
|
||||
painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
// painter->drawLine(rect.bottomLeft() + QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
|
||||
QColor highlight(255, 255, 255, 30);
|
||||
painter->setPen(highlight);
|
||||
} else if (option->state & State_Enabled &&
|
||||
option->state & State_MouseOver) {
|
||||
QColor lighter(255, 255, 255, 37);
|
||||
painter->fillRect(rect, lighter);
|
||||
}
|
||||
if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) {
|
||||
QColor highlight = option->palette.highlight().color();
|
||||
highlight.setAlphaF(0.4);
|
||||
painter->setPen(QPen(highlight.lighter(), 1));
|
||||
highlight.setAlphaF(0.3);
|
||||
painter->setBrush(highlight);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
QRectF rect = option->rect;
|
||||
rect.translate(0.5, 0.5);
|
||||
painter->drawRoundedRect(rect.adjusted(2, 2, -3, -3), 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PE_PanelStatusBar:
|
||||
{
|
||||
painter->save();
|
||||
QLinearGradient grad = Utils::StyleHelper::statusBarGradient(rect);
|
||||
painter->fillRect(rect, grad);
|
||||
painter->setPen(QColor(255, 255, 255, 60));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, 1),
|
||||
rect.topRight() + QPoint(0, 1));
|
||||
painter->setPen(Utils::StyleHelper::borderColor().darker(110));
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
case PE_IndicatorToolBarSeparator:
|
||||
{
|
||||
QColor separatorColor = Utils::StyleHelper::borderColor();
|
||||
separatorColor.setAlpha(100);
|
||||
painter->setPen(separatorColor);
|
||||
const int margin = 6;
|
||||
if (option->state & State_Horizontal) {
|
||||
const int offset = rect.width() / 2;
|
||||
painter->drawLine(rect.bottomLeft().x() + offset,
|
||||
rect.bottomLeft().y() - margin,
|
||||
rect.topLeft().x() + offset,
|
||||
rect.topLeft().y() + margin);
|
||||
} else { // Draw vertical separator
|
||||
const int offset = rect.height() / 2;
|
||||
painter->setPen(QPen(option->palette.background().color().darker(110)));
|
||||
painter->drawLine(rect.topLeft().x() + margin,
|
||||
rect.topLeft().y() + offset,
|
||||
rect.topRight().x() - margin,
|
||||
rect.topRight().y() + offset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PE_IndicatorToolBarHandle:
|
||||
{
|
||||
bool horizontal = option->state & State_Horizontal;
|
||||
painter->save();
|
||||
QPainterPath path;
|
||||
int x = option->rect.x() + (horizontal ? 2 : 6);
|
||||
int y = option->rect.y() + (horizontal ? 6 : 2);
|
||||
static const int RectHeight = 2;
|
||||
if (horizontal) {
|
||||
while (y < option->rect.height() - RectHeight - 6) {
|
||||
path.moveTo(x, y);
|
||||
path.addRect(x, y, RectHeight, RectHeight);
|
||||
y += 6;
|
||||
}
|
||||
} else {
|
||||
while (x < option->rect.width() - RectHeight - 6) {
|
||||
path.moveTo(x, y);
|
||||
path.addRect(x, y, RectHeight, RectHeight);
|
||||
x += 6;
|
||||
}
|
||||
}
|
||||
|
||||
painter->setPen(Qt::NoPen);
|
||||
QColor dark = Utils::StyleHelper::borderColor();
|
||||
dark.setAlphaF(0.4);
|
||||
|
||||
QColor light = Utils::StyleHelper::baseColor();
|
||||
light.setAlphaF(0.4);
|
||||
|
||||
painter->fillPath(path, light);
|
||||
painter->save();
|
||||
painter->translate(1, 1);
|
||||
painter->fillPath(path, dark);
|
||||
painter->restore();
|
||||
painter->translate(3, 3);
|
||||
painter->fillPath(path, light);
|
||||
painter->translate(1, 1);
|
||||
painter->fillPath(path, dark);
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
case PE_IndicatorArrowUp:
|
||||
case PE_IndicatorArrowDown:
|
||||
case PE_IndicatorArrowRight:
|
||||
case PE_IndicatorArrowLeft:
|
||||
{
|
||||
Utils::StyleHelper::drawArrow(element, painter, option);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option,
|
||||
QPainter *painter, const QWidget *widget) const
|
||||
{
|
||||
if (!panelWidget(widget)) {
|
||||
return QProxyStyle::drawControl(element, option, painter, widget);
|
||||
}
|
||||
|
||||
switch (element) {
|
||||
case CE_Splitter:
|
||||
painter->fillRect(option->rect, Utils::StyleHelper::borderColor());
|
||||
break;
|
||||
|
||||
case CE_TabBarTabShape:
|
||||
// Most styles draw a single dark outline. This looks rather ugly when combined with our
|
||||
// single pixel dark separator so we adjust the first tab to compensate for this
|
||||
|
||||
if (const QStyleOptionTabV3 * tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) {
|
||||
QStyleOptionTabV3 adjustedTab = *tab;
|
||||
if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && (
|
||||
tab->position == QStyleOptionTab::Beginning ||
|
||||
tab->position == QStyleOptionTab::OnlyOneTab)) {
|
||||
if (option->direction == Qt::LeftToRight) {
|
||||
adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0);
|
||||
} else {
|
||||
adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1, 0);
|
||||
}
|
||||
}
|
||||
QProxyStyle::drawControl(element, &adjustedTab, painter, widget);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_MenuBarItem:
|
||||
painter->save();
|
||||
if (const QStyleOptionMenuItem * mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
||||
QColor highlightOutline = Utils::StyleHelper::borderColor().lighter(120);
|
||||
bool act = mbi->state & State_Sunken;
|
||||
bool dis = !(mbi->state & State_Enabled);
|
||||
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
||||
QStyleOptionMenuItem item = *mbi;
|
||||
item.rect = mbi->rect;
|
||||
QPalette pal = mbi->palette;
|
||||
pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black);
|
||||
item.palette = pal;
|
||||
QCommonStyle::drawControl(element, &item, painter, widget);
|
||||
QRect r = option->rect;
|
||||
|
||||
if (act) {
|
||||
// Fill|
|
||||
QColor baseColor = Utils::StyleHelper::baseColor();
|
||||
QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft());
|
||||
grad.setColorAt(0, baseColor.lighter(120));
|
||||
grad.setColorAt(1, baseColor.lighter(130));
|
||||
painter->fillRect(option->rect.adjusted(1, 1, -1, 0), grad);
|
||||
|
||||
// Outline
|
||||
painter->setPen(QPen(highlightOutline, 0));
|
||||
painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom()));
|
||||
painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom()));
|
||||
painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()));
|
||||
highlightOutline.setAlpha(60);
|
||||
painter->setPen(QPen(highlightOutline, 0));
|
||||
painter->drawPoint(r.topLeft());
|
||||
painter->drawPoint(r.topRight());
|
||||
|
||||
QPalette pal = mbi->palette;
|
||||
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
||||
if (!styleHint(SH_UnderlineShortcut, mbi, widget)) {
|
||||
alignment |= Qt::TextHideMnemonic;
|
||||
}
|
||||
pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60));
|
||||
drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
|
||||
pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white);
|
||||
drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
break;
|
||||
|
||||
case CE_ComboBoxLabel:
|
||||
if (const QStyleOptionComboBox * cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||
if (panelWidget(widget)) {
|
||||
painter->save();
|
||||
QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
|
||||
QPalette customPal = cb->palette;
|
||||
bool drawIcon = !(widget && widget->property("hideicon").toBool());
|
||||
|
||||
if (!cb->currentIcon.isNull() && drawIcon) {
|
||||
QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
|
||||
: QIcon::Disabled;
|
||||
QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
|
||||
QRect iconRect(editRect);
|
||||
iconRect.setWidth(cb->iconSize.width() + 4);
|
||||
iconRect = alignedRect(cb->direction,
|
||||
Qt::AlignLeft | Qt::AlignVCenter,
|
||||
iconRect.size(), editRect);
|
||||
if (cb->editable) {
|
||||
painter->fillRect(iconRect, customPal.brush(QPalette::Base));
|
||||
}
|
||||
drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
|
||||
|
||||
if (cb->direction == Qt::RightToLeft) {
|
||||
editRect.translate(-4 - cb->iconSize.width(), 0);
|
||||
} else {
|
||||
editRect.translate(cb->iconSize.width() + 4, 0);
|
||||
}
|
||||
|
||||
// Reserve some space for the down-arrow
|
||||
editRect.adjust(0, 0, -13, 0);
|
||||
}
|
||||
|
||||
QLatin1Char asterisk('*');
|
||||
int elideWidth = editRect.width();
|
||||
|
||||
bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool()
|
||||
&& cb->currentText.endsWith(asterisk)
|
||||
&& option->fontMetrics.width(cb->currentText) > elideWidth;
|
||||
|
||||
QString text;
|
||||
if (notElideAsterisk) {
|
||||
elideWidth -= option->fontMetrics.width(asterisk);
|
||||
text = asterisk;
|
||||
}
|
||||
text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth));
|
||||
|
||||
if ((option->state & State_Enabled)) {
|
||||
painter->setPen(QColor(0, 0, 0, 70));
|
||||
painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);
|
||||
} else {
|
||||
painter->setOpacity(0.8);
|
||||
}
|
||||
painter->setPen(Utils::StyleHelper::panelTextColor());
|
||||
painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);
|
||||
|
||||
painter->restore();
|
||||
} else {
|
||||
QProxyStyle::drawControl(element, option, painter, widget);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_SizeGrip:
|
||||
{
|
||||
painter->save();
|
||||
QColor dark = Qt::white;
|
||||
dark.setAlphaF(0.1);
|
||||
int x, y, w, h;
|
||||
option->rect.getRect(&x, &y, &w, &h);
|
||||
int sw = qMin(h, w);
|
||||
if (h > w) {
|
||||
painter->translate(0, h - w);
|
||||
} else {
|
||||
painter->translate(w - h, 0);
|
||||
}
|
||||
int sx = x;
|
||||
int sy = y;
|
||||
int s = 4;
|
||||
painter->setPen(dark);
|
||||
if (option->direction == Qt::RightToLeft) {
|
||||
sx = x + sw;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
painter->drawLine(x, sy, sx, sw);
|
||||
sx -= s;
|
||||
sy += s;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
painter->drawLine(sx, sw, sw, sy);
|
||||
sx += s;
|
||||
sy += s;
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_MenuBarEmptyArea:
|
||||
{
|
||||
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
||||
painter->save();
|
||||
painter->setPen(Utils::StyleHelper::borderColor());
|
||||
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_ToolBar:
|
||||
{
|
||||
QRect rect = option->rect;
|
||||
bool horizontal = option->state & State_Horizontal;
|
||||
rect = option->rect;
|
||||
|
||||
// Map offset for global window gradient
|
||||
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
|
||||
widget->mapToGlobal(option->rect.topLeft());
|
||||
QRect gradientSpan;
|
||||
if (widget) {
|
||||
gradientSpan = QRect(offset, widget->window()->size());
|
||||
}
|
||||
|
||||
bool drawLightColored = lightColored(widget);
|
||||
if (horizontal) {
|
||||
Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||
} else {
|
||||
Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||
}
|
||||
|
||||
if (!drawLightColored) {
|
||||
painter->setPen(Utils::StyleHelper::borderColor());
|
||||
} else {
|
||||
painter->setPen(QColor(0x888888));
|
||||
}
|
||||
|
||||
if (horizontal) {
|
||||
// Note: This is a hack to determine if the
|
||||
// toolbar should draw the top or bottom outline
|
||||
// (needed for the find toolbar for instance)
|
||||
QColor lighter(Utils::StyleHelper::sidebarHighlight());
|
||||
if (drawLightColored) {
|
||||
lighter = QColor(255, 255, 255, 180);
|
||||
}
|
||||
if (widget && widget->property("topBorder").toBool()) {
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
painter->setPen(lighter);
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1));
|
||||
} else {
|
||||
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
painter->setPen(lighter);
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
}
|
||||
} else {
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
QProxyStyle::drawControl(element, option, painter, widget);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
||||
QPainter *painter, const QWidget *widget) const
|
||||
{
|
||||
if (!panelWidget(widget)) {
|
||||
return QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||
}
|
||||
|
||||
QRect rect = option->rect;
|
||||
switch (control) {
|
||||
case CC_ToolButton:
|
||||
if (const QStyleOptionToolButton * toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
|
||||
bool reverse = option->direction == Qt::RightToLeft;
|
||||
bool drawborder = (widget && widget->property("showborder").toBool());
|
||||
|
||||
if (drawborder) {
|
||||
drawButtonSeparator(painter, rect, reverse);
|
||||
}
|
||||
|
||||
QRect button, menuarea;
|
||||
button = subControlRect(control, toolbutton, SC_ToolButton, widget);
|
||||
menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
|
||||
|
||||
State bflags = toolbutton->state;
|
||||
if (bflags & State_AutoRaise) {
|
||||
if (!(bflags & State_MouseOver)) {
|
||||
bflags &= ~State_Raised;
|
||||
}
|
||||
}
|
||||
|
||||
State mflags = bflags;
|
||||
if (toolbutton->state & State_Sunken) {
|
||||
if (toolbutton->activeSubControls & SC_ToolButton) {
|
||||
bflags |= State_Sunken;
|
||||
}
|
||||
if (toolbutton->activeSubControls & SC_ToolButtonMenu) {
|
||||
mflags |= State_Sunken;
|
||||
}
|
||||
}
|
||||
|
||||
QStyleOption tool(0);
|
||||
tool.palette = toolbutton->palette;
|
||||
if (toolbutton->subControls & SC_ToolButton) {
|
||||
tool.rect = button;
|
||||
tool.state = bflags;
|
||||
drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
|
||||
}
|
||||
|
||||
QStyleOptionToolButton label = *toolbutton;
|
||||
|
||||
label.palette = panelPalette(option->palette, lightColored(widget));
|
||||
int fw = pixelMetric(PM_DefaultFrameWidth, option, widget);
|
||||
label.rect = button.adjusted(fw, fw, -fw, -fw);
|
||||
|
||||
drawControl(CE_ToolButtonLabel, &label, painter, widget);
|
||||
|
||||
if (toolbutton->subControls & SC_ToolButtonMenu) {
|
||||
tool.state = mflags;
|
||||
tool.rect = menuarea.adjusted(1, 1, -1, -1);
|
||||
if (mflags & (State_Sunken | State_On | State_Raised)) {
|
||||
painter->setPen(Qt::gray);
|
||||
painter->drawLine(tool.rect.topLeft(), tool.rect.bottomLeft());
|
||||
if (mflags & (State_Sunken)) {
|
||||
QColor shade(0, 0, 0, 50);
|
||||
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
||||
} else if (!Utils::HostOsInfo::isMacHost() && (mflags & State_MouseOver)) {
|
||||
QColor shade(255, 255, 255, 50);
|
||||
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
||||
}
|
||||
}
|
||||
tool.rect = tool.rect.adjusted(2, 2, -2, -2);
|
||||
drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
|
||||
} else if (toolbutton->features & QStyleOptionToolButton::HasMenu
|
||||
&& !widget->property("noArrow").toBool()) {
|
||||
int arrowSize = 6;
|
||||
QRect ir = toolbutton->rect.adjusted(1, 1, -1, -1);
|
||||
QStyleOptionToolButton newBtn = *toolbutton;
|
||||
newBtn.palette = panelPalette(option->palette);
|
||||
newBtn.rect = QRect(ir.right() - arrowSize - 1,
|
||||
ir.height() - arrowSize - 2, arrowSize, arrowSize);
|
||||
drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CC_ComboBox:
|
||||
if (const QStyleOptionComboBox * cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||
painter->save();
|
||||
bool isEmpty = cb->currentText.isEmpty() && cb->currentIcon.isNull();
|
||||
bool reverse = option->direction == Qt::RightToLeft;
|
||||
bool drawborder = !(widget && widget->property("hideborder").toBool());
|
||||
bool alignarrow = !(widget && widget->property("alignarrow").toBool());
|
||||
|
||||
if (drawborder) {
|
||||
drawButtonSeparator(painter, rect, reverse);
|
||||
}
|
||||
|
||||
QStyleOption toolbutton = *option;
|
||||
if (isEmpty) {
|
||||
toolbutton.state &= ~(State_Enabled | State_Sunken);
|
||||
}
|
||||
painter->save();
|
||||
if (drawborder) {
|
||||
painter->setClipRect(toolbutton.rect.adjusted(0, 0, -2, 0));
|
||||
}
|
||||
drawPrimitive(PE_PanelButtonTool, &toolbutton, painter, widget);
|
||||
painter->restore();
|
||||
// Draw arrow
|
||||
int menuButtonWidth = 12;
|
||||
int left = !reverse ? rect.right() - menuButtonWidth : rect.left();
|
||||
int right = !reverse ? rect.right() : rect.left() + menuButtonWidth;
|
||||
QRect arrowRect((left + right) / 2 + (reverse ? 6 : -6), rect.center().y() - 3, 9, 9);
|
||||
|
||||
if (!alignarrow) {
|
||||
int labelwidth = option->fontMetrics.width(cb->currentText);
|
||||
if (reverse) {
|
||||
arrowRect.moveLeft(qMax(rect.width() - labelwidth - menuButtonWidth - 2, 4));
|
||||
} else {
|
||||
arrowRect.moveLeft(qMin(labelwidth + menuButtonWidth - 2, rect.width() - menuButtonWidth - 4));
|
||||
}
|
||||
}
|
||||
if (option->state & State_On) {
|
||||
arrowRect.translate(QProxyStyle::pixelMetric(PM_ButtonShiftHorizontal, option, widget),
|
||||
QProxyStyle::pixelMetric(PM_ButtonShiftVertical, option, widget));
|
||||
}
|
||||
|
||||
QStyleOption arrowOpt = *option;
|
||||
arrowOpt.rect = arrowRect;
|
||||
if (isEmpty) {
|
||||
arrowOpt.state &= ~(State_Enabled | State_Sunken);
|
||||
}
|
||||
|
||||
if (styleHint(SH_ComboBox_Popup, option, widget)) {
|
||||
arrowOpt.rect.translate(0, -3);
|
||||
drawPrimitive(PE_IndicatorArrowUp, &arrowOpt, painter, widget);
|
||||
arrowOpt.rect.translate(0, 6);
|
||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||
} else {
|
||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ManhattanStyle::drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const
|
||||
{
|
||||
QLinearGradient grad(rect.topRight(), rect.bottomRight());
|
||||
|
||||
grad.setColorAt(0, QColor(255, 255, 255, 20));
|
||||
grad.setColorAt(0.4, QColor(255, 255, 255, 60));
|
||||
grad.setColorAt(0.7, QColor(255, 255, 255, 50));
|
||||
grad.setColorAt(1, QColor(255, 255, 255, 40));
|
||||
painter->setPen(QPen(grad, 0));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
grad.setColorAt(0, QColor(0, 0, 0, 30));
|
||||
grad.setColorAt(0.4, QColor(0, 0, 0, 70));
|
||||
grad.setColorAt(0.7, QColor(0, 0, 0, 70));
|
||||
grad.setColorAt(1, QColor(0, 0, 0, 40));
|
||||
painter->setPen(QPen(grad, 0));
|
||||
if (!reverse) {
|
||||
painter->drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
|
||||
} else {
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file manhattanstyle.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef MANHATTANSTYLE_H
|
||||
#define MANHATTANSTYLE_H
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QProxyStyle>
|
||||
|
||||
class ManhattanStylePrivate;
|
||||
|
||||
class CORE_EXPORT ManhattanStyle : public QProxyStyle {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ManhattanStyle(const QString &baseStyleName);
|
||||
|
||||
~ManhattanStyle();
|
||||
|
||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||
|
||||
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
||||
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
|
||||
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const;
|
||||
|
||||
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const;
|
||||
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
|
||||
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
|
||||
QRect itemRect(QPainter *p, const QRect &r, int flags, bool enabled, const QPixmap *pixmap, const QString &text, int len = -1) const;
|
||||
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
|
||||
|
||||
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
|
||||
|
||||
QPalette standardPalette() const;
|
||||
|
||||
void polish(QWidget *widget);
|
||||
void polish(QPalette &pal);
|
||||
void polish(QApplication *app);
|
||||
|
||||
void unpolish(QWidget *widget);
|
||||
void unpolish(QApplication *app);
|
||||
|
||||
protected slots:
|
||||
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
|
||||
|
||||
private:
|
||||
void drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const;
|
||||
|
||||
ManhattanStylePrivate *d;
|
||||
};
|
||||
|
||||
#endif // MANHATTANSTYLE_H
|
@ -28,8 +28,6 @@
|
||||
|
||||
#include "modemanager.h"
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
#include "fancyactionbar.h"
|
||||
#include "utils/mytabwidget.h"
|
||||
#include "icore.h"
|
||||
#include "mainwindow.h"
|
||||
|
@ -48,8 +48,6 @@ class Command;
|
||||
class IMode;
|
||||
|
||||
namespace Internal {
|
||||
class FancyTabWidget;
|
||||
class FancyActionBar;
|
||||
class MainWindow;
|
||||
} // namespace Internal
|
||||
|
||||
|
@ -1,246 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file rightpane.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "rightpane.h"
|
||||
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QSplitter>
|
||||
#include <QResizeEvent>
|
||||
#include <QTextEdit>
|
||||
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
RightPanePlaceHolder *RightPanePlaceHolder::m_current = 0;
|
||||
|
||||
RightPanePlaceHolder *RightPanePlaceHolder::current()
|
||||
{
|
||||
return m_current;
|
||||
}
|
||||
|
||||
RightPanePlaceHolder::RightPanePlaceHolder(Core::IMode *mode, QWidget *parent)
|
||||
: QWidget(parent), m_mode(mode)
|
||||
{
|
||||
setLayout(new QVBoxLayout);
|
||||
layout()->setMargin(0);
|
||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode *)),
|
||||
this, SLOT(currentModeChanged(Core::IMode *)));
|
||||
}
|
||||
|
||||
RightPanePlaceHolder::~RightPanePlaceHolder()
|
||||
{
|
||||
if (m_current == this) {
|
||||
RightPaneWidget::instance()->setParent(0);
|
||||
RightPaneWidget::instance()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void RightPanePlaceHolder::applyStoredSize(int width)
|
||||
{
|
||||
if (width) {
|
||||
QSplitter *splitter = qobject_cast<QSplitter *>(parentWidget());
|
||||
if (splitter) {
|
||||
// A splitter we need to resize the splitter sizes
|
||||
QList<int> sizes = splitter->sizes();
|
||||
int index = splitter->indexOf(this);
|
||||
int diff = width - sizes.at(index);
|
||||
int adjust = sizes.count() > 1 ? (diff / (sizes.count() - 1)) : 0;
|
||||
for (int i = 0; i < sizes.count(); ++i) {
|
||||
if (i != index) {
|
||||
sizes[i] -= adjust;
|
||||
}
|
||||
}
|
||||
sizes[index] = width;
|
||||
splitter->setSizes(sizes);
|
||||
} else {
|
||||
QSize s = size();
|
||||
s.setWidth(width);
|
||||
resize(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This function does work even though the order in which
|
||||
// the placeHolder get the signal is undefined.
|
||||
// It does ensure that after all PlaceHolders got the signal
|
||||
// m_current points to the current PlaceHolder, or zero if there
|
||||
// is no PlaceHolder in this mode
|
||||
// And that the parent of the RightPaneWidget gets the correct parent
|
||||
void RightPanePlaceHolder::currentModeChanged(Core::IMode *mode)
|
||||
{
|
||||
if (m_current == this) {
|
||||
m_current = 0;
|
||||
RightPaneWidget::instance()->setParent(0);
|
||||
RightPaneWidget::instance()->hide();
|
||||
}
|
||||
if (m_mode == mode) {
|
||||
m_current = this;
|
||||
|
||||
int width = RightPaneWidget::instance()->storedWidth();
|
||||
|
||||
layout()->addWidget(RightPaneWidget::instance());
|
||||
RightPaneWidget::instance()->show();
|
||||
|
||||
applyStoredSize(width);
|
||||
setVisible(RightPaneWidget::instance()->isShown());
|
||||
}
|
||||
}
|
||||
|
||||
/////
|
||||
// RightPaneWidget
|
||||
/////
|
||||
|
||||
|
||||
RightPaneWidget *RightPaneWidget::m_instance = 0;
|
||||
|
||||
RightPaneWidget::RightPaneWidget()
|
||||
: m_shown(true), m_width(0)
|
||||
{
|
||||
m_instance = this;
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setMargin(0);
|
||||
setLayout(layout);
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
|
||||
BaseRightPaneWidget *rpw = pm->getObject<BaseRightPaneWidget>();
|
||||
if (rpw) {
|
||||
layout->addWidget(rpw->widget());
|
||||
}
|
||||
connect(pm, SIGNAL(objectAdded(QObject *)),
|
||||
this, SLOT(objectAdded(QObject *)));
|
||||
connect(pm, SIGNAL(aboutToRemoveObject(QObject *)),
|
||||
this, SLOT(aboutToRemoveObject(QObject *)));
|
||||
}
|
||||
|
||||
RightPaneWidget::~RightPaneWidget()
|
||||
{
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
void RightPaneWidget::objectAdded(QObject *obj)
|
||||
{
|
||||
BaseRightPaneWidget *rpw = qobject_cast<BaseRightPaneWidget *>(obj);
|
||||
|
||||
if (rpw) {
|
||||
layout()->addWidget(rpw->widget());
|
||||
setFocusProxy(rpw->widget());
|
||||
}
|
||||
}
|
||||
|
||||
void RightPaneWidget::aboutToRemoveObject(QObject *obj)
|
||||
{
|
||||
BaseRightPaneWidget *rpw = qobject_cast<BaseRightPaneWidget *>(obj);
|
||||
|
||||
if (rpw) {
|
||||
delete rpw->widget();
|
||||
}
|
||||
}
|
||||
|
||||
RightPaneWidget *RightPaneWidget::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
int RightPaneWidget::storedWidth()
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
void RightPaneWidget::resizeEvent(QResizeEvent *re)
|
||||
{
|
||||
if (m_width && re->size().width()) {
|
||||
m_width = re->size().width();
|
||||
}
|
||||
QWidget::resizeEvent(re);
|
||||
}
|
||||
|
||||
void RightPaneWidget::saveSettings(QSettings *settings)
|
||||
{
|
||||
settings->setValue("RightPane/Visible", isShown());
|
||||
settings->setValue("RightPane/Width", m_width);
|
||||
}
|
||||
|
||||
void RightPaneWidget::readSettings(QSettings *settings)
|
||||
{
|
||||
if (settings->contains("RightPane/Visible")) {
|
||||
setShown(settings->value("RightPane/Visible").toBool());
|
||||
} else {
|
||||
setShown(false); // TODO set to false
|
||||
}
|
||||
|
||||
if (settings->contains("RightPane/Width")) {
|
||||
m_width = settings->value("RightPane/Width").toInt();
|
||||
if (!m_width) {
|
||||
m_width = 500;
|
||||
}
|
||||
} else {
|
||||
m_width = 500; // pixel
|
||||
}
|
||||
// Apply
|
||||
if (RightPanePlaceHolder::m_current) {
|
||||
RightPanePlaceHolder::m_current->applyStoredSize(m_width);
|
||||
}
|
||||
}
|
||||
|
||||
void RightPaneWidget::setShown(bool b)
|
||||
{
|
||||
if (RightPanePlaceHolder::m_current) {
|
||||
RightPanePlaceHolder::m_current->setVisible(b);
|
||||
}
|
||||
m_shown = b;
|
||||
}
|
||||
|
||||
bool RightPaneWidget::isShown()
|
||||
{
|
||||
return m_shown;
|
||||
}
|
||||
|
||||
/////
|
||||
// BaseRightPaneWidget
|
||||
/////
|
||||
|
||||
BaseRightPaneWidget::BaseRightPaneWidget(QWidget *widget)
|
||||
{
|
||||
m_widget = widget;
|
||||
}
|
||||
|
||||
BaseRightPaneWidget::~BaseRightPaneWidget()
|
||||
{}
|
||||
|
||||
QWidget *BaseRightPaneWidget::widget() const
|
||||
{
|
||||
return m_widget;
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file rightpane.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef RIGHTPANE_H
|
||||
#define RIGHTPANE_H
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class IMode;
|
||||
class RightPaneWidget;
|
||||
|
||||
// TODO: The right pane works only for the help plugin atm. It can't cope
|
||||
// with more than one plugin publishing objects they want in the right pane
|
||||
// For that the API would need to be different. (Might be that instead of
|
||||
// adding objects to the pool, there should be a method
|
||||
// RightPaneWidget::setWidget(QWidget *w) Anyway if a second plugin wants to
|
||||
// show something there, redesign this API
|
||||
|
||||
class CORE_EXPORT RightPanePlaceHolder : public QWidget {
|
||||
friend class Core::RightPaneWidget;
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RightPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
||||
~RightPanePlaceHolder();
|
||||
static RightPanePlaceHolder *current();
|
||||
|
||||
private slots:
|
||||
void currentModeChanged(Core::IMode *);
|
||||
|
||||
private:
|
||||
void applyStoredSize(int width);
|
||||
Core::IMode *m_mode;
|
||||
static RightPanePlaceHolder *m_current;
|
||||
};
|
||||
|
||||
|
||||
class CORE_EXPORT BaseRightPaneWidget : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BaseRightPaneWidget(QWidget *widget);
|
||||
~BaseRightPaneWidget();
|
||||
QWidget *widget() const;
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
};
|
||||
|
||||
|
||||
class CORE_EXPORT RightPaneWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RightPaneWidget();
|
||||
~RightPaneWidget();
|
||||
|
||||
void saveSettings(QSettings *settings);
|
||||
void readSettings(QSettings *settings);
|
||||
|
||||
bool isShown();
|
||||
void setShown(bool b);
|
||||
|
||||
static RightPaneWidget *instance();
|
||||
|
||||
int storedWidth();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void objectAdded(QObject *obj);
|
||||
void aboutToRemoveObject(QObject *obj);
|
||||
|
||||
private:
|
||||
bool m_shown;
|
||||
int m_width;
|
||||
static RightPaneWidget *m_instance;
|
||||
};
|
||||
} // namespace Core
|
||||
|
||||
#endif // RIGHTPANE_H
|
@ -1,392 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file sidebar.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "sidebar.h"
|
||||
#include "imode.h"
|
||||
#include "modemanager.h"
|
||||
|
||||
#include "actionmanager/actionmanager.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QLayout>
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
#include <QToolButton>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
SideBarItem::~SideBarItem()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
SideBar::SideBar(QList<SideBarItem *> itemList,
|
||||
QList<SideBarItem *> defaultVisible)
|
||||
{
|
||||
setOrientation(Qt::Vertical);
|
||||
foreach(SideBarItem * item, itemList) {
|
||||
const QString title = item->widget()->windowTitle();
|
||||
|
||||
m_itemMap.insert(title, item);
|
||||
}
|
||||
foreach(SideBarItem * item, defaultVisible) {
|
||||
if (!itemList.contains(item)) {
|
||||
continue;
|
||||
}
|
||||
m_defaultVisible.append(item->widget()->windowTitle());
|
||||
}
|
||||
|
||||
m_availableItems = m_itemMap.keys();
|
||||
}
|
||||
|
||||
SideBar::~SideBar()
|
||||
{
|
||||
qDeleteAll(m_itemMap.values());
|
||||
}
|
||||
|
||||
QStringList SideBar::availableItems() const
|
||||
{
|
||||
return m_availableItems;
|
||||
}
|
||||
|
||||
void SideBar::makeItemAvailable(SideBarItem *item)
|
||||
{
|
||||
QMap<QString, SideBarItem *>::const_iterator it = m_itemMap.constBegin();
|
||||
while (it != m_itemMap.constEnd()) {
|
||||
if (it.value() == item) {
|
||||
m_availableItems.append(it.key());
|
||||
qSort(m_availableItems);
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
SideBarItem *SideBar::item(const QString &title)
|
||||
{
|
||||
if (m_itemMap.contains(title)) {
|
||||
m_availableItems.removeAll(title);
|
||||
return m_itemMap.value(title, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SideBarWidget *SideBar::insertSideBarWidget(int position, const QString &title)
|
||||
{
|
||||
SideBarWidget *item = new SideBarWidget(this, title);
|
||||
|
||||
connect(item, SIGNAL(splitMe()), this, SLOT(splitSubWidget()));
|
||||
connect(item, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
||||
connect(item, SIGNAL(currentWidgetChanged()), this, SLOT(updateWidgets()));
|
||||
insertWidget(position, item);
|
||||
m_widgets.insert(position, item);
|
||||
updateWidgets();
|
||||
return item;
|
||||
}
|
||||
|
||||
void SideBar::removeSideBarWidget(SideBarWidget *widget)
|
||||
{
|
||||
widget->removeCurrentItem();
|
||||
m_widgets.removeOne(widget);
|
||||
widget->hide();
|
||||
widget->deleteLater();
|
||||
}
|
||||
|
||||
void SideBar::splitSubWidget()
|
||||
{
|
||||
SideBarWidget *original = qobject_cast<SideBarWidget *>(sender());
|
||||
int pos = indexOf(original) + 1;
|
||||
|
||||
insertSideBarWidget(pos);
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
void SideBar::closeSubWidget()
|
||||
{
|
||||
if (m_widgets.count() != 1) {
|
||||
SideBarWidget *widget = qobject_cast<SideBarWidget *>(sender());
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
removeSideBarWidget(widget);
|
||||
updateWidgets();
|
||||
}
|
||||
}
|
||||
|
||||
void SideBar::updateWidgets()
|
||||
{
|
||||
foreach(SideBarWidget * i, m_widgets)
|
||||
i->updateAvailableItems();
|
||||
}
|
||||
|
||||
void SideBar::saveSettings(QSettings *settings)
|
||||
{
|
||||
QStringList views;
|
||||
|
||||
for (int i = 0; i < m_widgets.count(); ++i) {
|
||||
views.append(m_widgets.at(i)->currentItemTitle());
|
||||
}
|
||||
settings->setValue("HelpSideBar/Views", views);
|
||||
settings->setValue("HelpSideBar/Visible", true); // isVisible());
|
||||
settings->setValue("HelpSideBar/VerticalPosition", saveState());
|
||||
settings->setValue("HelpSideBar/Width", width());
|
||||
}
|
||||
|
||||
void SideBar::readSettings(QSettings *settings)
|
||||
{
|
||||
foreach(SideBarWidget * widget, m_widgets)
|
||||
removeSideBarWidget(widget);
|
||||
|
||||
if (settings->contains("HelpSideBar/Views")) {
|
||||
QStringList views = settings->value("HelpSideBar/Views").toStringList();
|
||||
if (views.count()) {
|
||||
foreach(const QString &title, views)
|
||||
insertSideBarWidget(m_widgets.count(), title);
|
||||
} else {
|
||||
insertSideBarWidget(0);
|
||||
}
|
||||
} else {
|
||||
foreach(const QString &title, m_defaultVisible)
|
||||
insertSideBarWidget(m_widgets.count(), title);
|
||||
}
|
||||
|
||||
if (settings->contains("HelpSideBar/Visible")) {
|
||||
setVisible(settings->value("HelpSideBar/Visible").toBool());
|
||||
}
|
||||
|
||||
if (settings->contains("HelpSideBar/VerticalPosition")) {
|
||||
restoreState(settings->value("HelpSideBar/VerticalPosition").toByteArray());
|
||||
}
|
||||
|
||||
if (settings->contains("HelpSideBar/Width")) {
|
||||
QSize s = size();
|
||||
s.setWidth(settings->value("HelpSideBar/Width").toInt());
|
||||
resize(s);
|
||||
}
|
||||
}
|
||||
|
||||
void SideBar::activateItem(SideBarItem *item)
|
||||
{
|
||||
QMap<QString, SideBarItem *>::const_iterator it = m_itemMap.constBegin();
|
||||
QString title;
|
||||
while (it != m_itemMap.constEnd()) {
|
||||
if (it.value() == item) {
|
||||
title = it.key();
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
if (title.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_widgets.count(); ++i) {
|
||||
if (m_widgets.at(i)->currentItemTitle() == title) {
|
||||
item->widget()->setFocus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SideBarWidget *widget = m_widgets.first();
|
||||
widget->setCurrentItem(title);
|
||||
updateWidgets();
|
||||
item->widget()->setFocus();
|
||||
}
|
||||
|
||||
void SideBar::setShortcutMap(const QMap<QString, Core::Command *> &shortcutMap)
|
||||
{
|
||||
m_shortcutMap = shortcutMap;
|
||||
}
|
||||
|
||||
QMap<QString, Core::Command *> SideBar::shortcutMap() const
|
||||
{
|
||||
return m_shortcutMap;
|
||||
}
|
||||
|
||||
|
||||
SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &title)
|
||||
: m_currentItem(0)
|
||||
, m_sideBar(sideBar)
|
||||
{
|
||||
m_comboBox = new ComboBox(this);
|
||||
m_comboBox->setMinimumContentsLength(15);
|
||||
|
||||
m_toolbar = new QToolBar(this);
|
||||
m_toolbar->setContentsMargins(0, 0, 0, 0);
|
||||
m_toolbar->addWidget(m_comboBox);
|
||||
|
||||
m_splitButton = new QToolButton;
|
||||
m_splitButton->setIcon(QIcon(":/core/images/splitbutton_horizontal.png"));
|
||||
m_splitButton->setToolTip(tr("Split"));
|
||||
connect(m_splitButton, SIGNAL(clicked(bool)), this, SIGNAL(splitMe()));
|
||||
|
||||
m_closeButton = new QToolButton;
|
||||
m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
|
||||
m_closeButton->setToolTip(tr("Close"));
|
||||
|
||||
connect(m_closeButton, SIGNAL(clicked(bool)), this, SIGNAL(closeMe()));
|
||||
|
||||
QWidget *spacerItem = new QWidget(this);
|
||||
spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
m_toolbar->addWidget(spacerItem);
|
||||
m_splitAction = m_toolbar->addWidget(m_splitButton);
|
||||
m_toolbar->addWidget(m_closeButton);
|
||||
|
||||
QVBoxLayout *lay = new QVBoxLayout();
|
||||
lay->setMargin(0);
|
||||
lay->setSpacing(0);
|
||||
setLayout(lay);
|
||||
lay->addWidget(m_toolbar);
|
||||
|
||||
const QStringList lst = m_sideBar->availableItems();
|
||||
QString t = title;
|
||||
if (lst.count()) {
|
||||
m_comboBox->addItems(lst);
|
||||
m_comboBox->setCurrentIndex(0);
|
||||
if (t.isEmpty()) {
|
||||
t = m_comboBox->currentText();
|
||||
}
|
||||
}
|
||||
setCurrentItem(t);
|
||||
|
||||
connect(m_comboBox, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(setCurrentIndex(int)));
|
||||
}
|
||||
|
||||
SideBarWidget::~SideBarWidget()
|
||||
{}
|
||||
|
||||
QString SideBarWidget::currentItemTitle() const
|
||||
{
|
||||
return m_comboBox->currentText();
|
||||
}
|
||||
|
||||
void SideBarWidget::setCurrentItem(const QString &title)
|
||||
{
|
||||
if (!title.isEmpty()) {
|
||||
int idx = m_comboBox->findText(title);
|
||||
if (idx < 0) {
|
||||
idx = 0;
|
||||
}
|
||||
bool blocked = m_comboBox->blockSignals(true);
|
||||
m_comboBox->setCurrentIndex(idx);
|
||||
m_comboBox->blockSignals(blocked);
|
||||
}
|
||||
|
||||
SideBarItem *item = m_sideBar->item(title);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
removeCurrentItem();
|
||||
m_currentItem = item;
|
||||
layout()->addWidget(m_currentItem->widget());
|
||||
|
||||
// Add buttons and remember their actions for later removal
|
||||
foreach(QToolButton * b, m_currentItem->createToolBarWidgets())
|
||||
m_addedToolBarActions.append(m_toolbar->insertWidget(m_splitAction, b));
|
||||
}
|
||||
|
||||
void SideBarWidget::updateAvailableItems()
|
||||
{
|
||||
bool blocked = m_comboBox->blockSignals(true);
|
||||
QString current = m_comboBox->currentText();
|
||||
|
||||
m_comboBox->clear();
|
||||
QStringList itms = m_sideBar->availableItems();
|
||||
if (!current.isEmpty() && !itms.contains(current)) {
|
||||
itms.append(current);
|
||||
}
|
||||
qSort(itms);
|
||||
m_comboBox->addItems(itms);
|
||||
int idx = m_comboBox->findText(current);
|
||||
if (idx < 0) {
|
||||
idx = 0;
|
||||
}
|
||||
m_comboBox->setCurrentIndex(idx);
|
||||
m_splitButton->setEnabled(itms.count() > 1);
|
||||
m_comboBox->blockSignals(blocked);
|
||||
}
|
||||
|
||||
void SideBarWidget::removeCurrentItem()
|
||||
{
|
||||
if (!m_currentItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget *w = m_currentItem->widget();
|
||||
layout()->removeWidget(w);
|
||||
w->setParent(0);
|
||||
m_sideBar->makeItemAvailable(m_currentItem);
|
||||
|
||||
// Delete custom toolbar widgets
|
||||
qDeleteAll(m_addedToolBarActions);
|
||||
m_addedToolBarActions.clear();
|
||||
|
||||
m_currentItem = 0;
|
||||
}
|
||||
|
||||
void SideBarWidget::setCurrentIndex(int)
|
||||
{
|
||||
setCurrentItem(m_comboBox->currentText());
|
||||
emit currentWidgetChanged();
|
||||
}
|
||||
|
||||
Core::Command *SideBarWidget::command(const QString &title) const
|
||||
{
|
||||
const QMap<QString, Core::Command *> shortcutMap = m_sideBar->shortcutMap();
|
||||
|
||||
QMap<QString, Core::Command *>::const_iterator r = shortcutMap.find(title);
|
||||
if (r != shortcutMap.end()) {
|
||||
return r.value();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ComboBox::ComboBox(SideBarWidget *sideBarWidget)
|
||||
: m_sideBarWidget(sideBarWidget)
|
||||
{}
|
||||
|
||||
bool ComboBox::event(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::ToolTip) {
|
||||
QString txt = currentText();
|
||||
Core::Command *cmd = m_sideBarWidget->command(txt);
|
||||
if (cmd) {
|
||||
txt = tr("Activate %1").arg(txt);
|
||||
setToolTip(cmd->stringWithAppendedShortcut(txt));
|
||||
} else {
|
||||
setToolTip(txt);
|
||||
}
|
||||
}
|
||||
return QComboBox::event(e);
|
||||
}
|
@ -1,178 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file sidebar.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef SIDEBAR_H
|
||||
#define SIDEBAR_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
|
||||
#include <coreplugin/minisplitter.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
class QToolBar;
|
||||
class QAction;
|
||||
class QToolButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class Command;
|
||||
|
||||
namespace Internal {
|
||||
class SideBarWidget;
|
||||
class ComboBox;
|
||||
} // namespace Internal
|
||||
|
||||
/*
|
||||
* An item in the sidebar. Has a widget that is displayed in the sidebar and
|
||||
* optionally a list of tool buttons that are added to the toolbar above it.
|
||||
* The window title of the widget is displayed in the combo box.
|
||||
*
|
||||
* The SideBarItem takes ownership over the widget.
|
||||
*/
|
||||
class CORE_EXPORT SideBarItem {
|
||||
public:
|
||||
SideBarItem(QWidget *widget)
|
||||
: m_widget(widget)
|
||||
{}
|
||||
|
||||
virtual ~SideBarItem();
|
||||
|
||||
QWidget *widget()
|
||||
{
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
/* Should always return a new set of tool buttons.
|
||||
*
|
||||
* Workaround since there doesn't seem to be a nice way to remove widgets
|
||||
* that have been added to a QToolBar without either not deleting the
|
||||
* associated QAction or causing the QToolButton to be deleted.
|
||||
*/
|
||||
virtual QList<QToolButton *> createToolBarWidgets()
|
||||
{
|
||||
return QList<QToolButton *>();
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
};
|
||||
|
||||
class CORE_EXPORT SideBar : public MiniSplitter {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/*
|
||||
* The SideBar takes ownership of the SideBarItems.
|
||||
*/
|
||||
SideBar(QList<SideBarItem *> widgetList,
|
||||
QList<SideBarItem *> defaultVisible);
|
||||
~SideBar();
|
||||
|
||||
QStringList availableItems() const;
|
||||
void makeItemAvailable(SideBarItem *item);
|
||||
SideBarItem *item(const QString &title);
|
||||
|
||||
void saveSettings(QSettings *settings);
|
||||
void readSettings(QSettings *settings);
|
||||
|
||||
void activateItem(SideBarItem *item);
|
||||
|
||||
void setShortcutMap(const QMap<QString, Core::Command *> &shortcutMap);
|
||||
QMap<QString, Core::Command *> shortcutMap() const;
|
||||
|
||||
private slots:
|
||||
void splitSubWidget();
|
||||
void closeSubWidget();
|
||||
void updateWidgets();
|
||||
|
||||
private:
|
||||
Internal::SideBarWidget *insertSideBarWidget(int position,
|
||||
const QString &title = QString());
|
||||
void removeSideBarWidget(Internal::SideBarWidget *widget);
|
||||
|
||||
QList<Internal::SideBarWidget *> m_widgets;
|
||||
|
||||
QMap<QString, SideBarItem *> m_itemMap;
|
||||
QStringList m_availableItems;
|
||||
QStringList m_defaultVisible;
|
||||
QMap<QString, Core::Command *> m_shortcutMap;
|
||||
};
|
||||
|
||||
namespace Internal {
|
||||
class SideBarWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SideBarWidget(SideBar *sideBar, const QString &title);
|
||||
~SideBarWidget();
|
||||
|
||||
QString currentItemTitle() const;
|
||||
void setCurrentItem(const QString &title);
|
||||
|
||||
void updateAvailableItems();
|
||||
void removeCurrentItem();
|
||||
|
||||
Core::Command *command(const QString &title) const;
|
||||
|
||||
signals:
|
||||
void splitMe();
|
||||
void closeMe();
|
||||
void currentWidgetChanged();
|
||||
|
||||
private slots:
|
||||
void setCurrentIndex(int);
|
||||
|
||||
private:
|
||||
ComboBox *m_comboBox;
|
||||
SideBarItem *m_currentItem;
|
||||
QToolBar *m_toolbar;
|
||||
QAction *m_splitAction;
|
||||
QList<QAction *> m_addedToolBarActions;
|
||||
SideBar *m_sideBar;
|
||||
QToolButton *m_splitButton;
|
||||
QToolButton *m_closeButton;
|
||||
};
|
||||
|
||||
class ComboBox : public QComboBox {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ComboBox(SideBarWidget *sideBarWidget);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
|
||||
private:
|
||||
SideBarWidget *m_sideBarWidget;
|
||||
};
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // SIDEBAR_H
|
@ -1,158 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file styleanimator.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "styleanimator.h"
|
||||
|
||||
#include <QStyleOption>
|
||||
|
||||
Animation *StyleAnimator::widgetAnimation(const QWidget *widget) const
|
||||
{
|
||||
if (!widget) {
|
||||
return 0;
|
||||
}
|
||||
foreach(Animation * a, animations) {
|
||||
if (a->widget() == widget) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Animation::paint(QPainter *painter, const QStyleOption *option)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(painter)
|
||||
}
|
||||
|
||||
void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
|
||||
{
|
||||
if (m_secondaryImage.isNull() || m_primaryImage.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_tempImage.isNull()) {
|
||||
m_tempImage = m_secondaryImage;
|
||||
}
|
||||
|
||||
const int a = qRound(alpha * 256);
|
||||
const int ia = 256 - a;
|
||||
const int sw = m_primaryImage.width();
|
||||
const int sh = m_primaryImage.height();
|
||||
const int bpl = m_primaryImage.bytesPerLine();
|
||||
switch (m_primaryImage.depth()) {
|
||||
case 32:
|
||||
{
|
||||
uchar *mixed_data = m_tempImage.bits();
|
||||
const uchar *back_data = m_primaryImage.bits();
|
||||
const uchar *front_data = m_secondaryImage.bits();
|
||||
for (int sy = 0; sy < sh; sy++) {
|
||||
quint32 *mixed = (quint32 *)mixed_data;
|
||||
const quint32 *back = (const quint32 *)back_data;
|
||||
const quint32 *front = (const quint32 *)front_data;
|
||||
for (int sx = 0; sx < sw; sx++) {
|
||||
quint32 bp = back[sx];
|
||||
quint32 fp = front[sx];
|
||||
mixed[sx] = qRgba((qRed(bp) * ia + qRed(fp) * a) >> 8,
|
||||
(qGreen(bp) * ia + qGreen(fp) * a) >> 8,
|
||||
(qBlue(bp) * ia + qBlue(fp) * a) >> 8,
|
||||
(qAlpha(bp) * ia + qAlpha(fp) * a) >> 8);
|
||||
}
|
||||
mixed_data += bpl;
|
||||
back_data += bpl;
|
||||
front_data += bpl;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
painter->drawImage(rect, m_tempImage);
|
||||
}
|
||||
|
||||
void Transition::paint(QPainter *painter, const QStyleOption *option)
|
||||
{
|
||||
float alpha = 1.0;
|
||||
|
||||
if (m_duration > 0) {
|
||||
QTime current = QTime::currentTime();
|
||||
|
||||
if (m_startTime > current) {
|
||||
m_startTime = current;
|
||||
}
|
||||
|
||||
int timeDiff = m_startTime.msecsTo(current);
|
||||
alpha = timeDiff / (float)m_duration;
|
||||
if (timeDiff > m_duration) {
|
||||
m_running = false;
|
||||
alpha = 1.0;
|
||||
}
|
||||
} else {
|
||||
m_running = false;
|
||||
}
|
||||
drawBlendedImage(painter, option->rect, alpha);
|
||||
}
|
||||
|
||||
void StyleAnimator::timerEvent(QTimerEvent *)
|
||||
{
|
||||
for (int i = animations.size() - 1; i >= 0; --i) {
|
||||
if (animations[i]->widget()) {
|
||||
animations[i]->widget()->update();
|
||||
}
|
||||
|
||||
if (!animations[i]->widget() ||
|
||||
!animations[i]->widget()->isEnabled() ||
|
||||
!animations[i]->widget()->isVisible() ||
|
||||
animations[i]->widget()->window()->isMinimized() ||
|
||||
!animations[i]->running()) {
|
||||
Animation *a = animations.takeAt(i);
|
||||
delete a;
|
||||
}
|
||||
}
|
||||
if (animations.size() == 0 && animationTimer.isActive()) {
|
||||
animationTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void StyleAnimator::stopAnimation(const QWidget *w)
|
||||
{
|
||||
for (int i = animations.size() - 1; i >= 0; --i) {
|
||||
if (animations[i]->widget() == w) {
|
||||
Animation *a = animations.takeAt(i);
|
||||
delete a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StyleAnimator::startAnimation(Animation *t)
|
||||
{
|
||||
stopAnimation(t->widget());
|
||||
animations.append(t);
|
||||
if (animations.size() > 0 && !animationTimer.isActive()) {
|
||||
animationTimer.start(35, this);
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file styleanimator.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef ANIMATION_H
|
||||
#define ANIMATION_H
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QTime>
|
||||
#include <QtCore/QBasicTimer>
|
||||
#include <QStyle>
|
||||
#include <QPainter>
|
||||
#include <QWidget>
|
||||
|
||||
/*
|
||||
* This is a set of helper classes to allow for widget animations in
|
||||
* the style. Its mostly taken from Vista style so it should be fully documented
|
||||
* there.
|
||||
*
|
||||
*/
|
||||
|
||||
class Animation {
|
||||
public:
|
||||
Animation() : m_running(true) {}
|
||||
virtual ~Animation() {}
|
||||
QWidget *widget() const
|
||||
{
|
||||
return m_widget;
|
||||
}
|
||||
bool running() const
|
||||
{
|
||||
return m_running;
|
||||
}
|
||||
const QTime &startTime() const
|
||||
{
|
||||
return m_startTime;
|
||||
}
|
||||
void setRunning(bool val)
|
||||
{
|
||||
m_running = val;
|
||||
}
|
||||
void setWidget(QWidget *widget)
|
||||
{
|
||||
m_widget = widget;
|
||||
}
|
||||
void setStartTime(const QTime &startTime)
|
||||
{
|
||||
m_startTime = startTime;
|
||||
}
|
||||
virtual void paint(QPainter *painter, const QStyleOption *option);
|
||||
|
||||
protected:
|
||||
void drawBlendedImage(QPainter *painter, QRect rect, float value);
|
||||
QTime m_startTime;
|
||||
QPointer<QWidget> m_widget;
|
||||
QImage m_primaryImage;
|
||||
QImage m_secondaryImage;
|
||||
QImage m_tempImage;
|
||||
bool m_running;
|
||||
};
|
||||
|
||||
// Handles state transition animations
|
||||
class Transition : public Animation {
|
||||
public:
|
||||
Transition() : Animation() {}
|
||||
virtual ~Transition() {}
|
||||
void setDuration(int duration)
|
||||
{
|
||||
m_duration = duration;
|
||||
}
|
||||
void setStartImage(const QImage &image)
|
||||
{
|
||||
m_primaryImage = image;
|
||||
}
|
||||
void setEndImage(const QImage &image)
|
||||
{
|
||||
m_secondaryImage = image;
|
||||
}
|
||||
virtual void paint(QPainter *painter, const QStyleOption *option);
|
||||
int duration() const
|
||||
{
|
||||
return m_duration;
|
||||
}
|
||||
int m_duration; // set time in ms to complete a state transition
|
||||
};
|
||||
|
||||
class StyleAnimator : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StyleAnimator(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
void timerEvent(QTimerEvent *);
|
||||
void startAnimation(Animation *);
|
||||
void stopAnimation(const QWidget *);
|
||||
Animation *widgetAnimation(const QWidget *) const;
|
||||
|
||||
private:
|
||||
QBasicTimer animationTimer;
|
||||
QList <Animation *> animations;
|
||||
};
|
||||
|
||||
#endif // ANIMATION_H
|
@ -1,52 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file tabpositionindicator.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "tabpositionindicator.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QBrush>
|
||||
#include <QPalette>
|
||||
|
||||
using namespace Core::Internal;
|
||||
|
||||
TabPositionIndicator::TabPositionIndicator()
|
||||
: QWidget(0, Qt::ToolTip)
|
||||
{}
|
||||
|
||||
void TabPositionIndicator::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter p(this);
|
||||
QPen pen = p.pen();
|
||||
|
||||
pen.setWidth(2);
|
||||
pen.setColor(palette().color(QPalette::Active, QPalette::LinkVisited));
|
||||
pen.setStyle(Qt::DotLine);
|
||||
p.setPen(pen);
|
||||
p.drawLine(event->rect().topLeft(), event->rect().bottomLeft());
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file tabpositionindicator.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup CorePlugin Core Plugin
|
||||
* @{
|
||||
* @brief The Core GCS plugin
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef TABPOSITIONINDICATOR_H
|
||||
#define TABPOSITIONINDICATOR_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
class TabPositionIndicator : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum { TABPOSITIONINDICATOR_WIDTH = 2 };
|
||||
|
||||
TabPositionIndicator();
|
||||
int indicatorWidth()
|
||||
{
|
||||
return TABPOSITIONINDICATOR_WIDTH;
|
||||
}
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
};
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // TABPOSITIONINDICATOR_H
|
@ -148,14 +148,14 @@
|
||||
style="fill:#ff201d;fill-opacity:1;stroke:#ef7d7d;stroke-width:0.39996386;stroke-miterlimit:4;stroke-opacity:0.59336093;stroke-dasharray:none"
|
||||
sodipodi:type="arc" />
|
||||
</a>
|
||||
<use
|
||||
<!--use
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#a3867"
|
||||
id="use3944"
|
||||
transform="translate(-7.1291862,13.018514)"
|
||||
width="64"
|
||||
height="64" />
|
||||
height="64" /-->
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#998ad7;stroke-width:0;stroke-miterlimit:4;stroke-opacity:0.59336093;stroke-dasharray:none"
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
@ -46,6 +46,9 @@ class qsspt;
|
||||
class opHID_hidapi;
|
||||
|
||||
namespace DFU {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
||||
Q_NAMESPACE
|
||||
#endif
|
||||
enum TransferTypes {
|
||||
FW,
|
||||
Descript
|
||||
|
27
make/3rdparty/osgearth/README.TXT
vendored
27
make/3rdparty/osgearth/README.TXT
vendored
@ -11,7 +11,7 @@ Make sure all LibrePilot SDKs are up to date as the osgEarth build relies on the
|
||||
More details can be found in osgearth.mk.
|
||||
|
||||
|
||||
Linux prerequisites
|
||||
Linux
|
||||
----------------------------------
|
||||
|
||||
$ sudo apt-get install libzip-dev libpng-dev lipjpeg-dev libtiff5-dev libcurl4-openssl-dev
|
||||
@ -20,22 +20,13 @@ $ sudo apt-get install libgeos++-dev libgdal-dev
|
||||
Alternative (not tested recently but could work):
|
||||
$ sudo apt-get build-dep openscenegraph
|
||||
|
||||
Tested with:
|
||||
|
||||
$ curl --version
|
||||
curl 7.35.0 (i686-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
|
||||
|
||||
$ gdal-config --version
|
||||
1.10.1
|
||||
|
||||
|
||||
OSX prerequisites
|
||||
OSX
|
||||
----------------------------------
|
||||
|
||||
brew install cmake
|
||||
brew install gdal
|
||||
|
||||
Windows prerequisites
|
||||
Windows
|
||||
----------------------------------
|
||||
|
||||
pacman -S mingw-w64-i686-cmake mingw-w64-i686-gdal-minimal
|
||||
@ -59,6 +50,18 @@ Todo
|
||||
- declare provides=<original pkgname> and conflicts with origina gdal in PKGBUILD file
|
||||
(allows to substitute the minimal package when anything depends on the original package)
|
||||
|
||||
Dependencies
|
||||
----------------------------------
|
||||
|
||||
GDAL GEOS
|
||||
MSYS2 2.0.1 3.6.1
|
||||
Trusty 3.4.2
|
||||
Xenial 3.5.0
|
||||
OSX 1.11.5 3.6.1
|
||||
|
||||
$ gdal-config --version
|
||||
$ geos-config --version
|
||||
|
||||
Building
|
||||
----------------------------------
|
||||
|
||||
|
24
make/3rdparty/osgearth/osg-3.4.0.patch
vendored
24
make/3rdparty/osgearth/osg-3.4.0.patch
vendored
@ -1,24 +0,0 @@
|
||||
diff --git a/include/osg/OperationThread b/include/osg/OperationThread
|
||||
index a62157e..75adfba 100644
|
||||
--- a/include/osg/OperationThread
|
||||
+++ b/include/osg/OperationThread
|
||||
@@ -80,6 +80,7 @@ protected:
|
||||
_keep(false) {}
|
||||
|
||||
Operation(const Operation& op):
|
||||
+ Referenced(),
|
||||
_name(op._name),
|
||||
_keep(op._keep) {}
|
||||
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 33edf57..d2ea025 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -27,7 +27,6 @@ FOREACH( mylibfolder
|
||||
osgUI
|
||||
osgVolume
|
||||
osgWrappers/serializers
|
||||
- osgWrappers/deprecated-dotosg
|
||||
osgPlugins
|
||||
)
|
||||
|
24
make/3rdparty/osgearth/osg-3.4.patch
vendored
24
make/3rdparty/osgearth/osg-3.4.patch
vendored
@ -1,24 +0,0 @@
|
||||
diff --git a/include/osg/OperationThread b/include/osg/OperationThread
|
||||
index a62157e..75adfba 100644
|
||||
--- a/include/osg/OperationThread
|
||||
+++ b/include/osg/OperationThread
|
||||
@@ -80,6 +80,7 @@ protected:
|
||||
_keep(false) {}
|
||||
|
||||
Operation(const Operation& op):
|
||||
+ Referenced(),
|
||||
_name(op._name),
|
||||
_keep(op._keep) {}
|
||||
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 33edf57..d2ea025 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -27,7 +27,6 @@ FOREACH( mylibfolder
|
||||
osgUI
|
||||
osgVolume
|
||||
osgWrappers/serializers
|
||||
- osgWrappers/deprecated-dotosg
|
||||
osgPlugins
|
||||
)
|
||||
|
13
make/3rdparty/osgearth/osg-3.5.1.patch
vendored
13
make/3rdparty/osgearth/osg-3.5.1.patch
vendored
@ -1,13 +0,0 @@
|
||||
diff --git a/include/osgViewer/View b/include/osgViewer/View
|
||||
index 472b489..07ef9ce 100644
|
||||
--- a/include/osgViewer/View
|
||||
+++ b/include/osgViewer/View
|
||||
@@ -127,7 +127,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
|
||||
/** Set the View's image pager.*/
|
||||
void setImagePager(osgDB::ImagePager* ip);
|
||||
|
||||
- template<class T> void setImagePager(const osg::ref_ptr<T>* ip) { setImagePager(ip.get()); }
|
||||
+ template<class T> void setImagePager(const osg::ref_ptr<T>& ip) { setImagePager(ip.get()); }
|
||||
|
||||
/** Get the View's image pager.*/
|
||||
osgDB::ImagePager* getImagePager();
|
13
make/3rdparty/osgearth/osg-3.5.3.patch
vendored
13
make/3rdparty/osgearth/osg-3.5.3.patch
vendored
@ -1,13 +0,0 @@
|
||||
diff --git a/src/osgPlugins/cfg/CMakeLists.txt b/src/osgPlugins/cfg/CMakeLists.txt
|
||||
index 972675f..4f7062b 100644
|
||||
--- a/src/osgPlugins/cfg/CMakeLists.txt
|
||||
+++ b/src/osgPlugins/cfg/CMakeLists.txt
|
||||
@@ -20,7 +20,7 @@ SET(TARGET_H
|
||||
|
||||
# lex/yacc generated files use register that causes warnings with CLang under OSX so disable this warnings.
|
||||
IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
- SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wno-deprecated-register)
|
||||
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
|
||||
ENDIF()
|
||||
|
||||
#
|
11
make/3rdparty/osgearth/osg-fix-3ds-plugin.patch
vendored
Normal file
11
make/3rdparty/osgearth/osg-fix-3ds-plugin.patch
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
--- OpenSceneGraph-OpenSceneGraph-3.5.5/src/osgPlugins/3ds/ReaderWriter3DS.cpp 2017-02-24 13:09:52.785969600 +0100
|
||||
+++ OpenSceneGraph-OpenSceneGraph-3.5.5/src/osgPlugins/3ds/ReaderWriter3DS.cpp.orig 2017-02-24 13:01:55.130353400 +0100
|
||||
@@ -619,7 +619,7 @@
|
||||
{
|
||||
// add our geometry to group (where our children already are)
|
||||
// creates geometry under modifier node
|
||||
- processMesh(drawStateMap,group,mesh,meshAppliedMatPtr);
|
||||
+ processMesh(drawStateMap,meshTransform,mesh,meshAppliedMatPtr);
|
||||
return group;
|
||||
}
|
||||
else
|
66
make/3rdparty/osgearth/osgearth-2.7.patch
vendored
66
make/3rdparty/osgearth/osgearth-2.7.patch
vendored
@ -1,66 +0,0 @@
|
||||
diff --git a/src/osgEarth/ElevationQuery b/src/osgEarth/ElevationQuery
|
||||
index d8e4d14..50db567 100644
|
||||
--- a/src/osgEarth/ElevationQuery
|
||||
+++ b/src/osgEarth/ElevationQuery
|
||||
@@ -37,7 +37,11 @@ namespace osgEarth
|
||||
|
||||
void pruneUnusedDatabaseCache();
|
||||
|
||||
+#if OSG_VERSION_GREATER_OR_EQUAL(3,5,0)
|
||||
+ virtual osg::ref_ptr<osg::Node> readNodeFile(const std::string& filename);
|
||||
+#else
|
||||
virtual osg::Node* readNodeFile(const std::string& filename);
|
||||
+#endif
|
||||
|
||||
protected:
|
||||
|
||||
diff --git a/src/osgEarth/ElevationQuery.cpp b/src/osgEarth/ElevationQuery.cpp
|
||||
index 5fb8222..8c03309 100644
|
||||
--- a/src/osgEarth/ElevationQuery.cpp
|
||||
+++ b/src/osgEarth/ElevationQuery.cpp
|
||||
@@ -55,7 +55,11 @@ void ElevationQueryCacheReadCallback::pruneUnusedDatabaseCache()
|
||||
{
|
||||
}
|
||||
|
||||
+#if OSG_VERSION_GREATER_OR_EQUAL(3,5,0)
|
||||
+osg::ref_ptr<osg::Node> ElevationQueryCacheReadCallback::readNodeFile(const std::string& filename)
|
||||
+#else
|
||||
osg::Node* ElevationQueryCacheReadCallback::readNodeFile(const std::string& filename)
|
||||
+#endif
|
||||
{
|
||||
// first check to see if file is already loaded.
|
||||
{
|
||||
@@ -71,7 +75,7 @@ osg::Node* ElevationQueryCacheReadCallback::readNodeFile(const std::string& file
|
||||
}
|
||||
|
||||
// now load the file.
|
||||
- osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filename);
|
||||
+ osg::ref_ptr<osg::Node> node = osgDB::readRefNodeFile(filename);
|
||||
|
||||
// insert into the cache.
|
||||
if (node.valid())
|
||||
@@ -105,7 +109,11 @@ osg::Node* ElevationQueryCacheReadCallback::readNodeFile(const std::string& file
|
||||
}
|
||||
}
|
||||
|
||||
+#if OSG_VERSION_GREATER_OR_EQUAL(3,5,0)
|
||||
+ return node;
|
||||
+#else
|
||||
return node.release();
|
||||
+#endif
|
||||
}
|
||||
|
||||
ElevationQuery::ElevationQuery(const Map* map) :
|
||||
diff --git a/src/osgEarthSymbology/Resource b/src/osgEarthSymbology/Resource
|
||||
index a8a1441..934fc7d 100644
|
||||
--- a/src/osgEarthSymbology/Resource
|
||||
+++ b/src/osgEarthSymbology/Resource
|
||||
@@ -33,7 +33,7 @@ namespace osgEarth { namespace Symbology
|
||||
class OSGEARTHSYMBOLOGY_EXPORT Resource : public Taggable<osg::Object>
|
||||
{
|
||||
protected:
|
||||
- Resource(const Resource& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {};
|
||||
+ Resource(const Resource& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : Taggable() {};
|
||||
Resource( const Config& config =Config() );
|
||||
|
||||
/** dtor */
|
80
make/3rdparty/osgearth/osgearth-geos-3_6_1-support.patch
vendored
Normal file
80
make/3rdparty/osgearth/osgearth-geos-3_6_1-support.patch
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
From 2a0f721b58a3280f151df095ef6cb8a9f063ba25 Mon Sep 17 00:00:00 2001
|
||||
From: Philippe Renon <philippe_renon@yahoo.fr>
|
||||
Date: Fri, 13 Jan 2017 15:13:54 +0100
|
||||
Subject: [PATCH] support geos 3.6.1
|
||||
|
||||
---
|
||||
src/osgEarthSymbology/GEOS | 3 ++-
|
||||
src/osgEarthSymbology/GEOS.cpp | 13 ++-----------
|
||||
2 files changed, 4 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/osgEarthSymbology/GEOS b/src/osgEarthSymbology/GEOS
|
||||
index b695bb7de..0184f6422 100644
|
||||
--- a/src/osgEarthSymbology/GEOS
|
||||
+++ b/src/osgEarthSymbology/GEOS
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <osgEarthSymbology/Style>
|
||||
#include <osgEarthSymbology/Geometry>
|
||||
#include <geos/geom/Geometry.h>
|
||||
+#include <geos/geom/GeometryFactory.h>
|
||||
|
||||
namespace osgEarth { namespace Symbology
|
||||
{
|
||||
@@ -45,7 +46,7 @@ namespace osgEarth { namespace Symbology
|
||||
void disposeGeometry(geos::geom::Geometry* input);
|
||||
|
||||
protected:
|
||||
- geos::geom::GeometryFactory* _factory;
|
||||
+ geos::geom::GeometryFactory::unique_ptr _factory;
|
||||
};
|
||||
|
||||
} } // namespace osgEarth::Features
|
||||
diff --git a/src/osgEarthSymbology/GEOS.cpp b/src/osgEarthSymbology/GEOS.cpp
|
||||
index cf04e3309..d87bf461f 100644
|
||||
--- a/src/osgEarthSymbology/GEOS.cpp
|
||||
+++ b/src/osgEarthSymbology/GEOS.cpp
|
||||
@@ -212,7 +212,7 @@ GEOSContext::GEOSContext()
|
||||
geos::geom::PrecisionModel* pm = new geos::geom::PrecisionModel(geom::PrecisionModel::FLOATING);
|
||||
|
||||
// Factory will clone the PM
|
||||
- _factory = new geos::geom::GeometryFactory( pm );
|
||||
+ _factory = geos::geom::GeometryFactory::create( pm );
|
||||
|
||||
// Delete the template.
|
||||
delete pm;
|
||||
@@ -220,7 +220,6 @@ GEOSContext::GEOSContext()
|
||||
|
||||
GEOSContext::~GEOSContext()
|
||||
{
|
||||
- delete _factory;
|
||||
}
|
||||
|
||||
geom::Geometry*
|
||||
@@ -229,12 +228,7 @@ GEOSContext::importGeometry(const Symbology::Geometry* input)
|
||||
geom::Geometry* output = 0L;
|
||||
if ( input && input->isValid() )
|
||||
{
|
||||
- output = import( input, _factory );
|
||||
-
|
||||
- // if output is ok, it will have a pointer to f. this is probably a leak.
|
||||
- // TODO: Check whether this is a leak!! -gw
|
||||
- //if ( !output )
|
||||
- // delete f;
|
||||
+ output = import( input, _factory.get() );
|
||||
}
|
||||
return output;
|
||||
}
|
||||
@@ -327,10 +321,7 @@ GEOSContext::disposeGeometry(geom::Geometry* input)
|
||||
{
|
||||
if (input)
|
||||
{
|
||||
- geom::GeometryFactory* f = const_cast<geom::GeometryFactory*>(input->getFactory());
|
||||
_factory->destroyGeometry(input);
|
||||
- if ( f != _factory )
|
||||
- delete f;
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.12.0
|
||||
|
62
make/3rdparty/osgearth/osgearth-remove-deprecated-call.patch
vendored
Normal file
62
make/3rdparty/osgearth/osgearth-remove-deprecated-call.patch
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
From b69573f50496f9cdcad2bff5e5e25bf1ecea94e6 Mon Sep 17 00:00:00 2001
|
||||
From: gwaldron <gwaldron@gmail.com>
|
||||
Date: Mon, 17 Oct 2016 08:04:31 -0400
|
||||
Subject: [PATCH] Removed/patched deprecated called to osg::Referenced
|
||||
thread-safe reference counting
|
||||
|
||||
---
|
||||
src/osgEarth/Locators.cpp | 4 ++--
|
||||
src/osgEarth/Registry.cpp | 3 +++
|
||||
src/osgEarth/TileSource.cpp | 2 --
|
||||
3 files changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/osgEarth/Locators.cpp b/src/osgEarth/Locators.cpp
|
||||
index fb3e825..fcb780c 100644
|
||||
--- a/src/osgEarth/Locators.cpp
|
||||
+++ b/src/osgEarth/Locators.cpp
|
||||
@@ -29,7 +29,7 @@ _inverseCalculated(false),
|
||||
_x0(0.0), _x1(1.0),
|
||||
_y0(0.0), _y1(1.0)
|
||||
{
|
||||
- this->setThreadSafeRefUnref(true);
|
||||
+ //nop
|
||||
}
|
||||
|
||||
GeoLocator::GeoLocator( const GeoExtent& dataExtent ) :
|
||||
@@ -38,7 +38,7 @@ _dataExtent( dataExtent ),
|
||||
_x0(0.0), _x1(1.0),
|
||||
_y0(0.0), _y1(1.0)
|
||||
{
|
||||
- this->setThreadSafeRefUnref(true);
|
||||
+ //nop
|
||||
}
|
||||
|
||||
GeoLocator::GeoLocator( const osgTerrain::Locator& prototype, const GeoExtent& dataExtent ) :
|
||||
diff --git a/src/osgEarth/Registry.cpp b/src/osgEarth/Registry.cpp
|
||||
index 32a9439..bf95e87 100644
|
||||
--- a/src/osgEarth/Registry.cpp
|
||||
+++ b/src/osgEarth/Registry.cpp
|
||||
@@ -694,7 +694,10 @@ class RegisterEarthTileExtension
|
||||
public:
|
||||
RegisterEarthTileExtension()
|
||||
{
|
||||
+#if OSG_VERSION_LESS_THAN(3,5,4)
|
||||
+ // Method deprecated beyone 3.5.4 since all ref counting is thread-safe by default
|
||||
osg::Referenced::setThreadSafeReferenceCounting( true );
|
||||
+#endif
|
||||
osgDB::Registry::instance()->addFileExtensionAlias("earth_tile", "earth");
|
||||
}
|
||||
};
|
||||
diff --git a/src/osgEarth/TileSource.cpp b/src/osgEarth/TileSource.cpp
|
||||
index fcdf2b8..28c6f61 100644
|
||||
--- a/src/osgEarth/TileSource.cpp
|
||||
+++ b/src/osgEarth/TileSource.cpp
|
||||
@@ -218,8 +218,6 @@ _status ( Status::Error("Not initialized") ),
|
||||
_mode ( 0 ),
|
||||
_openCalled( false )
|
||||
{
|
||||
- this->setThreadSafeRefUnref( true );
|
||||
-
|
||||
// Initialize the l2 cache size to the options.
|
||||
int l2CacheSize = *options.L2CacheSize();
|
||||
|
68
make/3rdparty/osgearth/osgearth.mk
vendored
68
make/3rdparty/osgearth/osgearth.mk
vendored
@ -23,7 +23,7 @@
|
||||
OSG_BUILD_CONF := Release
|
||||
|
||||
OSG_NAME_PREFIX :=
|
||||
OSG_NAME_SUFIX := -qt-$(QT_VERSION)
|
||||
OSG_NAME_SUFIX :=
|
||||
|
||||
################################
|
||||
#
|
||||
@ -31,7 +31,7 @@ OSG_NAME_SUFIX := -qt-$(QT_VERSION)
|
||||
#
|
||||
################################
|
||||
|
||||
OSG_VERSION := 3.5.3
|
||||
OSG_VERSION := 3.5.5
|
||||
OSG_GIT_TAG := OpenSceneGraph-$(OSG_VERSION)
|
||||
|
||||
OSG_BASE_NAME := osg-$(OSG_VERSION)
|
||||
@ -45,14 +45,11 @@ ifeq ($(UNAME), Linux)
|
||||
OSG_CMAKE_GENERATOR := "Unix Makefiles"
|
||||
OSG_CMAKE_MAKE_PROGRAM := make
|
||||
OSG_WINDOWING_SYSTEM := "X11"
|
||||
# for some reason Qt is not added to the path in make/tools.mk
|
||||
OSG_BUILD_PATH := $(QT_SDK_PREFIX)/bin:$(PATH)
|
||||
else ifeq ($(UNAME), Darwin)
|
||||
OSG_NAME := $(OSG_BASE_NAME)-clang_64
|
||||
OSG_CMAKE_GENERATOR := "Unix Makefiles"
|
||||
OSG_CMAKE_MAKE_PROGRAM := make
|
||||
OSG_WINDOWING_SYSTEM := "Cocoa"
|
||||
OSG_BUILD_PATH := $(QT_SDK_PREFIX)/bin:$(PATH)
|
||||
else ifeq ($(UNAME), Windows)
|
||||
OSG_NAME := $(OSG_BASE_NAME)-$(QT_SDK_ARCH)
|
||||
OSG_CMAKE_GENERATOR := "MinGW Makefiles"
|
||||
@ -62,7 +59,6 @@ OSG_NAME := $(OSG_NAME_PREFIX)$(OSG_NAME)$(OSG_NAME_SUFIX)
|
||||
OSG_SRC_DIR := $(ROOT_DIR)/3rdparty/osg
|
||||
OSG_BUILD_DIR := $(BUILD_DIR)/3rdparty/$(OSG_NAME)
|
||||
OSG_INSTALL_DIR := $(BUILD_DIR)/3rdparty/install/$(OSG_NAME)
|
||||
OSG_PATCH_FILE := $(ROOT_DIR)/make/3rdparty/osgearth/osg-$(OSG_VERSION).patch
|
||||
|
||||
.PHONY: osg
|
||||
osg:
|
||||
@ -74,17 +70,15 @@ osg:
|
||||
fi ; \
|
||||
$(CMAKE) -G $(OSG_CMAKE_GENERATOR) -DCMAKE_BUILD_TYPE=$(OSG_BUILD_CONF) \
|
||||
-DCMAKE_MAKE_PROGRAM=$(MAKE) \
|
||||
-DOSG_USE_QT=ON \
|
||||
-DBUILD_OSG_APPLICATIONS=ON \
|
||||
-DBUILD_OSG_EXAMPLES=OFF \
|
||||
-DBUILD_OPENTHREADS_WITH_QT=OFF \
|
||||
-DOSG_GL3_AVAILABLE=OFF \
|
||||
-DOSG_PLUGIN_SEARCH_INSTALL_DIR_FOR_PLUGINS=OFF \
|
||||
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
|
||||
-DOSG_WINDOWING_SYSTEM=$(OSG_WINDOWING_SYSTEM) \
|
||||
-DCMAKE_INSTALL_NAME_DIR=@executable_path/../Plugins \
|
||||
-DCMAKE_INSTALL_PREFIX=$(OSG_INSTALL_DIR) $(OSG_SRC_DIR) && \
|
||||
$(MAKE) && \
|
||||
$(MAKE) -j3 && \
|
||||
$(MAKE) install ; \
|
||||
)
|
||||
|
||||
@ -99,34 +93,6 @@ package_osg:
|
||||
$(call MD5_GEN_TEMPLATE,$(notdir $(OSG_INSTALL_DIR)).tar.gz) ; \
|
||||
)
|
||||
|
||||
.PHONY: install_win_osg
|
||||
install_win_osg:
|
||||
# curl
|
||||
$(V1) $(CP) /mingw32/bin/libcurl-4.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libidn-11.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/librtmp-1.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libgmp-10.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libgnutls-30.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libp11-kit-0.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libffi-6.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libtasn1-6.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libhogweed-4-1.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libnettle-6-1.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libssh2-1.dll $(OSG_INSTALL_DIR)/bin/
|
||||
# gdal
|
||||
$(V1) $(CP) /mingw32/bin/libgdal-20.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libgeos_c.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libgeos.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libjpeg-8.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libtiff-5.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/liblzma-5.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libiconv-2.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/zlib1.dll $(OSG_INSTALL_DIR)/bin/
|
||||
# other
|
||||
$(V1) $(CP) /mingw32/bin/libproj-9.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libfreetype-6.dll $(OSG_INSTALL_DIR)/bin/
|
||||
$(V1) $(CP) /mingw32/bin/libpng16-16.dll $(OSG_INSTALL_DIR)/bin/
|
||||
|
||||
.NOTPARALLEL:
|
||||
.PHONY: prepare_osg
|
||||
prepare_osg: clone_osg
|
||||
@ -141,10 +107,7 @@ clone_osg:
|
||||
$(V1) $(GIT) clone --depth 1 --no-checkout -b $(OSG_GIT_TAG) git://github.com/openscenegraph/osg.git $(OSG_SRC_DIR)
|
||||
@$(ECHO) "Checkout osg $(OSG_GIT_TAG)"
|
||||
$(V1) ( $(CD) $(OSG_SRC_DIR) && $(GIT) checkout --force tags/$(OSG_GIT_TAG) ; )
|
||||
$(V1) if [ -e $(OSG_PATCH_FILE) ]; then \
|
||||
$(ECHO) "Patching osg..." ; \
|
||||
( $(CD) $(OSG_SRC_DIR) && $(GIT) apply $(OSG_PATCH_FILE) ; ) \
|
||||
fi
|
||||
$(V1) ( $(CD) $(OSG_SRC_DIR) && $(GIT) apply $(ROOT_DIR)/make/3rdparty/osgearth/osg-fix-3ds-plugin.patch ; )
|
||||
|
||||
.PHONY: clean_osg
|
||||
clean_osg:
|
||||
@ -168,7 +131,7 @@ clean_all_osg: clean_osg
|
||||
# fix Debug build
|
||||
# add option to not build the applications (in Debug mode in particular)
|
||||
|
||||
OSGEARTH_VERSION := 2.7
|
||||
OSGEARTH_VERSION := 2.8
|
||||
OSGEARTH_GIT_TAG := osgearth-$(OSGEARTH_VERSION)
|
||||
|
||||
OSGEARTH_BASE_NAME := osgearth-$(OSGEARTH_VERSION)
|
||||
@ -184,8 +147,7 @@ ifeq ($(UNAME), Linux)
|
||||
endif
|
||||
OSGEARTH_CMAKE_GENERATOR := "Unix Makefiles"
|
||||
OSGEARTH_CMAKE_MAKE_PROGRAM := make
|
||||
# for some reason Qt is not added to the path in make/tools.mk
|
||||
OSGEARTH_BUILD_PATH := $(QT_SDK_PREFIX)/bin:$(OSG_INSTALL_DIR)/bin:$(PATH)
|
||||
OSGEARTH_BUILD_PATH := $(OSG_INSTALL_DIR)/bin:$(PATH)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
OSGEARTH_LIB_PATH := $(OSG_INSTALL_DIR)/lib64
|
||||
else
|
||||
@ -195,7 +157,7 @@ else ifeq ($(UNAME), Darwin)
|
||||
OSGEARTH_NAME := $(OSGEARTH_BASE_NAME)-clang_64
|
||||
OSGEARTH_CMAKE_GENERATOR := "Unix Makefiles"
|
||||
OSGEARTH_CMAKE_MAKE_PROGRAM := make
|
||||
OSGEARTH_BUILD_PATH := $(QT_SDK_PREFIX)/bin:$(OSG_INSTALL_DIR)/bin:$(PATH)
|
||||
OSGEARTH_BUILD_PATH := $(OSG_INSTALL_DIR)/bin:$(PATH)
|
||||
OSGEARTH_LIB_PATH := $(OSG_INSTALL_DIR)/lib
|
||||
else ifeq ($(UNAME), Windows)
|
||||
OSGEARTH_NAME := $(OSGEARTH_BASE_NAME)-$(QT_SDK_ARCH)
|
||||
@ -207,7 +169,6 @@ OSGEARTH_NAME := $(OSG_NAME_PREFIX)$(OSGEARTH_NAME)$(OSG_NAME_SUFIX)
|
||||
OSGEARTH_SRC_DIR := $(ROOT_DIR)/3rdparty/osgearth
|
||||
OSGEARTH_BUILD_DIR := $(BUILD_DIR)/3rdparty/$(OSGEARTH_NAME)
|
||||
OSGEARTH_INSTALL_DIR := $(BUILD_DIR)/3rdparty/install/$(OSGEARTH_NAME)
|
||||
OSGEARTH_PATCH_FILE := $(ROOT_DIR)/make/3rdparty/osgearth/osgearth-$(OSGEARTH_VERSION).patch
|
||||
|
||||
.PHONY: osgearth
|
||||
osgearth:
|
||||
@ -222,7 +183,7 @@ osgearth:
|
||||
unset OSG_NOTIFY_LEVEL && \
|
||||
$(CMAKE) -G $(OSGEARTH_CMAKE_GENERATOR) -DCMAKE_BUILD_TYPE=$(OSGEARTH_BUILD_CONF) \
|
||||
-DCMAKE_MAKE_PROGRAM=$(MAKE) \
|
||||
-DOSGEARTH_USE_QT=ON \
|
||||
-DOSGEARTH_USE_QT=OFF \
|
||||
-DINSTALL_TO_OSG_DIR=OFF \
|
||||
-DOSG_DIR=$(OSG_INSTALL_DIR) \
|
||||
-DCMAKE_INCLUDE_PATH=$(OSG_INSTALL_DIR)/include \
|
||||
@ -231,7 +192,7 @@ osgearth:
|
||||
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
|
||||
-DCMAKE_INSTALL_NAME_DIR=@executable_path/../Plugins \
|
||||
-DCMAKE_INSTALL_PREFIX=$(OSGEARTH_INSTALL_DIR) $(OSGEARTH_SRC_DIR) && \
|
||||
$(MAKE) && \
|
||||
$(MAKE) -j3 && \
|
||||
$(MAKE) install ; \
|
||||
)
|
||||
|
||||
@ -259,10 +220,8 @@ clone_osgearth:
|
||||
$(V1) $(GIT) clone --depth 1 --no-checkout -b $(OSGEARTH_GIT_TAG) git://github.com/gwaldron/osgearth.git $(OSGEARTH_SRC_DIR)
|
||||
@$(ECHO) "Checkout osgearth $(OSGEARTH_GIT_TAG)"
|
||||
$(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) checkout --force tags/$(OSGEARTH_GIT_TAG) ; )
|
||||
$(V1) if [ -e $(OSGEARTH_PATCH_FILE) ]; then \
|
||||
$(ECHO) "Patching osgearth..." ; \
|
||||
( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) apply $(OSGEARTH_PATCH_FILE) ; ) \
|
||||
fi
|
||||
$(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) apply $(ROOT_DIR)/make/3rdparty/osgearth/osgearth-remove-deprecated-call.patch ; )
|
||||
$(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) apply $(ROOT_DIR)/make/3rdparty/osgearth/osgearth-geos-3_6_1-support.patch ; )
|
||||
|
||||
.PHONY: clean_osgearth
|
||||
clean_osgearth:
|
||||
@ -284,9 +243,4 @@ clean_all_osgearth: clean_osgearth
|
||||
|
||||
.NOTPARALLEL:
|
||||
.PHONY: all_osg
|
||||
|
||||
ifeq ($(UNAME), Windows)
|
||||
all_osg: prepare_osg prepare_osgearth osg osgearth install_win_osg package_osg package_osgearth
|
||||
else
|
||||
all_osg: prepare_osg prepare_osgearth osg osgearth package_osg package_osgearth
|
||||
endif
|
||||
|
@ -1,9 +1,12 @@
|
||||
/*
|
||||
silent installer script
|
||||
Silent installer script
|
||||
|
||||
known to work with Qt 5.6.0 and QtIFW 2.1.0
|
||||
Known to work with Qt 5.8.0 and QtIFW 2.0.5
|
||||
|
||||
known issues:
|
||||
Test with:
|
||||
$ ./qt-opensource-windows-x86-mingw530-5.8.0.exe --verbose --script ../librepilot/make/tool_install/qt-install.qs
|
||||
|
||||
Known issues:
|
||||
- silent but not headless (QtIFW 2.1.0 should support gui.setSilent(true))
|
||||
- cannot disable forced components (QtCreator, ...)
|
||||
- cannot disable virtual components (doc, examples, ...)
|
||||
@ -17,7 +20,7 @@ function Controller()
|
||||
|
||||
var qtInstallTargetDir = installer.environmentVariable("QT_INSTALL_TARGET_DIR");
|
||||
if (qtInstallTargetDir == "") {
|
||||
qtInstallTargetDir = installer.environmentVariable("PWD") + "/tools/qt-5.6.0";
|
||||
qtInstallTargetDir = installer.environmentVariable("PWD") + "/tools/qt-5.8.0";
|
||||
console.log("Environment variable QT_INSTALL_TARGET_DIR not set, using default " + qtInstallTargetDir);
|
||||
}
|
||||
installer.setValue("TargetDir", qtInstallTargetDir);
|
||||
@ -65,6 +68,14 @@ onFinishedCalculateComponentsToInstall = function()
|
||||
//dumpComponents();
|
||||
}
|
||||
|
||||
function disableComponent(componentName)
|
||||
{
|
||||
component = installer.componentByName(componentName)
|
||||
component.enabled = false
|
||||
component.forcedInstallation = false
|
||||
//component.setValue("ForcedInstallation", "false");
|
||||
}
|
||||
|
||||
// page callbacks
|
||||
// used to setup wizard pages and move the wizard forward
|
||||
|
||||
@ -96,25 +107,22 @@ Controller.prototype.ComponentSelectionPageCallback = function()
|
||||
var page = gui.currentPageWidget();
|
||||
page.deselectAll()
|
||||
if (installer.value("os") == "win") {
|
||||
selectComponent(page, "qt.56.win32_mingw492");
|
||||
selectComponent(page, "qt.tools.win32_mingw492");
|
||||
selectComponent(page, "qt.58.win32_mingw53");
|
||||
selectComponent(page, "qt.tools.win32_mingw530");
|
||||
}
|
||||
else if (installer.value("os") == "x11") {
|
||||
selectComponent(page, "qt.56.gcc");
|
||||
selectComponent(page, "qt.56.gcc_64");
|
||||
selectComponent(page, "qt.58.gcc");
|
||||
selectComponent(page, "qt.58.gcc_64");
|
||||
}
|
||||
else if (installer.value("os") == "mac") {
|
||||
selectComponent(page, "qt.56.clang_64");
|
||||
selectComponent(page, "qt.58.clang_64");
|
||||
}
|
||||
selectComponent(page, "qt.56.qtquickcontrols");
|
||||
selectComponent(page, "qt.56.qtscript");
|
||||
|
||||
//installer.componentByName("qt.tools.qtcreator").setValue("ForcedInstallation", "false");
|
||||
//selectComponent(page, "qt.58.qtquickcontrols");
|
||||
selectComponent(page, "qt.58.qtscript");
|
||||
|
||||
gui.clickButton(buttons.NextButton);
|
||||
}
|
||||
|
||||
|
||||
function selectComponent(page, name)
|
||||
{
|
||||
component = installer.componentByName(name);
|
||||
|
@ -86,16 +86,23 @@ $(TOOL_REMOVE_TARGETS):
|
||||
|
||||
TOOLS_URL := http://librepilot.github.io/tools
|
||||
|
||||
QT_SHORT_VERSION := 5.6
|
||||
QT_VERSION := 5.6.2
|
||||
# versions given below are defaults
|
||||
# and are used only to install the tools on some OSes
|
||||
# don't assume actual versions to match
|
||||
|
||||
QT_SHORT_VERSION := 5.8
|
||||
QT_VERSION := 5.8.0
|
||||
|
||||
OSG_VERSION := 3.5.5
|
||||
OSGEARTH_VERSION := 2.8
|
||||
|
||||
ifeq ($(UNAME), Linux)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
QT_SDK_ARCH := gcc_64
|
||||
QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-linux-x64-$(QT_VERSION).run
|
||||
QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
|
||||
OSG_URL := $(TOOLS_URL)/osg-3.5.3-linux-x64-qt-$(QT_VERSION).tar.gz
|
||||
OSGEARTH_URL := $(TOOLS_URL)/osgearth-2.7-linux-x64-qt-$(QT_VERSION).tar.gz
|
||||
OSG_URL := $(TOOLS_URL)/osg-$(OSG_VERSION)-linux-x64.tar.gz
|
||||
OSGEARTH_URL := $(TOOLS_URL)/osgearth-$(OSGEARTH_VERSION)-linux-x64.tar.gz
|
||||
else
|
||||
# x32 for linux no longer provided as pre-built binaries.
|
||||
endif
|
||||
@ -109,11 +116,11 @@ else ifeq ($(UNAME), Darwin)
|
||||
QT_SDK_MAINTENANCE_TOOL := /Volumes/qt-opensource-mac-x64-clang-$(QT_VERSION)/qt-opensource-mac-x64-clang-$(QT_VERSION).app/Contents/MacOS/qt-opensource-mac-x64-clang-$(QT_VERSION)
|
||||
UNCRUSTIFY_URL := $(TOOLS_URL)/uncrustify-0.60.tar.gz
|
||||
DOXYGEN_URL := $(TOOLS_URL)/doxygen-1.8.3.1.src.tar.gz
|
||||
OSG_URL := $(TOOLS_URL)/osg-3.5.3-clang_64-qt-$(QT_VERSION).tar.gz
|
||||
OSGEARTH_URL := $(TOOLS_URL)/osgearth-2.7-clang_64-qt-$(QT_VERSION).tar.gz
|
||||
OSG_URL := $(TOOLS_URL)/osg-$(OSG_VERSION)-clang_64.tar.gz
|
||||
OSGEARTH_URL := $(TOOLS_URL)/osgearth-$(OSGEARTH_VERSION)-clang_64.tar.gz
|
||||
else ifeq ($(UNAME), Windows)
|
||||
QT_SDK_ARCH := mingw492_32
|
||||
QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-windows-x86-mingw492-$(QT_VERSION).exe
|
||||
QT_SDK_ARCH := mingw53_32
|
||||
QT_SDK_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/qt-opensource-windows-x86-mingw530-$(QT_VERSION).exe
|
||||
QT_SDK_MD5_URL := http://download.qt.io/official_releases/qt/$(QT_SHORT_VERSION)/$(QT_VERSION)/md5sums.txt
|
||||
NSIS_URL := $(TOOLS_URL)/nsis-2.46-unicode.tar.bz2
|
||||
MESAWIN_URL := $(TOOLS_URL)/mesawin.tar.gz
|
||||
@ -133,15 +140,15 @@ CCACHE_DIR := $(TOOLS_DIR)/ccache
|
||||
|
||||
ifeq ($(UNAME), Linux)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-linux-x64-qt-$(QT_VERSION)
|
||||
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-linux-x64-qt-$(QT_VERSION)
|
||||
OSG_SDK_DIR := $(TOOLS_DIR)/osg-$(OSG_VERSION)-linux-x64
|
||||
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-$(OSGEARTH_VERSION)-linux-x64
|
||||
else
|
||||
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-linux-x86-qt-$(QT_VERSION)
|
||||
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-linux-x86-qt-$(QT_VERSION)
|
||||
OSG_SDK_DIR := $(TOOLS_DIR)/osg-$(OSG_VERSION)-linux-x86
|
||||
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-$(OSGEARTH_VERSION)-linux-x86
|
||||
endif
|
||||
else ifeq ($(UNAME), Darwin)
|
||||
OSG_SDK_DIR := $(TOOLS_DIR)/osg-3.5.3-clang_64-qt-$(QT_VERSION)
|
||||
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-2.7-clang_64-qt-$(QT_VERSION)
|
||||
OSG_SDK_DIR := $(TOOLS_DIR)/osg-$(OSG_VERSION)-clang_64
|
||||
OSGEARTH_SDK_DIR := $(TOOLS_DIR)/osgearth-$(OSGEARTH_VERSION)-clang_64
|
||||
else ifeq ($(UNAME), Windows)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
MINGW_DIR := /mingw64
|
||||
@ -342,7 +349,7 @@ endif
|
||||
##############################
|
||||
|
||||
define DOWNLOAD_TEMPLATE
|
||||
@$(ECHO) $(MSG_VERIFYING) $$(call toprel, $(DL_DIR)/$(2))
|
||||
@$(ECHO) $(MSG_VERIFYING) $$(call toprel, $(DL_DIR)/$(2))
|
||||
$(V1) ( \
|
||||
cd "$(DL_DIR)" && \
|
||||
$(CURL) $(CURL_OPTIONS) --silent -o "$(DL_DIR)/$(2).md5" "$(3)" && \
|
||||
|
Loading…
Reference in New Issue
Block a user