QmlJSInspector: Save button states in settings

Change-Id: I5431e2ff63f2785ac3020dede165779cbb97dc45
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Aurindam Jana
2012-03-26 11:54:20 +02:00
parent 9a50052af1
commit 1cf369f71c
2 changed files with 40 additions and 13 deletions

View File

@@ -45,6 +45,7 @@
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <utils/styledbar.h> #include <utils/styledbar.h>
#include <utils/savedaction.h>
#include <QAction> #include <QAction>
#include <QActionGroup> #include <QActionGroup>
@@ -95,7 +96,6 @@ void QmlJsInspectorToolBar::enable()
{ {
setEnabled(true); setEnabled(true);
m_emitSignals = false; m_emitSignals = false;
m_showAppOnTopAction->setChecked(false);
setAnimationSpeed(1.0f); setAnimationSpeed(1.0f);
m_designModeActive = false; m_designModeActive = false;
updateDesignModeActions(NoTool); updateDesignModeActions(NoTool);
@@ -167,12 +167,22 @@ void QmlJsInspectorToolBar::createActions()
Core::Context context(Debugger::Constants::C_QMLDEBUGGER); Core::Context context(Debugger::Constants::C_QMLDEBUGGER);
Core::ActionManager *am = Core::ICore::actionManager(); Core::ActionManager *am = Core::ICore::actionManager();
m_fromQmlAction = m_fromQmlAction = new Utils::SavedAction(this);
new QAction(QIcon(QLatin1String(":/qml/images/from-qml-small.png")), m_fromQmlAction->setDefaultValue(true);
tr("Apply Changes on Save"), this); m_fromQmlAction->setSettingsKey(QLatin1String(Constants::S_QML_INSPECTOR),
m_showAppOnTopAction = QLatin1String(Constants::FROM_QML_ACTION));
new QAction(QIcon(QLatin1String(":/qml/images/app-on-top.png")), m_fromQmlAction->setText(tr("Apply Changes on Save"));
tr("Show application on top"), this); m_fromQmlAction->setCheckable(true);
m_fromQmlAction->setIcon(QIcon(QLatin1String(":/qml/images/from-qml-small.png")));
m_showAppOnTopAction = new Utils::SavedAction(this);
m_showAppOnTopAction->setDefaultValue(false);
m_showAppOnTopAction->setSettingsKey(QLatin1String(Constants::S_QML_INSPECTOR),
QLatin1String(Constants::SHOW_APP_ON_TOP_ACTION));
m_showAppOnTopAction->setText(tr("Show application on top"));
m_showAppOnTopAction->setCheckable(true);
m_showAppOnTopAction->setIcon(QIcon(QLatin1String(":/qml/images/app-on-top.png")));
m_playAction = m_playAction =
new QAction(m_pauseIcon, tr("Play/Pause Animations"), this); new QAction(m_pauseIcon, tr("Play/Pause Animations"), this);
m_selectAction = m_selectAction =
@@ -182,10 +192,6 @@ void QmlJsInspectorToolBar::createActions()
new QAction(QIcon(QLatin1String(":/qml/images/zoom-small.png")), new QAction(QIcon(QLatin1String(":/qml/images/zoom-small.png")),
tr("Zoom"), this); tr("Zoom"), this);
m_fromQmlAction->setCheckable(true);
m_fromQmlAction->setChecked(true);
m_showAppOnTopAction->setCheckable(true);
m_showAppOnTopAction->setChecked(false);
m_selectAction->setCheckable(true); m_selectAction->setCheckable(true);
m_zoomAction->setCheckable(true); m_zoomAction->setCheckable(true);
@@ -267,6 +273,24 @@ void QmlJsInspectorToolBar::createActions()
activeDebugLanguagesChanged(mw->activeDebugLanguages()); activeDebugLanguagesChanged(mw->activeDebugLanguages());
connect(mw, SIGNAL(activeDebugLanguagesChanged(Debugger::DebuggerLanguages)), connect(mw, SIGNAL(activeDebugLanguagesChanged(Debugger::DebuggerLanguages)),
this, SLOT(activeDebugLanguagesChanged(Debugger::DebuggerLanguages))); this, SLOT(activeDebugLanguagesChanged(Debugger::DebuggerLanguages)));
readSettings();
connect(Core::ICore::instance(),
SIGNAL(saveSettingsRequested()), SLOT(writeSettings()));
}
void QmlJsInspectorToolBar::readSettings()
{
QSettings *settings = Core::ICore::settings();
m_fromQmlAction->readSettings(settings);
m_showAppOnTopAction->readSettings(settings);
}
void QmlJsInspectorToolBar::writeSettings() const
{
QSettings *settings = Core::ICore::settings();
m_fromQmlAction->writeSettings(settings);
m_showAppOnTopAction->writeSettings(settings);
} }
QWidget *QmlJsInspectorToolBar::widget() const QWidget *QmlJsInspectorToolBar::widget() const

View File

@@ -46,6 +46,7 @@ QT_END_NAMESPACE
namespace Utils { namespace Utils {
class StyledBar; class StyledBar;
class SavedAction;
} }
namespace QmlJSInspector { namespace QmlJSInspector {
@@ -69,8 +70,10 @@ public:
explicit QmlJsInspectorToolBar(QObject *parent = 0); explicit QmlJsInspectorToolBar(QObject *parent = 0);
void createActions(); void createActions();
QWidget *widget() const; QWidget *widget() const;
void readSettings();
public slots: public slots:
void writeSettings() const;
void setEnabled(bool value); void setEnabled(bool value);
void enable(); void enable();
void disable(); void disable();
@@ -117,12 +120,12 @@ private:
QToolButton *m_operateByInstructionButton; QToolButton *m_operateByInstructionButton;
QAction *m_fromQmlAction; Utils::SavedAction *m_fromQmlAction;
QAction *m_playAction; QAction *m_playAction;
QAction *m_selectAction; QAction *m_selectAction;
QAction *m_zoomAction; QAction *m_zoomAction;
QAction *m_showAppOnTopAction; Utils::SavedAction *m_showAppOnTopAction;
QActionGroup *m_playSpeedMenuActions; QActionGroup *m_playSpeedMenuActions;