mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
GCS/coreplugin: Modification to allow two (or more) modes with splittable views. Fixed crash bug. Commented out some items not thought to be needed in mainwindow.cpp/h
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@326 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
a3486477eb
commit
de4f097073
@ -87,11 +87,10 @@ MessageManager *CoreImpl::messageManager() const
|
||||
return m_mainwindow->messageManager();
|
||||
}
|
||||
|
||||
UAVGadgetManager *CoreImpl::uavGadgetManager() const
|
||||
{
|
||||
return m_mainwindow->uavGadgetManager();
|
||||
}
|
||||
|
||||
//UAVGadgetManager *CoreImpl::uavGadgetManager() const
|
||||
//{
|
||||
// return m_mainwindow->uavGadgetManager();
|
||||
//}
|
||||
|
||||
VariableManager *CoreImpl::variableManager() const
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
ActionManager *actionManager() const;
|
||||
UniqueIDManager *uniqueIDManager() const;
|
||||
MessageManager *messageManager() const;
|
||||
UAVGadgetManager *uavGadgetManager() const;
|
||||
// UAVGadgetManager *uavGadgetManager() const;
|
||||
VariableManager *variableManager() const;
|
||||
ModeManager *modeManager() const;
|
||||
MimeDatabase *mimeDatabase() const;
|
||||
|
@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
#include "coreplugin.h"
|
||||
#include "coreimpl.h"
|
||||
#include "mainwindow.h"
|
||||
#include "modemanager.h"
|
||||
#include "uavgadgetmode.h"
|
||||
@ -39,16 +40,19 @@
|
||||
using namespace Core::Internal;
|
||||
|
||||
CorePlugin::CorePlugin() :
|
||||
m_mainWindow(new MainWindow),
|
||||
m_uavGadgetMode(0)
|
||||
m_mainWindow(new MainWindow)
|
||||
// m_uavGadgetMode(0)
|
||||
{
|
||||
}
|
||||
|
||||
CorePlugin::~CorePlugin()
|
||||
{
|
||||
if (m_uavGadgetMode) {
|
||||
removeObject(m_uavGadgetMode);
|
||||
delete m_uavGadgetMode;
|
||||
if (m_uavGadgetModes.count() > 0) {
|
||||
foreach (UAVGadgetMode *mode, m_uavGadgetModes)
|
||||
{
|
||||
removeObject(mode);
|
||||
delete mode;
|
||||
}
|
||||
}
|
||||
delete m_mainWindow;
|
||||
}
|
||||
@ -58,9 +62,21 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
Q_UNUSED(arguments)
|
||||
const bool success = m_mainWindow->init(errorMessage);
|
||||
if (success) {
|
||||
UAVGadgetManager *uavGadgetManager = m_mainWindow->uavGadgetManager();
|
||||
m_uavGadgetMode = new UAVGadgetMode(uavGadgetManager);
|
||||
addObject(m_uavGadgetMode);
|
||||
UAVGadgetMode *uavGadgetMode;
|
||||
UAVGadgetManager *m_uavGadgetManager = new UAVGadgetManager(CoreImpl::instance(), m_mainWindow);
|
||||
m_uavGadgetManager->hide();
|
||||
uavGadgetMode = new UAVGadgetMode(m_uavGadgetManager, QString("Mode 1"),
|
||||
QIcon(":/core/images/openpilot_logo_64.png"), 80, QString("Mode1"));
|
||||
m_uavGadgetManager->setUAVGadgetMode(uavGadgetMode);
|
||||
m_uavGadgetModes.append(uavGadgetMode);
|
||||
addObject(uavGadgetMode);
|
||||
m_uavGadgetManager = new UAVGadgetManager(CoreImpl::instance(), m_mainWindow);
|
||||
m_uavGadgetManager->hide();
|
||||
uavGadgetMode = new UAVGadgetMode(m_uavGadgetManager, QString("Mode 2"),
|
||||
QIcon(":/core/images/plus.png"), 60, QString("Mode2"));
|
||||
m_uavGadgetManager->setUAVGadgetMode(uavGadgetMode);
|
||||
m_uavGadgetModes.append(uavGadgetMode);
|
||||
addObject(uavGadgetMode);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public slots:
|
||||
|
||||
private:
|
||||
MainWindow *m_mainWindow;
|
||||
UAVGadgetMode *m_uavGadgetMode;
|
||||
QList<UAVGadgetMode*> m_uavGadgetModes;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
virtual MessageManager *messageManager() const = 0;
|
||||
virtual VariableManager *variableManager() const = 0;
|
||||
virtual ModeManager *modeManager() const = 0;
|
||||
virtual UAVGadgetManager *uavGadgetManager() const = 0;
|
||||
// virtual UAVGadgetManager *uavGadgetManager() const = 0;
|
||||
virtual MimeDatabase *mimeDatabase() const = 0;
|
||||
|
||||
virtual QSettings *settings() const = 0;
|
||||
|
@ -110,11 +110,11 @@ MainWindow::MainWindow() :
|
||||
this)),
|
||||
m_actionManager(new ActionManagerPrivate(this)),
|
||||
m_variableManager(new VariableManager(this)),
|
||||
m_viewManager(0),
|
||||
// m_viewManager(0),
|
||||
m_modeManager(0),
|
||||
m_uavGadgetManager(0),
|
||||
m_mimeDatabase(new MimeDatabase),
|
||||
m_rightPaneWidget(0),
|
||||
// m_rightPaneWidget(0),
|
||||
m_versionDialog(0),
|
||||
m_activeContext(0),
|
||||
m_generalSettings(new GeneralSettings),
|
||||
@ -163,18 +163,17 @@ MainWindow::MainWindow() :
|
||||
registerDefaultContainers();
|
||||
registerDefaultActions();
|
||||
|
||||
m_rightPaneWidget = new RightPaneWidget();
|
||||
// m_rightPaneWidget = new RightPaneWidget();
|
||||
|
||||
m_modeStack = new FancyTabWidget(this);
|
||||
m_modeManager = new ModeManager(this, m_modeStack);
|
||||
//m_modeManager->addWidget(m_progressManager->progressView());
|
||||
m_viewManager = new ViewManager(this);
|
||||
// m_viewManager = new ViewManager(this);
|
||||
m_messageManager = new MessageManager;
|
||||
m_uavGadgetManager = new UAVGadgetManager(m_coreImpl, this);
|
||||
m_uavGadgetManager->hide();
|
||||
// m_uavGadgetManager = new UAVGadgetManager(m_coreImpl, this);
|
||||
// m_uavGadgetManager->hide();
|
||||
setCentralWidget(m_modeStack);
|
||||
|
||||
|
||||
connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)),
|
||||
this, SLOT(updateFocusWidget(QWidget*,QWidget*)));
|
||||
|
||||
@ -204,15 +203,15 @@ MainWindow::~MainWindow()
|
||||
delete m_uniqueIDManager;
|
||||
m_uniqueIDManager = 0;
|
||||
|
||||
delete m_viewManager;
|
||||
m_viewManager = 0;
|
||||
// delete m_viewManager;
|
||||
// m_viewManager = 0;
|
||||
|
||||
pm->removeObject(m_coreImpl);
|
||||
delete m_coreImpl;
|
||||
m_coreImpl = 0;
|
||||
|
||||
delete m_rightPaneWidget;
|
||||
m_rightPaneWidget = 0;
|
||||
// delete m_rightPaneWidget;
|
||||
// m_rightPaneWidget = 0;
|
||||
|
||||
delete m_modeManager;
|
||||
m_modeManager = 0;
|
||||
@ -226,7 +225,7 @@ bool MainWindow::init(QString *errorMessage)
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
pm->addObject(m_coreImpl);
|
||||
m_viewManager->init();
|
||||
// m_viewManager->init();
|
||||
m_modeManager->init();
|
||||
|
||||
pm->addObject(m_generalSettings);
|
||||
@ -242,7 +241,7 @@ void MainWindow::modeChanged(Core::IMode */*mode*/)
|
||||
|
||||
void MainWindow::extensionsInitialized()
|
||||
{
|
||||
m_viewManager->extensionsInitalized();
|
||||
// m_viewManager->extensionsInitalized();
|
||||
|
||||
m_messageManager->init();
|
||||
|
||||
@ -382,6 +381,7 @@ void MainWindow::registerDefaultContainers()
|
||||
menubar->addMenu(mwindow, Constants::G_WINDOW);
|
||||
mwindow->menu()->setTitle(tr("&Window"));
|
||||
mwindow->appendGroup(Constants::G_WINDOW_SIZE);
|
||||
mwindow->appendGroup(Constants::G_WINDOW_HIDE_TOOLBAR);
|
||||
mwindow->appendGroup(Constants::G_WINDOW_PANES);
|
||||
mwindow->appendGroup(Constants::G_WINDOW_SPLIT);
|
||||
mwindow->appendGroup(Constants::G_WINDOW_NAVIGATE);
|
||||
@ -869,7 +869,7 @@ void MainWindow::readSettings()
|
||||
|
||||
m_settings->endGroup();
|
||||
|
||||
m_rightPaneWidget->readSettings(m_settings);
|
||||
// m_rightPaneWidget->readSettings(m_settings);
|
||||
}
|
||||
|
||||
void MainWindow::writeSettings()
|
||||
@ -889,7 +889,7 @@ void MainWindow::writeSettings()
|
||||
|
||||
m_settings->endGroup();
|
||||
|
||||
m_viewManager->saveSettings(m_settings);
|
||||
// m_viewManager->saveSettings(m_settings);
|
||||
m_actionManager->saveSettings(m_settings);
|
||||
}
|
||||
|
||||
|
@ -162,12 +162,12 @@ private:
|
||||
ActionManagerPrivate *m_actionManager;
|
||||
MessageManager *m_messageManager;
|
||||
VariableManager *m_variableManager;
|
||||
ViewManager *m_viewManager;
|
||||
// ViewManager *m_viewManager;
|
||||
ModeManager *m_modeManager;
|
||||
UAVGadgetManager *m_uavGadgetManager;
|
||||
MimeDatabase *m_mimeDatabase;
|
||||
FancyTabWidget *m_modeStack;
|
||||
RightPaneWidget *m_rightPaneWidget;
|
||||
// RightPaneWidget *m_rightPaneWidget;
|
||||
Core::BaseView *m_outputView;
|
||||
VersionDialog *m_versionDialog;
|
||||
|
||||
|
@ -67,7 +67,7 @@ ModeManager::ModeManager(Internal::MainWindow *mainWindow, FancyTabWidget *modeS
|
||||
m_instance = this;
|
||||
|
||||
m_actionBar = new FancyActionBar(modeStack);
|
||||
m_modeStack->addCornerWidget(m_actionBar);
|
||||
// m_modeStack->addCornerWidget(m_actionBar);
|
||||
|
||||
connect(m_modeStack, SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
|
||||
connect(m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
||||
@ -92,7 +92,9 @@ void ModeManager::addWidget(QWidget *widget)
|
||||
|
||||
IMode *ModeManager::currentMode() const
|
||||
{
|
||||
if (m_modes.count() > 0)
|
||||
return m_modes.at(m_modeStack->currentIndex());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ModeManager::indexOf(const QString &id) const
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "uavgadgetmanager.h"
|
||||
#include "uavgadgetview.h"
|
||||
#include "uavgadgetmode.h"
|
||||
#include "iuavgadgetfactory.h"
|
||||
#include "iuavgadget.h"
|
||||
#include "icore.h"
|
||||
@ -77,46 +78,51 @@ static inline ExtensionSystem::PluginManager *pluginManager()
|
||||
|
||||
//===================UAVGadgetManager=====================
|
||||
|
||||
UAVGadgetManagerPlaceHolder *UAVGadgetManagerPlaceHolder::m_current = 0;
|
||||
//UAVGadgetManagerPlaceHolder *UAVGadgetManagerPlaceHolder::m_current = 0;
|
||||
|
||||
UAVGadgetManagerPlaceHolder::UAVGadgetManagerPlaceHolder(Core::IMode *mode, QWidget *parent)
|
||||
: QWidget(parent), m_mode(mode)
|
||||
UAVGadgetManagerPlaceHolder::UAVGadgetManagerPlaceHolder(Core::Internal::UAVGadgetMode *mode, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_current(0),
|
||||
m_uavGadgetMode(mode)
|
||||
{
|
||||
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 *)));
|
||||
|
||||
//Julien: this line is crashing (I guess when no mode are added yet)
|
||||
//currentModeChanged(Core::ModeManager::instance()->currentMode());
|
||||
currentModeChanged(Core::ModeManager::instance()->currentMode());
|
||||
}
|
||||
|
||||
UAVGadgetManagerPlaceHolder::~UAVGadgetManagerPlaceHolder()
|
||||
{
|
||||
if (m_current == this) {
|
||||
UAVGadgetManager::instance()->setParent(0);
|
||||
UAVGadgetManager::instance()->hide();
|
||||
m_uavGadgetMode->uavGadgetManager()->setParent(0);
|
||||
m_uavGadgetMode->uavGadgetManager()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void UAVGadgetManagerPlaceHolder::currentModeChanged(Core::IMode *mode)
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << mode;
|
||||
UAVGadgetManager *gm = m_uavGadgetMode->uavGadgetManager();
|
||||
if (m_current == this) {
|
||||
m_current = 0;
|
||||
UAVGadgetManager::instance()->setParent(0);
|
||||
UAVGadgetManager::instance()->hide();
|
||||
gm->setParent(0);
|
||||
gm->hide();
|
||||
}
|
||||
if (m_mode == mode) {
|
||||
m_current = this;
|
||||
layout()->addWidget(UAVGadgetManager::instance());
|
||||
UAVGadgetManager::instance()->show();
|
||||
layout()->addWidget(gm);
|
||||
gm->hideToolbars(gm->toolbarsHidden());
|
||||
gm->show();
|
||||
}
|
||||
}
|
||||
|
||||
UAVGadgetManagerPlaceHolder* UAVGadgetManagerPlaceHolder::current()
|
||||
{
|
||||
return m_current;
|
||||
}
|
||||
//UAVGadgetManagerPlaceHolder* UAVGadgetManagerPlaceHolder::current()
|
||||
//{
|
||||
// return m_current;
|
||||
//}
|
||||
|
||||
// ---------------- UAVGadgetManager
|
||||
|
||||
@ -134,23 +140,28 @@ struct UAVGadgetManagerPrivate {
|
||||
ICore *m_core;
|
||||
|
||||
// actions
|
||||
QAction *m_hideToolbarsAction;
|
||||
QAction *m_splitAction;
|
||||
QAction *m_splitSideBySideAction;
|
||||
QAction *m_removeCurrentSplitAction;
|
||||
QAction *m_removeAllSplitsAction;
|
||||
QAction *m_gotoOtherSplitAction;
|
||||
QAction *m_closeCurrentUAVGadgetAction;
|
||||
static QAction *m_hideToolbarsAction;
|
||||
static QAction *m_splitAction;
|
||||
static QAction *m_splitSideBySideAction;
|
||||
static QAction *m_removeCurrentSplitAction;
|
||||
static QAction *m_removeAllSplitsAction;
|
||||
static QAction *m_gotoOtherSplitAction;
|
||||
|
||||
Internal::UAVGadgetClosingCoreListener *m_coreListener;
|
||||
};
|
||||
}
|
||||
|
||||
QAction *UAVGadgetManagerPrivate::m_hideToolbarsAction = 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) :
|
||||
m_view(0),
|
||||
m_splitterOrView(0),
|
||||
m_core(core),
|
||||
m_closeCurrentUAVGadgetAction(new QAction(UAVGadgetManager::tr("Close"), parent)),
|
||||
m_coreListener(0)
|
||||
{
|
||||
}
|
||||
@ -159,29 +170,18 @@ UAVGadgetManagerPrivate::~UAVGadgetManagerPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
UAVGadgetManager *UAVGadgetManager::m_instance = 0;
|
||||
|
||||
/*static Command *createSeparator(ActionManager *am, QObject *parent,
|
||||
const QString &name,
|
||||
const QList<int> &context)
|
||||
{
|
||||
QAction *tmpaction = new QAction(parent);
|
||||
tmpaction->setSeparator(true);
|
||||
Command *cmd = am->registerAction(tmpaction, name, context);
|
||||
return cmd;
|
||||
}*/
|
||||
|
||||
UAVGadgetManager::UAVGadgetManager(ICore *core, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_hidden(false),
|
||||
m_d(new UAVGadgetManagerPrivate(core, parent))
|
||||
{
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
m_instance = this;
|
||||
// m_instance = this;
|
||||
|
||||
// //qDebug() << Q_FUNC_INFO << m_d->m_core->resourcePath();
|
||||
connect(m_d->m_core, SIGNAL(contextAboutToChange(Core::IContext *)),
|
||||
this, SLOT(handleContextChange(Core::IContext *)));
|
||||
const QList<int> gc = QList<int>() << Constants::C_GLOBAL_ID;
|
||||
// const QList<int> gc = QList<int>() << Constants::C_GLOBAL_ID;
|
||||
const QList<int> uavGadgetManagerContext =
|
||||
QList<int>() << m_d->m_core->uniqueIDManager()->uniqueIdentifier(Constants::C_UAVGADGETMANAGER);
|
||||
|
||||
@ -189,33 +189,35 @@ UAVGadgetManager::UAVGadgetManager(ICore *core, QWidget *parent) :
|
||||
|
||||
//Window Menu
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
Command *cmd;
|
||||
|
||||
// The actions m_d->m_hideToolbarsAction 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_hideToolbarsAction == 0)
|
||||
{
|
||||
//Window menu separators
|
||||
QAction *tmpaction = new QAction(this);
|
||||
tmpaction->setSeparator(true);
|
||||
Command *cmd = am->registerAction(tmpaction, QLatin1String("OpenPilot.Window.Sep.Split"), uavGadgetManagerContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
cmd = am->registerAction(tmpaction, QLatin1String("OpenPilot.Window.Sep.Split"), uavGadgetManagerContext);
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_HIDE_TOOLBAR);
|
||||
|
||||
m_d->m_hideToolbarsAction = new QAction(tr("Hide toolbars"), this);
|
||||
m_d->m_hideToolbarsAction->setCheckable(true);
|
||||
cmd = am->registerAction(m_d->m_hideToolbarsAction, Constants::HIDE_TOOLBARS, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence("Ctrl+Shift+F10"));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
connect(m_d->m_hideToolbarsAction, SIGNAL(triggered(bool)), this, SLOT(hideToolbars(bool)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_HIDE_TOOLBAR);
|
||||
|
||||
// //Window menu separators
|
||||
//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);
|
||||
|
||||
//Close Action
|
||||
// //qDebug() << Q_FUNC_INFO << "close cmd" << m_d->m_closeCurrentUAVGadgetAction;
|
||||
cmd = am->registerAction(m_d->m_closeCurrentUAVGadgetAction, Constants::CLOSE, uavGadgetManagerContext);
|
||||
// cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+W")));
|
||||
cmd->setAttribute(Core::Command::CA_UpdateText);
|
||||
cmd->setDefaultText(m_d->m_closeCurrentUAVGadgetAction->text());
|
||||
connect(m_d->m_closeCurrentUAVGadgetAction, SIGNAL(triggered()), this, SLOT(closeUAVGadget()));
|
||||
}
|
||||
connect(m_d->m_hideToolbarsAction, SIGNAL(triggered(bool)), this, SLOT(hideToolbars(bool)));
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
QString prefix = tr("Meta+E");
|
||||
@ -223,43 +225,55 @@ UAVGadgetManager::UAVGadgetManager(ICore *core, QWidget *parent) :
|
||||
QString prefix = tr("Ctrl+E");
|
||||
#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,2").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,3").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("Remove Current Split"), this);
|
||||
cmd = am->registerAction(m_d->m_removeCurrentSplitAction, Constants::REMOVE_CURRENT_SPLIT, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1,0").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("Remove All Splits"), this);
|
||||
cmd = am->registerAction(m_d->m_removeAllSplitsAction, Constants::REMOVE_ALL_SPLITS, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1,1").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 Other Split"), this);
|
||||
cmd = am->registerAction(m_d->m_gotoOtherSplitAction, Constants::GOTO_OTHER_SPLIT, uavGadgetManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("%1,o").arg(prefix)));
|
||||
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||
}
|
||||
connect(m_d->m_gotoOtherSplitAction, SIGNAL(triggered()), this, SLOT(gotoOtherSplit()));
|
||||
|
||||
|
||||
// other setup
|
||||
m_d->m_splitterOrView = new SplitterOrView(0, true);
|
||||
m_d->m_splitterOrView = new SplitterOrView(this, 0, true);
|
||||
m_d->m_view = m_d->m_splitterOrView->view();
|
||||
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
@ -430,7 +444,7 @@ bool UAVGadgetManager::closeAllUAVGadgets()
|
||||
{
|
||||
// if (closeUAVGadgets(openedUAVGadgets())) {
|
||||
// m_d->clearNavigationHistory();
|
||||
return true;
|
||||
// return true;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
@ -614,7 +628,7 @@ void UAVGadgetManager::ensureUAVGadgetManagerVisible()
|
||||
{
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
if (!isVisible())
|
||||
m_d->m_core->modeManager()->activateMode(Constants::MODE_UAVGADGET);
|
||||
m_d->m_core->modeManager()->activateMode(m_uavGadgetMode->uniqueModeName());
|
||||
}
|
||||
|
||||
void UAVGadgetManager::updateActions()
|
||||
@ -752,6 +766,8 @@ void UAVGadgetManager::readSettings()
|
||||
|
||||
void UAVGadgetManager::split(Qt::Orientation orientation)
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
return;
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
SplitterOrView *view = m_d->m_currentView;
|
||||
// //qDebug() << Q_FUNC_INFO << view << m_d->m_currentUAVGadget;
|
||||
@ -779,6 +795,8 @@ void UAVGadgetManager::splitSideBySide()
|
||||
|
||||
void UAVGadgetManager::removeCurrentSplit()
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
return;
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
SplitterOrView *viewToClose = m_d->m_currentView;
|
||||
if (!viewToClose && m_d->m_currentUAVGadget)
|
||||
@ -793,6 +811,8 @@ void UAVGadgetManager::removeCurrentSplit()
|
||||
|
||||
void UAVGadgetManager::removeAllSplits()
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
return;
|
||||
if (!m_d->m_splitterOrView->isSplitter())
|
||||
return;
|
||||
IUAVGadget *uavGadget = m_d->m_currentUAVGadget;
|
||||
@ -805,6 +825,8 @@ void UAVGadgetManager::removeAllSplits()
|
||||
|
||||
void UAVGadgetManager::gotoOtherSplit()
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
return;
|
||||
if (m_d->m_splitterOrView->isSplitter()) {
|
||||
SplitterOrView *currentView = m_d->m_currentView;
|
||||
if (!currentView && m_d->m_currentUAVGadget)
|
||||
@ -827,6 +849,10 @@ void UAVGadgetManager::gotoOtherSplit()
|
||||
|
||||
void UAVGadgetManager::hideToolbars(bool hide)
|
||||
{
|
||||
if (m_d->m_core->modeManager()->currentMode() != m_uavGadgetMode)
|
||||
return;
|
||||
m_d->m_hideToolbarsAction->setChecked(hide);
|
||||
m_hidden = hide;
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
QList<SplitterOrView*> views;
|
||||
SplitterOrView *next = m_d->m_splitterOrView->findFirstView();
|
||||
|
@ -54,6 +54,7 @@ struct UAVGadgetManagerPrivate;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class UAVGadgetMode;
|
||||
class UAVGadgetView;
|
||||
class SplitterOrView;
|
||||
|
||||
@ -66,14 +67,15 @@ class CORE_EXPORT UAVGadgetManagerPlaceHolder : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UAVGadgetManagerPlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
||||
UAVGadgetManagerPlaceHolder(Core::Internal::UAVGadgetMode *mode, QWidget *parent = 0);
|
||||
~UAVGadgetManagerPlaceHolder();
|
||||
static UAVGadgetManagerPlaceHolder* current();
|
||||
// static UAVGadgetManagerPlaceHolder* current();
|
||||
private slots:
|
||||
void currentModeChanged(Core::IMode *);
|
||||
private:
|
||||
Core::IMode *m_mode;
|
||||
static UAVGadgetManagerPlaceHolder* m_current;
|
||||
Core::Internal::UAVGadgetMode *m_uavGadgetMode;
|
||||
UAVGadgetManagerPlaceHolder* m_current;
|
||||
};
|
||||
|
||||
class CORE_EXPORT UAVGadgetManager : public QWidget
|
||||
@ -86,7 +88,9 @@ public:
|
||||
explicit UAVGadgetManager(ICore *core, QWidget *parent);
|
||||
virtual ~UAVGadgetManager();
|
||||
void init();
|
||||
static UAVGadgetManager *instance() { return m_instance; }
|
||||
// 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; }
|
||||
|
||||
void ensureUAVGadgetManagerVisible();
|
||||
|
||||
@ -100,6 +104,7 @@ public:
|
||||
|
||||
void saveSettings();
|
||||
void readSettings();
|
||||
bool toolbarsHidden() { return m_hidden; }
|
||||
|
||||
UAVGadgetFactoryList uavGadgetFactories() const;
|
||||
|
||||
@ -141,8 +146,9 @@ private:
|
||||
Core::Internal::UAVGadgetView *currentUAVGadgetView() const;
|
||||
IUAVGadget *pickUnusedUAVGadget() const;
|
||||
|
||||
static UAVGadgetManager *m_instance;
|
||||
UAVGadgetManagerPrivate *m_d;
|
||||
Core::Internal::UAVGadgetMode *m_uavGadgetMode;
|
||||
bool m_hidden;
|
||||
|
||||
friend class Core::Internal::SplitterOrView;
|
||||
friend class Core::Internal::UAVGadgetView;
|
||||
|
@ -63,8 +63,9 @@ using namespace Core::Internal;
|
||||
|
||||
// ================UAVGadgetView====================
|
||||
|
||||
UAVGadgetView::UAVGadgetView(IUAVGadget *uavGadget, QWidget *parent) :
|
||||
UAVGadgetView::UAVGadgetView(UAVGadgetManager *uavGadgetManager, IUAVGadget *uavGadget, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_uavGadgetManager(uavGadgetManager),
|
||||
m_uavGadget(uavGadget),
|
||||
m_toolBar(new QWidget),
|
||||
m_defaultToolBar(new QWidget(this)),
|
||||
@ -116,8 +117,8 @@ UAVGadgetView::UAVGadgetView(IUAVGadget *uavGadget, QWidget *parent) :
|
||||
// //qDebug() << Q_FUNC_INFO << uavGadget;
|
||||
ActionManager *am = ICore::instance()->actionManager();
|
||||
// //qDebug() << Q_FUNC_INFO << uavGadget << am;
|
||||
connect(am->command(Constants::CLOSE), SIGNAL(keySequenceChanged()),
|
||||
this, SLOT(updateActionShortcuts()));
|
||||
// connect(am->command(Constants::CLOSE), SIGNAL(keySequenceChanged()),
|
||||
// this, SLOT(updateActionShortcuts()));
|
||||
|
||||
updateActionShortcuts();
|
||||
// updateActions();
|
||||
@ -140,8 +141,7 @@ void UAVGadgetView::hideToolbar(bool hide)
|
||||
void UAVGadgetView::closeView()
|
||||
{
|
||||
// m_top->hide();
|
||||
UAVGadgetManager *gm = CoreImpl::instance()->uavGadgetManager();
|
||||
gm->closeView(this);
|
||||
m_uavGadgetManager->closeView(this);
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
/* removeUAVGadget();
|
||||
if (m_uavGadget)
|
||||
@ -228,17 +228,18 @@ void UAVGadgetView::listSelectionActivated(int index)
|
||||
void UAVGadgetView::updateActionShortcuts()
|
||||
{
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
ActionManager *am = ICore::instance()->actionManager();
|
||||
m_closeButton->setToolTip(am->command(Constants::CLOSE)->stringWithAppendedShortcut(UAVGadgetManager::tr("Close")));
|
||||
// ActionManager *am = ICore::instance()->actionManager();
|
||||
// m_closeButton->setToolTip(am->command(Constants::CLOSE)->stringWithAppendedShortcut(UAVGadgetManager::tr("Close")));
|
||||
}
|
||||
|
||||
|
||||
SplitterOrView::SplitterOrView(Core::IUAVGadget *uavGadget, bool isRoot)
|
||||
SplitterOrView::SplitterOrView(UAVGadgetManager *uavGadgetManager, Core::IUAVGadget *uavGadget, bool isRoot) :
|
||||
m_uavGadgetManager(uavGadgetManager),
|
||||
m_isRoot(isRoot)
|
||||
{
|
||||
//qDebug() << Q_FUNC_INFO << uavGadget << isRoot;
|
||||
m_isRoot = isRoot;
|
||||
// //qDebug() << Q_FUNC_INFO << uavGadget << isRoot;
|
||||
m_view = new UAVGadgetView(uavGadget);
|
||||
m_view = new UAVGadgetView(m_uavGadgetManager, uavGadget);
|
||||
m_layout = new QStackedLayout(this);
|
||||
m_splitter = 0;
|
||||
m_layout->addWidget(m_view);
|
||||
@ -258,13 +259,13 @@ void SplitterOrView::mousePressEvent(QMouseEvent *e)
|
||||
if (e->button() != Qt::LeftButton)
|
||||
return;
|
||||
setFocus(Qt::MouseFocusReason);
|
||||
CoreImpl::instance()->uavGadgetManager()->setCurrentView(this);
|
||||
m_uavGadgetManager->setCurrentView(this);
|
||||
}
|
||||
|
||||
void SplitterOrView::paintEvent(QPaintEvent *)
|
||||
{
|
||||
// //qDebug() << Q_FUNC_INFO;
|
||||
if (CoreImpl::instance()->uavGadgetManager()->currentSplitterOrView() != this)
|
||||
if (m_uavGadgetManager->currentSplitterOrView() != this)
|
||||
return;
|
||||
|
||||
if (!m_view || hasUAVGadgets())
|
||||
@ -464,18 +465,17 @@ void SplitterOrView::split(Qt::Orientation orientation)
|
||||
m_splitter = new MiniSplitter(this);
|
||||
m_splitter->setOrientation(orientation);
|
||||
m_layout->addWidget(m_splitter);
|
||||
UAVGadgetManager *gm = CoreImpl::instance()->uavGadgetManager();
|
||||
Core::IUAVGadget *e = m_view->currentUAVGadget();
|
||||
|
||||
SplitterOrView *view = 0;
|
||||
SplitterOrView *otherView = 0;
|
||||
if (e) {
|
||||
m_view->removeUAVGadget();
|
||||
m_splitter->addWidget((view = new SplitterOrView(e)));
|
||||
m_splitter->addWidget((otherView = new SplitterOrView()));
|
||||
m_splitter->addWidget((view = new SplitterOrView(m_uavGadgetManager, e)));
|
||||
m_splitter->addWidget((otherView = new SplitterOrView(m_uavGadgetManager)));
|
||||
} else {
|
||||
m_splitter->addWidget((otherView = new SplitterOrView()));
|
||||
m_splitter->addWidget((view = new SplitterOrView()));
|
||||
m_splitter->addWidget((otherView = new SplitterOrView(m_uavGadgetManager)));
|
||||
m_splitter->addWidget((view = new SplitterOrView(m_uavGadgetManager)));
|
||||
}
|
||||
|
||||
// QWidget *w = m_layout->currentWidget();
|
||||
@ -483,12 +483,12 @@ void SplitterOrView::split(Qt::Orientation orientation)
|
||||
// m_layout->removeWidget(w);
|
||||
|
||||
if (m_view && !m_isRoot) {
|
||||
gm->emptyView(m_view);
|
||||
m_uavGadgetManager->emptyView(m_view);
|
||||
delete m_view;
|
||||
m_view = 0;
|
||||
}
|
||||
|
||||
gm->setCurrentView(view);
|
||||
m_uavGadgetManager->setCurrentView(view);
|
||||
}
|
||||
|
||||
void SplitterOrView::unsplitAll()
|
||||
@ -505,7 +505,7 @@ void SplitterOrView::unsplitAll_helper()
|
||||
{
|
||||
//qDebug() << Q_FUNC_INFO;
|
||||
if (!m_isRoot && m_view)
|
||||
CoreImpl::instance()->uavGadgetManager()->emptyView(m_view);
|
||||
m_uavGadgetManager->emptyView(m_view);
|
||||
if (m_splitter) {
|
||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
||||
if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) {
|
||||
@ -522,7 +522,6 @@ void SplitterOrView::unsplit()
|
||||
return;
|
||||
|
||||
Q_ASSERT(m_splitter->count() == 1);
|
||||
UAVGadgetManager *em = CoreImpl::instance()->uavGadgetManager();
|
||||
SplitterOrView *childSplitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(0));
|
||||
QSplitter *oldSplitter = m_splitter;
|
||||
m_splitter = 0;
|
||||
@ -540,7 +539,7 @@ void SplitterOrView::unsplit()
|
||||
childView->removeUAVGadget();
|
||||
m_view->setCurrentUAVGadget(e);
|
||||
}
|
||||
em->emptyView(childView);
|
||||
m_uavGadgetManager->emptyView(childView);
|
||||
} else {
|
||||
m_view = childSplitterOrView->takeView();
|
||||
m_layout->addWidget(m_view);
|
||||
@ -548,71 +547,71 @@ void SplitterOrView::unsplit()
|
||||
m_layout->setCurrentWidget(m_view);
|
||||
}
|
||||
delete oldSplitter;
|
||||
em->setCurrentView(findFirstView());
|
||||
m_uavGadgetManager->setCurrentView(findFirstView());
|
||||
}
|
||||
|
||||
|
||||
QByteArray SplitterOrView::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
/* QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
|
||||
if (m_splitter) {
|
||||
stream << QByteArray("splitter")
|
||||
<< (qint32)m_splitter->orientation()
|
||||
<< m_splitter->saveState()
|
||||
<< static_cast<SplitterOrView*>(m_splitter->widget(0))->saveState()
|
||||
<< static_cast<SplitterOrView*>(m_splitter->widget(1))->saveState();
|
||||
} else {
|
||||
IUAVGadget* e = uavGadget();
|
||||
UAVGadgetManager *em = CoreImpl::instance()->uavGadgetManager();
|
||||
|
||||
if (e && e == em->currentUAVGadget()) {
|
||||
stream << QByteArray("currentuavGadget")
|
||||
<< e->file()->fileName() << e->kind() << e->saveState();
|
||||
} else if (e) {
|
||||
stream << QByteArray("uavGadget")
|
||||
<< e->file()->fileName() << e->kind() << e->saveState();
|
||||
} else {
|
||||
stream << QByteArray("empty");
|
||||
}
|
||||
}*/
|
||||
// QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
//
|
||||
// if (m_splitter) {
|
||||
// stream << QByteArray("splitter")
|
||||
// << (qint32)m_splitter->orientation()
|
||||
// << m_splitter->saveState()
|
||||
// << static_cast<SplitterOrView*>(m_splitter->widget(0))->saveState()
|
||||
// << static_cast<SplitterOrView*>(m_splitter->widget(1))->saveState();
|
||||
// } else {
|
||||
// IUAVGadget* e = uavGadget();
|
||||
// UAVGadgetManager *em = CoreImpl::instance()->uavGadgetManager();
|
||||
//
|
||||
// if (e && e == em->currentUAVGadget()) {
|
||||
// stream << QByteArray("currentuavGadget")
|
||||
// << e->file()->fileName() << e->kind() << e->saveState();
|
||||
// } else if (e) {
|
||||
// stream << QByteArray("uavGadget")
|
||||
// << e->file()->fileName() << e->kind() << e->saveState();
|
||||
// } else {
|
||||
// stream << QByteArray("empty");
|
||||
// }
|
||||
// }
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void SplitterOrView::restoreState(const QByteArray &state)
|
||||
{
|
||||
/* QDataStream stream(state);
|
||||
QByteArray mode;
|
||||
stream >> mode;
|
||||
if (mode == "splitter") {
|
||||
qint32 orientation;
|
||||
QByteArray splitter, first, second;
|
||||
stream >> orientation >> splitter >> first >> second;
|
||||
split((Qt::Orientation)orientation);
|
||||
m_splitter->restoreState(splitter);
|
||||
static_cast<SplitterOrView*>(m_splitter->widget(0))->restoreState(first);
|
||||
static_cast<SplitterOrView*>(m_splitter->widget(1))->restoreState(second);
|
||||
} else if (mode == "uavGadget" || mode == "currentuavGadget") {
|
||||
UAVGadgetManager *em = CoreImpl::instance()->uavGadgetManager();
|
||||
QString fileName;
|
||||
QByteArray kind;
|
||||
QByteArray uavGadgetState;
|
||||
stream >> fileName >> kind >> uavGadgetState;
|
||||
IUAVGadget *e = em->openUAVGadget(view(), fileName, kind, Core::UAVGadgetManager::IgnoreNavigationHistory
|
||||
| Core::UAVGadgetManager::NoActivate);
|
||||
|
||||
if (!e) {
|
||||
QModelIndex idx = em->openedUAVGadgetsModel()->firstRestoredUAVGadget();
|
||||
if (idx.isValid())
|
||||
em->activateUAVGadget(idx, view(), Core::UAVGadgetManager::IgnoreNavigationHistory
|
||||
| Core::UAVGadgetManager::NoActivate);
|
||||
}
|
||||
|
||||
if (e) {
|
||||
e->restoreState(uavGadgetState);
|
||||
if (mode == "currentuavGadget")
|
||||
em->setCurrentUAVGadget(e);
|
||||
}
|
||||
}*/
|
||||
// QDataStream stream(state);
|
||||
// QByteArray mode;
|
||||
// stream >> mode;
|
||||
// if (mode == "splitter") {
|
||||
// qint32 orientation;
|
||||
// QByteArray splitter, first, second;
|
||||
// stream >> orientation >> splitter >> first >> second;
|
||||
// split((Qt::Orientation)orientation);
|
||||
// m_splitter->restoreState(splitter);
|
||||
// static_cast<SplitterOrView*>(m_splitter->widget(0))->restoreState(first);
|
||||
// static_cast<SplitterOrView*>(m_splitter->widget(1))->restoreState(second);
|
||||
// } else if (mode == "uavGadget" || mode == "currentuavGadget") {
|
||||
// UAVGadgetManager *em = CoreImpl::instance()->uavGadgetManager();
|
||||
// QString fileName;
|
||||
// QByteArray kind;
|
||||
// QByteArray uavGadgetState;
|
||||
// stream >> fileName >> kind >> uavGadgetState;
|
||||
// IUAVGadget *e = em->openUAVGadget(view(), fileName, kind, Core::UAVGadgetManager::IgnoreNavigationHistory
|
||||
// | Core::UAVGadgetManager::NoActivate);
|
||||
//
|
||||
// if (!e) {
|
||||
// QModelIndex idx = em->openedUAVGadgetsModel()->firstRestoredUAVGadget();
|
||||
// if (idx.isValid())
|
||||
// em->activateUAVGadget(idx, view(), Core::UAVGadgetManager::IgnoreNavigationHistory
|
||||
// | Core::UAVGadgetManager::NoActivate);
|
||||
// }
|
||||
//
|
||||
// if (e) {
|
||||
// e->restoreState(uavGadgetState);
|
||||
// if (mode == "currentuavGadget")
|
||||
// em->setCurrentUAVGadget(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ class StyledBar;
|
||||
namespace Core {
|
||||
|
||||
class IUAVGadget;
|
||||
class UAVGadgetManager;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@ -62,7 +63,7 @@ class UAVGadgetView : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UAVGadgetView(IUAVGadget *uavGadget = 0, QWidget *parent = 0);
|
||||
UAVGadgetView(UAVGadgetManager *uavGadgetManager, IUAVGadget *uavGadget = 0, QWidget *parent = 0);
|
||||
virtual ~UAVGadgetView();
|
||||
|
||||
void removeUAVGadget();
|
||||
@ -81,6 +82,7 @@ private slots:
|
||||
private:
|
||||
void updateToolBar();
|
||||
|
||||
UAVGadgetManager *m_uavGadgetManager;
|
||||
IUAVGadget *m_uavGadget;
|
||||
QWidget *m_toolBar;
|
||||
QWidget *m_defaultToolBar;
|
||||
@ -96,7 +98,7 @@ class SplitterOrView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SplitterOrView(Core::IUAVGadget *uavGadget = 0, bool root = false);
|
||||
SplitterOrView(UAVGadgetManager *uavGadgetManager, Core::IUAVGadget *uavGadget = 0, bool root = false);
|
||||
~SplitterOrView();
|
||||
|
||||
void split(Qt::Orientation orientation);
|
||||
@ -135,13 +137,11 @@ protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
|
||||
|
||||
private:
|
||||
void unsplitAll_helper();
|
||||
SplitterOrView *findNextView_helper(SplitterOrView *view, bool *found);
|
||||
public:
|
||||
UAVGadgetManager *m_uavGadgetManager;
|
||||
bool m_isRoot;
|
||||
private:
|
||||
QStackedLayout *m_layout;
|
||||
UAVGadgetView *m_view;
|
||||
QSplitter *m_splitter;
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "iuavgadget.h"
|
||||
|
||||
#include <QtCore/QLatin1String>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QSplitter>
|
||||
@ -45,8 +44,11 @@
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
UAVGadgetMode::UAVGadgetMode(UAVGadgetManager *uavGadgetManager) :
|
||||
UAVGadgetMode::UAVGadgetMode(UAVGadgetManager *uavGadgetManager, QString name, QIcon icon, int priority, QString uniqueName) :
|
||||
m_uavGadgetManager(uavGadgetManager),
|
||||
m_name(name),
|
||||
m_icon(icon),
|
||||
m_priority(0),
|
||||
m_widget(new QWidget),
|
||||
m_layout(new QVBoxLayout)
|
||||
{
|
||||
@ -54,26 +56,18 @@ UAVGadgetMode::UAVGadgetMode(UAVGadgetManager *uavGadgetManager) :
|
||||
m_layout->setMargin(0);
|
||||
m_widget->setLayout(m_layout);
|
||||
m_layout->insertWidget(0, new Core::UAVGadgetManagerPlaceHolder(this));
|
||||
|
||||
// MiniSplitter *rightPaneSplitter = new MiniSplitter;
|
||||
// rightPaneSplitter->insertWidget(0, rightSplitWidget);
|
||||
// rightPaneSplitter->insertWidget(1, new RightPanePlaceHolder(this));
|
||||
// rightPaneSplitter->setStretchFactor(0, 1);
|
||||
// rightPaneSplitter->setStretchFactor(1, 0);
|
||||
//
|
||||
// MiniSplitter *splitter = new MiniSplitter;
|
||||
// splitter->setOrientation(Qt::Vertical);
|
||||
// splitter->insertWidget(0, rightPaneSplitter);
|
||||
// splitter->insertWidget(1, new Core::OutputPanePlaceHolder(this));
|
||||
// splitter->setStretchFactor(0, 3);
|
||||
// splitter->setStretchFactor(1, 0);
|
||||
//
|
||||
// m_splitter->insertWidget(0, new NavigationWidgetPlaceHolder(this));
|
||||
// m_splitter->insertWidget(1, splitter);
|
||||
// m_splitter->setStretchFactor(0, 0);
|
||||
// m_splitter->setStretchFactor(1, 1);
|
||||
if (0 <= priority && priority <= 100)
|
||||
m_priority = priority;
|
||||
|
||||
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));
|
||||
}
|
||||
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)),
|
||||
this, SLOT(grabUAVGadgetManager(Core::IMode*)));
|
||||
m_widget->setFocusProxy(m_uavGadgetManager);
|
||||
@ -81,6 +75,7 @@ UAVGadgetMode::UAVGadgetMode(UAVGadgetManager *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;
|
||||
@ -88,17 +83,17 @@ UAVGadgetMode::~UAVGadgetMode()
|
||||
|
||||
QString UAVGadgetMode::name() const
|
||||
{
|
||||
return tr("UavGadget");
|
||||
return m_name;
|
||||
}
|
||||
|
||||
QIcon UAVGadgetMode::icon() const
|
||||
{
|
||||
return QIcon(QLatin1String(":/core/images/openpilot_logo_64.png"));
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
int UAVGadgetMode::priority() const
|
||||
{
|
||||
return Constants::P_MODE_UAVGADGET;
|
||||
return m_priority;
|
||||
}
|
||||
|
||||
QWidget* UAVGadgetMode::widget()
|
||||
@ -108,7 +103,7 @@ QWidget* UAVGadgetMode::widget()
|
||||
|
||||
const char* UAVGadgetMode::uniqueModeName() const
|
||||
{
|
||||
return Constants::MODE_UAVGADGET;
|
||||
return m_uniqueName.toAscii().data();
|
||||
}
|
||||
|
||||
QList<int> UAVGadgetMode::context() const
|
||||
|
@ -32,10 +32,12 @@
|
||||
#include <coreplugin/imode.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSplitter;
|
||||
class QWidget;
|
||||
class QIcon;
|
||||
class QVBoxLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@ -50,7 +52,7 @@ class UAVGadgetMode : public Core::IMode
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UAVGadgetMode(UAVGadgetManager *uavGadgetManager);
|
||||
UAVGadgetMode(UAVGadgetManager *uavGadgetManager, QString name, QIcon icon, int priority, QString uniqueName);
|
||||
~UAVGadgetMode();
|
||||
|
||||
// IMode
|
||||
@ -60,6 +62,7 @@ public:
|
||||
QWidget* widget();
|
||||
const char* uniqueModeName() const;
|
||||
QList<int> context() const;
|
||||
UAVGadgetManager* uavGadgetManager() const { return m_uavGadgetManager; }
|
||||
|
||||
private slots:
|
||||
void grabUAVGadgetManager(Core::IMode *mode);
|
||||
@ -68,6 +71,10 @@ private:
|
||||
UAVGadgetManager *m_uavGadgetManager;
|
||||
QWidget *m_widget;
|
||||
QVBoxLayout *m_layout;
|
||||
QString m_name;
|
||||
QIcon m_icon;
|
||||
QString m_uniqueName;
|
||||
int m_priority;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Loading…
Reference in New Issue
Block a user