Commit 9a54afee authored by Casper Boemann's avatar Casper Boemann

move kofficui to koguiutils

dir nemd guiutils

Note: Followup commit comming in 5 minutes

svn path=/trunk/koffice/; revision=662287
parent 47559181
add_subdirectory( tests )
include_directories( ${KOMAIN_INCLUDES} ${FLAKE_INCLUDES} ${PIGMENT_INCLUDES} ${KOGUIUTILS_INCLUDES})
########### next target ###############
set(koguiutils_LIB_SRCS
KoCharSelectDia.cpp
KoContextHelp.cpp
KoCsvImportDialog.cpp
KoDocumentSectionDelegate.cpp
KoDocumentSectionView.cpp
KoDocumentSectionToolTip.cpp
KoGeneralPropertyUi.cpp
KoGuideLineDia.cpp
KoGuides.cpp
KoImageResource.cpp
KoInsertLink.cpp
KoItemToolTip.cpp
#KoPageLayoutColumns.cpp
#KoPageLayoutDia.cpp
#KoPageLayoutHeader.cpp
#KoPageLayoutSize.cpp
KoPartSelectDia.cpp
KoPartSelectAction.cpp
KoPictureFilePreview.cpp
KoRuler.cpp
KoShapeGeometry.cpp
KoSliderCombo.cpp
KoTabBar.cpp
KoTabChooser.cpp
KoTemplateChooseDia.cpp
KoTemplateCreateDia.cpp
KoToolBox.cpp
KoUnitWidgets.cpp
KoZoomAction.cpp
KoZoomController.cpp
KoZoomHandler.cpp
KoZoomMode.cpp
KoToolBoxFactory.cpp
KoToolDocker.cpp
KoToolDockerFactory.cpp
KoLayoutVisitor.cpp
KoCopyController.cpp
KoImageData.cpp
KoImageCollection.cpp
KoColorDocker.cpp
KoResourceChooser.cpp
KoColorSlider.cc
KoXYColorSelector.cc
KoUniColorChooser.cpp
KoUniColorDialog.cpp
KoColorPatch.cpp
KoDualColorButton.cpp
)
kde4_automoc(${koguiutils_LIB_SRCS})
kde4_add_ui_files( koguiutils_LIB_SRCS
KoCsvImportDialog.ui
KoGeneralPropertyUi.ui
#KoPageLayoutColumns.ui
#KoPageLayoutHeaderBase.ui
KoShapeGeometry.ui
)
kde4_add_library(koguiutils SHARED ${koguiutils_LIB_SRCS})
target_link_libraries(koguiutils ${KDE4_KDECORE_LIBS} komain flake pigment )
set_target_properties(koguiutils PROPERTIES VERSION ${GENERIC_KOFFICE_LIB_VERSION} SOVERSION ${GENERIC_KOFFICE_LIB_SOVERSION} )
install(TARGETS koguiutils DESTINATION ${LIB_INSTALL_DIR})
install( FILES zoom-width.png zoom-page.png zoom-pixels.png DESTINATION ${DATA_INSTALL_DIR}/koffice/icons/hicolor/22x22/actions)
########### install files ###############
install(
FILES
KoCharSelectDia.h
KoContextHelp.h
KoDocumentSectionModel.h
KoDocumentSectionView.h
KoGeneralPropertyUi.h
KoGuideLineDia.h
KoGuides.h
KoImageResource.h
KoInsertLink.h
KoItemToolTip.h
#KoPageLayoutColumns.h
#KoPageLayoutDia.h
#KoPageLayoutHeader.h
#KoPageLayoutSize.h
KoPartSelectAction.h
KoPartSelectDia.h
KoPictureFilePreview.h
KoRuler.h
KoTabBar.h
KoTabChooser.h
KoTabulator.h
KoTemplateChooseDia.h
KoTemplateCreateDia.h
KoUnitWidgets.h
KoZoomAction.h
KoZoomController.h
KoZoomHandler.h
KoZoomMode.h
KoToolBoxFactory.h
KoToolDocker.h
KoToolDockerFactory.h
DESTINATION
${INCLUDE_INSTALL_DIR}
)
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
Copyright (C) 2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoCharSelectDia.h"
#include "KoCharSelectDia.moc"
#include <QLayout>
#include <QGridLayout>
#include <klocale.h>
#include <kcharselect.h>
#include <kdebug.h>
#include <KStandardGuiItem>
class KoCharSelectDia::Private {
public:
Private() : charSelect(0) {}
KCharSelect *charSelect;
};
/******************************************************************/
/* class KoCharSelectDia */
/******************************************************************/
KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr, const QString &_font, bool _modal)
: KDialog( parent ),
d(new Private())
{
setCaption( i18n("Select Character") );
setModal( _modal );
setButtons( Ok | Cancel );
setDefaultButton( Ok );
setObjectName( name );
initDialog(_chr,_font);
KGuiItem okItem = KStandardGuiItem::ok(); // start from std item to keep the OK icon...
okItem.setText( i18n("&Insert") );
okItem.setWhatsThis( i18n("Insert the selected character in the text") );
setButtonGuiItem( KDialog::Ok, okItem );
}
KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QString &_font, const QChar &_chr, bool _modal )
: KDialog( parent ),
d(new Private())
{
setCaption( i18n("Select Character") );
setModal( _modal );
setButtons( User1 | Close );
setDefaultButton( User1 );
setObjectName( name );
initDialog(_chr,_font);
setButtonText( User1, i18n("&Insert") );
setButtonToolTip( User1, i18n("Insert the selected character in the text") );
connect(this,SIGNAL(user1Clicked()),this,SLOT(slotUser1()));
}
void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font)
{
QWidget *page = mainWidget()/*plainPage()*/;
QGridLayout *grid = new QGridLayout( page );
grid->setMargin(0);
grid->setSpacing(KDialog::spacingHint());
d->charSelect = new KCharSelect( page );
d->charSelect->setCurrentChar( _chr );
d->charSelect->setCurrentFont( QFont(_font) );
connect(d->charSelect, SIGNAL(charSelected()),this, SLOT(slotDoubleClicked()));
d->charSelect->resize( d->charSelect->sizeHint() );
// d->charSelect->enableFontCombo( true );
grid->addWidget( d->charSelect, 0, 0 );
grid->addItem( new QSpacerItem( d->charSelect->width(), 0 ), 0, 0 );
grid->addItem( new QSpacerItem( 0, d->charSelect->height() ), 0, 0 );
grid->setRowStretch( 0, 0 );
d->charSelect->setFocus();
}
KoCharSelectDia::~KoCharSelectDia()
{
delete d;
}
void KoCharSelectDia::closeDialog()
{
KDialog::close();
}
// static
bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, QWidget* parent, const char* name)
{
bool res = false;
KoCharSelectDia *dlg = new KoCharSelectDia( parent, name, _chr, _font);
dlg->setFocus();
if ( dlg->exec() == Accepted )
{
_font = dlg->font();
_chr = dlg->chr();
res = true;
}
delete dlg;
return res;
}
QChar KoCharSelectDia::chr() const
{
return d->charSelect->currentChar();
}
QString KoCharSelectDia::font() const
{
return d->charSelect->font().family();
}
void KoCharSelectDia::slotUser1()
{
emit insertChar(chr(),font());
}
void KoCharSelectDia::slotDoubleClicked()
{
emit insertChar(chr(),font());
}
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
Copyright (C) 2007 Thomas Zander <zander@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOCHARSELECTDIA_H
#define KOCHARSELECTDIA_H
#include <kdialog.h>
#include <koguiutils_export.h>
class QWidget;
class QGridLayout;
class QPushButton;
class KCharSelect;
class KButtonBox;
/**
* A dialog for selecting a character.
*/
class KOGUIUTILS_EXPORT KoCharSelectDia : public KDialog
{
Q_OBJECT
public:
// constructor
KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr,
const QString &_font, bool _modal=true );
//constructor when you want to insert multi char
KoCharSelectDia( QWidget *parent, const char *name, const QString &_font,
const QChar &_chr, bool _modal=true );
~KoCharSelectDia();
/**
* Shows the selection dialog and returns true if user pressed ok, after filling the font and character parameters.
* @param font will be filled when the user pressed Ok with the selected font.
* @param character will be filled when the user pressed Ok with the selected character.
* @param parent the parent widget this dialog will be associated with.
*/
KOGUIUTILS_EXPORT static bool selectChar( QString &font, QChar &character, QWidget* parent = 0, const char* name = 0);
signals:
/**
* Emitted when the user presses the 'insert' button.
* @param character the character that the user selected
* @param font the font name that was selected when the user inserted the character.
*/
void insertChar(QChar character ,const QString &font);
private:
void initDialog(const QChar &_chr, const QString &_font);
QChar chr() const;
QString font() const;
void closeDialog();
private slots:
void slotUser1();
void slotDoubleClicked();
private:
class Private;
Private * const d;
};
#endif
/* This file is part of the KDE project
Made by Tomislav Lukman (tomislav.lukman@ck.tel.hr)
Copyright (C) 2002 - 2005, Rob Buis <buis@kde.org>
Copyright (C) 2006 Jan Hambecht <jaham@gmx.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "KoColorDocker.h"
#include <klocale.h>
#include <kdebug.h>
#include <KoUniColorChooser.h>
KoColorDocker::KoColorDocker(bool showOpacitySlider)
: QDockWidget()
{
setWindowTitle( i18n( "Color Chooser" ) );
m_colorChooser = new KoUniColorChooser( this, showOpacitySlider );
setWidget( m_colorChooser );
setMinimumWidth( 194 );
}
KoColorDocker::~KoColorDocker()
{
}
QString KoColorDockerFactory::id() const
{
return QString("KoColorDocker");
}
Qt::DockWidgetArea KoColorDockerFactory::defaultDockWidgetArea() const
{
return Qt::RightDockWidgetArea;
}
QDockWidget* KoColorDockerFactory::createDockWidget()
{
KoColorDocker* widget = new KoColorDocker(m_showOpacitySlider);
widget->setObjectName(id());
return widget;
}
#include "KoColorDocker.moc"
/* This file is part of the KDE project
Made by Tomislav Lukman (tomislav.lukman@ck.tel.hr)
Copyright (C) 2002 - 2005, Rob Buis <buis@kde.org>
Copyright (C) 2006 Jan Hambecht <jaham@gmx.net>
Copyright (C) 2006 Boudewijn Rempt <boud@valdyas.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __KO_COLOR_DOCKER_H__
#define __KO_COLOR_DOCKER_H__
#include <QDockWidget>
#include <KoDockFactory.h>
#include "koguiutils_export.h"
class KoUniColorChooser;
/**
Dock widget that contains a color selector. Currently this is the
big, unified color selector, but I would prefer a small strip with
just a band of colors -- and have the unified color selector popup.
This just takes a tad too much place.
*/
class KOGUIUTILS_EXPORT KoColorDocker : public QDockWidget
{
Q_OBJECT
public:
KoColorDocker(bool showOpacitySlider);
virtual ~KoColorDocker();
private:
KoUniColorChooser *m_colorChooser;
};
class KOGUIUTILS_EXPORT KoColorDockerFactory : public KoDockFactory
{
public:
KoColorDockerFactory(bool showOpacitySlider = false)
: m_showOpacitySlider( showOpacitySlider )
{}
~KoColorDockerFactory() {}
QString id() const;
Qt::DockWidgetArea defaultDockWidgetArea() const;
QDockWidget * createDockWidget();
private:
bool m_showOpacitySlider;
};
#endif
/**
* Copyright (c) 2006 Casper Boemann (cbr@boemann.dk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QPainter>
#include "KoColorPatch.h"
KoColorPatch::KoColorPatch( QWidget *parent ) : QFrame( parent )
{
setFrameStyle( QFrame::Panel | QFrame::Sunken );
}
KoColorPatch::~KoColorPatch()
{
}
void KoColorPatch::setColor(const KoColor c)
{
m_color = c;
update();
}
void KoColorPatch::paintEvent ( QPaintEvent* pe )
{
QColor qc;
m_color.toQColor(&qc);
QFrame::paintEvent(pe);
QPainter painter( this );
painter.setPen(qc);
painter.setBrush(QBrush(qc));
painter.drawRect(contentsRect());
}
#include "KoColorPatch.moc"
/**
* Copyright (c) 2006 Casper Boemann (cbr@boemann.dk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOCOLORPATCH_H
#define KOCOLORPATCH_H
#include <QFrame>
#include <KoColor.h>
#include "koguiutils_export.h"
/**
* The small widget showing the selected color
*/
class KOGUIUTILS_EXPORT KoColorPatch : public QFrame
{
Q_OBJECT
public:
explicit KoColorPatch( QWidget *parent );
virtual ~KoColorPatch();
void setColor( const KoColor c );
protected:
virtual void paintEvent ( QPaintEvent * pe );
private:
KoColor m_color;
};
#endif
/* This file is part of the KDE project
Copyright (C) 2006 Sven Langkamp <sven.langkamp@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QColor>
#include <QPainter>
#include "KoColorSlider.h"
#include "KoColorSpace.h"
KoColorSlider::KoColorSlider(QWidget* parent)
: KSelector(parent)
{
setMaximum(255);
}
KoColorSlider::KoColorSlider(Qt::Orientation o, QWidget *parent)
: KSelector(o, parent)
{
setMaximum(255);
}
KoColorSlider::~KoColorSlider()
{
}
void KoColorSlider::setColors(const KoColor& mincolor, const KoColor& maxcolor)
{
m_minColor = mincolor;
m_maxColor = maxcolor;
update();
}
void KoColorSlider::drawContents( QPainter *painter )
{
QPixmap checker(8, 8);
QPainter p(&checker);
p.fillRect(0, 0, 4, 4, Qt::lightGray);
p.fillRect(4, 0, 4, 4, Qt::darkGray);
p.fillRect(0, 4, 4, 4, Qt::darkGray);
p.fillRect(4, 4, 4, 4, Qt::lightGray);
p.end();
painter->fillRect(contentsRect(), QBrush(checker));
KoColor c = m_minColor; // smart way to fetch colorspace
QColor color;
quint8 opacity;
const quint8 *colors[2];
colors[0] = m_minColor.data();
colors[1] = m_maxColor.data();
KoMixColorsOp * mixOp = c.colorSpace()->mixColorsOp();
QImage image(contentsRect().width(), contentsRect().height(), QImage::Format_ARGB32 );
if( orientation() == Qt::Horizontal ) {
for (int x = 0; x < contentsRect().width(); x++) {
double t = static_cast<double>(x) / (contentsRect().width() - 1);
quint8 colorWeights[2];
colorWeights[0] = static_cast<quint8>((1.0 - t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
mixOp->mixColors(colors, colorWeights, 2, c.data());
c.toQColor(&color, &opacity);
color.setAlpha(opacity);
for (int y = 0; y < contentsRect().height(); y++)
image.setPixel(x, y, color.rgba());
}
}
else {
for (int y = 0; y < contentsRect().height(); y++) {
double t = static_cast<double>(y) / (contentsRect().height() - 1);
quint8 colorWeights[2];
colorWeights[0] = static_cast<quint8>((t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
mixOp->mixColors(colors, colorWeights, 2, c.data());
c.toQColor(&color, &opacity);
color.setAlpha(opacity);
for (int x = 0; x < contentsRect().width(); x++)
image.setPixel(x, y, color.rgba());
}
}
painter->drawImage( contentsRect(), image, QRect( 0, 0, image.width(), image.height()) );
}