forked from qt-creator/qt-creator
QmlJSInspector: Remove Color Picker Tool
Change-Id: Ic1a158f3e96052fcf30071ec827c23a4a83625f5 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
committed by
Kai Koehne
parent
ebeb5b7f49
commit
f14dffe681
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB |
@@ -95,8 +95,6 @@ void ClientProxy::connectToServer()
|
||||
this, SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
|
||||
connect(m_inspectorClient, SIGNAL(currentObjectsChanged(QList<int>)),
|
||||
SLOT(onCurrentObjectsChanged(QList<int>)));
|
||||
connect(m_inspectorClient, SIGNAL(colorPickerActivated()),
|
||||
SIGNAL(colorPickerActivated()));
|
||||
connect(m_inspectorClient, SIGNAL(zoomToolActivated()),
|
||||
SIGNAL(zoomToolActivated()));
|
||||
connect(m_inspectorClient, SIGNAL(selectToolActivated()),
|
||||
@@ -113,8 +111,6 @@ void ClientProxy::connectToServer()
|
||||
SIGNAL(showAppOnTopChanged(bool)));
|
||||
connect(m_inspectorClient, SIGNAL(reloaded()), this,
|
||||
SIGNAL(serverReloaded()));
|
||||
connect(m_inspectorClient, SIGNAL(selectedColorChanged(QColor)),
|
||||
SIGNAL(selectedColorChanged(QColor)));
|
||||
connect(m_inspectorClient, SIGNAL(logActivity(QString,QString)),
|
||||
m_adapter.data(), SLOT(logServiceActivity(QString,QString)));
|
||||
|
||||
@@ -609,12 +605,6 @@ void ClientProxy::setAnimationPaused(bool paused)
|
||||
m_inspectorClient->setAnimationPaused(paused);
|
||||
}
|
||||
|
||||
void ClientProxy::changeToColorPickerTool()
|
||||
{
|
||||
if (isConnected())
|
||||
m_inspectorClient->changeToColorPickerTool();
|
||||
}
|
||||
|
||||
void ClientProxy::changeToZoomTool()
|
||||
{
|
||||
if (isConnected())
|
||||
|
@@ -108,7 +108,6 @@ signals:
|
||||
void connected();
|
||||
void disconnected();
|
||||
|
||||
void colorPickerActivated();
|
||||
void selectToolActivated();
|
||||
void selectMarqueeToolActivated();
|
||||
void zoomToolActivated();
|
||||
@@ -117,7 +116,6 @@ signals:
|
||||
void designModeBehaviorChanged(bool inDesignMode);
|
||||
void showAppOnTopChanged(bool showAppOnTop);
|
||||
void serverReloaded();
|
||||
void selectedColorChanged(const QColor &color);
|
||||
void propertyChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue);
|
||||
|
||||
void result(quint32 queryId, const QVariant &result);
|
||||
@@ -130,7 +128,6 @@ public slots:
|
||||
void setDesignModeBehavior(bool inDesignMode);
|
||||
void setAnimationSpeed(qreal slowDownFactor);
|
||||
void setAnimationPaused(bool paused);
|
||||
void changeToColorPickerTool();
|
||||
void changeToZoomTool();
|
||||
void changeToSelectTool();
|
||||
void changeToSelectMarqueeTool();
|
||||
|
@@ -720,20 +720,6 @@ void InspectorUi::gotoObjectReferenceDefinition(const QmlDebugObjectReference &o
|
||||
}
|
||||
}
|
||||
|
||||
bool InspectorUi::addQuotesForData(const QVariant &value) const
|
||||
{
|
||||
switch (value.type()) {
|
||||
case QVariant::String:
|
||||
case QVariant::Color:
|
||||
case QVariant::Date:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void InspectorUi::setupDockWidgets()
|
||||
{
|
||||
Debugger::DebuggerMainWindow *mw = Debugger::DebuggerPlugin::mainWindow();
|
||||
@@ -877,8 +863,6 @@ void InspectorUi::connectSignals()
|
||||
connect(m_clientProxy, SIGNAL(disconnected()),
|
||||
this, SLOT(disable()));
|
||||
|
||||
connect(m_clientProxy, SIGNAL(colorPickerActivated()),
|
||||
m_toolBar, SLOT(activateColorPicker()));
|
||||
connect(m_clientProxy, SIGNAL(selectToolActivated()),
|
||||
m_toolBar, SLOT(activateSelectTool()));
|
||||
connect(m_clientProxy, SIGNAL(zoomToolActivated()),
|
||||
@@ -887,8 +871,6 @@ void InspectorUi::connectSignals()
|
||||
m_toolBar, SLOT(setDesignModeBehavior(bool)));
|
||||
connect(m_clientProxy, SIGNAL(showAppOnTopChanged(bool)),
|
||||
m_toolBar, SLOT(setShowAppOnTop(bool)));
|
||||
connect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)),
|
||||
m_toolBar, SLOT(setSelectedColor(QColor)));
|
||||
connect(m_clientProxy, SIGNAL(animationSpeedChanged(qreal)),
|
||||
m_toolBar, SLOT(setAnimationSpeed(qreal)));
|
||||
connect(m_clientProxy, SIGNAL(animationPausedChanged(bool)),
|
||||
@@ -905,8 +887,6 @@ void InspectorUi::connectSignals()
|
||||
m_clientProxy, SLOT(setAnimationSpeed(qreal)));
|
||||
connect(m_toolBar, SIGNAL(animationPausedChanged(bool)),
|
||||
m_clientProxy, SLOT(setAnimationPaused(bool)));
|
||||
connect(m_toolBar, SIGNAL(colorPickerSelected()),
|
||||
m_clientProxy, SLOT(changeToColorPickerTool()));
|
||||
connect(m_toolBar, SIGNAL(zoomToolSelected()),
|
||||
m_clientProxy, SLOT(changeToZoomTool()));
|
||||
connect(m_toolBar, SIGNAL(selectToolSelected()),
|
||||
|
@@ -136,7 +136,6 @@ private slots:
|
||||
void showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
|
||||
|
||||
private:
|
||||
bool addQuotesForData(const QVariant &value) const;
|
||||
void resetViews();
|
||||
|
||||
void initializeDocuments();
|
||||
|
@@ -20,7 +20,6 @@ qmljsclientproxy.h \
|
||||
qmljsinspector.h \
|
||||
qmljsinspectortoolbar.h \
|
||||
qmljslivetextpreview.h \
|
||||
qmljstoolbarcolorbox.h \
|
||||
qmljsinspectorclient.h \
|
||||
qmljscontextcrumblepath.h \
|
||||
qmljsinspectorsettings.h \
|
||||
@@ -32,7 +31,6 @@ qmljsclientproxy.cpp \
|
||||
qmljsinspector.cpp \
|
||||
qmljsinspectortoolbar.cpp \
|
||||
qmljslivetextpreview.cpp \
|
||||
qmljstoolbarcolorbox.cpp \
|
||||
qmljsinspectorclient.cpp \
|
||||
qmljscontextcrumblepath.cpp \
|
||||
qmljsinspectorsettings.cpp \
|
||||
|
@@ -39,7 +39,6 @@ QtcPlugin {
|
||||
"qmljsinspector.h",
|
||||
"qmljsinspectortoolbar.h",
|
||||
"qmljslivetextpreview.h",
|
||||
"qmljstoolbarcolorbox.h",
|
||||
"qmljsinspectorclient.h",
|
||||
"qmljscontextcrumblepath.h",
|
||||
"qmljsinspectorsettings.h",
|
||||
@@ -50,7 +49,6 @@ QtcPlugin {
|
||||
"qmljsinspector.cpp",
|
||||
"qmljsinspectortoolbar.cpp",
|
||||
"qmljslivetextpreview.cpp",
|
||||
"qmljstoolbarcolorbox.cpp",
|
||||
"qmljsinspectorclient.cpp",
|
||||
"qmljscontextcrumblepath.cpp",
|
||||
"qmljsinspectorsettings.cpp",
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/qml">
|
||||
<file>images/color-picker.png</file>
|
||||
<file>images/from-qml.png</file>
|
||||
<file>images/pause.png</file>
|
||||
<file>images/reload.png</file>
|
||||
@@ -9,7 +8,6 @@
|
||||
<file>images/to-qml.png</file>
|
||||
<file>images/select-marquee.png</file>
|
||||
<file>images/zoom.png</file>
|
||||
<file>images/color-picker-small.png</file>
|
||||
<file>images/select-small.png</file>
|
||||
<file>images/play-small.png</file>
|
||||
<file>images/to-qml-small.png</file>
|
||||
@@ -17,7 +15,6 @@
|
||||
<file>images/from-qml-small.png</file>
|
||||
<file>images/zoom-small.png</file>
|
||||
<file>images/select-marquee-small.png</file>
|
||||
<file>images/color-picker-small-hicontrast.png</file>
|
||||
<file>images/app-on-top.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@@ -33,8 +33,6 @@
|
||||
#include "qmljsclientproxy.h"
|
||||
#include "qmljsinspectorconstants.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
using namespace QmlJSDebugger;
|
||||
|
||||
namespace QmlJSInspector {
|
||||
@@ -85,9 +83,7 @@ void QmlJSInspectorClient::messageReceived(const QByteArray &message)
|
||||
|
||||
log(LogReceive, type, QString::number(toolId));
|
||||
|
||||
if (toolId == Constants::ColorPickerMode) {
|
||||
emit colorPickerActivated();
|
||||
} else if (toolId == Constants::ZoomMode) {
|
||||
if (toolId == Constants::ZoomMode) {
|
||||
emit zoomToolActivated();
|
||||
} else if (toolId == Constants::SelectionToolMode) {
|
||||
emit selectToolActivated();
|
||||
@@ -137,17 +133,8 @@ void QmlJSInspectorClient::messageReceived(const QByteArray &message)
|
||||
emit reloaded();
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ColorChanged: {
|
||||
QColor col;
|
||||
ds >> col;
|
||||
|
||||
log(LogReceive, type, col.name());
|
||||
|
||||
emit selectedColorChanged(col);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning() << "Warning: Not handling message:" << type;
|
||||
log(LogReceive, type, QLatin1String("Warning: Not handling message"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,24 +287,6 @@ void QmlJSInspectorClient::setAnimationPaused(bool paused)
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QmlJSInspectorClient::changeToColorPickerTool()
|
||||
{
|
||||
if (!m_connection || !m_connection->isConnected())
|
||||
return;
|
||||
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
InspectorProtocol::Message cmd = InspectorProtocol::ChangeTool;
|
||||
InspectorProtocol::Tool tool = InspectorProtocol::ColorPickerTool;
|
||||
ds << cmd
|
||||
<< tool;
|
||||
|
||||
log(LogSend, cmd, InspectorProtocol::toString(tool));
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QmlJSInspectorClient::changeToSelectTool()
|
||||
{
|
||||
if (!m_connection || !m_connection->isConnected())
|
||||
|
@@ -51,7 +51,6 @@ public:
|
||||
void setDesignModeBehavior(bool inDesignMode);
|
||||
void setAnimationSpeed(qreal slowDownFactor);
|
||||
void setAnimationPaused(bool paused);
|
||||
void changeToColorPickerTool();
|
||||
void changeToSelectTool();
|
||||
void changeToSelectMarqueeTool();
|
||||
void changeToZoomTool();
|
||||
@@ -76,8 +75,6 @@ signals:
|
||||
void connectedStatusChanged(QDeclarativeDebugClient::Status status);
|
||||
|
||||
void currentObjectsChanged(const QList<int> &debugIds);
|
||||
void selectedColorChanged(const QColor &color);
|
||||
void colorPickerActivated();
|
||||
void selectToolActivated();
|
||||
void selectMarqueeToolActivated();
|
||||
void zoomToolActivated();
|
||||
|
@@ -42,7 +42,6 @@ const char INFO_OUT_OF_SYNC[] = "QmlInspector.OutOfSyncWarning";
|
||||
const char PLAY_ACTION[] = "QmlInspector.Play";
|
||||
const char SELECT_ACTION[] = "QmlInspector.Select";
|
||||
const char ZOOM_ACTION[] = "QmlInspector.Zoom";
|
||||
const char COLOR_PICKER_ACTION[] = "QmlInspector.ColorPicker";
|
||||
const char FROM_QML_ACTION[] = "QmlInspector.FromQml";
|
||||
const char SHOW_APP_ON_TOP_ACTION[] = "QmlInspector.ShowAppOnTop";
|
||||
|
||||
@@ -56,7 +55,6 @@ enum DesignTool {
|
||||
MarqueeSelectionToolMode = 2,
|
||||
MoveToolMode = 3,
|
||||
ResizeToolMode = 4,
|
||||
ColorPickerMode = 5,
|
||||
ZoomMode = 6
|
||||
};
|
||||
|
||||
|
@@ -33,7 +33,6 @@
|
||||
#include "qmljsinspectortoolbar.h"
|
||||
|
||||
#include "qmljsinspectorconstants.h"
|
||||
#include "qmljstoolbarcolorbox.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
@@ -70,12 +69,10 @@ QmlJsInspectorToolBar::QmlJsInspectorToolBar(QObject *parent) :
|
||||
m_playAction(0),
|
||||
m_selectAction(0),
|
||||
m_zoomAction(0),
|
||||
m_colorPickerAction(0),
|
||||
m_showAppOnTopAction(0),
|
||||
m_playSpeedMenuActions(0),
|
||||
m_playIcon(QIcon(QLatin1String(":/qml/images/play-small.png"))),
|
||||
m_pauseIcon(QIcon(QLatin1String(":/qml/images/pause-small.png"))),
|
||||
m_colorBox(0),
|
||||
m_emitSignals(true),
|
||||
m_paused(false),
|
||||
m_animationSpeed(1.0f),
|
||||
@@ -92,8 +89,6 @@ void QmlJsInspectorToolBar::setEnabled(bool value)
|
||||
m_playAction->setEnabled(value);
|
||||
m_selectAction->setEnabled(value);
|
||||
m_zoomAction->setEnabled(value);
|
||||
m_colorPickerAction->setEnabled(value);
|
||||
m_colorBox->setEnabled(value);
|
||||
}
|
||||
|
||||
void QmlJsInspectorToolBar::enable()
|
||||
@@ -115,11 +110,6 @@ void QmlJsInspectorToolBar::disable()
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
void QmlJsInspectorToolBar::activateColorPicker()
|
||||
{
|
||||
updateDesignModeActions(ColorPickerMode);
|
||||
}
|
||||
|
||||
void QmlJsInspectorToolBar::activateSelectTool()
|
||||
{
|
||||
updateDesignModeActions(SelectionToolMode);
|
||||
@@ -191,9 +181,6 @@ void QmlJsInspectorToolBar::createActions()
|
||||
m_zoomAction =
|
||||
new QAction(QIcon(QLatin1String(":/qml/images/zoom-small.png")),
|
||||
tr("Zoom"), this);
|
||||
m_colorPickerAction =
|
||||
new QAction(QIcon(QLatin1String(":/qml/images/color-picker-small.png")),
|
||||
tr("Color Picker"), this);
|
||||
|
||||
m_fromQmlAction->setCheckable(true);
|
||||
m_fromQmlAction->setChecked(true);
|
||||
@@ -201,13 +188,11 @@ void QmlJsInspectorToolBar::createActions()
|
||||
m_showAppOnTopAction->setChecked(false);
|
||||
m_selectAction->setCheckable(true);
|
||||
m_zoomAction->setCheckable(true);
|
||||
m_colorPickerAction->setCheckable(true);
|
||||
|
||||
Core::Command *command = am->registerAction(m_playAction, Constants::PLAY_ACTION, context);
|
||||
command->setAttribute(Core::Command::CA_UpdateIcon);
|
||||
am->registerAction(m_selectAction, Constants::SELECT_ACTION, context);
|
||||
am->registerAction(m_zoomAction, Constants::ZOOM_ACTION, context);
|
||||
am->registerAction(m_colorPickerAction, Constants::COLOR_PICKER_ACTION, context);
|
||||
am->registerAction(m_fromQmlAction, Constants::FROM_QML_ACTION, context);
|
||||
am->registerAction(m_showAppOnTopAction, Constants::SHOW_APP_ON_TOP_ACTION, context);
|
||||
|
||||
@@ -271,19 +256,10 @@ void QmlJsInspectorToolBar::createActions()
|
||||
toolBarLayout->addWidget(new Utils::StyledSeparator);
|
||||
toolBarLayout->addWidget(toolButton(am->command(Constants::SELECT_ACTION)->action()));
|
||||
toolBarLayout->addWidget(toolButton(am->command(Constants::ZOOM_ACTION)->action()));
|
||||
toolBarLayout->addWidget(toolButton(am->command(Constants::COLOR_PICKER_ACTION)->action()));
|
||||
|
||||
m_colorBox = new ToolBarColorBox(m_barWidget);
|
||||
m_colorBox->setMinimumSize(20, 20);
|
||||
m_colorBox->setMaximumSize(20, 20);
|
||||
m_colorBox->setInnerBorderColor(QColor(192, 192, 192));
|
||||
m_colorBox->setOuterBorderColor(QColor(58, 58, 58));
|
||||
toolBarLayout->addWidget(m_colorBox);
|
||||
|
||||
connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml()));
|
||||
connect(m_showAppOnTopAction, SIGNAL(triggered()), SLOT(showAppOnTopClick()));
|
||||
connect(m_playAction, SIGNAL(triggered()), SLOT(activatePlayOnClick()));
|
||||
connect(m_colorPickerAction, SIGNAL(triggered(bool)), SLOT(colorPickerTriggered(bool)));
|
||||
connect(m_selectAction, SIGNAL(triggered(bool)), SLOT(selectToolTriggered(bool)));
|
||||
connect(m_zoomAction, SIGNAL(triggered(bool)), SLOT(zoomToolTriggered(bool)));
|
||||
|
||||
@@ -320,19 +296,6 @@ void QmlJsInspectorToolBar::updatePlayAction()
|
||||
m_playAction->setIcon(m_paused ? m_playIcon : m_pauseIcon);
|
||||
}
|
||||
|
||||
void QmlJsInspectorToolBar::colorPickerTriggered(bool checked)
|
||||
{
|
||||
updateDesignModeActions(ColorPickerMode);
|
||||
|
||||
if (m_designModeActive != checked) {
|
||||
m_designModeActive = checked;
|
||||
emit designModeSelected(checked);
|
||||
}
|
||||
|
||||
if (checked)
|
||||
emit colorPickerSelected();
|
||||
}
|
||||
|
||||
void QmlJsInspectorToolBar::selectToolTriggered(bool checked)
|
||||
{
|
||||
updateDesignModeActions(SelectionToolMode);
|
||||
@@ -365,11 +328,6 @@ void QmlJsInspectorToolBar::showAppOnTopClick()
|
||||
emit showAppOnTopSelected(m_showAppOnTopAction->isChecked());
|
||||
}
|
||||
|
||||
void QmlJsInspectorToolBar::setSelectedColor(const QColor &color)
|
||||
{
|
||||
m_colorBox->setColor(color);
|
||||
}
|
||||
|
||||
void QmlJsInspectorToolBar::activateFromQml()
|
||||
{
|
||||
if (m_emitSignals)
|
||||
@@ -386,7 +344,6 @@ void QmlJsInspectorToolBar::updateDesignModeActions(DesignTool activeTool)
|
||||
m_activeTool = activeTool;
|
||||
m_selectAction->setChecked(m_designModeActive && (m_activeTool == SelectionToolMode));
|
||||
m_zoomAction->setChecked(m_designModeActive && (m_activeTool == ZoomMode));
|
||||
m_colorPickerAction->setChecked(m_designModeActive && (m_activeTool == ColorPickerMode));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -41,7 +41,6 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QActionGroup;
|
||||
class QColor;
|
||||
class QToolButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -51,8 +50,6 @@ class StyledBar;
|
||||
|
||||
namespace QmlJSInspector {
|
||||
|
||||
class ToolBarColorBox;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QmlJsInspectorToolBar : public QObject
|
||||
@@ -66,7 +63,6 @@ public:
|
||||
MarqueeSelectionToolMode = 2,
|
||||
MoveToolMode = 3,
|
||||
ResizeToolMode = 4,
|
||||
ColorPickerMode = 5,
|
||||
ZoomMode = 6
|
||||
};
|
||||
|
||||
@@ -79,7 +75,6 @@ public slots:
|
||||
void enable();
|
||||
void disable();
|
||||
|
||||
void activateColorPicker();
|
||||
void activateSelectTool();
|
||||
void activateZoomTool();
|
||||
|
||||
@@ -88,14 +83,12 @@ public slots:
|
||||
|
||||
void setDesignModeBehavior(bool inDesignMode);
|
||||
void setShowAppOnTop(bool showAppOnTop);
|
||||
void setSelectedColor(const QColor &color);
|
||||
|
||||
signals:
|
||||
void applyChangesFromQmlFileTriggered(bool isChecked);
|
||||
|
||||
void designModeSelected(bool);
|
||||
void reloadSelected();
|
||||
void colorPickerSelected();
|
||||
void selectToolSelected();
|
||||
void zoomToolSelected();
|
||||
|
||||
@@ -106,7 +99,6 @@ signals:
|
||||
|
||||
private slots:
|
||||
void activatePlayOnClick();
|
||||
void colorPickerTriggered(bool checked);
|
||||
void selectToolTriggered(bool checked);
|
||||
void zoomToolTriggered(bool checked);
|
||||
|
||||
@@ -129,7 +121,6 @@ private:
|
||||
QAction *m_playAction;
|
||||
QAction *m_selectAction;
|
||||
QAction *m_zoomAction;
|
||||
QAction *m_colorPickerAction;
|
||||
|
||||
QAction *m_showAppOnTopAction;
|
||||
|
||||
@@ -139,8 +130,6 @@ private:
|
||||
QIcon m_playIcon;
|
||||
QIcon m_pauseIcon;
|
||||
|
||||
ToolBarColorBox *m_colorBox;
|
||||
|
||||
bool m_emitSignals;
|
||||
bool m_paused;
|
||||
qreal m_animationSpeed;
|
||||
|
@@ -1,132 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
#include "qmljstoolbarcolorbox.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QClipboard>
|
||||
#include <QApplication>
|
||||
#include <QColorDialog>
|
||||
#include <QDrag>
|
||||
|
||||
#include <QMimeData>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSInspector {
|
||||
|
||||
ToolBarColorBox::ToolBarColorBox(QWidget *parent) :
|
||||
QLabel(parent)
|
||||
{
|
||||
m_color = Qt::white;
|
||||
m_borderColorOuter = Qt::white;
|
||||
m_borderColorInner = QColor(143, 143 ,143);
|
||||
|
||||
m_copyHexColorAction = new QAction(QIcon(QLatin1String(":/qml/images/color-picker-small-hicontrast.png")), tr("Copy Color"), this);
|
||||
connect(m_copyHexColorAction, SIGNAL(triggered()), SLOT(copyColorToClipboard()));
|
||||
setScaledContents(false);
|
||||
}
|
||||
|
||||
void ToolBarColorBox::setColor(const QColor &color)
|
||||
{
|
||||
m_color = color;
|
||||
|
||||
QPixmap pix = createDragPixmap(width());
|
||||
setPixmap(pix);
|
||||
update();
|
||||
}
|
||||
|
||||
void ToolBarColorBox::setInnerBorderColor(const QColor &color)
|
||||
{
|
||||
m_borderColorInner = color;
|
||||
setColor(m_color);
|
||||
}
|
||||
|
||||
void ToolBarColorBox::setOuterBorderColor(const QColor &color)
|
||||
{
|
||||
m_borderColorOuter = color;
|
||||
setColor(m_color);
|
||||
}
|
||||
|
||||
void ToolBarColorBox::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_dragBeginPoint = event->pos();
|
||||
m_dragStarted = false;
|
||||
}
|
||||
|
||||
void ToolBarColorBox::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton
|
||||
&& QPoint(event->pos() - m_dragBeginPoint).manhattanLength() > QApplication::startDragDistance()
|
||||
&& !m_dragStarted)
|
||||
{
|
||||
m_dragStarted = true;
|
||||
QDrag *drag = new QDrag(this);
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
|
||||
mimeData->setText(m_color.name());
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setPixmap(createDragPixmap());
|
||||
|
||||
drag->exec();
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap ToolBarColorBox::createDragPixmap(int size) const
|
||||
{
|
||||
QPixmap pix(size, size);
|
||||
QPainter p(&pix);
|
||||
|
||||
p.setBrush(QBrush(m_color));
|
||||
p.setPen(QPen(QBrush(m_borderColorInner),1));
|
||||
|
||||
p.fillRect(0, 0, size, size, m_borderColorOuter);
|
||||
p.drawRect(1,1, size - 3, size - 3);
|
||||
return pix;
|
||||
}
|
||||
|
||||
void ToolBarColorBox::contextMenuEvent(QContextMenuEvent *ev)
|
||||
{
|
||||
QMenu contextMenu;
|
||||
contextMenu.addAction(m_copyHexColorAction);
|
||||
contextMenu.exec(ev->globalPos());
|
||||
}
|
||||
|
||||
void ToolBarColorBox::copyColorToClipboard()
|
||||
{
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(m_color.name());
|
||||
}
|
||||
|
||||
} // namespace QmlJSInspector
|
@@ -1,75 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef TOOLBARCOLORBOX_H
|
||||
#define TOOLBARCOLORBOX_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QColor>
|
||||
#include <QPoint>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QContextMenuEvent)
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
|
||||
namespace QmlJSInspector {
|
||||
|
||||
class ToolBarColorBox : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ToolBarColorBox(QWidget *parent = 0);
|
||||
void setColor(const QColor &color);
|
||||
void setInnerBorderColor(const QColor &color);
|
||||
void setOuterBorderColor(const QColor &color);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *ev);
|
||||
void mousePressEvent(QMouseEvent *ev);
|
||||
void mouseMoveEvent(QMouseEvent *ev);
|
||||
private slots:
|
||||
void copyColorToClipboard();
|
||||
|
||||
private:
|
||||
QPixmap createDragPixmap(int size = 24) const;
|
||||
|
||||
private:
|
||||
bool m_dragStarted;
|
||||
QPoint m_dragBeginPoint;
|
||||
QAction *m_copyHexColorAction;
|
||||
QColor m_color;
|
||||
|
||||
QColor m_borderColorOuter;
|
||||
QColor m_borderColorInner;
|
||||
};
|
||||
|
||||
} // namespace QmlJSInspector
|
||||
|
||||
#endif // TOOLBARCOLORBOX_H
|
Reference in New Issue
Block a user