BListView::BListView(QWidget* parent, const char* name) : KListView(parent, name) { KAccel* accel = new KAccel(this); accel->insert(KStdAccel::SelectAll, this, SLOT(slotSelectAll())); accel->insert(KStdAccel::Deselect, this, SLOT(slotDeselect())); accel->readSettings(); }
KSnapshot::KSnapshot(QWidget *parent, const char *name) : super(parent, name, false, QString::null, Ok|Cancel) { grabber = new QWidget( 0, 0, WStyle_Customize | WX11BypassWM ); Q_CHECK_PTR(grabber); grabber->move( -1000, -1000 ); grabber->installEventFilter( this ); #ifdef HAVE_X11_EXTENSIONS_SHAPE_H int tmp1, tmp2; //Check whether the extension is available haveXShape = XShapeQueryExtension( qt_xdisplay(), &tmp1, &tmp2 ); #endif QVBox *vbox = makeVBoxMainWidget(); mainWidget = new KSnapshotWidget( vbox, "mainWidget" ); Q_CHECK_PTR(mainWidget); mainWidget->btnSave->hide(); mainWidget->btnPrint->hide(); connect(mainWidget, SIGNAL(startImageDrag()), SLOT(slotDragSnapshot())); connect( mainWidget, SIGNAL( newClicked() ), SLOT( slotGrab() ) ); connect( mainWidget, SIGNAL( printClicked() ), SLOT( slotPrint() ) ); grabber->show(); grabber->grabMouse( waitCursor ); snapshot = QPixmap::grabWindow( qt_xrootwin() ); updatePreview(); grabber->releaseMouse(); grabber->hide(); KConfig *conf=KGlobal::config(); conf->setGroup("GENERAL"); mainWidget->setDelay(conf->readNumEntry("delay",0)); mainWidget->setMode( conf->readNumEntry( "mode", 0 ) ); mainWidget->setIncludeDecorations(conf->readBoolEntry("includeDecorations",true)); connect( &grabTimer, SIGNAL( timeout() ), this, SLOT( grabTimerDone() ) ); KAccel* accel = new KAccel(this); Q_CHECK_PTR(accel); accel->insert(KStdAccel::Print, this, SLOT(slotPrint())); accel->insert(KStdAccel::New, this, SLOT(slotGrab())); accel->insert( "Print2", Qt::Key_P, this, SLOT(slotPrint())); accel->insert( "New2", Qt::Key_N, this, SLOT(slotGrab())); accel->insert( "New3", Qt::Key_Space, this, SLOT(slotGrab())); mainWidget->btnNew->setFocus(); }
KSnapshot::KSnapshot(QWidget *parent, const char *name, bool grabCurrent) : DCOPObject("interface"), KDialogBase(parent, name, true, QString::null, Help|User1, User1, true, KStdGuiItem::quit() ) { grabber = new QWidget( 0, 0, WStyle_Customize | WX11BypassWM ); grabber->move( -1000, -1000 ); grabber->installEventFilter( this ); KStartupInfo::appStarted(); QVBox *vbox = makeVBoxMainWidget(); mainWidget = new KSnapshotWidget( vbox, "mainWidget" ); connect(mainWidget, SIGNAL(startImageDrag()), SLOT(slotDragSnapshot())); connect( mainWidget, SIGNAL( newClicked() ), SLOT( slotGrab() ) ); connect( mainWidget, SIGNAL( saveClicked() ), SLOT( slotSaveAs() ) ); connect( mainWidget, SIGNAL( printClicked() ), SLOT( slotPrint() ) ); connect( mainWidget, SIGNAL( copyClicked() ), SLOT( slotCopy() ) ); grabber->show(); grabber->grabMouse( waitCursor ); if ( !grabCurrent ) snapshot = QPixmap::grabWindow( qt_xrootwin() ); else { mainWidget->setMode( WindowUnderCursor ); mainWidget->setIncludeDecorations( true ); performGrab(); } updatePreview(); grabber->releaseMouse(); grabber->hide(); KConfig *conf=KGlobal::config(); conf->setGroup("GENERAL"); mainWidget->setDelay(conf->readNumEntry("delay",0)); mainWidget->setMode( conf->readNumEntry( "mode", 0 ) ); mainWidget->setIncludeDecorations(conf->readBoolEntry("includeDecorations",true)); filename = KURL::fromPathOrURL( conf->readPathEntry( "filename", QDir::currentDirPath()+"/"+i18n("snapshot")+"1.png" )); // Make sure the name is not already being used while(KIO::NetAccess::exists( filename, false, this )) { autoincFilename(); } connect( &grabTimer, SIGNAL( timeout() ), this, SLOT( grabTimerDone() ) ); connect( &updateTimer, SIGNAL( timeout() ), this, SLOT( updatePreview() ) ); QTimer::singleShot( 0, this, SLOT( updateCaption() ) ); KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), false); QPushButton *helpButton = actionButton( Help ); helpButton->setPopup(helpMenu->menu()); KAccel* accel = new KAccel(this); accel->insert(KStdAccel::Quit, kapp, SLOT(quit())); accel->insert( "QuickSave", i18n("Quick Save Snapshot &As..."), i18n("Save the snapshot to the file specified by the user without showing the file dialog."), CTRL+SHIFT+Key_S, this, SLOT(slotSave())); accel->insert(KStdAccel::Save, this, SLOT(slotSaveAs())); // accel->insert(KShortcut(CTRL+Key_A), this, SLOT(slotSaveAs())); accel->insert( "SaveAs", i18n("Save Snapshot &As..."), i18n("Save the snapshot to the file specified by the user."), CTRL+Key_A, this, SLOT(slotSaveAs())); accel->insert(KStdAccel::Print, this, SLOT(slotPrint())); accel->insert(KStdAccel::New, this, SLOT(slotGrab())); accel->insert(KStdAccel::Copy, this, SLOT(slotCopy())); accel->insert( "Quit2", Key_Q, this, SLOT(slotSave())); accel->insert( "Save2", Key_S, this, SLOT(slotSaveAs())); accel->insert( "Print2", Key_P, this, SLOT(slotPrint())); accel->insert( "New2", Key_N, this, SLOT(slotGrab())); accel->insert( "New3", Key_Space, this, SLOT(slotGrab())); setEscapeButton( User1 ); connect( this, SIGNAL( user1Clicked() ), SLOT( reject() ) ); mainWidget->btnNew->setFocus(); }
//BEGIN class ItemView ItemView::ItemView(ItemDocument * itemDocument, ViewContainer *viewContainer, uint viewAreaId, const char *name) : View(itemDocument, viewContainer, viewAreaId, name) { KActionCollection * ac = actionCollection(); KStdAction::selectAll(itemDocument, SLOT(selectAll()), ac); KStdAction::zoomIn(this, SLOT(zoomIn()), ac); KStdAction::zoomOut(this, SLOT(zoomOut()), ac); KStdAction::actualSize(this, SLOT(actualSize()), ac)->setEnabled(false); KAccel *pAccel = new KAccel(this); pAccel->insert("Cancel", i18n("Cancel"), i18n("Cancel the current operation"), Qt::Key_Escape, itemDocument, SLOT(cancelCurrentOperation())); pAccel->readSettings(); new KAction(i18n("Delete"), "editdelete", Qt::Key_Delete, itemDocument, SLOT(deleteSelection()), ac, "edit_delete"); new KAction(i18n("Export as Image..."), 0, 0, itemDocument, SLOT(exportToImage()), ac, "file_export_image"); //BEGIN Item Alignment actions new KAction(i18n("Align Horizontally"), 0, 0, itemDocument, SLOT(alignHorizontally()), ac, "align_horizontally"); new KAction(i18n("Align Vertically"), 0, 0, itemDocument, SLOT(alignVertically()), ac, "align_vertically"); new KAction(i18n("Distribute Horizontally"), 0, 0, itemDocument, SLOT(distributeHorizontally()), ac, "distribute_horizontally"); new KAction(i18n("Distribute Vertically"), 0, 0, itemDocument, SLOT(distributeVertically()), ac, "distribute_vertically"); //END Item Alignment actions //BEGIN Draw actions KToolBarPopupAction * pa = new KToolBarPopupAction(i18n("Draw"), "paintbrush", 0, 0, 0, ac, "edit_draw"); pa->setDelayed(false); KPopupMenu * m = pa->popupMenu(); m->insertTitle(i18n("Draw")); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_text", KIcon::Small), i18n("Text"), DrawPart::da_text); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_line", KIcon::Small), i18n("Line"), DrawPart::da_line); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_arrow", KIcon::Small), i18n("Arrow"), DrawPart::da_arrow); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_ellipse", KIcon::Small), i18n("Ellipse"), DrawPart::da_ellipse); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_rectangle", KIcon::Small), i18n("Rectangle"), DrawPart::da_rectangle); m->insertItem(KGlobal::iconLoader()->loadIcon("imagegallery", KIcon::Small), i18n("Image"), DrawPart::da_image); connect(m, SIGNAL(activated(int)), itemDocument, SLOT(slotSetDrawAction(int))); //END Draw actions //BEGIN Item Control actions new KAction(i18n("Raise Selection"), "bring_forward", Qt::Key_PageUp, itemDocument, SLOT(raiseZ()), ac, "edit_raise"); new KAction(i18n("Lower Selection"), "send_backward", Qt::Key_PageDown, itemDocument, SLOT(lowerZ()), ac, "edit_lower"); //END Item Control actions KAction * na = new KAction("", 0, 0, 0, 0, ac, "null_action"); na->setEnabled(false); setXMLFile("ktechlabitemviewui.rc"); m_pUpdateStatusTmr = new QTimer(this); connect(m_pUpdateStatusTmr, SIGNAL(timeout()), this, SLOT(updateStatus())); connect(this, SIGNAL(unfocused()), this, SLOT(stopUpdatingStatus())); m_pDragItem = 0l; p_itemDocument = itemDocument; m_zoomLevel = 1.; m_CVBEditor = new CVBEditor(p_itemDocument->canvas(), this, "cvbEditor"); m_CVBEditor->setLineWidth(1); connect(m_CVBEditor, SIGNAL(horizontalSliderReleased()), itemDocument, SLOT(requestCanvasResize())); connect(m_CVBEditor, SIGNAL(verticalSliderReleased()), itemDocument, SLOT(requestCanvasResize())); m_layout->insertWidget(0, m_CVBEditor); setAcceptDrops(true); setFocusWidget(m_CVBEditor->viewport()); }