From e16866e072f94410321d70daedbcb855ea878cac Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 6 Nov 2011 15:56:40 -0600 Subject: Actually move the kde files that were renamed in the last commit --- tdeui/tests/CMakeLists.txt | 49 ++ tdeui/tests/Makefile.am | 105 ++++ tdeui/tests/RayTracedGear.png | Bin 0 -> 5844 bytes tdeui/tests/background_1.png | Bin 0 -> 7209 bytes tdeui/tests/go.png | Bin 0 -> 3286 bytes tdeui/tests/itemcontainertest.cpp | 225 +++++++ tdeui/tests/itemcontainertest.h | 45 ++ tdeui/tests/kaboutdialogtest.cpp | 72 +++ tdeui/tests/kaccelgentest.cpp | 51 ++ tdeui/tests/kactiontest.cpp | 38 ++ tdeui/tests/kalphaicontest.h | 24 + tdeui/tests/kblendtest.cpp | 98 +++ tdeui/tests/kblendtest.h | 24 + tdeui/tests/kbuttonboxtest.cpp | 205 ++++++ tdeui/tests/kcharselecttest.cpp | 16 + tdeui/tests/kcolordlgtest.cpp | 41 ++ tdeui/tests/kcolortest.cpp | 169 +++++ tdeui/tests/kcolortest.h | 21 + tdeui/tests/kcomboboxtest.cpp | 227 +++++++ tdeui/tests/kcomboboxtest.h | 44 ++ tdeui/tests/kcompletiontest.cpp | 198 ++++++ tdeui/tests/kcompletiontest.h | 67 ++ tdeui/tests/kdatepicktest.cpp | 16 + tdeui/tests/kdatetimewidgettest.cpp | 14 + tdeui/tests/kdatewidgettest.cpp | 16 + tdeui/tests/kdesattest.cpp | 65 ++ tdeui/tests/kdesattest.h | 31 + tdeui/tests/kdialogbasetest.cpp | 77 +++ tdeui/tests/kdocktest.cpp | 65 ++ tdeui/tests/kdocktest.h | 19 + tdeui/tests/kdockwidgetdemo.cpp | 796 ++++++++++++++++++++++++ tdeui/tests/kdockwidgetdemo.h | 164 +++++ tdeui/tests/kdockwidgettest.cpp | 255 ++++++++ tdeui/tests/kdockwidgettest.h | 72 +++ tdeui/tests/kdualcolortest.cpp | 63 ++ tdeui/tests/kdualcolortest.h | 20 + tdeui/tests/keditlistboxtest.cpp | 21 + tdeui/tests/kedittest.cpp | 14 + tdeui/tests/kfontdialogtest.cpp | 51 ++ tdeui/tests/kgradienttest.cpp | 108 ++++ tdeui/tests/kgradienttest.h | 24 + tdeui/tests/khashtest.cpp | 137 ++++ tdeui/tests/khashtest.h | 26 + tdeui/tests/kinputdialogtest.cpp | 67 ++ tdeui/tests/kjanuswidgettest.cpp | 25 + tdeui/tests/kledtest.cpp | 160 +++++ tdeui/tests/kledtest.h | 56 ++ tdeui/tests/klineeditdlgtest.cpp | 19 + tdeui/tests/klineedittest.cpp | 137 ++++ tdeui/tests/klineedittest.h | 41 ++ tdeui/tests/klistviewtest.cpp | 39 ++ tdeui/tests/kmainwindowrestoretest.cpp | 41 ++ tdeui/tests/kmainwindowrestoretest.h | 48 ++ tdeui/tests/kmainwindowtest.cpp | 38 ++ tdeui/tests/kmainwindowtest.h | 18 + tdeui/tests/kmessageboxtest.cpp | 242 +++++++ tdeui/tests/knuminputtest.cpp | 145 +++++ tdeui/tests/knuminputtest.h | 23 + tdeui/tests/kpalettetest.cpp | 38 ++ tdeui/tests/kpanelmenutest.cpp | 72 +++ tdeui/tests/kpanelmenutest.h | 21 + tdeui/tests/kpixmapregionselectordialogtest.cpp | 33 + tdeui/tests/kpopuptest.cpp | 40 ++ tdeui/tests/kprogresstest.cpp | 58 ++ tdeui/tests/krulertest.cpp | 375 +++++++++++ tdeui/tests/krulertest.h | 91 +++ tdeui/tests/kseparatortest.cpp | 51 ++ tdeui/tests/kspelltest.cpp | 57 ++ tdeui/tests/ksqueezedtextlabeltest.cpp | 13 + tdeui/tests/kstatusbartest.cpp | 121 ++++ tdeui/tests/kstatusbartest.h | 33 + tdeui/tests/ksystemtraytest.cpp | 14 + tdeui/tests/ktabctltest.cpp | 105 ++++ tdeui/tests/ktabctltest.h | 30 + tdeui/tests/ktabwidgettest.cpp | 366 +++++++++++ tdeui/tests/ktabwidgettest.h | 69 ++ tdeui/tests/ktextedittest.cpp | 43 ++ tdeui/tests/ktimewidgettest.cpp | 14 + tdeui/tests/ktoolbarlabelactiontest.cpp | 97 +++ tdeui/tests/ktoolbarlabelactiontestui.rc | 9 + tdeui/tests/kunbalancedgrdtest.cpp | 176 ++++++ tdeui/tests/kunbalancedgrdtest.h | 49 ++ tdeui/tests/kwindowtest.cpp | 528 ++++++++++++++++ tdeui/tests/kwindowtest.h | 71 +++ tdeui/tests/kwizardtest.cpp | 54 ++ tdeui/tests/kwordwraptest.cpp | 43 ++ tdeui/tests/kxmlguitest.cpp | 64 ++ tdeui/tests/kxmlguitest.h | 19 + tdeui/tests/kxmlguitest_part.rc | 8 + tdeui/tests/kxmlguitest_shell.rc | 7 + tdeui/tests/qxembedtest.cpp | 88 +++ tdeui/tests/testimage.png | Bin 0 -> 35951 bytes 92 files changed, 7729 insertions(+) create mode 100644 tdeui/tests/CMakeLists.txt create mode 100644 tdeui/tests/Makefile.am create mode 100644 tdeui/tests/RayTracedGear.png create mode 100644 tdeui/tests/background_1.png create mode 100644 tdeui/tests/go.png create mode 100644 tdeui/tests/itemcontainertest.cpp create mode 100644 tdeui/tests/itemcontainertest.h create mode 100644 tdeui/tests/kaboutdialogtest.cpp create mode 100644 tdeui/tests/kaccelgentest.cpp create mode 100644 tdeui/tests/kactiontest.cpp create mode 100644 tdeui/tests/kalphaicontest.h create mode 100644 tdeui/tests/kblendtest.cpp create mode 100644 tdeui/tests/kblendtest.h create mode 100644 tdeui/tests/kbuttonboxtest.cpp create mode 100644 tdeui/tests/kcharselecttest.cpp create mode 100644 tdeui/tests/kcolordlgtest.cpp create mode 100644 tdeui/tests/kcolortest.cpp create mode 100644 tdeui/tests/kcolortest.h create mode 100644 tdeui/tests/kcomboboxtest.cpp create mode 100644 tdeui/tests/kcomboboxtest.h create mode 100644 tdeui/tests/kcompletiontest.cpp create mode 100644 tdeui/tests/kcompletiontest.h create mode 100644 tdeui/tests/kdatepicktest.cpp create mode 100644 tdeui/tests/kdatetimewidgettest.cpp create mode 100644 tdeui/tests/kdatewidgettest.cpp create mode 100644 tdeui/tests/kdesattest.cpp create mode 100644 tdeui/tests/kdesattest.h create mode 100644 tdeui/tests/kdialogbasetest.cpp create mode 100644 tdeui/tests/kdocktest.cpp create mode 100644 tdeui/tests/kdocktest.h create mode 100644 tdeui/tests/kdockwidgetdemo.cpp create mode 100644 tdeui/tests/kdockwidgetdemo.h create mode 100644 tdeui/tests/kdockwidgettest.cpp create mode 100644 tdeui/tests/kdockwidgettest.h create mode 100644 tdeui/tests/kdualcolortest.cpp create mode 100644 tdeui/tests/kdualcolortest.h create mode 100644 tdeui/tests/keditlistboxtest.cpp create mode 100644 tdeui/tests/kedittest.cpp create mode 100644 tdeui/tests/kfontdialogtest.cpp create mode 100644 tdeui/tests/kgradienttest.cpp create mode 100644 tdeui/tests/kgradienttest.h create mode 100644 tdeui/tests/khashtest.cpp create mode 100644 tdeui/tests/khashtest.h create mode 100644 tdeui/tests/kinputdialogtest.cpp create mode 100644 tdeui/tests/kjanuswidgettest.cpp create mode 100644 tdeui/tests/kledtest.cpp create mode 100644 tdeui/tests/kledtest.h create mode 100644 tdeui/tests/klineeditdlgtest.cpp create mode 100644 tdeui/tests/klineedittest.cpp create mode 100644 tdeui/tests/klineedittest.h create mode 100644 tdeui/tests/klistviewtest.cpp create mode 100644 tdeui/tests/kmainwindowrestoretest.cpp create mode 100644 tdeui/tests/kmainwindowrestoretest.h create mode 100644 tdeui/tests/kmainwindowtest.cpp create mode 100644 tdeui/tests/kmainwindowtest.h create mode 100644 tdeui/tests/kmessageboxtest.cpp create mode 100644 tdeui/tests/knuminputtest.cpp create mode 100644 tdeui/tests/knuminputtest.h create mode 100644 tdeui/tests/kpalettetest.cpp create mode 100644 tdeui/tests/kpanelmenutest.cpp create mode 100644 tdeui/tests/kpanelmenutest.h create mode 100644 tdeui/tests/kpixmapregionselectordialogtest.cpp create mode 100644 tdeui/tests/kpopuptest.cpp create mode 100644 tdeui/tests/kprogresstest.cpp create mode 100644 tdeui/tests/krulertest.cpp create mode 100644 tdeui/tests/krulertest.h create mode 100644 tdeui/tests/kseparatortest.cpp create mode 100644 tdeui/tests/kspelltest.cpp create mode 100644 tdeui/tests/ksqueezedtextlabeltest.cpp create mode 100644 tdeui/tests/kstatusbartest.cpp create mode 100644 tdeui/tests/kstatusbartest.h create mode 100644 tdeui/tests/ksystemtraytest.cpp create mode 100644 tdeui/tests/ktabctltest.cpp create mode 100644 tdeui/tests/ktabctltest.h create mode 100644 tdeui/tests/ktabwidgettest.cpp create mode 100644 tdeui/tests/ktabwidgettest.h create mode 100644 tdeui/tests/ktextedittest.cpp create mode 100644 tdeui/tests/ktimewidgettest.cpp create mode 100644 tdeui/tests/ktoolbarlabelactiontest.cpp create mode 100644 tdeui/tests/ktoolbarlabelactiontestui.rc create mode 100644 tdeui/tests/kunbalancedgrdtest.cpp create mode 100644 tdeui/tests/kunbalancedgrdtest.h create mode 100644 tdeui/tests/kwindowtest.cpp create mode 100644 tdeui/tests/kwindowtest.h create mode 100644 tdeui/tests/kwizardtest.cpp create mode 100644 tdeui/tests/kwordwraptest.cpp create mode 100644 tdeui/tests/kxmlguitest.cpp create mode 100644 tdeui/tests/kxmlguitest.h create mode 100644 tdeui/tests/kxmlguitest_part.rc create mode 100644 tdeui/tests/kxmlguitest_shell.rc create mode 100644 tdeui/tests/qxembedtest.cpp create mode 100644 tdeui/tests/testimage.png (limited to 'tdeui/tests') diff --git a/tdeui/tests/CMakeLists.txt b/tdeui/tests/CMakeLists.txt new file mode 100644 index 000000000..3cc853235 --- /dev/null +++ b/tdeui/tests/CMakeLists.txt @@ -0,0 +1,49 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${TQT_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdeui + ${CMAKE_SOURCE_DIR}/tdefx + ${CMAKE_SOURCE_DIR}/dcop +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +set( test_PROGS + kaboutdialogtest kblendtest kbuttonboxtest kcharselecttest + kcolortest kcolordlgtest kcomboboxtest kcompletiontest + kdatepicktest kdatewidgettest kdialogbasetest + kdockwidgetdemo kdockwidgettest + kdualcolortest keditlistboxtest kfontdialogtest + kgradienttest khashtest kdesattest + kledtest klineedittest klineeditdlgtest + kmessageboxtest knuminputtest + kpalettetest + kpopuptest kprogresstest krulertest kseparatortest + kstatusbartest ktabctltest + kunbalancedgrdtest kwindowtest kwizardtest + itemcontainertest kpanelmenutest kedittest + kxmlguitest kaccelgentest ksystemtraytest klistviewtest + ktextedittest kmainwindowtest kmainwindowrestoretest + kactiontest kdatetimewidgettest ktimewidgettest + kspelltest kinputdialogtest ktabwidgettest kwordwraptest + kdocktest qxembedtest ksqueezedtextlabeltest + kpixmapregionselectordialogtest kjanuswidgettest ktoolbarlabelactiontest +) + +foreach( PROG ${test_PROGS} ) + tde_add_executable( ${PROG} AUTOMOC SOURCES "${PROG}.cpp" LINK tdeui-shared ) +endforeach( PROG ${test_PROGS} ) diff --git a/tdeui/tests/Makefile.am b/tdeui/tests/Makefile.am new file mode 100644 index 000000000..b919ab3b4 --- /dev/null +++ b/tdeui/tests/Makefile.am @@ -0,0 +1,105 @@ +# This file is part of the KDE libraries +# Copyright (C) 1996-1997 Matthias Kalle Dalheimer (kalle@kde.org) +# (C) 1997-1998 Stephan Kulow (coolo@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. + +INCLUDES = -I$(top_srcdir)/tdefx -I$(top_srcdir)/tdecore -I$(top_srcdir)/tdeui \ + $(all_includes) + +AM_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) $(KDE_RPATH) + +check_PROGRAMS = kaboutdialogtest kblendtest kbuttonboxtest kcharselecttest \ + kcolortest kcolordlgtest kcomboboxtest kcompletiontest \ + kdatepicktest kdatewidgettest kdialogbasetest \ + kdockwidgetdemo kdockwidgettest \ + kdualcolortest keditlistboxtest kfontdialogtest \ + kgradienttest khashtest kdesattest\ + kledtest klineedittest klineeditdlgtest \ + kmessageboxtest knuminputtest \ + kpalettetest \ + kpopuptest kprogresstest krulertest kseparatortest \ + kstatusbartest ktabctltest \ + kunbalancedgrdtest kwindowtest kwizardtest \ + itemcontainertest kpanelmenutest kedittest \ + kxmlguitest kaccelgentest ksystemtraytest klistviewtest \ + ktextedittest kmainwindowtest kmainwindowrestoretest \ + kactiontest kdatetimewidgettest ktimewidgettest \ + kspelltest kinputdialogtest ktabwidgettest kwordwraptest \ + kdocktest qxembedtest ksqueezedtextlabeltest \ + kpixmapregionselectordialogtest kjanuswidgettest ktoolbarlabelactiontest + +METASOURCES = AUTO + +LDADD = ../libtdeui.la + +kaboutdialogtest_SOURCES = kaboutdialogtest.cpp +kblendtest_SOURCES = kblendtest.cpp +kdesattest_SOURCES = kdesattest.cpp +kbuttonboxtest_SOURCES = kbuttonboxtest.cpp +kcharselecttest_SOURCES = kcharselecttest.cpp +kcolordlgtest_SOURCES = kcolordlgtest.cpp +kcolortest_SOURCES = kcolortest.cpp +kcomboboxtest_SOURCES = kcomboboxtest.cpp +kcompletiontest_SOURCES = kcompletiontest.cpp +kdatepicktest_SOURCES = kdatepicktest.cpp +kdatetimewidgettest_SOURCES = kdatetimewidgettest.cpp +kdatewidgettest_SOURCES = kdatewidgettest.cpp +kdialogbasetest_SOURCES = kdialogbasetest.cpp +kdualcolortest_SOURCES = kdualcolortest.cpp +kedittest_SOURCES = kedittest.cpp +keditlistboxtest_SOURCES = keditlistboxtest.cpp +kfontdialogtest_SOURCES = kfontdialogtest.cpp +kgradienttest_SOURCES = kgradienttest.cpp +khashtest_SOURCES = khashtest.cpp +kledtest_SOURCES = kledtest.cpp +klineedittest_SOURCES = klineedittest.cpp +klineeditdlgtest_SOURCES = klineeditdlgtest.cpp +kmessageboxtest_SOURCES = kmessageboxtest.cpp +knuminputtest_SOURCES = knuminputtest.cpp +kpalettetest_SOURCES = kpalettetest.cpp +kpopuptest_SOURCES = kpopuptest.cpp +kprogresstest_SOURCES = kprogresstest.cpp +krulertest_SOURCES = krulertest.cpp +kseparatortest_SOURCES = kseparatortest.cpp +kstatusbartest_SOURCES = kstatusbartest.cpp +ktabctltest_SOURCES = ktabctltest.cpp +ktimewidgettest_SOURCES = ktimewidgettest.cpp +kunbalancedgrdtest_SOURCES = kunbalancedgrdtest.cpp +kwindowtest_SOURCES = kwindowtest.cpp +kwizardtest_SOURCES = kwizardtest.cpp +itemcontainertest_SOURCES = itemcontainertest.cpp +kpanelmenutest_SOURCES = kpanelmenutest.cpp +kdockwidgetdemo_SOURCES = kdockwidgetdemo.cpp +kdockwidgettest_SOURCES = kdockwidgettest.cpp +kxmlguitest_SOURCES = kxmlguitest.cpp +kaccelgentest_SOURCES = kaccelgentest.cpp +ksystemtraytest_SOURCES = ksystemtraytest.cpp +klistviewtest_SOURCES = klistviewtest.cpp +ktextedittest_SOURCES = ktextedittest.cpp +kmainwindowtest_SOURCES = kmainwindowtest.cpp +kmainwindowrestoretest_SOURCES = kmainwindowrestoretest.cpp +kactiontest_SOURCES = kactiontest.cpp +kspelltest_SOURCES = kspelltest.cpp +kinputdialogtest_SOURCES = kinputdialogtest.cpp +ktabwidgettest_SOURCES = ktabwidgettest.cpp +kwordwraptest_SOURCES = kwordwraptest.cpp +kdocktest_SOURCES=kdocktest.cpp +qxembedtest_SOURCES=qxembedtest.cpp +ksqueezedtextlabeltest_SOURCES = ksqueezedtextlabeltest.cpp +kjanuswidgettest_SOURCES = kjanuswidgettest.cpp +kpixmapregionselectordialogtest_SOURCES = kpixmapregionselectordialogtest.cpp +ktoolbarlabelactiontest_SOURCES = ktoolbarlabelactiontest.cpp diff --git a/tdeui/tests/RayTracedGear.png b/tdeui/tests/RayTracedGear.png new file mode 100644 index 000000000..03314ca53 Binary files /dev/null and b/tdeui/tests/RayTracedGear.png differ diff --git a/tdeui/tests/background_1.png b/tdeui/tests/background_1.png new file mode 100644 index 000000000..5723d3a46 Binary files /dev/null and b/tdeui/tests/background_1.png differ diff --git a/tdeui/tests/go.png b/tdeui/tests/go.png new file mode 100644 index 000000000..8b9eacceb Binary files /dev/null and b/tdeui/tests/go.png differ diff --git a/tdeui/tests/itemcontainertest.cpp b/tdeui/tests/itemcontainertest.cpp new file mode 100644 index 000000000..1767bec5f --- /dev/null +++ b/tdeui/tests/itemcontainertest.cpp @@ -0,0 +1,225 @@ +/* +* Tests the item container widgets KIconView, KListView, KListBox +* +* Copyright (c) 2000 by Michael Reiher +* +* License: GPL, version 2 +* Version: $Id: +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "itemcontainertest.h" + +static const char * item_xpm[] = { +"22 22 3 1", +" c None", +". c #000000", +"+ c #FF0000", +" ...... ", +" ....++++.... ", +" ..++++..++++.. ", +" ..++++++++++++.. ", +" ..++++++..++++++.. ", +" ..++++++++++++++++.. ", +" .++++++++..++++++++. ", +" .++++++++++++++++++. ", +"..++++++++..++++++++..", +".++++++++++++++++++++.", +".+.+.+.+.+..+.+.+.+.+.", +".+.+.+.+.+..+.+.+.+.+.", +".++++++++++++++++++++.", +"..++++++++..++++++++..", +" .++++++++++++++++++. ", +" .++++++++..++++++++. ", +" ..++++++++++++++++.. ", +" ..++++++..++++++.. ", +" ..++++++++++++.. ", +" ..++++..++++.. ", +" ....++++.... ", +" ...... "}; + + +KApplication *app; + +TopLevel::TopLevel(TQWidget *parent, const char *name) + : TQWidget(parent, name) +{ + setCaption("Item container test application"); + + TQHBoxLayout* hBox = new TQHBoxLayout( this ); + TQVBoxLayout* vBox = new TQVBoxLayout( hBox ); + hBox->addSpacing( 5 ); + + //Selection mode selection + m_pbgMode = new TQButtonGroup( 1, Qt::Horizontal, "Selection Mode", this); + m_pbgMode->insert(new TQRadioButton("NoSlection", m_pbgMode), TopLevel::NoSelection ); + m_pbgMode->insert(new TQRadioButton("Single", m_pbgMode), TopLevel::Single ); + m_pbgMode->insert(new TQRadioButton("Multi", m_pbgMode), TopLevel::Multi ); + m_pbgMode->insert(new TQRadioButton("Extended", m_pbgMode), TopLevel::Extended ); + m_pbgMode->setExclusive( true ); + vBox->addWidget( m_pbgMode ); + + connect( m_pbgMode, TQT_SIGNAL( clicked( int ) ), + this, TQT_SLOT( slotSwitchMode( int ) ) ); + + //Signal labels + TQGroupBox* gbWiget = new TQGroupBox( 1, Qt::Horizontal, "Widget", this); + m_plblWidget = new TQLabel( gbWiget ); + vBox->addWidget( gbWiget ); + TQGroupBox* gbSignal = new TQGroupBox( 1, Qt::Horizontal, "emitted Signal", this); + m_plblSignal = new TQLabel( gbSignal ); + vBox->addWidget( gbSignal ); + TQGroupBox* gbItem = new TQGroupBox( 1, Qt::Horizontal, "on Item", this); + m_plblItem = new TQLabel( gbItem ); + vBox->addWidget( gbItem ); + + TQButtonGroup* bgListView = new TQButtonGroup( 1, Qt::Horizontal, "KListView", this); + TQCheckBox* cbListView = new TQCheckBox("Single Column", bgListView); + vBox->addWidget( bgListView ); + connect( cbListView, TQT_SIGNAL( toggled( bool ) ), + this, TQT_SLOT( slotToggleSingleColumn( bool ) ) ); + + KGlobal::config()->reparseConfiguration(); + + //Create IconView + TQGroupBox* gbIconView = new TQGroupBox( 1, Qt::Horizontal, "KIconView", this); + m_pIconView = new KIconView( gbIconView ); + hBox->addWidget( gbIconView ); + hBox->addSpacing( 5 ); + connect( m_pIconView, TQT_SIGNAL( executed( TQIconViewItem* ) ), + this, TQT_SLOT( slotIconViewExec( TQIconViewItem* ) ) ); + + //Create ListView + TQGroupBox* gbListView = new TQGroupBox( 1, Qt::Horizontal, "KListView", this); + m_pListView = new KListView( gbListView ); + m_pListView->addColumn("Item"); + m_pListView->addColumn("Text"); + hBox->addWidget( gbListView ); + hBox->addSpacing( 5 ); + connect( m_pListView, TQT_SIGNAL( executed( TQListViewItem* ) ), + this, TQT_SLOT( slotListViewExec( TQListViewItem* ) ) ); + + //Create ListBox + TQGroupBox* gbListBox = new TQGroupBox( 1, Qt::Horizontal, "KListBox", this); + m_pListBox = new KListBox( gbListBox ); + hBox->addWidget( gbListBox ); + connect( m_pListBox, TQT_SIGNAL( executed( TQListBoxItem* ) ), + this, TQT_SLOT( slotListBoxExec( TQListBoxItem* ) ) ); + + //Initialize buttons + cbListView->setChecked( !m_pListView->allColumnsShowFocus() ); + m_pbgMode->setButton( TopLevel::Extended ); + slotSwitchMode( TopLevel::Extended ); + + //Fill container widgets + for( int i = 0; i < 10; i++ ) { + new TQIconViewItem( m_pIconView, TQString("Item%1").arg(i), TQPixmap(item_xpm) ); + + TQListViewItem* lv = new TQListViewItem( m_pListView, TQString("Item%1").arg(i), TQString("Text%1").arg(i) ); + lv->setPixmap( 0, TQPixmap(item_xpm)); + lv->setPixmap( 1, TQPixmap(item_xpm)); + + new TQListBoxPixmap( m_pListBox, TQPixmap(item_xpm), TQString("Item%1").arg(i)); + } + + connect( m_pIconView, TQT_SIGNAL( clicked( TQIconViewItem* ) ), + this, TQT_SLOT( slotClicked( TQIconViewItem* ) ) ); + connect( m_pIconView, TQT_SIGNAL( doubleClicked( TQIconViewItem* ) ), + this, TQT_SLOT( slotDoubleClicked( TQIconViewItem* ) ) ); +} + +void TopLevel::slotSwitchMode( int id ) +{ + m_pIconView->clearSelection(); + m_pListView->clearSelection(); + m_pListBox->clearSelection(); + + switch( id ) { + case TopLevel::NoSelection: + m_pIconView->setSelectionMode( KIconView::NoSelection ); + m_pListView->setSelectionMode( TQListView::NoSelection ); + m_pListBox->setSelectionMode( KListBox::NoSelection ); + break; + case TopLevel::Single: + m_pIconView->setSelectionMode( KIconView::Single ); + m_pListView->setSelectionMode( TQListView::Single ); + m_pListBox->setSelectionMode( KListBox::Single ); + break; + case TopLevel::Multi: + m_pIconView->setSelectionMode( KIconView::Multi ); + m_pListView->setSelectionMode( TQListView::Multi ); + m_pListBox->setSelectionMode( KListBox::Multi ); + break; + case TopLevel::Extended: + m_pIconView->setSelectionMode( KIconView::Extended ); + m_pListView->setSelectionMode( TQListView::Extended ); + m_pListBox->setSelectionMode( KListBox::Extended ); + break; + default: + Q_ASSERT(0); + } +} + +void TopLevel::slotIconViewExec( TQIconViewItem* item ) +{ + m_plblWidget->setText("KIconView"); + m_plblSignal->setText("executed"); + if( item ) + m_plblItem->setText( item->text() ); + else + m_plblItem->setText("Viewport"); +} + +void TopLevel::slotListViewExec( TQListViewItem* item ) +{ + m_plblWidget->setText("KListView"); + m_plblSignal->setText("executed"); + if( item ) + m_plblItem->setText( item->text(0) ); + else + m_plblItem->setText("Viewport"); +} + +void TopLevel::slotListBoxExec( TQListBoxItem* item ) +{ + m_plblWidget->setText("KListBox"); + m_plblSignal->setText("executed"); + if( item ) + m_plblItem->setText( item->text() ); + else + m_plblItem->setText("Viewport"); +} + +void TopLevel::slotToggleSingleColumn( bool b ) +{ + m_pListView->setAllColumnsShowFocus( !b ); +} + +int main( int argc, char ** argv ) +{ + app = new KApplication ( argc, argv, "ItemContainerTest" ); + + TopLevel *toplevel = new TopLevel(0, "itemcontainertest"); + + toplevel->show(); + toplevel->resize( 600, 300 ); + app->setMainWidget(toplevel); + app->exec(); +} + +#include "itemcontainertest.moc" diff --git a/tdeui/tests/itemcontainertest.h b/tdeui/tests/itemcontainertest.h new file mode 100644 index 000000000..4334bd805 --- /dev/null +++ b/tdeui/tests/itemcontainertest.h @@ -0,0 +1,45 @@ +#ifndef _ITEMCONTAINERTEST_H +#define _ITEMCONTAINERTEST_H + +#include + +class KIconView; +class KListView; +class KListBox; +class TQButtonGroup; +class TQLabel; + +class TopLevel : public TQWidget +{ + Q_OBJECT +public: + + TopLevel( TQWidget *parent=0, const char *name=0 ); + + enum ViewID { IconView, ListView, ListBox }; + enum ModeID { NoSelection, Single, Multi, Extended }; + +public slots: + //void slotSwitchView( int id ); + void slotSwitchMode( int id ); + + void slotIconViewExec( TQIconViewItem* item ); + void slotListViewExec( TQListViewItem* item ); + void slotListBoxExec( TQListBoxItem* item ); + void slotToggleSingleColumn( bool b ); + + void slotClicked( TQIconViewItem* ) { qDebug("CLICK");} + void slotDoubleClicked( TQIconViewItem* ) { qDebug("DOUBLE CLICK");} +protected: + KIconView* m_pIconView; + KListView* m_pListView; + KListBox* m_pListBox; + + TQButtonGroup* m_pbgView; + TQButtonGroup* m_pbgMode; + TQLabel* m_plblWidget; + TQLabel* m_plblSignal; + TQLabel* m_plblItem; +}; + +#endif diff --git a/tdeui/tests/kaboutdialogtest.cpp b/tdeui/tests/kaboutdialogtest.cpp new file mode 100644 index 000000000..ea92096b0 --- /dev/null +++ b/tdeui/tests/kaboutdialogtest.cpp @@ -0,0 +1,72 @@ +/* -*- C++ -*- + * This file shows an example for the KDE about dialog. + * + * copyright: (C) Mirko Boehm, 1999 + * license: GNU Public License, Version 2 + * mail to: Mirko Boehm + * requires: recent C++-compiler, at least Qt 1.4 + * $Revision$ + */ + +#include "kaboutdialog.h" +// #include +#include +#include +#include + +int main(int argc, char** argv) +{ + (void)new KApplication(argc, argv, "KAboutDialogTest"); + TQImage logo; + TQImage bg; + TQPixmap pix; + KAboutDialog about; + // ----- + // kimgioRegister(); + if(logo.load("RayTracedGear.png")) + { + pix=logo; + about.setLogo(pix); + } else { + qDebug("main: No logo loaded."); + } + if(bg.load("background_1.png")) + { + pix=bg; + about.setBackgroundTile(&pix); + about.showTile( true ); + about.enableLinkedHelp( true ); + + //about.showBaseFrameTile(true); + } else { + qDebug("main: No tile loaded."); + } +// about.setButtonOKText +// ("Cl&ose", "Close this dialog.", +// "Close the dialog
" +// "(there are no settings to save)."); + about.setCaption("KAboutDialog example"); + about.setVersion("KAboutDialog, Draft Study"); + about.setHelp("kdehelp/intro.html", "intro"); + // ----- set the application author: + about.setAuthor + ("Mirko Boehm", "mirko@kde.org", "", "Initial developer."); + // ----- set the application maintainer: + about.setMaintainer("Any One", // name + "anyone@kde.org", // email address + "http://www.anyhere.com", // URL + "Current maintainer."); // description + // ----- add some contributors: + about.addContributor("Some One", "someone@kde.org", "http://www.somehere.com", + "Making coffee"); + about.addContributor("Another One", + "anotherone@kde.org", + "http://www.blablax.com", + "Pizza donator"); + // ----- contents of the dialog have changed, adapt sizes: + about.adjust(); + about.exec(); + // ----- + return 0; +} + diff --git a/tdeui/tests/kaccelgentest.cpp b/tdeui/tests/kaccelgentest.cpp new file mode 100644 index 000000000..f5f95ac57 --- /dev/null +++ b/tdeui/tests/kaccelgentest.cpp @@ -0,0 +1,51 @@ +#include "kaccelgen.h" + +#include + +#include + +using std::cout; +using std::endl; + +void check( const TQString &what, const TQStringList &expected, const TQStringList &received ) +{ + cout << "Testing " << what.latin1() << ": "; + if ( expected == received ) { + cout << "ok" << endl; + } else { + cout << "ERROR!" << endl; + cout << "Expected: " << expected.join( "," ).latin1() << endl; + cout << "Received: " << received.join( "," ).latin1() << endl; + } +} + +int main() +{ + TQStringList input; + input << "foo" << "bar item" << "&baz" << "bif" << "boz" << "boz 2" + << "yoyo && dyne"; + + TQStringList expected; + expected << "&foo" << "bar &item" << "&baz" << "bif" << "b&oz" << "boz &2" + << "&yoyo && dyne"; + + TQStringList output; + KAccelGen::generate( input, output ); + check( "TQStringList value generation", expected, output ); + + TQMap map; + for (TQStringList::ConstIterator it = input.begin(); it != input.end(); ++it) { + map.insert(*it, *it); + } + input.sort(); + expected.clear(); + KAccelGen::generate( input, expected ); + + output.clear(); + KAccelGen::generateFromValues( map, output ); + check( "map value generation", expected, output ); + + output.clear(); + KAccelGen::generateFromKeys( map, output ); + check( "map key generation", expected, output ); +} diff --git a/tdeui/tests/kactiontest.cpp b/tdeui/tests/kactiontest.cpp new file mode 100644 index 000000000..ea97883c8 --- /dev/null +++ b/tdeui/tests/kactiontest.cpp @@ -0,0 +1,38 @@ + +#include + +#include +#include + +#include + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "kactiontest" ); + + KActionCollection coll( static_cast( 0 ) ); + + TQGuardedPtr action1 = new KRadioAction("test",0, &coll); + TQGuardedPtr action2 = new KRadioAction("test",0, &coll); + TQGuardedPtr action3 = new KRadioAction("test",0, &coll); + TQGuardedPtr action4 = new KRadioAction("test",0, &coll); + TQGuardedPtr action5 = new KRadioAction("test",0, &coll); + TQGuardedPtr action6 = new KRadioAction("test",0, &coll); + TQGuardedPtr action7 = new KRadioAction("test",0, &coll); + + coll.clear(); + assert( coll.isEmpty() ); + + assert( action1.isNull() ); + assert( action2.isNull() ); + assert( action3.isNull() ); + assert( action4.isNull() ); + assert( action5.isNull() ); + assert( action6.isNull() ); + assert( action7.isNull() ); + + return 0; +} + +/* vim: et sw=4 ts=4 + */ diff --git a/tdeui/tests/kalphaicontest.h b/tdeui/tests/kalphaicontest.h new file mode 100644 index 000000000..201f96cd6 --- /dev/null +++ b/tdeui/tests/kalphaicontest.h @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include + +class KAlphaTest : public TQWidget +{ + public: + KAlphaTest(); + protected: + void paintEvent(TQPaintEvent *); + private: + TQImage m_image; + TQPixmap m_pixmap; + TQImage m_bg; + + public: + static bool m_useDblBuffer; + static bool m_usePixmap; + static bool m_correctOverlapping; +}; + diff --git a/tdeui/tests/kblendtest.cpp b/tdeui/tests/kblendtest.cpp new file mode 100644 index 000000000..59a57dc6a --- /dev/null +++ b/tdeui/tests/kblendtest.cpp @@ -0,0 +1,98 @@ +#include "kblendtest.h" +#include +#include +#include +#include +#include + +int cols = 3, rows = 3; // how many + +KBlendWidget::KBlendWidget(TQWidget *parent, const char *name) + :TQWidget(parent, name) +{ + + bgnd = tqRgb(255, 255, 255); + + image = TQImage("testimage.png"); + + resize(image.width()*2+60, image.height()*3+80); + setBackgroundColor(bgnd); +} + +void KBlendWidget::paintEvent(TQPaintEvent */*ev*/) +{ + TQTime time; + int it, ft; + TQString say; + + image = TQImage("testimage.png"); + + TQPainter p(this); + p.setPen(Qt::black); + + // you see here use of anti_dir param (blend from down to up, here) + time.start(); + it = time.elapsed(); + KImageEffect::blend(image, 0.2, bgnd, KImageEffect::VerticalGradient,true); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Vertical"; + p.drawImage(20, 20, image); + p.drawText(5 , 15, say); + + image = TQImage("testimage.png"); + + // here a negative initial intensity is used (1/2 of image is unaffected) + it = time.elapsed(); + KImageEffect::blend(image, -0.5, bgnd, KImageEffect::HorizontalGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Horizontal"; + p.drawImage(40+image.width(), 20, image); + p.drawText(15+image.width() , 15, say); + + image = TQImage("testimage.png"); + + it = time.elapsed(); + KImageEffect::blend(image, 0., bgnd, KImageEffect::DiagonalGradient,true); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Diagonal"; + p.drawImage(20, 40+image.height(), image); + p.drawText(5 , 35+image.height(), say); + + image = TQImage("testimage.png"); + + it = time.elapsed(); + KImageEffect::blend(image, 0.1, bgnd, KImageEffect::CrossDiagonalGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, CrossDiagonal"; + p.drawImage(40+image.width(), 40+image.height(), image); + p.drawText(25+image.width() , 35 + image.height(), say); + + image = TQImage("testimage.png"); + + it = time.elapsed(); + KImageEffect::blend(image, -0.6, bgnd, KImageEffect::RectangleGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Rectangle"; + p.drawImage(20, 60+2*image.height(), image); + p.drawText(5 , 55+2*image.height(), say); + + image = TQImage("testimage.png"); + + it = time.elapsed(); + KImageEffect::blend(image, 0.2, bgnd, KImageEffect::EllipticGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Elliptic"; + p.drawImage(40+image.width(), 60+2*image.height(), image); + p.drawText(25+image.width(), 55+2*image.height(), say); + p.end(); +} + +int main(int argc, char **argv) +{ + KApplication app(argc, argv, "KBlendTest"); + KBlendWidget w; + app.setMainWidget(&w); + w.show(); + return(app.exec()); +} + diff --git a/tdeui/tests/kblendtest.h b/tdeui/tests/kblendtest.h new file mode 100644 index 000000000..f35afbb5f --- /dev/null +++ b/tdeui/tests/kblendtest.h @@ -0,0 +1,24 @@ +// +// Simple little hack to show off blending effects. +// +// (C) KDE Artistic Cristian Tibirna +// + +#ifndef __KBLEND_TEST_H +#define __KBLEND_TEST_H + +#include +#include + +class KBlendWidget : public TQWidget +{ +public: + KBlendWidget(TQWidget *parent=0, const char *name=0); +protected: + void paintEvent(TQPaintEvent *ev); +private: + TQImage image, original; + TQColor bgnd; +}; + +#endif diff --git a/tdeui/tests/kbuttonboxtest.cpp b/tdeui/tests/kbuttonboxtest.cpp new file mode 100644 index 000000000..86850f0ce --- /dev/null +++ b/tdeui/tests/kbuttonboxtest.cpp @@ -0,0 +1,205 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Mario Weilguni (mweilguni@sime.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 +#include "kbuttonbox.h" +#include +#include +#include +#include + +int main(int argc, char **argv) { + KApplication a(argc, argv, "dummy"); + + // example 1 + { + TQDialog *w = new TQDialog(0, "A common dialog", true); + w->setCaption("Example 1"); + TQVBoxLayout *tl = new TQVBoxLayout(w, 5); + TQLabel *l = new TQLabel("A very common dialog\n\n"\ + "OK and Cancel are left aligned, Help\n"\ + "is right aligned. Try resizing\n"\ + "the window!\n" + "Press OK or Cancel when done" + , w); + l->tqsetAlignment(Qt::AlignVCenter|Qt::AlignLeft|Qt::WordBreak); + l->setMinimumSize(l->tqsizeHint()); + tl->addWidget(l,1); + KButtonBox *bbox = new KButtonBox(w); + TQPushButton *b = bbox->addButton("OK"); + b->setDefault(true); + w->connect(b, TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + w->connect(bbox->addButton("Cancel"), TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + + bbox->addStretch(1); + bbox->addButton("Help"); + bbox->layout(); + tl->addWidget(bbox,0); + tl->activate(); + w->exec(); + delete w; + } + + // example 2 + { + TQDialog *w = new TQDialog(0, "Right aligned buttons", true); + w->setCaption("Example 2"); + TQVBoxLayout *tl = new TQVBoxLayout(w, 5); + TQLabel *l = new TQLabel("Another common dialog\n\n"\ + "OK and Cancel are right aligned\n"\ + "Try resizing the window!", w); + l->tqsetAlignment(Qt::AlignVCenter|Qt::AlignLeft|Qt::WordBreak); + l->setMinimumSize(l->tqsizeHint()); + tl->addWidget(l,1); + KButtonBox *bbox = new KButtonBox(w); + bbox->addStretch(1); + TQPushButton *b = bbox->addButton("OK"); + b->setDefault(true); + w->connect(b, TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + w->connect(bbox->addButton("Cancel"), TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + bbox->layout(); + tl->addWidget(bbox,0); + tl->activate(); + w->exec(); + delete w; + } + + // example 3 + { + TQDialog *w = new TQDialog(0, "Middle aligned buttons", true); + w->setCaption("Example 3"); + TQVBoxLayout *tl = new TQVBoxLayout(w, 5); + TQLabel *l = new TQLabel("Another common dialog\n\n"\ + "OK and Cancel are middle aligned\n"\ + "Try resizing the window!", w); + l->tqsetAlignment(Qt::AlignVCenter|Qt::AlignLeft|Qt::WordBreak); + l->setMinimumSize(l->tqsizeHint()); + tl->addWidget(l,1); + KButtonBox *bbox = new KButtonBox(w); + bbox->addStretch(1); + TQPushButton *b = bbox->addButton("OK"); + b->setDefault(true); + w->connect(b, TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + w->connect(bbox->addButton("Cancel"), TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + bbox->addStretch(1); + bbox->layout(); + tl->addWidget(bbox,0); + tl->activate(); + w->exec(); + delete w; + } + + // example 4 + { + TQDialog *w = new TQDialog(0, "Bad example", true); + w->setCaption("Example 4"); + TQVBoxLayout *tl = new TQVBoxLayout(w, 5); + TQLabel *l = new TQLabel("A very bad example\n\n"\ + "Sometimes it's a bad idea to take\n" + "the maximum width for all buttons\n" + "since it will look ugly -- " + "anyway, it works", w); + l->tqsetAlignment(Qt::AlignVCenter|Qt::AlignLeft|Qt::WordBreak); + l->setMinimumSize(l->tqsizeHint()); + tl->addWidget(l,1); + KButtonBox *bbox = new KButtonBox(w); + bbox->addStretch(1); + TQPushButton *b = bbox->addButton("OK"); + b->setDefault(true); + w->connect(b, TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + w->connect(bbox->addButton("Cancel"), TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + + bbox->addButton("Push me and I give you a banana"); + bbox->addStretch(1); + bbox->layout(); + tl->addWidget(bbox,0); + tl->activate(); + w->exec(); + delete w; + } + + // example 5 + { + TQDialog *w = new TQDialog(0, "Bad example", true); + w->setCaption("Example 5"); + TQVBoxLayout *tl = new TQVBoxLayout(w, 5); + TQLabel *l = new TQLabel("A better solution for the bad example\n\n"\ + "Use \"addButton(\"Push me and I give" + "you a banana\", true);\" to\n" + "prevent this strange effect as seen\n" + "the former example!" + ,w); + l->tqsetAlignment(Qt::AlignVCenter|Qt::AlignLeft|Qt::WordBreak); + l->setMinimumSize(l->tqsizeHint()); + tl->addWidget(l,1); + KButtonBox *bbox = new KButtonBox(w); + bbox->addStretch(1); + TQPushButton *b = bbox->addButton("OK"); + b->setDefault(true); + w->connect(b, TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + w->connect(bbox->addButton("Cancel"), TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + + bbox->addButton("Push me and I give you a banana", true); + bbox->addStretch(1); + bbox->layout(); + tl->addWidget(bbox,0); + tl->activate(); + w->exec(); + delete w; + } + + // example 6 + { + TQDialog *w = new TQDialog(0, "Vertical", true); + w->setCaption("Example 6 (last)"); + TQHBoxLayout *tl = new TQHBoxLayout(w, 5); + TQLabel *l = new TQLabel("Did I mention that it's possible\n" + "to make vertically aligned buttons\n" + "too?" + ,w); + l->tqsetAlignment(Qt::AlignVCenter|Qt::AlignLeft|Qt::WordBreak); + l->setMinimumSize(l->tqsizeHint()); + tl->addWidget(l,1); + KButtonBox *bbox = new KButtonBox(w, KButtonBox::Vertical); + TQPushButton *b = bbox->addButton("OK"); + b->setDefault(true); + w->connect(b, TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + w->connect(bbox->addButton("Cancel"), TQT_SIGNAL(clicked()), + w, TQT_SLOT(accept())); + + bbox->addStretch(1); + bbox->layout(); + tl->addWidget(bbox,0); + tl->activate(); + w->exec(); + delete w; + } + + return 0; +} diff --git a/tdeui/tests/kcharselecttest.cpp b/tdeui/tests/kcharselecttest.cpp new file mode 100644 index 000000000..5880c436a --- /dev/null +++ b/tdeui/tests/kcharselecttest.cpp @@ -0,0 +1,16 @@ +#include +#include +#include "kcharselect.h" + +int main (int argc,char **argv) +{ + KApplication app( argc, argv, "kcharselecttest" ); + + KCharSelect selector( 0, "char selector" ); + selector.resize( selector.tqsizeHint() ); + selector.show(); + selector.setCaption( "KCharSelect Test" ); + + app.setMainWidget( &selector ); + return app.exec(); +} diff --git a/tdeui/tests/kcolordlgtest.cpp b/tdeui/tests/kcolordlgtest.cpp new file mode 100644 index 000000000..a7e64928d --- /dev/null +++ b/tdeui/tests/kcolordlgtest.cpp @@ -0,0 +1,41 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Martin Jones (mjones@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 +#include "kcolordialog.h" +#include +#include + +int main( int argc, char *argv[] ) +{ + TQColor color; + + KLocale::setMainCatalogue("kdelibs"); + TQApplication::setColorMode( TQApplication::CustomColors ); + KApplication a( argc, argv, "KColorDialogTest" ); + KConfig aConfig; + aConfig.setGroup( "KColorDialog-test" ); + + color = aConfig.readColorEntry( "Chosen" ); + int nRet = KColorDialog::getColor( color, Qt::red /*testing default color*/ ); + aConfig.writeEntry( "Chosen", color ); + + return nRet; +} + diff --git a/tdeui/tests/kcolortest.cpp b/tdeui/tests/kcolortest.cpp new file mode 100644 index 000000000..46f5b42bc --- /dev/null +++ b/tdeui/tests/kcolortest.cpp @@ -0,0 +1,169 @@ + +#include "kcolortest.h" +#include +#include +#include +#include + +bool fullscreen = false, oldway = false, intvsfade = false; +int max = 20; // how many steps + +KColorWidget::KColorWidget(TQWidget *parent, const char *name) + : TQWidget(parent, name) +{ + + if (fullscreen || intvsfade) { + TQPixmap shot = TQPixmap::grabWindow(TQApplication::desktop()->winId()); + original = shot.convertToImage(); + } + else + original = TQImage("testimage.png"); + resize(original.width(), original.height()); +} + +void KColorWidget::paintEvent(TQPaintEvent *) +{ + if(!pixmap.isNull()) + bitBlt(this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height(), + Qt::CopyROP, true); +} + +void KColorWidget::doIntensityLoop() +{ + int count; + + int start, stop; + TQTime t; + + t.start(); + + image = original; image.detach(); + + if (fullscreen){ + start = t.elapsed(); + for(count=0; count < max; ++count){ + if (!oldway) + KImageEffect::intensity(image, -1./max); + else { + uint *qptr=(uint *)image.bits(); + QRgb qrgb; + int size=pixmap.width()*pixmap.height(); + for (int i=0;i 1) { + if (!strcmp(argv[1], "fullscreen")) + { + fullscreen = true; + if (!strcmp(argv[2], "old_way")) + oldway = true; + } + else if (!strcmp(argv[1], "int_vs_fade")) { + intvsfade = fullscreen = true; + oldway = false; + } + else + printf("Usage: %s [int_vs_fade | fullscreen [old_way]]\n ", argv[0]); + } + KApplication *app = new KApplication(argc, argv, "KColorTest"); + KColorWidget w; + app->setMainWidget(&w); + w.show(); + w.doIntensityLoop(); + return(app->exec()); +} diff --git a/tdeui/tests/kcolortest.h b/tdeui/tests/kcolortest.h new file mode 100644 index 000000000..529a1ad74 --- /dev/null +++ b/tdeui/tests/kcolortest.h @@ -0,0 +1,21 @@ +#ifndef __KCOLORTEST_H +#define __KCOLORTEST_H + +#include +#include +#include + +class KColorWidget : public TQWidget +{ +public: + KColorWidget(TQWidget *parent=0, const char *name=0); + void doIntensityLoop(); +protected: + void paintEvent(TQPaintEvent *ev); +private: + TQImage image, original; + KPixmap pixmap; + +}; + +#endif diff --git a/tdeui/tests/kcomboboxtest.cpp b/tdeui/tests/kcomboboxtest.cpp new file mode 100644 index 000000000..e8fd35f7e --- /dev/null +++ b/tdeui/tests/kcomboboxtest.cpp @@ -0,0 +1,227 @@ +#define protected public // for delegate() +#include +#undef protected + +#include "kcomboboxtest.h" + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +KComboBoxTest::KComboBoxTest(TQWidget* widget, const char* name ) + :TQWidget(widget, name) +{ + TQVBoxLayout *vbox = new TQVBoxLayout (this, KDialog::marginHint(), KDialog::spacingHint()); + + // Test for KCombo's KLineEdit destruction + KComboBox *testCombo = new KComboBox( true, this ); // rw, with KLineEdit + testCombo->setEditable( false ); // destroys our KLineEdit + assert( testCombo->delegate() == 0L ); + delete testCombo; // not needed anymore + + // Qt combobox + TQHBox* hbox = new TQHBox(this); + hbox->setSpacing (KDialog::spacingHint()); + TQLabel* lbl = new TQLabel("&QCombobox:", hbox); + lbl->tqsetSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred); + + m_qc = new TQComboBox(hbox, "QtReadOnlyCombo" ); + lbl->setBuddy (m_qc); + TQObject::connect (m_qc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int))); + TQObject::connect (m_qc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&))); + vbox->addWidget (hbox); + + // Read-only combobox + hbox = new TQHBox(this); + hbox->setSpacing (KDialog::spacingHint()); + lbl = new TQLabel("&Read-Only Combo:", hbox); + lbl->tqsetSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred); + + m_ro = new KComboBox(hbox, "ReadOnlyCombo" ); + lbl->setBuddy (m_ro); + m_ro->setCompletionMode( KGlobalSettings::CompletionAuto ); + TQObject::connect (m_ro, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int))); + TQObject::connect (m_ro, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&))); + vbox->addWidget (hbox); + + // Read-write combobox + hbox = new TQHBox(this); + hbox->setSpacing (KDialog::spacingHint()); + lbl = new TQLabel("&Editable Combo:", hbox); + lbl->tqsetSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred); + + m_rw = new KComboBox( true, hbox, "ReadWriteCombo" ); + lbl->setBuddy (m_rw); + m_rw->setDuplicatesEnabled( true ); + m_rw->setInsertionPolicy( TQComboBox::NoInsertion ); + m_rw->setTrapReturnKey( true ); + TQObject::connect (m_rw, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int))); + TQObject::connect (m_rw, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(slotActivated(const TQString&))); + TQObject::connect (m_rw, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed())); + TQObject::connect (m_rw, TQT_SIGNAL(returnPressed(const TQString&)), TQT_SLOT(slotReturnPressed(const TQString&))); + vbox->addWidget (hbox); + + // History combobox... + hbox = new TQHBox(this); + hbox->setSpacing (KDialog::spacingHint()); + lbl = new TQLabel("&History Combo:", hbox); + lbl->tqsetSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred); + + m_hc = new KHistoryCombo( true, hbox, "HistoryCombo" ); + lbl->setBuddy (m_hc); + m_hc->setDuplicatesEnabled( true ); + m_hc->setInsertionPolicy( TQComboBox::NoInsertion ); + TQObject::connect (m_hc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int))); + TQObject::connect (m_hc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(slotActivated(const TQString&))); + TQObject::connect (m_hc, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed())); + vbox->addWidget (hbox); + m_hc->setTrapReturnKey(true); + + // Read-write combobox that is a replica of code in konqueror... + hbox = new TQHBox(this); + hbox->setSpacing (KDialog::spacingHint()); + lbl = new TQLabel( "&Konq's Combo:", hbox); + lbl->tqsetSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred); + + m_konqc = new KComboBox( true, hbox, "KonqyCombo" ); + lbl->setBuddy (m_konqc); + m_konqc->setMaxCount( 10 ); + TQObject::connect (m_konqc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int))); + TQObject::connect (m_konqc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&))); + TQObject::connect (m_konqc, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed())); + vbox->addWidget (hbox); + + // Create an exit button + hbox = new TQHBox (this); + m_btnExit = new TQPushButton( "E&xit", hbox ); + TQObject::connect( m_btnExit, TQT_SIGNAL(clicked()), TQT_SLOT(quitApp()) ); + + // Create a disable button... + m_btnEnable = new TQPushButton( "Disa&ble", hbox ); + TQObject::connect (m_btnEnable, TQT_SIGNAL(clicked()), TQT_SLOT(slotDisable())); + + vbox->addWidget (hbox); + + // Popuplate the select-only list box + TQStringList list; + list << "Stone" << "Tree" << "Peables" << "Ocean" << "Sand" << "Chips" + << "Computer" << "Mankind"; + list.sort(); + + // Setup the qcombobox + m_qc->insertStringList (list); + + // Setup read-only combo + m_ro->insertStringList( list ); + m_ro->completionObject()->setItems( list ); + + // Setup read-write combo + m_rw->insertStringList( list ); + m_rw->completionObject()->setItems( list ); + + // Setup read-write combo + m_hc->insertStringList( list ); + m_hc->completionObject()->setItems( list ); + + // Setup konq's combobox + KSimpleConfig historyConfig( "konq_history" ); + historyConfig.setGroup( "Location Bar" ); + KCompletion * s_pCompletion = new KCompletion; + s_pCompletion->setOrder( KCompletion::Weighted ); + s_pCompletion->setItems( historyConfig.readListEntry( "ComboContents" ) ); + s_pCompletion->setCompletionMode( KGlobalSettings::completionMode() ); + m_konqc->setCompletionObject( s_pCompletion ); + + TQPixmap pix = SmallIcon("www"); + m_konqc->insertItem( pix, "http://www.kde.org" ); + m_konqc->setCurrentItem( m_konqc->count()-1 ); + + m_timer = new TQTimer (this); + connect (m_timer, TQT_SIGNAL (timeout()), TQT_SLOT (slotTimeout())); +} + +KComboBoxTest::~KComboBoxTest() +{ + if (m_timer) + { + delete m_timer; + m_timer = 0; + } +} + +void KComboBoxTest::slotDisable () +{ + if (m_timer->isActive()) + return; + + m_btnEnable->setEnabled (!m_btnEnable->isEnabled()); + + m_timer->start (5000, true); +} + +void KComboBoxTest::slotTimeout () +{ + bool enabled = m_ro->isEnabled(); + + if (enabled) + m_btnEnable->setText ("Ena&ble"); + else + m_btnEnable->setText ("Disa&ble"); + + m_qc->setEnabled (!enabled); + m_ro->setEnabled (!enabled); + m_rw->setEnabled (!enabled); + m_hc->setEnabled (!enabled); + m_konqc->setEnabled (!enabled); + + m_btnEnable->setEnabled (!m_btnEnable->isEnabled()); +} + +void KComboBoxTest::slotActivated( int index ) +{ + kdDebug() << "Activated Combo: " << sender()->name() << ", index:" << index << endl; +} + +void KComboBoxTest::slotActivated (const TQString& item) +{ + kdDebug() << "Activated Combo: " << sender()->name() << ", item: " << item << endl; +} + +void KComboBoxTest::slotReturnPressed () +{ + kdDebug() << "Return Pressed: " << sender()->name() << endl; +} + +void KComboBoxTest::slotReturnPressed(const TQString& item) +{ + kdDebug() << "Return Pressed, value = " << item << endl; +} + +void KComboBoxTest::quitApp() +{ + kapp->closeAllWindows(); +} + +int main ( int argc, char **argv) +{ + KApplication a(argc, argv, "kcomboboxtest"); + KComboBoxTest* t= new KComboBoxTest; + a.setMainWidget (t); + t->show (); + return a.exec(); +} + +#include "kcomboboxtest.moc" diff --git a/tdeui/tests/kcomboboxtest.h b/tdeui/tests/kcomboboxtest.h new file mode 100644 index 000000000..6566c9097 --- /dev/null +++ b/tdeui/tests/kcomboboxtest.h @@ -0,0 +1,44 @@ +#ifndef _KCOMBOBOXTEST_H +#define _KCOMBOBOXTEST_H + +#include + +class TQTimer; +class TQComboBox; +class TQPushButton; + +class KComboBox; + +class KComboBoxTest : public TQWidget +{ + Q_OBJECT + +public: + KComboBoxTest ( TQWidget *parent=0, const char *name=0 ); + ~KComboBoxTest(); + +private slots: + void quitApp(); + void slotTimeout(); + void slotDisable(); + void slotReturnPressed(); + void slotReturnPressed(const TQString&); + void slotActivated( int ); + void slotActivated( const TQString& ); + +protected: + TQComboBox* m_qc; + + KComboBox* m_ro; + KComboBox* m_rw; + KComboBox* m_hc; + KComboBox* m_konqc; + + + TQPushButton* m_btnExit; + TQPushButton* m_btnEnable; + + TQTimer* m_timer; +}; + +#endif diff --git a/tdeui/tests/kcompletiontest.cpp b/tdeui/tests/kcompletiontest.cpp new file mode 100644 index 000000000..fd44307d3 --- /dev/null +++ b/tdeui/tests/kcompletiontest.cpp @@ -0,0 +1,198 @@ +#include +/**************************************************************************** +** Form implementation generated from reading ui file './kcompletiontest.ui' +** +** Created: Wed Nov 15 20:15:10 2000 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "kcompletiontest.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +/* + * Constructs a Form1 which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +Form1::Form1( TQWidget* parent, const char* name ) + : TQWidget( parent, name, WDestructiveClose ) +{ + if ( !name ) + setName( "Form1" ); + resize( 559, 465 ); + setCaption( "Form1" ); + Form1Layout = new TQVBoxLayout( this ); + Form1Layout->setSpacing( 6 ); + Form1Layout->setMargin( 11 ); + + GroupBox1 = new TQGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( "Completion Test" ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 0 ); + GroupBox1->layout()->setMargin( 0 ); + GroupBox1Layout = new TQVBoxLayout( GroupBox1->layout() ); + GroupBox1Layout->tqsetAlignment( Qt::AlignTop ); + GroupBox1Layout->setSpacing( 6 ); + GroupBox1Layout->setMargin( 11 ); + + Layout9 = new TQVBoxLayout; + Layout9->setSpacing( 6 ); + Layout9->setMargin( 0 ); + + Layout1 = new TQHBoxLayout; + Layout1->setSpacing( 6 ); + Layout1->setMargin( 0 ); + + TextLabel1 = new TQLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setText( "Completion" ); + Layout1->addWidget( TextLabel1 ); + + edit = new KLineEdit( GroupBox1, "edit" ); + Layout1->addWidget( edit ); + Layout9->addLayout( Layout1 ); + edit->completionObject()->setItems( defaultItems() ); + edit->completionObject()->setIgnoreCase( true ); + edit->setFocus(); + TQToolTip::add( edit, "right-click to change completion mode" ); + + Layout2 = new TQHBoxLayout; + Layout2->setSpacing( 6 ); + Layout2->setMargin( 0 ); + + combo = new KHistoryCombo( GroupBox1, "history combo" ); + combo->setCompletionObject( edit->completionObject() ); + // combo->setMaxCount( 5 ); + combo->setHistoryItems( defaultItems(), true ); + connect( combo, TQT_SIGNAL( activated( const TQString& )), + combo, TQT_SLOT( addToHistory( const TQString& ))); + TQToolTip::add( combo, "KHistoryCombo" ); + Layout2->addWidget( combo ); + + LineEdit1 = new KLineEdit( GroupBox1, "LineEdit1" ); + Layout2->addWidget( LineEdit1 ); + + PushButton1 = new TQPushButton( GroupBox1, "PushButton1" ); + PushButton1->setText( "Add" ); + connect( PushButton1, TQT_SIGNAL( clicked() ), TQT_SLOT( slotAdd() )); + Layout2->addWidget( PushButton1 ); + Layout9->addLayout( Layout2 ); + + Layout3 = new TQHBoxLayout; + Layout3->setSpacing( 6 ); + Layout3->setMargin( 0 ); + TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum ); + Layout3->addItem( spacer ); + + PushButton1_4 = new TQPushButton( GroupBox1, "PushButton1_4" ); + PushButton1_4->setText( "Remove" ); + connect( PushButton1_4, TQT_SIGNAL( clicked() ), TQT_SLOT( slotRemove() )); + Layout3->addWidget( PushButton1_4 ); + Layout9->addLayout( Layout3 ); + + Layout8 = new TQHBoxLayout; + Layout8->setSpacing( 6 ); + Layout8->setMargin( 0 ); + + ListBox1 = new TQListBox( GroupBox1, "ListBox1" ); + Layout8->addWidget( ListBox1 ); + connect( ListBox1, TQT_SIGNAL( highlighted( const TQString& )), + TQT_SLOT( slotHighlighted( const TQString& ))); + TQToolTip::add( ListBox1, "Contains the contents of the completion object.\n:x is the weighting, i.e. how often an item has been inserted"); + + Layout7 = new TQVBoxLayout; + Layout7->setSpacing( 6 ); + Layout7->setMargin( 0 ); + + PushButton1_3 = new TQPushButton( GroupBox1, "PushButton1_3" ); + PushButton1_3->setText( "Completion items" ); + connect( PushButton1_3, TQT_SIGNAL( clicked() ), TQT_SLOT( slotList() )); + Layout7->addWidget( PushButton1_3 ); + + PushButton1_2 = new TQPushButton( GroupBox1, "PushButton1_2" ); + PushButton1_2->setText( "Clear" ); + connect( PushButton1_2, TQT_SIGNAL( clicked() ), + edit->completionObject(), TQT_SLOT( clear() )); + Layout7->addWidget( PushButton1_2 ); + Layout8->addLayout( Layout7 ); + Layout9->addLayout( Layout8 ); + GroupBox1Layout->addLayout( Layout9 ); + Form1Layout->addWidget( GroupBox1 ); + + slotList(); +} + +/* + * Destroys the object and frees any allocated resources + */ +Form1::~Form1() +{ + // no need to delete child widgets, Qt does it all for us +} + +void Form1::slotAdd() +{ + qDebug("** adding: %s", LineEdit1->text().latin1() ); + edit->completionObject()->addItem( LineEdit1->text() ); + + TQStringList matches = edit->completionObject()->allMatches("S"); + TQStringList::ConstIterator it = matches.begin(); + for ( ; it != matches.end(); ++it ) + qDebug("-- %s", (*it).latin1()); +} + +void Form1::slotRemove() +{ + edit->completionObject()->removeItem( LineEdit1->text() ); +} + +void Form1::slotList() +{ + ListBox1->clear(); + TQStringList items = edit->completionObject()->items(); + ListBox1->insertStringList( items ); +} + +void Form1::slotHighlighted( const TQString& text ) +{ + // remove any "weighting" + int index = text.findRev( ':' ); + if ( index > 0 ) + LineEdit1->setText( text.left( index ) ); + else + LineEdit1->setText( text ); +} + + +TQStringList Form1::defaultItems() const +{ + TQStringList items; + items << "Super" << "Sushi" << "Samson" << "Sucks" << "Sumo" << "Schumi"; + items << "Slashdot" << "sUpEr" << "SUshi" << "sUshi" << "sUShi"; + items << "sushI" << "SushI"; + return items; +} + + +int main(int argc, char **argv ) +{ + KApplication app( argc, argv, "kcompletiontest" ); + + Form1 *form = new Form1(); + form->show(); + + return app.exec(); +} + + +#include "kcompletiontest.moc" diff --git a/tdeui/tests/kcompletiontest.h b/tdeui/tests/kcompletiontest.h new file mode 100644 index 000000000..9443401eb --- /dev/null +++ b/tdeui/tests/kcompletiontest.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** Form interface generated from reading ui file './kcompletiontest.ui' +** +** Created: Wed Nov 15 20:12:56 2000 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef FORM1_H +#define FORM1_H + +#include +#include +#include +class TQVBoxLayout; +class TQHBoxLayout; +class TQGridLayout; +class TQGroupBox; +class TQLabel; +class TQListBox; +class TQListBoxItem; +class TQPushButton; + +class KHistoryCombo; +class KLineEdit; + + +class Form1 : public TQWidget +{ + Q_OBJECT + +public: + Form1( TQWidget* parent = 0, const char* name = 0 ); + ~Form1(); + + TQGroupBox* GroupBox1; + TQLabel* TextLabel1; + KLineEdit* LineEdit1; + TQPushButton* PushButton1; + TQPushButton* PushButton1_4; + TQListBox* ListBox1; + TQPushButton* PushButton1_3; + TQPushButton* PushButton1_2; + + KLineEdit* edit; + KHistoryCombo *combo; + +protected slots: + void slotList(); + void slotAdd(); + void slotRemove(); + void slotHighlighted( const TQString& ); + +protected: + TQStringList defaultItems() const; + + TQVBoxLayout* Form1Layout; + TQVBoxLayout* GroupBox1Layout; + TQVBoxLayout* Layout9; + TQHBoxLayout* Layout1; + TQHBoxLayout* Layout2; + TQHBoxLayout* Layout3; + TQHBoxLayout* Layout8; + TQVBoxLayout* Layout7; +}; + +#endif // FORM1_H diff --git a/tdeui/tests/kdatepicktest.cpp b/tdeui/tests/kdatepicktest.cpp new file mode 100644 index 000000000..c982dbe91 --- /dev/null +++ b/tdeui/tests/kdatepicktest.cpp @@ -0,0 +1,16 @@ +#include "kdatepicker.h" +#include +#include +#include + +int main(int argc, char** argv) +{ + KLocale::setMainCatalogue("kdelibs"); + KApplication app(argc, argv, "KDatePickertest"); + KDatePicker picker; + app.setMainWidget(&picker); + picker.show(); + // picker.setEnabled(false); + return app.exec(); +} + diff --git a/tdeui/tests/kdatetimewidgettest.cpp b/tdeui/tests/kdatetimewidgettest.cpp new file mode 100644 index 000000000..fd3680be0 --- /dev/null +++ b/tdeui/tests/kdatetimewidgettest.cpp @@ -0,0 +1,14 @@ +#include "kdatetimewidget.h" +#include +#include + +int main(int argc, char** argv) +{ + KLocale::setMainCatalogue("kdelibs"); + KApplication app(argc, argv, "KDateTimeWidgettest"); + KDateTimeWidget dateTimeWidget; + app.setMainWidget(&dateTimeWidget); + dateTimeWidget.show(); + // dateTimeWidget.setEnabled(false); + return app.exec(); +} diff --git a/tdeui/tests/kdatewidgettest.cpp b/tdeui/tests/kdatewidgettest.cpp new file mode 100644 index 000000000..8550ab363 --- /dev/null +++ b/tdeui/tests/kdatewidgettest.cpp @@ -0,0 +1,16 @@ +#include "kdatewidget.h" +#include +#include +#include + +int main(int argc, char** argv) +{ + KLocale::setMainCatalogue("kdelibs"); + KApplication app(argc, argv, "KDateWidgettest"); + KDateWidget dateWidget; + app.setMainWidget(&dateWidget); + dateWidget.show(); + // dateWidget.setEnabled(false); + return app.exec(); +} + diff --git a/tdeui/tests/kdesattest.cpp b/tdeui/tests/kdesattest.cpp new file mode 100644 index 000000000..e75b320a7 --- /dev/null +++ b/tdeui/tests/kdesattest.cpp @@ -0,0 +1,65 @@ +#include "kdesattest.h" +#include +#include +#include +#include +#include + +int cols = 3, rows = 3; // how many + +KDesatWidget::KDesatWidget(TQWidget *parent, const char *name) + :TQWidget(parent, name) +{ + + image = TQImage("testimage.png"); + slide = new KDoubleNumInput(700, this, "desat"); + slide->setRange(0, 1, 0.001); + slide->setLabel("Desaturate: ", AlignVCenter | AlignLeft); + connect(slide,TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(change(double))); + + resize(image.width()*2, image.height() + slide->height()); + slide->setGeometry(0, image.height(), image.width()*2, slide->height()); +} + +void KDesatWidget::change(double) { + desat_value = slide->value(); + tqrepaint(false); +} + +void KDesatWidget::paintEvent(TQPaintEvent */*ev*/) +{ + TQTime time; + int it, ft; + TQString say; + + TQPainter p(this); + p.setPen(Qt::black); + + // original image + time.start(); + it = time.elapsed(); + image = TQImage("testimage.png"); + p.drawImage(0, 0, image); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Vertical"; + p.drawText(5 , 15, say); + + // desaturated image + it = time.elapsed(); + image = KImageEffect::desaturate(image, desat_value); + p.drawImage(image.width(), 0, image); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Horizontal"; + p.drawText(15+image.width() , 15, say); +} + +int main(int argc, char **argv) +{ + KApplication *app = new KApplication(argc, argv, "KDesatTest"); + KDesatWidget w; + app->setMainWidget(&w); + w.show(); + return(app->exec()); +} + +#include "kdesattest.moc" diff --git a/tdeui/tests/kdesattest.h b/tdeui/tests/kdesattest.h new file mode 100644 index 000000000..8e04c08c6 --- /dev/null +++ b/tdeui/tests/kdesattest.h @@ -0,0 +1,31 @@ +// +// Simple little hack to show off blending effects. +// +// (C) KDE Artistic Cristian Tibirna +// + +#ifndef __KBLEND_TEST_H +#define __KBLEND_TEST_H + +#include +#include +#include + +class KDesatWidget : public TQWidget +{ +Q_OBJECT +public: + KDesatWidget(TQWidget *parent=0, const char *name=0); + +public slots: + void change(double); + +protected: + void paintEvent(TQPaintEvent *ev); +private: + float desat_value; + TQImage image; + KDoubleNumInput *slide; +}; + +#endif diff --git a/tdeui/tests/kdialogbasetest.cpp b/tdeui/tests/kdialogbasetest.cpp new file mode 100644 index 000000000..ec77e7453 --- /dev/null +++ b/tdeui/tests/kdialogbasetest.cpp @@ -0,0 +1,77 @@ +#include +#include + +#include +#include + +int main(int argc, char** argv) +{ + KApplication app(argc, argv, "DialogBaseTest"); + // ----- + TQString text= // the explanation shown by the example dialog + "

DialogBase Example



" + "This example shows the usage of the DialogBase class. " + "DialogBase is the KDE user interface class used to create " + "dialogs with unique layout without having to define an own dialog " + "style for your application.
" + "It provides three standard buttons (OK, Apply, and " + "Cancel) that are needed in most dialogs. Each one may be " + "hidden, enabled or disabled, and tooltips and quickhelp texts might be" + " added. And you do not need to bother about geometry management, this " + "is all done automatically.
" + "To polish your user interface even further, you might want to add " + "textures to the inner and the outer frame of the dialog (the frame is " + "created by the dialog object). This is done " + "using the setMainFrameTile and the setBaseFrameTile " + "methods. These tiles are added application-wide, so each dialog " + "of you application uses the same tiles. This is a tribute to a " + "comprehensable user interface.
" + "The class supports the creation of dialogs without being forced " + "to derive an own class for it, but you may derive your own class " + "for a better code structure.
" + "If you wrote a help chapter explaining what your dialog does, you " + "should add a link to it to the dialog using setHelp. You do " + "not have to take care about launching the help viewer, just set the " + "help file and topic and of course copy it to your documentation " + "directory during the program installation."; + /* Create the dialog object. DialogBase is derived from TQDialog, but + you do not need to derive it to create a nice-looking dialog. Mostly, + you already have a widget class representing the core of your dialog, + and you only need to add a frame around it and the default buttons. + + If you want to derive it, you still can, moving all code shown here + inside of your new class. */ + KDialogBase dialog; + /* Set a help chapter. If you do not set one, the link is not shown, and the + upper part of the frame shrinks as much as possible. The help window " + "will of course only pop up if you correctly installed kdebase. */ + // I disabled it, as khcclient did not run for me. + // dialog.setHelp("kdehelp/intro.html", "", ""); + /* This TQTextView is intended to be the main widget of our dialog. The + main widget is placed inside the dialogs frame, with the buttons below + it. You do not have to take care about the size handling, but it is a + good idea to set the main wigdets minimum size, since the sizes Qt and + the DialogBase class guess are sometimes ugly. + + It is important that your main widget is created with the dialog object + as its parent! */ + TQTextView view(text, TQString::null, &dialog); + //view.setMinimumSize(400, view.heightForWidth(400)+20); + view.setMinimumSize( 250, 300 ); + dialog.setMainWidget(&view); + /* After finishing the setup of your main widget, the dialog needs to be + adjusted. It is not done automatically, since the layout of the main + widget may change before the dialog is shown. Additionally, setting a + help chapter may cause a need for adjustment since it modifies the height + of the upper frame. */ + dialog.resize(dialog.tqminimumSize()); + /* The dialog object is used just as any other TQDialog: */ + if(dialog.exec()) + { + qDebug("Accepted."); + } else { + qDebug("Rejected."); + } + return 0; +} + diff --git a/tdeui/tests/kdocktest.cpp b/tdeui/tests/kdocktest.cpp new file mode 100644 index 000000000..84895c414 --- /dev/null +++ b/tdeui/tests/kdocktest.cpp @@ -0,0 +1,65 @@ +#include "kdocktest.h" + +#include +#include + +#include +#include + +DockTest::DockTest( TQWidget* parent ) + : KDockArea( parent ) +{ + m_blueDock = createDockWidget( "Blue Widget", SmallIcon("mail") ); + //m_blueDock->setDetachable( false ); + m_blueDock->setEnableDocking( KDockWidget::DockFullSite ); + KDockWidgetHeader *header = new KDockWidgetHeader( m_blueDock, "Blue Header" ); + header->forceCloseButtonHidden(); + m_blueDock->setHeader( header ); + m_blueDock->setCaption( "Blue" ); + m_blueDock->setGeometry( 50, 50, 100, 100 ); + TQWidget *l = new TQWidget( m_blueDock ); + l->setBackgroundColor( Qt::blue ); + l->setMinimumSize( 100,100 ); + m_blueDock->setWidget( l ); + + setMainDockWidget( m_blueDock ); + + m_redDock = createDockWidget( "Red Widget", SmallIcon("news") ); + m_redDock->setEnableDocking( KDockWidget::DockFullSite ); + //m_redDock->setDetachable( false ); + header = new KDockWidgetHeader( m_redDock, "Red kHeader" ); + m_redDock->setHeader( header ); + m_redDock->setCaption( "Red" ); + m_redDock->setGeometry( 50, 50, 100, 100 ); + l = new TQWidget( m_redDock ); + l->setBackgroundColor( Qt::red ); + l->setMinimumSize( 100,100 ); + m_redDock->setWidget( l ); + m_redDock->manualDock( m_blueDock, KDockWidget::DockLeft, 3000 ); + + m_yellowDock = createDockWidget( "Yellow Widget", SmallIcon("web") ); + m_yellowDock->setEnableDocking( KDockWidget::DockFullSite ); + //m_yellowDock->setDetachable( false ); +// header = new KDockWidgetHeader( m_yellowDock, "Yellow Header" ); + // m_yellowDock->setHeader( header ); + m_yellowDock->setCaption( "Yellow" ); + m_yellowDock->setGeometry( 50, 50, 100, 100 ); + l = new TQWidget( m_yellowDock ); + l->setBackgroundColor( Qt::yellow ); + l->setMinimumSize( 100,100 ); + m_yellowDock->setWidget( l ); + m_yellowDock->manualDock( m_blueDock, KDockWidget::DockTop, 5000 ); +} + +int +main( int argc, char** argv ) +{ + KApplication a( argc,argv, "docktest" ); + DockTest* ap = new DockTest(); + ap->setCaption("DockWidget demo"); + a.setMainWidget( ap ); + ap->show(); + return a.exec(); +} + +#include "kdocktest.moc" diff --git a/tdeui/tests/kdocktest.h b/tdeui/tests/kdocktest.h new file mode 100644 index 000000000..f23d22a35 --- /dev/null +++ b/tdeui/tests/kdocktest.h @@ -0,0 +1,19 @@ +#ifndef KDOCKTEST_H +#define KDOCKTEST_H + +#include + +class TQWidget; +class DockTest : public KDockArea +{ + Q_OBJECT +public: + DockTest( TQWidget* parent=0 ); + +private: + KDockWidget* m_blueDock; + KDockWidget* m_redDock; + KDockWidget* m_yellowDock; +}; + +#endif diff --git a/tdeui/tests/kdockwidgetdemo.cpp b/tdeui/tests/kdockwidgetdemo.cpp new file mode 100644 index 000000000..9b65db594 --- /dev/null +++ b/tdeui/tests/kdockwidgetdemo.cpp @@ -0,0 +1,796 @@ +#include "kdockwidgetdemo.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +//#include +#include + +static const char *dir_tree_xpm[] = { +"16 16 8 1", +" c Gray0", +". c #000080", +"X c Cyan", +"o c #808000", +"O c Yellow", +"+ c #808080", +"@ c None", +"# c #c1c1c1", +"@@@@@@@@@@@@@@@@", +"@@@+++++@@@@@@@@", +"@@+@O@O@+@@@@@@@", +"@+@O@O@O@++++++@", +"@+@@@@@@@@@@@@o ", +"@+@O@++ +O@O@Oo ", +"@+@@+@X@ +O@O@o ", +"@+@+@X@X@ +O@Oo ", +"@+@+X@X@X o@O@o ", +"@+@+@X@X@ oO@Oo ", +"@+@@+@X@ +ooO@o ", +"@+@O@+ +@..oOo ", +"@+ooooooo.X..oo ", +"@@ .X.. @", +"@@@@@@@@@@@.X.. ", +"@@@@@@@@@@@@.X. " +}; + +static const char *preview_xpm[] = { +"16 16 6 1", +" c Gray0", +". c #000080", +"X c Yellow", +"o c #808080", +"O c None", +"+ c Gray100", +"OOOOOOOOOOOOOOOO", +"OOo oOOOOOOO", +"Oo oooo OOOOOO", +"O OOOOoo oOOOOO", +"O OOOO++oo OOOOO", +"O OOOO++Oo OOOOO", +"O O+OOOOOo OOOOO", +"O OO+OOOOo OOOOO", +"OooOO+OOo OOOOO", +"OO oOOOo + OOOO", +"OOOo .X+ OOO", +"OOOOOOOOO .X+ OO", +"OOOOOOOOOO .X+ O", +"OOOOOOOOOOO .X O", +"OOOOOOOOOOOO OO", +"OOOOOOOOOOOOOOOO" +}; + +SFileDialog::SFileDialog( TQString initially, const TQStringList& filter, const char* name ) +:TQDialog(0L,name,true) +{ + KConfig* config = kapp->config(); + config->setGroup( TQString::tqfromLatin1("SFileDialogData:") + name ); + if ( initially.isNull() ){ + initially = config->readPathEntry( "InitiallyDir", TQDir::currentDirPath() ); + } + + TQStringList bookmark; + bookmark = config->readListEntry( "Bookmarks" ); + + dockManager = new KDockManager(this); + + d_dirView = new KDockWidget( dockManager, "Dock_DirView", TQPixmap(dir_tree_xpm) ); + d_dirView->setCaption("Tree"); + + dirView = new DirectoryView( d_dirView, 0 ); + dirView->addColumn( "" ); + dirView->header()->hide(); + d_dirView->setWidget( dirView ); + + Directory* root = new Directory( dirView, "/" ); + root->setOpen(true); + + d_preview = new KDockWidget( dockManager, "Dock_Preview", TQPixmap(preview_xpm) ); + d_preview->setCaption("Preview"); + preview = new Preview( d_preview ); + d_preview->setWidget( preview ); + + d_fd = new KDockWidget( dockManager, "Dock_QFileDialog", TQPixmap(), this ); + fd = new CustomFileDialog( d_fd ); + fd->setDir( initially ); + fd->setFilters( filter ); + fd->setBookmark( bookmark ); + fd->reparent(d_fd, TQPoint(0,0)); + d_fd->setWidget( fd ); + + connect( dirView, TQT_SIGNAL( folderSelected( const TQString & ) ), fd, TQT_SLOT( setDir2( const TQString & ) ) ); + connect( fd, TQT_SIGNAL( dirEntered( const TQString & ) ), dirView, TQT_SLOT( setDir( const TQString & ) ) ); + + d_fd->setDockSite( KDockWidget::DockTop|KDockWidget::DockLeft|KDockWidget::DockRight|KDockWidget::DockBottom ); + d_fd->setEnableDocking(KDockWidget::DockNone); + + d_dirView->setEnableDocking(KDockWidget::DockTop|KDockWidget::DockLeft|KDockWidget::DockRight|KDockWidget::DockBottom|KDockWidget::DockCenter); + d_preview->setEnableDocking(KDockWidget::DockTop|KDockWidget::DockLeft|KDockWidget::DockRight|KDockWidget::DockBottom|KDockWidget::DockCenter); + + d_dirView->manualDock( d_fd, KDockWidget::DockLeft, 20 ); + d_preview->manualDock( d_fd, KDockWidget::DockBottom, 70 ); + + connect(fd, TQT_SIGNAL(fileHighlighted(const TQString&)), preview, TQT_SLOT(showPreview(const TQString&))); + connect(fd, TQT_SIGNAL(signalDone(int)), this, TQT_SLOT(done(int))); + + connect(fd, TQT_SIGNAL(dirEntered(const TQString&)), this, TQT_SLOT(changeDir(const TQString&))); + connect(dirView, TQT_SIGNAL(folderSelected(const TQString&)), this, TQT_SLOT(changeDir(const TQString&))); + + b_tree = new TQToolButton( fd ); + TQToolTip::add( b_tree, "Show/Hide Tree" ); + b_tree->setPixmap( TQPixmap( dir_tree_xpm ) ); + connect( b_tree, TQT_SIGNAL(clicked()), d_dirView, TQT_SLOT(changeHideShowState()) ); + b_tree->setToggleButton(true); + b_tree->setOn(true); + fd->addToolButton( b_tree, true ); + + b_preview = new TQToolButton( fd ); + TQToolTip::add( b_preview, "Show/Hide Preview" ); + b_preview->setPixmap( TQPixmap( preview_xpm ) ); + connect( b_preview, TQT_SIGNAL(clicked()), d_preview, TQT_SLOT(changeHideShowState()) ); + b_preview->setToggleButton(true); + b_preview->setOn(true); + fd->addToolButton( b_preview ); + + connect( dockManager, TQT_SIGNAL(change()), this, TQT_SLOT(dockChange())); + connect( dockManager, TQT_SIGNAL(setDockDefaultPos(KDockWidget*)), this, TQT_SLOT(setDockDefaultPos(KDockWidget*))); + setCaption("Open File"); + resize(550,450); + qDebug("read config"); + dockManager->readConfig( 0L , name ); +} + +void SFileDialog::dockChange() +{ + b_preview->setOn( d_preview->isVisibleToTLW() ); + b_tree->setOn( d_dirView->isVisibleToTLW() ); +} + +SFileDialog::~SFileDialog() +{ + KConfig* config = kapp->config(); + config->setGroup( TQString("SFileDialogData:") + name() ); + config->writeEntry( "Bookmarks", fd->getBookmark() ); + + qDebug("write config"); + dockManager->writeConfig( 0L , name() ); +} + +void SFileDialog::setDockDefaultPos( KDockWidget* d ) +{ + if ( d == d_dirView ){ + d_dirView->manualDock( d_fd, KDockWidget::DockLeft, 20 ); + } + + if ( d == d_preview ){ + d_preview->manualDock( d_fd, KDockWidget::DockBottom, 70 ); + } +} + +void SFileDialog::changeDir( const TQString& f ) +{ + if ( !f.isEmpty() ){ + KConfig* config = kapp->config(); + config->setGroup( TQString("SFileDialogData:") + name() ); + config->writePathEntry( "InitiallyDir", f ); + } +} + +TQString SFileDialog::getOpenFileName( TQString initially, + const TQStringList& filter, + const TQString caption, const char* name ) +{ + SFileDialog* fd = new SFileDialog( initially, filter, name ); + if ( !caption.isNull() ) fd->setCaption( caption ); + TQString result = ( fd->exec() == TQDialog::Accepted ) ? fd->fd->selectedFile():TQString::null; + delete fd; + + return result; +} + +TQStringList SFileDialog::getOpenFileNames( TQString initially, + const TQStringList& filter, + const TQString caption, const char* name ) +{ + SFileDialog* fd = new SFileDialog( initially, filter, name ); + if ( !caption.isNull() ) fd->setCaption( caption ); + + fd->fd->setMode( TQFileDialog::ExistingFiles ); + fd->d_preview->undock(); + fd->b_preview->hide(); + + fd->exec(); + TQStringList result = fd->fd->selectedFiles(); + delete fd; + + return result; +} + +void SFileDialog::showEvent( TQShowEvent *e ) +{ + TQDialog::showEvent( e ); + dirView->setDir( fd->dirPath() ); +} + +/******************************************************************************************************/ +PixmapView::PixmapView( TQWidget *parent ) +:TQScrollView( parent ) +{ +// kimgioRegister(); + viewport()->setBackgroundMode( PaletteBase ); +} + +void PixmapView::setPixmap( const TQPixmap &pix ) +{ + pixmap = pix; + resizeContents( pixmap.size().width(), pixmap.size().height() ); + viewport()->tqrepaint( true ); +} + +void PixmapView::drawContents( TQPainter *p, int, int, int, int ) +{ + p->drawPixmap( 0, 0, pixmap ); +} + +Preview::Preview( TQWidget *parent ) +:TQWidgetStack( parent ) +{ + normalText = new TQMultiLineEdit( this ); + normalText->setReadOnly( true ); + html = new TQTextView( this ); + pixmap = new PixmapView( this ); + raiseWidget( normalText ); +} + +void Preview::showPreview( const TQString &str ) +{ + TQUrl u(str); + if ( u.isLocalFile() ){ + TQString path = u.path(); + TQFileInfo fi( path ); + if ( fi.isFile() && (int)fi.size() > 400 * 1024 ) { + normalText->setText( tr( "The File\n%1\nis too large, so I don't show it!" ).arg( path ) ); + raiseWidget( normalText ); + return; + } + + TQPixmap pix( path ); + if ( pix.isNull() ) { + if ( fi.isFile() ) { + TQFile f( path ); + if ( f.open( IO_ReadOnly ) ) { + TQTextStream ts( &f ); + TQString text = ts.read(); + f.close(); + if ( fi.extension().lower().contains( "htm" ) ) { + TQString url = html->mimeSourceFactory()->makeAbsolute( path, html->context() ); + html->setText( text, url ); + raiseWidget( html ); + return; + } else { + normalText->setText( text ); + raiseWidget( normalText ); + return; + } + } + } + normalText->setText( TQString::null ); + raiseWidget( normalText ); + } else { + pixmap->setPixmap( pix ); + raiseWidget( pixmap ); + } + } else { + normalText->setText( "I only show local files!" ); + raiseWidget( normalText ); + } +} + +// **************************************************************************************************** +static const char* homepage_xpm[] = { +"24 24 9 1", +" c #262660", +". c #383666", +"X c #62639c", +"o c #7e86a5", +"O c #a6a7dd", +"+ c #bbbaed", +"@ c #c4c4f2", +"# c #f8f9f9", +"$ c None", +"$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$o.X$$$$$", +"$$$$$$$$$$oOOOO$O.X$$$$$", +"$$$$$$$$$$oXXXX+O.X$$$$$", +"$$$$$$$$$X#XXXXXO.X$$$$$", +"$$$$$$$$X #XXXXO.X$$$$$", +"$$$$$$$X XO #XXXO.X$$$$$", +"$$$$$$X XOOO #XXX.XX$$$$", +"$$$$$X XOOOOO #XXXXXX$$$", +"$$$$X XOOOOOOO #XXXXXX$$", +"$$$X XOOOOOOOOO #XXXXXX$", +"$$X XOOOOOOOOOOO #.....$", +"$$$$$OOOOXXXXOOOOX...$$$", +"$$$$$OOOOXXXXOOOOX...$$$", +"$$$$$OOOOXXXXOOOOX..o$$$", +"$$$$$OOOOXXXXOOOOX.oo$$$", +"$$$$$OOOOXXXXOOOOXXoo$$$", +"$$$$$OOOOXXXXOOOOXooo$$$", +"$$$ooOOOOXXXXOOOOXoooo$$", +"$ooooXXXXXXXXXXXXXooooo$", +"$ooooooooooooooooooooooo", +"$$$$$$$$$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$$$$$$$$$" +}; + +static const char* folder_trash[] = { +"16 16 10 1", +" c Gray0", +". c #222222", +"X c #333366", +"o c #6666cc", +"O c Magenta", +"+ c #808080", +"@ c #9999ff", +"# c #c0c0c0", +"$ c Gray100", +"% c None", +"%%%%%%oo%%%%%%%%", +"%%%%%o$$o%%%%%%%", +"%%%%o$$$$o%%%%%%", +"%%%o$+$+$$o o%%%", +"%%oo$$+$+$$o .%%", +"%%.oo$$+$+$$o.%%", +"%% Xoo$$+$$o +%%", +"%%o Xoo$$oo o%%", +"%%%X.XX +X%%%", +"%%%o@X+X#X+X+%%%", +"%%%+.$X#X+X %%%%", +"%%%%.o$o#X+X%%%%", +"%%%%.X@$X+ +%%%%", +"%%%%+Xo.#. %%%%%", +"%%%%%.Xo. o%%%%%", +"%%%%%+. %%%%%%" +}; + +static const char* globalbookmark_xpm[]={ +"12 16 3 1", +". c None", +"a c #000000", +"# c #008080", +"............", +"............", +"........##..", +".......#####", +"......#####a", +".....#####a.", +"....#####a..", +"...#####a...", +"..#####a....", +".#####a.....", +"aaa##a......", +"...#a.......", +"...a........", +"............", +"............", +"............"}; + +CustomFileDialog::CustomFileDialog( TQWidget* parent ) +: TQFileDialog( parent, 0, false ) +{ + TQToolButton *p = new TQToolButton( this ); + + p->setPixmap( TQPixmap( globalbookmark_xpm ) ); + TQToolTip::add( p, tr( "Bookmarks" ) ); + + bookmarkMenu = new TQPopupMenu( this ); + connect( bookmarkMenu, TQT_SIGNAL( activated( int ) ), this, TQT_SLOT( bookmarkChosen( int ) ) ); + addId = bookmarkMenu->insertItem( "Add bookmark" ); + clearId = bookmarkMenu->insertItem( TQPixmap(folder_trash), "Clear bookmarks" ); + bookmarkMenu->insertSeparator(); + + p->setPopup( bookmarkMenu ); + p->setPopupDelay(0); + addToolButton( p, true ); + + TQToolButton *b = new TQToolButton( this ); + TQToolTip::add( b, tr( "Go Home!" ) ); + + b->setPixmap( TQPixmap( homepage_xpm ) ); + connect( b, TQT_SIGNAL( clicked() ), this, TQT_SLOT( goHome() ) ); + + addToolButton( b ); +} + + +void CustomFileDialog::setBookmark( TQStringList &s ) +{ + TQStringList::Iterator it = s.begin(); + for ( ; it != s.end(); ++it ){ + bookmarkList << (*it); + + const char* book_pix[]={ + "12 16 3 1", + ". c None", + "a c #000000", + "# c #008080", + "............", + "............", + "........##..", + ".......#####", + "......#####a", + ".....#####a.", + "....#####a..", + "...#####a...", + "..#####a....", + ".#####a.....", + "aaa##a......", + "...#a.......", + "...a........", + "............", + "............", + "............"}; + bookmarkMenu->insertItem( TQIconSet( book_pix ), (*it) ); + } +} + +CustomFileDialog::~CustomFileDialog() +{ +} + +void CustomFileDialog::setDir2( const TQString &s ) +{ + blockSignals( true ); + setDir( s ); + blockSignals( false ); +} + +void CustomFileDialog::bookmarkChosen( int i ) +{ + if ( i == clearId ){ + bookmarkList.clear(); + bookmarkMenu->clear(); + addId = bookmarkMenu->insertItem( "Add bookmark" ); + clearId = bookmarkMenu->insertItem( "Clear bookmarks" ); + bookmarkMenu->insertSeparator(); + return; + } + + if ( i == addId ){ + bookmarkList << dirPath(); + + const char* book_pix[]={ + "12 16 3 1", + ". c None", + "a c #000000", + "# c #008080", + "............", + "............", + "........##..", + ".......#####", + "......#####a", + ".....#####a.", + "....#####a..", + "...#####a...", + "..#####a....", + ".#####a.....", + "aaa##a......", + "...#a.......", + "...a........", + "............", + "............", + "............"}; + bookmarkMenu->insertItem( TQIconSet( book_pix ), dirPath() ); + return; + } + + setDir( bookmarkMenu->text( i ) ); +} + +void CustomFileDialog::goHome() +{ + if ( getenv( "HOME" ) ) + setDir( getenv( "HOME" ) ); + else + setDir( "/" ); +} + +void CustomFileDialog::done( int i ) +{ + emit signalDone(i); +} +/******************************************************************************************************/ +static const char* folder_closed_xpm[] = { +"16 16 9 1", +" c Gray0", +". c #222222", +"X c #6666cc", +"o c #9999ff", +"O c #c0c0c0", +"+ c #ccccff", +"@ c #ffffcc", +"# c Gray100", +"$ c None", +"$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$", +"$$$$$$$$$$$$$$$$", +"$$XXXXo$$$$$$$$$", +"$X#++o@XXXXXX$$$", +"X#+++++++++++o$$", +"X#o+o+o+o+o+oX$$", +"X#+o+o+o+o+o+X $", +"X#o+o+o+o+o+oX $", +"X#+o+o+o+o+o+X $", +"X#o+o+o+o+o+oX $", +"X#+o+o+o+o+o+X $", +"X+o+o+o+o+o+oX $", +"XXXXXXXXXXXXXX $", +"$ .. $" +}; + +static const char* folder_open_xpm[] = { +"16 16 10 1", +" c Gray0", +". c #222222", +"X c #6666cc", +"o c Magenta", +"O c #9999ff", +"+ c #c0c0c0", +"@ c #ccccff", +"# c #ffffcc", +"$ c Gray100", +"% c None", +"%%%%%%%%%%%%%%%%", +"%%%%%%%%%%%%%%%%", +"%%%%%%%%%%%%%%%%", +"%%%%%%%%%%%%%%%%", +"%%XXXX%%%%%%%%%%", +"%X$$$XXXXXXXXX%%", +"%X$O+#######.OX%", +"%X$+#######.O@X%", +"%O$#######.O@OX ", +"XXXXXXXXXX.XO@X ", +"X$$$$$$$$$+ @OX ", +"%XO+O+O+O+O+ @X ", +"%X+O+O+O+O+O. X ", +"%%X+O+O+O+O+O. ", +"%%XXXXXXXXXXXXX ", +"%%% " +}; + +static const char* folder_locked_xpm[] = { +"16 16 8 1", +" c Gray0", +". c #333366", +"X c #6666cc", +"o c Magenta", +"O c #9999ff", +"+ c #c0c0c0", +"@ c Gray100", +"# c None", +"###O.O##########", +"###...##########", +"###O.O##########", +"##.#X#.#OX######", +"#...X...@@X#####", +"#.......OOOOOOX#", +"#.......@@@@@@X#", +"#@@@@@@@O+O+O+X ", +"#O@O+O+O+O+O+OX ", +"#O@+O+O+O+O+O+X ", +"#O@O+O+O+O+O+OX ", +"#O@+O+O+O+O+O+X ", +"#O@O+O+O+O+O+OX ", +"#OXXXXXXXXXXXXX ", +"## ", +"################" +}; + +Directory::Directory( Directory * parent, const TQString& filename ) +:TQListViewItem( parent ), f(filename) +{ + p = parent; + readable = TQDir( fullName() ).isReadable(); + + if ( !readable ) + setPixmap( 0, TQPixmap( folder_locked_xpm ) ); + else + setPixmap( 0, TQPixmap( folder_closed_xpm ) ); +} + + +Directory::Directory( TQListView * parent, const TQString& filename ) +:TQListViewItem( parent ), f(filename) +{ + p = 0; + readable = TQDir( fullName() ).isReadable(); +} + + +void Directory::setOpen( bool o ) +{ + if ( o ) + setPixmap( 0, TQPixmap( folder_open_xpm ) ); + else + setPixmap( 0, TQPixmap( folder_closed_xpm ) ); + + if ( o && !childCount() ){ + TQString s( fullName() ); + TQDir thisDir( s ); + if ( !thisDir.isReadable() ) { + readable = false; + setExpandable( false ); + return; + } + + listView()->tqsetUpdatesEnabled( false ); + const QFileInfoList * files = thisDir.entryInfoList(); + if ( files ){ + QFileInfoListIterator it( *files ); + TQFileInfo * f; + while( (f=it.current()) != 0 ){ + ++it; + if ( f->fileName() != "." && f->fileName() != ".." && f->isDir() ) + (void)new Directory( this, f->fileName() ); + } + } + listView()->tqsetUpdatesEnabled( true ); + } + TQListViewItem::setOpen( o ); +} + + +void Directory::setup() +{ + setExpandable( true ); + TQListViewItem::setup(); +} + + +TQString Directory::fullName() +{ + TQString s; + if ( p ) { + s = p->fullName(); + s.append( f.name() ); + s.append( "/" ); + } else { + s = f.name(); + } + return s; +} + + +TQString Directory::text( int column ) const +{ + if ( column == 0 ) + return f.name(); + else + if ( readable ) + return "Directory"; + else + return "Unreadable Directory"; +} + +DirectoryView::DirectoryView( TQWidget *parent, const char *name ) +:TQListView( parent, name ) +{ + connect( this, TQT_SIGNAL( clicked( TQListViewItem * ) ), + this, TQT_SLOT( slotFolderSelected( TQListViewItem * ) ) ); + connect( this, TQT_SIGNAL( doubleClicked( TQListViewItem * ) ), + this, TQT_SLOT( slotFolderSelected( TQListViewItem * ) ) ); + connect( this, TQT_SIGNAL( returnPressed( TQListViewItem * ) ), + this, TQT_SLOT( slotFolderSelected( TQListViewItem * ) ) ); + + setAcceptDrops( true ); + viewport()->setAcceptDrops( true ); +} + +void DirectoryView::setOpen( TQListViewItem* i, bool b ) +{ + TQListView::setOpen(i,b); + setCurrentItem(i); + slotFolderSelected(i); +} + +void DirectoryView::slotFolderSelected( TQListViewItem *i ) +{ + if ( !i ) return; + + Directory *dir = (Directory*)i; + emit folderSelected( dir->fullName() ); +} + +TQString DirectoryView::fullPath(TQListViewItem* item) +{ + TQString fullpath = item->text(0); + while ( (item=item->parent()) ) { + if ( item->parent() ) + fullpath = item->text(0) + "/" + fullpath; + else + fullpath = item->text(0) + fullpath; + } + return fullpath; +} + +void DirectoryView::setDir( const TQString &s ) +{ + TQListViewItemIterator it( this ); + ++it; + for ( ; it.current(); ++it ) { + it.current()->setOpen( false ); + } + + TQStringList lst( TQStringList::split( "/", s ) ); + TQListViewItem *item = firstChild(); + TQStringList::Iterator it2 = lst.begin(); + for ( ; it2 != lst.end(); ++it2 ) { + while ( item ) { + if ( item->text( 0 ) == *it2 ) { + item->setOpen( true ); + break; + } + item = item->itemBelow(); + } + } + + if ( item ){ + setSelected( item, true ); + setCurrentItem( item ); + } +} + +TQString DirectoryView::selectedDir() +{ + Directory *dir = (Directory*)currentItem(); + return dir->fullName(); +} +/**********************************************************************************************/ + +int main(int argc, char* argv[]) { + KApplication app(argc,argv,"kdockwidgetdemo"); + +#if 0 + SFileDialog* openfile = new SFileDialog(); + openfile->exec(); + qDebug( openfile->fileName() ); +#endif + +#if 0 + qDebug ( SFileDialog::getOpenFileName( TQString::null, TQString::tqfromLatin1("All (*)"), + TQString::tqfromLatin1("DockWidget Demo"), "dialog1" ) ); +#endif + +#if 1 + TQStringList s = SFileDialog::getOpenFileNames( TQString::null, TQString::tqfromLatin1("All (*)"), + TQString::tqfromLatin1("DockWidget Demo"), "dialog1" ); + TQStringList::Iterator it = s.begin(); + for ( ; it != s.end(); ++it ){ + qDebug( "%s", (*it).local8Bit().data() ); + } +#endif + return 0; +} + +#include "kdockwidgetdemo.moc" + diff --git a/tdeui/tests/kdockwidgetdemo.h b/tdeui/tests/kdockwidgetdemo.h new file mode 100644 index 000000000..b6f029cd5 --- /dev/null +++ b/tdeui/tests/kdockwidgetdemo.h @@ -0,0 +1,164 @@ +#ifndef KDOCKWIDGETDEMO_H +#define KDOCKWIDGETDEMO_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class TQMultiLineEdit; +class TQTextView; +class TQToolButton; +class TQSpinBox; +class TQShowEvent; +class TQPopupMenu; + +class DirectoryView; +class CustomFileDialog; +class Preview; +class DirectoryView; + +class SFileDialog : public TQDialog +{Q_OBJECT + +public: + SFileDialog( TQString initially = TQString::null, + const TQStringList& filter = "All Files ( * )", const char* name = 0 ); + ~SFileDialog(); + + static TQString getOpenFileName( TQString initially = TQString::null, + const TQStringList& filter = "All Files ( * )", + const TQString caption = TQString::null, const char* name = 0 ); + + static TQStringList getOpenFileNames( TQString initially = TQString::null, + const TQStringList& filter = "All Files ( * )", + const TQString caption = TQString::null, const char* name = 0 ); + + +protected: + void showEvent( TQShowEvent *e ); + +protected slots: + void dockChange(); + void setDockDefaultPos( KDockWidget* ); + void changeDir( const TQString& ); + +private: + DirectoryView* dirView; + CustomFileDialog* fd; + Preview* preview; + + KDockManager* dockManager; + KDockWidget* d_dirView; + KDockWidget* d_preview; + KDockWidget* d_fd; + + TQToolButton *b_tree; + TQToolButton *b_preview; +}; +/******************************************************************************************************/ +class Directory : public TQListViewItem +{ +public: + Directory( TQListView * parent, const TQString& filename ); + Directory( Directory * parent, const TQString& filename ); + + TQString text( int column ) const; + + TQString fullName(); + + void setOpen( bool ); + void setup(); + +private: + TQFile f; + Directory * p; + bool readable; +}; + +class DirectoryView : public TQListView +{Q_OBJECT +public: + DirectoryView( TQWidget *parent = 0, const char *name = 0 ); + virtual void setOpen ( TQListViewItem *, bool ); + + TQString selectedDir(); + +public slots: + void setDir( const TQString & ); + +signals: + void folderSelected( const TQString & ); + +protected slots: + void slotFolderSelected( TQListViewItem * ); + +private: + TQString fullPath(TQListViewItem* item); +}; +/******************************************************************************************************/ +class PixmapView : public TQScrollView +{Q_OBJECT +public: + PixmapView( TQWidget *parent ); + void setPixmap( const TQPixmap &pix ); + void drawContents( TQPainter *p, int, int, int, int ); + +private: + TQPixmap pixmap; +}; + +class Preview : public TQWidgetStack +{Q_OBJECT +public: + Preview( TQWidget *parent ); + +public slots: + void showPreview( const TQString& ); + +private: + TQMultiLineEdit *normalText; + TQTextView *html; + PixmapView *pixmap; +}; + +class CustomFileDialog : public TQFileDialog +{Q_OBJECT +public: + CustomFileDialog( TQWidget* parent ); + ~CustomFileDialog(); + + void addToolButton( TQButton * b, bool separator = false ){ TQFileDialog::addToolButton(b,separator); } + void setBookmark( TQStringList& ); + TQStringList getBookmark(){ return bookmarkList; } + +public slots: + void setDir2( const TQString & ); + +signals: + void signalDone( int ); + +protected slots: + void bookmarkChosen( int i ); + void goHome(); + virtual void done( int ); + +private: + TQPopupMenu *bookmarkMenu; + TQStringList bookmarkList; + int addId, clearId; +}; + +#endif + + diff --git a/tdeui/tests/kdockwidgettest.cpp b/tdeui/tests/kdockwidgettest.cpp new file mode 100644 index 000000000..7d4625357 --- /dev/null +++ b/tdeui/tests/kdockwidgettest.cpp @@ -0,0 +1,255 @@ +/*************************************************************************** + copyright : (C) 1999 by Judin Max + email : novaprint@mtu-net.ru + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kdockwidgettest.h" + +#include +#include +#include +#include +#include +#include +#include + +static const char*folder[]={ +"16 16 9 1", +"g c #808080", +"b c #ffa858", +"e c #c0c0c0", +"# c #000000", +"c c #ffdca8", +". c None", +"a c #585858", +"f c #a0a0a4", +"d c #ffffff", +"..#a#...........", +".#abc##.........", +".#daabc#####....", +".#ddeaabcccb#...", +".#dedeeabccca...", +".#edeeeeaaaab#..", +".#deeeeeeefe#ba.", +".#eeeeeeefef#ba.", +".#eeeeeefeff#ba.", +".#eeeeefefff#ba.", +".##geefeffff#ba.", +"...##gefffff#ba.", +".....##fffff#ba.", +".......##fff#b##", +".........##f#b##", +"...........####."}; + + +DockApplication::DockApplication( const char* name ) +: KDockMainWindow( 0L, name ) +{ + TQPixmap p(folder); + + initMenuBar(); + initToolBars(); + initStatusBar(); + + /*****************************************************/ + dock = createDockWidget( "Green Widget", p ); + dock->setCaption("Green"); + dock->setGeometry(50, 50, 100, 100); + l = new TQWidget(dock); + l->setBackgroundColor(green); + l->setMinimumSize(100,100); + dock->setWidget(l); + /*****************************************************/ + dock1 = createDockWidget( "Blue Widget", p ); + dock1->setCaption("Blue"); + dock1->setGeometry( 150, 150, 100, 100); + setView( dock1 ); + setMainDockWidget( dock1 ); + + mainW = new TQWidget( dock1, "createdOnBlueDock" ); + mainW->setBackgroundColor(blue); + mainW->setMinimumSize(300,150); + dock1->setWidget( mainW ); + /*****************************************************/ + + KDockWidget* dock2 = createDockWidget( "Yellow Widget", p ); + dock2->setGeometry(300, 300, 100, 100); + dock2->setCaption("Yellow"); + + /* test set new header widget...*/ +// dock2->setHeader( new KDockWidgetHeader(dock2) ); + + TQWidget* l2 = new TQWidget(dock2); + l2->setBackgroundColor(yellow); + dock2->setWidget( l2 ); + /*****************************************************/ + + /*****************************************************/ + dock5 = createDockWidget( "Container Widget", p ); + dock5->setCaption("Container"); + dock5->setGeometry(50, 50, 100, 100); + l = new CTW(dock5); + l->setBackgroundColor(white); + l->setMinimumSize(100,100); + dock5->setWidget(l); + if (::tqqt_cast(l)) qDebug("KDockContainer created for dock 5"); + /*****************************************************/ + + /*****************************************************/ + dock6 = createDockWidget( "Container Widget2", p ); + dock6->setCaption("Container2"); + dock6->setGeometry(50, 50, 100, 100); + l = new CTW(dock6); + l->setBackgroundColor(white); + l->setMinimumSize(100,100); + dock6->setWidget(l); + if (::tqqt_cast(l)) qDebug("KDockContainer created for dock 6"); + /*****************************************************/ + + + + TQPushButton* b1 = new TQPushButton(mainW); + b1->setGeometry(10, 10, 250, 25); + b1->setText("write dock config"); + connect(b1, TQT_SIGNAL(clicked()), TQT_SLOT(wConfig())); + + TQPushButton* b2 = new TQPushButton(mainW); + b2->setGeometry(10, 35, 250, 25); + b2->setText("read dock config"); + connect(b2, TQT_SIGNAL(clicked()), TQT_SLOT(rConfig())); + + m_bname = new TQPushButton(mainW); + m_bname->setGeometry(10, 60, 250, 25); + m_bname->setEnabled( false ); + + TQPushButton *b3 = new TQPushButton(mainW); + b3->setGeometry(10,95,250,25); + b3->setText("change the icon of the green widget"); + connect(b3,TQT_SIGNAL(clicked()), TQT_SLOT(gSetPix1())); + + TQPushButton *b4 = new TQPushButton(mainW); + b4->setGeometry(10,130,250,25); + b4->setText("remove icon "); + connect(b4,TQT_SIGNAL(clicked()), TQT_SLOT(gSetPix2())); + + setGeometry(200, 100, 500, 300); + + qDebug("load config"); + readDockConfig(); + + updateButton(); +} + +DockApplication::~DockApplication() +{ + qDebug("Close & store config"); + writeDockConfig(); +} + +void DockApplication::rConfig() +{ + readDockConfig(); +} + +void DockApplication::wConfig() +{ + writeDockConfig(); +} + +void DockApplication::initMenuBar() +{ + TQPixmap p(folder); + TQPopupMenu *file_menu = new TQPopupMenu(); + + file_menu->insertItem(p, "Change Green Widget Caption", this, TQT_SLOT(cap()) ); + file_menu->insertSeparator(); + file_menu->insertItem(p, "Set Green Widget as MainDockWidget", this, TQT_SLOT(greenMain()) ); + file_menu->insertItem(p, "Set Blue Widget as MainDockWidget", this, TQT_SLOT(blueMain()) ); + file_menu->insertItem(p, "Set NULL as MainDockWidget", this, TQT_SLOT(nullMain()) ); + + KMenuBar* menu_bar = menuBar(); + menu_bar->insertItem( "&Test", file_menu ); + menu_bar->insertItem( "&Docking Windows", dockHideShowMenu() ); +} + +void DockApplication::initToolBars() +{ + TQPixmap p(folder); + KToolBar* tool_bar_0 = toolBar(0); + tool_bar_0->setFullSize(false); + tool_bar_0->insertButton( p, 1 ); + tool_bar_0->insertButton(p, 2 ); + tool_bar_0->setFullSize( true ); +} + +void DockApplication::initStatusBar() +{ + KStatusBar* status_bar = statusBar(); + status_bar->insertItem("Welcome to KDockWidget test...", 1); +} + +void DockApplication::cap() +{ + if ( dock->caption() != "Test Caption1" ) + dock->setCaption("Test Caption1"); + else + dock->setCaption("Another Caption"); +} + +void DockApplication::greenMain() +{ + setMainDockWidget( dock ); + updateButton(); +} + +void DockApplication::blueMain() +{ + setMainDockWidget( dock1 ); + updateButton(); +} + +void DockApplication::nullMain() +{ + setMainDockWidget( 0L ); + updateButton(); +} + +void DockApplication::updateButton() +{ + if ( getMainDockWidget() ) + m_bname->setText(TQString("MainDockWidget is %1").arg(getMainDockWidget()->name())); + else + m_bname->setText("MainDockWidget is NULL"); +} + +void DockApplication::gSetPix1() { + dock->setPixmap(SmallIcon("agent")); + +} + +void DockApplication::gSetPix2() { + dock->setPixmap(); + +} + +int main(int argc, char* argv[]) { + KApplication a(argc,argv, "kdockdemoapp1"); + DockApplication* ap = new DockApplication("DockWidget demo"); + ap->setCaption("DockWidget demo"); + a.setMainWidget(ap); + ap->show(); + return a.exec(); +} + + +#include "kdockwidgettest.moc" + diff --git a/tdeui/tests/kdockwidgettest.h b/tdeui/tests/kdockwidgettest.h new file mode 100644 index 000000000..7ae2ab271 --- /dev/null +++ b/tdeui/tests/kdockwidgettest.h @@ -0,0 +1,72 @@ +/*************************************************************************** + copyright : (C) 1999 by Judin Max + email : novaprint@mtu-net.ru + ***************************************************************************/ + +/*************************************************************************** + * * + * This program 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KDOCKWIDGETTEST_H +#define KDOCKWIDGETTEST_H + +#include +#include +#include +#include +class TQPushButton; + +class DockApplication : public KDockMainWindow +{Q_OBJECT +public: + DockApplication( const char* name ); + ~DockApplication(); + +public slots: + void rConfig(); + void wConfig(); + void cap(); + void greenMain(); + void blueMain(); + void nullMain(); + void gSetPix1(); + void gSetPix2(); + +protected: + void initMenuBar(); + void initToolBars(); + void initStatusBar(); + +private: + void updateButton(); + KDockWidget* dock; + KDockWidget* dock1; + KDockWidget* dock4; + KDockWidget* dock5; + KDockWidget* dock6; + + TQWidget* mainW; + TQWidget* l; + TQPushButton* m_bname; +}; + +class CTW:public TQTabWidget,public KDockContainer +{ + Q_OBJECT +public: + CTW(TQWidget *parent):TQTabWidget(parent,"MyDockContainer"),KDockContainer(){insertTab(new TQLabel("BLAH",this),"BLUP");} + virtual ~CTW(){;} + KDockWidget *parentDockWidget(){return ((KDockWidget*)parent());} + void insertWidget (KDockWidget *w, TQPixmap, const TQString &, int &){qDebug("widget inserted"); insertTab(w,"NO");} + void setToolTip (KDockWidget *, TQString &){qDebug("Tooltip set");} +}; + + +#endif + + diff --git a/tdeui/tests/kdualcolortest.cpp b/tdeui/tests/kdualcolortest.cpp new file mode 100644 index 000000000..507030132 --- /dev/null +++ b/tdeui/tests/kdualcolortest.cpp @@ -0,0 +1,63 @@ +#include "kdualcolortest.h" +#include +#include +#include +#include +#include + +KDualColorWidget::KDualColorWidget(TQWidget *parent, const char *name) + : TQWidget(parent, name) +{ + lbl = new TQLabel("Testing, testing, 1, 2, 3...", this); + KDualColorButton *colorBtn = + new KDualColorButton(lbl->tqcolorGroup().text(), + lbl->tqcolorGroup().background(), this); + connect(colorBtn, TQT_SIGNAL(fgChanged(const TQColor &)), + TQT_SLOT(slotFgChanged(const TQColor &))); + connect(colorBtn, TQT_SIGNAL(bgChanged(const TQColor &)), + TQT_SLOT(slotBgChanged(const TQColor &))); + connect(colorBtn, TQT_SIGNAL(currentChanged(KDualColorButton::DualColor)), + TQT_SLOT(slotCurrentChanged(KDualColorButton::DualColor))); + + TQHBoxLayout *layout = new TQHBoxLayout(this, 5); + layout->addWidget(colorBtn, 0); + layout->addWidget(lbl, 1); + layout->activate(); + resize(tqsizeHint()); +} + +void KDualColorWidget::slotFgChanged(const TQColor &c) +{ + TQPalette p = lbl->palette(); + p.setColor(TQColorGroup::Text, c); + lbl->setPalette(p); +} + +void KDualColorWidget::slotBgChanged(const TQColor &c) +{ + TQPalette p = lbl->palette(); + TQBrush b(c, SolidPattern); + p.setBrush(TQColorGroup::Background, b); + setPalette(p); +} + +void KDualColorWidget::slotCurrentChanged(KDualColorButton::DualColor current) +{ + if(current == KDualColorButton::Foreground) + qDebug("Foreground Button Selected."); + else + qDebug("Background Button Selected."); +} + +int main(int argc, char **argv) +{ + KApplication *app = new KApplication(argc, argv, "KDualColorTest"); + KDualColorWidget w; + app->setMainWidget(&w); + w.show(); + return(app->exec()); +} + +#include "kdualcolortest.moc" + + diff --git a/tdeui/tests/kdualcolortest.h b/tdeui/tests/kdualcolortest.h new file mode 100644 index 000000000..2c38b7af0 --- /dev/null +++ b/tdeui/tests/kdualcolortest.h @@ -0,0 +1,20 @@ +#ifndef __KDUALCOLORTEST_H +#define __KDUALCOLORTEST_H + +#include +#include + +class KDualColorWidget : public TQWidget +{ + Q_OBJECT +public: + KDualColorWidget(TQWidget *parent=0, const char *name=0); +protected slots: + void slotFgChanged(const TQColor &c); + void slotBgChanged(const TQColor &c); + void slotCurrentChanged(KDualColorButton::DualColor current); +protected: + TQLabel *lbl; +}; + +#endif diff --git a/tdeui/tests/keditlistboxtest.cpp b/tdeui/tests/keditlistboxtest.cpp new file mode 100644 index 000000000..fdc90a742 --- /dev/null +++ b/tdeui/tests/keditlistboxtest.cpp @@ -0,0 +1,21 @@ +#include +#include +#include + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "keditlistboxtest" ); + + KEditListBox::CustomEditor editor( new KComboBox( true, 0L, "test" ) ); + KEditListBox *box = new KEditListBox( TQString::tqfromLatin1("KEditListBox"), + editor ); + + box->insertItem( TQString::tqfromLatin1("Test") ); + box->insertItem( TQString::tqfromLatin1("for") ); + box->insertItem( TQString::tqfromLatin1("this") ); + box->insertItem( TQString::tqfromLatin1("KEditListBox") ); + box->insertItem( TQString::tqfromLatin1("Widget") ); + box->show(); + + return app.exec(); +} diff --git a/tdeui/tests/kedittest.cpp b/tdeui/tests/kedittest.cpp new file mode 100644 index 000000000..17a593e74 --- /dev/null +++ b/tdeui/tests/kedittest.cpp @@ -0,0 +1,14 @@ +#include +#include +#include + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "kedittest" ); + KEdit *edit = new KEdit( 0L ); + TQPopupMenu *pop = new TQPopupMenu( 0L ); + pop->insertItem( "Popupmenu item" ); + edit->installRBPopup( pop ); + edit->show(); + return app.exec(); +} diff --git a/tdeui/tests/kfontdialogtest.cpp b/tdeui/tests/kfontdialogtest.cpp new file mode 100644 index 000000000..205fd48f7 --- /dev/null +++ b/tdeui/tests/kfontdialogtest.cpp @@ -0,0 +1,51 @@ +/* + $Id$ + + Requires the Qt widget libraries, available at no cost at + http://www.troll.no + + Copyright (C) 1996 Bernd Johannes Wuebben + wuebben@math.cornell.edu + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + + +#include +#include "kfontdialog.h" +#include + + + int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "KFontDialogTest" ); + + KConfig aConfig; + aConfig.setGroup( "KFontDialog-test" ); + + app.setFont(TQFont("Helvetica",12)); + + // TQFont font = TQFont("Times",18,TQFont::Bold); + + TQFont font = aConfig.readFontEntry( "Chosen" ); + int nRet = KFontDialog::getFont(font); + int flags; + nRet = KFontDialog::getFontDiff(font, flags); + aConfig.writeEntry( "Chosen", font, true ); + + aConfig.sync(); + return nRet; +} diff --git a/tdeui/tests/kgradienttest.cpp b/tdeui/tests/kgradienttest.cpp new file mode 100644 index 000000000..6942ca55d --- /dev/null +++ b/tdeui/tests/kgradienttest.cpp @@ -0,0 +1,108 @@ +#include "kgradienttest.h" +#include +#include +#include +#include +#include + +int cols = 3, rows = 3; // how many + +void KGradientWidget::paintEvent(TQPaintEvent */*ev*/) +{ + TQTime time; + int it, ft; + TQString say; + + TQColor ca = Qt::black, cb = Qt::blue; + + int x = 0, y = 0; + + pix.resize(width()/cols, height()/rows); + TQPainter p(this); + p.setPen(Qt::white); + + // draw once, so that the benchmarking be fair :-) + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::VerticalGradient); + + // vertical + time.start(); + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::VerticalGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Vertical"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5 + (x++)*width()/cols, 15+y*height()/rows, say); // augment x + + // horizontal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::HorizontalGradient); + ft = time.elapsed() ; + say.setNum( ft - it); say += " ms, Horizontal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // elliptic + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::EllipticGradient); + ft = time.elapsed() ; + say.setNum( ft - it); say += " ms, Elliptic"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + y++; // next row + x = 0; // reset the columns + + // diagonal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::DiagonalGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Diagonal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // crossdiagonal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::CrossDiagonalGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, CrossDiagonal"; + p.drawPixmap(width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + y++; // next row + x = 0; // reset the columns + + // pyramidal + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::PyramidGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Pyramid"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // pattern + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::RectangleGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Rectangle"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/rows, 15+y*height()/rows, say); + + // crosspipe + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::PipeCrossGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, PipeCross"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/rows, 15+y*height()/rows, say); +} + +int main(int argc, char **argv) +{ + KApplication *app = new KApplication(argc, argv, "KGradientTest"); + KGradientWidget w; + w.resize(250 * cols, 250 * rows); + app->setMainWidget(&w); + w.show(); + return(app->exec()); +} + diff --git a/tdeui/tests/kgradienttest.h b/tdeui/tests/kgradienttest.h new file mode 100644 index 000000000..ba99c8313 --- /dev/null +++ b/tdeui/tests/kgradienttest.h @@ -0,0 +1,24 @@ +// +// Simple little hack to show off new diagonal gradients. +// +// (C) KDE Artistic Daniel M. Duley +// + +#ifndef __KGRADIENT_TEST_H +#define __KGRADIENT_TEST_H + +#include +#include + +class KGradientWidget : public TQWidget +{ +public: + KGradientWidget(TQWidget *parent=0, const char *name=0) + : TQWidget(parent, name){;} +protected: + void paintEvent(TQPaintEvent *ev); +private: + KPixmap pix; +}; + +#endif diff --git a/tdeui/tests/khashtest.cpp b/tdeui/tests/khashtest.cpp new file mode 100644 index 000000000..2f00c9296 --- /dev/null +++ b/tdeui/tests/khashtest.cpp @@ -0,0 +1,137 @@ +#include "khashtest.h" +#include +#include +#include +#include +#include +#include +#include + +int cols = 3, rows = 3; // how many + +void KHashWidget::paintEvent(TQPaintEvent * /*ev*/) +{ + TQTime time; + int it, ft; + TQString say; + + TQColor cb = TQColor(0,70,70), ca = TQColor(80,200,200); + + int x = 0, y = 0; + + pix.resize(width()/cols, height()/rows); + TQPainter p(this); + p.setPen(Qt::white); + + // draw once, so that the benchmarking be fair :-) + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::VerticalGradient); + + // vertical + time.start(); + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::VerticalGradient); + KPixmapEffect::hash(pix,KPixmapEffect::NorthLite); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Vertical"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5 + (x++)*width()/cols, 15+y*height()/rows, say); // augment x + + // horizontal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::HorizontalGradient); + KPixmapEffect::hash(pix,KPixmapEffect::SouthLite); + ft = time.elapsed() ; + say.setNum( ft - it); say += " ms, Horizontal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // elliptic + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::EllipticGradient); + KPixmapEffect::hash(pix,KPixmapEffect::NorthLite, 1); + ft = time.elapsed() ; + say.setNum( ft - it); say += " ms, Elliptic"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + y++; // next row + x = 0; // reset the columns + + // diagonal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::DiagonalGradient); + KPixmapEffect::hash(pix,KPixmapEffect::EastLite); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Diagonal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // crossdiagonal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::CrossDiagonalGradient); + KPixmapEffect::hash(pix,KPixmapEffect::EastLite, 2); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, CrossDiagonal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + + TQImage image = TQImage("testimage.png"); + it = time.elapsed(); + KImageEffect::hash(image, KImageEffect::WestLite, 2); + ft = time.elapsed(); + pix.resize(image.width(), image.height()); + pix.convertFromImage(image); + pix.resize(width()/cols, height()/rows); + say.setNum( ft - it); say += " ms, CrossDiagonal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.setPen(Qt::blue); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + p.setPen(Qt::white); + + + y++; // next row + x = 0; // reset the columns + + // pyramidal + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::PyramidGradient); + KPixmapEffect::hash(pix,KPixmapEffect::WestLite); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Pyramid"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // rectangular + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::RectangleGradient); + KPixmapEffect::hash(pix,KPixmapEffect::NWLite); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Rectangle"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/rows, 15+y*height()/rows, say); + + // crosspipe + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::PipeCrossGradient); + KPixmapEffect::hash(pix,KPixmapEffect::WestLite, 3); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, PipeCross"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/rows, 15+y*height()/rows, say); + +} + +int main(int argc, char **argv) +{ + + KApplication *app = new KApplication(argc, argv, "KHashTest"); + KHashWidget w; + w.resize(250 * cols, 250 * rows); + app->setMainWidget(&w); + w.show(); + return(app->exec()); +} + +#include diff --git a/tdeui/tests/khashtest.h b/tdeui/tests/khashtest.h new file mode 100644 index 000000000..05de5c435 --- /dev/null +++ b/tdeui/tests/khashtest.h @@ -0,0 +1,26 @@ +// +// Simple little hack to show off new diagonal gradients. +// +// (C) KDE Artistic Daniel M. Duley +// + +#ifndef __KHASH_TEST_H +#define __KHASH_TEST_H + +#include +#include + +class KHashWidget : public TQWidget +{ + Q_OBJECT + +public: + KHashWidget(TQWidget *parent=0, const char *name=0) + : TQWidget(parent, name){;} +protected: + void paintEvent(TQPaintEvent *ev); +private: + KPixmap pix; +}; + +#endif diff --git a/tdeui/tests/kinputdialogtest.cpp b/tdeui/tests/kinputdialogtest.cpp new file mode 100644 index 000000000..66db4617a --- /dev/null +++ b/tdeui/tests/kinputdialogtest.cpp @@ -0,0 +1,67 @@ +/* + * Author: Nadeem Hasan + * License: GPL V2 + */ + +#include +#include +#include + +#include +#include + +int main( int argc, char *argv[] ) +{ + KApplication app( argc, argv, "kinputdialogtest" ); + + bool ok; + TQString svalue; + int ivalue; + double dvalue; + + svalue = KInputDialog::getText( "_caption", "_label:", "_value", &ok ); + kdDebug() << "value1: " << svalue << ", ok: " << ok << endl; + + svalue = KInputDialog::getText( "_caption", "_label:", "_value", &ok, 0L, 0L, + &TQRegExpValidator( TQRegExp( "[0-9]{3}\\-[0-9]{3}\\-[0-9]{4}" ), 0L ) ); + kdDebug() << "value2: " << svalue << ", ok: " << ok << endl; + + svalue = KInputDialog::getText( "_caption", "_label:", "_value", &ok, 0L, 0L, + 0L, "900.900.900.900" ); + kdDebug() << "value1: " << svalue << ", ok: " << ok << endl; + + ivalue = KInputDialog::getInteger( "_caption", "_label:", 64, 0, 255, + 16, 16, &ok ); + kdDebug() << "value3: " << ivalue << ", ok: " << ok << endl; + + ivalue = KInputDialog::getInteger( "_caption", "_label:", 100, 0, 255, + 10, 10, &ok ); + kdDebug() << "value4: " << ivalue << ", ok: " << ok << endl; + + dvalue = KInputDialog::getDouble( "_caption", "_label:", 10, 0, 100, 0.1, + 2, &ok ); + kdDebug() << "value5: " << dvalue << ", ok: " << ok << endl; + + dvalue = KInputDialog::getDouble( "_caption", "_label:", 10, 0, 100, 2, &ok ); + kdDebug() << "value6: " << dvalue << ", ok: " << ok << endl; + + TQStringList list, slvalue; + list << "Item 1" << "Item 2" << "Item 3" << "Item 4" << "Item 5"; + svalue = KInputDialog::getItem( "_caption", "_label:", list, 1, false, &ok ); + kdDebug() << "value7: " << svalue << ", ok: " << ok << endl; + + svalue = KInputDialog::getItem( "_caption", "_label:", list, 1, true, &ok ); + kdDebug() << "value8: " << svalue << ", ok: " << ok << endl; + + TQStringList select; + select << "Item 3"; + list << "Item 6" << "Item 7" << "Item 8" << "Item 9" << "Item 10"; + slvalue = KInputDialog::getItemList( "_caption", "_label:", list, select, + false, &ok ); + kdDebug() << "value9: " << slvalue << ", ok: " << ok << endl; + + select << "Item 5"; + slvalue = KInputDialog::getItemList( "_caption", "_label:", list, select, + true, &ok ); + kdDebug() << "value10: " << slvalue << ", ok: " << ok << endl; +} diff --git a/tdeui/tests/kjanuswidgettest.cpp b/tdeui/tests/kjanuswidgettest.cpp new file mode 100644 index 000000000..59db252e2 --- /dev/null +++ b/tdeui/tests/kjanuswidgettest.cpp @@ -0,0 +1,25 @@ +#include +#include + +#include +#include +#include + +int main(int argc, char** argv) +{ + KApplication app(argc, argv, "JanusWidgetTest"); + // ----- + KJanusWidget* janus = new KJanusWidget( 0, 0, KJanusWidget::IconList ); + + TQVBox* page1 = janus->addVBoxPage( TQString( "Page1" ) ); // use i18n in real apps + TQCheckBox* cb1 = new TQCheckBox( "a", page1 ); + + TQVBox* page2 = janus->addVBoxPage( TQString( "Page2" ) ); + TQCheckBox* cb2 = new TQCheckBox( "a", page2 ); + + janus->show(); + TQObject::connect( &app, TQT_SIGNAL( lastWindowClosed() ), &app, TQT_SLOT( quit() ) ); + + return app.exec(); +} + diff --git a/tdeui/tests/kledtest.cpp b/tdeui/tests/kledtest.cpp new file mode 100644 index 000000000..f8d031530 --- /dev/null +++ b/tdeui/tests/kledtest.cpp @@ -0,0 +1,160 @@ +#include +#include +#include +#include +#include "kled.h" +#include "kledtest.h" + + + +KLedTest::KLedTest(TQWidget* parent) + : TQWidget(parent, 0), + LedWidth(16), + LedHeight(10), + Grid(3), + ledcolor(0), + red(TQColor("red")), + blue(TQColor("blue")), + green(TQColor("green")), + yellow(TQColor("yellow")), + kled_round(true) // Switch HERE between rectangle and circular leds +{ + if (kled_round) { + //KLed l(KLed::red, &qw); // create lamp + //KLed l(KLed::blue, &qw); // create lamp + l = new KLed(Qt::green, this); // create lamp + //KLed l(KLed::yellow, &qw); // create lamp + //KLed l(KLed::orange, &qw); // create lamp + + + l->resize(16,30); + //l.setLook(KLed::flat); + l->setShape(KLed::Circular); + //l->setShape(KLed::Rectangular); + + //l->setLook(KLed::Flat); + //l->setLook(KLed::Flat); + //l->setLook(KLed::Flat); + + l->move(5,5); + // ktmp tmpobj(l); + + t_toggle.start(1000, false); + t_color.start(3500, false); + t_look.start(3500, false); + TQObject::connect(&t_toggle, TQT_SIGNAL(timeout()), l, TQT_SLOT(toggle())); + TQObject::connect(&t_color, TQT_SIGNAL(timeout()), this, TQT_SLOT(nextColor())); + TQObject::connect(&t_look, TQT_SIGNAL(timeout()), this, TQT_SLOT(nextLook())); + l->show(); + resize(240,140); + } + else { + y=Grid; index=0; + for( int tqshape=0; (int)tqshape<2; tqshape=(KLed::Shape)(tqshape+1)) { + x=Grid; + for( int look=0; (int)look<3; look=(KLed::Look)(look+1)) { + for(state=KLed::Off; (int)state<2; state=(KLed::State)(state+1)) + { + leds[index]=new KLed(Qt::yellow, state, + (KLed::Look)(look+1), + (KLed::Shape)(tqshape+1), this); + leds[index]->setGeometry(x, y, LedWidth, LedHeight); + ++index; + x+=Grid+LedWidth; + } + } + y+=Grid+LedHeight; + } + setFixedSize(x+Grid, y+Grid); + connect(&timer, TQT_SIGNAL(timeout()), TQT_SLOT(timeout())); + timer.start(500); + } +} + + +KLedTest::~KLedTest() +{ + if (kled_round) { + delete l; + } +} + + +void +KLedTest::nextColor() { + + ledcolor++; + ledcolor%=4; + + switch(ledcolor) { + default: + case 0: l->setColor(green); break; + case 1: l->setColor(blue); break; + case 2: l->setColor(red); break; + case 3: l->setColor(yellow); break; + } +} + + +void +KLedTest::nextLook() { + register int tmp; + if (kled_round) { + tmp = (static_cast(ledlook) +1 ) % 3 ; + } + else { + tmp = (static_cast(ledlook) + 1) % 3; + } + ledlook = static_cast(tmp); + l->setLook(ledlook); + //qDebug("painting look %i", ledlook); + //l->tqrepaint(); +} + + +void +KLedTest::timeout() +{ + const int NoOfLeds=sizeof(leds)/sizeof(leds[0]); + int count; + // ----- + for(count=0; countstate()==KLed::Off) + { + leds[count]->setState(KLed::On); + } else { + leds[count]->setState(KLed::Off); + } + } +} + + +/*#include */ + +int main( int argc, char **argv ) +{ + KApplication a( argc, argv, "KLedTest" ); + KLedTest widget; + // ----- + /* + if (argc>1) { // look out for round or circular led command + if (strncmp(argv[1],"-c",2)) { + // paint circular + printf("painting circular led\n"); + widget.kled_round = true; + } + else if (strncmp(argv[1],"-r",2)) { + // paint rectangle + printf("painting rectangular led\n"); + widget.kled_round = false; + } + } + */ + a.setMainWidget(&widget); + widget.show(); + return a.exec(); // go +} + +#include "kledtest.moc" + diff --git a/tdeui/tests/kledtest.h b/tdeui/tests/kledtest.h new file mode 100644 index 000000000..5d660f5a3 --- /dev/null +++ b/tdeui/tests/kledtest.h @@ -0,0 +1,56 @@ +#ifndef kledtest_h +#define kledtest_h + +#include +#include +#include +#include + +class KLedTest : public TQWidget +{ + Q_OBJECT +protected: + TQTimer timer; + KLed *leds[/*KLed::NoOfShapes*/2* /*KLed::NoOfLooks*/3* /*KLed::NoOfStates*/2]; + const int LedWidth; + const int LedHeight; + const int Grid; + KLed::Shape tqshape; + KLed::Look look; + KLed::State state; + int x, y, index; + + + TQTimer t_toggle, t_color, t_look; + //KLed *l; // create lamp + //KLed *l; // create lamp + KLed *l; // create lamp + //KLed *l; // create lamp + //KLed *l; // create lamp + int ledcolor; + KLed::Look ledlook; + + const TQColor red; + const TQColor blue; + const TQColor green; + const TQColor yellow; + +public: + + KLedTest(TQWidget* parent=0); + ~KLedTest(); + + bool kled_round; + + +public slots: + void timeout(); + + void nextColor(); + void nextLook(); + + +}; + +#endif + diff --git a/tdeui/tests/klineeditdlgtest.cpp b/tdeui/tests/klineeditdlgtest.cpp new file mode 100644 index 000000000..e43085c0c --- /dev/null +++ b/tdeui/tests/klineeditdlgtest.cpp @@ -0,0 +1,19 @@ +#include +#include + +#include +#include + +int main(int argc, char** argv) +{ + KApplication app(argc, argv, "klineedittest"); + KLineEditDlg dialog( "_text", "_value", 0L ); + if(dialog.exec()) + { + qDebug("Accepted."); + } else { + qDebug("Rejected."); + } + return 0; +} + diff --git a/tdeui/tests/klineedittest.cpp b/tdeui/tests/klineedittest.cpp new file mode 100644 index 000000000..3508982fa --- /dev/null +++ b/tdeui/tests/klineedittest.cpp @@ -0,0 +1,137 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "klineedittest.h" + +KLineEditTest::KLineEditTest (TQWidget* widget, const char* name ) + :TQWidget( widget, name ) +{ + TQVBoxLayout* layout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() ); + + TQStringList list; + list << "Tree" << "Suuupa" << "Stroustrup" << "Stone" << "Slick" + << "Slashdot" << "Send" << "Peables" << "Mankind" << "Ocean" + << "Chips" << "Computer" << "Sandworm" << "Sandstorm" << "Chops"; + list.sort(); + + m_lineedit = new KLineEdit( this, "klineedittest" ); + m_lineedit->completionObject()->setItems( list ); + m_lineedit->setFixedSize(500,30); + m_lineedit->setEnableSqueezedText( true ); + connect( m_lineedit, TQT_SIGNAL( returnPressed() ), TQT_SLOT( slotReturnPressed() ) ); + connect( m_lineedit, TQT_SIGNAL( returnPressed(const TQString&) ), + TQT_SLOT( slotReturnPressed(const TQString&) ) ); + + TQHBox *hbox = new TQHBox (this); + m_btnExit = new TQPushButton( "E&xit", hbox ); + m_btnExit->setFixedSize(100,30); + connect( m_btnExit, TQT_SIGNAL( clicked() ), TQT_SLOT( quitApp() ) ); + + m_btnReadOnly = new TQPushButton( "&Read Only", hbox ); + m_btnReadOnly->setToggleButton (true); + m_btnReadOnly->setFixedSize(100,30); + connect( m_btnReadOnly, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( slotReadOnly(bool) ) ); + + m_btnEnable = new TQPushButton( "Dis&able", hbox ); + m_btnEnable->setToggleButton (true); + m_btnEnable->setFixedSize(100,30); + connect( m_btnEnable, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( slotEnable(bool) ) ); + + m_btnHide = new TQPushButton( "Hi&de", hbox ); + m_btnHide->setFixedSize(100,30); + connect( m_btnHide, TQT_SIGNAL( clicked() ), TQT_SLOT( slotHide() ) ); + + layout->addWidget( m_lineedit ); + layout->addWidget( hbox ); + setCaption( "KLineEdit Unit Test" ); +} + +KLineEditTest::~KLineEditTest() +{ +} + +void KLineEditTest::quitApp() +{ + kapp->closeAllWindows(); +} + +void KLineEditTest::show() +{ + if (m_lineedit->isHidden()) + m_lineedit->show(); + + m_btnHide->setEnabled( true ); + + TQWidget::show(); +} + +void KLineEditTest::slotReturnPressed() +{ + kdDebug() << "Return pressed" << endl; +} + +void KLineEditTest::slotReturnPressed( const TQString& text ) +{ + kdDebug() << "Return pressed: " << text << endl; +} + +void KLineEditTest::resultOutput( const TQString& text ) +{ + kdDebug() << "KlineEditTest Debug: " << text << endl; +} + +void KLineEditTest::slotReadOnly( bool ro ) +{ + m_lineedit->setReadOnly (ro); + TQString text = (ro) ? "&Read Write" : "&Read Only"; + m_btnReadOnly->setText (text); +} + +void KLineEditTest::slotEnable (bool enable) +{ + m_lineedit->setEnabled (!enable); + TQString text = (enable) ? "En&able":"Dis&able"; + m_btnEnable->setText (text); +} + +void KLineEditTest::slotHide() +{ + m_lineedit->hide(); + m_btnHide->setEnabled( false ); + m_lineedit->setText( "My dog ate the homework, whaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaa! I want my mommy!" ); + TQTimer::singleShot( 1000, this, TQT_SLOT(show()) ); +} + +int main ( int argc, char **argv) +{ + KAboutData aboutData( "klineedittest", "klineedittest", "1.0" ); + KCmdLineArgs::init(argc, argv, &aboutData); + KApplication::addCmdLineOptions(); + + KApplication a; + KLineEditTest *t = new KLineEditTest(); + //t->lineEdit()->setTrapReturnKey( true ); + //t->lineEdit()->completionBox()->setTabHandling( false ); + t->lineEdit()->setEnableSqueezedText( true ); + t->lineEdit()->setText ("This is a really really really really really really " + "really really long line because I am a talkative fool!"); + a.setMainWidget(t); + t->show(); + return a.exec(); +} + +#include "klineedittest.moc" diff --git a/tdeui/tests/klineedittest.h b/tdeui/tests/klineedittest.h new file mode 100644 index 000000000..6fee4dbc4 --- /dev/null +++ b/tdeui/tests/klineedittest.h @@ -0,0 +1,41 @@ +#ifndef _KLINEEDITTEST_H +#define _KLINEEDITTEST_H + +#include +#include + +class TQString; +class TQPushButton; + +class KLineEdit; + +class KLineEditTest : public TQWidget +{ + Q_OBJECT + +public: + KLineEditTest( TQWidget *parent=0, const char *name=0 ); + ~KLineEditTest(); + KLineEdit* lineEdit() const { return m_lineedit; } + +public slots: + virtual void show (); + +private slots: + void quitApp(); + void slotHide(); + void slotEnable( bool ); + void slotReadOnly( bool ); + void slotReturnPressed(); + void resultOutput( const TQString& ); + void slotReturnPressed( const TQString& ); + +protected: + TQGuardedPtr m_lineedit; + TQPushButton* m_btnExit; + TQPushButton* m_btnReadOnly; + TQPushButton* m_btnEnable; + TQPushButton* m_btnHide; +}; + +#endif diff --git a/tdeui/tests/klistviewtest.cpp b/tdeui/tests/klistviewtest.cpp new file mode 100644 index 000000000..6189c76e9 --- /dev/null +++ b/tdeui/tests/klistviewtest.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include + + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "klistviewtest" ); + KDialogBase dialog; + KListView *view = new KListView( dialog.makeVBoxMainWidget() ); + view->setSelectionModeExt( KListView::FileManager ); + view->setDragEnabled( true ); + view->setItemsMovable( false ); + view->setAcceptDrops( true ); + view->addColumn("Column 1"); + view->addColumn("Column 2"); + view->addColumn("Column 3"); + + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 1"); + new KListViewItem( view, "Item 2", "Some more", "Hi Mom :)" ); + + view->restoreLayout( KGlobal::config(), "ListView" ); + + new KListViewItem( view, "Item 3" ); + + dialog.exec(); + view->saveLayout( KGlobal::config(), "ListView" ); + + return 0; +} diff --git a/tdeui/tests/kmainwindowrestoretest.cpp b/tdeui/tests/kmainwindowrestoretest.cpp new file mode 100644 index 000000000..7415085ac --- /dev/null +++ b/tdeui/tests/kmainwindowrestoretest.cpp @@ -0,0 +1,41 @@ + +#include "kmainwindowrestoretest.h" + +#include + +#include + +#define MAKE_WINDOW( kind, title ) do { \ + MainWin##kind * m = new MainWin##kind; \ + m->setCaption( title ); \ + m->setCentralWidget( new TQLabel( title, m ) ); \ + m->show(); \ +} while ( false ) + +int main( int argc, char * argv[] ) { + + KApplication app( argc, argv, "kmainwindowrestoretest" ); + + if ( kapp->isRestored() ) { + kRestoreMainWindows< MainWin1, MainWin2, MainWin3 >(); + kRestoreMainWindows< MainWin4, MainWin5 >(); + RESTORE(MainWin6); + //kRestoreMainWindows< MainWin6 >(); // should be equivalent to RESTORE() + } else { + MAKE_WINDOW( 1, "First 1" ); + MAKE_WINDOW( 1, "Second 1" ); + MAKE_WINDOW( 2, "Only 2" ); + MAKE_WINDOW( 3, "First 3" ); + MAKE_WINDOW( 4, "First 4" ); + MAKE_WINDOW( 4, "Second 4" ); + MAKE_WINDOW( 3, "Second 3" ); + MAKE_WINDOW( 4, "Third 4" ); + MAKE_WINDOW( 5, "First 5" ); + MAKE_WINDOW( 5, "Second 5" ); + MAKE_WINDOW( 1, "Only 6" ); + } + + return app.exec(); +} + +#include "kmainwindowrestoretest.moc" diff --git a/tdeui/tests/kmainwindowrestoretest.h b/tdeui/tests/kmainwindowrestoretest.h new file mode 100644 index 000000000..7bd535f74 --- /dev/null +++ b/tdeui/tests/kmainwindowrestoretest.h @@ -0,0 +1,48 @@ +#ifndef _KDEUI_TESTS_KMAINWINDOWRESTORETEST_H_ +#define _KDEUI_TESTS_KMAINWINDOWRESTORETEST_H_ + +#include + +class MainWin1 : public KMainWindow { + Q_OBJECT +public: + MainWin1() : KMainWindow() {} + virtual ~MainWin1() {} +}; + +class MainWin2 : public KMainWindow { + Q_OBJECT +public: + MainWin2() : KMainWindow() {} + virtual ~MainWin2() {} +}; + +class MainWin3 : public KMainWindow { + Q_OBJECT +public: + MainWin3() : KMainWindow() {} + virtual ~MainWin3() {} +}; + +class MainWin4 : public KMainWindow { + Q_OBJECT +public: + MainWin4() : KMainWindow() {} + virtual ~MainWin4() {} +}; + +class MainWin5 : public KMainWindow { + Q_OBJECT +public: + MainWin5() : KMainWindow() {} + virtual ~MainWin5() {} +}; + +class MainWin6 : public KMainWindow { + Q_OBJECT +public: + MainWin6() : KMainWindow() {} + virtual ~MainWin6() {} +}; + +#endif // _KDEUI_TESTS_KMAINWINDOWRESTORETEST_H_ diff --git a/tdeui/tests/kmainwindowtest.cpp b/tdeui/tests/kmainwindowtest.cpp new file mode 100644 index 000000000..5b7afd36f --- /dev/null +++ b/tdeui/tests/kmainwindowtest.cpp @@ -0,0 +1,38 @@ +#include +#include + +#include +#include +#include + +#include "kmainwindowtest.h" + +MainWindow::MainWindow() +{ + TQTimer::singleShot( 2*1000, this, TQT_SLOT( showMessage() ) ); + + setCentralWidget( new TQLabel( "foo", this ) ); + + menuBar()->insertItem( "hi" ); +} + +void MainWindow::showMessage() +{ + statusBar()->show(); + statusBar()->message( "test" ); +} + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "kmainwindowtest" ); + + MainWindow* mw = new MainWindow; // deletes itself when closed + mw->show(); + + return app.exec(); +} + +#include "kmainwindowtest.moc" + +/* vim: et sw=4 ts=4 + */ diff --git a/tdeui/tests/kmainwindowtest.h b/tdeui/tests/kmainwindowtest.h new file mode 100644 index 000000000..4fb426ac5 --- /dev/null +++ b/tdeui/tests/kmainwindowtest.h @@ -0,0 +1,18 @@ +#ifndef KMAINWINDOWTEST_H +#define KMAINWINDOWTEST_H + +#include + +class MainWindow : public KMainWindow +{ + Q_OBJECT +public: + MainWindow(); + +private slots: + void showMessage(); +}; + +#endif // KMAINWINDOWTEST_H +/* vim: et sw=4 ts=4 + */ diff --git a/tdeui/tests/kmessageboxtest.cpp b/tdeui/tests/kmessageboxtest.cpp new file mode 100644 index 000000000..e63d24fca --- /dev/null +++ b/tdeui/tests/kmessageboxtest.cpp @@ -0,0 +1,242 @@ +#include "kmessagebox.h" + +#include +#include + +#include + +#include + +#include +#include + +#include + +class ExampleWidget : public QLabel +{ +public: + ExampleWidget( TQWidget *parent = 0, const char *name = 0 ); +}; + +ExampleWidget::ExampleWidget( TQWidget *parent, const char *name ) + : TQLabel(parent, name ) +{ + // Make the top-level layout; a vertical box to contain all widgets + // and sub-layouts. + TQSize sh; + setText("

Hello.

"); + sh = tqsizeHint(); + qWarning("SizeHint = %d x %d", sh.width(), sh.height()); + setText("Hello."); + sh = tqsizeHint(); + qWarning("SizeHint = %d x %d", sh.width(), sh.height()); + setText("

Hello
World

"); + sh = tqsizeHint(); + qWarning("SizeHint = %d x %d", sh.width(), sh.height()); +// setText("Hello\nWorld"); + sh = tqsizeHint(); + qWarning("SizeHint = %d x %d", sh.width(), sh.height()); + setMinimumSize(tqsizeHint()); +} + + +class Foo: public QDialog +{ + public: + Foo() : TQDialog(0, "foo", true) { resize(200,200); new TQLabel("Hello World", this); show(); } +}; + +void showResult(int test, int i) +{ + printf("%d. returned %d ", test, i); + switch( i) { + case KMessageBox::Ok : printf("(%s)\n", "Ok"); break; + case KMessageBox::Cancel : printf("(%s)\n", "Cancel"); break; + case KMessageBox::Yes : printf("(%s)\n", "Yes"); break; + case KMessageBox::No : printf("(%s)\n", "No"); break; + case KMessageBox::Continue : printf("(%s)\n", "Continue"); break; + default: printf("(%s)\n", "ERROR!"); exit(1); + } +} + + +int main( int argc, char *argv[] ) +{ + int i, test; + new KApplication( argc, argv, "MyApplication" ); + + ExampleWidget *w = new ExampleWidget(); + w->show(); + w->deleteLater(); + + TQStringList list; list.append("Hello"); list.append("World"); + + for( test = 1; true; test++) + { + switch(test) + { +case 1: + i = KMessageBox::warningContinueCancel(w, + "You are about to .\n" + "Are you sure?", + "Print", TQString::tqfromLatin1("&Print"), "dontask", false); + i = KMessageBox::warningContinueCancel(0, + "You are about to .\n" + "Are you sure?", + "Print", TQString::tqfromLatin1("&Print"), "dontask", KMessageBox::AllowLink); + i = KMessageBox::questionYesNo(0, "

Do you have a printer? thisisaverylongdkldhklghklghklashgkllasghkdlsghkldfghklsabla bla bbla bla. It also has this URL.

", + TQString("Bla"), TQString("Yes"), TQString("No"), "bla", KMessageBox::AllowLink); + break; + +case 2: + i = KMessageBox::questionYesNo(0, "Do you have a printer?", + TQString("Printer setup"), TQString::null); + break; + +case 3: + i = KMessageBox::questionYesNo(0, + "Does your printer support color or only black and white?", + "Printer setup", TQString::tqfromLatin1("&Color"), TQString::tqfromLatin1("&Black & White")); + break; + +case 4: + i = KMessageBox::warningYesNo(0, + "KDVI could not locate the program 'dvipdfm' on your computer. That program is " + "absolutely needed by the export function. You can, however, convert " + "the DVI-file to PDF using the print function of KDVI, but that will often " + "produce files which print ok, but are of inferior quality if viewed in the " + "Acrobat Reader. It may be wise to upgrade to a more recent version of your " + "TeX distribution which includes the 'dvipdfm' program.\n" + "Hint to the perplexed system administrator: KDVI uses the shell's PATH variable " + "when looking for programs." + ); + break; + + +case 5: + i = KMessageBox::warningYesNo(0, "Your printer has been added.\n" + "Do you want to update your configuration?", + "Printer Setup"); + break; + +case 6: + i = KMessageBox::warningContinueCancel(0, + "You are about to print.\n" + "Are you sure?", + "Print", TQString::tqfromLatin1("&Print")); + break; +case 7: + i = KMessageBox::warningContinueCancel(0, + "You are about to .\n" + "Are you sure?", + "Print", TQString::tqfromLatin1("&Print"), "dontask", false); + break; + +case 8: + i = KMessageBox::warningYesNoCancel(0, + "Your document contains unsaved changes.\n" + "Do you want to save your changes?\n"); + break; + +case 9: + i = KMessageBox::warningYesNoCancel(0, + "Your document contains unsaved changes.\n" + "Do you want to save your changes?\n", + TQString::tqfromLatin1("Close")); + break; + +case 10: + i = KMessageBox::warningYesNoCancel(0, + "Your document contains unsaved changes.\n" + "Do you want to save or discard your changes?\n", + "Close", TQString::tqfromLatin1("&Save"), TQString::tqfromLatin1("&Discard") ); + break; + +case 11: + i = KMessageBox::Ok; + KMessageBox::error(0, "Oops, Your harddisk is unreadable."); + break; + +case 12: + i = KMessageBox::Ok; + KMessageBox::error(0, "Oops, Your harddisk is unreadable." , "Uh ooh"); + break; + +case 13: + i = KMessageBox::Ok; + KMessageBox::sorry(0, "Sorry, Your harddisk appears to be empty."); + break; + +case 14: + i = KMessageBox::Ok; + KMessageBox::sorry(0, "Sorry, Your harddisk appears to be empty.", "Oops"); + break; + +case 15: + i = KMessageBox::Ok; + KMessageBox::information(0, "You can enable the menubar again " + "with the right mouse button menu."); + break; + +case 16: + i = KMessageBox::Ok; + KMessageBox::information(0, "You can enable the menubar again " + "with the right mouse button menu.", "Menubar Info"); + break; + +case 17: + i = KMessageBox::Ok; + KMessageBox::information(0, "You can enable the menubar again\nwith the right mouse button menu.", TQString::null, "Enable_Menubar"); + break; + +case 18: + i = KMessageBox::Ok; + KMessageBox::enableAllMessages(); + break; + +case 19: + i = KMessageBox::Ok; + KMessageBox::information(0, "Return of the annoying popup message.", TQString::null, "Enable_Menubar"); + break; +case 20: + { + TQStringList strlist; + strlist << "/dev/hda" << "/etc/inittab" << "/usr/somefile" << "/some/really/" + "long/file/name/which/is/in/a/really/deep/directory/in/a/really/large/" + "hard/disk/of/your/system" << "/and/another/one" ; + i = KMessageBox::questionYesNoList(0, "Do you want to delete the following files ?",strlist); + } + break; +case 21: + { + TQStringList strlist; + printf("Filling StringList...\n"); + for (int j=1;j<=6000;j++) strlist.append(TQString("/tmp/tmp.%1").arg(j)); + printf("Completed...\n"); + i = KMessageBox::questionYesNoList(0, "Do you want to delete the following files ?",strlist); + } + break; + +case 22: + i = KMessageBox::Ok; + KMessageBox::informationList(0, "The following words have been found:",list); + break; + +case 23: + i = KMessageBox::Ok; + KMessageBox::informationList(0, "The following words have been found:", list, "Search Words"); + break; + +case 24: + i = KMessageBox::Ok; + KMessageBox::informationList(0, "The follwoing words have been found:", list, TQString::null, "Search_Words"); + break; + +default: + return 0; + } // Switch + + showResult(test, i); + } // Test +} + diff --git a/tdeui/tests/knuminputtest.cpp b/tdeui/tests/knuminputtest.cpp new file mode 100644 index 000000000..fdf8697e9 --- /dev/null +++ b/tdeui/tests/knuminputtest.cpp @@ -0,0 +1,145 @@ +/* +* Tests the KNumInput Widget class +* +* Copyright (c) 1999 by Dirk A. Mueller +* +* License: GPL, version 2 +* Version: $Id: +* +*/ + +#include +#include + +#include +#include + +#include "knuminputtest.h" + +KApplication *a; + +#include +void TopLevel::slotPrint( int n ) { + kdDebug() << "slotPrint( " << n << " )" << endl; +} +void TopLevel::slotPrint( double n ) { + kdDebug() << "slotPrint( " << n << " )" << endl; +} + +#define conn(x,y) connect( x, TQT_SIGNAL(valueChanged(y)), TQT_SLOT(slotPrint(y))) +TopLevel::TopLevel(TQWidget *parent, const char *name) + : TQWidget(parent, name) +{ + setCaption("KNumInput test application"); + + TQBoxLayout* l = new TQHBoxLayout(this, 10); + + TQGroupBox* b1 = new TQVGroupBox("KIntNumInput", this); + + i1 = new KIntNumInput(42, b1, 10, "perc_no_slider"); + i1->setLabel("percent of usage (no slider)"); + i1->setRange(0, 100, 5, false); + conn(i1,int); + + i2 = new KIntNumInput(i1, 42, b1); + i2->setLabel("percentage of usage (with slider)"); + i2->setRange(0, 100, 5); + i2->setSuffix(" %"); + conn(i2,int); + + i3 = new KIntNumInput(i2, 0xAF, b1, 16); + i3->setLabel("Hex byte (no slider)"); + i3->setRange(0, 255, 1, false); + i3->setSuffix(" (hex)"); + conn(i3,int); + + i4 = new KIntNumInput(i3, 0xfe, b1, 16); + i4->setLabel("Hex byte (with slider)"); + i4->setRange(0, 255, 1); + conn(i4,int); + + i5 = new KIntNumInput(i4, 10, b1, 10); + i5->setLabel("Width (keeps aspect ratio):"); + i5->setRange(0, 200, 1, false); + i5->setReferencePoint( 5 ); + + i6 = new KIntNumInput(i5, 20, b1, 10); + i6->setLabel("Height (should be 2xWidth):"); + i6->setRange(0, 200, 1, false); + i6->setReferencePoint( 10 ); + connect( i5, TQT_SIGNAL(relativeValueChanged(double)), + i6, TQT_SLOT(setRelativeValue(double)) ); + connect( i6, TQT_SIGNAL(relativeValueChanged(double)), + i5, TQT_SLOT(setRelativeValue(double)) ); + + i7 = new KIntNumInput(i6, 0, b1, 10); + i7->setLabel("math test:", AlignVCenter|AlignLeft ); + i7->setRange( INT_MIN, INT_MAX, 1 ); + conn(i7,int); + + l->addWidget(b1); + + TQGroupBox* b2 = new TQVGroupBox("KDoubleNumInput", this); + + d1 = new KDoubleNumInput(4.0, b2, "perc_double_no_slider"); + d1->setLabel("percent of usage (no slider)", AlignTop | AlignRight); + d1->setRange(0.0, 4000.0, 0.01, false); + //d1->setValue(1.00000000000000000001); + conn(d1,double); + + d2 = new KDoubleNumInput(d1, 0.422, b2, "perc_double_with_slider"); + d2->setLabel("percentage of usage (with slider)", AlignBottom | AlignLeft); + d2->setRange(0, 1.0, 0.005); + d2->setSuffix("%"); + conn(d2,double); + + d3 = new KDoubleNumInput(d2, 16.20, b2); + d3->setLabel("cash: ", AlignVCenter | AlignHCenter); + d3->setRange(0.10, 100, 0.1); + d3->setPrefix("p"); + d3->setSuffix("$"); + conn(d3,double); + + d4 = new KDoubleNumInput(d3, INT_MAX/10000.0, b2); + d4->setPrecision(3); + d4->setRange(double(INT_MIN+1)/1000.0, double(INT_MAX)/1000.0, 1); + d4->setLabel("math test: ", AlignVCenter | AlignLeft); +// d4->setFormat("%g"); + conn(d4,double); + + d5 = new KDoubleNumInput(d4, double(INT_MIN+1)/1e9, double(INT_MAX-1)/1e9, + 0.1, 0.001, 9, b2, "d5"); + d5->setLabel("math test 2: ", AlignVCenter|AlignLeft); + conn(d5,double); + + d6 = new KDoubleNumInput(d5, -10, 10, 0, 0.001, 3, b2, "d6"); + d6->setLabel("aspect ratio test with a negative ratio:"); + d6->setReferencePoint( 1 ); + + d7 = new KDoubleNumInput(d6, -30, 30, 0, 0.001, 3, b2, "d7"); + d7->setReferencePoint( -3 ); + + connect( d6, TQT_SIGNAL(relativeValueChanged(double)), + d7, TQT_SLOT(setRelativeValue(double)) ); + connect( d7, TQT_SIGNAL(relativeValueChanged(double)), + d6, TQT_SLOT(setRelativeValue(double)) ); + + l->addWidget(b2); +} + + + + +int main( int argc, char ** argv ) +{ + a = new KApplication ( argc, argv, "KNuminputTest" ); + + TopLevel *toplevel = new TopLevel(0, "knuminputtest"); + + toplevel->show(); + a->setMainWidget(toplevel); + a->exec(); +} + +#include "knuminputtest.moc" + diff --git a/tdeui/tests/knuminputtest.h b/tdeui/tests/knuminputtest.h new file mode 100644 index 000000000..32a9e9098 --- /dev/null +++ b/tdeui/tests/knuminputtest.h @@ -0,0 +1,23 @@ +#ifndef _KNUMINPUTTEST_H +#define _KNUMINPUTTEST_H + +#include + +class KIntNumInput; +class KDoubleNumInput; + +class TopLevel : public TQWidget +{ + Q_OBJECT +public: + + TopLevel( TQWidget *parent=0, const char *name=0 ); +protected: + KIntNumInput* i1, *i2, *i3, *i4, *i5, *i6, *i7; + KDoubleNumInput* d1, *d2, *d3, *d4, *d5, *d6, *d7; +protected slots: + void slotPrint( int ); + void slotPrint( double ); +}; + +#endif diff --git a/tdeui/tests/kpalettetest.cpp b/tdeui/tests/kpalettetest.cpp new file mode 100644 index 000000000..32b91ff96 --- /dev/null +++ b/tdeui/tests/kpalettetest.cpp @@ -0,0 +1,38 @@ + +#include +#include +#include +#include +#include "kpalette.h" +#include "kledtest.h" +#include + +#include + + +int main( int argc, char **argv ) +{ + KApplication a( argc, argv, "KPalettetest" ); + + TQStringList palettes = KPalette::getPaletteList(); + for(TQStringList::ConstIterator it = palettes.begin(); + it != palettes.end(); it++) + { + printf("Palette = %s\n", (*it).ascii()); + + KPalette myPalette = KPalette(*it); + + printf("Palette Name = \"%s\"\n", myPalette.name().ascii()); + printf("Description:\n\"%s\"\n", myPalette.description().ascii()); + printf("Nr of Colors = %d\n", myPalette.nrColors()); + for(int i = 0; i < myPalette.nrColors(); i++) + { + int r,g,b; + myPalette.color(i).rgb(&r, &g, &b); + printf("#%d Name = \"%s\" #%02x%02x%02x\n", + i, myPalette.colorName(i).ascii(), r,g,b); + } + } +} + + diff --git a/tdeui/tests/kpanelmenutest.cpp b/tdeui/tests/kpanelmenutest.cpp new file mode 100644 index 000000000..e081e467f --- /dev/null +++ b/tdeui/tests/kpanelmenutest.cpp @@ -0,0 +1,72 @@ +#include "kpanelmenutest.h" +#include +#include +#include + +TestWidget::TestWidget(TQWidget *parent, const char *name) + : TQLabel(parent, name) +{ + testMenu = new KPanelAppMenu(locate("mini", "x.png"), "Client Test", this, + "menu1"); + + subMenu = testMenu->insertMenu(locate("mini", "x.png"), "Submenu Test"); + subMenu->insertItem(locate("mini", "bx2.png"), "First Entry", 100); + subMenu->insertItem(locate("mini", "bx2.png"), "Second Entry", 101); + + KPanelAppMenu *ssub = subMenu->insertMenu(locate("mini", "x.png"), "One more"); + + connect(testMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(slotMenuCalled(int))); + connect(subMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSubMenuCalled(int))); + init(); + + setText("We added \"Client Test\" to kicker. Click the K Menu to check."); + resize(tqsizeHint()); +} + +void TestWidget::init() +{ + testMenu->insertItem(locate("mini", "bx2.png"), + "Add another entry!", 1); + testMenu->insertItem("Attention, this will clear the menu", 2); +} + +void TestWidget::slotMenuCalled(int id) +{ + switch ( id ) { + case 1: + setText("Selected \"Add another entry!\" "); + testMenu->insertItem("Another entry"); + break; + case 2: + setText("Selected \"Attention, this will clear the menu\""); + testMenu->clear(); + init(); + break; + default: + setText("Selected \"Another entry...\""); + } +} + + +void TestWidget::slotSubMenuCalled(int id) +{ + TQString msg("Called with id=%1"); + setText(msg.arg(id)); +} + + +int main(int argc, char **argv) +{ + KApplication *app = new KApplication(argc, argv, "menutest"); + + TestWidget w; + app->setMainWidget(&w); + w.show(); + + app->exec(); +} + +#include "kpanelmenutest.moc" + + + diff --git a/tdeui/tests/kpanelmenutest.h b/tdeui/tests/kpanelmenutest.h new file mode 100644 index 000000000..361ae545a --- /dev/null +++ b/tdeui/tests/kpanelmenutest.h @@ -0,0 +1,21 @@ +#ifndef __KPANELMENUTEST_H +#define __KPANELMENUTEST_H + +#include +#include + +class TestWidget : public TQLabel +{ + Q_OBJECT +public: + TestWidget(TQWidget *parent=0, const char *name=0); + ~TestWidget(){delete testMenu;} +public slots: + void slotMenuCalled(int id); + void slotSubMenuCalled(int id); +private: + void init(); + KPanelAppMenu *testMenu, *subMenu; +}; + +#endif diff --git a/tdeui/tests/kpixmapregionselectordialogtest.cpp b/tdeui/tests/kpixmapregionselectordialogtest.cpp new file mode 100644 index 000000000..c698c66f2 --- /dev/null +++ b/tdeui/tests/kpixmapregionselectordialogtest.cpp @@ -0,0 +1,33 @@ +#include "kpixmapregionselectordialog.h" +#include +#include +#include +#include +#include + +static const KCmdLineOptions options[] = +{ + { "+file", "The image file to open", 0 }, + KCmdLineLastOption +}; + +int main(int argc, char**argv) +{ + KCmdLineArgs::init(argc, argv, "test", "test" ,"test" ,"1.0"); + KCmdLineArgs::addCmdLineOptions( options ); + KApplication app("test"); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + if (args->count()!=1) + { + std::cout << "Usage: kpixmapregionselectordialogtest " << std::endl; + return 1; + } + + TQImage image= + KPixmapRegionSelectorDialog::getSelectedImage(TQPixmap(args->arg(0)),100,100); + + image.save("output.png", "PNG"); + + return 0; +} diff --git a/tdeui/tests/kpopuptest.cpp b/tdeui/tests/kpopuptest.cpp new file mode 100644 index 000000000..3db71106b --- /dev/null +++ b/tdeui/tests/kpopuptest.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include "kpopupmenu.h" + +class DemoWidget : public TQWidget { +private: + KPopupMenu *menu; + +void mousePressEvent(TQMouseEvent *) +{ + menu->popup(TQCursor::pos()); +} + +void paintEvent(TQPaintEvent *) +{ + drawText(32, 32, "Press a Mouse Button!"); +} + +public: + DemoWidget() : TQWidget() + { + menu = new KPopupMenu("Popup Menu:"); + menu->insertItem("Item1"); + menu->insertItem("Item2"); + menu->insertSeparator(); + menu->insertItem("Quit", tqApp, TQT_SLOT(quit())); + } +}; + +int main(int argc, char **argv) +{ + KApplication app(argc, argv, "kpopupmenutest"); + DemoWidget w; + app.setMainWidget(&w); + w.setFont(TQFont("helvetica", 12, TQFont::Bold), true); + w.show(); + return app.exec(); +} + diff --git a/tdeui/tests/kprogresstest.cpp b/tdeui/tests/kprogresstest.cpp new file mode 100644 index 000000000..7b7024135 --- /dev/null +++ b/tdeui/tests/kprogresstest.cpp @@ -0,0 +1,58 @@ +#include +#include +#include "kprogress.h" + + +class MyWidget : public TQWidget { +public: + MyWidget() : TQWidget() + { + setFixedSize(440, 80); + Progress = new KProgress(this); + Progress->resize(400, 40); + Progress->move(20, 20); + startTimer(50); + } + +private: + KProgress *Progress; + + void timerEvent(TQTimerEvent *); +}; + +void MyWidget::timerEvent(TQTimerEvent *) +{ + static enum { fwd, back } direction = fwd; + //static KProgress::BarStyle style = KProgress::Solid; + if (direction == fwd) + { + if (Progress->value() == Progress->maxValue()) + direction = back; + else + Progress->advance(1); + } + else + { + if (Progress->value() == 0 /*Progress->minValue()*/) + { + direction = fwd; + //style = (style == KProgress::Solid)? KProgress::Blocked : KProgress::Solid; + //Progress->setBarStyle(style); + } + else + Progress->advance(-1); + } +} + +int main(int argc, char *argv[]) +{ + KApplication app(argc, argv, "KProgressTest"); + MyWidget w; + + app.setMainWidget(&w); + + w.show(); + + int ret = app.exec(); + return ret; +} diff --git a/tdeui/tests/krulertest.cpp b/tdeui/tests/krulertest.cpp new file mode 100644 index 000000000..8d64a53f4 --- /dev/null +++ b/tdeui/tests/krulertest.cpp @@ -0,0 +1,375 @@ + + +#include "krulertest.h" + +#include "kruler.h" +#include +#include +#include + +/* +void +MyCheckBox::mouseReleaseEvent(QMouseEvent *e ) +{ + TQButton::mouseReleaseEvent(e); + if (); +} +*/ + +MouseWidget::MouseWidget( TQWidget *parent, const char *name, WFlags f ) + : TQFrame(parent, name, f) +{ +} + +void +MouseWidget::mousePressEvent( TQMouseEvent *e ) +{ + mouseButtonDown = true; + emit newXPos(e->x()); + emit newYPos(e->y()); +} + +void +MouseWidget::mouseReleaseEvent( TQMouseEvent * ) +{ mouseButtonDown = false; } + +void +MouseWidget::mouseMoveEvent( TQMouseEvent *e ) +{ + if (mouseButtonDown) { + emit newXPos(e->x()); + emit newYPos(e->y()); + } +} + +void +MouseWidget::resizeEvent( TQResizeEvent *r ) +{ + emit newWidth(r->size().width()); + emit newHeight(r->size().height()); +} + + +KRulerTest::KRulerTest( const char *name ) + : KMainWindow(0, name) +{ + mainframe = new TQFrame(this); + + layout = new TQGridLayout(mainframe, 2, 2); + + miniwidget = new TQFrame(mainframe); + miniwidget->setFrameStyle(TQFrame::WinPanel | TQFrame::Raised); + bigwidget = new MouseWidget(mainframe); + bigwidget->setFrameStyle(TQFrame::WinPanel | TQFrame::Sunken); + + // TQRect bwrect = bigwidget->frameRect(); + // qDebug("big rect: top%i left%i bottom%i right%i", + // bwrect.top(), bwrect.left(), bwrect.bottom(), bwrect.right()); + hruler = new KRuler(Horizontal, mainframe); + // hruler->setRange( bwrect.left(), bwrect.right() ); + hruler->setRange( 0, 1000 ); + // hruler->setOffset( bwrect.left() - bigwidget->frameRect().left() ); + hruler->setOffset( 0 ); + + vruler = new KRuler(Vertical, mainframe); + vruler->setFrameStyle(TQFrame::WinPanel | TQFrame::Sunken); + vruler->setOffset( 0 ); + vruler->setRange( 0, 1000 ); + + connect( bigwidget, TQT_SIGNAL(newXPos(int)), + hruler, TQT_SLOT(slotNewValue(int)) ); + connect( bigwidget, TQT_SIGNAL(newYPos(int)), + vruler, TQT_SLOT(slotNewValue(int)) ); + connect( bigwidget, TQT_SIGNAL(newWidth(int)), + TQT_SLOT(slotNewWidth(int)) ); + connect( bigwidget, TQT_SIGNAL(newHeight(int)), + TQT_SLOT(slotNewHeight(int)) ); + + layout->addWidget(miniwidget, 0, 0); + layout->addWidget(hruler, 0, 1); + layout->addWidget(vruler, 1, 0); + layout->addWidget(bigwidget, 1, 1); + + mouse_message = new TQLabel("Press and hold mouse button\nfor pointer movement", bigwidget); + mouse_message->adjustSize(); + mouse_message->move(4,4); + + showMarks = new TQGroupBox("Show which marks ?", bigwidget); + showMarks->setFixedSize(140, 160); + showMarks->move(330,4); + showTM = new TQCheckBox("show tiny marks", showMarks); + showTM->adjustSize(); + showTM->move(5,15); + showTM->setChecked(true); + connect(showTM, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotSetTinyMarks(bool)) ); + showLM = new TQCheckBox("show little marks", showMarks); + showLM->adjustSize(); + showLM->move(5,35); + showLM->setChecked(true); + connect(showLM, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotSetLittleMarks(bool)) ); + showMM = new TQCheckBox("show medium marks", showMarks); + showMM->adjustSize(); + showMM->move(5,55); + showMM->setChecked(true); + connect(showMM, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotSetMediumMarks(bool)) ); + showBM = new TQCheckBox("show big marks", showMarks); + showBM->adjustSize(); + showBM->move(5,75); + showBM->setChecked(true); + connect(showBM, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotSetBigMarks(bool)) ); + showEM = new TQCheckBox("show end marks", showMarks); + showEM->adjustSize(); + showEM->move(5,95); + showEM->setChecked(true); + connect(showEM, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotSetEndMarks(bool)) ); + showPT = new TQCheckBox("show ruler pointer", showMarks); + showPT->adjustSize(); + showPT->move(5,115); + showPT->setChecked(true); + connect(showPT, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotSetRulerPointer(bool)) ); + fixLen = new TQCheckBox("fix ruler length", showMarks); + fixLen->adjustSize(); + fixLen->move(5,135); + fixLen->setChecked(true); + connect(fixLen, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotFixRulerLength(bool)) ); + connect(fixLen, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotCheckLength(bool)) ); + + lineEdit = new TQGroupBox("Value of begin/end", bigwidget); + lineEdit->setFixedSize(140, 80); + lineEdit->move(330,4+160); + beginMark = new KIntNumInput(0, lineEdit); + beginMark->setRange(-1000, 1000, 1, false); + beginMark->move(5, 15); + beginMark->setFixedSize(beginMark->tqsizeHint()); + connect(beginMark, TQT_SIGNAL(valueChanged(int)), + hruler, TQT_SLOT(slotNewOffset(int)) ); + connect(beginMark, TQT_SIGNAL(valueChanged(int)), + vruler, TQT_SLOT(slotNewOffset(int)) ); + endMark = new KIntNumInput(0, lineEdit); + endMark->setRange(-1000, 1000, 1, false); + endMark->move(5, 35); + endMark->setFixedSize(endMark->tqsizeHint()); + connect(endMark, TQT_SIGNAL(valueChanged(int)), + hruler, TQT_SLOT(slotEndOffset(int)) ); + connect(endMark, TQT_SIGNAL(valueChanged(int)), + vruler, TQT_SLOT(slotEndOffset(int)) ); + lengthInput = new KIntNumInput(0, lineEdit); + lengthInput->setRange(-1000, 1000, 1, false); + lengthInput->move(5, 55); + lengthInput->setFixedSize(lengthInput->tqsizeHint()); + connect(lengthInput, TQT_SIGNAL(valueChanged(int)), + hruler, TQT_SLOT(slotEndOffset(int)) ); + connect(lengthInput, TQT_SIGNAL(valueChanged(int)), + vruler, TQT_SLOT(slotEndOffset(int)) ); + + + vertrot = new TQGroupBox("Value of rotate translate for Vert.", bigwidget); + vertrot->setFixedSize(140, 80); + vertrot->move(330,4+160+80+4); + transX = new KDoubleNumInput(0.0, vertrot); + transX->setRange(-1000, 1000, 1, false); + transX->move(5, 15); + transX->setFixedSize(transX->tqsizeHint()); + //transX->setLabel("transx", AlignLeft); + connect(transX, TQT_SIGNAL(valueChanged(double)), + TQT_SLOT(slotSetXTrans(double)) ); + transY = new KDoubleNumInput(-12.0, vertrot); + transY->setRange(-1000, 1000, 1, false); + transY->move(5, 35); + transY->setFixedSize(transY->tqsizeHint()); + //transY->setLabel("transy", AlignLeft); + connect(transY, TQT_SIGNAL(valueChanged(double)), + TQT_SLOT(slotSetYTrans(double)) ); + rotV = new KDoubleNumInput(90.0, vertrot); + rotV->setRange(-1000, 1000, 1, false); + rotV->move(5, 55); + rotV->setFixedSize(rotV->tqsizeHint()); + //rotV->setLabel("rot", AlignLeft); + connect(rotV, TQT_SIGNAL(valueChanged(double)), + TQT_SLOT(slotSetRotate(double)) ); + + + metricstyle = new TQButtonGroup("metric styles", bigwidget); + metricstyle->setFixedSize(100, 120); + metricstyle->move(330-110,4); + pixelmetric = new TQRadioButton("pixel", metricstyle); + pixelmetric->adjustSize(); + pixelmetric->move(5,15); + metricstyle->insert(pixelmetric, (int)KRuler::Pixel); + inchmetric = new TQRadioButton("inch", metricstyle); + inchmetric->adjustSize(); + inchmetric->move(5,35); + metricstyle->insert(inchmetric, (int)KRuler::Inch); + mmmetric = new TQRadioButton("millimeter", metricstyle); + mmmetric->adjustSize(); + mmmetric->move(5,55); + metricstyle->insert(mmmetric, (int)KRuler::Millimetres); + cmmetric = new TQRadioButton("centimeter", metricstyle); + cmmetric->adjustSize(); + cmmetric->move(5,75); + metricstyle->insert(cmmetric, (int)KRuler::Centimetres); + mmetric = new TQRadioButton("meter", metricstyle); + mmetric->adjustSize(); + mmetric->move(5,95); + metricstyle->insert(mmetric, (int)KRuler::Metres); + connect ( metricstyle, TQT_SIGNAL(clicked(int)), TQT_SLOT(slotSetMStyle(int)) ); + + setCentralWidget(mainframe); + + slotUpdateShowMarks(); +} + +KRulerTest::~KRulerTest() +{ + delete layout; + delete hruler; + delete vruler; + delete miniwidget; + delete bigwidget; + delete mainframe; +} + +void +KRulerTest::slotNewWidth(int width) +{ + hruler->setMaxValue(width); +} + +void +KRulerTest::slotNewHeight(int height) +{ + vruler->setMaxValue(height); +} + +void +KRulerTest::slotSetTinyMarks(bool set) +{ + hruler->setShowTinyMarks(set); + vruler->setShowTinyMarks(set); +} + +void +KRulerTest::slotSetLittleMarks(bool set) +{ + hruler->setShowLittleMarks(set); + vruler->setShowLittleMarks(set); +} + +void +KRulerTest::slotSetMediumMarks(bool set) +{ + hruler->setShowMediumMarks(set); + vruler->setShowMediumMarks(set); +} + +void +KRulerTest::slotSetBigMarks(bool set) +{ + hruler->setShowBigMarks(set); + vruler->setShowBigMarks(set); +} + +void +KRulerTest::slotSetEndMarks(bool set) +{ + hruler->setShowEndMarks(set); + vruler->setShowEndMarks(set); +} + +void +KRulerTest::slotSetRulerPointer(bool set) +{ + hruler->setShowPointer(set); + vruler->setShowPointer(set); +} + +void +KRulerTest::slotSetRulerLength(int len) +{ + hruler->setLength(len); + vruler->setLength(len); +} + +void +KRulerTest::slotFixRulerLength(bool fix) +{ + hruler->setLengthFixed(fix); + vruler->setLengthFixed(fix); +} + +void +KRulerTest::slotSetMStyle(int style) +{ + hruler->setRulerMetricStyle((KRuler::MetricStyle)style); + vruler->setRulerMetricStyle((KRuler::MetricStyle)style); + slotUpdateShowMarks(); +} + + +void +KRulerTest::slotUpdateShowMarks() +{ + showTM->setChecked(hruler->showTinyMarks()); + showLM->setChecked(hruler->showLittleMarks()); + showMM->setChecked(hruler->showMediumMarks()); + showBM->setChecked(hruler->showBigMarks()); + showEM->setChecked(hruler->showEndMarks()); +} + +void +KRulerTest::slotCheckLength(bool fixlen) +{ + beginMark->setValue(hruler->offset()); + endMark->setValue(hruler->endOffset()); + lengthInput->setValue(hruler->length()); +} + +void +KRulerTest::slotSetRotate(double d) +{ +#ifdef KRULER_ROTATE_TEST + vruler->rotate = d; + vruler->update(); + //debug("rotate %.1f", d); +#endif +} + +void +KRulerTest::slotSetXTrans(double d) +{ +#ifdef KRULER_ROTATE_TEST + vruler->xtrans = d; + vruler->update(); + //debug("trans x %.1f", d); +#endif +} + +void +KRulerTest::slotSetYTrans(double d) +{ +#ifdef KRULER_ROTATE_TEST + vruler->ytrans = d; + vruler->update(); + //debug("trans y %.1f", d); +#endif +} + + +/* --- MAIN -----------------------*/ +int main(int argc, char **argv) +{ + KApplication *testapp; + KRulerTest *window; + + testapp = new KApplication(argc, argv,"krulertest"); + testapp->setFont(TQFont("Helvetica",12),true); + + window = new KRulerTest("main"); + testapp->setMainWidget(window); + window->setCaption("KRulerTest"); + window->show(); + return testapp->exec(); +} + +#include "krulertest.moc" + diff --git a/tdeui/tests/krulertest.h b/tdeui/tests/krulertest.h new file mode 100644 index 000000000..d180e93a0 --- /dev/null +++ b/tdeui/tests/krulertest.h @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ + +#ifndef krulertest_h +#define krulertest_h + +#include +#include +#include +#include +#include +#include +#include + +class KRuler; +class TQWidget; +class TQFrame; +class TQGridLayout; +class TQCheckBox; +class TQGroupBox; + + +class MouseWidget : public TQFrame +{ +Q_OBJECT +public: +MouseWidget( TQWidget *parent=0, const char *name=0, WFlags f=0 ); + +signals: + void newXPos(int); + void newYPos(int); + void newWidth(int); + void newHeight(int); + +protected: + virtual void mousePressEvent ( TQMouseEvent * ); + virtual void mouseReleaseEvent ( TQMouseEvent * ); + virtual void mouseMoveEvent ( TQMouseEvent * ); + virtual void resizeEvent ( TQResizeEvent * ); +private: + bool mouseButtonDown; + +}; + + +class KRulerTest : public KMainWindow +{ +Q_OBJECT +public: +KRulerTest( const char *name = 0L ); +~KRulerTest(); + +private slots: + void slotNewWidth(int); + void slotNewHeight(int); + + void slotSetTinyMarks(bool); + void slotSetLittleMarks(bool); + void slotSetMediumMarks(bool); + void slotSetBigMarks(bool); + void slotSetEndMarks(bool); + void slotSetRulerPointer(bool); + + void slotSetRulerLength(int); + void slotFixRulerLength(bool); + void slotSetMStyle(int); + void slotUpdateShowMarks(); + void slotCheckLength(bool); + + void slotSetRotate(double); + void slotSetXTrans(double); + void slotSetYTrans(double); + + +private: + + KRuler *hruler, *vruler; + TQGridLayout *layout; + TQFrame *miniwidget, *bigwidget; + TQFrame *mainframe; + + TQLabel *mouse_message; + TQGroupBox *showMarks, *lineEdit, *vertrot; + TQCheckBox *showTM, *showLM, *showMM, *showBM, *showEM, *showPT, *fixLen; + KIntNumInput *beginMark, *endMark, *lengthInput; + KDoubleNumInput *transX, *transY, *rotV; + TQButtonGroup *metricstyle; + TQRadioButton *pixelmetric, *inchmetric, *mmmetric, *cmmetric, *mmetric; + +}; +#endif + diff --git a/tdeui/tests/kseparatortest.cpp b/tdeui/tests/kseparatortest.cpp new file mode 100644 index 000000000..17e965ca8 --- /dev/null +++ b/tdeui/tests/kseparatortest.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 1997 Michael Roth + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + + +#include +#include +#include + +#include "kseparator.h" + + +int main(int argc, char **argv) +{ + TQApplication app(argc, argv); + + TQWidget *toplevel = new TQWidget(); + + TQBoxLayout *mainbox = new TQBoxLayout(toplevel, TQBoxLayout::TopToBottom, 10); + + KSeparator *sep1 = new KSeparator( KSeparator::VLine, toplevel ); + mainbox->addWidget(sep1); + + KSeparator *sep2 = new KSeparator( KSeparator::HLine, toplevel ); + mainbox->addWidget(sep2); + + mainbox->activate(); + + app.setMainWidget(toplevel); + toplevel->show(); + return app.exec(); +} + + + + diff --git a/tdeui/tests/kspelltest.cpp b/tdeui/tests/kspelltest.cpp new file mode 100644 index 000000000..9180ed376 --- /dev/null +++ b/tdeui/tests/kspelltest.cpp @@ -0,0 +1,57 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 David Sweet + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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 "kspell.h" +#include +#include + +#include +#include +#include + +int main(int argc, char **argv) +{ + KApplication *app = new KApplication(argc, argv, "KSpellTest"); + + // test ASCII + //TQString text( "I have noo idee of how to wride englisch or englisch" ); + + // test Latin-3 (need dictionary "esperanto" and "Latin3" in config) + //TQCString ctext( "sed jen: eĥoŝanĝ' ĉiuĵaŭde; eĥuŝunĝo ĝiun fendredon - kaj dimanĝon..."); + //TQTextCodec *codec = TQTextCodec::codecForName("ISO 8859-3"); + + // test UTF-8 (need dictionary "esperanto" and "UTF-8" in config) + TQCString ctext( "sed jen: e\304\245oĊanĝo ĉiuĵaĊ­de e\304\245uĊunĝo ĝiun fendredon kaj dimanĝon"); + TQTextCodec *codec = TQTextCodec::codecForName("UTF-8"); + + TQString text = codec->toUnicode(ctext.data()); + + KSpell::modalCheck( text ); + + kdDebug() << "Returned " << text << endl; + + return 0; + +} + + + + + + + diff --git a/tdeui/tests/ksqueezedtextlabeltest.cpp b/tdeui/tests/ksqueezedtextlabeltest.cpp new file mode 100644 index 000000000..62f3c1a76 --- /dev/null +++ b/tdeui/tests/ksqueezedtextlabeltest.cpp @@ -0,0 +1,13 @@ +#include "ksqueezedtextlabel.h" +#include + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "KSqueezedTextLabelTest" ); + + KSqueezedTextLabel l( "This is a rather long string", 0); + app.setMainWidget( &l ); + l.show(); + + return app.exec(); +} diff --git a/tdeui/tests/kstatusbartest.cpp b/tdeui/tests/kstatusbartest.cpp new file mode 100644 index 000000000..669044c55 --- /dev/null +++ b/tdeui/tests/kstatusbartest.cpp @@ -0,0 +1,121 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "kstatusbar.h" +#include +#include +#include +#include "kstatusbartest.h" + +testWindow::testWindow (TQWidget *, const char *name) + : KMainWindow (0, name) + { + // Setup Menus + menuBar = new KMenuBar (this); + fileMenu = new TQPopupMenu; + menuBar->insertItem ("&File", fileMenu); + fileMenu->insertItem ("&Exit", KApplication::kApplication(), + TQT_SLOT( quit() ), ALT + Key_Q ); + statusbar = new KStatusBar (this); + statusbar->insertItem("Zoom: XXXX", 0); + statusbar->insertItem("XXX", 1); + statusbar->insertItem("Line: XXXXX", 2); + + statusbar->changeItem("Zoom: 100%", 0); + statusbar->changeItem("INS", 1); + insert = true; + statusbar->changeItem("Line: 13567", 2); + + connect (statusbar, TQT_SIGNAL(pressed(int)), this, TQT_SLOT(slotPress(int))); + connect (statusbar, TQT_SIGNAL(released(int)), this, TQT_SLOT(slotClick(int))); + + widget = new TQMultiLineEdit (this); + + setCentralWidget(widget); + + setCaption( KApplication::kApplication()->caption() ); + + smenu = new TQPopupMenu; + + smenu->insertItem("50%"); + smenu->insertItem("75%"); + smenu->insertItem("100%"); + smenu->insertItem("150%"); + smenu->insertItem("200%"); + smenu->insertItem("400%"); + smenu->insertItem("oo%"); + + connect (smenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotMenu(int))); +} + +void testWindow::slotClick(int id) +{ + switch (id) + { + case 0: + break; + + case 1: + if (insert == true) + { + insert = false; + statusbar->changeItem("OVR", 1); + } + else + { + insert = true; + statusbar->changeItem("INS", 1); + } + break; + + case 2: + TQMessageBox::information(0, "Go to line", "Enter line number:", "where?"); + statusbar->changeItem("16543", 2); + break; + } +} + +void testWindow::slotPress(int id) +{ + if (id == 0) + smenu->popup(TQCursor::pos()); // This popup should understand keys up and down +} + +void testWindow::slotMenu(int id) +{ + TQString s = "Zoom: "; + s.append (smenu->text(id)); + statusbar->changeItem(s,0); +} + +testWindow::~testWindow () +{ + // I would delete toolbars here, but there are none + delete statusbar; +} + +int main( int argc, char *argv[] ) +{ + KApplication *myApp = new KApplication( argc, argv, "KStatusBarTest" ); + testWindow *test = new testWindow; + + myApp->setMainWidget(test); + test->show(); + test->resize(test->width(), test->height()); // I really really really dunno why it doesn't show + int ret = myApp->exec(); + + delete test; + + return ret; +} + +#include "kstatusbartest.moc" + diff --git a/tdeui/tests/kstatusbartest.h b/tdeui/tests/kstatusbartest.h new file mode 100644 index 000000000..37f500334 --- /dev/null +++ b/tdeui/tests/kstatusbartest.h @@ -0,0 +1,33 @@ +#ifndef test_kstatusbar_h +#define test_kstatusbar_h + +#include +#include +#include +#include + +class TQMultiLineEdit; + +class testWindow : public KMainWindow +{ + Q_OBJECT + +public: + testWindow (TQWidget *parent=0, const char *name=0); + ~testWindow (); + +public slots: + void slotPress(int i); + void slotClick(int i); + void slotMenu(int i); + +protected: + TQPopupMenu *fileMenu; + TQPopupMenu *smenu; + KMenuBar *menuBar; + KStatusBar *statusbar; + bool insert; + TQMultiLineEdit *widget; +}; +#endif + diff --git a/tdeui/tests/ksystemtraytest.cpp b/tdeui/tests/ksystemtraytest.cpp new file mode 100644 index 000000000..dcee78346 --- /dev/null +++ b/tdeui/tests/ksystemtraytest.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main(int argc, char **argv) +{ + KApplication app( argc, argv, "ksystemtraytest" ); + TQLabel *l = new TQLabel("System Tray Main Window", 0L); + KSystemTray *tray = new KSystemTray( l ); + tray->setText("Test"); + l->show(); + tray->show(); + + return app.exec(); +} diff --git a/tdeui/tests/ktabctltest.cpp b/tdeui/tests/ktabctltest.cpp new file mode 100644 index 000000000..33e7fc5b7 --- /dev/null +++ b/tdeui/tests/ktabctltest.cpp @@ -0,0 +1,105 @@ +/* + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "ktabctl.h" +#include "ktabctltest.h" + +TQFont default_font("Helvetica", 12); + +KApplication *a; + +TopLevel::TopLevel(TQWidget *parent, const char *name) + : TQWidget(parent, name) +{ + setCaption("KTabCtl test application"); + setMinimumSize(300, 200); + + /* + * add a tabctrl widget + */ + + test = new KTabCtl(this, "test"); + connect(test, TQT_SIGNAL(tabSelected(int)), this, TQT_SLOT(tabChanged(int))); + TQWidget *w = new TQWidget(test, "_page1"); + TQPushButton *bt = new TQPushButton("Click me to quit", w, "_bt1"); + connect(bt, TQT_SIGNAL(clicked()), this, TQT_SLOT(okPressed())); + bt->adjustSize(); + bt->move(20, 20); + test->addTab(w, "Seite 1"); + pages[0] = w; + w = new TQWidget(test, "_page2"); + e = new TQMultiLineEdit(w, "_editor"); + e->setText("Write some usesless stuff here :-)"); + w->resize(width(), height()); + test->addTab(w, "Seite 2"); + pages[1] = w; + w = new TQWidget(test, "_page3"); + bt = new TQPushButton("This button does absolutely nothing", w, "_bt3"); + bt->adjustSize(); + bt->move(20, 20); + test->addTab(w, "Seite 3"); + pages[2] = w; + test->resize(200, 200); + test->move(0, 0); + move(20, 20); + resize(400, 300); + adjustSize(); +} + +void TopLevel::resizeEvent( TQResizeEvent * ) +{ + test->resize(width(), height()); + e->setGeometry(10, 10, pages[1]->width() - 20, pages[1]->height() - 20); +} + +void TopLevel::tabChanged(int newpage) +{ + printf("tab number %d selected\n", newpage); + if(newpage == 1) + e->setFocus(); +} + +void TopLevel::okPressed() +{ + a->quit(); +} + +int main( int argc, char ** argv ) +{ + a = new KApplication ( argc, argv, "KTabCtlTest" ); + + a->setFont(default_font); + + TopLevel *toplevel = new TopLevel(0, "_ktabctl_test"); + + toplevel->show(); + a->setMainWidget(toplevel); + a->exec(); +} + +#include "ktabctltest.moc" + diff --git a/tdeui/tests/ktabctltest.h b/tdeui/tests/ktabctltest.h new file mode 100644 index 000000000..6dd3b932a --- /dev/null +++ b/tdeui/tests/ktabctltest.h @@ -0,0 +1,30 @@ +/* + * $Id$ + */ + +#ifndef _KTABCTLTEST_H +#define _KTABCTLTEST_H + +#include +class KTabCtl; +class TQPushButton; +class TQMultiLineEdit; + +class TopLevel : public TQWidget +{ + Q_OBJECT +public: + + TopLevel( TQWidget *parent=0, const char *name=0 ); +protected: + void resizeEvent(TQResizeEvent *); + KTabCtl *test; + TQPushButton *ok, *cancel; + TQMultiLineEdit *e; + TQWidget *pages[3]; +public slots: + void okPressed(); + void tabChanged(int); +}; + +#endif diff --git a/tdeui/tests/ktabwidgettest.cpp b/tdeui/tests/ktabwidgettest.cpp new file mode 100644 index 000000000..5f9fb3dcc --- /dev/null +++ b/tdeui/tests/ktabwidgettest.cpp @@ -0,0 +1,366 @@ +#include +#include +#include + +#include +#include +#include +#include + +#include "ktabwidgettest.h" + +Test::Test( TQWidget* parent, const char *name ) + :TQVBox( parent, name ), mChange(0), mLeftWidget(0), mRightWidget(0), + mLeftPopup( false ), mRightPopup( false ), mTabbarContextPopup( false ), mContextPopup( false ) + +{ + resize( 600,300 ); + + mWidget = new KTabWidget( this ); + mWidget->addTab( new TQLabel( "Testlabel 1", mWidget ), "One" ); + mWidget->addTab( new TQLabel( "Testlabel 2", mWidget ), "Two" ); + mWidget->addTab( new TQWidget( mWidget), SmallIcon( "konsole" ), "Three" ); + mWidget->addTab( new TQWidget( mWidget), "Four" ); + mWidget->setTabColor( mWidget->page(0), Qt::red ); + mWidget->setTabColor( mWidget->page(1), Qt::blue ); + + connect( mWidget, TQT_SIGNAL( currentChanged( TQWidget * ) ), TQT_SLOT( currentChanged( TQWidget * ) ) ); + connect( mWidget, TQT_SIGNAL( contextMenu( TQWidget *, const TQPoint & )), TQT_SLOT(contextMenu( TQWidget *, const TQPoint & ))); + connect( mWidget, TQT_SIGNAL( contextMenu( const TQPoint & )), TQT_SLOT(tabbarContextMenu( const TQPoint & ))); + connect( mWidget, TQT_SIGNAL( mouseDoubleClick( TQWidget * )), TQT_SLOT(mouseDoubleClick( TQWidget * ))); + connect( mWidget, TQT_SIGNAL( mouseMiddleClick() ), TQT_SLOT(addTab() )); + connect( mWidget, TQT_SIGNAL( mouseMiddleClick( TQWidget * )), TQT_SLOT(mouseMiddleClick( TQWidget * ))); + connect( mWidget, TQT_SIGNAL( closeRequest( TQWidget * )), TQT_SLOT(mouseMiddleClick( TQWidget * ))); + connect( mWidget, TQT_SIGNAL( testCanDecode(const TQDragMoveEvent *, bool & )), TQT_SLOT(testCanDecode(const TQDragMoveEvent *, bool & ))); + connect( mWidget, TQT_SIGNAL( receivedDropEvent( TQDropEvent * )), TQT_SLOT(receivedDropEvent( TQDropEvent * ))); + connect( mWidget, TQT_SIGNAL( receivedDropEvent( TQWidget *, TQDropEvent * )), TQT_SLOT(receivedDropEvent( TQWidget *, TQDropEvent * ))); + connect( mWidget, TQT_SIGNAL( initiateDrag( TQWidget * )), TQT_SLOT(initiateDrag( TQWidget * ))); + connect( mWidget, TQT_SIGNAL( movedTab( int, int )), TQT_SLOT(movedTab( int, int ))); + mWidget->setTabReorderingEnabled( true ); + + TQWidget * grid = new TQWidget(this); + TQGridLayout * gridlayout = new TQGridLayout( grid, 5, 2 ); + + TQPushButton * addTab = new TQPushButton( "Add Tab", grid ); + gridlayout->addWidget( addTab, 0, 0 ); + connect( addTab, TQT_SIGNAL( clicked() ), TQT_SLOT( addTab() ) ); + + TQPushButton * removeTab = new TQPushButton( "Remove Current Tab", grid ); + gridlayout->addWidget( removeTab, 0, 1 ); + connect( removeTab, TQT_SIGNAL( clicked() ), TQT_SLOT( removeCurrentTab() ) ); + + mLeftButton = new TQCheckBox( "Show left button", grid ); + gridlayout->addWidget( mLeftButton, 1, 0 ); + connect( mLeftButton, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( toggleLeftButton(bool) ) ); + mLeftButton->setChecked(true); + + TQCheckBox * leftPopup = new TQCheckBox( "Enable left popup", grid ); + gridlayout->addWidget( leftPopup, 2, 0 ); + connect( leftPopup, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( toggleLeftPopup(bool) ) ); + leftPopup->setChecked(true); + + mRightButton = new TQCheckBox( "Show right button", grid ); + gridlayout->addWidget( mRightButton, 1, 1 ); + connect( mRightButton, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( toggleRightButton(bool) ) ); + mRightButton->setChecked(true); + + TQCheckBox * rightPopup = new TQCheckBox( "Enable right popup", grid ); + gridlayout->addWidget( rightPopup, 2, 1 ); + connect( rightPopup, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( toggleRightPopup(bool) ) ); + rightPopup->setChecked(true); + + mTabsBottom = new TQCheckBox( "Show tabs at bottom", grid ); + gridlayout->addWidget( mTabsBottom, 3, 0 ); + connect( mTabsBottom, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( toggleTabPosition(bool) ) ); + + TQCheckBox * tabtqshape = new TQCheckBox( "Triangular tab tqshape", grid ); + gridlayout->addWidget( tabtqshape, 3, 1 ); + connect( tabtqshape, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( toggleTabShape(bool) ) ); + + TQCheckBox *tabClose = new TQCheckBox( "Close button on icon hover", grid ); + gridlayout->addWidget( tabClose, 4, 0 ); + connect( tabClose, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( toggleCloseButtons(bool) ) ); + tabClose->setChecked(true); + + TQCheckBox * showlabels = new TQCheckBox( "Show labels", grid ); + gridlayout->addWidget( showlabels, 4, 1 ); + connect( showlabels, TQT_SIGNAL( toggled(bool) ), this, TQT_SLOT( toggleLabels(bool) ) ); +} + +void Test::currentChanged(TQWidget* w) +{ + mWidget->setTabColor( w, Qt::black ); +} + +void Test::addTab() +{ + mWidget->addTab( new TQWidget( mWidget ), SmallIcon( "konsole" ), TQString("Tab %1").arg( mWidget->count()+1 ) ); +} + +void Test::testCanDecode(const TQDragMoveEvent *e, bool &accept /* result */) +{ + if ( TQTextDrag::canDecode(e) ) // don't accept=false if it cannot be decoded! + accept = true; +} + +void Test::receivedDropEvent( TQDropEvent *e ) +{ + TQString dropText; + if (TQTextDrag::decode(e, dropText)) { + mWidget->addTab( new TQWidget( mWidget), dropText ); + } +} + +void Test::receivedDropEvent( TQWidget *w, TQDropEvent *e ) +{ + TQString dropText; + if (TQTextDrag::decode(e, dropText)) { + mWidget->changeTab( w, dropText ); + } +} + +void Test::initiateDrag( TQWidget *w ) +{ + TQDragObject *d = new TQTextDrag( mWidget->label( mWidget->indexOf( w ) ), this ); + d->dragCopy(); // do NOT delete d. +} + +void Test::removeCurrentTab() +{ + if ( mWidget->count()==1 ) return; + + mWidget->removePage( mWidget->currentPage() ); +} + +void Test::toggleLeftButton(bool state) +{ + if (state) { + if (!mLeftWidget) { + mLeftWidget = new TQToolButton( mWidget ); + connect( mLeftWidget, TQT_SIGNAL( clicked() ), TQT_SLOT( addTab() ) ); + mLeftWidget->setIconSet( SmallIcon( "tab_new" ) ); + mLeftWidget->setTextLabel("New"); + mLeftWidget->setTextPosition(TQToolButton::Right); + mLeftWidget->adjustSize(); + //mLeftWidget->setGeometry( 0, 0, h, h ); + mLeftWidget->setPopup(mLeftPopup); + mWidget->setCornerWidget( mLeftWidget, TopLeft ); + } + mLeftWidget->show(); + } + else + mLeftWidget->hide(); +} + +void Test::toggleLeftPopup(bool state) +{ + if (state) { + if (!mLeftPopup) { + mLeftPopup = new TQPopupMenu(this); + mLeftPopup->insertItem(SmallIcon( "tab_new" ), "Empty Tab", 0); + mLeftPopup->insertItem(SmallIcon( "tab_new" ), "Empty Tab After First", 3); + mLeftPopup->insertSeparator(); + mLeftPopup->insertItem(SmallIcon( "tab_new" ), "Button Tab", 1); + mLeftPopup->insertItem(SmallIcon( "tab_new" ), "Label Tab", 2); + connect(mLeftPopup, TQT_SIGNAL(activated(int)), TQT_SLOT(leftPopupActivated(int))); + } + mLeftWidget->setPopup(mLeftPopup); + } + else + mLeftWidget->setPopup(0); +} + +void Test::leftPopupActivated(int item) +{ + switch (item) { + case 0: mWidget->addTab( new TQWidget( mWidget), TQString("Tab %1").arg( mWidget->count()+1 ) ); + break; + case 1: mWidget->addTab( new TQPushButton( "Testbutton", mWidget ), TQString("Tab %1").arg( mWidget->count()+1 ) ); + break; + case 2: mWidget->addTab( new TQLabel( "Testlabel", mWidget ), TQString("Tab %1").arg( mWidget->count()+1 ) ); + break; + case 3: mWidget->insertTab( new TQWidget( mWidget), TQString("Tab %1").arg( mWidget->count()+1 ), 1 ); + } +} + +void Test::toggleRightButton(bool state) +{ +if (state) { + if ( !mRightWidget) { + mRightWidget = new TQToolButton( mWidget ); + TQObject::connect( mRightWidget, TQT_SIGNAL( clicked() ), TQT_SLOT( removeCurrentTab() ) ); + mRightWidget->setIconSet( SmallIcon( "tab_remove" ) ); + mRightWidget->setTextLabel("Close"); + mRightWidget->setTextPosition(TQToolButton::Right); + mRightWidget->adjustSize(); + //mRightButton->setGeometry( 0, 0, h, h ); + mRightWidget->setPopup(mRightPopup); + mWidget->setCornerWidget( mRightWidget, TopRight ); + } + mRightWidget->show(); + } + else + mRightWidget->hide(); +} + +void Test::toggleRightPopup(bool state) +{ + if (state) { + if (!mRightPopup) { + mRightPopup = new TQPopupMenu(this); + mRightPopup->insertItem(SmallIcon( "tab_remove" ), "Current Tab", 1); + mRightPopup->insertSeparator(); + mRightPopup->insertItem(SmallIcon( "tab_remove" ), "Most Left Tab", 0); + mRightPopup->insertItem(SmallIcon( "tab_remove" ), "Most Right Tab", 2); + connect(mRightPopup, TQT_SIGNAL(activated(int)), TQT_SLOT(rightPopupActivated(int))); + } + mRightWidget->setPopup(mRightPopup); + } + else + mRightWidget->setPopup(0); +} + +void Test::rightPopupActivated(int item) +{ + switch (item) { + case 0: if ( mWidget->count() >1) { + mWidget->removePage( mWidget->page(0) ); + } + break; + case 1: removeCurrentTab(); + break; + case 2: int count = mWidget->count(); + if (count>1) { + mWidget->removePage( mWidget->page(count-1) ); + } + } +} + +void Test::toggleTabPosition(bool state) +{ + mWidget->setTabPosition(state ? TQTabWidget::Bottom : TQTabWidget::Top); +} + +void Test::toggleTabShape(bool state) +{ + mWidget->setTabShape(state ? TQTabWidget::Triangular : TQTabWidget::Rounded); +} + +void Test::toggleCloseButtons(bool state) +{ + mWidget->setHoverCloseButton( state ); +} + +void Test::contextMenu(TQWidget *w, const TQPoint &p) +{ + if (mContextPopup) + delete mContextPopup; + + mContextPopup = new TQPopupMenu(this); + mContextPopup->insertItem( "Activate Tab", 4); + mContextPopup->insertSeparator(); + mContextPopup->insertItem(SmallIcon( "konsole" ), "Set This Icon", 0); + mContextPopup->insertItem(SmallIcon( "konqueror" ), "Set This Icon", 1); + mContextPopup->insertSeparator(); + mContextPopup->insertItem( mWidget->isTabEnabled(w) ? "Disable Tab" : "Enable Tab", 2); + mContextPopup->insertItem( mWidget->tabToolTip(w).isEmpty() ? "Set Tooltip" : "Remove Tooltip", 3); + connect(mContextPopup, TQT_SIGNAL(activated(int)), TQT_SLOT(contextMenuActivated(int))); + + mContextWidget = w; + mContextPopup->popup(p); +} + +void Test::contextMenuActivated(int item) +{ + switch (item) { + case 0: mWidget->changeTab( mContextWidget, SmallIcon( "konsole" ), mWidget->label( mWidget->indexOf( mContextWidget ) ) ); + break; + case 1: mWidget->changeTab( mContextWidget, SmallIcon( "konqueror" ), mWidget->label( mWidget->indexOf( mContextWidget ) ) ); + break; + case 2: mWidget->setTabEnabled( mContextWidget, !(mWidget->isTabEnabled(mContextWidget)) ); + break; + case 3: if ( mWidget->tabToolTip(mContextWidget).isEmpty() ) + mWidget->setTabToolTip( mContextWidget, "This is a tool tip."); + else + mWidget->removeTabToolTip( mContextWidget ); + break; + case 4: mWidget->showPage( mContextWidget ); + } + delete mContextPopup; + mContextPopup = 0; +} + +void Test::tabbarContextMenu(const TQPoint &p) +{ + if (mTabbarContextPopup) + delete mTabbarContextPopup; + + mTabbarContextPopup = new TQPopupMenu(this); + mTabbarContextPopup->insertItem(SmallIcon( "tab_new" ), mLeftWidget->isVisible() ? "Hide \"Add\" Button" : "Show \"Add\" Button", 0); + mTabbarContextPopup->insertItem(SmallIcon( "tab_remove" ), mRightWidget->isVisible() ? "Hide \"Remove\" Button" : "Show \"Remove\" Button", 1); + mTabbarContextPopup->insertSeparator(); + mTabbarContextPopup->insertItem(mWidget->tabPosition()==TQTabWidget::Top ? "Put Tabbar to Bottom" : "Put Tabbar to Top", 2); + connect(mTabbarContextPopup, TQT_SIGNAL(activated(int)), TQT_SLOT(tabbarContextMenuActivated(int))); + + mTabbarContextPopup->popup(p); +} + +void Test::tabbarContextMenuActivated(int item) +{ + switch (item) { + case 0: mLeftButton->toggle(); + break; + case 1: mRightButton->toggle(); + break; + case 2: mTabsBottom->toggle(); + } + delete mTabbarContextPopup; + mTabbarContextPopup = 0; +} + +void Test::mouseDoubleClick(TQWidget *w) +{ + bool ok; + TQString text = KInputDialog::getText( + "Rename Tab", "Enter new name:", + mWidget->label( mWidget->indexOf( w ) ), &ok, this ); + if ( ok && !text.isEmpty() ) { + mWidget->changeTab( w, text ); + mWidget->setTabColor( w, Qt::green ); + } +} + +void Test::mouseMiddleClick(TQWidget *w) +{ + if ( mWidget->count()==1 ) return; + + mWidget->removePage( w ); +} + +void Test::movedTab(int from, int to) +{ + kdDebug() << "Moved tab from index " << from << " to " << to << endl; +} + +void Test::toggleLabels(bool state) +{ + mLeftWidget->setUsesTextLabel(state); + mLeftWidget->adjustSize(); + mRightWidget->setUsesTextLabel(state); + mRightWidget->adjustSize(); + mWidget->hide(); // trigger update + mWidget->show(); +} + +int main(int argc, char** argv ) +{ + KCmdLineArgs::init(argc, argv, "ktabwidgettest", "ktabwidget test app", "1.0"); + KApplication app(argc, argv); + Test *t = new Test(); + + app.setMainWidget( t ); + t->show(); + app.exec(); +} + +#include "ktabwidgettest.moc" diff --git a/tdeui/tests/ktabwidgettest.h b/tdeui/tests/ktabwidgettest.h new file mode 100644 index 000000000..7c178bd32 --- /dev/null +++ b/tdeui/tests/ktabwidgettest.h @@ -0,0 +1,69 @@ +#ifndef KTABWIDGETTEST_H +#define KTABWIDGETTEST_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class Test : public TQVBox +{ + Q_OBJECT +public: + Test( TQWidget* parent=0, const char *name =0 ); + +private slots: + void addTab(); + void removeCurrentTab(); + void toggleLeftButton(bool); + void toggleRightButton(bool); + void toggleLeftPopup(bool); + void toggleRightPopup(bool); + void toggleTabPosition(bool); + void toggleTabShape(bool); + void toggleCloseButtons(bool); + void toggleLabels(bool); + + void currentChanged(TQWidget*); + void contextMenu(TQWidget*, const TQPoint&); + void tabbarContextMenu(const TQPoint&); + void testCanDecode(const TQDragMoveEvent *, bool & /* result */); + void receivedDropEvent( TQDropEvent* ); + void initiateDrag( TQWidget * ); + void receivedDropEvent( TQWidget *, TQDropEvent * ); + void mouseDoubleClick(TQWidget*); + void mouseMiddleClick(TQWidget*); + void movedTab( int, int ); + + void leftPopupActivated(int); + void rightPopupActivated(int); + void contextMenuActivated(int); + void tabbarContextMenuActivated(int); + +private: + KTabWidget* mWidget; + int mChange; + + TQCheckBox * mLeftButton; + TQCheckBox * mRightButton; + TQCheckBox * mTabsBottom; + + TQToolButton* mLeftWidget; + TQToolButton* mRightWidget; + + TQPopupMenu* mLeftPopup; + TQPopupMenu* mRightPopup; + TQPopupMenu* mTabbarContextPopup; + TQPopupMenu* mContextPopup; + TQWidget* mContextWidget; +}; + + +#endif diff --git a/tdeui/tests/ktextedittest.cpp b/tdeui/tests/ktextedittest.cpp new file mode 100644 index 000000000..d43f77260 --- /dev/null +++ b/tdeui/tests/ktextedittest.cpp @@ -0,0 +1,43 @@ +/* This file is part of the KDE libraries + Copyright (C) 2002 Carsten Pfeiffer + + 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 +#include + +#include + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "ktextedittest" ); + KTextEdit *edit = new KTextEdit(); + edit->setReadOnly( true ); + edit->setCheckSpellingEnabled( true ); + + TQFile file( "ktextedittest.cpp" ); + if ( file.open( IO_ReadOnly ) ) + { + edit->setText( file.readAll() ); + file.close(); + } + + edit->resize( 600, 600 ); + edit->show(); + edit->setReadOnly( false ); // also enables spell checking + return app.exec(); +} diff --git a/tdeui/tests/ktimewidgettest.cpp b/tdeui/tests/ktimewidgettest.cpp new file mode 100644 index 000000000..f2767b416 --- /dev/null +++ b/tdeui/tests/ktimewidgettest.cpp @@ -0,0 +1,14 @@ +#include "ktimewidget.h" +#include +#include + +int main(int argc, char** argv) +{ + KLocale::setMainCatalogue("kdelibs"); + KApplication app(argc, argv, "KTimeWidgettest"); + KTimeWidget timeWidget; + app.setMainWidget(&timeWidget); + timeWidget.show(); + // timeWidget.setEnabled(false); + return app.exec(); +} diff --git a/tdeui/tests/ktoolbarlabelactiontest.cpp b/tdeui/tests/ktoolbarlabelactiontest.cpp new file mode 100644 index 000000000..020834605 --- /dev/null +++ b/tdeui/tests/ktoolbarlabelactiontest.cpp @@ -0,0 +1,97 @@ +/* This file is part of the KDE libraries + Copyright (C) 2004 Felix Berger + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +class MainWindow : public KMainWindow +{ +public: + MainWindow() + { + TQVBox* main = new TQVBox(this); + setCentralWidget(main); + + KSqueezedTextLabel* accel = new KSqueezedTextLabel + ("&Really long, long, long and boring text goes here", main, + "kde toolbar widget"); + new KSqueezedTextLabel + ("Really long, long, long and boring text goes here", main, + "kde toolbar widget"); + + + // first constructor + KToolBarLabelAction* label1 = new KToolBarLabelAction("&Label 1", 0, + 0, 0, + actionCollection(), + "label1"); + // second constructor + KLineEdit* lineEdit = new KLineEdit(this); + new KWidgetAction(lineEdit, "Line Edit", 0, this, 0, + actionCollection(), "lineEdit"); + KToolBarLabelAction* label2 = + new KToolBarLabelAction(lineEdit, "L&abel 2", 0, 0, 0, + actionCollection(), + "label2"); + + // set buddy for label1 + label1->setBuddy(lineEdit); + accel->setBuddy(lineEdit); + + // third constructor + TQLabel* customLabel = new KSqueezedTextLabel + ("&Really long, long, long and boring text goes here", this, + "kde toolbar widget"); + + KToolBarLabelAction* label3 = new KToolBarLabelAction(customLabel, 0, 0, 0, + actionCollection(), + "label3"); + + // set buddy for label3 + label3->setBuddy(lineEdit); + + // customLabel->setText("&test me again some time soon"); + + createGUI("ktoolbarlabelactiontestui.rc"); + } +}; + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "ktoolbarlabelactiontest" ); + + KGlobal::instance()->dirs()->addResourceDir("data", "."); + + MainWindow* mw = new MainWindow; + app.setMainWidget(mw); + mw->show(); + + return app.exec(); +} + diff --git a/tdeui/tests/ktoolbarlabelactiontestui.rc b/tdeui/tests/ktoolbarlabelactiontestui.rc new file mode 100644 index 000000000..75d02e54e --- /dev/null +++ b/tdeui/tests/ktoolbarlabelactiontestui.rc @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tdeui/tests/kunbalancedgrdtest.cpp b/tdeui/tests/kunbalancedgrdtest.cpp new file mode 100644 index 000000000..9f616496d --- /dev/null +++ b/tdeui/tests/kunbalancedgrdtest.cpp @@ -0,0 +1,176 @@ +#include "kunbalancedgrdtest.h" +#include +#include +#include +#include +#include + +int cols = 3, rows = 3; // how many + + +KGradientWidget::KGradientWidget(TQWidget *parent, const char *name) + :TQWidget(parent, name) +{ + time.start(); + setMinimumSize(250 * cols, 250 * rows); +} + +void KGradientWidget::paintEvent(TQPaintEvent *) +{ + int it, ft; + TQString say; + + TQColor ca = Qt::black, cb = Qt::cyan; + + int x = 0, y = 0; + + pix.resize(width()/cols, height()/rows); + TQPainter p(this); + p.setPen(Qt::white); + + // draw once, so that the benchmarking be fair :-) + KPixmapEffect::unbalancedGradient(pix,ca, cb, + KPixmapEffect::VerticalGradient, + xbalance, ybalance); + + // vertical + time.start(); + it = time.elapsed(); + KPixmapEffect::unbalancedGradient(pix,ca, cb, + KPixmapEffect::VerticalGradient, + xbalance, ybalance); + ft = time.elapsed(); + say.setNum( ft - it); say = "Vertical"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5 + (x++)*width()/cols, 15+y*height()/rows, say); // augment x + + // horizontal + it = time.elapsed(); + KPixmapEffect::unbalancedGradient(pix,ca, cb, + KPixmapEffect::HorizontalGradient, + xbalance, ybalance); + ft = time.elapsed() ; + say.setNum( ft - it); say = "Horizontal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // elliptic + it = time.elapsed(); + KPixmapEffect::unbalancedGradient(pix, ca, cb, + KPixmapEffect::EllipticGradient, + xbalance, ybalance); + ft = time.elapsed() ; + say.setNum( ft - it); say = "Elliptic"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + y++; // next row + x = 0; // reset the columns + + // diagonal + it = time.elapsed(); + KPixmapEffect::unbalancedGradient(pix,ca, cb, + KPixmapEffect::DiagonalGradient, + xbalance, ybalance); + ft = time.elapsed(); + say.setNum( ft - it); say = "Diagonal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // crossdiagonal + it = time.elapsed(); + KPixmapEffect::unbalancedGradient(pix,ca, cb, + KPixmapEffect::CrossDiagonalGradient, + xbalance, ybalance); + ft = time.elapsed(); + say.setNum( ft - it); say = "CrossDiagonal"; + p.drawPixmap(width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + y++; // next row + x = 0; // reset the columns + + // pyramidal + it = time.elapsed(); + KPixmapEffect::unbalancedGradient(pix, ca, cb, + KPixmapEffect::PyramidGradient, + xbalance, ybalance); + ft = time.elapsed(); + say.setNum( ft - it); say = "Pyramid"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // rectangular + it = time.elapsed(); + KPixmapEffect::unbalancedGradient(pix, ca, cb, + KPixmapEffect::RectangleGradient, + xbalance, ybalance); + ft = time.elapsed(); + say.setNum( ft - it); say = "Rectangle"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/rows, 15+y*height()/rows, say); + + // crosspipe + it = time.elapsed(); + KPixmapEffect::unbalancedGradient(pix, ca, cb, + KPixmapEffect::PipeCrossGradient, + xbalance, ybalance); + ft = time.elapsed(); + say.setNum( ft - it); say = "PipeCross"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/rows, 15+y*height()/rows, say); +} + +myTopWidget::myTopWidget (TQWidget *parent, const char *name) + :TQWidget(parent, name) +{ + TQGridLayout *lay = new TQGridLayout (this, 2, 3, 0); + + grds = new KGradientWidget(this); + lay->addMultiCellWidget(grds, 0, 0 ,0, 2); + + bLabel = new TQLabel("Balance: X = 000; Y = 000", this); + lay->addWidget(bLabel, 1, 0); + + xSlider = new TQSlider ( -200, 200, 1, 100, TQSlider::Horizontal, this); + lay->addWidget(xSlider, 1, 1); + + ySlider = new TQSlider ( -200, 200, 1, 100, TQSlider::Horizontal, this); + lay->addWidget(ySlider, 1, 2); + + connect(xSlider, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(rebalance())); + connect(ySlider, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(rebalance())); + + rebalance(); + + itime = otime = 0; + time.start(); +} + +void myTopWidget::rebalance() +{ + otime = time.elapsed(); + + TQString val; val.sprintf("Balance: X = %3d; Y = %3d", + xSlider->value(), ySlider->value()); + + bLabel->setText(val); + grds->setBalance(xSlider->value(), ySlider->value()); + + if ((otime - itime )> 500) + { + grds->tqrepaint(false); + itime = time.elapsed(); + } +} + +int main(int argc, char **argv) +{ + KApplication *app = new KApplication(argc, argv, "KUnbalancedGradientTest"); + myTopWidget w; + app->setMainWidget(&w); + w.show(); + return(app->exec()); +} + +#include "kunbalancedgrdtest.moc" diff --git a/tdeui/tests/kunbalancedgrdtest.h b/tdeui/tests/kunbalancedgrdtest.h new file mode 100644 index 000000000..8b7893772 --- /dev/null +++ b/tdeui/tests/kunbalancedgrdtest.h @@ -0,0 +1,49 @@ +// +// Simple little hack to show off new diagonal gradients. +// +// (C) KDE Artistic Daniel M. Duley +// + +#ifndef __KGRADIENT_TEST_H +#define __KGRADIENT_TEST_H + +#include +#include +#include +#include +#include + +class KGradientWidget : public TQWidget +{ +public: + KGradientWidget(TQWidget *parent=0, const char *name=0); + + void setBalance(int a, int b) { xbalance = a; ybalance = b; } +protected: + void paintEvent(TQPaintEvent *ev); +private: + KPixmap pix; + int xbalance, ybalance; + TQTime time; + +}; + +class myTopWidget: public TQWidget +{ + Q_OBJECT +public: + myTopWidget(TQWidget *parent=0, const char *name=0); + +private: + TQLabel *bLabel; + TQSlider *xSlider, *ySlider; + KGradientWidget *grds; + + TQTime time; + + int itime, otime; + +private slots: + void rebalance(); +}; +#endif diff --git a/tdeui/tests/kwindowtest.cpp b/tdeui/tests/kwindowtest.cpp new file mode 100644 index 000000000..0615d492f --- /dev/null +++ b/tdeui/tests/kwindowtest.cpp @@ -0,0 +1,528 @@ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "kwindowtest.h" + +#include + + +//#include + +/* + Ok this is a constructor of our top widget. It inherits KMainWindow. + In constructor wi will create all of our interface elements: + menubar, toolbar(s), statusbar, and main widget. Non of those + interface is obligatory, i.e. you don't have to use menubar, + toolbars or statusbar if you don't want to. Theoreticly, you + don't need even main widget (but in that case, you'll get blank + KMainWindow). + */ + +static int itemId = 0; + +testWindow::testWindow (TQWidget *parent, const char *name) + : KMainWindow (parent,name) +{ + ena=false; + setCaption("test window"); +setAutoSaveSettings(); + /******************************/ + /* First, we setup setup Menus */ + /******************************/ + menuBar = new KMenuBar (this); + + // First popup... + fileMenu = new TQPopupMenu; + // We insert this popup in menubar with caption "File". + // Prefix "&" means that "F" will be underlined + menuBar->insertItem ("&File", fileMenu); + // We insert item "Exit" with accelerator ALT-Q, and connect + // it to application's exit-slot. + fileMenu->insertItem ("&Exit", KApplication::kApplication(), + TQT_SLOT( quit() ), ALT + Key_Q ); + + // Another popup... + toolBarMenu = new TQPopupMenu; + menuBar->insertItem ("&Toolbars", toolBarMenu); + toolBarMenu->insertItem ("(Un)Hide tollbar 1", this, TQT_SLOT(slotHide1())); + toolBarMenu->insertItem ("(Un)Hide tollbar 2", this, TQT_SLOT(slotHide2())); + + itemsMenu = new TQPopupMenu; + menuBar->insertItem ("&Items", itemsMenu); + + exitB = true; // exit button is shown + lineL = true; // Lined is enabled + greenF = false; // Frame not inserted + + itemsMenu->insertItem ("delete/insert exit button", this, TQT_SLOT(slotExit())); + itemsMenu->insertItem ("insert/delete green frame!", this, TQT_SLOT(slotFrame())); + itemsMenu->insertItem ("enable/disable Lined", this, TQT_SLOT(slotLined())); + itemsMenu->insertItem ("Toggle fileNew", this, TQT_SLOT(slotNew())); + itemsMenu->insertItem ("Clear comboBox", this, TQT_SLOT(slotClearCombo())); + itemsMenu->insertItem ("Insert List in Combo", this, TQT_SLOT(slotInsertListInCombo())); + itemsMenu->insertItem ("Make item 3 curent", this, TQT_SLOT(slotMakeItem3Current())); + //itemsMenu->insertItem ("Insert clock!", this, TQT_SLOT(slotInsertClock())); + itemsMenu->insertItem ("Important!", this, TQT_SLOT(slotImportant())); + + menuBar->insertSeparator(); + helpMenu = new KHelpMenu(this, "KWindowTest was programmed by Sven Radej"); + menuBar->insertItem( "&Help", helpMenu->menu() ); + + /**************************************************/ + /*Now, we setup statusbar order is not important. */ + /**************************************************/ + statusBar = new KStatusBar (this); + statusBar->insertItem("Hi there! ", 0); + statusBar->insertItem("Look for tooltips to see functions", 1); + + //DigitalClock *clk = new DigitalClock (statusBar); + //clk->setFrameStyle(TQFrame::NoFrame); + //statusBar->insertWidget(clk, 70, 2); + + /***********************/ + /* And now the toolbar */ + /***********************/ + + // pixmap which we will use + TQPixmap pix; + + // Create toolbar... + tb = toolBar(); + + // and set it to full width + tb->setFullSize(true); + + + + // First four buttons + pix = BarIcon("filenew"); + itemId = tb->insertButton(pix, 0, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotNew()), + true, "Create.. (toggles upper button)", 50); + pix = BarIcon("fileopen"); + tb->insertButton(pix, 1, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotOpen()), + false, "Open"); + pix = BarIcon("filefloppy"); + tb->insertButton(pix, 2, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSave()), + true, "Save (beep or delayed popup)"); + tb->setDelayedPopup(2, itemsMenu); + pix = BarIcon("fileprint"); + tb->insertButton(pix, 3, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotPrint()), + true, "Print (enables/disables open)"); + + // And a combobox + // arguments: text (or strList), ID, writable, signal, object, slot, enabled, + // tooltiptext, size + tb->insertCombo (TQString("one"), 4, true, TQT_SIGNAL(activated(const TQString&)), this, + TQT_SLOT(slotList(const TQString&)), true, "ComboBox", 150); + + + // Then one line editor + // arguments: text, id, signal, object (this), slot, enabled, tooltiptext, size + tb->insertLined ("ftp://ftp.kde.org/pub/kde", 5, TQT_SIGNAL(returnPressed()), this, + TQT_SLOT(slotReturn()), true, "Location", 200); + + // Set this Lined to auto size itself. Note that only one item (Lined or Combo) + // Can be set to autosize; If you specify more of them only last (according to + /// index) will be set to autosize itself. Only Lined or Combo can be + // set to autosize. All items after autoSized one must be aligned right. + // Auto size is valid only for fullWidth toolbars. + + tb->setItemAutoSized (5); + + // Now add another button and align it right + pix = BarIcon("exit"); + tb->insertButton(pix, 6, TQT_SIGNAL(clicked()), KApplication::kApplication(), + TQT_SLOT( quit() ), true, "Exit"); + tb->alignItemRight (6); + + // Another toolbar + tb1 = new KToolBar(this, TQMainWindow::DockTop); // this one is normal and has separators + + + pix = BarIcon("filenew"); + tb1->insertButton(pix, 0, true, "Create new file2 (Toggle)"); + tb1->setToggle(0); + tb1->addConnection (0, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggle(bool))); + + pix = BarIcon("fileopen"); + tb1->insertButton(pix, 1, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotOpen()), + true, "Open (starts progres in sb)"); + + tb1->insertSeparator (); + + pix = BarIcon("filefloppy"); + tb1->insertButton(pix, 2, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSave()), + true, "Save file2 (autorepeat)"); + tb1->setAutoRepeat(2); + + pix = BarIcon("fileprint"); + tb1->insertButton(pix, 3, itemsMenu, true, "Print (pops menu)"); + + tb1->insertSeparator (); + /**** RADIO BUTTONS */ + pix = BarIcon("filenew"); + tb1->insertButton(pix, 4, true, "Radiobutton1"); + tb1->setToggle(4); + + pix = BarIcon("fileopen"); + tb1->insertButton(pix, 5, true, "Radiobutton2"); + tb1->setToggle(5); + + pix = BarIcon("filefloppy"); + tb1->insertButton(pix, 6, true, "Radiobutton3"); + tb1->setToggle(6); + + pix = BarIcon("fileprint"); + tb1->insertButton(pix, 7, true, "Radiobutton4"); + tb1->setToggle(7); + + //Create + rg = new KToolBarRadioGroup (tb1); + + rg->addButton(4); + rg->addButton(5); + rg->addButton(6); + rg->addButton(7); + + connect (tb1, TQT_SIGNAL(toggled(int)), this, TQT_SLOT(slotToggled(int))); + + // Set caption for floating toolbars + tb->setTitle ("Toolbar 1"); + tb1->setTitle ("Toolbar 2"); + + // Set main widget. In this example it is Qt's multiline editor. + widget = new TQMultiLineEdit (this); + + // Setup is now complete + + // add two toolbars + //addToolBar (tb1); + //addToolBar (tb); + + connect (tb, TQT_SIGNAL(highlighted(int,bool)), this, TQT_SLOT(slotMessage(int, bool))); + connect (tb1, TQT_SIGNAL(highlighted(int, bool)), this, TQT_SLOT(slotMessage(int, bool))); + + // Floating is enabled by default, so you don't need this. + // tb->enableFloating(true); + // tb1->enableFloating(true); + + // Show toolbars + tb->show(); + tb1->show(); + + //... and main widget + setCentralWidget (widget); + + // This is not strictly related to toolbars, menubars or KMainWindow. + // Setup popup for completions + completions = new TQPopupMenu; + + completions->insertItem("/"); + completions->insertItem("/usr/"); + completions->insertItem("/lib/"); + completions->insertItem("/var/"); + completions->insertItem("/bin/"); + completions->insertItem("/kde/"); + completions->insertItem("/home/"); + completions->insertItem("/vmlinuz :-)"); + + connect (completions, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotCompletionsMenu(int))); + pr = 0; +} +/***********************************/ +/* Now slots for toolbar actions */ +/***********************************/ +void testWindow::slotToggled(int) +{ + statusBar->message ("Buton toggled", 1500); +} + +void testWindow::slotInsertClock() +{ + //DigitalClock *clock = new DigitalClock(tb1); + //clock->setFrameStyle(TQFrame::NoFrame); + //tb1->insertWidget(8, 70, clock); +} + +void testWindow::slotNew() +{ + tb1->toggleButton(0); + toolBar()->removeItem( itemId ); +} +void testWindow::slotOpen() +{ + if (pr == 0) + pr = new TQProgressBar (statusBar); +// statusBar->message(pr); + timer = new TQTimer (pr); + + connect (timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotGoGoGoo())); + timer->start(100); +} + +void testWindow::slotGoGoGoo() +{ + pr->setProgress(pr->progress()+1); + if (pr->progress()==100) + { + timer->stop(); + statusBar->clear(); + delete pr; + pr = 0; + } +} + +void testWindow::slotSave() +{ + kapp->beep(); + statusBar->changeItem("Saving properties...", 0); +} + +void testWindow::slotPrint() +{ + statusBar->changeItem("Print file pressed", 0); + ena=!ena; + tb->setItemEnabled(1,ena ); +} +void testWindow::slotReturn() +{ + TQString s = "You entered "; + s = s + tb->getLinedText(5); + statusBar->changeItem(s, 0); + +} +void testWindow::slotList(const TQString &str) +{ + TQString s = "You chose "; + s = s + str; + statusBar->changeItem(s, 0); +} + +void testWindow::slotCompletion() +{ + // Now do a completion + // Call your completing function and set that text in klined + // TQString s = tb->getLinedText(/* ID */ 4) + // TQString completed = complete (s); + // tb->setLinedText(/* ID */ 4, completed.data()) + + // for now this: + + completions->popup(TQCursor::pos()); // This popup should understunf keys up and down + + /* This is just an example. KLined automatically sets cursor at end of string + when ctrl-d or ctrl-s is pressed. KToolBar will also put cursor at end of text in Lined + after inserting text with setLinedText (...). + */ + +} + +void testWindow::slotListCompletion() +{ + /* + Combo is not behaving good and it is ugly. I will see how it behaves in Qt-1.3, + and then decide should I make a new combobox. + */ + TQString s(tb->getComboItem(4)); // get text in combo + s+= "(completing)"; + //tb->getCombo(4)->changeItem(s.data()); // setTextIncombo + +} + +void testWindow::slotCompletionsMenu(int id) +{ + // Now set text in lined + TQString s =completions->text(id); + tb->setLinedText(5, s); // Cursor is automatically at the end of string after this +} + +void testWindow::slotHide2 () +{ + tb1->show(); +} + +void testWindow::slotHide1 () +{ + tb->show(); +} + +testWindow::~testWindow () +{ + /********************************************************/ + /* */ + /* THIS IS NOT ANY MORE IMPORTANT BUT ALLOWED!!! */ + /* */ + /********************************************************/ + + delete tb1->getWidget(8); + //debug ("kwindowtest: deleted clock"); + + delete tb; + delete tb1; + delete menuBar; + + qDebug ("kwindowtest finished"); +} + +void testWindow::beFixed() +{ + widget->setFixedSize (400, 200); +} + +void testWindow::beYFixed() +{ + widget->setMinimumSize(400, 200); + widget->setMaximumSize(9999, 200); +} + +void testWindow::slotImportant () +{ + statusBar->message("This important message will go away in 15 seconds", 15000); +} + +void testWindow::slotExit () +{ + if (exitB == true) + { + tb->removeItem(6); + exitB = false; + } + else + { + TQPixmap pix; + pix = BarIcon("exit"); + tb->insertButton(pix, 6, TQT_SIGNAL(clicked()), KApplication::kApplication(), + TQT_SLOT( quit() ), true, "Exit"); + tb->alignItemRight (6); + exitB = true; + } +} + +void testWindow::slotLined() +{ + lineL = !lineL; + tb->setItemEnabled(5, lineL); // enable/disable lined +} + +void testWindow::slotToggle (bool on) +{ + if (on == true) + statusBar->changeItem("Toggle is on", 0); + else + statusBar->changeItem("Toggle is off", 0); +} + +void testWindow::slotFrame() +{ +#if 0 + if (greenF == false) + { + tb1->insertFrame(10, 100); + tb1->alignItemRight (10); // this is pointless 'cause tb1 is not fullwidth + + TQFrame *myFrame = tb1->getFrame(10); // get frame pointer + + if (myFrame == 0) + { + warning ("bad frame ID"); + return; + } + + //paint it green + // Or do whatever you want with it, just don't change its height (height = hardcoded = 24) + // And don't move it + // If you want to have something right from your toolbar you can reduce its + // max_width with setMaxWidth() + myFrame->setBackgroundColor (TQColor("green")); + + greenF = true; + } + else + { + tb1->removeItem (10); + greenF = false; + } +#endif +} + +void testWindow::slotMessage(int, bool boo) +{ + if (boo) + statusBar->message("This button does this and that", 1500); + else + statusBar->clear(); +} +// Now few Combo slots, for Torben + +void testWindow::slotClearCombo() +{ + tb->getCombo(4)->clear(); +} + +void testWindow::slotInsertListInCombo() +{ + TQStringList list; + list.append("ListOne"); + list.append("ListTwo"); + list.append("ListThree"); + list.append("ListFour"); + list.append("ListFive"); + list.append("ListSix"); + list.append("ListSeven"); + list.append("ListEight"); + list.append("ListNine"); + list.append("ListTen"); + list.append("ListEleven"); + list.append("ListAndSoOn"); + tb->getCombo(4)->insertStringList (list,0); +} + +void testWindow::slotMakeItem3Current() +{ + tb->getCombo(4)->setCurrentItem(3); +} + +int main( int argc, char *argv[] ) +{ + int i; + KCmdLineArgs::init(argc, argv, "KWindowTest", "description", "version"); + + KApplication *myApp = new KApplication(); + testWindow *test = new testWindow; + + myApp->setMainWidget(test); + + i = TQMessageBox::information(0, "Select", "Select type of mainwidget", + "Fixed", "Y-fixed", "Resizable"); + if (i == 0) + test->beFixed(); + else if (i == 1) + test->beYFixed(); + + test->show(); + test->resize(400, 500); + int ret = myApp->exec(); + + //delete test; + return ret; +} + +#include "kwindowtest.moc" + diff --git a/tdeui/tests/kwindowtest.h b/tdeui/tests/kwindowtest.h new file mode 100644 index 000000000..14e2a6da8 --- /dev/null +++ b/tdeui/tests/kwindowtest.h @@ -0,0 +1,71 @@ +#ifndef testwindow_h +#define testwindow_h + +#include +#include +#include +#include +#include +#include +#include + +class TQMultiLineEdit; +class KToolBarRadioGroup; +class KHelpMenu; + +class testWindow : public KMainWindow +{ + Q_OBJECT + +public: + testWindow (TQWidget *parent=0, const char *name=0); + ~testWindow (); + +public slots: + void beFixed(); + void beYFixed(); + + void slotNew(); + void slotPrint(); + void slotReturn(); + void slotSave(); + void slotList(const TQString &str); + void slotOpen(); + void slotCompletion(); + void slotCompletionsMenu(int id); + void slotHide2 (); + void slotInsertClock(); + void slotHide1 (); + void slotLined (); + void slotImportant (); + void slotExit(); + void slotFrame(); + void slotListCompletion(); + void slotMessage(int, bool); + void slotToggle(bool); + void slotClearCombo(); + void slotGoGoGoo(); + void slotInsertListInCombo (); + void slotMakeItem3Current (); + void slotToggled(int); +protected: + KMenuBar *menuBar; + TQPopupMenu *fileMenu; + TQPopupMenu *itemsMenu; + TQPopupMenu *completions; + TQPopupMenu *toolBarMenu; + KStatusBar *statusBar; + KHelpMenu *helpMenu; + KToolBar *tb; + KToolBar *tb1; + bool lineL; + bool exitB; + bool greenF; + bool ena; + TQMultiLineEdit *widget; + TQTimer *timer; + TQProgressBar *pr; + KToolBarRadioGroup *rg; +}; +#endif + diff --git a/tdeui/tests/kwizardtest.cpp b/tdeui/tests/kwizardtest.cpp new file mode 100644 index 000000000..dd9e9eeaf --- /dev/null +++ b/tdeui/tests/kwizardtest.cpp @@ -0,0 +1,54 @@ +/* + * kwizardtest - a test program for the KWizard dialog + * Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org) + * + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + KApplication a(argc,argv,"kwizardtest"); + KWizard *wiz = new KWizard(0, "kwizardtest", false); + TQObject::connect((TQObject*) wiz->cancelButton(), TQT_SIGNAL(clicked()), + &a, TQT_SLOT(quit())); + TQObject::connect((TQObject*) wiz->finishButton(), TQT_SIGNAL(clicked()), + &a, TQT_SLOT(quit())); + for(int i = 1; i < 11; i++) + { + TQWidget *p = new TQWidget; + TQString msg = TQString("This is page %1 out of 10").arg(i); + TQLabel *label = new TQLabel(msg, p); + TQHBoxLayout *layout = new TQHBoxLayout(p, 5); + label->tqsetAlignment(Qt::AlignCenter); + label->setFixedSize(300, 200); + layout->addWidget(label); + TQString title = TQString("%1. page").arg(i); + wiz->addPage(p, title); + wiz->setFinishEnabled(p, (i==10)); + } + + a.setMainWidget(wiz); + wiz->show(); + return a.exec(); +} + + + diff --git a/tdeui/tests/kwordwraptest.cpp b/tdeui/tests/kwordwraptest.cpp new file mode 100644 index 000000000..ad60bd897 --- /dev/null +++ b/tdeui/tests/kwordwraptest.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2003 David Faure + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation; + * + * 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 +#include +#include +#include "kwordwrap.h" + +int main(int argc, char *argv[]) +{ + KApplication app(argc, argv, "KWordWrapTest"); + + TQFont font( "helvetica", 12 ); // let's hope we all have the same... + TQFontMetrics fm( font ); + TQRect r( 0, 0, 100, -1 ); + TQString str = "test wadabada [/foo/bar/waba]"; + KWordWrap* ww = KWordWrap::formatText( fm, r, 0, str ); + kdDebug() << str << " => " << ww->truncatedString() << endl; + delete ww; + + str = "

"; + for ( ; r.width() > 0 ; r.setWidth( r.width()-10 ) ) + { + ww = KWordWrap::formatText( fm, r, 0, str ); + kdDebug() << str << " => " << ww->truncatedString() << endl; + delete ww; + } +} diff --git a/tdeui/tests/kxmlguitest.cpp b/tdeui/tests/kxmlguitest.cpp new file mode 100644 index 000000000..a903aeb3f --- /dev/null +++ b/tdeui/tests/kxmlguitest.cpp @@ -0,0 +1,64 @@ +#include "kxmlguitest.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void Client::slotSec() +{ + kdDebug() << "Client::slotSec()" << endl; +} + +int main( int argc, char **argv ) +{ + KApplication app( argc, argv, "kxmlguitest" ); + + // KXMLGUIClient looks in the "data" resource for the .rc files + // Let's add $PWD (ideally $srcdir instead...) to it + KGlobal::dirs()->addResourceDir( "data", TQDir::currentDirPath() ); + + KMainWindow *mainwindow = new KMainWindow; + + TQLineEdit* line = new TQLineEdit( mainwindow ); + mainwindow->setCentralWidget( line ); + + mainwindow->show(); + + KXMLGUIBuilder *builder = new KXMLGUIBuilder( mainwindow ); + + KXMLGUIFactory *factory = new KXMLGUIFactory( builder ); + + Client *shell = new Client; + shell->setInstance( new KInstance( "konqueror" ) ); + shell->instance()->dirs()->addResourceDir( "data", TQDir::currentDirPath() ); + + (void)new KAction( "Split", "view_left_right", 0, 0, 0, shell->actionCollection(), "splitviewh" ); + + shell->setXMLFile( "./kxmlguitest_shell.rc" ); + + factory->addClient( shell ); + + Client *part = new Client; + + (void)new KAction( "decfont", "viewmag-", 0, 0, 0, part->actionCollection(), "decFontSizes" ); + (void)new KAction( "sec", "unlock", Qt::ALT + Qt::Key_1, part, TQT_SLOT( slotSec() ), part->actionCollection(), "security" ); + + part->setXMLFile( "./kxmlguitest_part.rc" ); + + factory->addClient( part ); + for ( int i = 0; i < 10; ++i ) + { + factory->removeClient( part ); + factory->addClient( part ); + } + + return app.exec(); +} +#include "kxmlguitest.moc" diff --git a/tdeui/tests/kxmlguitest.h b/tdeui/tests/kxmlguitest.h new file mode 100644 index 000000000..1adb1a14b --- /dev/null +++ b/tdeui/tests/kxmlguitest.h @@ -0,0 +1,19 @@ +#ifndef KXMLGUITEST_H +#define KXMLGUITEST_H + +#include +#include + +class Client : public TQObject, public KXMLGUIClient +{ + Q_OBJECT +public: + Client() {} + + void setXMLFile( const TQString &f, bool merge = true ) { KXMLGUIClient::setXMLFile( f, merge ); } + void setInstance( KInstance *inst ) { KXMLGUIClient::setInstance( inst ); } + +public slots: + void slotSec(); +}; +#endif diff --git a/tdeui/tests/kxmlguitest_part.rc b/tdeui/tests/kxmlguitest_part.rc new file mode 100644 index 000000000..84f5e4f57 --- /dev/null +++ b/tdeui/tests/kxmlguitest_part.rc @@ -0,0 +1,8 @@ + + +Main Toolbar + + + + + diff --git a/tdeui/tests/kxmlguitest_shell.rc b/tdeui/tests/kxmlguitest_shell.rc new file mode 100644 index 000000000..f211eb259 --- /dev/null +++ b/tdeui/tests/kxmlguitest_shell.rc @@ -0,0 +1,7 @@ + + + Main Toolbar + + + + diff --git a/tdeui/tests/qxembedtest.cpp b/tdeui/tests/qxembedtest.cpp new file mode 100644 index 000000000..5e870ba8f --- /dev/null +++ b/tdeui/tests/qxembedtest.cpp @@ -0,0 +1,88 @@ +#include +#include + +#include "tqapplication.h" +#include "tqpushbutton.h" +#include "tqlineedit.h" +#include "tqhbox.h" +#include "tqvbox.h" +#include "qxembed.h" + +WId windowWithName(const char *); + + +int +main(int argc, char**argv) +{ + if (argc != 2) + { + fprintf(stderr, + "usage: qxembedtest [qtoptions] windowid\n" + " qxembedtest [qtoptions] windowTitle\n"); + exit(10); + } + + + TQApplication a(argc,argv); + + TQWidget *main = new TQVBox(NULL,"main",Qt::WDestructiveClose); + TQWidget *top = new TQHBox(main); + TQPushButton *quit = new TQPushButton("Quit", top); + TQObject::connect( quit, TQT_SIGNAL(clicked()), main, TQT_SLOT(close()) ); + TQLineEdit *edit = new TQLineEdit(top); + edit->setText( "Just to see focus changes"); + QXEmbed *embed = new QXEmbed(main); + embed->setProtocol(QXEmbed::XPLAIN); + a.setMainWidget(main); + main->show(); + + WId wid = strtol(argv[1], NULL, 0); + if (! wid) + wid = windowWithName(argv[1]); + if (! wid) + { + fprintf(stderr,"qxembedtest: window not found\n"); + exit(10); + } + + fprintf(stderr,"qxembedtest: embedding wid=0x%08x\n", (unsigned int)wid); + + embed->embed(wid); + + return a.exec(); +} + + + + + +#include +#include + +// This is lifted from X11 xprop. + +Window Window_With_Name(Display *dpy, Window top, const char *name) +{ + Window *children, dummy; + unsigned int nchildren; + Window w=0; + char *window_name; + if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name)) + return(top); + if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren)) + return(0); + for (unsigned int i=0; i