mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
Merge remote-tracking branch 'origin/PeterG/OP-290_GCS_workspaces' into next
This commit is contained in:
commit
224e75bfe5
38
ground/openpilotgcs/src/libs/utils/mylistwidget.cpp
Normal file
38
ground/openpilotgcs/src/libs/utils/mylistwidget.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mylistwidget.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 "mylistwidget.h"
|
||||
|
||||
QStyleOptionViewItem MyListWidget::viewOptions() const
|
||||
{
|
||||
QStyleOptionViewItem option = QListWidget::viewOptions();
|
||||
if (m_iconAbove) {
|
||||
option.decorationPosition = QStyleOptionViewItem::Top;
|
||||
option.displayAlignment = Qt::AlignCenter;
|
||||
}
|
||||
return option;
|
||||
}
|
53
ground/openpilotgcs/src/libs/utils/mylistwidget.h
Normal file
53
ground/openpilotgcs/src/libs/utils/mylistwidget.h
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mylistwidget.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 MYLISTWIDGET_H
|
||||
#define MYLISTWIDGET_H
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include <QtGui/QListWidget>
|
||||
|
||||
/*
|
||||
* MyListWidget is a plain QListWidget but with the added option
|
||||
* to place the icon above the label in ListMode. This is achieved
|
||||
* the easiest by subclassing QListWidget and overriding viewOptions().
|
||||
*/
|
||||
class QTCREATOR_UTILS_EXPORT MyListWidget : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MyListWidget(QWidget *parent) : QListWidget(parent), m_iconAbove(false) { }
|
||||
void setIconAbove(bool iconAbove) { m_iconAbove = iconAbove; }
|
||||
protected:
|
||||
QStyleOptionViewItem viewOptions() const;
|
||||
private:
|
||||
bool m_iconAbove;
|
||||
};
|
||||
|
||||
#endif // MYLISTWIDGET_H
|
109
ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp
Normal file
109
ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mytabbedstackwidget.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 "mytabbedstackwidget.h"
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
MyTabbedStackWidget::MyTabbedStackWidget(QWidget *parent, bool isVertical, bool iconAbove)
|
||||
: QWidget(parent),
|
||||
m_vertical(isVertical),
|
||||
m_iconAbove(iconAbove)
|
||||
{
|
||||
m_listWidget = new MyListWidget(this);
|
||||
m_listWidget->setIconAbove(m_iconAbove);
|
||||
m_stackWidget = new QStackedWidget();
|
||||
m_stackWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
QBoxLayout *toplevelLayout;
|
||||
if (m_vertical) {
|
||||
toplevelLayout = new QHBoxLayout;
|
||||
toplevelLayout->addWidget(m_listWidget);
|
||||
toplevelLayout->addWidget(m_stackWidget);
|
||||
m_listWidget->setFlow(QListView::TopToBottom);
|
||||
m_listWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
} else {
|
||||
toplevelLayout = new QVBoxLayout;
|
||||
toplevelLayout->addWidget(m_stackWidget);
|
||||
toplevelLayout->addWidget(m_listWidget);
|
||||
m_listWidget->setFlow(QListView::LeftToRight);
|
||||
m_listWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
}
|
||||
if (m_iconAbove && m_vertical)
|
||||
m_listWidget->setFixedWidth(90); // this should be computed instead
|
||||
|
||||
toplevelLayout->setSpacing(0);
|
||||
toplevelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_listWidget->setSpacing(0);
|
||||
m_listWidget->setContentsMargins(0, 0, 0, 0);
|
||||
m_stackWidget->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(toplevelLayout);
|
||||
|
||||
connect(m_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(showWidget(int)));
|
||||
}
|
||||
|
||||
void MyTabbedStackWidget::insertTab(const int index, QWidget *tab, const QIcon &icon, const QString &label)
|
||||
{
|
||||
tab->setContentsMargins(0, 0, 0, 0);
|
||||
m_stackWidget->insertWidget(index, tab);
|
||||
QListWidgetItem *item = new QListWidgetItem(icon, label);
|
||||
item->setToolTip(label);
|
||||
m_listWidget->insertItem(index, item);
|
||||
}
|
||||
|
||||
void MyTabbedStackWidget::removeTab(int index)
|
||||
{
|
||||
m_stackWidget->removeWidget(m_stackWidget->widget(index));
|
||||
QListWidgetItem *item = m_listWidget->item(index);
|
||||
m_listWidget->removeItemWidget(item);
|
||||
delete item;
|
||||
}
|
||||
|
||||
int MyTabbedStackWidget::currentIndex() const
|
||||
{
|
||||
return m_listWidget->currentRow();
|
||||
}
|
||||
|
||||
void MyTabbedStackWidget::setCurrentIndex(int index)
|
||||
{
|
||||
m_listWidget->setCurrentRow(index);
|
||||
}
|
||||
|
||||
void MyTabbedStackWidget::showWidget(int index)
|
||||
{
|
||||
emit currentAboutToShow(index);
|
||||
m_stackWidget->setCurrentIndex(index);
|
||||
emit currentChanged(index);
|
||||
}
|
||||
|
||||
void MyTabbedStackWidget::insertCornerWidget(int index, QWidget *widget)
|
||||
{
|
||||
widget->hide();
|
||||
}
|
||||
|
74
ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h
Normal file
74
ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mytabbedstackwidget.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 MYTABBEDSTACKWIDGET_H
|
||||
#define MYTABBEDSTACKWIDGET_H
|
||||
|
||||
#include "utils/mylistwidget.h"
|
||||
#include <QtGui/QStackedWidget>
|
||||
|
||||
/*
|
||||
* MyTabbedStackWidget is a MyListWidget combined with a QStackedWidget,
|
||||
* similar in function to QTabWidget.
|
||||
*/
|
||||
class QTCREATOR_UTILS_EXPORT MyTabbedStackWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MyTabbedStackWidget(QWidget *parent = 0, bool isVertical = false, bool iconAbove = true);
|
||||
|
||||
void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
|
||||
void removeTab(int index);
|
||||
void setIconSize(int size) { m_listWidget->setIconSize(QSize(size, size)); }
|
||||
|
||||
int currentIndex() const;
|
||||
|
||||
void insertCornerWidget(int index, QWidget *widget);
|
||||
int cornerWidgetCount() { return m_cornerWidgetCount; }
|
||||
|
||||
signals:
|
||||
void currentAboutToShow(int index);
|
||||
void currentChanged(int index);
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(int index);
|
||||
|
||||
private slots:
|
||||
void showWidget(int index);
|
||||
|
||||
private:
|
||||
MyListWidget *m_listWidget;
|
||||
QStackedWidget *m_stackWidget;
|
||||
QWidget *m_selectionWidget;
|
||||
bool m_vertical;
|
||||
bool m_iconAbove;
|
||||
int m_cornerWidgetCount;
|
||||
};
|
||||
|
||||
#endif // MYTABBEDSTACKWIDGET_H
|
48
ground/openpilotgcs/src/libs/utils/mytabwidget.cpp
Normal file
48
ground/openpilotgcs/src/libs/utils/mytabwidget.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mytabwidget.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 "mytabwidget.h"
|
||||
#include <QtGui/QTabBar>
|
||||
|
||||
MyTabWidget::MyTabWidget(QWidget *parent)
|
||||
: QTabWidget(parent)
|
||||
{
|
||||
QTabBar *tabBar = QTabWidget::tabBar();
|
||||
connect(tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(myTabMoved(int,int)));
|
||||
}
|
||||
|
||||
void MyTabWidget::moveTab(int from, int to)
|
||||
{
|
||||
QTabBar *tabBar = QTabWidget::tabBar();
|
||||
tabBar->moveTab(from, to);
|
||||
}
|
||||
|
||||
|
||||
void MyTabWidget::myTabMoved(int from, int to)
|
||||
{
|
||||
emit tabMoved(from, to);
|
||||
}
|
55
ground/openpilotgcs/src/libs/utils/mytabwidget.h
Normal file
55
ground/openpilotgcs/src/libs/utils/mytabwidget.h
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file mytabwidget.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 MYTABWIDGET_H
|
||||
#define MYTABWIDGET_H
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
#include <QtGui/QTabWidget>
|
||||
|
||||
/*
|
||||
* MyTabWidget is a plain QTabWidget with the addition of the signal
|
||||
* tabMoved(int, int) which QTabBar has but for some reason is
|
||||
* not made available from QTabWidget.
|
||||
*/
|
||||
class QTCREATOR_UTILS_EXPORT MyTabWidget : public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MyTabWidget(QWidget *parent = 0);
|
||||
void moveTab(int from, int to);
|
||||
|
||||
private slots:
|
||||
void myTabMoved(int from, int to);
|
||||
|
||||
signals:
|
||||
void tabMoved(int from, int to);
|
||||
};
|
||||
|
||||
#endif // MYTABWIDGET_H
|
@ -45,7 +45,10 @@ SOURCES += reloadpromptutils.cpp \
|
||||
coordinateconversions.cpp \
|
||||
pathutils.cpp \
|
||||
worldmagmodel.cpp \
|
||||
homelocationutil.cpp
|
||||
homelocationutil.cpp \
|
||||
mytabbedstackwidget.cpp \
|
||||
mytabwidget.cpp \
|
||||
mylistwidget.cpp
|
||||
SOURCES += xmlconfig.cpp
|
||||
|
||||
win32 {
|
||||
@ -96,7 +99,10 @@ HEADERS += utils_global.h \
|
||||
coordinateconversions.h \
|
||||
pathutils.h \
|
||||
worldmagmodel.h \
|
||||
homelocationutil.h
|
||||
homelocationutil.h \
|
||||
mytabbedstackwidget.h \
|
||||
mytabwidget.h \
|
||||
mylistwidget.h
|
||||
HEADERS += xmlconfig.h
|
||||
|
||||
FORMS += filewizardpage.ui \
|
||||
|
@ -52,11 +52,11 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
ftw = new FancyTabWidget(this, true);
|
||||
|
||||
ftw = new MyTabbedStackWidget(this, true, true);
|
||||
ftw->setIconSize(64);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(ftw);
|
||||
setLayout(layout);
|
||||
|
||||
|
@ -38,7 +38,8 @@
|
||||
#include <QTextBrowser>
|
||||
#include "utils/pathutils.h"
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
//#include "fancytabwidget.h"
|
||||
#include "utils/mytabbedstackwidget.h"
|
||||
|
||||
|
||||
class ConfigGadgetWidget: public QWidget
|
||||
@ -61,8 +62,7 @@ signals:
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent * event);
|
||||
FancyTabWidget *ftw;
|
||||
|
||||
MyTabbedStackWidget *ftw;
|
||||
};
|
||||
|
||||
#endif // CONFIGGADGETWIDGET_H
|
||||
|
@ -32,36 +32,33 @@
|
||||
#include <coreplugin/iconnection.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
#include "fancyactionbar.h"
|
||||
#include "qextserialport/src/qextserialenumerator.h"
|
||||
#include "qextserialport/src/qextserialport.h"
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
||||
ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, Internal::FancyTabWidget *modeStack) :
|
||||
ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidget *modeStack) :
|
||||
QWidget(mainWindow), // Pip
|
||||
m_availableDevList(0),
|
||||
m_connectBtn(0),
|
||||
m_ioDev(NULL),m_mainWindow(mainWindow)
|
||||
m_ioDev(NULL),
|
||||
m_mainWindow(mainWindow)
|
||||
{
|
||||
// Q_UNUSED(mainWindow);
|
||||
|
||||
QVBoxLayout *top = new QVBoxLayout;
|
||||
/* QVBoxLayout *top = new QVBoxLayout;
|
||||
top->setSpacing(0);
|
||||
top->setMargin(0);
|
||||
top->setMargin(0);*/
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(5,0,5,0);
|
||||
layout->addWidget(new QLabel("Connections: "));
|
||||
layout->setSpacing(5);
|
||||
layout->setContentsMargins(5,5,5,5);
|
||||
layout->addWidget(new QLabel(tr("Connections:")));
|
||||
|
||||
m_availableDevList = new QComboBox;
|
||||
//m_availableDevList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
@ -70,17 +67,18 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, Internal:
|
||||
m_availableDevList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
layout->addWidget(m_availableDevList);
|
||||
|
||||
m_connectBtn = new QPushButton("Connect");
|
||||
m_connectBtn = new QPushButton(tr("Connect"));
|
||||
m_connectBtn->setEnabled(false);
|
||||
layout->addWidget(m_connectBtn);
|
||||
|
||||
Utils::StyledBar *bar = new Utils::StyledBar;
|
||||
/* Utils::StyledBar *bar = new Utils::StyledBar;
|
||||
bar->setLayout(layout);
|
||||
|
||||
top->addWidget(bar);
|
||||
setLayout(top);
|
||||
top->addWidget(bar);*/
|
||||
setLayout(layout);
|
||||
|
||||
modeStack->insertCornerWidget(modeStack->cornerWidgetCount()-1, this);
|
||||
// modeStack->insertCornerWidget(modeStack->cornerWidgetCount()-1, this);
|
||||
modeStack->setCornerWidget(this, Qt::TopRightCorner);
|
||||
|
||||
QObject::connect(m_connectBtn, SIGNAL(pressed()), this, SLOT(onConnectPressed()));
|
||||
}
|
||||
|
@ -40,6 +40,10 @@
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTabWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IConnection;
|
||||
@ -65,7 +69,7 @@ class CORE_EXPORT ConnectionManager : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConnectionManager(Internal::MainWindow *mainWindow, Internal::FancyTabWidget *modeStack);
|
||||
ConnectionManager(Internal::MainWindow *mainWindow, QTabWidget *modeStack);
|
||||
virtual ~ConnectionManager();
|
||||
|
||||
void init();
|
||||
|
@ -187,9 +187,9 @@ void CoreImpl::openFiles(const QStringList &arguments)
|
||||
//m_mainwindow->openFiles(arguments);
|
||||
}
|
||||
|
||||
void CoreImpl::readMainSettings(QSettings* qs)
|
||||
void CoreImpl::readMainSettings(QSettings* qs, bool workspaceDiffOnly)
|
||||
{
|
||||
m_mainwindow->readSettings(qs);
|
||||
m_mainwindow->readSettings(qs, workspaceDiffOnly);
|
||||
}
|
||||
|
||||
void CoreImpl::saveMainSettings(QSettings* qs)
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
|
||||
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
|
||||
SettingsDatabase *settingsDatabase() const;
|
||||
void readMainSettings(QSettings* qs);
|
||||
void readMainSettings(QSettings* qs, bool workspaceDiffOnly);
|
||||
void saveMainSettings(QSettings* qs);
|
||||
void readSettings(IConfigurablePlugin* plugin, QSettings* qs = 0 );
|
||||
void saveSettings(IConfigurablePlugin* plugin, QSettings* qs = 0 );
|
||||
|
@ -24,10 +24,8 @@ SOURCES += mainwindow.cpp \
|
||||
uniqueidmanager.cpp \
|
||||
messagemanager.cpp \
|
||||
messageoutputwindow.cpp \
|
||||
viewmanager.cpp \
|
||||
versiondialog.cpp \
|
||||
iuavgadget.cpp \
|
||||
uavgadgetmode.cpp \
|
||||
uavgadgetmanager/uavgadgetmanager.cpp \
|
||||
uavgadgetmanager/uavgadgetview.cpp \
|
||||
uavgadgetmanager/splitterorview.cpp \
|
||||
@ -73,9 +71,7 @@ HEADERS += mainwindow.h \
|
||||
uniqueidmanager.h \
|
||||
messagemanager.h \
|
||||
messageoutputwindow.h \
|
||||
viewmanager.h \
|
||||
iuavgadget.h \
|
||||
uavgadgetmode.h \
|
||||
iuavgadgetfactory.h \
|
||||
uavgadgetmanager/uavgadgetmanager.h \
|
||||
uavgadgetmanager/uavgadgetview.h \
|
||||
|
@ -44,9 +44,10 @@ using namespace Utils;
|
||||
using namespace Core::Internal;
|
||||
|
||||
GeneralSettings::GeneralSettings():
|
||||
m_dialog(0),
|
||||
m_saveSettingsOnExit(true),
|
||||
m_autoConnect(true),m_autoSelect(true)
|
||||
m_dialog(0),
|
||||
m_autoConnect(true),
|
||||
m_autoSelect(true)
|
||||
{
|
||||
}
|
||||
|
||||
@ -119,24 +120,9 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
|
||||
m_page->checkAutoConnect->setChecked(m_autoConnect);
|
||||
m_page->checkAutoSelect->setChecked(m_autoSelect);
|
||||
m_page->colorButton->setColor(StyleHelper::baseColor());
|
||||
#ifdef Q_OS_UNIX
|
||||
m_page->terminalEdit->setText(ConsoleProcess::terminalEmulator(Core::ICore::instance()->settings()));
|
||||
#else
|
||||
m_page->terminalLabel->hide();
|
||||
m_page->terminalEdit->hide();
|
||||
m_page->resetTerminalButton->hide();
|
||||
#endif
|
||||
|
||||
connect(m_page->resetButton, SIGNAL(clicked()),
|
||||
this, SLOT(resetInterfaceColor()));
|
||||
connect(m_page->resetEditorButton, SIGNAL(clicked()),
|
||||
this, SLOT(resetExternalEditor()));
|
||||
connect(m_page->helpExternalEditorButton, SIGNAL(clicked()),
|
||||
this, SLOT(showHelpForExternalEditor()));
|
||||
#ifdef Q_OS_UNIX
|
||||
connect(m_page->resetTerminalButton, SIGNAL(clicked()),
|
||||
this, SLOT(resetTerminal()));
|
||||
#endif
|
||||
|
||||
return w;
|
||||
}
|
||||
@ -151,11 +137,6 @@ void GeneralSettings::apply()
|
||||
m_saveSettingsOnExit = m_page->checkBoxSaveOnExit->isChecked();
|
||||
m_autoConnect = m_page->checkAutoConnect->isChecked();
|
||||
m_autoSelect = m_page->checkAutoSelect->isChecked();
|
||||
#ifdef Q_OS_UNIX
|
||||
ConsoleProcess::setTerminalEmulator(Core::ICore::instance()->settings(),
|
||||
m_page->terminalEdit->text());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void GeneralSettings::finish()
|
||||
@ -171,7 +152,6 @@ void GeneralSettings::readSettings(QSettings* qs)
|
||||
m_autoConnect = qs->value(QLatin1String("AutoConnect"),m_autoConnect).toBool();
|
||||
m_autoSelect = qs->value(QLatin1String("AutoSelect"),m_autoSelect).toBool();
|
||||
qs->endGroup();
|
||||
|
||||
}
|
||||
|
||||
void GeneralSettings::saveSettings(QSettings* qs)
|
||||
@ -194,17 +174,6 @@ void GeneralSettings::resetInterfaceColor()
|
||||
m_page->colorButton->setColor(0x666666);
|
||||
}
|
||||
|
||||
void GeneralSettings::resetExternalEditor()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
void GeneralSettings::resetTerminal()
|
||||
{
|
||||
m_page->terminalEdit->setText(ConsoleProcess::defaultTerminalEmulator() + QLatin1String(" -e"));
|
||||
}
|
||||
#endif
|
||||
|
||||
void GeneralSettings::showHelpForExternalEditor()
|
||||
{
|
||||
if (m_dialog) {
|
||||
@ -238,10 +207,11 @@ QString GeneralSettings::language() const
|
||||
|
||||
void GeneralSettings::setLanguage(const QString &locale)
|
||||
{
|
||||
if (m_language != locale)
|
||||
{
|
||||
if (m_language != locale) {
|
||||
if (!locale.isEmpty()) {
|
||||
QMessageBox::information((QWidget*)Core::ICore::instance()->mainWindow(), tr("Restart required"),
|
||||
tr("The language change will take effect after a restart of the OpenPilot GCS."));
|
||||
}
|
||||
m_language = locale;
|
||||
}
|
||||
}
|
||||
|
@ -61,15 +61,13 @@ public:
|
||||
void readSettings(QSettings* qs);
|
||||
void saveSettings(QSettings* qs);
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
void resetInterfaceColor();
|
||||
void resetLanguage();
|
||||
void resetExternalEditor();
|
||||
void showHelpForExternalEditor();
|
||||
void slotAutoConnect(int);
|
||||
#ifdef Q_OS_UNIX
|
||||
void resetTerminal();
|
||||
#endif
|
||||
|
||||
private:
|
||||
void fillLanguageBox() const;
|
||||
|
@ -17,33 +17,6 @@
|
||||
<string>General settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="terminalLabel">
|
||||
<property name="text">
|
||||
<string>Terminal:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>External editor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>When files are externally modified:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="terminalEdit"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="colorLabel">
|
||||
<property name="text">
|
||||
@ -51,44 +24,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="resetTerminalButton">
|
||||
<property name="toolTip">
|
||||
<string>Reset to default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="core.qrc">
|
||||
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLineEdit" name="externalEditorEdit"/>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<widget class="QToolButton" name="resetEditorButton">
|
||||
<property name="toolTip">
|
||||
<string>Reset to default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="core.qrc">
|
||||
<normaloff>:/core/images/reset.png</normaloff>:/core/images/reset.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="3">
|
||||
<widget class="QToolButton" name="helpExternalEditorButton">
|
||||
<property name="text">
|
||||
<string>?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
@ -144,53 +79,12 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="reloadBehavior">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Always ask</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Reload all modified files</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ignore modifications</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>132</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -221,7 +115,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxSaveOnExit">
|
||||
<property name="text">
|
||||
<string/>
|
||||
@ -231,27 +125,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Save configuration settings on on exit</string>
|
||||
<string>Save configuration settings on exit:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Automatically connect an OpenPilot USB device</string>
|
||||
<string>Automatically connect an OpenPilot USB device:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="QCheckBox" name="checkAutoConnect">
|
||||
<property name="text">
|
||||
<string/>
|
||||
@ -261,17 +155,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Automatically select an OpenPilot USB device</string>
|
||||
<string>Automatically select an OpenPilot USB device:</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<item row="11" column="1">
|
||||
<widget class="QCheckBox" name="checkAutoSelect">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
|
||||
virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0;
|
||||
virtual SettingsDatabase *settingsDatabase() const = 0;
|
||||
virtual void readMainSettings(QSettings* qs) = 0;
|
||||
virtual void readMainSettings(QSettings* qs, bool workspaceDiffOnly = false) = 0;
|
||||
virtual void saveMainSettings(QSettings* qs) = 0;
|
||||
virtual void readSettings(IConfigurablePlugin* plugin, QSettings* qs = 0) = 0;
|
||||
virtual void saveSettings(IConfigurablePlugin* plugin, QSettings* qs = 0) = 0;
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
virtual QString name() const = 0;
|
||||
virtual QIcon icon() const = 0;
|
||||
virtual int priority() const = 0;
|
||||
virtual void setPriority(int priority) = 0;
|
||||
virtual const char *uniqueModeName() const = 0;
|
||||
};
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "connectionmanager.h"
|
||||
#include "coreimpl.h"
|
||||
#include "coreconstants.h"
|
||||
#include "fancytabwidget.h"
|
||||
#include "utils/mytabwidget.h"
|
||||
#include "generalsettings.h"
|
||||
#include "messagemanager.h"
|
||||
#include "modemanager.h"
|
||||
@ -43,7 +43,6 @@
|
||||
#include "qxtlogger.h"
|
||||
#include "qxtbasicstdloggerengine.h"
|
||||
#include "shortcutsettings.h"
|
||||
#include "uavgadgetmode.h"
|
||||
#include "uavgadgetmanager.h"
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
#include "workspacesettings.h"
|
||||
@ -60,7 +59,6 @@
|
||||
#include "uniqueidmanager.h"
|
||||
#include "variablemanager.h"
|
||||
#include "versiondialog.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
#include <coreplugin/settingsdatabase.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
@ -123,7 +121,6 @@ MainWindow::MainWindow() :
|
||||
m_actionManager(new ActionManagerPrivate(this)),
|
||||
m_variableManager(new VariableManager(this)),
|
||||
m_threadManager(new ThreadManager(this)),
|
||||
m_viewManager(0),
|
||||
m_modeManager(0),
|
||||
m_connectionManager(0),
|
||||
m_mimeDatabase(new MimeDatabase),
|
||||
@ -178,17 +175,25 @@ MainWindow::MainWindow() :
|
||||
registerDefaultContainers();
|
||||
registerDefaultActions();
|
||||
|
||||
m_modeStack = new FancyTabWidget(this);
|
||||
m_modeStack = new MyTabWidget(this);
|
||||
m_modeStack->setIconSize(QSize(24,24));
|
||||
m_modeStack->setTabPosition(QTabWidget::South);
|
||||
m_modeStack->setMovable(false);
|
||||
#ifndef Q_WS_MAC
|
||||
m_modeStack->setDocumentMode(true);
|
||||
#endif
|
||||
m_modeManager = new ModeManager(this, m_modeStack);
|
||||
|
||||
m_connectionManager = new ConnectionManager(this, m_modeStack);
|
||||
|
||||
m_viewManager = new ViewManager(this);
|
||||
m_messageManager = new MessageManager;
|
||||
setCentralWidget(m_modeStack);
|
||||
|
||||
connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)),
|
||||
this, SLOT(updateFocusWidget(QWidget*,QWidget*)));
|
||||
connect(m_workspaceSettings, SIGNAL(tabBarSettingsApplied(QTabWidget::TabPosition,bool)),
|
||||
this, SLOT(applyTabBarSettings(QTabWidget::TabPosition,bool)));
|
||||
connect(m_modeManager, SIGNAL(newModeOrder(QVector<IMode*>)), m_workspaceSettings, SLOT(newModeOrder(QVector<IMode*>)));
|
||||
|
||||
// setUnifiedTitleAndToolBarOnMac(true);
|
||||
#ifdef Q_OS_UNIX
|
||||
@ -218,8 +223,8 @@ MainWindow::~MainWindow()
|
||||
foreach (QString engine, qxtLog->allLoggerEngines())
|
||||
qxtLog->removeLoggerEngine(engine);
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
if (m_uavGadgetModes.count() > 0) {
|
||||
foreach (UAVGadgetMode *mode, m_uavGadgetModes)
|
||||
if (m_uavGadgetManagers.count() > 0) {
|
||||
foreach (UAVGadgetManager *mode, m_uavGadgetManagers)
|
||||
{
|
||||
pm->removeObject(mode);
|
||||
delete mode;
|
||||
@ -242,9 +247,6 @@ MainWindow::~MainWindow()
|
||||
delete m_uniqueIDManager;
|
||||
m_uniqueIDManager = 0;
|
||||
|
||||
delete m_viewManager;
|
||||
m_viewManager = 0;
|
||||
|
||||
pm->removeObject(m_coreImpl);
|
||||
delete m_coreImpl;
|
||||
m_coreImpl = 0;
|
||||
@ -264,7 +266,6 @@ bool MainWindow::init(QString *errorMessage)
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
pm->addObject(m_coreImpl);
|
||||
m_viewManager->init();
|
||||
m_modeManager->init();
|
||||
m_connectionManager->init();
|
||||
|
||||
@ -393,7 +394,7 @@ IContext *MainWindow::currentContextObject() const
|
||||
|
||||
QStatusBar *MainWindow::statusBar() const
|
||||
{
|
||||
return m_modeStack->statusBar();
|
||||
return new QStatusBar();// m_modeStack->statusBar();
|
||||
}
|
||||
|
||||
void MainWindow::registerDefaultContainers()
|
||||
@ -669,6 +670,60 @@ void MainWindow::registerDefaultActions()
|
||||
connect(m_toggleFullScreenAction, SIGNAL(triggered(bool)), this, SLOT(setFullScreen(bool)));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* UavGadgetManager Actions
|
||||
*/
|
||||
const QList<int> uavGadgetManagerContext =
|
||||
QList<int>() << CoreImpl::instance()->uniqueIDManager()->uniqueIdentifier(Constants::C_UAVGADGETMANAGER);
|
||||
//Window menu separators
|
||||
QAction *tmpaction1 = new QAction(this);
|
||||
tmpaction1->setSeparator(true);
|
||||
cmd = am->registerAction(tmpaction1, QLatin1String("OpenPilot.Window.Sep.Split"), uavGadgetManagerContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_HIDE_TOOLBAR);
|
||||
|
||||
m_showToolbarsAction = new QAction(tr("Edit Gadgets Mode"), this);
|
||||
m_showToolbarsAction->setCheckable(true);
|
||||
cmd = am->registerAction(m_showToolbarsAction, Constants::HIDE_TOOLBARS, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F10")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_HIDE_TOOLBAR);
|
||||
|
||||
//Window menu separators
|
||||
QAction *tmpaction2 = new QAction(this);
|
||||
tmpaction2->setSeparator(true);
|
||||
cmd = am->registerAction(tmpaction2, QLatin1String("OpenPilot.Window.Sep.Split2"), uavGadgetManagerContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
QString prefix = tr("Meta+Shift");
|
||||
#else
|
||||
QString prefix = tr("Ctrl+Shift");
|
||||
#endif
|
||||
|
||||
m_splitAction = new QAction(tr("Split"), this);
|
||||
cmd = am->registerAction(m_splitAction, Constants::SPLIT, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+Down").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
|
||||
m_splitSideBySideAction = new QAction(tr("Split Side by Side"), this);
|
||||
cmd = am->registerAction(m_splitSideBySideAction, Constants::SPLIT_SIDE_BY_SIDE, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+Right").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
|
||||
m_removeCurrentSplitAction = new QAction(tr("Close Current View"), this);
|
||||
cmd = am->registerAction(m_removeCurrentSplitAction, Constants::REMOVE_CURRENT_SPLIT, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+C").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
|
||||
m_removeAllSplitsAction = new QAction(tr("Close All Other Views"), this);
|
||||
cmd = am->registerAction(m_removeAllSplitsAction, Constants::REMOVE_ALL_SPLITS, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+A").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
|
||||
m_gotoOtherSplitAction = new QAction(tr("Goto Next View"), this);
|
||||
cmd = am->registerAction(m_gotoOtherSplitAction, Constants::GOTO_OTHER_SPLIT, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+N").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
|
||||
//Help Action
|
||||
tmpaction = new QAction(QIcon(Constants::ICON_HELP), tr("&Help..."), this);
|
||||
cmd = am->registerAction(tmpaction, Constants::G_HELP_HELP, m_globalContext);
|
||||
@ -807,6 +862,12 @@ void MainWindow::openFileWith()
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::applyTabBarSettings(QTabWidget::TabPosition pos, bool movable) {
|
||||
if (m_modeStack->tabPosition() != pos)
|
||||
m_modeStack->setTabPosition(pos);
|
||||
m_modeStack->setMovable(movable);
|
||||
}
|
||||
|
||||
ActionManager *MainWindow::actionManager() const
|
||||
{
|
||||
return m_actionManager;
|
||||
@ -845,12 +906,6 @@ ConnectionManager *MainWindow::connectionManager() const
|
||||
return m_connectionManager;
|
||||
}
|
||||
|
||||
void MainWindow::addUAVGadgetManager(UAVGadgetManager *manager)
|
||||
{
|
||||
if (!m_uavGadgetManagers.contains(manager))
|
||||
m_uavGadgetManagers.append(manager);
|
||||
}
|
||||
|
||||
QList<UAVGadgetManager*> MainWindow::uavGadgetManagers() const
|
||||
{
|
||||
return m_uavGadgetManagers;
|
||||
@ -986,40 +1041,83 @@ void MainWindow::shutdown()
|
||||
uavGadgetInstanceManager()->removeAllGadgets();
|
||||
}
|
||||
|
||||
void MainWindow::createWorkspaces() {
|
||||
/* Enable/disable menus for uavgadgets */
|
||||
void MainWindow::showUavGadgetMenus(bool show, bool hasSplitter)
|
||||
{
|
||||
m_showToolbarsAction->setChecked(show);
|
||||
m_splitAction->setEnabled(show);
|
||||
m_splitSideBySideAction->setEnabled(show);
|
||||
m_removeCurrentSplitAction->setEnabled(show && hasSplitter);
|
||||
m_removeAllSplitsAction->setEnabled(show && hasSplitter);
|
||||
m_gotoOtherSplitAction->setEnabled(show && hasSplitter);
|
||||
}
|
||||
|
||||
inline int takeLeastPriorityUavGadgetManager(const QList<Core::UAVGadgetManager*> m_uavGadgetManagers) {
|
||||
int index = 0;
|
||||
int prio = m_uavGadgetManagers.at(0)->priority();
|
||||
for (int i = 0; i < m_uavGadgetManagers.count(); i++) {
|
||||
int prio2 = m_uavGadgetManagers.at(i)->priority();
|
||||
if (prio2 < prio) {
|
||||
prio = prio2;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void MainWindow::createWorkspaces(QSettings* qs, bool diffOnly) {
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
|
||||
UAVGadgetMode *uavGadgetMode;
|
||||
Core::UAVGadgetManager *uavGadgetManager;
|
||||
|
||||
while (!m_uavGadgetModes.isEmpty()){
|
||||
pm->removeObject(m_uavGadgetModes.takeFirst());
|
||||
}
|
||||
while (!m_uavGadgetManagers.isEmpty()){
|
||||
Core::UAVGadgetManager* uavGadgetManager = m_uavGadgetManagers.takeLast();
|
||||
uavGadgetManager->removeAllSplits();
|
||||
// TODO Fixthis: This only happens, when settings are reloaded.
|
||||
// then the old GadgetManagers should be deleted, but if
|
||||
// I delete them the GCS segfaults.
|
||||
//delete uavGadgetManager;
|
||||
}
|
||||
m_uavGadgetManagers.clear();
|
||||
m_uavGadgetModes.clear();
|
||||
for (int i = 0; i < m_workspaceSettings->numberOfWorkspaces(); ++i) {
|
||||
// If diffOnly is true, we only add/remove the number of workspaces
|
||||
// that has changed,
|
||||
// otherwise a complete reload of workspaces is done
|
||||
int toRemoveFirst = m_uavGadgetManagers.count();
|
||||
int newWorkspacesNo = m_workspaceSettings->numberOfWorkspaces();
|
||||
if (diffOnly && m_uavGadgetManagers.count() > newWorkspacesNo)
|
||||
toRemoveFirst = m_uavGadgetManagers.count() - newWorkspacesNo;
|
||||
else
|
||||
toRemoveFirst = 0;
|
||||
|
||||
int removed = 0;
|
||||
|
||||
while (!m_uavGadgetManagers.isEmpty() && (toRemoveFirst > removed)) {
|
||||
int index = takeLeastPriorityUavGadgetManager(m_uavGadgetManagers);
|
||||
uavGadgetManager = m_uavGadgetManagers.takeAt(index);
|
||||
uavGadgetManager->removeAllSplits();
|
||||
pm->removeObject(uavGadgetManager);
|
||||
delete uavGadgetManager;
|
||||
removed++;
|
||||
}
|
||||
|
||||
int start = 0;
|
||||
if (diffOnly) {
|
||||
start = m_uavGadgetManagers.count();
|
||||
} else {
|
||||
m_uavGadgetManagers.clear();
|
||||
}
|
||||
for (int i = start; i < newWorkspacesNo; ++i) {
|
||||
|
||||
uavGadgetManager = new Core::UAVGadgetManager(CoreImpl::instance(), this);
|
||||
uavGadgetManager->hide();
|
||||
const QString name = m_workspaceSettings->name(i);
|
||||
const QString iconName = m_workspaceSettings->iconName(i);
|
||||
const QString modeName = m_workspaceSettings->modeName(i);
|
||||
uavGadgetManager = new Core::UAVGadgetManager(CoreImpl::instance(), name,
|
||||
QIcon(iconName), 90-i+1, modeName, this);
|
||||
|
||||
uavGadgetMode = new UAVGadgetMode(uavGadgetManager, name,
|
||||
QIcon(iconName), 90-i+1, modeName);
|
||||
uavGadgetManager->setUAVGadgetMode(uavGadgetMode);
|
||||
m_uavGadgetModes.append(uavGadgetMode);
|
||||
pm->addObject(uavGadgetMode);
|
||||
addUAVGadgetManager(uavGadgetManager);
|
||||
connect(uavGadgetManager, SIGNAL(showUavGadgetMenus(bool, bool)), this, SLOT(showUavGadgetMenus(bool, bool)));
|
||||
|
||||
connect(m_showToolbarsAction, SIGNAL(triggered(bool)), uavGadgetManager, SLOT(showToolbars(bool)));
|
||||
connect(m_splitAction, SIGNAL(triggered()), uavGadgetManager, SLOT(split()));
|
||||
connect(m_splitSideBySideAction, SIGNAL(triggered()), uavGadgetManager, SLOT(splitSideBySide()));
|
||||
connect(m_removeCurrentSplitAction, SIGNAL(triggered()), uavGadgetManager, SLOT(removeCurrentSplit()));
|
||||
connect(m_removeAllSplitsAction, SIGNAL(triggered()), uavGadgetManager, SLOT(removeAllSplits()));
|
||||
connect(m_gotoOtherSplitAction, SIGNAL(triggered()), uavGadgetManager, SLOT(gotoOtherSplit()));
|
||||
|
||||
pm->addObject(uavGadgetManager);
|
||||
m_uavGadgetManagers.append(uavGadgetManager);
|
||||
uavGadgetManager->readSettings(qs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1028,13 +1126,19 @@ static const char *geometryKey = "Geometry";
|
||||
static const char *colorKey = "Color";
|
||||
static const char *maxKey = "Maximized";
|
||||
static const char *fullScreenKey = "FullScreen";
|
||||
static const char *modePriorities = "ModePriorities";
|
||||
|
||||
void MainWindow::readSettings(QSettings* qs)
|
||||
void MainWindow::readSettings(QSettings* qs, bool workspaceDiffOnly)
|
||||
{
|
||||
if ( !qs ){
|
||||
qs = m_settings;
|
||||
}
|
||||
|
||||
if (workspaceDiffOnly) {
|
||||
createWorkspaces(qs, workspaceDiffOnly);
|
||||
return;
|
||||
}
|
||||
|
||||
m_generalSettings->readSettings(qs);
|
||||
m_actionManager->readSettings(qs);
|
||||
|
||||
@ -1056,13 +1160,18 @@ void MainWindow::readSettings(QSettings* qs)
|
||||
|
||||
m_workspaceSettings->readSettings(qs);
|
||||
|
||||
createWorkspaces();
|
||||
createWorkspaces(qs);
|
||||
|
||||
foreach (UAVGadgetManager *manager, m_uavGadgetManagers) {
|
||||
manager->readSettings(qs);
|
||||
// Read tab ordering
|
||||
qs->beginGroup(QLatin1String(modePriorities));
|
||||
QStringList modeNames = qs->childKeys();
|
||||
QMap<QString, int> map;
|
||||
foreach (QString modeName, modeNames) {
|
||||
map.insert(modeName, qs->value(modeName).toInt());
|
||||
}
|
||||
m_modeManager->reorderModes(map);
|
||||
|
||||
m_viewManager->readSettings(qs);
|
||||
qs->endGroup();
|
||||
|
||||
}
|
||||
|
||||
@ -1092,11 +1201,18 @@ void MainWindow::saveSettings(QSettings* qs)
|
||||
|
||||
qs->endGroup();
|
||||
|
||||
// Write tab ordering
|
||||
qs->beginGroup(QLatin1String(modePriorities));
|
||||
QVector<IMode*> modes = m_modeManager->modes();
|
||||
foreach (IMode *mode, modes) {
|
||||
qs->setValue(QLatin1String(mode->uniqueModeName()), mode->priority());
|
||||
}
|
||||
qs->endGroup();
|
||||
|
||||
foreach (UAVGadgetManager *manager, m_uavGadgetManagers) {
|
||||
manager->saveSettings(qs);
|
||||
}
|
||||
|
||||
m_viewManager->saveSettings(qs);
|
||||
m_actionManager->saveSettings(qs);
|
||||
m_generalSettings->saveSettings(qs);
|
||||
|
||||
|
@ -40,6 +40,7 @@ QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
class QShortcut;
|
||||
class QToolButton;
|
||||
class MyTabWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
@ -73,10 +74,8 @@ class FancyTabWidget;
|
||||
class GeneralSettings;
|
||||
class ShortcutSettings;
|
||||
class WorkspaceSettings;
|
||||
class ViewManager;
|
||||
class VersionDialog;
|
||||
class AuthorsDialog;
|
||||
class UAVGadgetMode;
|
||||
|
||||
class CORE_EXPORT MainWindow : public EventFilteringMainWindow
|
||||
{
|
||||
@ -94,7 +93,7 @@ public:
|
||||
void addContextObject(IContext *contex);
|
||||
void removeContextObject(IContext *contex);
|
||||
void resetContext();
|
||||
void readSettings(QSettings* qs = 0);
|
||||
void readSettings(QSettings* qs = 0, bool workspaceDiffOnly = false);
|
||||
void saveSettings(QSettings* qs = 0);
|
||||
void readSettings(IConfigurablePlugin* plugin, QSettings* qs = 0);
|
||||
void saveSettings(IConfigurablePlugin* plugin, QSettings* qs = 0);
|
||||
@ -162,14 +161,14 @@ private slots:
|
||||
void destroyVersionDialog();
|
||||
void destroyAuthorsDialog();
|
||||
void modeChanged(Core::IMode *mode);
|
||||
void showUavGadgetMenus(bool show, bool hasSplitter);
|
||||
void applyTabBarSettings(QTabWidget::TabPosition pos, bool movable);
|
||||
|
||||
private:
|
||||
void addUAVGadgetManager(Core::UAVGadgetManager *manager);
|
||||
void updateContextObject(IContext *context);
|
||||
void registerDefaultContainers();
|
||||
void registerDefaultActions();
|
||||
|
||||
void createWorkspaces();
|
||||
void createWorkspaces(QSettings* qs, bool diffOnly = false);
|
||||
|
||||
CoreImpl *m_coreImpl;
|
||||
UniqueIDManager *m_uniqueIDManager;
|
||||
@ -183,15 +182,12 @@ private:
|
||||
MessageManager *m_messageManager;
|
||||
VariableManager *m_variableManager;
|
||||
ThreadManager *m_threadManager;
|
||||
ViewManager *m_viewManager;
|
||||
ModeManager *m_modeManager;
|
||||
QList<UAVGadgetManager*> m_uavGadgetManagers;
|
||||
QList<UAVGadgetMode*> m_uavGadgetModes;
|
||||
UAVGadgetInstanceManager *m_uavGadgetInstanceManager;
|
||||
ConnectionManager *m_connectionManager;
|
||||
MimeDatabase *m_mimeDatabase;
|
||||
FancyTabWidget *m_modeStack;
|
||||
// RightPaneWidget *m_rightPaneWidget;
|
||||
MyTabWidget *m_modeStack;
|
||||
Core::BaseView *m_outputView;
|
||||
VersionDialog *m_versionDialog;
|
||||
AuthorsDialog *m_authorsDialog;
|
||||
@ -213,6 +209,14 @@ private:
|
||||
QAction *m_exitAction;
|
||||
QAction *m_optionsAction;
|
||||
QAction *m_toggleFullScreenAction;
|
||||
// UavGadgetManager actions
|
||||
QAction *m_showToolbarsAction;
|
||||
QAction *m_splitAction;
|
||||
QAction *m_splitSideBySideAction;
|
||||
QAction *m_removeCurrentSplitAction;
|
||||
QAction *m_removeAllSplitsAction;
|
||||
QAction *m_gotoOtherSplitAction;
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
QAction *m_minimizeAction;
|
||||
QAction *m_zoomAction;
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
#include "fancyactionbar.h"
|
||||
#include "utils/mytabwidget.h"
|
||||
#include "icore.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
@ -59,18 +60,17 @@ using namespace Core::Internal;
|
||||
|
||||
ModeManager *ModeManager::m_instance = 0;
|
||||
|
||||
ModeManager::ModeManager(Internal::MainWindow *mainWindow, FancyTabWidget *modeStack) :
|
||||
ModeManager::ModeManager(Internal::MainWindow *mainWindow, MyTabWidget *modeStack) :
|
||||
m_mainWindow(mainWindow),
|
||||
m_modeStack(modeStack),
|
||||
m_signalMapper(new QSignalMapper(this))
|
||||
m_signalMapper(new QSignalMapper(this)),
|
||||
m_isReprioritizing(false)
|
||||
{
|
||||
m_instance = this;
|
||||
|
||||
m_actionBar = new FancyActionBar(modeStack);
|
||||
// m_modeStack->addCornerWidget(m_actionBar);
|
||||
|
||||
connect(m_modeStack, SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
|
||||
connect(m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
||||
// connect((m_modeStack), SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
|
||||
connect(m_modeStack, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
||||
connect(m_modeStack, SIGNAL(tabMoved(int,int)), this, SLOT(tabMoved(int,int)));
|
||||
connect(m_signalMapper, SIGNAL(mapped(QString)), this, SLOT(activateMode(QString)));
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ void ModeManager::addWidget(QWidget *widget)
|
||||
// We want the actionbar to stay on the bottom
|
||||
// so m_modeStack->cornerWidgetCount() -1 inserts it at the position immediately above
|
||||
// the actionbar
|
||||
m_modeStack->insertCornerWidget(m_modeStack->cornerWidgetCount() -1, widget);
|
||||
// m_modeStack->insertCornerWidget(m_modeStack->cornerWidgetCount() -1, widget);
|
||||
}
|
||||
|
||||
IMode *ModeManager::currentMode() const
|
||||
@ -150,6 +150,14 @@ void ModeManager::objectAdded(QObject *obj)
|
||||
|
||||
m_modeShortcuts.insert(index, cmd);
|
||||
connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updateModeToolTip()));
|
||||
|
||||
setDefaultKeyshortcuts();
|
||||
|
||||
m_signalMapper->setMapping(shortcut, mode->uniqueModeName());
|
||||
connect(shortcut, SIGNAL(activated()), m_signalMapper, SLOT(map()));
|
||||
}
|
||||
|
||||
void ModeManager::setDefaultKeyshortcuts() {
|
||||
for (int i = 0; i < m_modeShortcuts.size(); ++i) {
|
||||
Command *currentCmd = m_modeShortcuts.at(i);
|
||||
bool currentlyHasDefaultSequence = (currentCmd->keySequence()
|
||||
@ -162,9 +170,6 @@ void ModeManager::objectAdded(QObject *obj)
|
||||
if (currentlyHasDefaultSequence)
|
||||
currentCmd->setKeySequence(currentCmd->defaultKeySequence());
|
||||
}
|
||||
|
||||
m_signalMapper->setMapping(shortcut, mode->uniqueModeName());
|
||||
connect(shortcut, SIGNAL(activated()), m_signalMapper, SLOT(map()));
|
||||
}
|
||||
|
||||
void ModeManager::updateModeToolTip()
|
||||
@ -182,7 +187,8 @@ void ModeManager::updateModeNameIcon(IMode *mode, const QIcon &icon, const QStri
|
||||
int index = indexOf(mode->uniqueModeName());
|
||||
if (index < 0)
|
||||
return;
|
||||
m_modeStack->updateTabNameIcon(index, icon, label);
|
||||
m_modeStack->setTabIcon(index, icon);
|
||||
m_modeStack->setTabText(index, label);
|
||||
}
|
||||
|
||||
void ModeManager::aboutToRemoveObject(QObject *obj)
|
||||
@ -194,7 +200,9 @@ void ModeManager::aboutToRemoveObject(QObject *obj)
|
||||
const int index = m_modes.indexOf(mode);
|
||||
m_modes.remove(index);
|
||||
m_modeShortcuts.remove(index);
|
||||
disconnect(m_modeStack, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
||||
m_modeStack->removeTab(index);
|
||||
connect(m_modeStack, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
||||
|
||||
m_mainWindow->removeContextObject(mode);
|
||||
}
|
||||
@ -209,7 +217,7 @@ void ModeManager::addAction(Command *command, int priority, QMenu *menu)
|
||||
if (p > priority)
|
||||
++index;
|
||||
|
||||
m_actionBar->insertAction(index, command->action(), menu);
|
||||
// m_actionBar->insertAction(index, command->action(), menu);
|
||||
}
|
||||
|
||||
void ModeManager::currentTabAboutToChange(int index)
|
||||
@ -223,6 +231,7 @@ void ModeManager::currentTabAboutToChange(int index)
|
||||
|
||||
void ModeManager::currentTabChanged(int index)
|
||||
{
|
||||
// qDebug() << "Current tab changed " << index;
|
||||
// Tab index changes to -1 when there is no tab left.
|
||||
if (index >= 0) {
|
||||
IMode *mode = m_modes.at(index);
|
||||
@ -242,6 +251,53 @@ void ModeManager::currentTabChanged(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void ModeManager::tabMoved(int from, int to)
|
||||
{
|
||||
IMode *mode = m_modes.at(from);
|
||||
m_modes.remove(from);
|
||||
m_modes.insert(to, mode);
|
||||
Command *cmd = m_modeShortcuts.at(from);
|
||||
m_modeShortcuts.remove(from);
|
||||
m_modeShortcuts.insert(to, cmd);
|
||||
setDefaultKeyshortcuts();
|
||||
// Reprioritize, high priority means show to the left
|
||||
if (!m_isReprioritizing) {
|
||||
for (int i = 0; i < m_modes.count(); ++i) {
|
||||
m_modes.at(i)->setPriority(100-i);
|
||||
}
|
||||
emit newModeOrder(m_modes);
|
||||
}
|
||||
}
|
||||
|
||||
void ModeManager::reorderModes(QMap<QString, int> priorities)
|
||||
{
|
||||
foreach (IMode *mode, m_modes)
|
||||
mode->setPriority(priorities.value(QString(QLatin1String(mode->uniqueModeName())), mode->priority()));
|
||||
|
||||
m_isReprioritizing = true;
|
||||
IMode *current = currentMode();
|
||||
// Bubble sort
|
||||
bool swapped = false;
|
||||
do {
|
||||
swapped = false;
|
||||
for (int i = 0; i < m_modes.count()-1; ++i) {
|
||||
IMode *mode1 = m_modes.at(i);
|
||||
IMode *mode2 = m_modes.at(i+1);
|
||||
// qDebug() << "Comparing " << i << " to " << i+1 << " p1 " << mode1->priority() << " p2 " << mode2->priority();
|
||||
if (mode2->priority() > mode1->priority()) {
|
||||
m_modeStack->moveTab(i, i+1);
|
||||
// qDebug() << "Tab moved from " << i << " to " << i+1;
|
||||
swapped = true;
|
||||
}
|
||||
}
|
||||
} while (swapped);
|
||||
m_isReprioritizing = false;
|
||||
m_modeStack->setCurrentIndex(0);
|
||||
activateMode(current->uniqueModeName());
|
||||
emit newModeOrder(m_modes);
|
||||
}
|
||||
|
||||
|
||||
void ModeManager::setFocusToCurrentMode()
|
||||
{
|
||||
IMode *mode = currentMode();
|
||||
|
@ -40,6 +40,7 @@ QT_BEGIN_NAMESPACE
|
||||
class QSignalMapper;
|
||||
class QMenu;
|
||||
class QIcon;
|
||||
class MyTabWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
@ -58,7 +59,7 @@ class CORE_EXPORT ModeManager : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModeManager(Internal::MainWindow *mainWindow, Internal::FancyTabWidget *modeStack);
|
||||
ModeManager(Internal::MainWindow *mainWindow, MyTabWidget *modeStack);
|
||||
|
||||
void init();
|
||||
static ModeManager *instance() { return m_instance; }
|
||||
@ -69,10 +70,13 @@ public:
|
||||
void addAction(Command *command, int priority, QMenu *menu = 0);
|
||||
void addWidget(QWidget *widget);
|
||||
void updateModeNameIcon(IMode *mode, const QIcon &icon, const QString &label);
|
||||
QVector<IMode*> modes() const { return m_modes; }
|
||||
void reorderModes(QMap<QString, int> priorities);
|
||||
|
||||
signals:
|
||||
void currentModeAboutToChange(Core::IMode *mode);
|
||||
void currentModeChanged(Core::IMode *mode);
|
||||
void newModeOrder(QVector<IMode*> modes);
|
||||
|
||||
public slots:
|
||||
void activateMode(const QString &id);
|
||||
@ -84,19 +88,22 @@ private slots:
|
||||
void currentTabAboutToChange(int index);
|
||||
void currentTabChanged(int index);
|
||||
void updateModeToolTip();
|
||||
void tabMoved(int from, int to);
|
||||
|
||||
private:
|
||||
int indexOf(const QString &id) const;
|
||||
void setDefaultKeyshortcuts();
|
||||
|
||||
static ModeManager *m_instance;
|
||||
Internal::MainWindow *m_mainWindow;
|
||||
Internal::FancyTabWidget *m_modeStack;
|
||||
Internal::FancyActionBar *m_actionBar;
|
||||
MyTabWidget *m_modeStack;
|
||||
QMap<Command*, int> m_actions;
|
||||
QVector<IMode*> m_modes;
|
||||
QVector<Command*> m_modeShortcuts;
|
||||
QSignalMapper *m_signalMapper;
|
||||
QList<int> m_addedContexts;
|
||||
QList<int> m_tabOrder;
|
||||
bool m_isReprioritizing;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@ -73,57 +73,6 @@ void SplitterOrView::mousePressEvent(QMouseEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
//void SplitterOrView::paintEvent(QPaintEvent *event)
|
||||
//{
|
||||
// if (m_uavGadgetManager->currentSplitterOrView() != this)
|
||||
// return;
|
||||
//
|
||||
// if (!m_view)
|
||||
// return;
|
||||
//
|
||||
// if (hasGadget())
|
||||
// return;
|
||||
//
|
||||
// if (m_uavGadgetManager->toolbarsShown())
|
||||
// return;
|
||||
//
|
||||
// // Discreet indication where an uavGadget would be if there is none
|
||||
// QPainter painter(this);
|
||||
// painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
// painter.setPen(Qt::NoPen);
|
||||
// QColor shadeBrush(Qt::black);
|
||||
// shadeBrush.setAlpha(25);
|
||||
// painter.setBrush(shadeBrush);
|
||||
// const int r = 3;
|
||||
// painter.drawRoundedRect(rect().adjusted(r, r, -r, -r), r * 2, r * 2);
|
||||
//
|
||||
//#if 0
|
||||
// if (hasFocus()) {
|
||||
//#ifdef Q_WS_MAC
|
||||
// // With QMacStyle, we have to draw our own focus rect, since I didn't find
|
||||
// // a way to draw the nice mac focus rect _inside_ this widget
|
||||
// if (qobject_cast<QMacStyle *>(style())) {
|
||||
// painter.setPen(Qt::DotLine);
|
||||
// painter.setBrush(Qt::NoBrush);
|
||||
// painter.setOpacity(0.75);
|
||||
// painter.drawRect(rect());
|
||||
// } else {
|
||||
//#endif
|
||||
// QStyleOptionFocusRect option;
|
||||
// option.initFrom(this);
|
||||
// option.backgroundColor = palette().color(QPalette::Background);
|
||||
//
|
||||
// // Some styles require a certain state flag in order to draw the focus rect
|
||||
// option.state |= QStyle::State_KeyboardFocusChange;
|
||||
//
|
||||
// style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter);
|
||||
//#ifdef Q_WS_MAC
|
||||
// }
|
||||
//#endif
|
||||
// }
|
||||
//#endif
|
||||
//}
|
||||
|
||||
/* Contract: return SplitterOrView that is not splitter, or 0 if not found.
|
||||
* Implications: must not return SplitterOrView that is splitter.
|
||||
*/
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "uavgadgetmanager.h"
|
||||
#include "uavgadgetview.h"
|
||||
#include "splitterorview.h"
|
||||
#include "uavgadgetmode.h"
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
#include "iuavgadgetfactory.h"
|
||||
#include "iuavgadget.h"
|
||||
@ -79,229 +78,76 @@ static inline ExtensionSystem::PluginManager *pluginManager()
|
||||
|
||||
//===================UAVGadgetManager=====================
|
||||
|
||||
//UAVGadgetManagerPlaceHolder *UAVGadgetManagerPlaceHolder::m_current = 0;
|
||||
|
||||
UAVGadgetManagerPlaceHolder::UAVGadgetManagerPlaceHolder(Core::Internal::UAVGadgetMode *mode, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_uavGadgetMode(mode),
|
||||
m_current(0)
|
||||
{
|
||||
m_mode = dynamic_cast<Core::IMode*>(mode);
|
||||
setLayout(new QVBoxLayout);
|
||||
layout()->setMargin(0);
|
||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode *)),
|
||||
this, SLOT(currentModeChanged(Core::IMode *)));
|
||||
|
||||
currentModeChanged(Core::ModeManager::instance()->currentMode());
|
||||
}
|
||||
|
||||
UAVGadgetManagerPlaceHolder::~UAVGadgetManagerPlaceHolder()
|
||||
{
|
||||
if (m_current == this) {
|
||||
m_uavGadgetMode->uavGadgetManager()->setParent(0);
|
||||
m_uavGadgetMode->uavGadgetManager()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void UAVGadgetManagerPlaceHolder::currentModeChanged(Core::IMode *mode)
|
||||
{
|
||||
UAVGadgetManager *gm = m_uavGadgetMode->uavGadgetManager();
|
||||
if (m_current == this) {
|
||||
m_current = 0;
|
||||
gm->setParent(0);
|
||||
gm->hide();
|
||||
}
|
||||
if (m_mode == mode) {
|
||||
m_current = this;
|
||||
layout()->addWidget(gm);
|
||||
gm->showToolbars(gm->toolbarsShown());
|
||||
gm->show();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- UAVGadgetManager
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
||||
struct UAVGadgetManagerPrivate {
|
||||
explicit UAVGadgetManagerPrivate(ICore *core, QWidget *parent);
|
||||
~UAVGadgetManagerPrivate();
|
||||
|
||||
// The root splitter or view.
|
||||
QPointer<Internal::SplitterOrView> m_splitterOrView;
|
||||
|
||||
// The gadget which is currently 'active'.
|
||||
QPointer<IUAVGadget> m_currentGadget;
|
||||
|
||||
QPointer<ICore> m_core;
|
||||
|
||||
QPointer<Internal::UAVGadgetClosingCoreListener> m_coreListener;
|
||||
|
||||
// actions
|
||||
static QAction *m_showToolbarsAction;
|
||||
static QAction *m_splitAction;
|
||||
static QAction *m_splitSideBySideAction;
|
||||
static QAction *m_removeCurrentSplitAction;
|
||||
static QAction *m_removeAllSplitsAction;
|
||||
static QAction *m_gotoOtherSplitAction;
|
||||
};
|
||||
}
|
||||
|
||||
QAction *UAVGadgetManagerPrivate::m_showToolbarsAction = 0;
|
||||
QAction *UAVGadgetManagerPrivate::m_splitAction = 0;
|
||||
QAction *UAVGadgetManagerPrivate::m_splitSideBySideAction = 0;
|
||||
QAction *UAVGadgetManagerPrivate::m_removeCurrentSplitAction = 0;
|
||||
QAction *UAVGadgetManagerPrivate::m_removeAllSplitsAction = 0;
|
||||
QAction *UAVGadgetManagerPrivate::m_gotoOtherSplitAction = 0;
|
||||
|
||||
UAVGadgetManagerPrivate::UAVGadgetManagerPrivate(ICore *core, QWidget *parent) :
|
||||
UAVGadgetManager::UAVGadgetManager(ICore *core, QString name, QIcon icon, int priority, QString uniqueName, QWidget *parent) :
|
||||
m_showToolbars(true),
|
||||
m_splitterOrView(0),
|
||||
m_currentGadget(0),
|
||||
m_core(core),
|
||||
m_coreListener(0)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
}
|
||||
|
||||
UAVGadgetManagerPrivate::~UAVGadgetManagerPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
UAVGadgetManager::UAVGadgetManager(ICore *core, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_showToolbars(false),
|
||||
m_d(new UAVGadgetManagerPrivate(core, parent)),
|
||||
m_uavGadgetMode(0)
|
||||
m_name(name),
|
||||
m_icon(icon),
|
||||
m_priority(priority),
|
||||
m_widget(new QWidget(parent))
|
||||
{
|
||||
|
||||
connect(m_d->m_core, SIGNAL(contextAboutToChange(Core::IContext *)),
|
||||
// checking that the mode name is unique gives harmless
|
||||
// warnings on the console output
|
||||
ModeManager *modeManager = ModeManager::instance();
|
||||
if (!modeManager->mode(uniqueName)) {
|
||||
m_uniqueName = uniqueName;
|
||||
} else {
|
||||
// this shouldn't happen
|
||||
m_uniqueName = uniqueName + QString::number(quint64(this));
|
||||
}
|
||||
m_uniqueNameBA = m_uniqueName.toLatin1();
|
||||
m_uniqueModeName = m_uniqueNameBA.data();
|
||||
|
||||
connect(m_core, SIGNAL(contextAboutToChange(Core::IContext *)),
|
||||
this, SLOT(handleContextChange(Core::IContext *)));
|
||||
const QList<int> uavGadgetManagerContext =
|
||||
QList<int>() << m_d->m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_UAVGADGETMANAGER);
|
||||
|
||||
ActionManager *am = m_d->m_core->actionManager();
|
||||
|
||||
//Window Menu
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
Command *cmd;
|
||||
|
||||
// The actions m_d->m_showToolbarsAction etc are common to all instances of UAVGadgetManager
|
||||
// which means that they share the menu items/signals in the Window menu.
|
||||
// That is, they all connect their slots to the same signal and have to check in the slot
|
||||
// if the current mode is their mode, otherwise they just ignore the signal.
|
||||
// The first UAVGadgetManager creates the actions, and the following just use them
|
||||
// (This also implies that they share the same context.)
|
||||
if (m_d->m_showToolbarsAction == 0)
|
||||
{
|
||||
//Window menu separators
|
||||
QAction *tmpaction = new QAction(this);
|
||||
tmpaction->setSeparator(true);
|
||||
cmd = am->registerAction(tmpaction, QLatin1String("OpenPilot.Window.Sep.Split"), uavGadgetManagerContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_HIDE_TOOLBAR);
|
||||
|
||||
m_d->m_showToolbarsAction = new QAction(tr("Edit Gadgets Mode"), this);
|
||||
m_d->m_showToolbarsAction->setCheckable(true);
|
||||
cmd = am->registerAction(m_d->m_showToolbarsAction, Constants::HIDE_TOOLBARS, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F10")));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_HIDE_TOOLBAR);
|
||||
|
||||
//Window menu separators
|
||||
QAction *tmpaction2 = new QAction(this);
|
||||
tmpaction2->setSeparator(true);
|
||||
cmd = am->registerAction(tmpaction2, QLatin1String("OpenPilot.Window.Sep.Split2"), uavGadgetManagerContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
}
|
||||
connect(m_d->m_showToolbarsAction, SIGNAL(triggered(bool)), this, SLOT(showToolbars(bool)));
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
QString prefix = tr("Meta+Shift");
|
||||
#else
|
||||
QString prefix = tr("Ctrl+Shift");
|
||||
#endif
|
||||
|
||||
if (m_d->m_splitAction == 0)
|
||||
{
|
||||
m_d->m_splitAction = new QAction(tr("Split"), this);
|
||||
cmd = am->registerAction(m_d->m_splitAction, Constants::SPLIT, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+Down").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
}
|
||||
connect(m_d->m_splitAction, SIGNAL(triggered()), this, SLOT(split()));
|
||||
|
||||
if (m_d->m_splitSideBySideAction == 0)
|
||||
{
|
||||
m_d->m_splitSideBySideAction = new QAction(tr("Split Side by Side"), this);
|
||||
cmd = am->registerAction(m_d->m_splitSideBySideAction, Constants::SPLIT_SIDE_BY_SIDE, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+Right").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
}
|
||||
connect(m_d->m_splitSideBySideAction, SIGNAL(triggered()), this, SLOT(splitSideBySide()));
|
||||
|
||||
if (m_d->m_removeCurrentSplitAction == 0)
|
||||
{
|
||||
m_d->m_removeCurrentSplitAction = new QAction(tr("Close Current View"), this);
|
||||
cmd = am->registerAction(m_d->m_removeCurrentSplitAction, Constants::REMOVE_CURRENT_SPLIT, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+C").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
}
|
||||
connect(m_d->m_removeCurrentSplitAction, SIGNAL(triggered()), this, SLOT(removeCurrentSplit()));
|
||||
|
||||
if (m_d->m_removeAllSplitsAction == 0)
|
||||
{
|
||||
m_d->m_removeAllSplitsAction = new QAction(tr("Close All Other Views"), this);
|
||||
cmd = am->registerAction(m_d->m_removeAllSplitsAction, Constants::REMOVE_ALL_SPLITS, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+A").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
}
|
||||
connect(m_d->m_removeAllSplitsAction, SIGNAL(triggered()), this, SLOT(removeAllSplits()));
|
||||
|
||||
if (m_d->m_gotoOtherSplitAction == 0)
|
||||
{
|
||||
m_d->m_gotoOtherSplitAction = new QAction(tr("Goto Next View"), this);
|
||||
cmd = am->registerAction(m_d->m_gotoOtherSplitAction, Constants::GOTO_OTHER_SPLIT, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1+N").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
}
|
||||
connect(m_d->m_gotoOtherSplitAction, SIGNAL(triggered()), this, SLOT(gotoOtherSplit()));
|
||||
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)),
|
||||
this, SLOT(modeChanged(Core::IMode*)));
|
||||
|
||||
// other setup
|
||||
m_d->m_splitterOrView = new SplitterOrView(this, 0);
|
||||
m_splitterOrView = new SplitterOrView(this, 0);
|
||||
|
||||
// SplitterOrView with 0 as gadget calls our setCurrentGadget, which relies on currentSplitterOrView(),
|
||||
// which needs our m_splitterorView to be set, which isn't set yet at that time.
|
||||
// So directly set our currentGadget to 0, and do it again.
|
||||
m_d->m_currentGadget = 0;
|
||||
setCurrentGadget(m_d->m_splitterOrView->view()->gadget());
|
||||
m_currentGadget = 0;
|
||||
setCurrentGadget(m_splitterOrView->view()->gadget());
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(m_widget);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(m_d->m_splitterOrView);
|
||||
layout->addWidget(m_splitterOrView);
|
||||
|
||||
showToolbars(m_showToolbars);
|
||||
updateActions();
|
||||
}
|
||||
|
||||
UAVGadgetManager::~UAVGadgetManager()
|
||||
{
|
||||
if (m_d->m_core) {
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
if (m_d->m_coreListener) {
|
||||
pm->removeObject(m_d->m_coreListener);
|
||||
delete m_d->m_coreListener;
|
||||
}
|
||||
}
|
||||
delete m_d;
|
||||
}
|
||||
|
||||
QList<int> UAVGadgetManager::context() const
|
||||
{
|
||||
static QList<int> contexts = QList<int>() <<
|
||||
UniqueIDManager::instance()->uniqueIdentifier(Constants::C_UAVGADGETMANAGER);
|
||||
return contexts;
|
||||
}
|
||||
|
||||
void UAVGadgetManager::modeChanged(Core::IMode *mode)
|
||||
{
|
||||
if (mode != this)
|
||||
return;
|
||||
|
||||
m_currentGadget->widget()->setFocus();
|
||||
showToolbars(toolbarsShown());
|
||||
}
|
||||
|
||||
void UAVGadgetManager::init()
|
||||
{
|
||||
QList<int> context;
|
||||
context << m_d->m_core->uniqueIDManager()->uniqueIdentifier("OpenPilot.UAVGadgetManager");
|
||||
|
||||
m_d->m_coreListener = new UAVGadgetClosingCoreListener(this);
|
||||
|
||||
pluginManager()->addObject(m_d->m_coreListener);
|
||||
context << m_core->uniqueIDManager()->uniqueIdentifier("OpenPilot.UAVGadgetManager");
|
||||
}
|
||||
|
||||
void UAVGadgetManager::handleContextChange(Core::IContext *context)
|
||||
@ -311,16 +157,15 @@ void UAVGadgetManager::handleContextChange(Core::IContext *context)
|
||||
IUAVGadget *uavGadget = context ? qobject_cast<IUAVGadget*>(context) : 0;
|
||||
if (uavGadget)
|
||||
setCurrentGadget(uavGadget);
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void UAVGadgetManager::setCurrentGadget(IUAVGadget *uavGadget)
|
||||
{
|
||||
if (m_d->m_currentGadget == uavGadget)
|
||||
if (m_currentGadget == uavGadget)
|
||||
return;
|
||||
|
||||
SplitterOrView *oldView = currentSplitterOrView();
|
||||
m_d->m_currentGadget = uavGadget;
|
||||
m_currentGadget = uavGadget;
|
||||
SplitterOrView *view = currentSplitterOrView();
|
||||
if (oldView != view) {
|
||||
if (oldView)
|
||||
@ -330,8 +175,6 @@ void UAVGadgetManager::setCurrentGadget(IUAVGadget *uavGadget)
|
||||
}
|
||||
uavGadget->widget()->setFocus();
|
||||
emit currentGadgetChanged(uavGadget);
|
||||
updateActions();
|
||||
// emit currentGadgetChanged(uavGadget);
|
||||
}
|
||||
|
||||
/* Contract: return current SplitterOrView.
|
||||
@ -339,17 +182,17 @@ void UAVGadgetManager::setCurrentGadget(IUAVGadget *uavGadget)
|
||||
*/
|
||||
Core::Internal::SplitterOrView *UAVGadgetManager::currentSplitterOrView() const
|
||||
{
|
||||
if (!m_d->m_splitterOrView) // this is only for startup
|
||||
if (!m_splitterOrView) // this is only for startup
|
||||
return 0;
|
||||
SplitterOrView *view = m_d->m_currentGadget ?
|
||||
m_d->m_splitterOrView->findView(m_d->m_currentGadget) :
|
||||
SplitterOrView *view = m_currentGadget ?
|
||||
m_splitterOrView->findView(m_currentGadget) :
|
||||
0;
|
||||
return view;
|
||||
}
|
||||
|
||||
IUAVGadget *UAVGadgetManager::currentGadget() const
|
||||
{
|
||||
return m_d->m_currentGadget;
|
||||
return m_currentGadget;
|
||||
}
|
||||
|
||||
void UAVGadgetManager::emptyView(Core::Internal::UAVGadgetView *view)
|
||||
@ -369,10 +212,10 @@ void UAVGadgetManager::closeView(Core::Internal::UAVGadgetView *view)
|
||||
{
|
||||
if (!view)
|
||||
return;
|
||||
SplitterOrView *splitterOrView = m_d->m_splitterOrView->findView(view);
|
||||
SplitterOrView *splitterOrView = m_splitterOrView->findView(view);
|
||||
Q_ASSERT(splitterOrView);
|
||||
Q_ASSERT(splitterOrView->view() == view);
|
||||
if (splitterOrView == m_d->m_splitterOrView)
|
||||
if (splitterOrView == m_splitterOrView)
|
||||
return;
|
||||
|
||||
IUAVGadget *gadget = view->gadget();
|
||||
@ -380,7 +223,7 @@ void UAVGadgetManager::closeView(Core::Internal::UAVGadgetView *view)
|
||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||
im->removeGadget(gadget);
|
||||
|
||||
SplitterOrView *splitter = m_d->m_splitterOrView->findSplitter(splitterOrView);
|
||||
SplitterOrView *splitter = m_splitterOrView->findSplitter(splitterOrView);
|
||||
Q_ASSERT(splitterOrView->hasGadget() == false);
|
||||
Q_ASSERT(splitter->isSplitter() == true);
|
||||
splitterOrView->hide();
|
||||
@ -398,7 +241,7 @@ void UAVGadgetManager::addGadgetToContext(IUAVGadget *gadget)
|
||||
{
|
||||
if (!gadget)
|
||||
return;
|
||||
m_d->m_core->addContextObject(gadget);
|
||||
m_core->addContextObject(gadget);
|
||||
|
||||
// emit uavGadgetOpened(uavGadget);
|
||||
}
|
||||
@ -407,27 +250,39 @@ void UAVGadgetManager::removeGadget(IUAVGadget *gadget)
|
||||
{
|
||||
if (!gadget)
|
||||
return;
|
||||
m_d->m_core->removeContextObject(qobject_cast<IContext*>(gadget));
|
||||
m_core->removeContextObject(qobject_cast<IContext*>(gadget));
|
||||
}
|
||||
|
||||
void UAVGadgetManager::ensureUAVGadgetManagerVisible()
|
||||
{
|
||||
if (!isVisible())
|
||||
m_d->m_core->modeManager()->activateMode(m_uavGadgetMode->uniqueModeName());
|
||||
if (!m_widget->isVisible())
|
||||
m_core->modeManager()->activateMode(this->uniqueModeName());
|
||||
}
|
||||
|
||||
void UAVGadgetManager::updateActions()
|
||||
void UAVGadgetManager::showToolbars(bool show)
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
if (m_core->modeManager()->currentMode() != this)
|
||||
return;
|
||||
if (!m_d->m_splitterOrView) // this is only for startup
|
||||
|
||||
m_showToolbars = show;
|
||||
SplitterOrView *next = m_splitterOrView->findFirstView();
|
||||
do {
|
||||
next->view()->showToolbar(show);
|
||||
next = m_splitterOrView->findNextView(next);
|
||||
} while (next);
|
||||
|
||||
updateUavGadgetMenus();
|
||||
}
|
||||
|
||||
void UAVGadgetManager::updateUavGadgetMenus()
|
||||
{
|
||||
if (m_core->modeManager()->currentMode() != this)
|
||||
return;
|
||||
if (!m_splitterOrView) // this is only for startup
|
||||
return;
|
||||
// Splitting is only possible when the toolbars are shown
|
||||
bool shown = m_d->m_showToolbarsAction->isChecked();
|
||||
bool hasSplitter = m_d->m_splitterOrView->isSplitter();
|
||||
m_d->m_removeCurrentSplitAction->setEnabled(shown && hasSplitter);
|
||||
m_d->m_removeAllSplitsAction->setEnabled(shown && hasSplitter);
|
||||
m_d->m_gotoOtherSplitAction->setEnabled(shown && hasSplitter);
|
||||
bool hasSplitter = m_splitterOrView->isSplitter();
|
||||
emit showUavGadgetMenus(m_showToolbars, hasSplitter);
|
||||
}
|
||||
|
||||
void UAVGadgetManager::saveState(QSettings* qSettings) const
|
||||
@ -435,7 +290,7 @@ void UAVGadgetManager::saveState(QSettings* qSettings) const
|
||||
qSettings->setValue("version","UAVGadgetManagerV1");
|
||||
qSettings->setValue("showToolbars",m_showToolbars);
|
||||
qSettings->beginGroup("splitter");
|
||||
m_d->m_splitterOrView->saveState(qSettings);
|
||||
m_splitterOrView->saveState(qSettings);
|
||||
qSettings->endGroup();
|
||||
}
|
||||
|
||||
@ -444,8 +299,8 @@ bool UAVGadgetManager::restoreState(QSettings* qSettings)
|
||||
removeAllSplits();
|
||||
|
||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||
IUAVGadget *gadget = m_d->m_splitterOrView->view()->gadget();
|
||||
emptyView(m_d->m_splitterOrView->view());
|
||||
IUAVGadget *gadget = m_splitterOrView->view()->gadget();
|
||||
emptyView(m_splitterOrView->view());
|
||||
im->removeGadget(gadget);
|
||||
|
||||
QString version = qSettings->value("version").toString();
|
||||
@ -458,7 +313,7 @@ bool UAVGadgetManager::restoreState(QSettings* qSettings)
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
qSettings->beginGroup("splitter");
|
||||
m_d->m_splitterOrView->restoreState(qSettings);
|
||||
m_splitterOrView->restoreState(qSettings);
|
||||
qSettings->endGroup();
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
@ -468,7 +323,7 @@ bool UAVGadgetManager::restoreState(QSettings* qSettings)
|
||||
void UAVGadgetManager::saveSettings(QSettings *qs)
|
||||
{
|
||||
qs->beginGroup("UAVGadgetManager");
|
||||
qs->beginGroup(m_uavGadgetMode->uniqueModeName());
|
||||
qs->beginGroup(this->uniqueModeName());
|
||||
|
||||
// Make sure the old tree is wiped.
|
||||
qs->remove("");
|
||||
@ -488,16 +343,15 @@ void UAVGadgetManager::readSettings(QSettings *qs)
|
||||
}
|
||||
qs->beginGroup(uavGadgetManagerRootKey);
|
||||
|
||||
if(!qs->childGroups().contains(m_uavGadgetMode->uniqueModeName())) {
|
||||
if(!qs->childGroups().contains(uniqueModeName())) {
|
||||
qs->endGroup();
|
||||
return;
|
||||
}
|
||||
qs->beginGroup(m_uavGadgetMode->uniqueModeName());
|
||||
qs->beginGroup(uniqueModeName());
|
||||
|
||||
restoreState(qs);
|
||||
|
||||
showToolbars(m_showToolbars);
|
||||
updateActions();
|
||||
|
||||
qs->endGroup();
|
||||
qs->endGroup();
|
||||
@ -505,18 +359,19 @@ void UAVGadgetManager::readSettings(QSettings *qs)
|
||||
|
||||
void UAVGadgetManager::split(Qt::Orientation orientation)
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
if (m_core->modeManager()->currentMode() != this)
|
||||
return;
|
||||
|
||||
IUAVGadget *uavGadget = m_d->m_currentGadget;
|
||||
IUAVGadget *uavGadget = m_currentGadget;
|
||||
Q_ASSERT(uavGadget);
|
||||
SplitterOrView *view = currentSplitterOrView();
|
||||
Q_ASSERT(view);
|
||||
view->split(orientation);
|
||||
|
||||
SplitterOrView *sor = m_d->m_splitterOrView->findView(uavGadget);
|
||||
SplitterOrView *next = m_d->m_splitterOrView->findNextView(sor);
|
||||
SplitterOrView *sor = m_splitterOrView->findView(uavGadget);
|
||||
SplitterOrView *next = m_splitterOrView->findNextView(sor);
|
||||
setCurrentGadget(next->gadget());
|
||||
updateUavGadgetMenus();
|
||||
}
|
||||
|
||||
void UAVGadgetManager::split()
|
||||
@ -531,37 +386,38 @@ void UAVGadgetManager::splitSideBySide()
|
||||
|
||||
void UAVGadgetManager::removeCurrentSplit()
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
if (m_core->modeManager()->currentMode() != this)
|
||||
return;
|
||||
|
||||
SplitterOrView *viewToClose = currentSplitterOrView();
|
||||
if (viewToClose == m_d->m_splitterOrView)
|
||||
if (viewToClose == m_splitterOrView)
|
||||
return;
|
||||
closeView(viewToClose->view());
|
||||
updateUavGadgetMenus();
|
||||
}
|
||||
|
||||
// Removes all gadgets and splits in the workspace, except the current/active gadget.
|
||||
void UAVGadgetManager::removeAllSplits()
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
if (m_core->modeManager()->currentMode() != this)
|
||||
return;
|
||||
|
||||
if (!m_d->m_splitterOrView->isSplitter())
|
||||
if (!m_splitterOrView->isSplitter())
|
||||
return;
|
||||
|
||||
// Use a QPointer, just in case we accidently delete the gadget we want to keep.
|
||||
QPointer<IUAVGadget> currentGadget = m_d->m_currentGadget;
|
||||
QPointer<IUAVGadget> currentGadget = m_currentGadget;
|
||||
|
||||
Q_ASSERT(currentGadget);
|
||||
QList<IUAVGadget*> gadgets = m_d->m_splitterOrView->gadgets();
|
||||
QList<IUAVGadget*> gadgets = m_splitterOrView->gadgets();
|
||||
Q_ASSERT(gadgets.count(currentGadget) == 1);
|
||||
gadgets.removeOne(currentGadget);
|
||||
|
||||
// Remove all splits and their gadgets, then create a new view with the current gadget.
|
||||
m_d->m_splitterOrView->unsplitAll(currentGadget);
|
||||
m_splitterOrView->unsplitAll(currentGadget);
|
||||
|
||||
// Zeroing the current gadget means setCurrentGadget will do something when we call it.
|
||||
m_d->m_currentGadget = 0;
|
||||
m_currentGadget = 0;
|
||||
setCurrentGadget(currentGadget);
|
||||
|
||||
// Remove all other gadgets from the instance manager.
|
||||
@ -569,53 +425,21 @@ void UAVGadgetManager::removeAllSplits()
|
||||
foreach (IUAVGadget *g, gadgets) {
|
||||
im->removeGadget(g);
|
||||
}
|
||||
updateUavGadgetMenus();
|
||||
}
|
||||
|
||||
void UAVGadgetManager::gotoOtherSplit()
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
if (m_core->modeManager()->currentMode() != this)
|
||||
return;
|
||||
|
||||
if (m_d->m_splitterOrView->isSplitter()) {
|
||||
if (m_splitterOrView->isSplitter()) {
|
||||
SplitterOrView *currentView = currentSplitterOrView();
|
||||
SplitterOrView *view = m_d->m_splitterOrView->findNextView(currentView);
|
||||
SplitterOrView *view = m_splitterOrView->findNextView(currentView);
|
||||
if (!view)
|
||||
view = m_d->m_splitterOrView->findFirstView();
|
||||
view = m_splitterOrView->findFirstView();
|
||||
if (view) {
|
||||
setCurrentGadget(view->gadget());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAVGadgetManager::showToolbars(bool show)
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
return;
|
||||
|
||||
m_d->m_showToolbarsAction->setChecked(show);
|
||||
m_showToolbars = show;
|
||||
SplitterOrView *next = m_d->m_splitterOrView->findFirstView();
|
||||
do {
|
||||
next->view()->showToolbar(show);
|
||||
next = m_d->m_splitterOrView->findNextView(next);
|
||||
} while (next);
|
||||
|
||||
m_d->m_splitAction->setEnabled(show);
|
||||
m_d->m_splitSideBySideAction->setEnabled(show);
|
||||
m_d->m_removeCurrentSplitAction->setEnabled(show);
|
||||
m_d->m_removeAllSplitsAction->setEnabled(show);
|
||||
m_d->m_gotoOtherSplitAction->setEnabled(show);
|
||||
}
|
||||
//===================UAVGadgetClosingCoreListener======================
|
||||
|
||||
UAVGadgetClosingCoreListener::UAVGadgetClosingCoreListener(UAVGadgetManager *em)
|
||||
: m_em(em)
|
||||
{
|
||||
}
|
||||
|
||||
bool UAVGadgetClosingCoreListener::coreAboutToClose()
|
||||
{
|
||||
// Do not ask for files to save.
|
||||
// MainWindow::closeEvent has already done that.
|
||||
return true;
|
||||
}
|
||||
|
@ -32,14 +32,15 @@
|
||||
#include "../core_global.h"
|
||||
|
||||
#include <coreplugin/icorelistener.h>
|
||||
#include <coreplugin/imode.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
class QModelIndex;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@ -48,49 +49,33 @@ namespace Core {
|
||||
class IContext;
|
||||
class ICore;
|
||||
class IUAVGadget;
|
||||
class IMode;
|
||||
|
||||
struct UAVGadgetManagerPrivate;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class UAVGadgetMode;
|
||||
class UAVGadgetView;
|
||||
class SplitterOrView;
|
||||
|
||||
class UAVGadgetClosingCoreListener;
|
||||
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
class CORE_EXPORT UAVGadgetManagerPlaceHolder : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UAVGadgetManagerPlaceHolder(Core::Internal::UAVGadgetMode *mode, QWidget *parent = 0);
|
||||
~UAVGadgetManagerPlaceHolder();
|
||||
// static UAVGadgetManagerPlaceHolder* current();
|
||||
private slots:
|
||||
void currentModeChanged(Core::IMode *);
|
||||
private:
|
||||
Core::IMode *m_mode;
|
||||
Core::Internal::UAVGadgetMode *m_uavGadgetMode;
|
||||
UAVGadgetManagerPlaceHolder* m_current;
|
||||
};
|
||||
|
||||
|
||||
class CORE_EXPORT UAVGadgetManager : public QWidget
|
||||
class CORE_EXPORT UAVGadgetManager : public IMode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit UAVGadgetManager(ICore *core, QWidget *parent);
|
||||
explicit UAVGadgetManager(ICore *core, QString name, QIcon icon, int priority, QString uniqueName, QWidget *parent);
|
||||
virtual ~UAVGadgetManager();
|
||||
|
||||
// IMode
|
||||
QString name() const { return m_name; }
|
||||
QIcon icon() const { return m_icon; }
|
||||
int priority() const { return m_priority; }
|
||||
void setPriority(int priority) { m_priority = priority; }
|
||||
const char *uniqueModeName() const { return m_uniqueModeName; }
|
||||
QList<int> context() const;
|
||||
|
||||
void init();
|
||||
// setUAVGadgetMode should be called exactly once
|
||||
// right after the mode has been created, and never thereafter
|
||||
void setUAVGadgetMode(Core::Internal::UAVGadgetMode *mode) { m_uavGadgetMode = mode; }
|
||||
QWidget *widget() { return m_widget; }
|
||||
|
||||
void ensureUAVGadgetManagerVisible();
|
||||
|
||||
@ -105,10 +90,14 @@ public:
|
||||
|
||||
signals:
|
||||
void currentGadgetChanged(IUAVGadget *gadget);
|
||||
void showUavGadgetMenus(bool show, bool hasSplitter);
|
||||
void updateSplitMenus(bool hasSplitter);
|
||||
|
||||
private slots:
|
||||
void handleContextChange(Core::IContext *context);
|
||||
void updateActions();
|
||||
void updateUavGadgetMenus();
|
||||
void modeChanged(Core::IMode *mode);
|
||||
|
||||
|
||||
public slots:
|
||||
void split(Qt::Orientation orientation);
|
||||
@ -120,16 +109,25 @@ public slots:
|
||||
void showToolbars(bool show);
|
||||
|
||||
private:
|
||||
void setCurrentGadget(IUAVGadget *gadget);
|
||||
void addGadgetToContext(IUAVGadget *gadget);
|
||||
void removeGadget(IUAVGadget *gadget);
|
||||
void setCurrentGadget(IUAVGadget *gadget);
|
||||
void closeView(Core::Internal::UAVGadgetView *view);
|
||||
void emptyView(Core::Internal::UAVGadgetView *view);
|
||||
Core::Internal::SplitterOrView *currentSplitterOrView() const;
|
||||
|
||||
bool m_showToolbars;
|
||||
UAVGadgetManagerPrivate *m_d;
|
||||
Core::Internal::UAVGadgetMode *m_uavGadgetMode;
|
||||
Core::Internal::SplitterOrView *m_splitterOrView;
|
||||
Core::IUAVGadget *m_currentGadget;
|
||||
Core::ICore *m_core;
|
||||
|
||||
QString m_name;
|
||||
QIcon m_icon;
|
||||
int m_priority;
|
||||
QString m_uniqueName;
|
||||
QByteArray m_uniqueNameBA;
|
||||
const char* m_uniqueModeName;
|
||||
QWidget *m_widget;
|
||||
|
||||
friend class Core::Internal::SplitterOrView;
|
||||
friend class Core::Internal::UAVGadgetView;
|
||||
@ -137,26 +135,4 @@ private:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
|
||||
//===================UAVGadgetClosingCoreListener======================
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class UAVGadgetClosingCoreListener : public ICoreListener
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UAVGadgetClosingCoreListener(UAVGadgetManager *em);
|
||||
bool uavGadgetAboutToClose(IUAVGadget *gadget);
|
||||
bool coreAboutToClose();
|
||||
|
||||
private:
|
||||
UAVGadgetManager *m_em;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // UAVGADGETMANAGER_H
|
||||
|
@ -1,135 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavgadgetmode.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 "uavgadgetmode.h"
|
||||
#include "uavgadgetmanager.h"
|
||||
#include "coreconstants.h"
|
||||
#include "modemanager.h"
|
||||
#include "uniqueidmanager.h"
|
||||
#include "minisplitter.h"
|
||||
#include "outputpane.h"
|
||||
#include "rightpane.h"
|
||||
#include "iuavgadget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtCore/QLatin1String>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QSplitter>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
UAVGadgetMode::UAVGadgetMode(UAVGadgetManager *uavGadgetManager, QString name, QIcon icon, int priority, QString uniqueName) :
|
||||
m_uavGadgetManager(uavGadgetManager),
|
||||
m_name(name),
|
||||
m_icon(icon),
|
||||
m_widget(new QWidget),
|
||||
m_priority(priority),
|
||||
m_layout(new QVBoxLayout)
|
||||
{
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setMargin(0);
|
||||
m_widget->setLayout(m_layout);
|
||||
m_layout->insertWidget(0, new Core::UAVGadgetManagerPlaceHolder(this));
|
||||
|
||||
ModeManager *modeManager = ModeManager::instance();
|
||||
// checking that the mode name is unique gives harmless
|
||||
// warnings on the console output
|
||||
if (!modeManager->mode(uniqueName)) {
|
||||
m_uniqueName = uniqueName;
|
||||
} else {
|
||||
// this shouldn't happen
|
||||
m_uniqueName = uniqueName + QString::number(quint64(this));
|
||||
}
|
||||
m_uniqueNameBA = m_uniqueName.toLatin1();
|
||||
m_uniqueNameC = m_uniqueNameBA.data();
|
||||
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)),
|
||||
this, SLOT(grabUAVGadgetManager(Core::IMode*)));
|
||||
m_widget->setFocusProxy(m_uavGadgetManager);
|
||||
}
|
||||
|
||||
UAVGadgetMode::~UAVGadgetMode()
|
||||
{
|
||||
// TODO: see if this leftover from Qt Creator still applies
|
||||
// Make sure the uavGadget manager does not get deleted
|
||||
m_uavGadgetManager->setParent(0);
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
QString UAVGadgetMode::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void UAVGadgetMode::setName(QString name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
QIcon UAVGadgetMode::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
void UAVGadgetMode::setIcon(QIcon icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
}
|
||||
|
||||
int UAVGadgetMode::priority() const
|
||||
{
|
||||
return m_priority;
|
||||
}
|
||||
|
||||
QWidget* UAVGadgetMode::widget()
|
||||
{
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
const char* UAVGadgetMode::uniqueModeName() const
|
||||
{
|
||||
return m_uniqueNameC;
|
||||
}
|
||||
|
||||
QList<int> UAVGadgetMode::context() const
|
||||
{
|
||||
static QList<int> contexts = QList<int>() <<
|
||||
UniqueIDManager::instance()->uniqueIdentifier(Constants::C_UAVGADGET_MODE) <<
|
||||
UniqueIDManager::instance()->uniqueIdentifier(Constants::C_UAVGADGETMANAGER);
|
||||
return contexts;
|
||||
}
|
||||
|
||||
void UAVGadgetMode::grabUAVGadgetManager(Core::IMode *mode)
|
||||
{
|
||||
if (mode != this)
|
||||
return;
|
||||
|
||||
if (m_uavGadgetManager->currentGadget())
|
||||
m_uavGadgetManager->currentGadget()->widget()->setFocus();
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavgadgetmode.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 UAVGADGETMODE_H
|
||||
#define UAVGADGETMODE_H
|
||||
|
||||
#include <coreplugin/imode.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSplitter;
|
||||
class QWidget;
|
||||
class QIcon;
|
||||
class QVBoxLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class UAVGadgetManager;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class UAVGadgetMode : public Core::IMode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UAVGadgetMode(UAVGadgetManager *uavGadgetManager, QString name, QIcon icon, int priority, QString uniqueName);
|
||||
~UAVGadgetMode();
|
||||
|
||||
// IMode
|
||||
QString name() const;
|
||||
QIcon icon() const;
|
||||
int priority() const;
|
||||
QWidget* widget();
|
||||
const char* uniqueModeName() const;
|
||||
QList<int> context() const;
|
||||
UAVGadgetManager* uavGadgetManager() const { return m_uavGadgetManager; }
|
||||
void setName(QString name);
|
||||
void setIcon(QIcon icon);
|
||||
|
||||
private slots:
|
||||
void grabUAVGadgetManager(Core::IMode *mode);
|
||||
|
||||
private:
|
||||
UAVGadgetManager *m_uavGadgetManager;
|
||||
QString m_name;
|
||||
QIcon m_icon;
|
||||
QWidget *m_widget;
|
||||
int m_priority;
|
||||
QVBoxLayout *m_layout;
|
||||
QString m_uniqueName;
|
||||
QByteArray m_uniqueNameBA;
|
||||
const char *m_uniqueNameC;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // UAVGADGETMODE_H
|
@ -1,119 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file viewmanager.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 "viewmanager.h"
|
||||
|
||||
#include "coreconstants.h"
|
||||
#include "mainwindow.h"
|
||||
#include "uniqueidmanager.h"
|
||||
#include "iview.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QStatusBar>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
ViewManager::ViewManager(MainWindow *mainWnd)
|
||||
: QObject(mainWnd),
|
||||
m_mainWnd(mainWnd)
|
||||
{
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
QWidget *w = new QWidget();
|
||||
m_mainWnd->statusBar()->insertPermanentWidget(i, w);
|
||||
w->setLayout(new QHBoxLayout);
|
||||
w->setVisible(true);
|
||||
w->layout()->setMargin(0);
|
||||
m_statusBarWidgets.append(w);
|
||||
}
|
||||
QLabel *l = new QLabel();
|
||||
m_mainWnd->statusBar()->insertPermanentWidget(3, l, 1);
|
||||
}
|
||||
|
||||
ViewManager::~ViewManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewManager::init()
|
||||
{
|
||||
connect(ExtensionSystem::PluginManager::instance(), SIGNAL(objectAdded(QObject*)),
|
||||
this, SLOT(objectAdded(QObject*)));
|
||||
connect(ExtensionSystem::PluginManager::instance(), SIGNAL(aboutToRemoveObject(QObject*)),
|
||||
this, SLOT(aboutToRemoveObject(QObject*)));
|
||||
}
|
||||
|
||||
void ViewManager::objectAdded(QObject *obj)
|
||||
{
|
||||
IView *view = Aggregation::query<IView>(obj);
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
QWidget *viewWidget = 0;
|
||||
viewWidget = view->widget();
|
||||
m_statusBarWidgets.at(view->defaultPosition())->layout()->addWidget(viewWidget);
|
||||
|
||||
m_viewMap.insert(view, viewWidget);
|
||||
viewWidget->setObjectName(view->uniqueViewName());
|
||||
m_mainWnd->addContextObject(view);
|
||||
}
|
||||
|
||||
void ViewManager::aboutToRemoveObject(QObject *obj)
|
||||
{
|
||||
IView *view = Aggregation::query<IView>(obj);
|
||||
if (!view)
|
||||
return;
|
||||
m_mainWnd->removeContextObject(view);
|
||||
}
|
||||
|
||||
void ViewManager::readSettings(QSettings *settings)
|
||||
{
|
||||
m_mainWnd->restoreState(settings->value(QLatin1String("ViewGroup_Default"), QByteArray()).toByteArray());
|
||||
}
|
||||
|
||||
void ViewManager::saveSettings(QSettings *settings)
|
||||
{
|
||||
settings->setValue(QLatin1String("ViewGroup_Default"), m_mainWnd->saveState());
|
||||
}
|
||||
|
||||
IView *ViewManager::view(const QString &id)
|
||||
{
|
||||
QList<IView *> list =
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<IView>();
|
||||
foreach (IView *view, list) {
|
||||
if (view->uniqueViewName() == id)
|
||||
return view;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file viewmanager.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 VIEWMANAGER_H
|
||||
#define VIEWMANAGER_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QSettings;
|
||||
class QMainWindow;
|
||||
class QComboBox;
|
||||
class QStackedWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IView;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class MainWindow;
|
||||
class NavigationWidget;
|
||||
|
||||
class ViewManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ViewManager(MainWindow *mainWnd);
|
||||
~ViewManager();
|
||||
|
||||
void init();
|
||||
void readSettings(QSettings *settings);
|
||||
void saveSettings(QSettings *settings);
|
||||
|
||||
IView * view(const QString & id);
|
||||
private slots:
|
||||
void objectAdded(QObject *obj);
|
||||
void aboutToRemoveObject(QObject *obj);
|
||||
|
||||
private:
|
||||
QMap<Core::IView *, QWidget *> m_viewMap;
|
||||
|
||||
MainWindow *m_mainWnd;
|
||||
QList<QWidget *> m_statusBarWidgets;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
#endif // VIEWMANAGER_H
|
@ -28,7 +28,7 @@
|
||||
#include "workspacesettings.h"
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/uavgadgetmode.h>
|
||||
#include <coreplugin/uavgadgetmanager/uavgadgetmanager.h>
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
#include "ui_workspacesettings.h"
|
||||
@ -95,26 +95,37 @@ QWidget *WorkspaceSettings::createPage(QWidget *parent)
|
||||
m_currentIndex = 0;
|
||||
selectWorkspace(m_currentIndex);
|
||||
|
||||
if (0 <= m_tabBarPlacementIndex && m_tabBarPlacementIndex < m_page->comboBoxTabBarPlacement->count())
|
||||
m_page->comboBoxTabBarPlacement->setCurrentIndex(m_tabBarPlacementIndex);
|
||||
m_page->checkBoxAllowTabMovement->setChecked(m_allowTabBarMovement);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
void WorkspaceSettings::readSettings(QSettings* qs)
|
||||
{
|
||||
m_iconNames.clear();
|
||||
m_names.clear();
|
||||
m_iconNames.clear();
|
||||
m_modeNames.clear();
|
||||
|
||||
qs->beginGroup(QLatin1String("Workspace"));
|
||||
m_numberOfWorkspaces = qs->value(QLatin1String("NumberOfWorkspaces"), 2).toInt();
|
||||
m_previousNumberOfWorkspaces = m_numberOfWorkspaces;
|
||||
for (int i = 1; i <= MAX_WORKSPACES; ++i) {
|
||||
QString numberString = QString::number(i);
|
||||
QString defaultName = "Workspace" + numberString;
|
||||
QString defaultIconName = "Icon" + numberString;
|
||||
const QString name = qs->value(defaultName, defaultName).toString();
|
||||
const QString iconName = qs->value(defaultIconName, ":/core/images/openpilot_logo_64.png").toString();
|
||||
m_iconNames.append(iconName);
|
||||
QString name = qs->value(defaultName, defaultName).toString();
|
||||
QString iconName = qs->value(defaultIconName, ":/core/images/openpilot_logo_64.png").toString();
|
||||
m_names.append(name);
|
||||
m_iconNames.append(iconName);
|
||||
m_modeNames.append(QString("Mode")+ QString::number(i));
|
||||
}
|
||||
m_tabBarPlacementIndex = qs->value(QLatin1String("TabBarPlacementIndex"), 1).toInt(); // 1 == "Bottom"
|
||||
m_allowTabBarMovement = qs->value(QLatin1String("AllowTabBarMovement"), false).toBool();
|
||||
qs->endGroup();
|
||||
QTabWidget::TabPosition pos = m_tabBarPlacementIndex == 0 ? QTabWidget::North : QTabWidget::South;
|
||||
emit tabBarSettingsApplied(pos, m_allowTabBarMovement);
|
||||
}
|
||||
|
||||
void WorkspaceSettings::saveSettings(QSettings* qs)
|
||||
@ -122,12 +133,16 @@ void WorkspaceSettings::saveSettings(QSettings* qs)
|
||||
qs->beginGroup(QLatin1String("Workspace"));
|
||||
qs->setValue(QLatin1String("NumberOfWorkspaces"), m_numberOfWorkspaces);
|
||||
for (int i = 0; i < MAX_WORKSPACES; ++i) {
|
||||
QString mode = QString("Mode")+ QString::number(i+1);
|
||||
int j = m_modeNames.indexOf(mode);
|
||||
QString numberString = QString::number(i+1);
|
||||
QString defaultName = "Workspace" + numberString;
|
||||
QString defaultIconName = "Icon" + numberString;
|
||||
qs->setValue(defaultName, m_names.at(i));
|
||||
qs->setValue(defaultIconName, m_iconNames.at(i));
|
||||
qs->setValue(defaultName, m_names.at(j));
|
||||
qs->setValue(defaultIconName, m_iconNames.at(j));
|
||||
}
|
||||
qs->setValue(QLatin1String("TabBarPlacementIndex"), m_tabBarPlacementIndex);
|
||||
qs->setValue(QLatin1String("AllowTabBarMovement"), m_allowTabBarMovement);
|
||||
qs->endGroup();
|
||||
}
|
||||
|
||||
@ -137,15 +152,23 @@ void WorkspaceSettings::apply()
|
||||
|
||||
saveSettings(Core::ICore::instance()->settings());
|
||||
|
||||
if (m_numberOfWorkspaces != m_previousNumberOfWorkspaces) {
|
||||
Core::ICore::instance()->readMainSettings(Core::ICore::instance()->settings(), true);
|
||||
m_previousNumberOfWorkspaces = m_numberOfWorkspaces;
|
||||
}
|
||||
|
||||
ModeManager* modeManager = Core::ICore::instance()->modeManager();
|
||||
for (int i = 0; i < MAX_WORKSPACES; ++i) {
|
||||
Core::Internal::UAVGadgetMode *mode =
|
||||
qobject_cast<Core::Internal::UAVGadgetMode*>(modeManager->mode(modeName(i)));
|
||||
IMode *baseMode = modeManager->mode(modeName(i));
|
||||
Core::UAVGadgetManager *mode = qobject_cast<Core::UAVGadgetManager*>(baseMode);
|
||||
if (mode) {
|
||||
modeManager->updateModeNameIcon(mode, QIcon(iconName(i)), name(i));
|
||||
}
|
||||
}
|
||||
|
||||
m_tabBarPlacementIndex = m_page->comboBoxTabBarPlacement->currentIndex();
|
||||
m_allowTabBarMovement = m_page->checkBoxAllowTabMovement->isChecked();
|
||||
QTabWidget::TabPosition pos = m_tabBarPlacementIndex == 0 ? QTabWidget::North : QTabWidget::South;
|
||||
emit tabBarSettingsApplied(pos, m_allowTabBarMovement);
|
||||
}
|
||||
|
||||
void WorkspaceSettings::finish()
|
||||
@ -186,8 +209,8 @@ void WorkspaceSettings::selectWorkspace(int index, bool store)
|
||||
// write old values of workspace not shown anymore
|
||||
m_iconNames.replace(m_currentIndex, m_page->iconPathChooser->path());
|
||||
m_names.replace(m_currentIndex, m_page->nameEdit->text());
|
||||
m_page->workspaceComboBox->setItemIcon(m_currentIndex, QIcon(m_page->iconPathChooser->path()));
|
||||
m_page->workspaceComboBox->setItemText(m_currentIndex, m_page->nameEdit->text());
|
||||
m_page->workspaceComboBox->setItemIcon(m_currentIndex, QIcon(m_iconNames.at(m_currentIndex)));
|
||||
m_page->workspaceComboBox->setItemText(m_currentIndex, m_names.at(m_currentIndex));
|
||||
}
|
||||
|
||||
// display current workspace
|
||||
@ -196,3 +219,34 @@ void WorkspaceSettings::selectWorkspace(int index, bool store)
|
||||
m_page->nameEdit->setText(m_names.at(index));
|
||||
m_currentIndex = index;
|
||||
}
|
||||
|
||||
void WorkspaceSettings::newModeOrder(QVector<IMode*> modes)
|
||||
{
|
||||
QList<int> priorities;
|
||||
QStringList modeNames;
|
||||
for (int i = 0; i < modes.count(); ++i) {
|
||||
Core::UAVGadgetManager *mode = qobject_cast<Core::UAVGadgetManager*>(modes.at(i));
|
||||
if (mode) {
|
||||
priorities.append(mode->priority());
|
||||
modeNames.append(mode->uniqueModeName());
|
||||
}
|
||||
}
|
||||
// Bubble sort
|
||||
bool swapped = false;
|
||||
do {
|
||||
swapped = false;
|
||||
for (int i = 0; i < m_names.count()-1; ++i) {
|
||||
int j = i+1;
|
||||
int p = modeNames.indexOf(m_modeNames.at(i));
|
||||
int q = modeNames.indexOf(m_modeNames.at(j));
|
||||
bool nonShowingMode = (p == -1 && q >=0);
|
||||
bool pqBothFound = (p >= 0 && q >= 0);
|
||||
if (nonShowingMode || (pqBothFound && (priorities.at(q) > priorities.at(p)))) {
|
||||
m_names.swap(i, j);
|
||||
m_iconNames.swap(i, j);
|
||||
m_modeNames.swap(i, j);
|
||||
swapped = true;
|
||||
}
|
||||
}
|
||||
} while (swapped);
|
||||
}
|
||||
|
@ -31,12 +31,14 @@
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtGui/QTabWidget>
|
||||
|
||||
class QSettings;
|
||||
|
||||
namespace Core {
|
||||
|
||||
class ModeManager;
|
||||
class IMode;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@ -65,24 +67,29 @@ public:
|
||||
int numberOfWorkspaces() const { return m_numberOfWorkspaces;}
|
||||
QString iconName(int i) const { return m_iconNames.at(i);}
|
||||
QString name(int i) const { return m_names.at(i);}
|
||||
QString modeName(int i) const { return QString("Mode")+ QString::number(i+1);}
|
||||
QString modeName(int i) const { return m_modeNames.at(i);}
|
||||
|
||||
signals:
|
||||
void tabBarSettingsApplied(QTabWidget::TabPosition pos, bool movable);
|
||||
|
||||
public slots:
|
||||
void selectWorkspace(int index, bool store = false);
|
||||
void numberOfWorkspacesChanged(int value);
|
||||
void textEdited(QString string);
|
||||
void iconChanged();
|
||||
void newModeOrder(QVector<IMode*> modes);
|
||||
|
||||
private:
|
||||
Ui::WorkspaceSettings *m_page;
|
||||
QStringList m_iconNames;
|
||||
QStringList m_names;
|
||||
QStringList m_modeNames;
|
||||
int m_currentIndex;
|
||||
int m_previousNumberOfWorkspaces;
|
||||
int m_numberOfWorkspaces;
|
||||
int m_tabBarPlacementIndex;
|
||||
bool m_allowTabBarMovement;
|
||||
static const int MAX_WORKSPACES;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<width>414</width>
|
||||
<height>320</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -145,11 +145,71 @@ p, li { white-space: pre-wrap; }
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Note:</span> A restart is needed for changes to number of workspaces to take effect.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans'; font-size:8pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Note:</span> A restart is needed for changes to number of workspaces to take effect.</p></body></html></string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Workspace panel</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Placement:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxTabBarPlacement">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Allow reordering:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxAllowTabMovement">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -77,7 +77,8 @@ WelcomeModePrivate::WelcomeModePrivate()
|
||||
|
||||
// --- WelcomeMode
|
||||
WelcomeMode::WelcomeMode() :
|
||||
m_d(new WelcomeModePrivate)
|
||||
m_d(new WelcomeModePrivate),
|
||||
m_priority(Core::Constants::P_MODE_WELCOME)
|
||||
{
|
||||
m_d->m_widget = new QWidget;
|
||||
QVBoxLayout *l = new QVBoxLayout(m_d->m_widget);
|
||||
@ -122,7 +123,7 @@ QIcon WelcomeMode::icon() const
|
||||
|
||||
int WelcomeMode::priority() const
|
||||
{
|
||||
return Core::Constants::P_MODE_WELCOME;
|
||||
return m_priority;
|
||||
}
|
||||
|
||||
QWidget* WelcomeMode::widget()
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
void activated();
|
||||
QString contextHelpId() const { return QLatin1String("OpenPilot GCS"); }
|
||||
void initPlugins();
|
||||
void setPriority(int priority) { m_priority = priority; }
|
||||
|
||||
private slots:
|
||||
void slotFeedback();
|
||||
@ -69,6 +70,7 @@ private slots:
|
||||
|
||||
private:
|
||||
WelcomeModePrivate *m_d;
|
||||
int m_priority;
|
||||
};
|
||||
|
||||
} // namespace Welcome
|
||||
|
Loading…
Reference in New Issue
Block a user