Fleshing out of using merge for colors.
This commit is contained in:
+13
-3
@@ -44,6 +44,8 @@ void ColorButton::init( const QString& defaultLabel, const QColor& defaultColor,
|
|||||||
mDefaultColor = defaultColor;
|
mDefaultColor = defaultColor;
|
||||||
mColorNode = ColorNode( color );
|
mColorNode = ColorNode( color );
|
||||||
|
|
||||||
|
setMinimumSize( QSize( 85, 34 ) );
|
||||||
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, color ) ) );
|
||||||
setText( "" );
|
setText( "" );
|
||||||
setCheckable( true );
|
setCheckable( true );
|
||||||
@@ -67,7 +69,7 @@ void ColorButton::setColorNode( ColorNode colorNode )
|
|||||||
if ( colorNode.fieldFlag() )
|
if ( colorNode.fieldFlag() )
|
||||||
{
|
{
|
||||||
setIcon( QIcon() );
|
setIcon( QIcon() );
|
||||||
setText( colorNode.key() );
|
setText( QString("${%1}").arg( colorNode.key() ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -155,8 +157,16 @@ void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
|||||||
mColorNode = colorNode;
|
mColorNode = colorNode;
|
||||||
mIsDefault = isDefault;
|
mIsDefault = isDefault;
|
||||||
|
|
||||||
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
if ( colorNode.fieldFlag() )
|
||||||
setText( "" );
|
{
|
||||||
|
setIcon( QIcon() );
|
||||||
|
setText( QString("${%1}").arg( colorNode.key() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setIcon( QIcon( ColorSwatch( SWATCH_W, SWATCH_H, colorNode.color() ) ) );
|
||||||
|
setText( "" );
|
||||||
|
}
|
||||||
|
|
||||||
emit colorChanged();
|
emit colorChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,6 @@
|
|||||||
|
|
||||||
#include "ColorPaletteDialog.h"
|
#include "ColorPaletteDialog.h"
|
||||||
|
|
||||||
#include "ColorPaletteItem.h"
|
|
||||||
#include "ColorPaletteButtonItem.h"
|
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
@@ -153,12 +150,17 @@ ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
|
|||||||
hline4->setLineWidth( 1 );
|
hline4->setLineWidth( 1 );
|
||||||
vLayout->addWidget( hline4 );
|
vLayout->addWidget( hline4 );
|
||||||
|
|
||||||
ColorPaletteButtonItem* mergeFieldButton = new ColorPaletteButtonItem( "TODO: Field Button" );
|
mMergeFieldButton = new ColorPaletteButtonItem( tr("Merge field") );
|
||||||
vLayout->addWidget( mergeFieldButton );
|
connect( mMergeFieldButton, SIGNAL(activated()), this, SLOT(onMergeFieldItemActivated()) );
|
||||||
|
mMergeFieldButton->setEnabled( false );
|
||||||
|
vLayout->addWidget( mMergeFieldButton );
|
||||||
|
|
||||||
setLayout( vLayout );
|
setLayout( vLayout );
|
||||||
|
|
||||||
loadCustomColorHistory();
|
loadCustomColorHistory();
|
||||||
|
|
||||||
|
mFieldMenu = new FieldMenu();
|
||||||
|
connect( mFieldMenu, SIGNAL(keySelected(QString)), this, SLOT(onFieldMenuItemActivated(QString)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,15 +170,23 @@ void ColorPaletteDialog::setColorNode( const ColorNode& colorNode )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::setKeys( const QList<QString> keyList )
|
void ColorPaletteDialog::setKeys( const QStringList& keyList )
|
||||||
{
|
{
|
||||||
// TODO
|
if ( keyList.size() > 0 )
|
||||||
|
{
|
||||||
|
mFieldMenu->setKeys( keyList );
|
||||||
|
mMergeFieldButton->setEnabled( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mMergeFieldButton->setEnabled( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::clearKeys()
|
void ColorPaletteDialog::clearKeys()
|
||||||
{
|
{
|
||||||
// TODO
|
mMergeFieldButton->setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -263,3 +273,21 @@ void ColorPaletteDialog::loadCustomColorHistory()
|
|||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::onMergeFieldItemActivated()
|
||||||
|
{
|
||||||
|
QPoint pos( mMergeFieldButton->width(), 0 );
|
||||||
|
mFieldMenu->popup( mMergeFieldButton->mapToGlobal(pos) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColorPaletteDialog::onFieldMenuItemActivated( QString key )
|
||||||
|
{
|
||||||
|
mColorNode.setFieldFlag( true );
|
||||||
|
mColorNode.setColor( QColor("#eeeeec") );
|
||||||
|
mColorNode.setKey( key );
|
||||||
|
|
||||||
|
emit colorChanged( mColorNode, false );
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
#include "ColorNode.h"
|
#include "ColorNode.h"
|
||||||
#include "ColorHistory.h"
|
#include "ColorHistory.h"
|
||||||
#include "ColorPaletteItem.h"
|
#include "ColorPaletteItem.h"
|
||||||
|
#include "ColorPaletteButtonItem.h"
|
||||||
|
#include "FieldMenu.h"
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -59,7 +61,7 @@ signals:
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setColorNode( const ColorNode& colorNode );
|
void setColorNode( const ColorNode& colorNode );
|
||||||
void setKeys( const QList<QString> keyList );
|
void setKeys( const QStringList& keyList );
|
||||||
void clearKeys();
|
void clearKeys();
|
||||||
|
|
||||||
|
|
||||||
@@ -72,6 +74,8 @@ private slots:
|
|||||||
void onHistoryItemActivated( int id );
|
void onHistoryItemActivated( int id );
|
||||||
void onCustomColorItemActivated();
|
void onCustomColorItemActivated();
|
||||||
void onColorHistoryChanged();
|
void onColorHistoryChanged();
|
||||||
|
void onMergeFieldItemActivated();
|
||||||
|
void onFieldMenuItemActivated( QString key );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
@@ -101,6 +105,9 @@ private:
|
|||||||
ColorHistory* mColorHistory;
|
ColorHistory* mColorHistory;
|
||||||
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
ColorPaletteItem* mHistoryItem[PALETTE_COLS];
|
||||||
|
|
||||||
|
FieldMenu* mFieldMenu;
|
||||||
|
ColorPaletteButtonItem* mMergeFieldButton;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ FieldMenu::FieldMenu()
|
|||||||
///
|
///
|
||||||
/// set keys
|
/// set keys
|
||||||
///
|
///
|
||||||
void FieldMenu::setKeys( const QList<QString>& keyList )
|
void FieldMenu::setKeys( const QStringList& keyList )
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
foreach ( QString key, keyList )
|
foreach ( QString key, keyList )
|
||||||
{
|
{
|
||||||
FieldMenuItem* menuItem = new FieldMenuItem( key );
|
FieldMenuItem* menuItem = new FieldMenuItem( key );
|
||||||
connect( menuItem, SIGNAL(activated()), this, SLOT(onMenuItemActivated) );
|
connect( menuItem, SIGNAL(activated(QString)), this, SLOT(onMenuItemActivated(QString)) );
|
||||||
|
|
||||||
addAction( menuItem );
|
addAction( menuItem );
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ void FieldMenu::setKeys( const QList<QString>& keyList )
|
|||||||
///
|
///
|
||||||
/// onMenuItemActivated slot
|
/// onMenuItemActivated slot
|
||||||
///
|
///
|
||||||
void FieldMenu::onMenuItemActivated( const QString& key )
|
void FieldMenu::onMenuItemActivated( QString key )
|
||||||
{
|
{
|
||||||
emit keySelected( key );
|
emit keySelected( key );
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -43,21 +43,21 @@ public:
|
|||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void keySelected( const QString& key );
|
void keySelected( QString key );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
void setKeys( const QList<QString>& keyList );
|
void setKeys( const QStringList& keyList );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onMenuItemActivated( const QString& key );
|
void onMenuItemActivated( QString key );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
// Signals
|
// Signals
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void activated( const QString& key );
|
void activated( QString key );
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ void LabelModel::setMerge( Merge* merge )
|
|||||||
setModified();
|
setModified();
|
||||||
|
|
||||||
emit mergeChanged();
|
emit mergeChanged();
|
||||||
|
emit mergeSourceChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,6 +427,7 @@ void LabelModel::onMergeSourceChanged()
|
|||||||
{
|
{
|
||||||
setModified();
|
setModified();
|
||||||
emit changed();
|
emit changed();
|
||||||
|
emit mergeSourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ signals:
|
|||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
void modifiedChanged();
|
void modifiedChanged();
|
||||||
void mergeChanged();
|
void mergeChanged();
|
||||||
|
void mergeSourceChanged();
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ public:
|
|||||||
// Virtual methods
|
// Virtual methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
virtual QStringList keyList() const = 0;
|
virtual QStringList keys() const = 0;
|
||||||
virtual QString primaryKey() const = 0;
|
virtual QString primaryKey() const = 0;
|
||||||
protected:
|
protected:
|
||||||
virtual void open() = 0;
|
virtual void open() = 0;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ Merge* MergeNone::create()
|
|||||||
///
|
///
|
||||||
/// Get key list
|
/// Get key list
|
||||||
///
|
///
|
||||||
QStringList MergeNone::keyList() const
|
QStringList MergeNone::keys() const
|
||||||
{
|
{
|
||||||
QStringList emptyList;
|
QStringList emptyList;
|
||||||
return emptyList;
|
return emptyList;
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ public:
|
|||||||
// Implementation of virtual methods
|
// Implementation of virtual methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QStringList keyList() const;
|
QStringList keys() const;
|
||||||
QString primaryKey() const;
|
QString primaryKey() const;
|
||||||
protected:
|
protected:
|
||||||
void open();
|
void open();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ MergeText::~MergeText()
|
|||||||
///
|
///
|
||||||
/// Get key list
|
/// Get key list
|
||||||
///
|
///
|
||||||
QStringList MergeText::keyList() const
|
QStringList MergeText::keys() const
|
||||||
{
|
{
|
||||||
QStringList keys;
|
QStringList keys;
|
||||||
for ( int iField = 0; iField < mNFieldsMax; iField++ )
|
for ( int iField = 0; iField < mNFieldsMax; iField++ )
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ protected:
|
|||||||
// Implementation of virtual methods
|
// Implementation of virtual methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
public:
|
public:
|
||||||
QStringList keyList() const;
|
QStringList keys() const;
|
||||||
QString primaryKey() const;
|
QString primaryKey() const;
|
||||||
protected:
|
protected:
|
||||||
void open();
|
void open();
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ void MergeView::onCellChanged( int iRow, int iCol )
|
|||||||
void MergeView::loadHeaders( Merge* merge )
|
void MergeView::loadHeaders( Merge* merge )
|
||||||
{
|
{
|
||||||
mPrimaryKey = merge->primaryKey();
|
mPrimaryKey = merge->primaryKey();
|
||||||
mKeys = merge->keyList();
|
mKeys = merge->keys();
|
||||||
|
|
||||||
if ( mKeys.size() > 0 )
|
if ( mKeys.size() > 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,9 +59,11 @@ void ObjectEditor::setModel( LabelModel* model, UndoRedoModel* undoRedoModel )
|
|||||||
|
|
||||||
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
|
connect( mModel, SIGNAL(sizeChanged()), this, SLOT(onLabelSizeChanged()) );
|
||||||
connect( mModel, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()) );
|
connect( mModel, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()) );
|
||||||
|
connect( mModel, SIGNAL(mergeSourceChanged()), this, SLOT(onMergeSourceChanged()) );
|
||||||
|
|
||||||
onLabelSizeChanged();
|
onLabelSizeChanged();
|
||||||
onSelectionChanged();
|
onSelectionChanged();
|
||||||
|
onMergeSourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -246,6 +248,17 @@ void ObjectEditor::onSelectionChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ObjectEditor::onMergeSourceChanged()
|
||||||
|
{
|
||||||
|
if ( !mBlocked )
|
||||||
|
{
|
||||||
|
lineColorButton->setKeys( mModel->merge()->keys() );
|
||||||
|
fillColorButton->setKeys( mModel->merge()->keys() );
|
||||||
|
shadowColorButton->setKeys( mModel->merge()->keys() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ObjectEditor::onObjectChanged()
|
void ObjectEditor::onObjectChanged()
|
||||||
{
|
{
|
||||||
if ( !mBlocked )
|
if ( !mBlocked )
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ private slots:
|
|||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
void onLabelSizeChanged();
|
void onLabelSizeChanged();
|
||||||
void onSelectionChanged();
|
void onSelectionChanged();
|
||||||
|
void onMergeSourceChanged();
|
||||||
void onObjectChanged();
|
void onObjectChanged();
|
||||||
void onObjectMoved();
|
void onObjectMoved();
|
||||||
void onObjectDestroyed();
|
void onObjectDestroyed();
|
||||||
|
|||||||
Reference in New Issue
Block a user