diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /tools/designer/examples/richedit | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'tools/designer/examples/richedit')
18 files changed, 767 insertions, 0 deletions
diff --git a/tools/designer/examples/richedit/images/editcopy.png b/tools/designer/examples/richedit/images/editcopy.png Binary files differnew file mode 100644 index 000000000..abfe86e22 --- /dev/null +++ b/tools/designer/examples/richedit/images/editcopy.png diff --git a/tools/designer/examples/richedit/images/editcut.png b/tools/designer/examples/richedit/images/editcut.png Binary files differnew file mode 100644 index 000000000..2d179bc0d --- /dev/null +++ b/tools/designer/examples/richedit/images/editcut.png diff --git a/tools/designer/examples/richedit/images/editpaste.png b/tools/designer/examples/richedit/images/editpaste.png Binary files differnew file mode 100644 index 000000000..356ee5595 --- /dev/null +++ b/tools/designer/examples/richedit/images/editpaste.png diff --git a/tools/designer/examples/richedit/images/filenew.png b/tools/designer/examples/richedit/images/filenew.png Binary files differnew file mode 100644 index 000000000..9853d9762 --- /dev/null +++ b/tools/designer/examples/richedit/images/filenew.png diff --git a/tools/designer/examples/richedit/images/fileopen.png b/tools/designer/examples/richedit/images/fileopen.png Binary files differnew file mode 100644 index 000000000..85dab435c --- /dev/null +++ b/tools/designer/examples/richedit/images/fileopen.png diff --git a/tools/designer/examples/richedit/images/filesave.png b/tools/designer/examples/richedit/images/filesave.png Binary files differnew file mode 100644 index 000000000..21309aa69 --- /dev/null +++ b/tools/designer/examples/richedit/images/filesave.png diff --git a/tools/designer/examples/richedit/images/redo.png b/tools/designer/examples/richedit/images/redo.png Binary files differnew file mode 100644 index 000000000..857d0939e --- /dev/null +++ b/tools/designer/examples/richedit/images/redo.png diff --git a/tools/designer/examples/richedit/images/textbold.png b/tools/designer/examples/richedit/images/textbold.png Binary files differnew file mode 100644 index 000000000..c51e5c0c0 --- /dev/null +++ b/tools/designer/examples/richedit/images/textbold.png diff --git a/tools/designer/examples/richedit/images/textcenter.png b/tools/designer/examples/richedit/images/textcenter.png Binary files differnew file mode 100644 index 000000000..032a9bb93 --- /dev/null +++ b/tools/designer/examples/richedit/images/textcenter.png diff --git a/tools/designer/examples/richedit/images/textitalic.png b/tools/designer/examples/richedit/images/textitalic.png Binary files differnew file mode 100644 index 000000000..b725b4367 --- /dev/null +++ b/tools/designer/examples/richedit/images/textitalic.png diff --git a/tools/designer/examples/richedit/images/textleft.png b/tools/designer/examples/richedit/images/textleft.png Binary files differnew file mode 100644 index 000000000..4ef081f3e --- /dev/null +++ b/tools/designer/examples/richedit/images/textleft.png diff --git a/tools/designer/examples/richedit/images/textright.png b/tools/designer/examples/richedit/images/textright.png Binary files differnew file mode 100644 index 000000000..a9b2b55c2 --- /dev/null +++ b/tools/designer/examples/richedit/images/textright.png diff --git a/tools/designer/examples/richedit/images/textunder.png b/tools/designer/examples/richedit/images/textunder.png Binary files differnew file mode 100644 index 000000000..50935095d --- /dev/null +++ b/tools/designer/examples/richedit/images/textunder.png diff --git a/tools/designer/examples/richedit/images/undo.png b/tools/designer/examples/richedit/images/undo.png Binary files differnew file mode 100644 index 000000000..9346c6c35 --- /dev/null +++ b/tools/designer/examples/richedit/images/undo.png diff --git a/tools/designer/examples/richedit/main.cpp b/tools/designer/examples/richedit/main.cpp new file mode 100644 index 000000000..1f5b8afff --- /dev/null +++ b/tools/designer/examples/richedit/main.cpp @@ -0,0 +1,25 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include <qapplication.h> +#include "richedit.h" + + +int main( int argc, char *argv[] ) +{ + TQApplication app( argc, argv ); + + EditorForm richeditForm; + app.setMainWidget( &richeditForm ); + richeditForm.show(); + + return app.exec(); +} + + diff --git a/tools/designer/examples/richedit/richedit.pro b/tools/designer/examples/richedit/richedit.pro new file mode 100644 index 000000000..bcc3d4dc3 --- /dev/null +++ b/tools/designer/examples/richedit/richedit.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +TARGET = richedit +LANGUAGE = C++ + +CONFIG += qt warn_on release +SOURCES += main.cpp +IMAGEFILE = images.cpp +FORMS = richedit.ui +IMAGES = images/editcopy.png images/editcut.png images/editpaste.png images/filenew.png images/fileopen.png images/filesave.png images/redo.png images/textbold.png images/textcenter.png images/textitalic.png images/textleft.png images/textright.png images/textunder.png images/undo.png +DBFILE = richedit.db diff --git a/tools/designer/examples/richedit/richedit.ui b/tools/designer/examples/richedit/richedit.ui new file mode 100644 index 000000000..0d86a19bd --- /dev/null +++ b/tools/designer/examples/richedit/richedit.ui @@ -0,0 +1,612 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>EditorForm</class> +<include location="global" impldecl="in implementation">qfile.h</include> +<include location="global" impldecl="in implementation">qfontdatabase.h</include> +<include location="global" impldecl="in implementation">qmessagebox.h</include> +<include location="global" impldecl="in implementation">qapplication.h</include> +<include location="global" impldecl="in implementation">qfiledialog.h</include> +<include location="global" impldecl="in implementation">qtextstream.h</include> +<include location="local" implDecl="in declaration">richedit.ui.h</include> +<variable>TQString fileName;</variable> +<pixmapinproject/> +<layoutdefaults spacing="6" margin="11"/> +<widget class="TQMainWindow"> + <property name="name"> + <cstring>EditorForm</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>646</width> + <height>436</height> + </rect> + </property> + <property name="caption"> + <string>Rich Edit</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQTextEdit"> + <property name="name"> + <cstring>textEdit</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + </widget> + </hbox> +</widget> +<menubar> + <property name="name"> + <cstring>menubar</cstring> + </property> + <item text="&File" name="fileMenu"> + <action name="fileNewAction"/> + <action name="fileOpenAction"/> + <action name="fileSaveAction"/> + <action name="fileSaveAsAction"/> + <separator/> + <action name="fileExitAction"/> + </item> + <item text="&Edit" name="editMenu"> + <action name="editUndoAction"/> + <action name="editRedoAction"/> + <separator/> + <action name="editCutAction"/> + <action name="editCopyAction"/> + <action name="editPasteAction"/> + </item> + <item text="F&ormat" name="PopupMenu_2"> + <action name="leftAlignAction"/> + <action name="rightAlignAction"/> + <action name="centerAlignAction"/> + <separator/> + <action name="boldAction"/> + <action name="italicAction"/> + <action name="underlineAction"/> + </item> + <item text="&Help" name="helpMenu"> + <action name="helpContentsAction"/> + <action name="helpIndexAction"/> + <separator/> + <action name="helpAboutAction"/> + </item> +</menubar> +<toolbars> + <toolbar dock="2"> + <property name="name"> + <cstring>toolBar</cstring> + </property> + <property name="label"> + <string>Tools</string> + </property> + <action name="fileNewAction"/> + <action name="fileOpenAction"/> + <action name="fileSaveAction"/> + <separator/> + <action name="editUndoAction"/> + <action name="editRedoAction"/> + <action name="editCutAction"/> + <action name="editCopyAction"/> + <action name="editPasteAction"/> + </toolbar> + <toolbar dock="2"> + <property name="name"> + <cstring>Toolbar</cstring> + </property> + <property name="label"> + <string>Toolbar</string> + </property> + <action name="leftAlignAction"/> + <action name="centerAlignAction"/> + <action name="rightAlignAction"/> + <separator/> + <action name="boldAction"/> + <action name="italicAction"/> + <action name="underlineAction"/> + <separator/> + <widget class="TQComboBox"> + <property name="name"> + <cstring>fontComboBox</cstring> + </property> + </widget> + <widget class="TQSpinBox"> + <property name="name"> + <cstring>SpinBox2</cstring> + </property> + <property name="minValue"> + <number>6</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </toolbar> +</toolbars> +<actions> + <action> + <property name="name"> + <cstring>fileNewAction</cstring> + </property> + <property name="iconSet"> + <iconset>filenew.png</iconset> + </property> + <property name="text"> + <string>New</string> + </property> + <property name="menuText"> + <string>&New</string> + </property> + <property name="accel"> + <number>4194382</number> + </property> + </action> + <action> + <property name="name"> + <cstring>fileOpenAction</cstring> + </property> + <property name="iconSet"> + <iconset>fileopen.png</iconset> + </property> + <property name="text"> + <string>Open</string> + </property> + <property name="menuText"> + <string>&Open...</string> + </property> + <property name="accel"> + <number>4194383</number> + </property> + </action> + <action> + <property name="name"> + <cstring>fileSaveAction</cstring> + </property> + <property name="iconSet"> + <iconset>filesave.png</iconset> + </property> + <property name="text"> + <string>Save</string> + </property> + <property name="menuText"> + <string>&Save</string> + </property> + <property name="accel"> + <number>4194387</number> + </property> + </action> + <action> + <property name="name"> + <cstring>fileSaveAsAction</cstring> + </property> + <property name="text"> + <string>Save As</string> + </property> + <property name="menuText"> + <string>Save &As...</string> + </property> + <property name="accel"> + <number>0</number> + </property> + </action> + <action> + <property name="name"> + <cstring>fileExitAction</cstring> + </property> + <property name="text"> + <string>Exit</string> + </property> + <property name="menuText"> + <string>E&xit</string> + </property> + <property name="accel"> + <number>0</number> + </property> + </action> + <action> + <property name="name"> + <cstring>editUndoAction</cstring> + </property> + <property name="iconSet"> + <iconset>undo.png</iconset> + </property> + <property name="text"> + <string>Undo</string> + </property> + <property name="menuText"> + <string>&Undo</string> + </property> + <property name="accel"> + <number>4194394</number> + </property> + </action> + <action> + <property name="name"> + <cstring>editRedoAction</cstring> + </property> + <property name="iconSet"> + <iconset>redo.png</iconset> + </property> + <property name="text"> + <string>Redo</string> + </property> + <property name="menuText"> + <string>&Redo</string> + </property> + <property name="accel"> + <number>4194393</number> + </property> + </action> + <action> + <property name="name"> + <cstring>editCutAction</cstring> + </property> + <property name="iconSet"> + <iconset>editcut.png</iconset> + </property> + <property name="text"> + <string>Cut</string> + </property> + <property name="menuText"> + <string>&Cut</string> + </property> + <property name="accel"> + <number>4194392</number> + </property> + </action> + <action> + <property name="name"> + <cstring>editCopyAction</cstring> + </property> + <property name="iconSet"> + <iconset>editcopy.png</iconset> + </property> + <property name="text"> + <string>Copy</string> + </property> + <property name="menuText"> + <string>C&opy</string> + </property> + <property name="accel"> + <number>4194371</number> + </property> + </action> + <action> + <property name="name"> + <cstring>editPasteAction</cstring> + </property> + <property name="iconSet"> + <iconset>editpaste.png</iconset> + </property> + <property name="text"> + <string>Paste</string> + </property> + <property name="menuText"> + <string>&Paste</string> + </property> + <property name="accel"> + <number>4194390</number> + </property> + </action> + <action> + <property name="name"> + <cstring>helpContentsAction</cstring> + </property> + <property name="text"> + <string>Contents</string> + </property> + <property name="menuText"> + <string>&Contents...</string> + </property> + <property name="accel"> + <number>0</number> + </property> + </action> + <action> + <property name="name"> + <cstring>helpIndexAction</cstring> + </property> + <property name="text"> + <string>Index</string> + </property> + <property name="menuText"> + <string>&Index...</string> + </property> + <property name="accel"> + <number>0</number> + </property> + </action> + <action> + <property name="name"> + <cstring>helpAboutAction</cstring> + </property> + <property name="text"> + <string>About</string> + </property> + <property name="menuText"> + <string>&About</string> + </property> + <property name="accel"> + <number>0</number> + </property> + </action> + <action> + <property name="name"> + <cstring>boldAction</cstring> + </property> + <property name="toggleAction"> + <bool>true</bool> + </property> + <property name="iconSet"> + <iconset>textbold.png</iconset> + </property> + <property name="text"> + <string>bold</string> + </property> + <property name="menuText"> + <string>&Bold</string> + </property> + <property name="accel"> + <number>272629826</number> + </property> + </action> + <action> + <property name="name"> + <cstring>italicAction</cstring> + </property> + <property name="toggleAction"> + <bool>true</bool> + </property> + <property name="iconSet"> + <iconset>textitalic.png</iconset> + </property> + <property name="text"> + <string>italic</string> + </property> + <property name="menuText"> + <string>&Italic</string> + </property> + <property name="accel"> + <number>272629833</number> + </property> + </action> + <action> + <property name="name"> + <cstring>underlineAction</cstring> + </property> + <property name="toggleAction"> + <bool>true</bool> + </property> + <property name="iconSet"> + <iconset>textunder.png</iconset> + </property> + <property name="text"> + <string>underline</string> + </property> + <property name="menuText"> + <string>&Underline</string> + </property> + <property name="accel"> + <number>272629845</number> + </property> + </action> + <actiongroup> + <property name="name"> + <cstring>alignActionGroup</cstring> + </property> + <property name="text"> + <string>align</string> + </property> + <property name="usesDropDown"> + <bool>false</bool> + </property> + <action> + <property name="name"> + <cstring>leftAlignAction</cstring> + </property> + <property name="toggleAction"> + <bool>true</bool> + </property> + <property name="iconSet"> + <iconset>textleft.png</iconset> + </property> + <property name="text"> + <string>left</string> + </property> + <property name="menuText"> + <string>&Left</string> + </property> + <property name="accel"> + <number>272629836</number> + </property> + </action> + <action> + <property name="name"> + <cstring>rightAlignAction</cstring> + </property> + <property name="toggleAction"> + <bool>true</bool> + </property> + <property name="iconSet"> + <iconset>textright.png</iconset> + </property> + <property name="text"> + <string>right</string> + </property> + <property name="menuText"> + <string>&Right</string> + </property> + <property name="accel"> + <number>272629842</number> + </property> + </action> + <action> + <property name="name"> + <cstring>centerAlignAction</cstring> + </property> + <property name="toggleAction"> + <bool>true</bool> + </property> + <property name="iconSet"> + <iconset>textcenter.png</iconset> + </property> + <property name="text"> + <string>center</string> + </property> + <property name="menuText"> + <string>&Center</string> + </property> + </action> + </actiongroup> +</actions> +<connections> + <connection language="C++"> + <sender>fileNewAction</sender> + <signal>activated()</signal> + <receiver>EditorForm</receiver> + <slot>fileNew()</slot> + </connection> + <connection language="C++"> + <sender>fileOpenAction</sender> + <signal>activated()</signal> + <receiver>EditorForm</receiver> + <slot>fileOpen()</slot> + </connection> + <connection language="C++"> + <sender>fileSaveAction</sender> + <signal>activated()</signal> + <receiver>EditorForm</receiver> + <slot>fileSave()</slot> + </connection> + <connection language="C++"> + <sender>fileSaveAsAction</sender> + <signal>activated()</signal> + <receiver>EditorForm</receiver> + <slot>fileSaveAs()</slot> + </connection> + <connection language="C++"> + <sender>fileExitAction</sender> + <signal>activated()</signal> + <receiver>EditorForm</receiver> + <slot>fileExit()</slot> + </connection> + <connection language="C++"> + <sender>helpIndexAction</sender> + <signal>activated()</signal> + <receiver>EditorForm</receiver> + <slot>helpIndex()</slot> + </connection> + <connection language="C++"> + <sender>helpContentsAction</sender> + <signal>activated()</signal> + <receiver>EditorForm</receiver> + <slot>helpContents()</slot> + </connection> + <connection language="C++"> + <sender>helpAboutAction</sender> + <signal>activated()</signal> + <receiver>EditorForm</receiver> + <slot>helpAbout()</slot> + </connection> + <connection language="C++"> + <sender>SpinBox2</sender> + <signal>valueChanged(int)</signal> + <receiver>textEdit</receiver> + <slot>setPointSize(int)</slot> + </connection> + <connection language="C++"> + <sender>editCutAction</sender> + <signal>activated()</signal> + <receiver>textEdit</receiver> + <slot>cut()</slot> + </connection> + <connection language="C++"> + <sender>editPasteAction</sender> + <signal>activated()</signal> + <receiver>textEdit</receiver> + <slot>paste()</slot> + </connection> + <connection language="C++"> + <sender>editCopyAction</sender> + <signal>activated()</signal> + <receiver>textEdit</receiver> + <slot>copy()</slot> + </connection> + <connection language="C++"> + <sender>editRedoAction</sender> + <signal>activated()</signal> + <receiver>textEdit</receiver> + <slot>redo()</slot> + </connection> + <connection language="C++"> + <sender>editUndoAction</sender> + <signal>activated()</signal> + <receiver>textEdit</receiver> + <slot>undo()</slot> + </connection> + <connection language="C++"> + <sender>alignActionGroup</sender> + <signal>selected(TQAction*)</signal> + <receiver>EditorForm</receiver> + <slot>changeAlignment(TQAction*)</slot> + </connection> + <connection language="C++"> + <sender>underlineAction</sender> + <signal>toggled(bool)</signal> + <receiver>textEdit</receiver> + <slot>setUnderline(bool)</slot> + </connection> + <connection language="C++"> + <sender>italicAction</sender> + <signal>toggled(bool)</signal> + <receiver>textEdit</receiver> + <slot>setItalic(bool)</slot> + </connection> + <connection language="C++"> + <sender>boldAction</sender> + <signal>toggled(bool)</signal> + <receiver>textEdit</receiver> + <slot>setBold(bool)</slot> + </connection> + <connection language="C++"> + <sender>fontComboBox</sender> + <signal>activated(const TQString&)</signal> + <receiver>textEdit</receiver> + <slot>setFamily(const TQString&)</slot> + </connection> + <connection language="C++"> + <sender>fontComboBox</sender> + <signal>activated(const TQString&)</signal> + <receiver>textEdit</receiver> + <slot>setFocus()</slot> + </connection> + <slot access="protected" specifier="virtual" language="C++" returnType="void">init()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">fileExit()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">fileNew()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">fileOpen()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">fileSave()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">fileSaveAs()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">helpAbout()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">helpContents()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">helpIndex()</slot> + <slot access="public" specifier="virtual" language="C++" returnType="void">changeAlignment( TQAction * align )</slot> + <slot access="public" specifier="virtual" language="C++" returnType="int">saveAndContinue( const TQString & action )</slot> +</connections> +</UI> diff --git a/tools/designer/examples/richedit/richedit.ui.h b/tools/designer/examples/richedit/richedit.ui.h new file mode 100644 index 000000000..e6acad87b --- /dev/null +++ b/tools/designer/examples/richedit/richedit.ui.h @@ -0,0 +1,120 @@ +void EditorForm::init() +{ + textEdit->setFocus(); + + TQFontDatabase fonts; + fontComboBox->insertStringList( fonts.families() ); + TQString font = textEdit->family(); + font = font.lower(); + for ( int i = 0 ; i < fontComboBox->count(); i++ ) { + if ( font == fontComboBox->text( i ) ) { + fontComboBox->setCurrentItem( i ); + break; + } + } +} + +void EditorForm::fileExit() +{ + if ( saveAndContinue( "Exit" ) ) + qApp->exit(); +} + +void EditorForm::fileNew() +{ + if ( saveAndContinue( "New" ) ) + textEdit->clear(); +} + +void EditorForm::fileOpen() +{ + if ( saveAndContinue( "Open" ) ) { + TQString fn( TQFileDialog::getOpenFileName( + TQString::null, + "Rich Text Files (*.htm*)", this ) ); + if ( !fn.isEmpty() ) { + fileName = fn; + TQFile file( fileName ); + if ( file.open( IO_ReadOnly ) ) { + TQTextStream ts( &file ); + textEdit->setText( ts.read() ); + } + } + } +} + +void EditorForm::fileSave() +{ + if ( fileName.isEmpty() ) { + fileSaveAs(); + } else { + TQFile f( fileName ); + if ( f.open( IO_WriteOnly ) ) { + TQTextStream ts( &f ); + ts << textEdit->text(); + textEdit->setModified( FALSE ); + } + } +} + +void EditorForm::fileSaveAs() +{ + TQString fn = TQFileDialog::getSaveFileName( + "", "Rich Text Files (*.htm*)", this ); + if ( !fn.isEmpty() ) { + fileName = fn; + fileSave(); + } +} + +void EditorForm::helpAbout() +{ + +} + +void EditorForm::helpContents() +{ + +} + +void EditorForm::helpIndex() +{ + +} + +void EditorForm::changeAlignment(TQAction * align) +{ + if ( align == leftAlignAction ) + textEdit->setAlignment( TQt::AlignLeft ); + else if ( align == rightAlignAction ) + textEdit->setAlignment( TQt::AlignRight ); + else if ( align == centerAlignAction ) + textEdit->setAlignment( TQt::AlignCenter ); +} + +int EditorForm::saveAndContinue(const TQString & action) +{ + int continueAction = 1; + + if ( textEdit->isModified() ) { + switch( TQMessageBox::information( + this, "Rich Edit", + "The document contains unsaved changes.\n" + "Do you want to save the changes?", + "&Save", "&Don't Save", "&Cancel " + action, + 0, // Enter == button 0 + 2 ) ) { // Escape == button 2 + case 0: // Save; continue + fileSave(); + break; + case 1: // Do not save; continue + break; + case 2: // Cancel + continueAction = 0; + break; + } + } + + return continueAction; +} + |