diff options
author | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/helpsystem/mainwindow.cpp | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/helpsystem/mainwindow.cpp')
-rw-r--r-- | examples/helpsystem/mainwindow.cpp | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/examples/helpsystem/mainwindow.cpp b/examples/helpsystem/mainwindow.cpp new file mode 100644 index 000000000..e7e4ef9a9 --- /dev/null +++ b/examples/helpsystem/mainwindow.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** 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 <qassistantclient.h> +#include <qfiledialog.h> +#include <qmenubar.h> +#include <qpopupmenu.h> +#include <qstatusbar.h> +#include <qtable.h> +#include <qtoolbar.h> +#include <qtoolbutton.h> +#include <qtooltip.h> + +#include "mainwindow.h" +#include "tooltip.h" +#include "whatsthis.h" + +MainWindow::MainWindow() +{ + statusBar(); + assistant = new TQAssistantClient( TQDir("../../bin").absPath(), this ); + + TQTable* table = new TQTable( 2, 3, this ); + setCentralWidget( table ); + + // populate table + TQStringList comboEntries; + comboEntries << "one" << "two" << "three" << "four"; + TQComboTableItem* comboItem1 = new TQComboTableItem( table, comboEntries ); + TQComboTableItem* comboItem2 = new TQComboTableItem( table, comboEntries ); + TQCheckTableItem* checkItem1 = new TQCheckTableItem( table, "Check me" ); + TQCheckTableItem* checkItem2 = new TQCheckTableItem( table, "Check me" ); + + table->setItem( 0, 0, comboItem1 ); + table->setItem( 1, 0, comboItem2 ); + + table->setItem( 1, 1, checkItem1 ); + table->setItem( 0, 1, checkItem2 ); + + table->setText( 1, 2, "Text" ); + + table->horizontalHeader()->setLabel( 0, " Combos" ); + table->horizontalHeader()->setLabel( 1, "Checkboxes" ); + table->verticalHeader()->setLabel( 0, "1" ); + table->verticalHeader()->setLabel( 1, "2" ); + + + // populate menubar + TQPopupMenu* fileMenu = new TQPopupMenu( this ); + TQPopupMenu* helpMenu = new TQPopupMenu( this ); + + menuBar()->insertItem( "&File", fileMenu ); + menuBar()->insertItem( "&Help", helpMenu ); + + int fileId = fileMenu->insertItem( "E&xit", this, SLOT(close()) ); + + int helpId = helpMenu->insertItem( "Open Assistant", this, SLOT(assistantSlot()) ); + + // populate toolbar + TQToolBar* toolbar = new TQToolBar( this ); + TQToolButton* assistantButton = new TQToolButton( toolbar ); + assistantButton->setIconSet( TQPixmap("appicon.png") ); + TQWhatsThis::whatsThisButton( toolbar ); + + //create tooltipgroup + TQToolTipGroup * tipGroup = new TQToolTipGroup( this ); + connect( tipGroup, SIGNAL(showTip(const TQString&)), statusBar(), + SLOT(message(const TQString&)) ); + connect( tipGroup, SIGNAL(removeTip()), statusBar(), SLOT(clear()) ); + + // set up tooltips + TQToolTip::add( assistantButton, tr ("Open Assistant"), tipGroup, "Opens TQt Assistant" ); + + horizontalTip = new HeaderToolTip( table->horizontalHeader(), tipGroup ); + verticalTip = new HeaderToolTip( table->verticalHeader(), tipGroup ); + + cellTip = new TableToolTip( table, tipGroup ); + + // set up whats this + TQWhatsThis::add ( assistantButton, "This is a toolbutton which opens Assistant" ); + + HeaderWhatsThis *horizontalWhatsThis = new HeaderWhatsThis( table->horizontalHeader() ); + HeaderWhatsThis *verticalWhatsThis = new HeaderWhatsThis( table->verticalHeader() ); + + TableWhatsThis *cellWhatsThis = new TableWhatsThis( table ); + + fileMenu->setWhatsThis( fileId, "Click here to exit the application" ); + helpMenu->setWhatsThis( helpId, "Click here to open Assistant" ); + + // connections + connect( assistantButton, SIGNAL(clicked()), this, SLOT(assistantSlot()) ); + connect( horizontalWhatsThis, SIGNAL(linkClicked(const TQString&)), assistant, + SLOT(showPage(const TQString&)) ); + connect( verticalWhatsThis, SIGNAL(linkClicked(const TQString&)), assistant, + SLOT(showPage(const TQString&)) ); + connect( cellWhatsThis, SIGNAL(linkClicked(const TQString&)), assistant, + SLOT(showPage(const TQString&)) ); +} + +MainWindow::~MainWindow() +{ + delete horizontalTip; + delete verticalTip; + delete cellTip; +} + +void MainWindow::assistantSlot() +{ + TQString docsPath = TQDir("../../doc").absPath(); + assistant->showPage( TQString("%1/html/qassistantclient.html").arg(docsPath) ); +} |