1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

LP-491 gcs: remove dead code

This commit is contained in:
Philippe Renon 2017-03-17 23:31:53 +01:00
parent 6aa8fd49f2
commit 29005473d4
29 changed files with 1 additions and 5562 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -27,7 +27,6 @@ SOURCES += \
newclasswidget.cpp \ newclasswidget.cpp \
classnamevalidatinglineedit.cpp \ classnamevalidatinglineedit.cpp \
linecolumnlabel.cpp \ linecolumnlabel.cpp \
fancylineedit.cpp \
qtcolorbutton.cpp \ qtcolorbutton.cpp \
savedaction.cpp \ savedaction.cpp \
submiteditorwidget.cpp \ submiteditorwidget.cpp \
@ -42,7 +41,6 @@ SOURCES += \
stylehelper.cpp \ stylehelper.cpp \
welcomemodetreewidget.cpp \ welcomemodetreewidget.cpp \
iwelcomepage.cpp \ iwelcomepage.cpp \
fancymainwindow.cpp \
detailsbutton.cpp \ detailsbutton.cpp \
detailswidget.cpp \ detailswidget.cpp \
coordinateconversions.cpp \ coordinateconversions.cpp \
@ -89,7 +87,6 @@ HEADERS += \
newclasswidget.h \ newclasswidget.h \
classnamevalidatinglineedit.h \ classnamevalidatinglineedit.h \
linecolumnlabel.h \ linecolumnlabel.h \
fancylineedit.h \
qtcolorbutton.h \ qtcolorbutton.h \
savedaction.h \ savedaction.h \
submiteditorwidget.h \ submiteditorwidget.h \
@ -106,7 +103,6 @@ HEADERS += \
stylehelper.h \ stylehelper.h \
welcomemodetreewidget.h \ welcomemodetreewidget.h \
iwelcomepage.h \ iwelcomepage.h \
fancymainwindow.h \
detailsbutton.h \ detailsbutton.h \
detailswidget.h \ detailswidget.h \
coordinateconversions.h \ coordinateconversions.h \

View File

@ -19,7 +19,6 @@ HEADERS += \
configgadgetwidget.h \ configgadgetwidget.h \
configgadgetfactory.h \ configgadgetfactory.h \
configgadget.h \ configgadget.h \
fancytabwidget.h \
configinputwidget.h \ configinputwidget.h \
configoutputwidget.h \ configoutputwidget.h \
configvehicletypewidget.h \ configvehicletypewidget.h \
@ -68,7 +67,6 @@ SOURCES += \
configgadgetwidget.cpp \ configgadgetwidget.cpp \
configgadgetfactory.cpp \ configgadgetfactory.cpp \
configgadget.cpp \ configgadget.cpp \
fancytabwidget.cpp \
configinputwidget.cpp \ configinputwidget.cpp \
configoutputwidget.cpp \ configoutputwidget.cpp \
configvehicletypewidget.cpp \ configvehicletypewidget.cpp \

View File

@ -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();
}

View File

@ -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

View File

@ -24,9 +24,6 @@ DEPENDPATH += \
SOURCES += \ SOURCES += \
mainwindow.cpp \ mainwindow.cpp \
tabpositionindicator.cpp \
fancyactionbar.cpp \
fancytabwidget.cpp \
generalsettings.cpp \ generalsettings.cpp \
uniqueidmanager.cpp \ uniqueidmanager.cpp \
messagemanager.cpp \ messagemanager.cpp \
@ -49,11 +46,7 @@ SOURCES += \
modemanager.cpp \ modemanager.cpp \
coreimpl.cpp \ coreimpl.cpp \
plugindialog.cpp \ plugindialog.cpp \
manhattanstyle.cpp \
minisplitter.cpp \ minisplitter.cpp \
styleanimator.cpp \
rightpane.cpp \
sidebar.cpp \
mimedatabase.cpp \ mimedatabase.cpp \
icore.cpp \ icore.cpp \
dialogs/ioptionspage.cpp \ dialogs/ioptionspage.cpp \
@ -72,9 +65,6 @@ SOURCES += \
HEADERS += \ HEADERS += \
mainwindow.h \ mainwindow.h \
tabpositionindicator.h \
fancyactionbar.h \
fancytabwidget.h \
generalsettings.h \ generalsettings.h \
uniqueidmanager.h \ uniqueidmanager.h \
messagemanager.h \ messagemanager.h \
@ -112,11 +102,7 @@ HEADERS += \
modemanager.h \ modemanager.h \
coreimpl.h \ coreimpl.h \
plugindialog.h \ plugindialog.h \
manhattanstyle.h \
minisplitter.h \ minisplitter.h \
styleanimator.h \
rightpane.h \
sidebar.h \
mimedatabase.h \ mimedatabase.h \
settingsdatabase.h \ settingsdatabase.h \
eventfilteringmainwindow.h \ eventfilteringmainwindow.h \
@ -139,8 +125,7 @@ FORMS += \
workspacesettings.ui workspacesettings.ui
RESOURCES += \ RESOURCES += \
core.qrc \ core.qrc
fancyactionbar.qrc
unix:!macx { unix:!macx {
images.files = images/librepilot_logo_*.png images.files = images/librepilot_logo_*.png

View File

@ -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();
}
}
}

View File

@ -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

View File

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/fancyactionbar">
<file>images/fancytoolbutton.svg</file>
</qresource>
</RCC>

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -54,7 +54,6 @@
#include <qstylefactory.h> #include <qstylefactory.h>
#include "rightpane.h"
#include "settingsdialog.h" #include "settingsdialog.h"
#include "threadmanager.h" #include "threadmanager.h"
#include "uniqueidmanager.h" #include "uniqueidmanager.h"

View File

@ -57,7 +57,6 @@ class ConnectionManager;
class MessageManager; class MessageManager;
class MimeDatabase; class MimeDatabase;
class ModeManager; class ModeManager;
class RightPaneWidget;
class SettingsDatabase; class SettingsDatabase;
class UniqueIDManager; class UniqueIDManager;
class VariableManager; class VariableManager;
@ -70,7 +69,6 @@ class UAVGadgetInstanceManager;
namespace Internal { namespace Internal {
class ActionManagerPrivate; class ActionManagerPrivate;
class CoreImpl; class CoreImpl;
class FancyTabWidget;
class GeneralSettings; class GeneralSettings;
class ShortcutSettings; class ShortcutSettings;
class WorkspaceSettings; class WorkspaceSettings;

View File

@ -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());
}
}

View File

@ -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

View File

@ -28,8 +28,6 @@
#include "modemanager.h" #include "modemanager.h"
#include "fancytabwidget.h"
#include "fancyactionbar.h"
#include "utils/mytabwidget.h" #include "utils/mytabwidget.h"
#include "icore.h" #include "icore.h"
#include "mainwindow.h" #include "mainwindow.h"

View File

@ -48,8 +48,6 @@ class Command;
class IMode; class IMode;
namespace Internal { namespace Internal {
class FancyTabWidget;
class FancyActionBar;
class MainWindow; class MainWindow;
} // namespace Internal } // namespace Internal

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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

View File

@ -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());
}

View File

@ -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