FileBrowser::FileBrowser( const char * name, Medium * medium ) : QVBox( 0, name ) { KActionCollection *actionCollection; SearchPane *searchPane; KURL *location; // Try to keep filebrowser working even if not in a medium context // so if a medium object not passed in, keep earlier behavior if (!medium) { m_medium = 0; location = new KURL( Pana::config( "Filebrowser" )->readPathEntry( "Location", QDir::homeDirPath() ) ); KFileItem *currentFolder = new KFileItem( KFileItem::Unknown, KFileItem::Unknown, *location ); //KIO sucks, NetAccess::exists puts up a dialog and has annoying error message boxes //if there is a problem so there is no point in using it anyways. //so... setting the diroperator to ~ is the least sucky option if ( !location->isLocalFile() || !currentFolder->isReadable() ) { delete location; location = new KURL( QDir::homeDirPath() ) ; } } else{ m_medium = medium; location = new KURL( m_medium->mountPoint() ); } KActionCollection* ac = new KActionCollection( this ); KStdAction::selectAll( this, SLOT( selectAll() ), ac, "filebrowser_select_all" ); KToolBar *toolbar = new Browser::ToolBar( this ); { //Filter LineEdit KToolBar* searchToolBar = new Browser::ToolBar( this ); KToolBarButton *button = new KToolBarButton( "locationbar_erase", 0, searchToolBar ); m_filter = new ClickLineEdit( i18n( "Enter search terms here" ), searchToolBar ); searchToolBar->setStretchableWidget( m_filter ); connect( button, SIGNAL(clicked()), m_filter, SLOT(clear()) ); QToolTip::add( button, i18n( "Clear search field" ) ); QToolTip::add( m_filter, i18n( "Enter space-separated terms to search in the directory-listing" ) ); } { //Directory Listing QVBox *container; QHBox *box; container = new QVBox( this ); container->setFrameStyle( m_filter->frameStyle() ); container->setMargin( 3 ); container->setSpacing( 2 ); container->setBackgroundMode( Qt::PaletteBase ); box = new QHBox( container ); box->setMargin( 3 ); box->setBackgroundMode( Qt::PaletteBase ); //folder selection combo box m_combo = new KURLComboBox( KURLComboBox::Directories, true, box, "path combo" ); if (!m_medium){ m_combo->setCompletionObject( new KURLCompletion( KURLCompletion::DirCompletion ) ); m_combo->setAutoDeleteCompletionObject( true ); } m_combo->setMaxItems( 9 ); m_combo->setURLs( Pana::config( "Filebrowser" )->readPathListEntry( "Dir History" ) ); if (!m_medium) m_combo->lineEdit()->setText( location->path() ); else m_combo->lineEdit()->setText( "/" ); //The main widget with file listings and that m_dir = new MyDirOperator( *location, container, m_medium ); m_dir->setEnableDirHighlighting( true ); m_dir->setMode( KFile::Mode((int)KFile::Files | (int)KFile::Directory) ); //allow selection of multiple files + dirs m_dir->setOnlyDoubleClickSelectsFiles( true ); //Pana type settings m_dir->readConfig( Pana::config( "Filebrowser" ) ); m_dir->setView( KFile::Default ); //will set userconfigured view, will load URL m_dir->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); m_dir->setAcceptDrops( true ); //Automatically open folder after hovering above it...probably a good thing //but easily disabled by commenting this line out //Disabled for now because can't show . and .. folders. //TODO: Find out a way to fix this? //m_dir->setDropOptions( KFileView::AutoOpenDirs ); static_cast<QFrame*>(m_dir->viewWidget())->setFrameStyle( QFrame::NoFrame ); static_cast<QIconView*>(m_dir->viewWidget())->setSpacing( 1 ); actionCollection = m_dir->actionCollection(); searchPane = new SearchPane( this ); setStretchFactor( container, 2 ); } { QPopupMenu* const menu = static_cast<KActionMenu*>(actionCollection->action("popupMenu"))->popupMenu(); menu->clear(); menu->insertItem( SmallIconSet( Pana::icon( "files" ) ), i18n( "&Load" ), MakePlaylist ); menu->insertItem( SmallIconSet( Pana::icon( "add_playlist" ) ), i18n( "&Append to Playlist" ), AppendToPlaylist ); menu->insertItem( SmallIconSet( Pana::icon( "queue_track" ) ), i18n( "&Queue Track" ), QueueTrack ); menu->insertItem( SmallIconSet( Pana::icon( "queue_track" ) ), i18n( "&Queue Tracks" ), QueueTracks ); menu->insertItem( SmallIconSet( Pana::icon( "save" ) ), i18n( "&Save as Playlist..." ), SavePlaylist ); menu->insertSeparator(); if (!m_medium) menu->insertItem( SmallIconSet( Pana::icon( "device" ) ), i18n( "&Transfer to Media Device" ), MediaDevice ); menu->insertItem( SmallIconSet( Pana::icon( "collection" ) ), i18n( "&Organize Files..." ), OrganizeFiles ); menu->insertItem( SmallIconSet( Pana::icon( "collection" ) ), i18n( "&Copy Files to Collection..." ), CopyToCollection ); menu->insertItem( SmallIconSet( Pana::icon( "collection" ) ), i18n( "&Move Files to Collection..." ), MoveToCollection ); menu->insertItem( SmallIconSet( Pana::icon( "burn" ) ), i18n("Burn to CD..."), BurnCd ); menu->insertSeparator(); menu->insertItem( i18n( "&Select All Files" ), SelectAllFiles ); menu->insertSeparator(); actionCollection->action( "delete" )->setIcon( Pana::icon( "remove" ) ); actionCollection->action( "delete" )->plug( menu ); menu->insertSeparator(); menu->insertItem( SmallIconSet( Pana::icon( "info" ) ), i18n( "Edit Track &Information..." ), EditTags ); actionCollection->action( "properties" )->plug( menu ); menu->setItemEnabled( BurnCd, K3bExporter::isAvailable() ); connect( menu, SIGNAL(aboutToShow()), SLOT(prepareContextMenu()) ); connect( menu, SIGNAL(activated( int )), SLOT(contextMenuActivated( int )) ); } { KActionMenu *a; a = static_cast<KActionMenu*>( actionCollection->action( "sorting menu" ) ); a->setIcon( Pana::icon( "configure" ) ); a->setDelayed( false ); //TODO should be done by KDirOperator actionCollection->action( "delete" )->setShortcut( KShortcut( SHIFT + Key_Delete ) ); a = new KActionMenu( i18n("Bookmarks"), "bookmark", actionCollection, "bookmarks" ); a->setDelayed( false ); new KBookmarkHandler( m_dir, a->popupMenu() ); } { if ( KAction *a = actionCollection->action( "up" ) ) a->plug( toolbar ); if ( KAction *a = actionCollection->action( "back" ) ) a->plug( toolbar ); if ( KAction *a = actionCollection->action( "forward" ) ) a->plug( toolbar ); if ( KAction *a = actionCollection->action( "home" ) ) a->plug( toolbar ); if ( KAction *a = actionCollection->action( "reload" ) ) { a->setIcon( Pana::icon( "refresh" ) ); a->plug( toolbar ); } toolbar->insertLineSeparator(); if ( KAction *a = actionCollection->action( "short view" ) ) a->plug( toolbar ); if ( KAction *a = actionCollection->action( "detailed view" ) ) a->plug( toolbar ); toolbar->insertLineSeparator(); if ( KAction *a = actionCollection->action( "sorting menu" ) ) a->plug( toolbar ); if ( KAction *a = actionCollection->action( "bookmarks" ) ) a->plug( toolbar ); KAction *gotoCurrent = new KAction( i18n("Go To Current Track Folder"), Pana::icon( "music" ), 0, this, SLOT( gotoCurrentFolder() ), actionCollection ); gotoCurrent->plug( toolbar ); disconnect( actionCollection->action( "up" ), SIGNAL( activated() ), m_dir, SLOT( cdUp() ) ); connect( actionCollection->action( "up" ), SIGNAL( activated() ), m_dir, SLOT( myCdUp() ) ); disconnect( actionCollection->action( "home" ), SIGNAL( activated() ), m_dir, SLOT( home() ) ); connect( actionCollection->action( "home" ), SIGNAL( activated() ), m_dir, SLOT( myHome() ) ); } connect( m_filter, SIGNAL(textChanged( const QString& )), SLOT(setFilter( const QString& )) ); connect( m_combo, SIGNAL(urlActivated( const KURL& )), SLOT(setUrl( const KURL& )) ); connect( m_combo, SIGNAL(returnPressed( const QString& )), SLOT(setUrl( const QString& )) ); connect( m_dir, SIGNAL(viewChanged( KFileView* )), SLOT(slotViewChanged( KFileView* )) ); connect( m_dir, SIGNAL(fileSelected( const KFileItem* )), SLOT(activate( const KFileItem* )) ); connect( m_dir, SIGNAL(urlEntered( const KURL& )), SLOT(urlChanged( const KURL& )) ); connect( m_dir, SIGNAL(urlEntered( const KURL& )), searchPane, SLOT(urlChanged( const KURL& )) ); connect( m_dir, SIGNAL(dropped( const KFileItem*, QDropEvent*, const KURL::List& )), SLOT(dropped( const KFileItem*, QDropEvent*, const KURL::List& )) ); setSpacing( 4 ); setFocusProxy( m_dir ); //so the dirOperator is focused when we get focus events // Toolbar is more than 250px wide, BrowserBar doesn't allow that. -> Resizing issues. setMinimumWidth( 250 /* toolbar->sizeHint().width() */ ); }
void ServiceLoader::loadServices(const KFileItem item, DOM::DOMString &html, int &count) { popups.clear(); KURL url = item.url(); QString mimeType = item.mimetype(); QString mimeGroup = mimeType.left(mimeType.find('/')); urlList.clear(); urlList.append(url); QStringList dirs = KGlobal::dirs()->findDirs( "data", "konqueror/servicemenus/" ); KConfig config("metabarrc", true, false); config.setGroup("General"); int maxActions = config.readNumEntry("MaxActions"); bool matchAll = false; // config.readBoolEntry("MatchAll"); int id = 0; QString idString; for(QStringList::Iterator dit = dirs.begin(); dit != dirs.end(); ++dit){ idString.setNum(id); QDir dir(*dit); QStringList entries = dir.entryList("*.desktop", QDir::Files); for(QStringList::Iterator eit = entries.begin(); eit != entries.end(); ++eit){ KSimpleConfig cfg( *dit + *eit, true ); cfg.setDesktopGroup(); if(cfg.hasKey("X-KDE-ShowIfRunning" )){ const QString app = cfg.readEntry( "X-KDE-ShowIfRunning" ); if(!kapp->dcopClient()->isApplicationRegistered(app.utf8())){ continue; } } if(cfg.hasKey("X-KDE-Protocol")){ const QString protocol = cfg.readEntry( "X-KDE-Protocol" ); if(protocol != url.protocol()){ continue; } } else if(url.protocol() == "trash"){ continue; } if(cfg.hasKey("X-KDE-Require")){ const QStringList capabilities = cfg.readListEntry( "X-KDE-Require" ); if (capabilities.contains( "Write" )){ continue; } } if ( cfg.hasKey( "Actions" ) && cfg.hasKey( "ServiceTypes" ) ){ const QStringList types = cfg.readListEntry( "ServiceTypes" ); const QStringList excludeTypes = cfg.readListEntry( "ExcludeServiceTypes" ); bool ok = false; for (QStringList::ConstIterator it = types.begin(); it != types.end() && !ok; ++it){ bool checkTheMimetypes = false; if(matchAll){ // first check if we have an all mimetype if (*it == "all/all" || *it == "allfiles"){ checkTheMimetypes = true; } // next, do we match all files? if (!ok && !item.isDir() && *it == "all/allfiles"){ checkTheMimetypes = true; } } // if we have a mimetype, see if we have an exact or a type globbed match if(!ok && (!mimeType.isEmpty() && *it == mimeType) || (!mimeGroup.isEmpty() && ((*it).right(1) == "*" && (*it).left((*it).find('/')) == mimeGroup))) { checkTheMimetypes = true; } if(checkTheMimetypes){ ok = true; for(QStringList::ConstIterator itex = excludeTypes.begin(); itex != excludeTypes.end(); ++itex){ if( ((*itex).right(1) == "*" && (*itex).left((*itex).find('/')) == mimeGroup) || ((*itex) == mimeType)) { ok = false; break; } } } } if (ok){ const QString priority = cfg.readEntry("X-KDE-Priority"); const QString submenuName = cfg.readEntry( "X-KDE-Submenu" ); bool usePopup = false; KPopupMenu *popup; if(!submenuName.isEmpty()){ usePopup = true; if(popups[submenuName]){ popup = popups[submenuName]; } else{ MetabarWidget::addEntry(html, submenuName, "servicepopup://" + idString, "1rightarrow", "popup" + idString, count < maxActions ? QString::null : QString("hiddenaction"), count >= maxActions); popup = new KPopupMenu(); popups.insert(idString, popup); count++; } } QValueList<KDEDesktopMimeType::Service> list = KDEDesktopMimeType::userDefinedServices( *dit + *eit, url.isLocalFile()); for (QValueList<KDEDesktopMimeType::Service>::iterator it = list.begin(); it != list.end(); ++it){ if(usePopup){ KAction *action = new KAction((*it).m_strName, (*it).m_strIcon, KShortcut(), this, SLOT(runAction()), popup, idString.utf8()); action->plug(popup); } else{ MetabarWidget::addEntry(html, (*it).m_strName, "service://" + idString, (*it).m_strIcon, QString::null, count < maxActions ? QString::null : QString("hiddenaction"), count >= maxActions); count++; } services.insert(idString, *it); id++; idString.setNum(id); } } } } } }
void SystemTray::mousePressEvent(QMouseEvent *event) { if (event->button() & Qt::LeftButton) { // Prepare drag m_pressPos = event->globalPos(); m_canDrag = true; event->accept(); } else if (event->button() & Qt::MidButton) { // Paste Global::bnpView->currentBasket()->setInsertPopupMenu(); Global::bnpView->currentBasket()->pasteNote(QClipboard::Selection); Global::bnpView->currentBasket()->cancelInsertPopupMenu(); if (Settings::usePassivePopup()) Global::bnpView->showPassiveDropped(i18n("Pasted selection to basket <i>%1</i>")); event->accept(); } else if (event->button() & Qt::RightButton) { // Popup menu KMenu menu(this); menu.addTitle( SmallIcon("basket"), KGlobal::mainComponent().aboutData()->programName() ); Global::bnpView->actNewBasket->plug(&menu); Global::bnpView->actNewSubBasket->plug(&menu); Global::bnpView->actNewSiblingBasket->plug(&menu); menu.insertSeparator(); Global::bnpView->m_actPaste->plug(&menu); Global::bnpView->m_actGrabScreenshot->plug(&menu); Global::bnpView->m_actColorPicker->plug(&menu); if(!Global::bnpView->isPart()) { KAction* action; menu.insertSeparator(); action = Global::bnpView->actionCollection()->action("options_configure_global_keybinding"); if(action) action->plug(&menu); action = Global::bnpView->actionCollection()->action("options_configure"); if(action) action->plug(&menu); menu.insertSeparator(); // Minimize / restore : since we manage the popup menu by ourself, we should do that work : action = Global::bnpView->actionCollection()->action("minimizeRestore"); if(action) { if (Global::mainWindow()->isVisible()) action->setText(i18n("&Minimize")); else action->setText(i18n("&Restore")); action->plug(&menu); } action = Global::bnpView->actionCollection()->action("file_quit"); if(action) action->plug(&menu); } Global::bnpView->currentBasket()->setInsertPopupMenu(); connect( &menu, SIGNAL(aboutToHide()), Global::bnpView->currentBasket(), SLOT(delayedCancelInsertPopupMenu()) ); menu.exec(event->globalPos()); event->accept(); } else event->ignore(); }
// Initialise Toolbar, Menus ScrollBar and other void ktvschedule::init() { // Creates central widgets tvgridbox = new QGroupBox ( this ); // Group box tvgridbox->setInsideMargin ( 15 ); t_TVGrid=new TvGuideTable(this->tvgridbox, "t_TVGrid"); // Add TvGuideTable custom QTable QGridLayout *tvgridboxLayout = new QGridLayout( tvgridbox->layout() ); //Layout tvgridboxLayout->setAlignment ( Qt::AlignTop ); tvgridboxLayout->addWidget ( t_TVGrid , 0 , 0 ); setCentralWidget( tvgridbox ); tvgridbox->show(); //////////////////////////////// //Check for home directory, if it does not exist, create it QString qstr(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule"); //for some reason this only works with gcc 3.3 and not the previous version QDir d(qstr); if ( !d.exists() ) { d.mkdir(qstr); } /*QDir d( QString(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule") ); if ( !d.exists() ) { d.mkdir(QString(QDir::homeDirPath()+"/.kde/share/apps/ktvschedule")); }*/ // This worked for gcc 3.4 but not for 3.3 //setRightJustification( TRUE ); //////////////////////////////// this->setIcon( KGlobal::iconLoader()->loadIcon("ktvschedule", KIcon::Desktop) ); // Creates the ToolBar KToolBar * TvToolBar = new KToolBar( this, KMainWindow::Top ); ////////////////////////////// // Creates a QDateEdit Widget for future use date_show = new QDateEdit( QDate::currentDate() , TvToolBar ); date_show->setOrder(QDateEdit::DMY); //////////////////////////////// // Define KActions //KAction *actionGoHome = new KAction ( "Now Playing", KGlobal::iconLoader()->loadIcon("gohome", KIcon::NoGroup), CTRL+Key_P , t_TVGrid, SLOT (SetToCurrentTime() ), collector, "Now Playing"); KAction *actionGoHome = new KAction ( i18n("Now &Playing"), "gohome", CTRL+Key_P , this, SLOT (SetToCurrentTime() ), actionCollection(), "Now Playing"); KAction *actionRefreshGuide = new KAction ( i18n("&Refresh Guide"), "reload", CTRL+Key_R , this, SLOT (RefreshXMLGuide() ), actionCollection(), "Refresh Guide"); KAction *actionManageChannels = new KAction ( i18n("&Manage Channels"), "toggle_log", CTRL+Key_M , this, SLOT (channelList() ), actionCollection(), "Manage Channels"); KAction *actionConfigure = new KAction ( i18n("&Configure"), "configure", CTRL+Key_C , this, SLOT (runConfig() ), actionCollection(), "Configure"); KAction *actionExit = KStdAction::quit(this, SLOT(close()), 0); KAction *actionPrevious = new KAction ( i18n("Pre&vious Day"), "previous", CTRL+Key_V , date_show, SLOT ( stepDown() ), actionCollection(), "PreviousDay"); KAction *actionNext = new KAction ( i18n("&Next Day"), "forward", CTRL+Key_N , date_show, SLOT ( stepUp() ), actionCollection(), "NextDay"); KAction *actionEvent = KStdAction::configureNotifications(this, SLOT( notificationsEvent() ), actionCollection(), "settings_notifications" ); KAction *actionFindCategory = new KAction (i18n("&Find Next Show"), "find", CTRL+Key_F , this, SLOT( findNextCategory() ), actionCollection(), "findnextshow"); ////////////////////////////////// // Plug actions to ToolBar actionGoHome->plug ( TvToolBar); actionRefreshGuide->plug (TvToolBar); actionExit->plug (TvToolBar); TvToolBar->insertLineSeparator(); actionManageChannels->plug (TvToolBar); actionConfigure->plug (TvToolBar); TvToolBar->insertLineSeparator(); actionPrevious->plug (TvToolBar); // Add a QDateEdit widget for the ToolBar TvToolBar->insertWidget (actionCollection()->count()+1,13, date_show ); actionNext->plug (TvToolBar); // Creates the KComboBox and adds it to the Toolbar combo_Categories = new KComboBox(TvToolBar); combo_Categories->setMinimumWidth( combo_Categories->width ()+60); combo_Categories->insertStringList(Categories); TvToolBar->insertWidget (actionCollection()->count()+1,15, combo_Categories); actionFindCategory->plug (TvToolBar); ////////////////////////////////// // Create menus KPopupMenu *menuGrid = new KPopupMenu( this ); KPopupMenu *menuConf = new KPopupMenu( this ); menuBar()->insertItem( i18n("&Grid"), menuGrid ); menuBar()->insertItem( i18n("&Configure"), menuConf ); // Plug KActions to menus actionGoHome->plug(menuGrid); actionRefreshGuide->plug(menuGrid); actionExit->plug(menuGrid); actionManageChannels->plug(menuConf); actionConfigure->plug(menuConf); actionEvent->plug(menuConf); KAboutData *_aboutData = new KAboutData("kTvSchedule", I18N_NOOP("KTvSchedule"), "0.1.8", I18N_NOOP("TV Schedule.\n\n" "KDE Front end for TV Schedule programs.\n" "created by xmltv (tv_grab_xx)"), KAboutData::License_GPL, "(c) 2005, Alexios Beveratos",0,"http://www.kde-apps.org/content/show.php?content=22747","*****@*****.**"); _aboutData->addAuthor("Alexios Beveratos", I18N_NOOP("Main Developper"), "*****@*****.**"); _aboutData->addAuthor("Benoit Philipps",0,"*****@*****.**"); //_aboutData->setHomepage("http://www.kde-apps.org/content/show.php?content=22747"); //_aboutData->setBugAddress("http://developer.berlios.de/projects/ktvschedule/"); KHelpMenu *HelpMenu = new KHelpMenu( this, _aboutData ); menuBar()->insertItem(i18n("&Help"), HelpMenu->menu() ); ////////////////////////////////// // Creates StatusBar StatusBar = this->statusBar(); led = new KLed(QColor ("#2EBB16"), KLed::On, KLed::Raised, KLed::Circular); StatusBar->addWidget ( led, 0, TRUE ); ////////////////////////////////// // Other Initialisations date_show->setDate(QDate::currentDate ()); date_show->setOrder(QDateEdit::DMY); FirstInput=QDate::currentDate(); LastInput=QDate::currentDate(); ////////////////////////////////// //Add connections connect( date_show, SIGNAL( valueChanged(const QDate&) ), this, SLOT( PopulateTvGrid() ) ); //connect( combo_Categories, SIGNAL( activated(const QString &)),t_TVGrid,SLOT( highlightCategory(const QString& ))); connect( combo_Categories, SIGNAL( activated(const QString &)),this,SLOT( highlightCategory(const QString& ))); // Creates the scheduler class, and connects it. can be made better tvShowScheduler= new tvscheduler(); connect( t_TVGrid, SIGNAL (infoContext(TvItem*) ), tvShowScheduler, SLOT (doNotMiss(TvItem*) ) ); connect( t_TVGrid, SIGNAL (recordProgramSignal(TvItem* ) ), tvShowScheduler, SLOT (recordProgram(TvItem* ) ) ); ///////////////////////////////// //If we use nxtvepg then disable some buttons if (Config().m_GrabberToUse == "nxtvepg") { actionRefreshGuide->setEnabled(FALSE); actionManageChannels->setEnabled(FALSE); } }