NotificationDialog::NotificationDialog(Notification *notification, QWidget *parent) : QDialog(parent), m_notification(notification), m_closeLabel(NULL) { QFrame *notificationFrame = new QFrame(this); notificationFrame->setObjectName(QLatin1String("notificationFrame")); notificationFrame->setStyleSheet(QLatin1String("#notificationFrame {padding:5px;border:1px solid #CCC;border-radius:10px;background:#F0F0f0;}")); notificationFrame->setCursor(QCursor(Qt::PointingHandCursor)); notificationFrame->installEventFilter(this); QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::LeftToRight); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); mainLayout->setSizeConstraint(QLayout::SetMinimumSize); mainLayout->addWidget(notificationFrame); QLabel *iconLabel = new QLabel(this); iconLabel->setPixmap(Utils::getIcon(QLatin1String("otter-browser-32")).pixmap(32, 32)); iconLabel->setStyleSheet(QLatin1String("padding:5px;")); QLabel *messageLabel = new QLabel(this); messageLabel->setText(m_notification->getMessage()); messageLabel->setStyleSheet(QLatin1String("padding:5px;font-size:13px;")); messageLabel->setWordWrap(true); QStyleOption option; option.rect = QRect(0, 0, 16, 16); QPixmap pixmap(16, 16); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &option, &painter, this); m_closeLabel = new QLabel(notificationFrame); m_closeLabel->setToolTip(tr("Close")); m_closeLabel->setPixmap(pixmap); m_closeLabel->setAlignment(Qt::AlignTop); m_closeLabel->setMargin(5); m_closeLabel->installEventFilter(this); QBoxLayout *notificationLayout = new QBoxLayout(QBoxLayout::LeftToRight); notificationLayout->setContentsMargins(0, 0, 0, 0); notificationLayout->setSpacing(0); notificationLayout->setSizeConstraint(QLayout::SetMinimumSize); notificationLayout->addWidget(iconLabel); notificationLayout->addWidget(messageLabel); notificationLayout->addWidget(m_closeLabel); notificationFrame->setLayout(notificationLayout); setLayout(mainLayout); setFixedWidth(400); setMinimumHeight(50); setMaximumHeight(150); setWindowOpacity(0); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Tool | Qt::FramelessWindowHint); setFocusPolicy(Qt::NoFocus); setAttribute(Qt::WA_ShowWithoutActivating); setAttribute(Qt::WA_TranslucentBackground); adjustSize(); m_animation = new QPropertyAnimation(this, QStringLiteral("windowOpacity").toLatin1()); m_animation->setDuration(500); m_animation->setStartValue(0.0); m_animation->setEndValue(1.0); m_animation->start(); const int visibilityDuration = SettingsManager::getValue(QLatin1String("Interface/NotificationVisibilityDuration")).toInt(); if (visibilityDuration > 0) { QTimer::singleShot((visibilityDuration * 1000), this, SLOT(aboutToClose())); } }
/** * 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(); }