示例#1
0
void KstDataManagerI::contextMenu(QListViewItem *i, const QPoint& p, int col) {
  Q_UNUSED(col)
  KstObjectItem *koi = static_cast<KstObjectItem*>(i);
  KstBaseCurve *c;

  if (koi->rtti() == RTTI_OBJ_OBJECT || koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
    KPopupMenu *m = new KPopupMenu(this);

    m->setTitle(koi->text(0));

    int id = m->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
    //m->setItemEnabled(id, RTTI_OBJ_VECTOR != koi->rtti());

    if (koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
      id = m->insertItem(i18n("&Make Curve..."), koi, SLOT(makeCurve()));
    } else if ((c = dynamic_cast<KstBaseCurve*>(koi->dataObject().data()))) {
      KPopupMenu *addMenu = new KPopupMenu(this);
      KPopupMenu *removeMenu = new KPopupMenu(this);
      PlotMap.clear();
      id = 100;
      bool haveAdd = false, haveRemove = false;
      for (KstPlot *p = KST::plotList.first(); p; p = KST::plotList.next()) {
        if (!p->Curves.contains(c)) {
          addMenu->insertItem(p->tagName(), koi, SLOT(addToPlot(int)), 0, id);
          haveAdd = true;
        } else {
void VariablesListView::slotContextMenuRequested(QListViewItem* item, const QPoint& p, int)
{
  //   if(col != NameCol) return;
  enum { CopyVarItem, CopyValueItem };
  
  KPopupMenu* menu = new KPopupMenu(this);
  menu->insertItem("Copy variable", CopyVarItem);
  menu->insertItem("Copy value", CopyValueItem);
 
  int selection = menu->exec(p);
  if(selection == -1)
  {
    delete menu;
    return;
  }
  
  QClipboard* clip = kapp->clipboard();
  VariablesListViewItem* converted =
      dynamic_cast<VariablesListViewItem*>(item);
  
  switch(selection)
  {
    case CopyVarItem:
      clip->setText(converted->variable()->toString(), QClipboard::Clipboard);
      break;
    case CopyValueItem:
      clip->setText(converted->variable()->value()->toString(), QClipboard::Clipboard);
      break;
  }

  delete menu;
      
}
示例#3
0
void ServiceLoader::showPopup(const QString &popup, const QPoint &point)
{
  KPopupMenu *p = popups[popup];
  if(p){
    p->exec(point);
  }
}
示例#4
0
文件: knazar.cpp 项目: Tayyib/uludag
knazar::knazar()
    : DCOPObject( "DCOPNazarIface" ), KSystemTray( 0, "knazar" )
{
	// Insert TrayIcon
	trayIcon = KSystemTray::loadIcon( "knazar" );
	setPixmap( trayIcon );

	// Initialize and Register KNazar DCOP Interface so any KDE program can make Nazar easily
	if ( !kapp->dcopClient()->isRegistered() )
	{
		kapp->dcopClient()->registerAs( "knazar" );
		kapp->dcopClient()->setDefaultObject( objId() );
	}


	// Build PopupMenu
	KPopupMenu* menu = contextMenu();

	( new KAction( i18n( "Protect" ), "ledgreen", 0, this, SLOT( protect_from_harmfull_looks() ), this ) )->plug( menu );
	( new KAction( i18n( "Release" ), "ledred", 0, this, SLOT( release_the_protection() ), this ) )->plug( menu );
	menu->insertSeparator();
	( new KAction( i18n( "About" ), "about", 0, this, SLOT( about() ), this ) )->plug( menu );

	// Initialize variables
	protection_working = true;
	number_of_attacks = defated_attacks = 0;
	QToolTip::add( this, i18n( "knazar - No Harmfull look allowed!" ));
}
示例#5
0
/*!
    \fn SnippetWidget::showPopupMenu( QListViewItem * item, const QPoint & p, int )
    Shows the Popup-Menu depending item is a valid pointer
*/
void SnippetWidget::showPopupMenu( QListViewItem * item, const QPoint & p, int )
{
	KPopupMenu popup;

	SnippetItem * selectedItem = static_cast<SnippetItem *>(item);
	if ( item ) {
		popup.insertTitle( selectedItem->getName() );

		popup.insertItem( i18n("Add Item..."), this, SLOT( slotAdd() ) );
		popup.insertItem( i18n("Add Group..."), this, SLOT( slotAddGroup() ) );
        if (dynamic_cast<SnippetGroup*>(item)) {
            popup.insertItem( i18n("Edit..."), this, SLOT( slotEditGroup() ) );
        } else {
            popup.insertItem( i18n("Edit..."), this, SLOT( slotEdit() ) );
        }
		popup.insertItem( i18n("Remove"), this, SLOT( slotRemove() ) );

	} else {
		popup.insertTitle(i18n("Code Snippets"));

		popup.insertItem( i18n("Add Group..."), this, SLOT( slotAddGroup() ) );
	}

	popup.exec(p);
}
示例#6
0
 UIServerSystemTray(UIServer *uis) : KSystemTray(uis)
 {
     KPopupMenu *pop = contextMenu();
     pop->insertItem(i18n("Settings..."), uis, SLOT(slotConfigure()));
     pop->insertItem(i18n("Remove"), uis, SLOT(slotRemoveSystemTrayIcon()));
     setPixmap(loadIcon("filesave"));
     // actionCollection()->action("file_quit")->setEnabled(true);
     KStdAction::quit(uis, SLOT(slotQuit()), actionCollection());
 }
示例#7
0
void MDWEnum::showContextMenu()
{
    if( m_mixerwidget == NULL )
	return;

    KPopupMenu *menu = m_mixerwidget->getPopup();

    QPoint pos = QCursor::pos();
    menu->popup( pos );
}
示例#8
0
KPopupMenu *ClassToolWidget::createPopup()
{
    KPopupMenu *popup = contextItem? contextItem->createPopup() : 0;
    if (!popup) {
        popup = new KPopupMenu(this);
	popup->insertTitle(i18n("Class Tool"));
    }

    return popup;
}
示例#9
0
void KasLoadItem::showMenuAt( QPoint p )
{
    mouseLeave();
    kasbar()->updateMouseOver();

    KasTasker *bar = dynamic_cast<KasTasker *> (KasItem::kasbar());
    if ( !bar )
	return;

    KPopupMenu *menu = bar->contextMenu();
    menu->exec( p );
}
示例#10
0
void GrepViewWidget::popupMenu(QListBoxItem*, const QPoint& p)
{
	if(m_curOutput->isRunning()) return;

	KPopupMenu rmbMenu;

	if(KAction *findAction = m_part->actionCollection()->action("edit_grep"))
	{
		rmbMenu.insertTitle(i18n("Find in Files"));
		findAction->plug(&rmbMenu);
		rmbMenu.exec(p);
	}
}
示例#11
0
void
AnalyzerContainer::contextMenuEvent( QContextMenuEvent *e)
{
#if defined HAVE_LIBVISUAL
    KPopupMenu menu;
    menu.insertItem( SmallIconSet( Amarok::icon( "visualizations" ) ), i18n("&Visualizations"), Menu::ID_SHOW_VIS_SELECTOR );

    if( menu.exec( mapToGlobal( e->pos() ) ) == Menu::ID_SHOW_VIS_SELECTOR )
        Menu::instance()->slotActivated( Menu::ID_SHOW_VIS_SELECTOR );
#else
    Q_UNUSED(e);
#endif
}
示例#12
0
void FavoriteFolderView::contextMenu(QListViewItem *item, const QPoint &point)
{
    KMFolderTree *ft = mainWidget()->folderTree();
    assert(ft);
    KMFolderTreeItem *fti = static_cast<KMFolderTreeItem *>(item);
    mContextMenuItem = fti;
    KPopupMenu contextMenu;
    if(fti && fti->folder())
    {
        contextMenu.insertItem(SmallIconSet("editdelete"), i18n("Remove From Favorites"),
                               this, SLOT(removeFolder()));
        contextMenu.insertItem(SmallIconSet("edit"), i18n("Rename Favorite"), this, SLOT(renameFolder()));
        contextMenu.insertSeparator();

        mainWidget()->action("mark_all_as_read")->plug(&contextMenu);
        if(fti->folder()->folderType() == KMFolderTypeImap || fti->folder()->folderType() == KMFolderTypeCachedImap)
            mainWidget()->action("refresh_folder")->plug(&contextMenu);
        if(fti->folder()->isMailingListEnabled())
            mainWidget()->action("post_message")->plug(&contextMenu);

        contextMenu.insertItem(SmallIconSet("configure_shortcuts"), i18n("&Assign Shortcut..."), fti, SLOT(assignShortcut()));
        contextMenu.insertItem(i18n("Expire..."), fti, SLOT(slotShowExpiryProperties()));
        mainWidget()->action("modify")->plug(&contextMenu);
    }
    else
    {
        contextMenu.insertItem(SmallIconSet("bookmark_add"), i18n("Add Favorite Folder..."),
                               this, SLOT(addFolder()));
    }
    contextMenu.exec(point, 0);
}
示例#13
0
void HistoryDialog::slotRightClick(const QString &url, const QPoint &point)
{
	KPopupMenu *chatWindowPopup = 0L;
	chatWindowPopup = new KPopupMenu();
	
	if ( !url.isEmpty() )
	{
		mURL = url;
		mCopyURLAct->plug( chatWindowPopup );
		chatWindowPopup->insertSeparator();
	}
	mCopyAct->setEnabled( mHtmlPart->hasSelection() );
	mCopyAct->plug( chatWindowPopup );
	
	connect( chatWindowPopup, SIGNAL( aboutToHide() ), chatWindowPopup, SLOT( deleteLater() ) );
	chatWindowPopup->popup(point);
}
示例#14
0
void
AnalyzerContainer::mousePressEvent( QMouseEvent *e)
{
    if( e->button() == Qt::LeftButton ) {
        AmarokConfig::setCurrentPlaylistAnalyzer( AmarokConfig::currentPlaylistAnalyzer() + 1 );
        changeAnalyzer();
    }
    else if( e->button() == Qt::RightButton ) {
        #if defined HAVE_XMMS || defined HAVE_LIBVISUAL
        KPopupMenu menu;
        menu.insertItem( SmallIconSet( "visualizations" ), i18n("&Visualizations"), Menu::ID_SHOW_VIS_SELECTOR );

        if( menu.exec( mapToGlobal( e->pos() ) ) == Menu::ID_SHOW_VIS_SELECTOR )
            Menu::instance()->slotActivated( Menu::ID_SHOW_VIS_SELECTOR );
        #endif
    }
}
示例#15
0
void KSlovar::addMenu()
{
  KPopupMenu * filemenu = new KPopupMenu;
  m_newDictionary->plug(filemenu);
  m_openDictionary->plug(filemenu);
  filemenu->insertSeparator();
  m_print->plug(filemenu);
  filemenu->insertSeparator();
  m_close->plug(filemenu);
  m_quit->plug(filemenu);

  KPopupMenu *editmenu=new KPopupMenu;
  m_editDictionary->plug(editmenu);
  m_selectAll->plug(editmenu);
  editmenu->insertSeparator();
  m_addPhrase->plug(editmenu);
  m_editPhrase->plug(editmenu);
  m_removePhrase->plug(editmenu);
  editmenu->insertSeparator();
  m_find->plug(editmenu);
  m_findNext->plug(editmenu);
  m_literalSearch->plug(editmenu);
  m_backSearch->plug(editmenu);

  KPopupMenu *gomenu=new KPopupMenu;
  m_back->plug(gomenu);
  m_forward->plug(gomenu);
  m_home->plug(gomenu);

  KPopupMenu *setmenu=new KPopupMenu;
  m_config->plug(setmenu);
  m_conversion->plug(setmenu);
  m_update->plug(setmenu);
  m_wizard->plug(setmenu);

  KPopupMenu *help = helpMenu();

  KMenuBar * menu = menuBar();
  menu->insertItem( i18n( "&File" ), filemenu );
  menu->insertItem(i18n("&Edit"), editmenu);
  menu->insertItem(i18n("&Go"), gomenu);
  menu->insertItem(i18n("&Settings"), setmenu);
  menu->insertItem( i18n( "&Help" ), help );
}
示例#16
0
bool Sidebar::eventFilter(QObject *obj, QEvent *ev)
{
  if (ev->type()==QEvent::ContextMenu)
  {
    QContextMenuEvent *e = (QContextMenuEvent *) ev;
    KMultiTabBarTab *bt = dynamic_cast<KMultiTabBarTab*>(obj);
    if (bt)
    {
      kdDebug()<<"Request for popup"<<endl;

      m_popupButton = bt->id();

      ToolView *w = m_idToWidget[m_popupButton];

      if (w)
      {
        KPopupMenu *p = new KPopupMenu (this);

        p->insertTitle(SmallIcon("view_remove"), i18n("Behavior"), 50);

        p->insertItem(w->persistent ? SmallIconSet("window_nofullscreen") : SmallIconSet("window_fullscreen"), w->persistent ? i18n("Make Non-Persistent") : i18n("Make Persistent"), 10);

        p->insertTitle(SmallIcon("move"), i18n("Move To"), 51);

        if (position() != 0)
          p->insertItem(SmallIconSet("back"), i18n("Left Sidebar"),0);

        if (position() != 1)
          p->insertItem(SmallIconSet("forward"), i18n("Right Sidebar"),1);

        if (position() != 2)
          p->insertItem(SmallIconSet("up"), i18n("Top Sidebar"),2);

        if (position() != 3)
          p->insertItem(SmallIconSet("down"), i18n("Bottom Sidebar"),3);

        connect(p, SIGNAL(activated(int)),
              this, SLOT(buttonPopupActivate(int)));

        p->exec(e->globalPos());
        delete p;

        return true;
      }
    }
  }
示例#17
0
void KSysTrayCmd::execContextMenu( const QPoint &pos )
{
    KPopupMenu *menu = new KPopupMenu();
    menu->insertTitle( *pixmap(), i18n( "KSysTrayCmd" ) );
    int hideShowId = menu->insertItem( isVisible ? i18n( "&Hide" ) : i18n( "&Restore" ) );
    int undockId = menu->insertItem( SmallIcon("close"), i18n( "&Undock" ) );
    int quitId = menu->insertItem( SmallIcon("exit"), i18n( "&Quit" ) );

    int cmd = menu->exec( pos );

    if ( cmd == quitId )
      quitClient();
    else if ( cmd == undockId )
      quit();
    else if ( cmd == hideShowId )
    {
      if ( lazyStart && ( !hasRunningClient() ) )
      {
        start();
        isVisible=true;
      }
      else if ( quitOnHide && ( hasRunningClient() ) && isVisible )
      {
        NETRootInfo ri( qt_xdisplay(), NET::CloseWindow );
        ri.closeWindowRequest( win );
        isVisible=false;
      }
      else
        toggleWindow();
    }

    delete menu;
}
示例#18
0
//Credit to amaroK for this
//Seems like it can become the next plugin to do since amarok is really cool (just missing plugin arch)
bool SongList::eventFilter(QObject *o, QEvent *e ) {
    if(o == header() && e->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(e)->button() == Qt::RightButton ) {
        KPopupMenu popup;
        //popup.setFont(this->font());
        popup.setCheckable(true);
        popup.insertTitle(i18n("Available Columns"));
        int colcount=columns();
        for( int i = 0; i < colcount; ++i ) //columns() references a property
        {
            popup.insertItem(columnText(i),i,i+1 );
            popup.setItemChecked(i,columnWidth(i)!=0);
        }

        int col = popup.exec( static_cast<QMouseEvent *>(e)->globalPos() );

        if( col != -1 ) {
            //TODO can result in massively wide column appearing!
            if( columnWidth( col ) == 0 ) {
                adjustColumn( col );
                header()->setResizeEnabled( true, col );
            } else hideColumn( col );
        }

        //determine first visible column again, since it has changed
        //eat event
        return TRUE;
    }
    return KListView::eventFilter(o,e);
}
示例#19
0
void ChatBase::initMenuBar()
{
  // Icons: /opt/kde2/share/icons/hicolor/16x16/actions

  menuBar()->clear();

  KPopupMenu* fileMenu = new KPopupMenu(menuBar(), "FileMenu");
  fileMenu->insertItem(SmallIcon("filesave"), i18n("&Save (Formatted)"), this, SLOT(saveHTML()),
		       ALT+Key_S );
  fileMenu->insertItem(SmallIcon("filesave"), i18n("S&ave (Unformatted)"), this, SLOT(saveText()), ALT+Key_A );
  fileMenu->insertItem( i18n("&Close"), this, SLOT(quit()) );
  menuBar()->insertItem( i18n("&File"), fileMenu );
  
  KPopupMenu* editMenu = new KPopupMenu(menuBar(), "EditMenu");
  editMenu->insertItem(SmallIcon("editcopy"), i18n("&Copy"), this, SLOT(copy()), CTRL+Key_C );
  editMenu->insertItem(SmallIcon("editcut"), i18n("C&ut"), this, SLOT(cut()), CTRL+Key_X );
  editMenu->insertItem(SmallIcon("editpaste"), i18n("&Paste"), this, SLOT(paste()), CTRL+Key_V );
  menuBar()->insertItem( i18n("&Edit"), editMenu);


#if 0
	KPopupMenu* buddyMenu = new KPopupMenu(menuBar(), "BuddyMenu");
	buddyMenu->insertItem("&Profile",this,SLOT(profile()),CTRL+Key_P);
  menuBar()->insertItem("&Buddy", buddyMenu);

  KPopupMenu viewMenu = new KPopupMenu(menuBar, "ViewMenu");
  menuBar->insertItem("&View", viewMenu);

  KPopupMenu insertMenu = new KPopupMenu(menuBar, "InsertMenu");
  menuBar->insertItem("&Insert", insertMenu);

  KPopupMenu insertFaceMenu = new KPopupMenu(insertMenu, "FaceMenu");

  KPopupMenu helpMenu = new KPopupMenu(kmenuBar, "HelpMenu");
  menuBar->insertItem("&Help", helpMenu);
	
#endif

} // initMenuBar
示例#20
0
k2send::k2send()
    : KMainWindow( 0, "k2send" ),
      m_printer(0)
{
    m_config = new KConfig("k2send");
    m_view = new k2sendWidget(this,"k2sendwidget",0,m_config);

    setAcceptDrops(FALSE);

    setCentralWidget(m_view);
    setupActions();
    statusBar()->show();
    setAutoSaveSettings();
    statusBar()->insertFixedItem("9999 Files", 0, true);
    statusBar()->insertFixedItem("00:00:00", 1, true);
    statusBar()->insertFixedItem("000 kbit/s", 2, true);
    statusBar()->insertFixedItem("Loud: 0", 3, true);
    statusBar()->insertFixedItem("00:00:00:00:00:00 ", 4, true);
    statusBar()->changeItem ("0 Files", 0);
    statusBar()->changeItem ("0 kbit/s", 2);

    trayicon = new KSystemTray(this, "k2sendtray");
    trayicon->show();
    trayicon->setPixmap (DesktopIcon( "k2send", 24));
    KPopupMenu * pop = trayicon->contextMenu() ;
    pop->insertItem(DesktopIcon( "player_play", 16 ), "Play",  m_view, SLOT(slotPlay()), CTRL+Key_P ,1,1);
    pop->insertItem(DesktopIcon( "player_stop", 16 ), "Stop",  m_view, SLOT(slotStop()), CTRL+Key_S ,2,2);
    pop->insertItem(DesktopIcon( "player_fwd", 16 ), "Next",  m_view, SLOT(slotSkip()), CTRL+Key_N ,3,3);
    pop->insertItem( "Loundess",  m_view, SLOT(slotLoudness()), CTRL+Key_L ,4,4);

    connect(m_view, SIGNAL(signalChangeStatusbar(const QString&)),
            this,   SLOT(changeStatusbar(const QString&)));
    connect(m_view, SIGNAL(signalChangeCaption(const QString&)),
            this,   SLOT(changeCaption(const QString&)));

}
示例#21
0
/**
 * Shows the popupmenu at a given point.
 */
void SelectTool::showPopupMenu( const QPoint &pos )
{
  KPopupMenu* menu = 0;

  if(view()->activePage()->selectedStencils()->count() < 1) {
    menu = static_cast<KPopupMenu*>(view()->factory()->container("PagePopup", view()));
  } else {
    menu = static_cast<KPopupMenu*>(view()->factory()->container("StencilPopup", view()));
    m_arrowHeadAction->setEnabled(view()->activePage()->checkForStencilTypeInSelection(kstConnector));

    if(view()->activePage()->checkForTextBoxesInSelection()) {
      m_textEditAction->setEnabled(true);
    } else {
      m_textEditAction->setEnabled(false);
    }
  }

  if(menu) {
    m_lastPoint = view()->canvasWidget()->mapFromScreen(pos);
    menu->popup(pos);
  } else {
    kdDebug(43000) << "What no popup! *ARGH*!" << endl;
  }
}
示例#22
0
//void OutputText::contextMenuEvent(QContextMenuEvent* e)
QPopupMenu* OutputText::createPopupMenu(const QPoint&)
{
    KPopupMenu* popup = new KPopupMenu;

    int id = popup->insertItem(i18n("Show Internal Commands"),
                               this,
                               SLOT(toggleShowInternalCommands()));

    popup->setItemChecked(id, parent_->showInternalCommands_);
    popup->setWhatsThis(
        id,
        i18n(
            "Controls if commands issued internally by KDevelop "
            "will be shown or not.<br>"
            "This option will affect only future commands, it won't "
            "add or remove already issued commands from the view."));

    popup->insertItem(i18n("Copy All"),
                      this,
                      SLOT(copyAll()));


    return popup;
}
示例#23
0
void
ScriptManager::slotShowContextMenu( QListViewItem* item, const QPoint& pos )
{
    const bool isCategory = item == m_generalCategory ||
                            item == m_lyricsCategory ||
                            item == m_scoreCategory ||
                            item == m_transcodeCategory;

    if( !item || isCategory ) return;

    // Look up script entry in our map
    ScriptMap::Iterator it;
    ScriptMap::Iterator end( m_scripts.end() );
    for( it = m_scripts.begin(); it != end; ++it )
        if( it.data().li == item ) break;

    enum { SHOW_LOG, EDIT };
    KPopupMenu menu;
    menu.insertTitle( i18n( "Debugging" ) );
    menu.insertItem( SmallIconSet( amaroK::icon( "clock" ) ), i18n( "Show Output &Log" ), SHOW_LOG );
    menu.insertItem( SmallIconSet( amaroK::icon( "edit" ) ), i18n( "&Edit" ), EDIT );
    menu.setItemEnabled( SHOW_LOG, it.data().process );
    const int id = menu.exec( pos );

    switch( id )
    {
        case EDIT:
            KRun::runCommand( "kwrite " + it.data().url.path() );
            break;

        case SHOW_LOG:
            QString line;
            while( it.data().process->readln( line ) != -1 )
                it.data().log += line;

            KTextEdit* editor = new KTextEdit( it.data().log );
            kapp->setTopWidget( editor );
            editor->setCaption( kapp->makeStdCaption( i18n( "Output Log for %1" ).arg( it.key() ) ) );
            editor->setReadOnly( true );

            QFont font( "fixed" );
            font.setFixedPitch( true );
            font.setStyleHint( QFont::TypeWriter );
            editor->setFont( font );

            editor->setTextFormat( QTextEdit::PlainText );
            editor->resize( 500, 380 );
            editor->show();
            break;
    }
}
示例#24
0
ICNView::ICNView(ICNDocument *icnDocument, ViewContainer *viewContainer, uint viewAreaId, const char *name)
		: ItemView(icnDocument, viewContainer, viewAreaId, name) {
	bool manualRouting = (icnDocument->m_cmManager->cmState() & CMManager::cms_manual_route);

	KActionCollection * ac = actionCollection();

	//BEGIN Routing Actions
	// These actions get inserted into the main menu
	m_pAutoRoutingAction = new KRadioAction(i18n("Automatic"), "", 0, this, SLOT(slotSetRoutingAuto()), ac, "routing_mode_auto");
	m_pAutoRoutingAction->setExclusiveGroup("routing_mode");

	if (!manualRouting)
		m_pAutoRoutingAction->setChecked(true);

	m_pManualRoutingAction = new KRadioAction(i18n("Manual"), "", 0, this, SLOT(slotSetRoutingManual()), ac, "routing_mode_manual");

	m_pManualRoutingAction->setExclusiveGroup("routing_mode");

	if (manualRouting)
		m_pManualRoutingAction->setChecked(true);

	// This popup gets inserted into the toolbar
	m_pRoutingModeToolbarPopup = new KToolBarPopupAction(i18n("Connection Routing Mode"), "pencil", 0, 0, 0, ac, "routing_mode");

	m_pRoutingModeToolbarPopup->setDelayed(false);

	KPopupMenu *m = m_pRoutingModeToolbarPopup->popupMenu();

	m->insertTitle(i18n("Connection Routing Mode"));
	m->insertItem(/*KGlobal::iconLoader()->loadIcon( "routing_mode_auto",	KIcon::Small ), */i18n("Automatic"), 0);

	m->insertItem(/*KGlobal::iconLoader()->loadIcon( "routing_mode_manual",	KIcon::Small ),*/ i18n("Manual"), 1);

	m->setCheckable(true);
	m->setItemChecked(manualRouting ? 1 : 0, true);

	connect(m, SIGNAL(activated(int)), this, SLOT(slotSetRoutingMode(int)));

	//END Routing Actions

	connect(icnDocument->m_cmManager, SIGNAL(manualRoutingChanged(bool)), this, SLOT(slotUpdateRoutingToggles(bool)));
}
示例#25
0
KToolBar *
xQGanttBarViewPort::toolbar(QMainWindow *mw)
{
    if(_toolbar || mw == 0) return _toolbar;

    _toolbar = new KToolBar(mw, QMainWindow::DockTop);

    mw->addToolBar(_toolbar);


    // KIconLoader* iconloader = new KIconLoader("kgantt");


    _toolbar->insertButton("ganttSelect.png", 0,
                           SIGNAL(clicked()),
                           this, SLOT(setSelect()),
                           true, i18n("Select"));

    KPopupMenu *selectMenu = new KPopupMenu(_toolbar);


    /*
      select all items
    */
    QPixmap pix = _iconloader->loadIcon("ganttSelecttask.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("ganttSelecttask.png not found !\n");
    selectMenu->insertItem(pix, i18n("Select All"), this, SLOT(selectAll()));


    /*
      unselect all items
    */
    pix = _iconloader->loadIcon("ganttUnselecttask", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("ganttUnselecttask.png not found !\n");
    selectMenu->insertItem(pix, i18n("Unselect All"), this, SLOT(unselectAll()));


    KToolBarButton *b = _toolbar->getButton(0);
    b->setDelayedPopup(selectMenu);


    _toolbar->insertButton("viewmag.png", 1,
                           SIGNAL(clicked()),
                           this, SLOT(setZoom()),
                           true, i18n("Zoom"));

    KPopupMenu *zoomMenu = new KPopupMenu(_toolbar);

    pix = _iconloader->loadIcon("viewmag.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("viewmag.png not found !\n");
    zoomMenu->insertItem(pix, i18n("Zoom All"), this, SLOT(zoomAll()));
    zoomMenu->insertSeparator();

    pix = _iconloader->loadIcon("viewmag+.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("viewmag+.png not found !\n");
    zoomMenu->insertItem(pix, i18n("Zoom In +"), this, SLOT(zoomIn()));

    pix = _iconloader->loadIcon("viewmag-.png", KIcon::Toolbar , 16);
    if(pix.isNull()) printf("viewmag-.png not found !\n");
    zoomMenu->insertItem(pix, i18n("Zoom Out -"), this, SLOT(zoomOut()));

    b = _toolbar->getButton(1);
    b->setDelayedPopup(zoomMenu);

    _toolbar->insertButton("move.png", 2,
                           SIGNAL(clicked()),
                           this, SLOT(setMove()),
                           true, i18n("Move"));

    return _toolbar;

}
示例#26
0
/**
 * This function will intialize the playlist window.
 */
void PlaylistWindow::init()
{
    DEBUG_BLOCK

    //this function is necessary because amaroK::actionCollection() returns our actionCollection
    //via the App::m_pPlaylistWindow pointer since App::m_pPlaylistWindow is not defined until
    //the above ctor returns it causes a crash unless we do the initialisation in 2 stages.

    m_browsers = new BrowserBar( this );

    //<Dynamic Mode Status Bar />
    DynamicBar *dynamicBar = new DynamicBar( m_browsers->container());

    { //<Search LineEdit>
        KToolBar *bar = new KToolBar( m_browsers->container(), "NotMainToolBar" );
        bar->setIconSize( 22, false ); //looks more sensible
        bar->setFlat( true ); //removes the ugly frame
        bar->setMovingEnabled( false ); //removes the ugly frame

        QWidget *button = new KToolBarButton( "locationbar_erase", 1, bar );
        QLabel *filter_label = new QLabel( i18n("S&earch:") + " ", bar );
        m_lineEdit = new ClickLineEdit( i18n( "Enter search terms here" ), bar );

        filter_label->setBuddy( m_lineEdit );

        bar->setStretchableWidget( m_lineEdit );
        m_lineEdit->setFrame( QFrame::Sunken );
        m_lineEdit->installEventFilter( this ); //we intercept keyEvents

        connect( button, SIGNAL(clicked()), m_lineEdit, SLOT(clear()) );

        QToolTip::add( button, i18n( "Clear filter" ) );
        QString filtertip = i18n( "Enter space-separated terms to filter the playlist.\n\n"
                                  "Advanced, Google-esque syntax is also available;\n"
                                  "see the handbook (The Playlist section of chapter 4) for details." );

        QToolTip::add( filter_label, filtertip );
        QToolTip::add( m_lineEdit, filtertip );
    } //</Search LineEdit>



    QFrame *playlist = new Playlist( m_browsers->container() );
    dynamicBar->init();
    m_toolbar = new amaroK::ToolBar( m_browsers->container(), "mainToolBar" );
    m_toolbar->setShown( AmarokConfig::showToolbar() );
    QWidget *statusbar = new amaroK::StatusBar( this );

    KAction* repeatAction = amaroK::actionCollection()->action( "repeat" );
    connect( repeatAction, SIGNAL( activated( int ) ), playlist, SLOT( slotRepeatTrackToggled( int ) ) );

    connect( m_lineEdit, SIGNAL(textChanged( const QString& )), playlist, SLOT(setFilterSlot( const QString& )) );

    m_menubar = new KMenuBar( this );
    m_menubar->setShown( AmarokConfig::showMenuBar() );

    //BEGIN Actions menu
    KPopupMenu *actionsMenu = new KPopupMenu( m_menubar );
    actionCollection()->action("playlist_playmedia")->plug( actionsMenu );
    actionCollection()->action("play_audiocd")->plug( actionsMenu );
    actionsMenu->insertSeparator();
    actionCollection()->action("prev")->plug( actionsMenu );
    actionCollection()->action("play_pause")->plug( actionsMenu );
    actionCollection()->action("stop")->plug( actionsMenu );
    actionCollection()->action("next")->plug( actionsMenu );
    actionsMenu->insertSeparator();
    actionCollection()->action(KStdAction::name(KStdAction::Quit))->plug( actionsMenu );

    connect( actionsMenu, SIGNAL( aboutToShow() ), SLOT( actionsMenuAboutToShow() ) );
    //END Actions menu

    //BEGIN Playlist menu
    KPopupMenu *playlistMenu = new KPopupMenu( m_menubar );
    actionCollection()->action("playlist_add")->plug( playlistMenu );
    actionCollection()->action("playlist_save")->plug( playlistMenu );
    playlistMenu->insertSeparator();
    actionCollection()->action("playlist_undo")->plug( playlistMenu );
    actionCollection()->action("playlist_redo")->plug( playlistMenu );
    playlistMenu->insertSeparator();
    actionCollection()->action("playlist_clear")->plug( playlistMenu );
    actionCollection()->action("playlist_shuffle")->plug( playlistMenu );
    actionCollection()->action("playlist_show")->plug( playlistMenu );
    //this one has no real context with regard to the menu
    //actionCollection()->action("playlist_copy")->plug( playlistMenu );
    playlistMenu->insertSeparator();
    actionCollection()->action("queue_selected")->plug( playlistMenu );
    actionCollection()->action("playlist_remove_duplicates")->plug( playlistMenu );
    actionCollection()->action("playlist_select_all")->plug( playlistMenu );
    //END Playlist menu

    //BEGIN Mode menu
    KPopupMenu *modeMenu = new KPopupMenu( m_menubar );
    actionCollection()->action("repeat")->plug( modeMenu );
    KSelectAction *random = static_cast<KSelectAction*>( actionCollection()->action("random_mode") );
    random->plug( modeMenu );
    random->popupMenu()->insertSeparator();
    actionCollection()->action("favor_tracks")->plug( random->popupMenu() );
    //END Mode menu

    //BEGIN Tools menu
    m_toolsMenu = new KPopupMenu( m_menubar );
    m_toolsMenu->insertItem( SmallIconSet( "covermanager" ), i18n("&Cover Manager"), amaroK::Menu::ID_SHOW_COVER_MANAGER );
    actionCollection()->action("queue_manager")->plug( m_toolsMenu );
    m_toolsMenu->insertItem( SmallIconSet( "visualizations"), i18n("&Visualizations"), amaroK::Menu::ID_SHOW_VIS_SELECTOR );
    m_toolsMenu->insertItem( SmallIconSet( "equalizer"), i18n("&Equalizer"), kapp, SLOT( slotConfigEqualizer() ), 0, amaroK::Menu::ID_CONFIGURE_EQUALIZER );
    actionCollection()->action("script_manager")->plug( m_toolsMenu );
    actionCollection()->action("statistics")->plug( m_toolsMenu );
    m_toolsMenu->insertSeparator();
    m_toolsMenu->insertItem( SmallIconSet( "wizard"), i18n("&First-Run Wizard"), amaroK::Menu::ID_SHOW_WIZARD );
    m_toolsMenu->insertItem( SmallIconSet( amaroK::icon( "rescan" ) ), i18n("&Rescan Collection"), amaroK::Menu::ID_RESCAN_COLLECTION );

    #if defined HAVE_XMMS || defined HAVE_LIBVISUAL
    m_toolsMenu->setItemEnabled( amaroK::Menu::ID_SHOW_VIS_SELECTOR, true );
    #else
    m_toolsMenu->setItemEnabled( amaroK::Menu::ID_SHOW_VIS_SELECTOR, false );
    #endif

    connect( m_toolsMenu, SIGNAL( aboutToShow() ), SLOT( toolsMenuAboutToShow() ) );
    connect( m_toolsMenu, SIGNAL( activated(int) ), SLOT( slotMenuActivated(int) ) );
    //END Tools menu

    //BEGIN Settings menu
    m_settingsMenu = new KPopupMenu( m_menubar );
    //TODO use KStdAction or KMainWindow
    static_cast<KToggleAction *>(actionCollection()->action(KStdAction::name(KStdAction::ShowMenubar)))->setChecked( AmarokConfig::showMenuBar() );
    actionCollection()->action(KStdAction::name(KStdAction::ShowMenubar))->plug( m_settingsMenu );
    m_settingsMenu->insertItem( AmarokConfig::showToolbar() ? i18n( "Hide Toolbar" ) : i18n("Show Toolbar"), ID_SHOW_TOOLBAR );
    m_settingsMenu->insertItem( AmarokConfig::showPlayerWindow() ? i18n("Hide Player &Window") : i18n("Show Player &Window"), ID_SHOW_PLAYERWINDOW );
    m_settingsMenu->insertSeparator();
    actionCollection()->action("options_configure_globals")->plug( m_settingsMenu );
    actionCollection()->action(KStdAction::name(KStdAction::KeyBindings))->plug( m_settingsMenu );
    actionCollection()->action(KStdAction::name(KStdAction::ConfigureToolbars))->plug( m_settingsMenu );
    actionCollection()->action(KStdAction::name(KStdAction::Preferences))->plug( m_settingsMenu );

    connect( m_settingsMenu, SIGNAL( activated(int) ), SLOT( slotMenuActivated(int) ) );
    //END Settings menu

    m_menubar->insertItem( i18n( "&Actions" ), actionsMenu );
    m_menubar->insertItem( i18n( "&Playlist" ), playlistMenu );
    m_menubar->insertItem( i18n( "&Mode" ), modeMenu );
    m_menubar->insertItem( i18n( "&Tools" ), m_toolsMenu );
    m_menubar->insertItem( i18n( "&Settings" ), m_settingsMenu );
    m_menubar->insertItem( i18n( "&Help" ), amaroK::Menu::helpMenu() );


    QBoxLayout *layV = new QVBoxLayout( this );
    layV->addWidget( m_menubar );
    layV->addWidget( m_browsers, 1 );
    layV->addWidget( m_toolbar );
    layV->addSpacing( 2 );
    layV->addWidget( statusbar );

    //The volume slider later becomes our FocusProxy, so all wheelEvents get redirected to it
    m_toolbar->setFocusPolicy( QWidget::WheelFocus );
    m_toolbar->setFlat( true );
    m_toolbar->setMovingEnabled( false );
    playlist->setMargin( 2 );
    playlist->installEventFilter( this ); //we intercept keyEvents


    //<XMLGUI>
    {
        QString xmlFile = amaroK::config()->readEntry( "XMLFile", "amarokui.rc" );

        if ( xmlFile == "amarokui_first.rc" )
            // this bug can bite you if you are a pre 1.2 user, we
            // deleted amarokui_first.rc, but we must still support it
            xmlFile = "amarokui.rc";

        setXMLFile( xmlFile );
        createGUI(); //NOTE we implement this
    }
    //</XMLGUI>


    //<Browsers>
    {
        Debug::Block block( "Creating browsers. Please report long start times!" );

        #define addBrowserMacro( Type, name, text, icon ) { \
            Debug::Block block( name ); \
            m_browsers->addBrowser( new Type( name ), text, icon ); }

        #define addInstBrowserMacro( Type, name, text, icon ) { \
            Debug::Block block( name ); \
            m_browsers->addBrowser( Type::instance(), text, icon ); }

        addBrowserMacro( ContextBrowser, "ContextBrowser", i18n( "Context" ), amaroK::icon( "info" ) )
        addBrowserMacro( CollectionBrowser, "CollectionBrowser", i18n( "Collection" ), amaroK::icon( "collection" ) )
        addInstBrowserMacro( PlaylistBrowser, "PlaylistBrowser", i18n( "Playlists" ), amaroK::icon( "playlist" ) )

        //DEBUG: Comment out the addBrowserMacro line and uncomment the m_browsers line (passing in a vfat device name) to see the "virtual root" functionality

        addBrowserMacro( FileBrowser, "FileBrowser", i18n( "Files" ), "folder" )
        //m_browsers->addBrowser( new FileBrowser( "FileBrowser", DeviceManager::instance()->getDevice( "hda5" ) ), i18n( "Files" ), "folder" );

        new MediaBrowser( "MediaBrowser" );
        if( MediaBrowser::isAvailable() )
            addInstBrowserMacro( MediaBrowser, "MediaBrowser", i18n( "Media Device" ), amaroK::icon( "device" ) )
        #undef addBrowserMacro
        #undef addInstBrowserMacro
    }
    //</Browsers>

    connect( Playlist::instance()->qscrollview(), SIGNAL( dynamicModeChanged( const DynamicMode* ) ),
             PlaylistBrowser::instance(), SLOT( loadDynamicItems() ) );


    qApp->installEventFilter( this ); // keyboards shortcuts for the browsers

    connect( playlist, SIGNAL( itemCountChanged(     int, int, int, int, int, int ) ),
             statusbar,  SLOT( slotItemCountChanged( int, int, int, int, int, int ) ) );
    connect( playlist, SIGNAL( queueChanged( const PLItemList &, const PLItemList & ) ),
             statusbar,  SLOT( updateQueueLabel() ) );
    connect( playlist, SIGNAL( aboutToClear() ), m_lineEdit, SLOT( clear() ) );
    amaroK::MessageQueue::instance()->sendMessages();
}
void DolphinContextMenu::openViewportContextMenu()
{
    // Parts of the following code have been taken
    // from the class KonqOperations located in
    // libqonq/konq_operations.h of Konqueror.
    // (Copyright (C) 2000  David Faure <*****@*****.**>)

    assert(m_fileInfo == 0);
    const int propertiesID = 100;
	const int bookmarkID = 101;

    KPopupMenu* popup = new KPopupMenu(m_dolphinView);
    Dolphin& dolphin = Dolphin::mainWin();

    // setup 'Create New' menu
    KPopupMenu* createNewMenu = new KPopupMenu();

    KAction* createFolderAction = dolphin.actionCollection()->action("create_folder");
    if (createFolderAction != 0) {
        createFolderAction->plug(createNewMenu);
    }

    createNewMenu->insertSeparator();

    KAction* action = 0;

    QPtrListIterator<KAction> fileGrouptIt(dolphin.fileGroupActions());
    while ((action = fileGrouptIt.current()) != 0) {
        action->plug(createNewMenu);
        ++fileGrouptIt;
    }

    // TODO: not used yet. See documentation of Dolphin::linkGroupActions()
    // and Dolphin::linkToDeviceActions() in the header file for details.
    //
    //createNewMenu->insertSeparator();
    //
    //QPtrListIterator<KAction> linkGroupIt(dolphin.linkGroupActions());
    //while ((action = linkGroupIt.current()) != 0) {
    //    action->plug(createNewMenu);
    //    ++linkGroupIt;
    //}
    //
    //KPopupMenu* linkToDeviceMenu = new KPopupMenu();
    //QPtrListIterator<KAction> linkToDeviceIt(dolphin.linkToDeviceActions());
    //while ((action = linkToDeviceIt.current()) != 0) {
    //    action->plug(linkToDeviceMenu);
    //    ++linkToDeviceIt;
    //}
    //
    //createNewMenu->insertItem(i18n("Link to Device"), linkToDeviceMenu);

    const KURL& url = dolphin.activeView()->url();
    if (url.protocol() == "trash")
    {
        popup->insertItem(i18n("Empty Deleted Items Folder"), emptyID);
    }
    else
    {
        popup->insertItem(SmallIcon("filenew"), i18n("Create New"), createNewMenu);
    }
    popup->insertSeparator();

    KAction* pasteAction = dolphin.actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
    pasteAction->plug(popup);

    // setup 'View Mode' menu
    KPopupMenu* viewModeMenu = new KPopupMenu();

    KAction* iconsMode = dolphin.actionCollection()->action("icons");
    iconsMode->plug(viewModeMenu);

    KAction* detailsMode = dolphin.actionCollection()->action("details");
    detailsMode->plug(viewModeMenu);

    KAction* previewsMode = dolphin.actionCollection()->action("previews");
    previewsMode->plug(viewModeMenu);

    popup->insertItem(i18n("View Mode"), viewModeMenu);
    popup->insertSeparator();

    popup->insertItem(i18n("Bookmark this folder"), bookmarkID);
    popup->insertSeparator();

    popup->insertItem(i18n("Properties..."), propertiesID);

    int id = popup->exec(m_pos);
    if (id == emptyID) {
        KonqOperations::emptyTrash();
    }
    else if (id == propertiesID) {
        new KPropertiesDialog(dolphin.activeView()->url());
    }
    else if (id == bookmarkID) {
        const KURL& url = dolphin.activeView()->url();
        KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add folder as bookmark"),
                                                             url.filename(),
                                                             url,
                                                             "bookmark");
        if (!bookmark.isNull()) {
            KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager();
            KBookmarkGroup root = manager->root();
            root.addBookmark(manager, bookmark);
            manager->emitChanged(root);
        }
    }

    popup->deleteLater();
}
示例#28
0
void PerforcePart::contextMenu(QPopupMenu *popup, const Context *context)
{
    if (context->hasType( Context::FileContext )) {
        const FileContext *fcontext = static_cast<const FileContext*>(context);
        popupfile = fcontext->urls().first().path();
        QFileInfo fi( popupfile );
        popup->insertSeparator();

        KPopupMenu *sub = new KPopupMenu(popup);
        QString name = fi.fileName();
        sub->insertTitle( i18n("Actions for %1").arg(name) );

        int id = sub->insertItem( i18n("Edit"),
                           this, SLOT(slotEdit()) );
        sub->setWhatsThis(id, i18n("<b>Edit</b><p>Opens file(s) in a client workspace for edit."));
        id = sub->insertItem( i18n("Revert"),
                           this, SLOT(slotRevert()) );
        sub->setWhatsThis(id, i18n("<b>Revert</b><p>Discards changes made to open files."));
        id = sub->insertItem( i18n("Submit"),
                           this, SLOT(slotCommit()) );
        sub->setWhatsThis(id, i18n("<b>Submit</b><p>Sends changes made to open files to the depot."));
        id = sub->insertItem( i18n("Sync"),
                           this, SLOT(slotUpdate()) );
        sub->setWhatsThis(id, i18n("<b>Sync</b><p>Copies files from the depot into the workspace."));
        sub->insertSeparator();
        id = sub->insertItem( i18n("Diff Against Repository"),
                          this, SLOT(slotDiff()) );
        sub->setWhatsThis(id, i18n("<b>Diff against repository</b><p>Compares a client workspace file to a revision in the depot."));
        id = sub->insertItem( i18n("Add to Repository"),
                           this, SLOT(slotAdd()) );
        sub->setWhatsThis(id, i18n("<b>Add to repository</b><p>Open file(s) in a client workspace for addition to the depot."));
        id = sub->insertItem( i18n("Remove From Repository"),
                           this, SLOT(slotRemove()) );
        sub->setWhatsThis(id, i18n("<b>Remove from repository</b><p>Open file(s) in a client workspace for deletion from the depot."));
        id = popup->insertItem(i18n("Perforce"), sub);
    }
}
void
RadialMap::Widget::mousePressEvent( QMouseEvent *e )
{
   //m_tip is hidden already by event filter
   //m_focus is set correctly (I've been strict, I assure you it is correct!)

   enum { Konqueror, Konsole, Center, Open, Copy, Delete };

   if (m_focus && !m_focus->isFake())
   {
      const KURL url   = Widget::url( m_focus->file() );
      const bool isDir = m_focus->file()->isDirectory();

      if( e->button() == Qt::RightButton )
      {
         KPopupMenu popup;
         popup.insertTitle( m_focus->file()->fullPath( m_tree ) );

         if (isDir) {
            popup.insertItem( SmallIconSet( "konqueror" ), i18n( "Open &Konqueror Here" ), Konqueror );

            if( url.protocol() == "file" )
               popup.insertItem( SmallIconSet( "konsole" ), i18n( "Open &Konsole Here" ), Konsole );

            if (m_focus->file() != m_tree) {
               popup.insertSeparator();
               popup.insertItem( SmallIconSet( "viewmag" ), i18n( "&Center Map Here" ), Center );
            }
         }
         else
            popup.insertItem( SmallIconSet( "fileopen" ), i18n( "&Open" ), Open );

         popup.insertSeparator();
         popup.insertItem( SmallIconSet( "editcopy" ), i18n( "&Copy to clipboard" ), Copy );

         popup.insertSeparator();
         popup.insertItem( SmallIconSet( "editdelete" ), i18n( "&Delete" ), Delete );

         switch (popup.exec( e->globalPos(), 1 )) {
            case Konqueror:
                //KRun::runCommand will show an error message if there was trouble
                KRun::runCommand( QString( "kfmclient openURL \"%1\"" ).arg( url.url() ) );
                break;

            case Konsole:
                // --workdir only works for local file paths
                KRun::runCommand( QString( "konsole --workdir \"%1\"" ).arg( url.path() ) );
                break;

            case Center:
            case Open:
                goto section_two;

            case Copy:
                QApplication::clipboard()->setData( new KURLDrag( KURL::List( url ) ) );
                break;

            case Delete:
            {
                const KURL url = Widget::url( m_focus->file() );
                const QString message = m_focus->file()->isDirectory()
                        ? i18n( "<qt>The directory at <i>'%1'</i> will be <b>recursively</b> and <b>permanently</b> deleted." )
                        : i18n( "<qt><i>'%1'</i> will be <b>permanently</b> deleted." );
                const int userIntention = KMessageBox::warningContinueCancel(
                        this, message.arg( url.prettyURL() ),
                        QString::null, KGuiItem( i18n("&Delete"), "editdelete" ) );

                if (userIntention == KMessageBox::Continue) {
                    KIO::Job *job = KIO::del( url );
                    job->setWindow( this );
                    connect( job, SIGNAL(result( KIO::Job* )), SLOT(deleteJobFinished( KIO::Job* )) );
                    QApplication::setOverrideCursor( KCursor::workingCursor() );
                }
            }

            default:
                //ensure m_focus is set for new mouse position
                sendFakeMouseEvent();
         }
      }
      else { // not right mouse button

      section_two:
         const QRect rect( e->x() - 20, e->y() - 20, 40, 40 );

         m_tip->hide(); // user expects this

         if (!isDir || e->button() == Qt::MidButton) {
            KIconEffect::visualActivate( this, rect );
            new KRun( url, this, true ); //FIXME see above
         }
         else if (m_focus->file() != m_tree) { // is left click
            KIconEffect::visualActivate( this, rect );
            emit activated( url ); //activate first, this will cause UI to prepare itself
            createFromCache( (Directory *)m_focus->file() );
         }
         else
            emit giveMeTreeFor( url.upURL() );
      }
   }
}
示例#30
0
/**
 * @short Initialize
 * @author Rene Schmidt <*****@*****.**>
 * @version 0.1
 */
KLAidWidget::KLAidWidget(QWidget* parent, const char* name, WFlags fl)
        : KLAidWidgetBase(parent,name,fl)
{
  this->setCaption(i18n("K Learning Aid %1").arg(VER));

  cfgOkay = FALSE;
  
  oldRepVal = 1;
  
  // Center window
  QDesktopWidget *d = QApplication::desktop();
  int dW = d->width();      int dH = d->height();
  int wW = this->width();   int wH = this->height();
  this->setGeometry((dW-wW)/2, (dH-wH)/2, wW, wH);
  
  // Create tray icon
  tray = new KSystemTray(this, "TimerTray");
  tray->setPixmap(SmallIcon("ktimer"));
  tray->show();

  QToolTip::add(tray, i18n("K Learning Aid %1").arg(VER));
  
  // Create logic backend
  aut = new KLAid(this);
  aut->desktopWidth = d->width();
  aut->setCentralWidget(tray);
  
  QObject::connect(aut, SIGNAL(loopExpired()), this, SLOT(reportExpired()));
  QObject::connect(aut, SIGNAL(popNow( QString&, QString&, uint&)),
                    this, SLOT(showPopUp(QString&, QString&, uint&)));

  // Add some tray menu items
  KPopupMenu * TrayMenu = tray->contextMenu(); 

  enPopAction = new KToggleAction(  i18n("&Enable PopUps"),
                                    0, 
                                    this, 
                                    SLOT(toggleTimer()), 
                                    parentWidget(), 
                                    TOGGLE_ITEM);

  KAction * AboutAction = new KAction(  i18n("&About"), 
                                        0, 
                                        this, 
                                        SLOT(about()), 
                                        parentWidget(), 
                                        ABOUT_ITEM);
      
  TrayMenu->removeItemAt(0);
  TrayMenu->insertTitle(SmallIcon("ktimer"), QString("KLAid"), 0, 0);
  
  enPopAction->plug(TrayMenu, 1);
  enPopAction->setEnabled(FALSE);
  
  AboutAction->plug(TrayMenu, 2);

  connect(popUpInterval, SIGNAL(valueChanged(const QString&)), this, SLOT(sanitizeMinStay()));
  connect(urlLine, SIGNAL(urlSelected(const QString&)), this, SLOT(enableOKButton()));
  connect(minStay, SIGNAL(valueChanged(const QString&)), this, SLOT(sanitizeMinStay()));
  connect(pIntvalUnit, SIGNAL(activated(const QString&)), this, SLOT(sanitizeMinStay()));
  connect(overlapPops, SIGNAL(stateChanged(int)), this, SLOT(sanitizeMinStay()));
  connect(rndSeqBox, SIGNAL(stateChanged(int)), this, SLOT(turnOffUniq()));
  connect(repModeBox, SIGNAL(activated(const QString&)), this, SLOT(changeRepMode()));
  connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));
  connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked()));
//  connect(defaultsButton, SIGNAL(clicked()), this, SLOT(resetConfig()));

  // Set default fonts for popups
  fntCaption = new QFont();
  fntCaption->setBold(TRUE);
  kFontRequester1->setFont(*fntCaption);
  fntBody = new QFont();
  kFontRequester2->setFont(*fntBody);

  // Set default fonts for popups
  tmpFgColor = new QColor(this->foregroundColor());
  tmpBgColor = new QColor(this->backgroundColor());

  fgCol->setColor(this->foregroundColor());
  bgCol->setColor(this->backgroundColor());

  this->_readConfig();
  this->show();
}