summaryrefslogtreecommitdiff
path: root/libopie
Side-by-side diff
Diffstat (limited to 'libopie') (more/less context) (show whitespace changes)
-rw-r--r--libopie/ocolorbutton.cpp5
-rw-r--r--libopie/ofontselector.cpp5
-rw-r--r--libopie/ofontselector.h1
3 files changed, 10 insertions, 1 deletions
diff --git a/libopie/ocolorbutton.cpp b/libopie/ocolorbutton.cpp
index 96e5612..4734c0c 100644
--- a/libopie/ocolorbutton.cpp
+++ b/libopie/ocolorbutton.cpp
@@ -30,49 +30,52 @@
#include <opie/ocolorbutton.h>
#include <qcolor.h>
#include <qpixmap.h>
#include <qimage.h>
#include <qpe/resource.h>
class OColorButtonPrivate {
public:
QPopupMenu *m_menu;
QColor m_color;
};
OColorButton::OColorButton ( QWidget *parent, const char *name )
: QPushButton ( parent, name )
{
d = new OColorButtonPrivate;
d-> m_menu = new ColorPopupMenu ( black, 0, 0 );
setPopup ( d-> m_menu );
// setPopupDelay ( 0 );
connect ( d-> m_menu, SIGNAL( colorSelected ( const QColor & )), this, SLOT( updateColor ( const QColor & )));
updateColor ( black );
- setMinimumSize ( sizeHint ( ) + QSize ( 8, 0 ));
+
+ QSize s = sizeHint ( ) + QSize ( 12, 0 );
+ setMinimumSize ( s );
+ setMaximumSize ( s. width ( ) * 2, s. height ( ));
}
OColorButton::~OColorButton ( )
{
delete d;
}
QColor OColorButton::color ( ) const
{
return d-> m_color;
}
void OColorButton::setColor ( const QColor &c )
{
updateColor ( c );
}
void OColorButton::updateColor ( const QColor &c )
{
d-> m_color = c;
QImage img ( 16, 16, 32 );
img. fill ( 0 );
diff --git a/libopie/ofontselector.cpp b/libopie/ofontselector.cpp
index d32aeb4..39440af 100644
--- a/libopie/ofontselector.cpp
+++ b/libopie/ofontselector.cpp
@@ -91,48 +91,53 @@ OFontSelector::OFontSelector ( QWidget *parent, const char *name, WFlags fl ) :
connect( m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) );
QLabel *label = new QLabel( tr( "Style" ), this );
gridLayout->addWidget( label, 0, 1 );
m_font_style_list = new QComboBox( this, "StyleListBox" );
connect( m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) );
gridLayout->addWidget( m_font_style_list, 1, 1 );
label = new QLabel( tr( "Size" ), this );
gridLayout->addWidget( label, 2, 1 );
m_font_size_list = new QComboBox( this, "SizeListBox" );
connect( m_font_size_list, SIGNAL( activated( int ) ),
this, SLOT( fontSizeClicked( int ) ) );
gridLayout->addWidget( m_font_size_list, 3, 1 );
loadFonts ( m_font_family_list );
}
OFontSelector::~OFontSelector ( )
{
}
+bool OFontSelector::setSelectedFont ( const QFont &f )
+{
+ return setSelectedFont ( f. family ( ), m_fdb. styleString ( f ), f. pointSize ( ), QFont::encodingName ( f. charSet ( )));
+}
+
bool OFontSelector::setSelectedFont ( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & /*charset*/ )
{
QString sizeStr = QString::number ( sizeVal );
QListBoxItem *family = m_font_family_list-> findItem ( familyStr );
if ( !family )
family = m_font_family_list-> findItem ( "Helvetica" );
if ( !family )
family = m_font_family_list-> firstItem ( );
m_font_family_list-> setCurrentItem ( family );
fontFamilyClicked ( m_font_family_list-> index ( family ));
int style = findItemCB ( m_font_style_list, styleStr );
if ( style < 0 )
style = findItemCB ( m_font_style_list, "Regular" );
if ( style < 0 && m_font_style_list-> count ( ) > 0 )
style = 0;
m_font_style_list-> setCurrentItem ( style );
fontStyleClicked ( style );
int size = findItemCB ( m_font_size_list, sizeStr );
if ( size < 0 )
size = findItemCB ( m_font_size_list, "10" );
if ( size < 0 && m_font_size_list-> count ( ) > 0 )
diff --git a/libopie/ofontselector.h b/libopie/ofontselector.h
index 2011e43..b3aa862 100644
--- a/libopie/ofontselector.h
+++ b/libopie/ofontselector.h
@@ -28,48 +28,49 @@
#ifndef __OPIE_FONTSELECTOR_H__
#define __OPIE_FONTSELECTOR_H__
#include <qwidget.h>
#include <qpe/fontdatabase.h>
class QComboBox;
class QListBox;
class QFont;
class OFontSelector : public QWidget
{
Q_OBJECT
public:
OFontSelector ( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
virtual ~OFontSelector ( );
bool selectedFont ( QString &family, QString &style, int &size );
bool selectedFont ( QString &family, QString &style, int &size, QString &charset );
QFont selectedFont ( );
+ bool setSelectedFont ( const QFont & );
bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 );
QString fontFamily ( ) const;
QString fontStyle ( ) const;
int fontSize ( ) const;
QString fontCharSet ( ) const;
signals:
void fontSelected ( const QFont & );
protected slots:
virtual void fontFamilyClicked ( int );
virtual void fontStyleClicked ( int );
virtual void fontSizeClicked ( int );
private:
void loadFonts ( QListBox * );
void changeFont ( );
private:
QListBox * m_font_family_list;
QComboBox * m_font_style_list;
QComboBox * m_font_size_list;