forked from qt-creator/qt-creator
Debugger: DebuggerSettings and QmlJSPropertyInspector
QmlJSPropertyInspector is a part of the debugger view and has dependencies on some of the actions in DebuggerSettings. Add the needed actions to the object pool so that QmlJSPropertyInspector can access them. Change-Id: Iad492f1195721b5e3a9033584b1a3bf64e320b18 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "debuggeractions.h"
|
||||
#include "debuggerconstants.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include "registerpostmortemaction.h"
|
||||
#endif
|
||||
@@ -39,6 +41,8 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QVariant>
|
||||
#include <QSettings>
|
||||
@@ -98,9 +102,13 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
|
||||
|
||||
SavedAction *item = 0;
|
||||
|
||||
//The Actions that are accessed by QML Inspector are added to PluginManager
|
||||
//Needed by QML Inspector
|
||||
item = new SavedAction(this);
|
||||
insertItem(SettingsDialog, item);
|
||||
item->setText(tr("Debugger Properties..."));
|
||||
item->setObjectName(QLatin1String(Constants::SETTINGS_DIALOG));
|
||||
ExtensionSystem::PluginManager::instance()->addObject(item);
|
||||
|
||||
//
|
||||
// View
|
||||
@@ -168,12 +176,15 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
|
||||
QLatin1String("AlwaysAdjustModulesColumnWidths"));
|
||||
insertItem(AlwaysAdjustModulesColumnWidths, item);
|
||||
|
||||
//Needed by QML Inspector
|
||||
item = new SavedAction(this);
|
||||
item->setText(tr("Use Alternating Row Colors"));
|
||||
item->setSettingsKey(debugModeGroup, QLatin1String("UseAlternatingRowColours"));
|
||||
item->setCheckable(true);
|
||||
item->setDefaultValue(false);
|
||||
insertItem(UseAlternatingRowColors, item);
|
||||
item->setObjectName(QLatin1String(Constants::USE_ALTERNATING_ROW_COLORS));
|
||||
ExtensionSystem::PluginManager::instance()->addObject(item);
|
||||
|
||||
item = new SavedAction(this);
|
||||
item->setText(tr("Debugger Font Size Follows Main Editor"));
|
||||
@@ -246,6 +257,7 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
|
||||
item->setValue(true);
|
||||
insertItem(ShowQtNamespace, item);
|
||||
|
||||
//Needed by QML Inspector
|
||||
item = new SavedAction(this);
|
||||
item->setSettingsKey(debugModeGroup, QLatin1String("SortStructMembers"));
|
||||
item->setText(tr("Sort Members of Classes and Structs Alphabetically"));
|
||||
@@ -253,6 +265,8 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
|
||||
item->setDefaultValue(true);
|
||||
item->setValue(true);
|
||||
insertItem(SortStructMembers, item);
|
||||
item->setObjectName(QLatin1String(Constants::SORT_STRUCT_MEMBERS));
|
||||
ExtensionSystem::PluginManager::instance()->addObject(item);
|
||||
|
||||
//
|
||||
// DebuggingHelper
|
||||
@@ -539,6 +553,18 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
|
||||
|
||||
DebuggerSettings::~DebuggerSettings()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pluginManager =
|
||||
ExtensionSystem::PluginManager::instance();
|
||||
QObject *o = pluginManager->getObjectByName(Constants::SETTINGS_DIALOG);
|
||||
if (o)
|
||||
pluginManager->removeObject(o);
|
||||
o = pluginManager->getObjectByName(Constants::USE_ALTERNATING_ROW_COLORS);
|
||||
if (o)
|
||||
pluginManager->removeObject(o);
|
||||
o = pluginManager->getObjectByName(Constants::SORT_STRUCT_MEMBERS);
|
||||
if (o)
|
||||
pluginManager->removeObject(o);
|
||||
|
||||
qDeleteAll(m_items);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,11 @@ const char DOCKWIDGET_QML_INSPECTOR[] = "Debugger.Docks.QmlInspector";
|
||||
const char DOCKWIDGET_QML_SCRIPTCONSOLE[] = "Debugger.Docks.ScriptConsole";
|
||||
const char DOCKWIDGET_DEFAULT_AREA[] = "Debugger.Docks.DefaultArea";
|
||||
|
||||
// Saved Actions
|
||||
const char SETTINGS_DIALOG[] = "SettingsDialog";
|
||||
const char USE_ALTERNATING_ROW_COLORS[] = "UseAlternatingRowColors";
|
||||
const char SORT_STRUCT_MEMBERS[] = "SortStructMembers";
|
||||
|
||||
} // namespace Constants
|
||||
|
||||
enum DebuggerState
|
||||
|
||||
@@ -49,6 +49,8 @@ const char SHOW_APP_ON_TOP_ACTION[] = "QmlInspector.ShowAppOnTop";
|
||||
const char S_QML_INSPECTOR [] = "QML.Inspector";
|
||||
const char S_LIVE_PREVIEW_WARNING_KEY[] = "ShowLivePreview";
|
||||
|
||||
const char ALWAYS_ADJUST_COLUMNS_WIDTHS[] = "AlwaysAdjustColumnWidths";
|
||||
|
||||
enum DesignTool {
|
||||
NoTool = 0,
|
||||
SelectionToolMode = 1,
|
||||
|
||||
@@ -30,6 +30,11 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
#include "qmljspropertyinspector.h"
|
||||
#include "qmljsinspectorconstants.h"
|
||||
|
||||
#include <debugger/debuggerconstants.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QItemDelegate>
|
||||
@@ -46,6 +51,7 @@
|
||||
#include <QMenu>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/savedaction.h>
|
||||
|
||||
const int PROPERTY_NAME_COLUMN = 0;
|
||||
const int PROPERTY_TYPE_COLUMN = 1;
|
||||
@@ -305,6 +311,56 @@ QmlJSPropertyInspector::QmlJSPropertyInspector(QWidget *parent)
|
||||
setModel(&m_model);
|
||||
//Add an empty Row to make the headers visible!
|
||||
addRow(QString(), QString(), QString(), -1, false);
|
||||
|
||||
m_adjustColumnsAction = new Utils::SavedAction(this);
|
||||
m_adjustColumnsAction->setText(tr("Always Adjust Column Widths to Contents"));
|
||||
m_adjustColumnsAction->setCheckable(true);
|
||||
m_adjustColumnsAction->setValue(false);
|
||||
m_adjustColumnsAction->setDefaultValue(false);
|
||||
m_adjustColumnsAction->setSettingsKey(QLatin1String(Constants::S_QML_INSPECTOR),
|
||||
QLatin1String(Constants::ALWAYS_ADJUST_COLUMNS_WIDTHS));
|
||||
readSettings();
|
||||
connect(Core::ICore::instance(),
|
||||
SIGNAL(saveSettingsRequested()), SLOT(writeSettings()));
|
||||
|
||||
setAlwaysAdjustColumnsAction(m_adjustColumnsAction);
|
||||
|
||||
QAction *act = qobject_cast<QAction *>(
|
||||
ExtensionSystem::PluginManager::instance()->getObjectByName(
|
||||
QLatin1String(Debugger::Constants::USE_ALTERNATING_ROW_COLORS)));
|
||||
if (act) {
|
||||
setAlternatingRowColors(act->isChecked());
|
||||
connect(act, SIGNAL(toggled(bool)),
|
||||
SLOT(setAlternatingRowColorsHelper(bool)));
|
||||
}
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::readSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
m_adjustColumnsAction->readSettings(settings);
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::writeSettings() const
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
m_adjustColumnsAction->writeSettings(settings);
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::addBaseContextActions(QMenu *menu)
|
||||
{
|
||||
QAction *act = qobject_cast<QAction *>(
|
||||
ExtensionSystem::PluginManager::instance()->getObjectByName(
|
||||
QLatin1String(Debugger::Constants::SORT_STRUCT_MEMBERS)));
|
||||
if (act)
|
||||
menu->addAction(act);
|
||||
Utils::BaseTreeView::addBaseContextActions(menu);
|
||||
|
||||
act = qobject_cast<QAction *>(
|
||||
ExtensionSystem::PluginManager::instance()->getObjectByName(
|
||||
QLatin1String(Debugger::Constants::SETTINGS_DIALOG)));
|
||||
if (act)
|
||||
menu->addAction(act);
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::clear()
|
||||
@@ -436,6 +492,11 @@ void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &ob
|
||||
m_model.setHeaderData(PROPERTY_VALUE_COLUMN, Qt::Horizontal,QVariant("value"));
|
||||
m_model.setHeaderData(PROPERTY_TYPE_COLUMN, Qt::Horizontal,QVariant("type"));
|
||||
|
||||
QAction *act = qobject_cast<QAction *>(
|
||||
ExtensionSystem::PluginManager::instance()->getObjectByName(
|
||||
QLatin1String(Debugger::Constants::SORT_STRUCT_MEMBERS)));
|
||||
if (act && act->isChecked())
|
||||
m_model.sort(PROPERTY_NAME_COLUMN);
|
||||
}
|
||||
|
||||
void QmlJSPropertyInspector::addRow(const QString &name,const QString &value,
|
||||
|
||||
@@ -45,6 +45,10 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class SavedAction;
|
||||
}
|
||||
|
||||
namespace QmlJSInspector {
|
||||
namespace Internal {
|
||||
|
||||
@@ -125,6 +129,8 @@ public:
|
||||
};
|
||||
|
||||
explicit QmlJSPropertyInspector(QWidget *parent = 0);
|
||||
void readSettings();
|
||||
void addBaseContextActions(QMenu *menu);
|
||||
void clear();
|
||||
void setContentsValid(bool contentsValid);
|
||||
bool contentsValid() const;
|
||||
@@ -135,6 +141,7 @@ signals:
|
||||
void customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
public slots:
|
||||
void writeSettings() const;
|
||||
void setCurrentObjects(const QList<QmlDebugObjectReference> &);
|
||||
void propertyValueEdited(const int objectId,const QString &propertyName,
|
||||
const QString &propertyValue, bool isLiteral = false);
|
||||
@@ -158,6 +165,7 @@ private:
|
||||
|
||||
QmlJSPropertyInspectorModel m_model;
|
||||
QList<int> m_currentObjects;
|
||||
Utils::SavedAction *m_adjustColumnsAction;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
|
||||
Reference in New Issue
Block a user