UniversalPana::UniversalPana(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name): KonqSidebarPlugin(inst,parent,widgetParent,desktopName,name) { KGlobal::iconLoader()->addAppDir( "pana" ); widget = new panaWidget( widgetParent ); // widgetParent->resize(580,300); KToolBar *topBar = new KToolBar( widget, "Topbar" ); topBar->setIconSize(16); topBar->insertButton( "today", 0, SIGNAL( clicked() ), this, SLOT( currentTrack() ) ); topBar->insertButton( "document", 0, SIGNAL( clicked() ), this, SLOT( lyrics() ) ); topBar->insertButton( "personal", 0, SIGNAL( clicked() ), this, SLOT( wiki() ) ); browser = new KHTMLPart(widget, "widget-browser"); //browser=new KHTMLPart(widget); kdDebug() << "parentPart() << " << browser->parentPart() << endl; browser->setDNDEnabled( true ); browser->setEncoding( "utf8", true ); updateBrowser( HTML_FILE ); browser->view()->installEventFilter( widget ); panaDCOP = new DCOPClient(); panaDCOP->attach(); playerStub = new PanaPlayerInterface_stub( panaDCOP, "pana", "player"); playlistStub = new PanaPlaylistInterface_stub( panaDCOP, "pana", "playlist"); contextStub = new PanaContextBrowserInterface_stub (panaDCOP, "pana", "contextbrowser"); KToolBar* toolBar=new KToolBar(widget, "PlayerControls"); toolBar->setIconSize(16); toolBar->insertButton( "player_start",0, SIGNAL( clicked() ), this, SLOT( sendPrev() ) ); toolBar->insertButton( "player_play", 0, SIGNAL( clicked() ), this, SLOT( sendPlay() ) ); toolBar->insertButton( "player_pause",0, SIGNAL( clicked() ), this, SLOT( sendPause() ) ); toolBar->insertButton( "player_stop", 0, SIGNAL( clicked() ), this, SLOT( sendStop() ) ); toolBar->insertButton( "player_end", 0, SIGNAL( clicked() ), this, SLOT( sendNext() ) ); toolBar->insertSeparator(); toolBar->insertButton( "arts", 0, SIGNAL( clicked() ), this, SLOT( sendMute() ) ); vol_slider = new QSlider(0,100,1,0,Qt::Horizontal, toolBar,"volume"); vol_slider->setLineStep(2); connect(vol_slider, SIGNAL( valueChanged(int) ), this, SLOT(volChanged(int ) ) ); toolBar->insertWidget(1,2, vol_slider); fileInfo = new QFileInfo(HTML_FILE); QTimer *t = new QTimer( this ); connect( t, SIGNAL(timeout()), SLOT(updateStatus() ) ); t->start( 2000, false ); kdDebug() << "Connecting widget signal" << endl; connect( widget, SIGNAL( emitURL( const KURL &)), this, SLOT( openURLRequest( const KURL &) ) ); connect( browser->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ), this, SLOT( openURLRequest( const KURL & ) ) ); widget->show(); }
DataOutputWidget::DataOutputWidget(QWidget *parent) : QWidget(parent) , m_model(new DataOutputModel(this)) , m_view(new DataOutputView(this)) , m_isEmpty(true) { m_view->setModel(m_model); QHBoxLayout *layout = new QHBoxLayout(this); m_dataLayout = new QVBoxLayout(); KToolBar *toolbar = new KToolBar(this); toolbar->setOrientation(Qt::Vertical); toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); toolbar->setIconSize(QSize(16, 16)); /// TODO: disable actions if no results are displayed or selected KAction *action; action = new KAction( KIcon("distribute-horizontal-x"), i18nc("@action:intoolbar", "Resize columns to contents"), this); toolbar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(resizeColumnsToContents())); action = new KAction( KIcon("distribute-vertical-y"), i18nc("@action:intoolbar", "Resize rows to contents"), this); toolbar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(resizeRowsToContents())); action = new KAction( KIcon("edit-copy"), i18nc("@action:intoolbar", "Copy"), this); toolbar->addAction(action); m_view->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(slotCopySelected())); action = new KAction( KIcon("document-export-table"), i18nc("@action:intoolbar", "Export..."), this); toolbar->addAction(action); m_view->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(slotExport())); action = new KAction( KIcon("edit-clear"), i18nc("@action:intoolbar", "Clear"), this); toolbar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(clearResults())); toolbar->addSeparator(); KToggleAction *toggleAction = new KToggleAction( KIcon("applications-education-language"), i18nc("@action:intoolbar", "Use system locale"), this); toolbar->addAction(toggleAction); connect(toggleAction, SIGNAL(triggered()), this, SLOT(slotToggleLocale())); m_dataLayout->addWidget(m_view); layout->addWidget(toolbar); layout->addLayout(m_dataLayout); layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); }
KToolBar *ComposerWebEngineWidgetPrivate::createToolBar(const QList<ComposerWebEngine::ComposerWebEngineAction> &lstActions) { KToolBar *toolbar = new KToolBar(q); toolbar->setIconSize(QSize(22, 22)); toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); toolBarLayout->addWidget(toolbar); webEngine->createToolBar(lstActions, toolbar); listToolBar.append(toolbar); return toolbar; }
TextOutputWidget::TextOutputWidget(QWidget *parent) : QWidget(parent) { m_succesTextColor = QColor::fromRgb(3, 191, 3); m_succesBackgroundColor = QColor::fromRgb(231, 247, 231); m_errorTextColor = QColor::fromRgb(191, 3, 3); m_errorBackgroundColor = QColor::fromRgb(247, 231, 231); m_layout = new QHBoxLayout(this); m_output = new QTextEdit(); m_output->setReadOnly(true); QFont fixedFont(KGlobalSettings::fixedFont()); m_output->setCurrentFont(fixedFont); KToolBar *toolbar = new KToolBar(this); toolbar->setOrientation(Qt::Vertical); toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); toolbar->setIconSize(QSize(16, 16)); /// TODO: disable actions if no results are displayed KAction *action; action = new KAction( KIcon("edit-clear"), i18nc("@action:intoolbar", "Clear"), this); toolbar->addAction(action); connect(action, SIGNAL(triggered()), m_output, SLOT(clear())); m_layout->addWidget(toolbar); m_layout->addWidget(m_output, 1); setLayout(m_layout); }
/** * 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(); }
PlaylistBrowserNS::DynamicCategory::DynamicCategory( QWidget* parent ) : BrowserCategory( "dynamic category", parent ) { setPrettyName( i18n( "Dynamic Playlists" ) ); setShortDescription( i18n( "Dynamically updating parameter based playlists" ) ); setIcon( KIcon( "dynamic-amarok" ) ); setLongDescription( i18n( "With a dynamic playlist, Amarok becomes your own personal dj, automatically selecting tracks for you, based on a number of parameters that you select." ) ); setImagePath( KStandardDirs::locate( "data", "amarok/images/hover_info_dynamic_playlists.png" ) ); // set background if( AmarokConfig::showBrowserBackgroundImage() ) setBackgroundImage( imagePath() ); bool enabled = AmarokConfig::dynamicMode(); setContentsMargins( 0, 0, 0, 0 ); KHBox* controls2Layout = new KHBox( this ); QLabel *label; label = new QLabel( i18n( "Previous:" ), controls2Layout ); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); m_previous = new QSpinBox( controls2Layout ); m_previous->setMinimum( 0 ); m_previous->setToolTip( i18n( "Number of previous tracks to remain in the playlist." ) ); m_previous->setValue( AmarokConfig::previousTracks() ); QObject::connect( m_previous, SIGNAL(valueChanged(int)), this, SLOT(setPreviousTracks(int)) ); label = new QLabel( i18n( "Upcoming:" ), controls2Layout ); // label->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); label->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); m_upcoming = new QSpinBox( controls2Layout ); m_upcoming->setMinimum( 1 ); m_upcoming->setToolTip( i18n( "Number of upcoming tracks to add to the playlist." ) ); m_upcoming->setValue( AmarokConfig::upcomingTracks() ); QObject::connect( m_upcoming, SIGNAL(valueChanged(int)), this, SLOT(setUpcomingTracks(int)) ); QObject::connect( (const QObject*)Amarok::actionCollection()->action( "playlist_clear" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()) ); QObject::connect( (const QObject*)Amarok::actionCollection()->action( "disable_dynamic" ), SIGNAL(triggered(bool)), this, SLOT(playlistCleared()), Qt::DirectConnection ); // -- the tool bar KHBox* presetLayout = new KHBox( this ); KToolBar* presetToolbar = new KToolBar( presetLayout ); presetToolbar->setIconSize( QSize( 22, 22 ) ); presetToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly ); presetToolbar->setMovable( false ); presetToolbar->setFloatable( false ); presetToolbar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); m_onOffButton = new QToolButton( presetToolbar ); m_onOffButton->setText( i18nc( "Turn dynamic mode on", "On") ); m_onOffButton->setCheckable( true ); m_onOffButton->setIcon( KIcon( "dynamic-amarok" ) ); m_onOffButton->setToolTip( i18n( "Turn dynamic mode on." ) ); presetToolbar->addWidget( m_onOffButton ); m_duplicateButton = new QToolButton( presetToolbar ); m_duplicateButton->setText( i18n("Duplicates") ); m_duplicateButton->setCheckable( true ); m_duplicateButton->setChecked( allowDuplicates() ); m_duplicateButton->setIcon( KIcon( "edit-copy" ) ); m_duplicateButton->setToolTip( i18n( "Allow duplicate songs in result" ) ); presetToolbar->addWidget( m_duplicateButton ); m_addButton = new QToolButton( presetToolbar ); m_addButton->setText( i18n("New") ); m_addButton->setIcon( KIcon( "document-new" ) ); m_addButton->setToolTip( i18n( "New playlist" ) ); presetToolbar->addWidget( m_addButton ); m_editButton = new QToolButton( presetToolbar ); m_editButton->setText( i18n("Edit") ); m_editButton->setIcon( KIcon( "document-properties-amarok" ) ); m_editButton->setToolTip( i18n( "Edit the selected playlist or bias" ) ); presetToolbar->addWidget( m_editButton ); m_deleteButton = new QToolButton( presetToolbar ); m_deleteButton->setText( i18n("Delete") ); m_deleteButton->setEnabled( false ); m_deleteButton->setIcon( KIcon( "edit-delete" ) ); m_deleteButton->setToolTip( i18n( "Delete the selected playlist or bias") ); presetToolbar->addWidget( m_deleteButton ); m_repopulateButton = new QPushButton( presetLayout ); m_repopulateButton->setText( i18n("Repopulate") ); m_repopulateButton->setToolTip( i18n("Replace the upcoming tracks with fresh ones.") ); m_repopulateButton->setIcon( KIcon( "view-refresh-amarok" ) ); m_repopulateButton->setEnabled( enabled ); // m_repopulateButton->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); QObject::connect( m_repopulateButton, SIGNAL(clicked(bool)), The::playlistActions(), SLOT(repopulateDynamicPlaylist()) ); // -- the tree view m_tree = new DynamicView( this ); connect( m_tree->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged()) ); connect( m_onOffButton, SIGNAL(toggled(bool)), The::playlistActions(), SLOT(enableDynamicMode(bool)) ); connect( m_duplicateButton, SIGNAL(toggled(bool)), this, SLOT(setAllowDuplicates(bool)) ); connect( m_addButton, SIGNAL(clicked(bool)), m_tree, SLOT(addPlaylist()) ); connect( m_editButton, SIGNAL(clicked(bool)), m_tree, SLOT(editSelected()) ); connect( m_deleteButton, SIGNAL(clicked(bool)), m_tree, SLOT(removeSelected()) ); navigatorChanged(); selectionChanged(); connect( The::playlistActions(), SIGNAL(navigatorChanged()), this, SLOT(navigatorChanged()) ); }