Example #1
0
void KMDITest::openNewWindow()
{
    // Add a child view
    m_childs ++;
    
    // The child view will be our child only if we aren't in Toplevel mode
    KMdiChildView *view = new KMdiChildView(
        i18n( "View %1" ).arg( m_childs ), 
        ( mdiMode() == KMdi::ToplevelMode ) ? 0 : this );
    ( new QHBoxLayout( view ) )->setAutoAdd( true );
    new QLabel( i18n( "Test of KMDI: view %1" ).arg( m_childs ), view );

    // Add the item to the window list
    m_window.append( view );
    m_listBox->insertItem( view->tabCaption() );

    // Add to the MDI and set as current
    if ( mdiMode() == KMdi::ToplevelMode ) {
        addWindow( view, KMdi::Detach );
    } else {
        addWindow( view );
    }
    currentChanged( view );
    
    // Handle the request of killing
    connect( view, SIGNAL( childWindowCloseRequest( KMdiChildView * ) ),
        this, SLOT( childClosed( KMdiChildView * ) ) );
}
Example #2
0
QString KstIfaceImpl::activeWindow() {
  KstApp *app = KstApp::inst();
  KMdiChildView *view = app->activeWindow();
  if (view) {
    return view->caption();
  }
  return QString::null;
}
Example #3
0
bool KstIfaceImpl::activateWindow(const QString& windowname) {
  KstApp *app = KstApp::inst();
  KMdiChildView *win = app->findWindow(windowname);

  if (win) {
    win->activate();
    return true;
  }

  return false;
}
Example #4
0
bool KstIfaceImpl::positionWindow(int topleftX, int topleftY, int width, int height) {
  KstApp *app = KstApp::inst();
  KMdiChildView *win = app->activeWindow();

  if (win) {
    if (topleftX >= 0 && topleftY >= 0 && width >= 0 && height >= 0){
      QRect rectangle(topleftX, topleftY, width, height);
      win->setExternalGeometry(rectangle);
      return true;
    }
  }

  return false;
}
Example #5
0
void KMDITest::listBoxExecuted( QListBoxItem *item )
{
    // Get the current item's text
    QString text = item->text();

    // Active the corresponding tab
    for ( QValueList< KMdiChildView *>::iterator it = m_window.begin();
        it != m_window.end(); ++it ) {
        // Get the view
        KMdiChildView *view = *it;
        assert( view );

        // Is the view we need to show?
        if ( view->caption() == text ) {
            view->activate();
            break;
        }
    }
}
Example #6
0
QString KstGuiData::currentWindow() {
  KMdiChildView *c = KstApp::inst()->activeWindow();
  return c ? c->caption() : QString::null;
}