diff options
Diffstat (limited to 'examples/tabdialog')
-rw-r--r-- | examples/tabdialog/main.cpp | 26 | ||||
-rw-r--r-- | examples/tabdialog/tabdialog.cpp | 110 | ||||
-rw-r--r-- | examples/tabdialog/tabdialog.doc | 31 | ||||
-rw-r--r-- | examples/tabdialog/tabdialog.h | 34 | ||||
-rw-r--r-- | examples/tabdialog/tabdialog.pro | 11 |
5 files changed, 212 insertions, 0 deletions
diff --git a/examples/tabdialog/main.cpp b/examples/tabdialog/main.cpp new file mode 100644 index 000000000..954f4dc94 --- /dev/null +++ b/examples/tabdialog/main.cpp @@ -0,0 +1,26 @@ +/**************************************************************************** +** +** 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 "tabdialog.h" +#include <qapplication.h> +#include <qstring.h> + +int main( int argc, char **argv ) +{ + + TQApplication a( argc, argv ); + + TabDialog tabdialog( 0, "tabdialog", TQString( argc < 2 ? "." : argv[1] ) ); + tabdialog.resize( 450, 350 ); + tabdialog.setCaption( "TQt Example - Tabbed Dialog" ); + a.setMainWidget( &tabdialog ); + tabdialog.show(); + + return a.exec(); +} diff --git a/examples/tabdialog/tabdialog.cpp b/examples/tabdialog/tabdialog.cpp new file mode 100644 index 000000000..774b74c73 --- /dev/null +++ b/examples/tabdialog/tabdialog.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** 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 "tabdialog.h" + +#include <qvbox.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qdatetime.h> +#include <qbuttongroup.h> +#include <qcheckbox.h> +#include <qlistbox.h> +#include <qapplication.h> + +TabDialog::TabDialog( TQWidget *parent, const char *name, const TQString &_filename ) + : TQTabDialog( parent, name ), filename( _filename ), fileinfo( filename ) +{ + setupTab1(); + setupTab2(); + setupTab3(); + + connect( this, SIGNAL( applyButtonPressed() ), qApp, SLOT( tquit() ) ); +} + +void TabDialog::setupTab1() +{ + TQVBox *tab1 = new TQVBox( this ); + tab1->setMargin( 5 ); + + (void)new TQLabel( "Filename:", tab1 ); + TQLineEdit *fname = new TQLineEdit( filename, tab1 ); + fname->setFocus(); + + (void)new TQLabel( "Path:", tab1 ); + TQLabel *path = new TQLabel( fileinfo.dirPath( TRUE ), tab1 ); + path->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); + + (void)new TQLabel( "Size:", tab1 ); + ulong kb = (ulong)(fileinfo.size()/1024); + TQLabel *size = new TQLabel( TQString( "%1 KB" ).arg( kb ), tab1 ); + size->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); + + (void)new TQLabel( "Last Read:", tab1 ); + TQLabel *lread = new TQLabel( fileinfo.lastRead().toString(), tab1 ); + lread->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); + + (void)new TQLabel( "Last Modified:", tab1 ); + TQLabel *lmodif = new TQLabel( fileinfo.lastModified().toString(), tab1 ); + lmodif->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); + + addTab( tab1, "General" ); +} + +void TabDialog::setupTab2() +{ + TQVBox *tab2 = new TQVBox( this ); + tab2->setMargin( 5 ); + + TQButtonGroup *bg = new TQButtonGroup( 1, TQGroupBox::Horizontal, "Permissions", tab2 ); + + TQCheckBox *readable = new TQCheckBox( "Readable", bg ); + if ( fileinfo.isReadable() ) + readable->setChecked( TRUE ); + + TQCheckBox *writable = new TQCheckBox( "Writeable", bg ); + if ( fileinfo.isWritable() ) + writable->setChecked( TRUE ); + + TQCheckBox *executable = new TQCheckBox( "Executable", bg ); + if ( fileinfo.isExecutable() ) + executable->setChecked( TRUE ); + + TQButtonGroup *bg2 = new TQButtonGroup( 2, TQGroupBox::Horizontal, "Owner", tab2 ); + + (void)new TQLabel( "Owner", bg2 ); + TQLabel *owner = new TQLabel( fileinfo.owner(), bg2 ); + owner->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); + + (void)new TQLabel( "Group", bg2 ); + TQLabel *group = new TQLabel( fileinfo.group(), bg2 ); + group->setFrameStyle( TQFrame::Panel | TQFrame::Sunken ); + + addTab( tab2, "Permissions" ); +} + +void TabDialog::setupTab3() +{ + TQVBox *tab3 = new TQVBox( this ); + tab3->setMargin( 5 ); + tab3->setSpacing( 5 ); + + (void)new TQLabel( TQString( "Open %1 with:" ).arg( filename ), tab3 ); + + TQListBox *prgs = new TQListBox( tab3 ); + for ( unsigned int i = 0; i < 30; i++ ) { + TQString prg = TQString( "Application %1" ).arg( i ); + prgs->insertItem( prg ); + } + prgs->setCurrentItem( 3 ); + + (void)new TQCheckBox( TQString( "Open files with the extension '%1' always with this application" ).arg( fileinfo.extension() ), tab3 ); + + addTab( tab3, "Applications" ); +} diff --git a/examples/tabdialog/tabdialog.doc b/examples/tabdialog/tabdialog.doc new file mode 100644 index 000000000..c52e6653c --- /dev/null +++ b/examples/tabdialog/tabdialog.doc @@ -0,0 +1,31 @@ +/* +*/ +/*! \page tabdialog-example.html + + \ingroup examples + \title Tabdialog + + This example shows how to use a dialog with multiple tabs + (pages). To start the program you have to specify a filename + as the first argument. The dialog shows information about the + file separated onto different tabs. + + <hr> + + Header file: + + \include tabdialog/tabdialog.h + + <hr> + + Implementation: + + \include tabdialog/tabdialog.cpp + + <hr> + + Main: + + \include tabdialog/main.cpp +*/ + diff --git a/examples/tabdialog/tabdialog.h b/examples/tabdialog/tabdialog.h new file mode 100644 index 000000000..363c07eb0 --- /dev/null +++ b/examples/tabdialog/tabdialog.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** 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. +** +*****************************************************************************/ + +#ifndef TABDIALOG_H +#define TABDIALOG_H + +#include <qtabdialog.h> +#include <qstring.h> +#include <qfileinfo.h> + +class TabDialog : public TQTabDialog +{ + Q_OBJECT + +public: + TabDialog( TQWidget *parent, const char *name, const TQString &_filename ); + +protected: + TQString filename; + TQFileInfo fileinfo; + + void setupTab1(); + void setupTab2(); + void setupTab3(); + +}; + +#endif diff --git a/examples/tabdialog/tabdialog.pro b/examples/tabdialog/tabdialog.pro new file mode 100644 index 000000000..40cfbe97a --- /dev/null +++ b/examples/tabdialog/tabdialog.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = tabdialog + +CONFIG += qt warn_on release +DEPENDPATH = ../../include + +REQUIRES = large-config + +HEADERS = tabdialog.h +SOURCES = main.cpp \ + tabdialog.cpp |