Exemple #1
0
void Document::handleNewView( View *view )
{
	if ( !view || m_viewList.contains(view) )
		return;
	
	m_viewList.append(view);
	view->setDCOPID(m_nextViewID++);
	view->setCaption(m_caption);
	connect( view, SIGNAL(destroyed(QObject* )), this, SLOT(slotViewDestroyed(QObject* )) );
	connect( view, SIGNAL(focused(View* )), this, SLOT(slotViewFocused(View* )) );
	connect( view, SIGNAL(unfocused()), this, SIGNAL(viewUnfocused()) );
	
	view->show();
	
	if ( !DocManager::self()->getFocusedView() )
		view->setFocus();
}
void dtkComposerViewLayoutItem::clear(void)
{
    if (d->proxy && d->proxy->view()){
        d->proxy->view()->hide();
        emit unfocused(d->proxy->view());
    }
    delete d->proxy;

    d->proxy = new dtkComposerViewLayoutItemProxy(d->root);

    connect(d->proxy, SIGNAL(focusedIn()), this, SLOT(onFocusedIn()));
    connect(d->proxy, SIGNAL(focusedOut()), this, SLOT(onFocusedOut()));

    d->splitter->addWidget(d->proxy);

    d->proxy->setFocus(Qt::OtherFocusReason);

    d->footer->show();

    this->setUpdatesEnabled(true);

    if (d->a)
        d->a->deleteLater();

    if (d->b)
        d->b->deleteLater();

    d->a = NULL;
    d->b = NULL;

    d->label->clear();
    d->close->setEnabled(false);
    d->vertc->setEnabled(false);
    d->horzt->setEnabled(false);
    d->maxmz->setEnabled(false);
}
Exemple #3
0
//BEGIN class ViewStatusBar
ViewStatusBar::ViewStatusBar( View *view )
	: KStatusBar(view)
{
	p_view = view;
	
	m_modifiedLabel = new QLabel(this);
	addWidget( m_modifiedLabel, 0, false );
	m_fileNameLabel = new KSqueezedTextLabel(this);
	addWidget( m_fileNameLabel, 1, false );
	
	m_modifiedPixmap = KIconLoader::global()->loadIcon( "filesave", KIconLoader::Small );
	m_unmodifiedPixmap = KIconLoader::global()->loadIcon( "null", KIconLoader::Small );
	
	connect( view->document(), SIGNAL(modifiedStateChanged()), this, SLOT(slotModifiedStateChanged()) );
	connect( view->document(), SIGNAL(fileNameChanged(const KUrl& )), this, SLOT(slotFileNameChanged(const KUrl& )) );
	
	connect( view, SIGNAL(focused(View* )), this, SLOT(slotViewFocused(View* )) );
	connect( view, SIGNAL(unfocused()), this, SLOT(slotViewUnfocused()) );
	
	slotModifiedStateChanged();
	slotFileNameChanged( view->document()->url() );
	
	slotViewUnfocused();
}
Exemple #4
0
bool View::eventFilter( QObject * watched, QEvent * e )
{
// 	kDebug() << k_funcinfo << e->type() << endl;
	
	if ( watched != m_pFocusWidget )
		return false;
	
	switch ( e->type() )
	{
		case QEvent::FocusIn:
		{
			p_viewContainer->setActiveViewArea( viewAreaId() );
	
			if ( KTechlab * ktl = KTechlab::self() )
			{
				ktl->actionByName("file_save")->setEnabled(true);
				ktl->actionByName("file_save_as")->setEnabled(true);
				ktl->actionByName("file_close")->setEnabled(true);
				ktl->actionByName("file_print")->setEnabled(true);
				ktl->actionByName("edit_paste")->setEnabled(true);
				ktl->actionByName("view_split_leftright")->setEnabled(true);
				ktl->actionByName("view_split_topbottom")->setEnabled(true);
		
				ItemInterface::self()->updateItemActions();
			}
	
// 			kDebug() << k_funcinfo << "Focused In\n";
			emit focused(this);
			break;
		}
		
		case QEvent::FocusOut:
		{
// 			kDebug() << k_funcinfo << "Focused Out.\n";
            QFocusEvent *fe = static_cast<QFocusEvent*>(e);
			
			if ( QWidget * fw = qApp->focusWidget() )
			{
				QString fwClassName( fw->className() );
// 				kDebug() << "New focus widget is \""<<fw->name()<<"\" of type " << fwClassName << endl;
				
				if ( (fwClassName != "KateViewInternal") &&
								  (fwClassName != "QViewportWidget") )
				{
// 					kDebug() << "Returning as a non-view widget has focus.\n";
					break;
				}
			}
			else
			{
// 				kDebug() << "No widget currently has focus.\n";
			}
			
			if ( fe->reason() == Qt::PopupFocusReason )
			{
// 				kDebug() << k_funcinfo << "Ignoring focus-out event as was a popup.\n";
				break;
			}
			
			if ( fe->reason() == Qt::ActiveWindowFocusReason )
			{
// 				kDebug() << k_funcinfo << "Ignoring focus-out event as main window lost focus.\n";
				break;
			}
			
			emit unfocused();
			break;
		}
		
		default:
			break;
	}
	
	return false;
}
Exemple #5
0
//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());
}