Some tweaking of ColorPaletteDialog.
This commit is contained in:
@@ -14,6 +14,7 @@ set (glabels_sources
|
|||||||
ColorNode.cpp
|
ColorNode.cpp
|
||||||
ColorPaletteDialog.cpp
|
ColorPaletteDialog.cpp
|
||||||
ColorPaletteItem.cpp
|
ColorPaletteItem.cpp
|
||||||
|
ColorPaletteButtonItem.cpp
|
||||||
ColorSwatch.cpp
|
ColorSwatch.cpp
|
||||||
Cursors.cpp
|
Cursors.cpp
|
||||||
FieldButton.cpp
|
FieldButton.cpp
|
||||||
@@ -49,6 +50,7 @@ set (glabels_qobject_headers
|
|||||||
ColorHistory.h
|
ColorHistory.h
|
||||||
ColorPaletteDialog.h
|
ColorPaletteDialog.h
|
||||||
ColorPaletteItem.h
|
ColorPaletteItem.h
|
||||||
|
ColorPaletteButtonItem.h
|
||||||
FieldButton.h
|
FieldButton.h
|
||||||
FieldMenu.h
|
FieldMenu.h
|
||||||
FieldMenuItem.h
|
FieldMenuItem.h
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace glabels
|
|||||||
mDialog->setModal( true );
|
mDialog->setModal( true );
|
||||||
|
|
||||||
connect( this, SIGNAL(pressed()), this, SLOT(onButtonPressed()) );
|
connect( this, SIGNAL(pressed()), this, SLOT(onButtonPressed()) );
|
||||||
connect( mDialog, SIGNAL(changed(colorNode,bool)), this, SLOT(onColorPaletteDialogChanged(colorNode,bool)) );
|
connect( mDialog, SIGNAL(colorChanged(colorNode,bool)), this, SLOT(onColorPaletteDialogChanged(colorNode,bool)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,7 +123,6 @@ namespace glabels
|
|||||||
|
|
||||||
void ColorButton::onButtonPressed()
|
void ColorButton::onButtonPressed()
|
||||||
{
|
{
|
||||||
setDown( true );
|
|
||||||
// TODO: move dialog -- see menu_position_function is VALA version
|
// TODO: move dialog -- see menu_position_function is VALA version
|
||||||
mDialog->show();
|
mDialog->show();
|
||||||
}
|
}
|
||||||
@@ -131,8 +130,6 @@ namespace glabels
|
|||||||
|
|
||||||
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
void ColorButton::onPaletteDialogChanged( ColorNode colorNode, bool isDefault )
|
||||||
{
|
{
|
||||||
setDown( false );
|
|
||||||
|
|
||||||
mColorNode = colorNode;
|
mColorNode = colorNode;
|
||||||
mIsDefault = isDefault;
|
mIsDefault = isDefault;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace glabels
|
|||||||
QColor newColors[MAX_COLORS];
|
QColor newColors[MAX_COLORS];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
readColorArray( oldColors, n );
|
readColorArray( oldColors, &n );
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
newColors[0] = color;
|
newColors[0] = color;
|
||||||
@@ -69,6 +69,8 @@ namespace glabels
|
|||||||
QColor colors[MAX_COLORS];
|
QColor colors[MAX_COLORS];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
readColorArray( colors, &n );
|
||||||
|
|
||||||
if ( (n > 0) && (i < n) )
|
if ( (n > 0) && (i < n) )
|
||||||
{
|
{
|
||||||
return colors[i];
|
return colors[i];
|
||||||
@@ -80,15 +82,15 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorHistory::readColorArray( QColor array[MAX_COLORS], int& n )
|
void ColorHistory::readColorArray( QColor array[MAX_COLORS], int* n )
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
settings.beginGroup( "ColorHistory" );
|
settings.beginGroup( "ColorHistory" );
|
||||||
|
|
||||||
settings.beginReadArray( "history" );
|
settings.beginReadArray( "history" );
|
||||||
n = settings.value( "history/size", 0 ).toInt();
|
*n = settings.value( "history/size", 0 ).toInt();
|
||||||
for ( int i = 0; i < n; i++ )
|
for ( int i = 0; i < *n; i++ )
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
array[i] = settings.value( "color" ).value<QColor>();
|
array[i] = settings.value( "color" ).value<QColor>();
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace glabels
|
|||||||
// Private Methods
|
// Private Methods
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private:
|
private:
|
||||||
void readColorArray( QColor array[MAX_COLORS], int& n );
|
void readColorArray( QColor array[MAX_COLORS], int* n );
|
||||||
void writeColorArray( const QColor array[MAX_COLORS], int n );
|
void writeColorArray( const QColor array[MAX_COLORS], int n );
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
/* ColorPaletteButtonItem.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ColorPaletteButtonItem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private Configuration Data
|
||||||
|
//
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const int border = 4;
|
||||||
|
const int hBox = 25;
|
||||||
|
const QColor hoverOutlineColor( 89, 130, 182 );
|
||||||
|
const QColor hoverGradientColor0( 164, 195, 232 );
|
||||||
|
const QColor hoverGradientColor1( 147, 181, 224 );
|
||||||
|
const int outlineWidthPixels = 1;
|
||||||
|
const QColor textColor( 0, 0, 0 );
|
||||||
|
const QColor hoverTextColor( 255, 255, 255 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor From Data
|
||||||
|
///
|
||||||
|
ColorPaletteButtonItem::ColorPaletteButtonItem( const QString& text, QWidget* parent )
|
||||||
|
: QWidget(parent), mText(text), mHover(false)
|
||||||
|
{
|
||||||
|
setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
|
||||||
|
setMinimumSize( hBox+2*border+1, hBox+2*border+1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Paint Event
|
||||||
|
///
|
||||||
|
void ColorPaletteButtonItem::paintEvent( QPaintEvent* event )
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw background
|
||||||
|
//
|
||||||
|
if ( mHover )
|
||||||
|
{
|
||||||
|
QLinearGradient gradient( 0, 0, 0, height() );
|
||||||
|
gradient.setColorAt( 0, hoverGradientColor0 );
|
||||||
|
gradient.setColorAt( 1, hoverGradientColor1 );
|
||||||
|
painter.setBrush( QBrush( gradient ) );
|
||||||
|
|
||||||
|
QPen pen( hoverOutlineColor );
|
||||||
|
pen.setWidth( outlineWidthPixels );
|
||||||
|
painter.setPen( pen );
|
||||||
|
|
||||||
|
painter.drawRect( 0, 0, width()-1, height()-1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw text
|
||||||
|
//
|
||||||
|
painter.setBrush( QBrush( Qt::NoBrush ) );
|
||||||
|
|
||||||
|
if ( mHover )
|
||||||
|
{
|
||||||
|
painter.setPen( QPen( hoverTextColor ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
painter.setPen( QPen( textColor ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect textRect( border, border, width()-2*border, hBox );
|
||||||
|
|
||||||
|
painter.drawText( textRect, Qt::AlignLeft|Qt::AlignVCenter, mText );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Enter Event
|
||||||
|
///
|
||||||
|
void ColorPaletteButtonItem::enterEvent( QEvent* event )
|
||||||
|
{
|
||||||
|
mHover = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Leave Event
|
||||||
|
///
|
||||||
|
void ColorPaletteButtonItem::leaveEvent( QEvent* event )
|
||||||
|
{
|
||||||
|
mHover = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Mouse Press Event
|
||||||
|
///
|
||||||
|
void ColorPaletteButtonItem::mousePressEvent( QMouseEvent* event )
|
||||||
|
{
|
||||||
|
emit activated();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/* ColorPaletteButtonItem.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Jim Evins <evins@snaught.com>
|
||||||
|
*
|
||||||
|
* This file is part of gLabels-qt.
|
||||||
|
*
|
||||||
|
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gLabels-qt is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef glabels_ColorPaletteButtonItem_h
|
||||||
|
#define glabels_ColorPaletteButtonItem_h
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
|
||||||
|
namespace glabels
|
||||||
|
{
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color Palette Item
|
||||||
|
///
|
||||||
|
class ColorPaletteButtonItem : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Life Cycle
|
||||||
|
/////////////////////////////////
|
||||||
|
public:
|
||||||
|
ColorPaletteButtonItem( const QString& text, QWidget* parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////
|
||||||
|
signals:
|
||||||
|
void activated();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Event handlers
|
||||||
|
/////////////////////////////////
|
||||||
|
protected:
|
||||||
|
void paintEvent( QPaintEvent* event );
|
||||||
|
void enterEvent( QEvent* event );
|
||||||
|
void leaveEvent( QEvent* event );
|
||||||
|
void mousePressEvent( QMouseEvent* event );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// Private Data
|
||||||
|
/////////////////////////////////
|
||||||
|
private:
|
||||||
|
QString mText;
|
||||||
|
|
||||||
|
bool mHover;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // glabels_ColorPaletteButtonItem_h
|
||||||
@@ -20,8 +20,15 @@
|
|||||||
|
|
||||||
#include "ColorPaletteDialog.h"
|
#include "ColorPaletteDialog.h"
|
||||||
|
|
||||||
|
#include "ColorPaletteItem.h"
|
||||||
|
#include "ColorPaletteButtonItem.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QFrame>
|
||||||
|
|
||||||
|
|
||||||
namespace glabels
|
namespace glabels
|
||||||
@@ -80,14 +87,20 @@ namespace glabels
|
|||||||
mColorHistory = ColorHistory::instance();
|
mColorHistory = ColorHistory::instance();
|
||||||
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
|
connect( mColorHistory, SIGNAL(changed()), this, SLOT(onColorHistoryChanged()) );
|
||||||
|
|
||||||
QGridLayout* layout = new QGridLayout();
|
QVBoxLayout* vLayout = new QVBoxLayout();
|
||||||
int iAbsRow = 0;
|
vLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
vLayout->setSpacing( 0 );
|
||||||
QPushButton* defaultButton = new QPushButton( defaultLabel );
|
|
||||||
layout->addWidget( defaultButton, iAbsRow, 0, 1, PALETTE_COLS );
|
|
||||||
iAbsRow++;
|
|
||||||
|
|
||||||
|
ColorPaletteButtonItem* defaultButton = new ColorPaletteButtonItem( defaultLabel );
|
||||||
|
vLayout->addWidget( defaultButton );
|
||||||
|
|
||||||
|
QFrame* hline1 = new QFrame;
|
||||||
|
hline1->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
||||||
|
hline1->setLineWidth( 1 );
|
||||||
|
vLayout->addWidget( hline1 );
|
||||||
|
|
||||||
|
QGridLayout* mainPaletteLayout = new QGridLayout();
|
||||||
|
mainPaletteLayout->setSpacing( 0 );
|
||||||
for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ )
|
for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ )
|
||||||
{
|
{
|
||||||
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
||||||
@@ -99,33 +112,46 @@ namespace glabels
|
|||||||
mColorTable[i].name );
|
mColorTable[i].name );
|
||||||
connect( item, SIGNAL(activated(int)), this, SLOT(onPaletteItemActivated(int)) );
|
connect( item, SIGNAL(activated(int)), this, SLOT(onPaletteItemActivated(int)) );
|
||||||
|
|
||||||
layout->addWidget( item, iAbsRow, iCol );
|
mainPaletteLayout->addWidget( item, iRow, iCol );
|
||||||
}
|
}
|
||||||
iAbsRow++;
|
|
||||||
}
|
}
|
||||||
|
vLayout->addLayout( mainPaletteLayout );
|
||||||
|
|
||||||
|
QFrame* hline2 = new QFrame;
|
||||||
|
hline2->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
||||||
|
hline2->setLineWidth( 1 );
|
||||||
|
vLayout->addWidget( hline2 );
|
||||||
|
|
||||||
|
QHBoxLayout* customPaletteLayout = new QHBoxLayout();
|
||||||
|
customPaletteLayout->setSpacing( 0 );
|
||||||
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ )
|
||||||
{
|
{
|
||||||
mHistoryItem[iCol] = new ColorPaletteItem( iCol,
|
mHistoryItem[iCol] = new ColorPaletteItem( iCol, QColor(0,0,0,0), "" );
|
||||||
QColor(0,0,0,0),
|
|
||||||
"" );
|
|
||||||
mHistoryItem[iCol]->setEnabled( false );
|
mHistoryItem[iCol]->setEnabled( false );
|
||||||
connect( mHistoryItem[iCol], SIGNAL(activated(int)), this, SLOT(onHistoryItemActivated(int)) );
|
connect( mHistoryItem[iCol], SIGNAL(activated(int)), this, SLOT(onHistoryItemActivated(int)) );
|
||||||
|
|
||||||
layout->addWidget( mHistoryItem[iCol], iAbsRow, iCol );
|
customPaletteLayout->addWidget( mHistoryItem[iCol] );
|
||||||
}
|
}
|
||||||
iAbsRow++;
|
vLayout->addLayout( customPaletteLayout );
|
||||||
|
|
||||||
|
|
||||||
QPushButton* customColorButton = new QPushButton( tr("Custom color") );
|
QFrame* hline3 = new QFrame;
|
||||||
layout->addWidget( customColorButton, iAbsRow, 0, 1, PALETTE_COLS );
|
hline3->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
||||||
iAbsRow++;
|
hline3->setLineWidth( 1 );
|
||||||
|
vLayout->addWidget( hline3 );
|
||||||
|
|
||||||
QPushButton* mergeFieldButton = new QPushButton( "TODO: Field Button" );
|
ColorPaletteButtonItem* customColorButton = new ColorPaletteButtonItem( tr("Custom color") );
|
||||||
layout->addWidget( mergeFieldButton, iAbsRow, 0, 1, PALETTE_COLS );
|
vLayout->addWidget( customColorButton );
|
||||||
|
|
||||||
setLayout( layout );
|
QFrame* hline4 = new QFrame;
|
||||||
|
hline4->setFrameStyle( QFrame::HLine | QFrame::Plain );
|
||||||
|
hline4->setLineWidth( 1 );
|
||||||
|
vLayout->addWidget( hline4 );
|
||||||
|
|
||||||
|
ColorPaletteButtonItem* mergeFieldButton = new ColorPaletteButtonItem( "TODO: Field Button" );
|
||||||
|
vLayout->addWidget( mergeFieldButton );
|
||||||
|
|
||||||
|
setLayout( vLayout );
|
||||||
|
|
||||||
loadCustomColorHistory();
|
loadCustomColorHistory();
|
||||||
}
|
}
|
||||||
@@ -143,12 +169,13 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onDefaultButtonClicked()
|
void ColorPaletteDialog::onDefaultItemActivated()
|
||||||
{
|
{
|
||||||
mColorNode.setFieldFlag( false );
|
mColorNode.setFieldFlag( false );
|
||||||
mColorNode.setColor( mDefaultColor );
|
mColorNode.setColor( mDefaultColor );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
|
setVisible( false );
|
||||||
emit colorChanged( mColorNode, true );
|
emit colorChanged( mColorNode, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +186,7 @@ namespace glabels
|
|||||||
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
mColorNode.setColor( QColor( mColorTable[id].colorSpec ) );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
|
setVisible( false );
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,12 +197,14 @@ namespace glabels
|
|||||||
mColorNode.setColor( mColorHistory->getColor( id ) );
|
mColorNode.setColor( mColorHistory->getColor( id ) );
|
||||||
mColorNode.setKey( "" );
|
mColorNode.setKey( "" );
|
||||||
|
|
||||||
|
setVisible( false );
|
||||||
emit colorChanged( mColorNode, false );
|
emit colorChanged( mColorNode, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColorPaletteDialog::onCustomColorButtonClicked()
|
void ColorPaletteDialog::onCustomColorItemActivated()
|
||||||
{
|
{
|
||||||
|
setVisible( false );
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +217,7 @@ namespace glabels
|
|||||||
|
|
||||||
void ColorPaletteDialog::loadCustomColorHistory()
|
void ColorPaletteDialog::loadCustomColorHistory()
|
||||||
{
|
{
|
||||||
for ( int i; i < PALETTE_COLS; i++ )
|
for ( int i = 0; i < PALETTE_COLS; i++ )
|
||||||
{
|
{
|
||||||
QColor color = mColorHistory->getColor( i );
|
QColor color = mColorHistory->getColor( i );
|
||||||
|
|
||||||
|
|||||||
@@ -69,10 +69,10 @@ namespace glabels
|
|||||||
// Slots
|
// Slots
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
private slots:
|
private slots:
|
||||||
void onDefaultButtonClicked();
|
void onDefaultItemActivated();
|
||||||
void onPaletteItemActivated( int id );
|
void onPaletteItemActivated( int id );
|
||||||
void onHistoryItemActivated( int id );
|
void onHistoryItemActivated( int id );
|
||||||
void onCustomColorButtonClicked();
|
void onCustomColorItemActivated();
|
||||||
void onColorHistoryChanged();
|
void onColorHistoryChanged();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,14 @@ namespace
|
|||||||
const int border = 4;
|
const int border = 4;
|
||||||
const int wSwatch = 25;
|
const int wSwatch = 25;
|
||||||
const int hSwatch = 25;
|
const int hSwatch = 25;
|
||||||
const QColor hoverColor( 170, 200, 255 );
|
|
||||||
|
const QColor hoverBgOutlineColor( 89, 130, 182 );
|
||||||
|
const QColor hoverBgGradientColor0( 164, 195, 232 );
|
||||||
|
const QColor hoverBgGradientColor1( 147, 181, 224 );
|
||||||
|
const int hoverBgOutlineWidthPixels = 1;
|
||||||
|
|
||||||
const QColor outlineColor( 0, 0, 0 );
|
const QColor outlineColor( 0, 0, 0 );
|
||||||
|
const QColor hoverOutlineColor( 255, 255, 255 );
|
||||||
const QColor emptyOutlineColor( 192, 192, 192 );
|
const QColor emptyOutlineColor( 192, 192, 192 );
|
||||||
const int outlineWidthPixels = 1;
|
const int outlineWidthPixels = 1;
|
||||||
}
|
}
|
||||||
@@ -80,18 +86,44 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
if ( mHover && mColor.alpha() )
|
//
|
||||||
|
// Draw background
|
||||||
|
//
|
||||||
|
if ( isEnabled() && mHover )
|
||||||
{
|
{
|
||||||
painter.setBrush( QBrush( hoverColor ) );
|
QLinearGradient gradient( 0, 0, 0, height() );
|
||||||
painter.setPen( Qt::NoPen );
|
gradient.setColorAt( 0, hoverBgGradientColor0 );
|
||||||
painter.drawRect( rect() );
|
gradient.setColorAt( 1, hoverBgGradientColor1 );
|
||||||
|
painter.setBrush( QBrush( gradient ) );
|
||||||
|
|
||||||
|
QPen pen( hoverBgOutlineColor );
|
||||||
|
pen.setWidth( hoverBgOutlineWidthPixels );
|
||||||
|
painter.setPen( pen );
|
||||||
|
|
||||||
|
painter.drawRect( 0, 0, width()-1, height()-1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mColor.alpha() )
|
//
|
||||||
|
// Draw swatch
|
||||||
|
//
|
||||||
|
painter.setBrush( QBrush( Qt::NoBrush ) );
|
||||||
|
|
||||||
|
if ( isEnabled() )
|
||||||
{
|
{
|
||||||
QPen pen( outlineColor );
|
if ( mHover )
|
||||||
pen.setWidth( outlineWidthPixels );
|
{
|
||||||
painter.setPen( pen );
|
QPen pen( hoverOutlineColor );
|
||||||
|
pen.setWidth( outlineWidthPixels );
|
||||||
|
painter.setPen( pen );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QPen pen( outlineColor );
|
||||||
|
pen.setWidth( outlineWidthPixels );
|
||||||
|
painter.setPen( pen );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user