int TKAction::plug(QWidget* widget, int index) { if ( widget->inherits("KToolBar") ) { KToolBar* bar = static_cast<KToolBar*>(widget); int id_ = KAction::getToolButtonID(); KInstance *instance; if ( parentCollection() ) instance = parentCollection()->instance(); else instance = KGlobal::instance(); TKToolBarButton* b = new TKToolBarButton(icon(),plainText(),bar,name(),instance); // we don't need clicked() and buttonClicked(), do we? // connect(b,SIGNAL(clicked()),SLOT(slotActivated())); b->setIconMode(m_imode); initToolBarButton(b); bar->insertWidget( id_, 100, b, index ); addContainer(bar,id_); connect( bar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); return containerCount() - 1; } return KAction::plug(widget,index); }
int PMComboAction::plug( QWidget* w, int index ) { if( !w->inherits( "KToolBar" ) ) return -1; KToolBar* toolBar = ( KToolBar* ) w; int id = KAction::getToolButtonID( ); QComboBox* comboBox = new PMComboBox( toolBar ); if( m_minWidth > 0 ) comboBox->setMinimumWidth( m_minWidth ); if( m_maxWidth > 0 ) comboBox->setMaximumWidth( m_maxWidth ); toolBar->insertWidget( id, m_minWidth > 0 ? m_minWidth : 300, comboBox, index ); connect( comboBox, SIGNAL( activated( int ) ), m_receiver, m_member ); addContainer( toolBar, id ); connect( toolBar, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) ); //toolBar->setItemAutoSized( id, true ); m_combo = comboBox; emit plugged( ); QWhatsThis::add( comboBox, whatsThis( ) ); return containerCount( ) - 1; }
int PMSpinBoxAction::plug( QWidget* w, int index ) { if( !w->inherits( "KToolBar" ) ) return -1; KToolBar* toolBar = ( KToolBar* ) w; int id = KAction::getToolButtonID( ); QSpinBox* spinBox = new QSpinBox( -1000, 1000, 1, w ); toolBar->insertWidget( id, 70, spinBox, index ); connect( spinBox, SIGNAL( valueChanged( int ) ), m_receiver, m_member ); addContainer( toolBar, id ); connect( toolBar, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) ); //toolBar->setItemAutoSized( id, false ); m_spinBox = spinBox; emit plugged( ); QWhatsThis::add( spinBox, whatsThis( ) ); return containerCount( ) - 1; }
int PMLabelAction::plug( QWidget *widget, int index ) { //do not call the previous implementation here if( widget->inherits( "KToolBar" ) ) { KToolBar* tb = ( KToolBar* ) widget; int id = KAction::getToolButtonID( ); m_button = new PMToolBarLabel( text( ), widget ); tb->insertWidget( id, m_button->width( ), m_button, index ); addContainer( tb, id ); connect( tb, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) ); return containerCount( ) - 1; } return -1; }
int TKBaseSelectAction::plug(QWidget* widget, int index) { if ( widget->inherits("KToolBar") ) { KToolBar* bar = static_cast<KToolBar*>( widget ); int id_ = KAction::getToolButtonID(); TKComboBox* cb = new TKComboBox(m_editable,bar); initComboBox(cb); cb->setMinimumWidth( cb->sizeHint().width() ); QWidget* base = createLayout(bar,cb); bar->insertWidget( id_, 100, base, index ); addContainer( bar, id_ ); connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); setCurrentItem(currentItem()); return containerCount() - 1; } return -1; }
int AnalyzerAction::plug( QWidget *w, int index ) { //NOTE the analyzer will be deleted when the toolbar is deleted or cleared() //we are not designed for unplugging() yet so there would be a leak if that happens //but it's a rare event and unplugging is complicated. KToolBar *bar = dynamic_cast<KToolBar*>(w); if( bar && kapp->authorizeKAction( name() ) ) { const int id = KAction::getToolButtonID(); addContainer( w, id ); connect( w, SIGNAL( destroyed() ), SLOT( slotDestroyed() ) ); QWidget *container = new AnalyzerContainer( w ); bar->insertWidget( id, 0, container, index ); bar->setItemAutoSized( id, true ); return containerCount() - 1; } else return -1; }
// TODO convert to use xmlui file void KuickShow::initGUI( const KURL& startDir ) { KURL startURL( startDir ); if ( !KProtocolInfo::supportsListing( startURL ) ) startURL = KURL(); fileWidget = new FileWidget( startURL, this, "MainWidget" ); setFocusProxy( fileWidget ); KActionCollection *coll = fileWidget->actionCollection(); redirectDeleteAndTrashActions(coll); connect( fileWidget, SIGNAL( fileSelected( const KFileItem * ) ), this, SLOT( slotSelected( const KFileItem * ) )); connect( fileWidget, SIGNAL( fileHighlighted( const KFileItem * )), this, SLOT( slotHighlighted( const KFileItem * ) )); connect( fileWidget, SIGNAL( urlEntered( const KURL& )), this, SLOT( dirSelected( const KURL& )) ); fileWidget->setAcceptDrops(true); connect( fileWidget, SIGNAL( dropped( const KFileItem *, QDropEvent *, const KURL::List & )), this, SLOT( slotDropped( const KFileItem *, QDropEvent *, const KURL::List &)) ); // setup actions KAction *open = KStdAction::open( this, SLOT( slotOpenURL() ), coll, "openURL" ); KAction *print = KStdAction::print( this, SLOT( slotPrint() ), coll, "kuick_print" ); print->setText( i18n("Print Image...") ); KAction *configure = new KAction( i18n("Configure %1...").arg( KGlobal::instance()->aboutData()->programName() ), "configure", KShortcut(), this, SLOT( configuration() ), coll, "kuick_configure" ); KAction *slide = new KAction( i18n("Start Slideshow" ), "ksslide", KShortcut( Key_F2 ), this, SLOT( startSlideShow() ), coll, "kuick_slideshow" ); KAction *about = new KAction( i18n( "About KuickShow" ), "about", KShortcut(), this, SLOT( about() ), coll, "about" ); oneWindowAction = new KToggleAction( i18n("Open Only One Image Window"), "window_new", KShortcut( CTRL+Key_N ), coll, "kuick_one window" ); m_toggleBrowserAction = new KToggleAction( i18n("Show File Browser"), KShortcut( Key_Space ), coll, "toggleBrowser" ); m_toggleBrowserAction->setCheckedState(i18n("Hide File Browser")); connect( m_toggleBrowserAction, SIGNAL( toggled( bool ) ), SLOT( toggleBrowser() )); KAction *showInOther = new KAction( i18n("Show Image"), KShortcut(), this, SLOT( slotShowInOtherWindow() ), coll, "kuick_showInOtherWindow" ); KAction *showInSame = new KAction( i18n("Show Image in Active Window"), KShortcut(), this, SLOT( slotShowInSameWindow() ), coll, "kuick_showInSameWindow" ); KAction *showFullscreen = new KAction( i18n("Show Image in Fullscreen Mode"), KShortcut(), this, SLOT( slotShowFullscreen() ), coll, "kuick_showFullscreen" ); KAction *quit = KStdAction::quit( this, SLOT(slotQuit()), coll, "quit"); // remove QString::null parameter -- ellis coll->readShortcutSettings( QString::null ); m_accel = coll->accel(); // menubar KMenuBar *mBar = menuBar(); QPopupMenu *fileMenu = new QPopupMenu( mBar, "file" ); open->plug( fileMenu ); showInOther->plug( fileMenu ); showInSame->plug( fileMenu ); showFullscreen->plug( fileMenu ); fileMenu->insertSeparator(); slide->plug( fileMenu ); print->plug( fileMenu ); fileMenu->insertSeparator(); quit->plug( fileMenu ); QPopupMenu *editMenu = new QPopupMenu( mBar, "edit" ); coll->action("mkdir")->plug( editMenu ); coll->action("delete")->plug( editMenu ); editMenu->insertSeparator(); coll->action("properties")->plug( editMenu ); // remove the Sorting submenu (and the separator below) // from the main contextmenu KActionMenu *sortingMenu = static_cast<KActionMenu*>( coll->action("sorting menu")); KActionMenu *mainActionMenu = static_cast<KActionMenu*>( coll->action("popupMenu")); QPopupMenu *mainPopup = mainActionMenu->popupMenu(); int sortingIndex = mainPopup->indexOf( sortingMenu->itemId( 0 ) ); int separatorId = mainPopup->idAt( sortingIndex + 1 ); QMenuItem *separatorItem = mainPopup->findItem( separatorId ); if ( separatorItem && separatorItem->isSeparator() ) mainPopup->removeItem( separatorId ); mainActionMenu->remove( sortingMenu ); // add the sorting menu and a separator into the View menu KActionMenu *viewActionMenu = static_cast<KActionMenu*>( coll->action("view menu")); viewActionMenu->popupMenu()->insertSeparator( 0 ); sortingMenu->plug( viewActionMenu->popupMenu(), 0 ); // on top of the menu QPopupMenu *settingsMenu = new QPopupMenu( mBar, "settings" ); configure->plug( settingsMenu ); mBar->insertItem( i18n("&File"), fileMenu ); mBar->insertItem( i18n("&Edit"), editMenu ); viewActionMenu->plug( mBar ); mBar->insertItem( i18n("&Settings"), settingsMenu ); // toolbar KToolBar *tBar = toolBar(); tBar->setText( i18n( "Main Toolbar" ) ); coll->action("up")->plug( tBar ); coll->action("back")->plug( tBar ); coll->action("forward")->plug( tBar ); coll->action("home")->plug( tBar ); coll->action("reload")->plug( tBar ); tBar->insertSeparator(); coll->action( "short view" )->plug( tBar ); coll->action( "detailed view" )->plug( tBar ); coll->action( "preview")->plug( tBar ); tBar->insertSeparator(); configure->plug( tBar ); slide->plug( tBar ); tBar->insertSeparator(); oneWindowAction->plug( tBar ); print->plug( tBar ); tBar->insertSeparator(); about->plug( tBar ); QPopupMenu *help = helpMenu( QString::null, false ); mBar->insertItem( KStdGuiItem::help().text() , help ); KStatusBar* sBar = statusBar(); sBar->insertItem( " ", URL_ITEM, 10 ); sBar->insertItem( " ", META_ITEM, 2 ); sBar->setItemAlignment(URL_ITEM, QLabel::AlignVCenter | QLabel::AlignLeft); fileWidget->setFocus(); KConfig *kc = KGlobal::config(); kc->setGroup("SessionSettings"); bool oneWindow = kc->readBoolEntry("OpenImagesInActiveWindow", true ); oneWindowAction->setChecked( oneWindow ); tBar->show(); // Address box in address tool bar KToolBar *addressToolBar = toolBar( "address_bar" ); const int ID_ADDRESSBAR = 1; cmbPath = new KURLComboBox( KURLComboBox::Directories, true, addressToolBar, "address_combo_box" ); KURLCompletion *cmpl = new KURLCompletion( KURLCompletion::DirCompletion ); cmbPath->setCompletionObject( cmpl ); cmbPath->setAutoDeleteCompletionObject( true ); addressToolBar->insertWidget( ID_ADDRESSBAR, 1, cmbPath); addressToolBar->setItemAutoSized( ID_ADDRESSBAR ); connect( cmbPath, SIGNAL( urlActivated( const KURL& )), this, SLOT( slotSetURL( const KURL& ))); connect( cmbPath, SIGNAL( returnPressed()), this, SLOT( slotURLComboReturnPressed())); fileWidget->initActions(); fileWidget->clearHistory(); dirSelected( fileWidget->url() ); setCentralWidget( fileWidget ); setupGUI( KMainWindow::Save ); coll->action( "reload" )->setShortcut( KStdAccel::reload() ); coll->action( "short view" )->setShortcut(Key_F6); coll->action( "detailed view" )->setShortcut(Key_F7); coll->action( "show hidden" )->setShortcut(Key_F8); coll->action( "mkdir" )->setShortcut(Key_F10); coll->action( "preview" )->setShortcut(Key_F11); coll->action( "separate dirs" )->setShortcut(Key_F12); }
// 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); } }