void TextEdit::setupEditActions() { QToolBar *tb = new QToolBar( this ); tb->setLabel( "Edit Actions" ); QPopupMenu *menu = new QPopupMenu( this ); menuBar()->insertItem( tr( "&Edit" ), menu ); QAction *a; a = new QAction( QPixmap::fromMimeSource( "editundo.xpm" ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" ); connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); a->addTo( tb ); a->addTo( menu ); a = new QAction( QPixmap::fromMimeSource( "editredo.xpm" ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); a->addTo( tb ); a->addTo( menu ); menu->insertSeparator(); a = new QAction( QPixmap::fromMimeSource( "editcopy.xpm" ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" ); connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); a->addTo( tb ); a->addTo( menu ); a = new QAction( QPixmap::fromMimeSource( "editcut.xpm" ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" ); connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); a->addTo( tb ); a->addTo( menu ); a = new QAction( QPixmap::fromMimeSource( "editpaste.xpm" ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" ); connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); a->addTo( tb ); a->addTo( menu ); }
QToolBar* CGLWin::_createToolBar(void) { _fileNewAction = new QAction( QPixmap(filenew_xpm), "&Clear Window", CTRL+Key_N, this); connect(_fileNewAction, SIGNAL(activated()), this, SLOT(newDoc())); _fileOpenAction = new QAction( QPixmap(fileopen), "&Open...", CTRL+Key_O, this); connect(_fileOpenAction, SIGNAL(activated()), this, SLOT(openCia3dFile())); _fileSaveAction = new QAction( QPixmap(filesave), "&Save snapshot", CTRL+Key_S, this); connect(_fileSaveAction, SIGNAL(activated()), this, SLOT(save())); _filePrintAction = new QAction( QPixmap(fileprint), "&Print", CTRL+Key_Q, this); connect(_filePrintAction, SIGNAL(activated()), this, SLOT(print())); // populate a tool bar with some actions QToolBar * fileTools = new QToolBar( this, "file operations" ); fileTools->setLabel( "File Operations" ); _fileNewAction->addTo( fileTools ); _fileOpenAction->addTo( fileTools ); _fileSaveAction->addTo( fileTools ); _filePrintAction->addTo( fileTools ); return fileTools; }
void TextEdit::setupFileActions() { QToolBar *tb = new QToolBar( this ); tb->setLabel( "File Actions" ); QPopupMenu *menu = new QPopupMenu( this ); menuBar()->insertItem( tr( "&File" ), menu ); QAction *a; a = new QAction( QPixmap::fromMimeSource( "filenew.xpm" ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" ); connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); a->addTo( tb ); a->addTo( menu ); a = new QAction( QPixmap::fromMimeSource( "fileopen.xpm" ), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" ); connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); a->addTo( tb ); a->addTo( menu ); menu->insertSeparator(); a = new QAction( QPixmap::fromMimeSource( "filesave.xpm" ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" ); connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) ); a->addTo( tb ); a->addTo( menu ); a = new QAction( tr( "Save &As..." ), 0, this, "fileSaveAs" ); connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) ); a->addTo( menu ); menu->insertSeparator(); a = new QAction( QPixmap::fromMimeSource( "fileprint.xpm" ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" ); connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) ); a->addTo( tb ); a->addTo( menu ); a = new QAction( tr( "&Close" ), 0, this, "fileClose" ); connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) ); a->addTo( menu ); a = new QAction( tr( "E&xit" ), 0, this, "fileExit" ); connect( a, SIGNAL( activated() ), this, SLOT( fileExit() ) ); a->addTo( menu ); }
void TextEdit::setupTextActions() { QToolBar *tb = new QToolBar( this ); tb->setLabel( "Format Actions" ); QPopupMenu *menu = new QPopupMenu( this ); menuBar()->insertItem( tr( "F&ormat" ), menu ); comboFont = new QComboBox( TRUE, tb ); QFontDatabase db; comboFont->insertStringList( db.families() ); connect( comboFont, SIGNAL( activated( const QString & ) ), this, SLOT( textFamily( const QString & ) ) ); comboFont->lineEdit()->setText( QApplication::font().family() ); comboSize = new QComboBox( TRUE, tb ); QValueList<int> sizes = db.standardSizes(); QValueList<int>::Iterator it = sizes.begin(); for ( ; it != sizes.end(); ++it ) comboSize->insertItem( QString::number( *it ) ); connect( comboSize, SIGNAL( activated( const QString & ) ), this, SLOT( textSize( const QString & ) ) ); comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); actionTextBold = new QAction( QPixmap::fromMimeSource( "textbold.xpm" ), tr( "&Bold" ), CTRL + Key_B, this, "textBold" ); connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); actionTextBold->addTo( tb ); actionTextBold->addTo( menu ); actionTextBold->setToggleAction( TRUE ); actionTextItalic = new QAction( QPixmap::fromMimeSource( "textitalic.xpm" ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" ); connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) ); actionTextItalic->addTo( tb ); actionTextItalic->addTo( menu ); actionTextItalic->setToggleAction( TRUE ); actionTextUnderline = new QAction( QPixmap::fromMimeSource( "textunder.xpm" ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" ); connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) ); actionTextUnderline->addTo( tb ); actionTextUnderline->addTo( menu ); actionTextUnderline->setToggleAction( TRUE ); menu->insertSeparator(); QActionGroup *grp = new QActionGroup( this ); connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) ); actionAlignLeft = new QAction( QPixmap::fromMimeSource( "textleft.xpm" ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" ); actionAlignLeft->setToggleAction( TRUE ); actionAlignCenter = new QAction( QPixmap::fromMimeSource( "textcenter.xpm" ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" ); actionAlignCenter->setToggleAction( TRUE ); actionAlignRight = new QAction( QPixmap::fromMimeSource( "textright.xpm" ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" ); actionAlignRight->setToggleAction( TRUE ); actionAlignJustify = new QAction( QPixmap::fromMimeSource( "textjustify.xpm" ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" ); actionAlignJustify->setToggleAction( TRUE ); grp->addTo( tb ); grp->addTo( menu ); menu->insertSeparator(); QPixmap pix( 16, 16 ); pix.fill( black ); actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" ); connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) ); actionTextColor->addTo( tb ); actionTextColor->addTo( menu ); }
kernelinfo::kernelinfo() : QMainWindow( 0, "kernelinfo", WDestructiveClose ) { printer = new QPrinter; QPixmap openIcon, saveIcon, printIcon; QToolBar * fileTools = new QToolBar( this, "file operations" ); fileTools->setLabel( tr("File Operations") ); openIcon = QPixmap( fileopen ); QToolButton * fileOpen = new QToolButton( openIcon, tr("Open File"), QString::null, this, SLOT(choose()), fileTools, "open file" ); saveIcon = QPixmap( filesave ); QToolButton * fileSave = new QToolButton( saveIcon, tr("Save File"), QString::null, this, SLOT(save()), fileTools, "save file" ); printIcon = QPixmap( fileprint ); QToolButton * filePrint = new QToolButton( printIcon, tr("Print File"), QString::null, this, SLOT(print()), fileTools, "print file" ); (void)QWhatsThis::whatsThisButton( fileTools ); QString fileOpenText = tr("<p><img source=\"fileopen\"> " "Click this button to open a <em>new file</em>. <br>" "You can also select the <b>Open</b> command " "from the <b>File</b> menu.</p>"); QWhatsThis::add( fileOpen, fileOpenText ); QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen", openIcon ); QString fileSaveText = tr("<p>Click this button to save the file you " "are editing. You will be prompted for a file name.\n" "You can also select the <b>Save</b> command " "from the <b>File</b> menu.</p>"); QWhatsThis::add( fileSave, fileSaveText ); QString filePrintText = tr("Click this button to print the file you " "are editing.\n You can also select the Print " "command from the File menu."); QWhatsThis::add( filePrint, filePrintText ); QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( tr("&File"), file ); file->insertItem( tr("&New"), this, SLOT(newDoc()), CTRL+Key_N ); int id; id = file->insertItem( openIcon, tr("&Open..."), this, SLOT(choose()), CTRL+Key_O ); file->setWhatsThis( id, fileOpenText ); id = file->insertItem( saveIcon, tr("&Save"), this, SLOT(save()), CTRL+Key_S ); file->setWhatsThis( id, fileSaveText ); id = file->insertItem( tr("Save &As..."), this, SLOT(saveAs()) ); file->setWhatsThis( id, fileSaveText ); file->insertSeparator(); id = file->insertItem( printIcon, tr("&Print..."), this, SLOT(print()), CTRL+Key_P ); file->setWhatsThis( id, filePrintText ); file->insertSeparator(); file->insertItem( tr("&Close"), this, SLOT(close()), CTRL+Key_W ); file->insertItem( tr("&Quit"), qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); menuBar()->insertSeparator(); QPopupMenu * help = new QPopupMenu( this ); menuBar()->insertItem( tr("&Help"), help ); help->insertItem( tr("&About"), this, SLOT(about()), Key_F1 ); help->insertItem( tr("About &Qt"), this, SLOT(aboutQt()) ); help->insertSeparator(); help->insertItem( tr("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1 ); e = new QTextEdit( this, "editor" ); e->setFocus(); setCentralWidget( e ); statusBar()->message( tr("Ready"), 2000 ); resize( 450, 600 ); }
ToolbarDemo::ToolbarDemo() : QMainWindow(0, "Toolbar Demo") { //主窗口本身是一个高级容器 //建立动作 QAction *fileNewAction, *fileOpenAction, *fileSaveAction, *fileSaveAsAction, *filePrintAction, *fileCloseAction, *fileQuitAction; fileNewAction = new QAction( "New", tr("新建(&N)"), CTRL+Key_N, this, "new" ); connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc())); fileOpenAction = new QAction( "Open File", QPixmap( fileopen ), tr("打开(&O)"), CTRL+Key_O, this, "open" ); connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) ); QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen", QPixmap( fileopen ) ); fileOpenAction->setWhatsThis( tr(fileOpenText) ); fileSaveAction = new QAction( "Save File", QPixmap( filesave ), tr("保存(&S)"), CTRL+Key_S, this, "save" ); connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) ); fileSaveAction->setWhatsThis( tr(fileSaveText) ); fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."), 0, this, "save as" ); connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() )); fileSaveAsAction->setWhatsThis( tr(fileSaveText) ); filePrintAction = new QAction( "Print File", QPixmap( fileprint ), tr("打印(&P)"), CTRL+Key_P, this, "print" ); connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print())); filePrintAction->setWhatsThis( tr(filePrintText) ); fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W, this, "close" ); connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) ); fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q, this, "quit" ); connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows())); //建立按钮条 QToolBar* fileTools = new QToolBar( this, "file operations" ); fileTools->setLabel( "File Operations" ); fileOpenAction->addTo( fileTools ); fileSaveAction->addTo( fileTools ); filePrintAction->addTo( fileTools ); (void)QWhatsThis::whatsThisButton( fileTools ); //建立文件菜单 QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( tr("文件(&F)"), file ); fileNewAction->addTo( file ); fileOpenAction->addTo( file ); fileSaveAction->addTo( file ); fileSaveAsAction->addTo( file ); file->insertSeparator(); filePrintAction->addTo( file ); file->insertSeparator(); fileCloseAction->addTo( file ); fileQuitAction->addTo( file ); //建立帮助菜单 QPopupMenu * help = new QPopupMenu( this ); menuBar()->insertSeparator(); menuBar()->insertItem( tr("帮助(&H)"), help ); help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 ); help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) ); help->insertSeparator(); help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1); QMultiLineEdit *e = new QMultiLineEdit( this, "editor" ); e->setFocus(); setCentralWidget( e ); statusBar()->message( tr("准备就绪"), 2000 ); resize( 400, 400 ); }
/*! MyWindow constructor * \param w - window width * \param h - window hight */ MyWindow::MyWindow(int w, int h) : num_of_colors(18) { myBar = new QTabWidget(this); setCentralWidget(myBar); m_width = w; m_height = h; tab_number = 0; number_of_tabs = 0; testlayer = new Qt_layer( myBar ); colors_flag = true; statusBar(); m_scailing_factor = 2; // Traits Group QActionGroup *traitsGroup = new QActionGroup( this ); // Connected later traitsGroup->setExclusive( TRUE ); /*setSegmentTraits = new QAction("Segment Traits", QPixmap( (const char**)line_xpm ), "&Segment Traits", 0 ,traitsGroup, "Segment Traits" ); setSegmentTraits->setToggleAction( TRUE ); setPolylineTraits = new QAction("Polyline Traits", QPixmap( (const char**)polyline_xpm ), "&Polyline Traits", 0 , traitsGroup, "Polyline Traits" ); setPolylineTraits->setToggleAction( TRUE ); #ifdef CGAL_USE_CORE setConicTraits = new QAction("Conic Traits", QPixmap( (const char**)conic_xpm ), "&Conic Traits", 0 , traitsGroup, "Conic Traits" ); setConicTraits->setToggleAction( TRUE ); #endif */ // Snap Mode Group setSnapMode = new QAction("Snap Mode", QPixmap( (const char**)snapvertex_xpm ), "&Snap Mode", 0 , this, "Snap Mode" ); setSnapMode->setToggleAction( TRUE ); setGridSnapMode = new QAction("Grid Snap Mode", QPixmap( (const char**)snapgrid_xpm ), "&Grid Snap Mode", 0 , this, "Grid Snap Mode" ); setGridSnapMode->setToggleAction( TRUE ); // insert - delete - point_location Mode Group QActionGroup *modeGroup = new QActionGroup( this ); // Connected later modeGroup->setExclusive( TRUE ); insertMode = new QAction("Insert", QPixmap( (const char**)insert_xpm ), "&Insert", 0 , modeGroup, "Insert" ); insertMode->setToggleAction( TRUE ); deleteMode = new QAction("Delete", QPixmap( (const char**)delete_xpm ), "&Delete", 0 , modeGroup, "Delete" ); deleteMode->setToggleAction( TRUE ); pointLocationMode = new QAction("PointLocation", QPixmap( (const char**)pointlocation_xpm ), "&Point Location", 0 , modeGroup, "Point Location" ); pointLocationMode->setToggleAction( TRUE ); dragMode = new QAction("Drag", QPixmap( (const char**)hand_xpm ), "&Drag", 0 , modeGroup, "Drag" ); dragMode->setToggleAction( TRUE ); // zoom in zoominBt = new QAction("Zoom in", QPixmap( (const char**)zoomin_xpm ), "&Zoom in", 0 , this, "Zoom in" ); // zoom out zoomoutBt = new QAction("Zoom out", QPixmap( (const char**)zoomout_xpm ), "&Zoom out", 0 , this, "Zoom out" ); // color dialog color_dialog_bt = new QAction("Choose color", QPixmap( (const char**)demo_colors_xpm ), "&choose color", 0 , this, "choose color" ); // Cartograms carto_new = new QAction("New instance", QPixmap( (const char**)carto_new_xpm ), "&New instance", 0 , this, "New instance" ); carto_weights = new QAction("Set weights", QPixmap( (const char**)carto_weights_xpm ), "&Set weights", 0 , this, "Set weights" ); carto_start = new QAction("Start Cartogram", QPixmap( (const char**)carto_start_xpm ), "&Start Cartogram", 0 , this, "Start Cartogram" ); carto_it = new QAction("Next step", QPixmap( (const char**)carto_nextIt_xpm ), "&Next step", 0 , this, "Next step" ); /* #ifdef CGAL_USE_CORE // Conic Type Group QActionGroup *conicTypeGroup = new QActionGroup( this ); // Connected later conicTypeGroup->setExclusive( TRUE ); setCircle = new QAction("Circle", QPixmap( (const char**)demo_conic_circle_xpm ), "&Circle", 0 ,conicTypeGroup, "Circle" ); setCircle->setToggleAction( TRUE ); setSegment = new QAction("Segment", QPixmap( (const char**)demo_conic_segment_xpm ), "&Segment", 0 ,conicTypeGroup, "Segment" ); setSegment->setToggleAction( TRUE ); setEllipse = new QAction("Ellipse", QPixmap( (const char**)demo_conic_ellipse_xpm ), "&Ellipse", 0 ,conicTypeGroup, "Ellipse" ); setEllipse->setToggleAction( TRUE ); setParabola = new QAction("3 Points Arc", QPixmap( (const char**)demo_conic_3points_xpm ), "&3 Points Arc", 0 ,conicTypeGroup, "3 Points Arc" ); setParabola->setToggleAction( TRUE ); setHyperbola = new QAction("5 Points Arc", QPixmap( (const char**)demo_conic_5points_xpm ), "&5 Points Arc", 0 ,conicTypeGroup, "5 Points Arc" ); setHyperbola->setToggleAction( TRUE ); #endif */ //create a timer for checking if somthing changed QTimer *timer = new QTimer( this ); connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); timer->start( 200, FALSE ); // file menu QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( "&File", file ); /* file->insertItem("&Open Segment File...", this, SLOT(fileOpenSegment())); file->insertItem("&Open Polyline File...", this, SLOT(fileOpenPolyline()));\ file->insertItem("&Open Segment Arr File...", this, SLOT(fileOpenSegmentPm())); file->insertItem("&Open Polyline Arr File...", this, SLOT(fileOpenPolylinePm())); file->insertItem("&Open Conic Pm File", this, SLOT(fileOpenConicPm())); */ file->insertItem("&Open Input File...", this, SLOT(fileOpenSegment())); file->insertItem("&Open Output File...", this, SLOT(fileOpenConic())); file->insertItem("&Save...", this, SLOT(fileSave())); file->insertItem("&Save As...", this, SLOT(fileSaveAs())); //file->insertItem("&Save to ps...", this, SLOT(fileSave_ps())); file->insertSeparator(); file->insertItem("&Print...", this , SLOT(print())); file->insertSeparator(); file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); menuBar()->insertSeparator(); // tab menu QPopupMenu * tab = new QPopupMenu( this ); menuBar()->insertItem( "&Tab", tab ); /* tab->insertItem("Add &Segment Tab", this, SLOT(add_segment_tab())); tab->insertItem("Add &Polyline Tab", this, SLOT(add_polyline_tab())); #ifdef CGAL_USE_CORE tab->insertItem("Add &Conic Tab", this, SLOT(add_conic_tab())); tab->insertSeparator(); #endif */ tab->insertItem("Remove &Tab", this, SLOT(remove_tab())); menuBar()->insertSeparator(); // mode menu QPopupMenu * mode = new QPopupMenu( this ); menuBar()->insertItem( "&Mode", mode ); insertMode->addTo( mode ); deleteMode->addTo( mode ); pointLocationMode->addTo( mode ); dragMode->addTo( mode ); menuBar()->insertSeparator(); // snap mode menu QPopupMenu * snap_mode = new QPopupMenu( this ); menuBar()->insertItem( "&Snap mode", snap_mode ); setSnapMode->addTo(snap_mode); setGridSnapMode->addTo(snap_mode); menuBar()->insertSeparator(); // traits menu /*QPopupMenu * traits = new QPopupMenu( this ); menuBar()->insertItem( "&Traits Type", traits ); setSegmentTraits->addTo(traits); setPolylineTraits->addTo(traits); #ifdef CGAL_USE_CORE setConicTraits->addTo(traits); #endif */ // options menu QPopupMenu * options = new QPopupMenu( this ); menuBar()->insertItem( "&Options", options ); options->insertSeparator(); //options->insertItem("Overlay...", this, SLOT(overlay_pm())); options->insertSeparator(); options->insertItem("Properties...", this, SLOT(properties())); options->insertSeparator(); options->insertItem("Show Grid", this, SLOT(showGrid())); options->insertItem("Hide Grid", this, SLOT(hideGrid())); options->insertSeparator(); //options->insertItem("Conic Type", this, SLOT(conicType())); //options->insertSeparator(); options->insertItem("Unbounded Face Color...", this, SLOT(backGroundColor())); options->insertSeparator(); options->insertItem("Edge Color...", this, SLOT(changeEdgeColor())); options->insertSeparator(); options->insertItem("Vertex Color...", this, SLOT(changeVertexColor())); options->insertSeparator(); /*options->insertItem("Point-Locaiton Strategy....", this , SLOT(pointLocationStrategy())); */ QToolBar *modeTools = new QToolBar( this, "mode operations" ); modeTools->setLabel( "Mode Operations" ); insertMode->addTo( modeTools ); deleteMode->addTo( modeTools ); pointLocationMode->addTo( modeTools ); dragMode->addTo( modeTools ); modeTools->addSeparator(); QToolBar *snapModeTools = new QToolBar( this, "snapMode operations" ); snapModeTools->setLabel( "Snap Mode Operations" ); snapModeTools->addSeparator(); setSnapMode->addTo( snapModeTools ); setGridSnapMode->addTo( snapModeTools ); snapModeTools->addSeparator(); /*QToolBar *traitsTool = new QToolBar( this, "traits type" ); traitsTool->setLabel( "Traits Type" ); traitsTool->addSeparator(); setSegmentTraits->addTo( traitsTool ); setPolylineTraits->addTo( traitsTool ); #ifdef CGAL_USE_CORE setConicTraits->addTo( traitsTool ); #endif traitsTool->addSeparator(); */ QToolBar *zoomTool = new QToolBar( this, "zoom" ); zoomTool->setLabel( "Zoom" ); zoomTool->addSeparator(); zoomoutBt->addTo( zoomTool ); zoominBt->addTo( zoomTool ); zoomTool->addSeparator(); QToolBar *colorTool = new QToolBar( this, "color" ); colorTool->addSeparator(); colorTool->setLabel("Choose color"); color_dialog_bt->addTo(colorTool); colorTool->addSeparator(); QToolBar *cartoTool = new QToolBar( this, "cartograms" ); cartoTool->addSeparator(); cartoTool->setLabel("Cartograms"); carto_new->addTo(cartoTool); carto_weights->addTo(cartoTool); carto_start->addTo(cartoTool); carto_it->addTo(cartoTool); cartoTool->addSeparator(); /* #ifdef CGAL_USE_CORE conicTypeTool = new QToolBar( this, "conic type" ); conicTypeTool->setLabel( "Conic Type" ); conicTypeTool->addSeparator(); setSegment->addTo( conicTypeTool ); setCircle->addTo( conicTypeTool ); setEllipse->addTo( conicTypeTool ); setParabola->addTo( conicTypeTool ); setHyperbola->addTo( conicTypeTool ); #endif */ connect( zoomoutBt, SIGNAL( activated () ) , this, SLOT( zoomout() ) ); connect( zoominBt, SIGNAL( activated () ) , this, SLOT( zoomin() ) ); connect (color_dialog_bt , SIGNAL( activated()) , this , SLOT(openColorDialog() ) ); // connect mode group connect( modeGroup, SIGNAL( selected(QAction*) ), this, SLOT( updateMode(QAction*) ) ); // connect Traits Group /* connect( traitsGroup, SIGNAL( selected(QAction*) ), this, SLOT( updateTraitsType(QAction*) ) ); #ifdef CGAL_USE_CORE // connect Conic Type Group connect( conicTypeGroup, SIGNAL( selected(QAction*) ), this, SLOT( updateConicType(QAction*) ) ); #endif */ // connect Snap Mode connect( setSnapMode, SIGNAL( toggled( bool ) ) , this, SLOT( updateSnapMode( bool ) ) ); connect( setGridSnapMode, SIGNAL( toggled( bool ) ) , this, SLOT( updateGridSnapMode( bool ) ) ); // connect the change of current tab connect( myBar, SIGNAL( currentChanged(QWidget * ) ), this, SLOT( update() ) ); // connect cartogram actions connect( carto_start, SIGNAL( activated () ) , this, SLOT( cartogram_start() ) ); connect( carto_weights, SIGNAL( activated () ) , this, SLOT( cartogram_weights() ) ); connect( carto_it, SIGNAL( activated () ) , this, SLOT( print_all_weights())); connect( carto_new, SIGNAL( activated () ) , this, SLOT( cartogram_balance() ) ); colors = new QColor[num_of_colors]; colors[0] = Qt::blue; colors[1] = Qt::gray; colors[2] = Qt::green; colors[3] = Qt::cyan; colors[4] = Qt::magenta; colors[5] = Qt::darkRed; colors[6] = Qt::darkGreen; colors[7] = Qt::darkBlue; colors[8] = Qt::darkMagenta; colors[9] = Qt::darkCyan; colors[10] = Qt::yellow; colors[11] = Qt::white; colors[12] = Qt::darkGray; colors[13] = Qt::gray; colors[14] = Qt::red; colors[15] = Qt::cyan; colors[16] = Qt::darkYellow; colors[17] = Qt::lightGray; //state flag old_state = 0; add_conic_tab(); resize(m_width,m_height); }
ThemeDemo::ThemeDemo() : QMainWindow(0, "Toolbar Demo") { appFont = QApplication::font(); //建立动作 QAction *fileNewAction, *fileOpenAction, *fileSaveAction, *fileSaveAsAction, *filePrintAction, *fileCloseAction, *fileQuitAction; fileNewAction = new QAction( "New", tr("新建(&N)"), CTRL+Key_N, this, "new" ); connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc())); fileOpenAction = new QAction( "Open File", QPixmap( fileopen ), tr("打开(&O)"), CTRL+Key_O, this, "open" ); connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) ); QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen", QPixmap( fileopen ) ); fileOpenAction->setWhatsThis( tr(fileOpenText) ); fileSaveAction = new QAction( "Save File", QPixmap( filesave ), tr("保存(&S)"), CTRL+Key_S, this, "save" ); connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) ); fileSaveAction->setWhatsThis( tr(fileSaveText) ); fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."), 0, this, "save as" ); connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() )); fileSaveAsAction->setWhatsThis( tr(fileSaveText) ); filePrintAction = new QAction( "Print File", QPixmap( fileprint ), tr("打印(&P)"), CTRL+Key_P, this, "print" ); connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print())); filePrintAction->setWhatsThis( tr(filePrintText) ); fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W, this, "close" ); connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) ); fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q, this, "quit" ); connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows())); //建立按钮条 QToolBar* fileTools = new QToolBar( this, "file operations" ); fileTools->setLabel( "File Operations" ); fileOpenAction->addTo( fileTools ); fileSaveAction->addTo( fileTools ); filePrintAction->addTo( fileTools ); (void)QWhatsThis::whatsThisButton( fileTools ); //建立文件菜单 QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( tr("文件(&F)"), file ); fileNewAction->addTo( file ); fileOpenAction->addTo( file ); fileSaveAction->addTo( file ); fileSaveAsAction->addTo( file ); file->insertSeparator(); filePrintAction->addTo( file ); file->insertSeparator(); fileCloseAction->addTo( file ); fileQuitAction->addTo( file ); //建立Style菜单 QPopupMenu *style = new QPopupMenu( this ); style->setCheckable( TRUE ); menuBar()->insertItem( tr("风格(&S)") , style ); sMetal = style->insertItem( "&Metal", this, SLOT( styleMetal() ) ); sWood = style->insertItem( "&Norwegian Wood", this, SLOT( styleWood() ) ); sPlatinum = style->insertItem( "&Platinum" , this ,SLOT( stylePlatinum() ) ); sWindows = style->insertItem( "&Windows", this, SLOT( styleWindows() ) ); sCDE = style->insertItem( "&CDE", this, SLOT( styleCDE() ) ); sMotif = style->insertItem( "M&otif", this, SLOT( styleMotif() ) ); sMotifPlus = style->insertItem( "Motif P&lus", this, SLOT( styleMotifPlus() ) ); //建立帮助菜单 QPopupMenu * help = new QPopupMenu( this ); menuBar()->insertSeparator(); menuBar()->insertItem( tr("帮助(&H)"), help ); help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 ); help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) ); help->insertSeparator(); help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1); QMultiLineEdit *e = new QMultiLineEdit( this, "editor" ); e->setFocus(); setCentralWidget( e ); statusBar()->message( tr("准备就绪"), 2000 ); resize( 400, 400 ); }
ApplicationWindow::ApplicationWindow() : QMainWindow( 0, "example application main window", WDestructiveClose ) { #ifndef QT_NO_PRINTER printer = new QPrinter( QPrinter::HighResolution ); #endif QAction * fileNewAction; QAction * fileOpenAction; QAction * fileSaveAction, * fileSaveAsAction, * filePrintAction; QAction * fileCloseAction, * fileQuitAction; fileNewAction = new QAction( "&New", CTRL+Key_N, this, "new" ); connect( fileNewAction, SIGNAL( activated() ) , this, SLOT( newDoc() ) ); fileOpenAction = new QAction( QPixmap( fileopen ), "&Open...", CTRL+Key_O, this, "open" ); connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( choose() ) ); const char * fileOpenText = "<p><img source=\"fileopen\"> " "Click this button to open a <em>new file</em>. <br>" "You can also select the <b>Open</b> command " "from the <b>File</b> menu.</p>"; QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen", fileOpenAction->iconSet().pixmap() ); fileOpenAction->setWhatsThis( fileOpenText ); fileSaveAction = new QAction( QPixmap( filesave ), "&Save", CTRL+Key_S, this, "save" ); connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) ); const char * fileSaveText = "<p>Click this button to save the file you " "are editing. You will be prompted for a file name.\n" "You can also select the <b>Save</b> command " "from the <b>File</b> menu.</p>"; fileSaveAction->setWhatsThis( fileSaveText ); fileSaveAsAction = new QAction( "Save File As", "Save &As...", 0, this, "save as" ); connect( fileSaveAsAction, SIGNAL( activated() ) , this, SLOT( saveAs() ) ); fileSaveAsAction->setWhatsThis( fileSaveText ); #ifndef QT_NO_PRINTER filePrintAction = new QAction( "Print File", QPixmap( fileprint ), "&Print...", CTRL+Key_P, this, "print" ); connect( filePrintAction, SIGNAL( activated() ) , this, SLOT( print() ) ); const char * filePrintText = "Click this button to print the file you " "are editing.\n You can also select the Print " "command from the File menu."; filePrintAction->setWhatsThis( filePrintText ); #else Q_UNUSED( filePrintAction ) #endif fileCloseAction = new QAction( "Close", "&Close", CTRL+Key_W, this, "close" ); connect( fileCloseAction, SIGNAL( activated() ) , this, SLOT( close() ) ); fileQuitAction = new QAction( "Quit", "&Quit", CTRL+Key_Q, this, "quit" ); connect( fileQuitAction, SIGNAL( activated() ) , qApp, SLOT( closeAllWindows() ) ); // populate a tool bar with some actions QToolBar * fileTools = new QToolBar( this, "file operations" ); fileTools->setLabel( "File Operations" ); fileOpenAction->addTo( fileTools ); fileSaveAction->addTo( fileTools ); #ifndef QT_NO_PRINTER filePrintAction->addTo( fileTools ); #endif (void)QWhatsThis::whatsThisButton( fileTools ); // populate a menu with all actions QPopupMenu * file = new QPopupMenu( this ); menuBar()->insertItem( "&File", file ); fileNewAction->addTo( file ); fileOpenAction->addTo( file ); fileSaveAction->addTo( file ); fileSaveAsAction->addTo( file ); #ifndef QT_NO_PRINTER file->insertSeparator(); filePrintAction->addTo( file ); #endif file->insertSeparator(); fileCloseAction->addTo( file ); fileQuitAction->addTo( file ); menuBar()->insertSeparator(); // add a help menu QPopupMenu * help = new QPopupMenu( this ); menuBar()->insertItem( "&Help", help ); help->insertItem( "&About", this, SLOT(about()), Key_F1 ); help->insertItem( "About &Qt", this, SLOT(aboutQt()) ); help->insertSeparator(); help->insertItem( "What's &This", this, SLOT(whatsThis()), SHIFT+Key_F1 ); // create and define the central widget e = new QTextEdit( this, "editor" ); e->setFocus(); setCentralWidget( e ); statusBar()->message( "Ready", 2000 ); resize( 450, 600 ); }
Main::Main() { setIcon( (const char**)logo_xpm ); #ifdef FIXED_LAYOUT QHBox* horizontal = new QHBox(this); #else QSplitter* horizontal = new QSplitter(this); #endif lv = new QListView(horizontal); lv->setSorting(-1); lv->setRootIsDecorated(TRUE); lv->addColumn("ID"); info = new Info(horizontal); info->setBackgroundMode(PaletteBase); info->setMargin(10); info->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); info->setAlignment(AlignTop); connect(info, SIGNAL(idClicked(const QString&)), this, SLOT(selectId(const QString&))); #ifdef FIXED_LAYOUT horizontal->setStretchFactor(info,2); #endif connect(lv, SIGNAL(pressed(QListViewItem*)), this, SLOT(updateAvailability(QListViewItem*))); connect(lv, SIGNAL(selectionChanged(QListViewItem*)), this, SLOT(showInfo(QListViewItem*))); setCentralWidget(horizontal); QToolBar* tb = new QToolBar( this, "browser controls" ); tb->setLabel( "Browser Controls" ); (void)new QToolButton( QPixmap(back_xpm), "Back", QString::null, info, SLOT(back()), tb, "back" ); (void)new QToolButton( QPixmap(forward_xpm), "Forward", QString::null, info, SLOT(forward()), tb, "forward" ); QPopupMenu* file = new QPopupMenu( menuBar() ); file->insertItem( "&Open", this, SLOT(open()), CTRL+Key_O ); file->insertItem( "&Save", this, SLOT(save()), CTRL+Key_S ); file->insertSeparator(); file->insertItem( "&Test all", this, SLOT(testAll()), CTRL+Key_T ); file->insertSeparator(); file->insertItem( "E&xit", qApp, SLOT(quit()), CTRL+Key_Q ); menuBar()->insertItem( "&File",file ); menuBar()->insertSeparator(); QPopupMenu *help = new QPopupMenu( menuBar() ); help->insertItem( "&About", this, SLOT(about()) ); help->insertItem( "About &Qt", this, SLOT(aboutQt()) ); menuBar()->insertItem( "&Help", help ); statusBar()->message( "Ready" ); }