summaryrefslogtreecommitdiffstats
path: root/lib/kofficeui/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kofficeui/tests')
-rw-r--r--lib/kofficeui/tests/Makefile.am15
-rw-r--r--lib/kofficeui/tests/coloraction_test.cpp112
-rw-r--r--lib/kofficeui/tests/coloraction_test.h44
3 files changed, 171 insertions, 0 deletions
diff --git a/lib/kofficeui/tests/Makefile.am b/lib/kofficeui/tests/Makefile.am
new file mode 100644
index 000000000..2aa13645e
--- /dev/null
+++ b/lib/kofficeui/tests/Makefile.am
@@ -0,0 +1,15 @@
+####### General stuff
+
+INCLUDES= -I$(srcdir)/.. $(KOFFICECORE_INCLUDES) $(all_includes)
+
+####### Files
+
+METASOURCES = AUTO
+
+check_PROGRAMS = # coloraction_test
+
+TESTS =
+
+#coloraction_test_SOURCES = coloraction_test.cpp
+#coloraction_test_LDADD = ../libkofficeui.la
+
diff --git a/lib/kofficeui/tests/coloraction_test.cpp b/lib/kofficeui/tests/coloraction_test.cpp
new file mode 100644
index 000000000..538f9707f
--- /dev/null
+++ b/lib/kofficeui/tests/coloraction_test.cpp
@@ -0,0 +1,112 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999 by Dirk A. Mueller <dmuell@gmx.net>
+ Copyright (C) 2002 Werner Trobin <trobin@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 <qlayout.h>
+#include <qvgroupbox.h>
+#include <qpopupmenu.h>
+#include <qmenubar.h>
+
+#include <kdebug.h>
+#include <ktoolbar.h>
+#include <kiconloader.h>
+#include <kapplication.h>
+#include <KoTooluButton.h>
+#include <coloraction_test.h>
+
+#include <stdlib.h>
+#include <time.h>
+
+
+TopLevel::TopLevel( QWidget* parent, const char* name) : QMainWindow( parent, name )
+{
+ setCaption( QString::fromLatin1( "KColorAction test application" ) );
+
+ QWidget *w = new QWidget( this );
+ setCentralWidget( w );
+
+ QBoxLayout* l = new QHBoxLayout( w, KDialog::marginHint(), KDialog::spacingHint() );
+ QGroupBox* b1 = new QVGroupBox( QString::fromLatin1( "KoColorPanel 1" ), w );
+ panel = new KoColorPanel( b1, "panel1" );
+ connect( panel, SIGNAL( colorSelected( const QColor& ) ), SLOT( slotColorSelected( const QColor& ) ) );
+ //panel->insertDefaultColors();
+ l->addWidget( b1 );
+
+ b1 = new QVGroupBox( QString::fromLatin1( "KoColorPanel 2" ), w );
+
+ ( void ) new KoColorPanel( b1, "panel2" );
+ l->addWidget( b1 );
+
+ QPopupMenu* file = new QPopupMenu( this );
+ menuBar()->insertItem( "&File", file );
+
+ file->insertItem( "Custom + Default", KoColorPanel::createColorPopup( KoColorPanel::CustomColors, Qt::red, this,
+ SLOT( slotColorSelected( const QColor& ) ), file, "blah" ) );
+ file->insertItem( "Custom", KoColorPanel::createColorPopup( KoColorPanel::CustomColors, QColor(), this,
+ SLOT( slotColorSelected( const QColor& ) ), file, "blah" ) );
+ file->insertItem( "Plain + Default", KoColorPanel::createColorPopup( KoColorPanel::Plain, Qt::green, this,
+ SLOT( slotColorSelected( const QColor& ) ), file, "blah" ) );
+ file->insertItem( "Plain", KoColorPanel::createColorPopup( KoColorPanel::Plain, QColor(), this,
+ SLOT( slotColorSelected( const QColor& ) ), file, "blah" ) );
+ file->insertSeparator();
+ file->insertItem( "Default Colors", this, SLOT( defaultColors() ), CTRL+Key_D );
+ file->insertItem( "Insert Random Color", this, SLOT( insertRandomColor() ), CTRL+Key_R );
+ file->insertSeparator();
+ file->insertItem( "Clear", this, SLOT( clearColors() ), CTRL+Key_C );
+ file->insertSeparator();
+ file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );
+
+ KToolBar* toolBar = new KToolBar( this );
+ addDockWindow( toolBar );
+ ( void ) new KoToolButton( "color_fill", 1, toolBar, "funky button", "Fill Color" );
+}
+
+void TopLevel::insertRandomColor()
+{
+ panel->insertColor( qRgb( rand() % 256, rand() % 256, rand() % 256 ) );
+}
+
+void TopLevel::defaultColors()
+{
+ panel->insertDefaultColors();
+}
+
+void TopLevel::clearColors()
+{
+ panel->clear();
+}
+
+void TopLevel::slotColorSelected( const QColor& color )
+{
+ kdDebug() << "#### selected: " << color.name() << endl;
+}
+
+
+int main( int argc, char ** argv )
+{
+ srand( time( 0 ) );
+
+ KApplication a( argc, argv, "KColorAction Test" );
+ TopLevel *toplevel = new TopLevel( 0, "coloractiontest" );
+ a.setMainWidget( toplevel );
+ toplevel->show();
+ return a.exec();
+}
+
+#include <coloraction_test.moc>
diff --git a/lib/kofficeui/tests/coloraction_test.h b/lib/kofficeui/tests/coloraction_test.h
new file mode 100644
index 000000000..d29f9c5af
--- /dev/null
+++ b/lib/kofficeui/tests/coloraction_test.h
@@ -0,0 +1,44 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999 by Dirk A. Mueller <dmuell@gmx.net>
+ Copyright (C) 2002 Werner Trobin <trobin@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 _COLORACTIONTEST_H
+#define _COLORACTIONTEST_H
+
+#include <qmainwindow.h>
+
+class KoColorPanel;
+
+class TopLevel : public QMainWindow
+{
+ Q_OBJECT
+public:
+ TopLevel( QWidget* parent = 0, const char* name = 0 );
+
+public slots:
+ void insertRandomColor();
+ void defaultColors();
+ void clearColors();
+ void slotColorSelected( const QColor& color );
+
+private:
+ KoColorPanel* panel;
+};
+
+#endif // _COLORACTIONTEST_H