diff options
Diffstat (limited to 'tools/designer/examples/multiclip')
-rw-r--r-- | tools/designer/examples/multiclip/main.cpp | 25 | ||||
-rw-r--r-- | tools/designer/examples/multiclip/multiclip.pro | 9 | ||||
-rw-r--r-- | tools/designer/examples/multiclip/multiclip.ui | 206 | ||||
-rw-r--r-- | tools/designer/examples/multiclip/multiclip.ui.h | 70 |
4 files changed, 310 insertions, 0 deletions
diff --git a/tools/designer/examples/multiclip/main.cpp b/tools/designer/examples/multiclip/main.cpp new file mode 100644 index 0000000..7f3aeb1 --- /dev/null +++ b/tools/designer/examples/multiclip/main.cpp @@ -0,0 +1,25 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for Qt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include <qapplication.h> +#include "multiclip.h" + + +int main( int argc, char *argv[] ) +{ + QApplication app( argc, argv ); + + MulticlipForm clippingForm; + app.setMainWidget( &clippingForm ); + clippingForm.show(); + + return app.exec(); +} + + diff --git a/tools/designer/examples/multiclip/multiclip.pro b/tools/designer/examples/multiclip/multiclip.pro new file mode 100644 index 0000000..f9391cb --- /dev/null +++ b/tools/designer/examples/multiclip/multiclip.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +LANGUAGE = C++ +TARGET = multiclip + +SOURCES += main.cpp +FORMS = multiclip.ui +CONFIG += qt warn_on release +DBFILE = multiclip.db +IMAGEFILE = images.cpp diff --git a/tools/designer/examples/multiclip/multiclip.ui b/tools/designer/examples/multiclip/multiclip.ui new file mode 100644 index 0000000..47bbd2f --- /dev/null +++ b/tools/designer/examples/multiclip/multiclip.ui @@ -0,0 +1,206 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>MulticlipForm</class> +<include location="global" impldecl="in declaration">qclipboard.h</include> +<include location="global" impldecl="in implementation">qapplication.h</include> +<include location="local" implDecl="in declaration">multiclip.ui.h</include> +<variable>QClipboard *cb;</variable> +<pixmapinproject/> +<layoutdefaults spacing="6" margin="11"/> +<widget class="QDialog"> + <property name="name"> + <cstring>MulticlipForm</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>585</width> + <height>472</height> + </rect> + </property> + <property name="caption"> + <string>Multiclip</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>TextLabel1</cstring> + </property> + <property name="text"> + <string>Current Clipping</string> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>currentLineEdit</cstring> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout19</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QPushButton" row="4" column="1"> + <property name="name"> + <cstring>addPushButton</cstring> + </property> + <property name="text"> + <string>&Add Clipping</string> + </property> + </widget> + <spacer row="2" column="1"> + <property name="name"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton" row="7" column="1"> + <property name="name"> + <cstring>quitPushButton</cstring> + </property> + <property name="text"> + <string>&Quit</string> + </property> + </widget> + <widget class="QLabel" row="0" column="1"> + <property name="name"> + <cstring>TextLabel3</cstring> + </property> + <property name="text"> + <string>Length</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>Previous Clippings</string> + </property> + </widget> + <widget class="QCheckBox" row="3" column="1"> + <property name="name"> + <cstring>autoCheckBox</cstring> + </property> + <property name="text"> + <string>A&uto Add Clippings</string> + </property> + </widget> + <widget class="QLCDNumber" row="1" column="1"> + <property name="name"> + <cstring>lengthLCDNumber</cstring> + </property> + </widget> + <widget class="QPushButton" row="6" column="1"> + <property name="name"> + <cstring>deletePushButton</cstring> + </property> + <property name="text"> + <string>&Delete Clipping</string> + </property> + </widget> + <widget class="QListBox" row="1" column="0" rowspan="7" colspan="1"> + <property name="name"> + <cstring>clippingsListBox</cstring> + </property> + </widget> + <widget class="QPushButton" row="5" column="1"> + <property name="name"> + <cstring>copyPushButton</cstring> + </property> + <property name="text"> + <string>&Copy Previous</string> + </property> + </widget> + </grid> + </widget> + </vbox> +</widget> +<connections> + <connection language="C++"> + <sender>quitPushButton</sender> + <signal>clicked()</signal> + <receiver>MulticlipForm</receiver> + <slot>accept()</slot> + </connection> + <connection language="C++"> + <sender>addPushButton</sender> + <signal>clicked()</signal> + <receiver>MulticlipForm</receiver> + <slot>addClipping()</slot> + </connection> + <connection language="C++"> + <sender>copyPushButton</sender> + <signal>pressed()</signal> + <receiver>MulticlipForm</receiver> + <slot>copyPrevious()</slot> + </connection> + <connection language="C++"> + <sender>deletePushButton</sender> + <signal>clicked()</signal> + <receiver>MulticlipForm</receiver> + <slot>deleteClipping()</slot> + </connection> + <slot access="public" specifier="virtual" language="C++" returnType="void">addClipping()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">dataChanged()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">deleteClipping()</slot> + <slot access="protected" specifier="virtual" language="C++" returnType="void">init()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">selectionChanged()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">copyPrevious()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">clippingChanged( const QString & clipping )</slot> +</connections> +<tabstops> + <tabstop>currentLineEdit</tabstop> + <tabstop>clippingsListBox</tabstop> + <tabstop>autoCheckBox</tabstop> + <tabstop>addPushButton</tabstop> + <tabstop>copyPushButton</tabstop> + <tabstop>deletePushButton</tabstop> + <tabstop>quitPushButton</tabstop> +</tabstops> +</UI> diff --git a/tools/designer/examples/multiclip/multiclip.ui.h b/tools/designer/examples/multiclip/multiclip.ui.h new file mode 100644 index 0000000..e4d7fc1 --- /dev/null +++ b/tools/designer/examples/multiclip/multiclip.ui.h @@ -0,0 +1,70 @@ +void MulticlipForm::addClipping() +{ + QString text = currentLineEdit->text(); + if ( ! text.isEmpty() ) { + lengthLCDNumber->display( (int)text.length() ); + int i = 0; + for ( ; i < (int)clippingsListBox->count(); i++ ) { + if ( clippingsListBox->text( i ) == text ) { + i = -1; // Do not add duplicates + break; + } + } + if ( i != -1 ) + clippingsListBox->insertItem( text, 0 ); + } +} + +void MulticlipForm::dataChanged() +{ + QString text; + text = cb->text(); + clippingChanged( text ); + if ( autoCheckBox->isChecked() ) + addClipping(); +} + +void MulticlipForm::deleteClipping() +{ + clippingChanged( "" ); + clippingsListBox->removeItem( clippingsListBox->currentItem() ); +} + +void MulticlipForm::init() +{ + lengthLCDNumber->setBackgroundColor( darkBlue ); + currentLineEdit->setFocus(); + + cb = qApp->clipboard(); + connect( cb, SIGNAL( dataChanged() ), SLOT( dataChanged() ) ); + if ( cb->supportsSelection() ) + connect( cb, SIGNAL( selectionChanged() ), SLOT( selectionChanged() ) ); + + dataChanged(); +} + +void MulticlipForm::selectionChanged() +{ + cb->setSelectionMode( TRUE ); + dataChanged(); + cb->setSelectionMode( FALSE ); +} + +void MulticlipForm::copyPrevious() +{ + if ( clippingsListBox->currentItem() != -1 ) { + cb->setText( clippingsListBox->currentText() ); + if ( cb->supportsSelection() ) { + cb->setSelectionMode( TRUE ); + cb->setText( clippingsListBox->currentText() ); + cb->setSelectionMode( FALSE ); + } + } +} + +void MulticlipForm::clippingChanged( const QString & clipping ) +{ + currentLineEdit->setText( clipping ); + lengthLCDNumber->display( (int)clipping.length() ); +} + |