MainWindow::MainWindow() { m_main = new MainArea(); QGraphicsView* view = new QGraphicsView(m_main, this); view->setOptimizationFlags( QGraphicsView::DontClipPainter | QGraphicsView::DontSavePainterState | QGraphicsView::DontAdjustForAntialiasing ); // view->setViewportUpdateMode( QGraphicsView::FullViewportUpdate ); view->setCacheMode( QGraphicsView::CacheBackground ); view->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); view->setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setCentralWidget(view); setupActions(); #ifndef Q_OS_QNX QLayout* l = layout(); Q_ASSERT(l); l->setSizeConstraint(QLayout::SetFixedSize); // setup status bar KStatusBar* bar = statusBar(); Q_ASSERT(bar); m_time_label = new QLabel(""); bar->addPermanentWidget(m_time_label); m_balls_label = new QLabel(""); bar->addWidget(m_balls_label); // bar->setItemAlignment(STATUSBAR_BALLS, Qt::AlignLeft); #endif connect(m_main, SIGNAL(changeGameTime(int)), this, SLOT(setGameTime(int))); connect(m_main, SIGNAL(changeBallNumber(int)), this, SLOT(setBallNumber(int))); connect(m_main, SIGNAL(changeState(bool)), this, SLOT(changeState(bool))); connect(m_main, SIGNAL(pause(bool)), this, SLOT(pause(bool))); #ifndef Q_OS_QNX stateChanged("playing", KXMLGUIClient::StateReverse); #endif connect(m_main, SIGNAL(starting()), this, SLOT(newGame())); connect(m_main, SIGNAL(gameOver(int)), this, SLOT(gameOver(int))); #ifndef Q_OS_QNX KGameDifficulty::init(this, this, SLOT(difficultyChanged(KGameDifficulty::standardLevel))); KGameDifficulty::setRestartOnChange(KGameDifficulty::RestartOnChange); KGameDifficulty::addStandardLevel(KGameDifficulty::Easy); KGameDifficulty::addStandardLevel(KGameDifficulty::Medium); KGameDifficulty::addStandardLevel(KGameDifficulty::Hard); KGameDifficulty::setLevel(KGameDifficulty::standardLevel(KollisionConfig::gameDifficulty())); #endif #ifdef Q_OS_QNX //setMinimumSize(m_main->sceneRect().size().toSize()); #endif }
/** * Positions child widgets into their docking stations, and performs some * other main window initialisation. */ void KScope::initMainWindow() { KStatusBar* pStatus; KDockWidget* pMainDock; QPopupMenu* pPopup; // Create the status bar pStatus = statusBar(); pStatus->insertItem(i18n(" Line: N/A Col: N/A "), 0, 0, true); // Create the main dock for the editor tabs widget pMainDock = createDockWidget("Editors Window", QPixmap()); pMainDock->setWidget(m_pEditTabs); pMainDock->setDockSite(KDockWidget::DockCorner); setMainDockWidget(pMainDock); setView(pMainDock); pMainDock->setEnableDocking(KDockWidget::DockNone); // Create the query window dock m_pQueryDock->setWidget(m_pQueryWidget); m_pQueryDock->manualDock(pMainDock, KDockWidget::DockBottom, 65); // Update the relevant shell action when the dock is hidden through its // close button connect(m_pQueryDock, SIGNAL(headerCloseButtonClicked()), m_pActions, SLOT(slotQueryDockClosed())); // Create the file view dock m_pFileViewDock->setWidget(m_pFileView); m_pFileViewDock->manualDock(pMainDock, KDockWidget::DockRight, 80); // Update the relevant shell action when the dock is hidden through its // close button connect(m_pFileViewDock, SIGNAL(headerCloseButtonClicked()), m_pActions, SLOT(slotFileViewDockClosed())); // Associate the "Window" menu with the editor tabs widdget pPopup = (QPopupMenu*)factory()->container("window", this); m_pEditTabs->setWindowMenu(pPopup); // Associate the "Query" popup menu with the query widget pPopup = (QPopupMenu*)factory()->container("query_popup", this); m_pQueryWidget->setPageMenu(pPopup, m_pActions->getLockAction()); // Restore dock configuration Config().loadWorkspace(this); m_bHideQueryOnSelection = m_pQueryDock->isHidden(); m_pActions->initLayoutActions(); }
void KoView::slotClearStatusText() { KStatusBar *sb = statusBar(); if ( sb ) sb->clear(); }
void KoView::slotActionStatusText( const QString &text ) { KStatusBar *sb = statusBar(); if ( sb ) sb->message( text ); }
void KHelpMain::createStatusbar() { KStatusBar *sbar = new KStatusBar(this); sbar->insertItem((char*)klocale->translate("In the Constructor!"), 0); statusbar = sbar; }
void KMJobViewer::initActions() { // job actions KAction *hact = new KAction(i18n("&Hold"),"stop",0,this,SLOT(slotHold()),actionCollection(),"job_hold"); KAction *ract = new KAction(i18n("&Resume"),"run",0,this,SLOT(slotResume()),actionCollection(),"job_resume"); KAction *dact = new KAction(i18n("Remo&ve"),"edittrash",Qt::Key_Delete,this,SLOT(slotRemove()),actionCollection(),"job_remove"); KAction *sact = new KAction(i18n("Res&tart"),"redo",0,this,SLOT(slotRestart()),actionCollection(),"job_restart"); KActionMenu *mact = new KActionMenu(i18n("&Move to Printer"),"fileprint",actionCollection(),"job_move"); mact->setDelayed(false); connect(mact->popupMenu(),SIGNAL(activated(int)),SLOT(slotMove(int))); connect(mact->popupMenu(),SIGNAL(aboutToShow()),KMTimer::self(),SLOT(hold())); connect(mact->popupMenu(),SIGNAL(aboutToHide()),KMTimer::self(),SLOT(release())); connect(mact->popupMenu(),SIGNAL(aboutToShow()),SLOT(slotShowMoveMenu())); KToggleAction *tact = new KToggleAction(i18n("&Toggle Completed Jobs"),"history",0,actionCollection(),"view_completed"); tact->setEnabled(m_manager->actions() & KMJob::ShowCompleted); connect(tact,SIGNAL(toggled(bool)),SLOT(slotShowCompleted(bool))); KToggleAction *uact = new KToggleAction(i18n("Show Only User Jobs"), "personal", 0, actionCollection(), "view_user_jobs"); uact->setCheckedState(KGuiItem(i18n("Hide Only User Jobs"),"personal")); connect(uact, SIGNAL(toggled(bool)), SLOT(slotUserOnly(bool))); m_userfield = new QLineEdit(0); m_userfield->setText(getenv("USER")); connect(m_userfield, SIGNAL(returnPressed()), SLOT(slotUserChanged())); connect(uact, SIGNAL(toggled(bool)), m_userfield, SLOT(setEnabled(bool))); m_userfield->setEnabled(false); m_userfield->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); KWidgetAction *ufact = new KWidgetAction(m_userfield, i18n("User Name"), 0, 0, 0, actionCollection(), "view_username"); if (!m_pop) { m_pop = new QPopupMenu(this); connect(m_pop,SIGNAL(aboutToShow()),KMTimer::self(),SLOT(hold())); connect(m_pop,SIGNAL(aboutToHide()),KMTimer::self(),SLOT(release())); hact->plug(m_pop); ract->plug(m_pop); m_pop->insertSeparator(); dact->plug(m_pop); mact->plug(m_pop); m_pop->insertSeparator(); sact->plug(m_pop); } // Filter actions KActionMenu *fact = new KActionMenu(i18n("&Select Printer"), "kdeprint_printer", actionCollection(), "filter_modify"); fact->setDelayed(false); connect(fact->popupMenu(),SIGNAL(activated(int)),SLOT(slotPrinterSelected(int))); connect(fact->popupMenu(),SIGNAL(aboutToShow()),KMTimer::self(),SLOT(hold())); connect(fact->popupMenu(),SIGNAL(aboutToHide()),KMTimer::self(),SLOT(release())); connect(fact->popupMenu(),SIGNAL(aboutToShow()),SLOT(slotShowPrinterMenu())); if (!m_standalone) { KToolBar *toolbar = toolBar(); hact->plug(toolbar); ract->plug(toolbar); toolbar->insertSeparator(); dact->plug(toolbar); mact->plug(toolbar); toolbar->insertSeparator(); sact->plug(toolbar); toolbar->insertSeparator(); tact->plug(toolbar); uact->plug(toolbar); ufact->plug(toolbar); } else { // stand-alone application KStdAction::quit(kapp,SLOT(quit()),actionCollection()); KStdAction::close(this,SLOT(slotClose()),actionCollection()); KStdAction::preferences(this, SLOT(slotConfigure()), actionCollection()); // refresh action new KAction(i18n("Refresh"),"reload",0,this,SLOT(slotRefresh()),actionCollection(),"refresh"); // create status bar KStatusBar *statusbar = statusBar(); m_stickybox = new QCheckBox( i18n( "Keep window permanent" ), statusbar ); statusbar->addWidget( m_stickybox, 1, false ); statusbar->insertItem(" " + i18n("Max.: %1").arg(i18n("Unlimited"))+ " ", 0, 0, true); statusbar->setItemFixed(0); updateStatusBar(); createGUI(); } loadPluginActions(); slotSelectionChanged(); }
// 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); }
Player::Player(QWidget *parent) : KXmlGuiWindow(parent) { //SETUP DATABASE QDir(KGlobal::dirs()->saveLocation("data")).mkdir("projekt7"); //NOTE: creates the projekt7 directory if it doesn't already exist QString db_path = KGlobal::dirs()->saveLocation("data") + "projekt7/tracks_db"; int return_code = sqlite3_open(qtos(db_path), &tracks_db); if (return_code) { showError("Failed to open the Projekt7 Track Database: ", sqlite3_errmsg(tracks_db)); exit(return_code); } const char *create_table = "CREATE TABLE IF NOT EXISTS `tracks` (`tid` INTEGER PRIMARY KEY, `artist` VARCHAR KEY ASC, `year` INT KEY ASC, `album` VARCHAR, `track_number` INT KEY ASC, `title` VARCHAR, `path` VARCHAR, `length` INT, `playcount` INT)"; //TODO make use of the `length` and `playcount` columns char *errmsg; return_code = sqlite3_exec(tracks_db, create_table, 0, 0, &errmsg); if (return_code) { showError("Failed to create `tracks` table: ", errmsg); sqlite3_free(errmsg); exit(return_code); } updateNumTracks(); //SETUP PHONON now_playing = new Phonon::MediaObject(this); Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); createPath(now_playing, audioOutput); now_playing->setTickInterval(1000); //SETUP WIDGETS QWidget *central_widget = new QWidget(this); KToolBar *toolbar_widget = new KToolBar(i18n("Main Toolbar"), central_widget); toolbar_widget->setIconDimensions(32); playlist_widget = new QWidget(central_widget); artist_list = new KListWidget(playlist_widget); artist_list->addItem(ALL); album_list = new KListWidget(playlist_widget); titles_list = new KListWidget(playlist_widget); QAction* tb_previousAction = toolbar_widget->addAction(KIcon("media-skip-backward"), ""); QString previousHelpText = i18n("Play the previous track"); tb_previousAction->setToolTip(previousHelpText); QAction* tb_pauseAction = toolbar_widget->addAction(KIcon("media-playback-pause"), ""); QString plauseHelpText = i18n("Plause playback"); tb_pauseAction->setToolTip(plauseHelpText); QAction* tb_playAction = toolbar_widget->addAction(KIcon("media-playback-start"), ""); QString playHelpText = i18n("Play the track"); tb_playAction->setToolTip(playHelpText); QAction* tb_nextAction = toolbar_widget->addAction(KIcon("media-skip-forward"), ""); QString nextHelpText = i18n("Play the next track"); tb_nextAction->setToolTip(nextHelpText); toolbar_widget->addSeparator(); Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider; volumeSlider->setAudioOutput(audioOutput); volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); toolbar_widget->addWidget(volumeSlider); toolbar_widget->addSeparator(); Phonon::SeekSlider *seekSlider = new Phonon::SeekSlider(now_playing); volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); toolbar_widget->addWidget(seekSlider); toolbar_widget->addSeparator(); cur_time = new QLabel(" 0:00", toolbar_widget); cur_time->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); toolbar_widget->addWidget(cur_time); toolbar_widget->addWidget(new QLabel(" / ", toolbar_widget)); track_duration = new QLabel("0:00", toolbar_widget); track_duration->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); toolbar_widget->addWidget(track_duration); queued = new KIcon("go-next-view"); QHBoxLayout *listLayout = new QHBoxLayout; listLayout->addWidget(artist_list); listLayout->addWidget(album_list); listLayout->addWidget(titles_list); playlist_widget->setLayout(listLayout); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(toolbar_widget); mainLayout->addWidget(playlist_widget); central_widget->setLayout(mainLayout); setCentralWidget(central_widget); //SETUP STATUS BAR KStatusBar* bar = statusBar(); bar->insertPermanentItem("", SONG_NAME, true); bar->setItemAlignment(SONG_NAME, Qt::AlignLeft | Qt::AlignVCenter); //SETUP SYSTEM TRAY ICON tray_icon = new KSystemTrayIcon("projekt7", this); tray_icon->show(); //SETUP METADATA WINDOW metadata_window = new QWidget(this, Qt::Dialog); metadata_window->setWindowModality(Qt::WindowModal); metadata_window->setWindowTitle("Track Details | Projekt 7"); mw_ok_button = new KPushButton(KIcon("dialog-ok-apply"), "OK", metadata_window); mw_ok_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); QGridLayout *mwLayout = new QGridLayout; mwLayout->addWidget(new QLabel("Artist:", metadata_window), 0, 0); mwLayout->addWidget(new QLabel("Year:", metadata_window), 1, 0); mwLayout->addWidget(new QLabel("Album:", metadata_window), 2, 0); mwLayout->addWidget(new QLabel("Track Number:", metadata_window), 3, 0); mwLayout->addWidget(new QLabel("Title:", metadata_window), 4, 0); mwLayout->addWidget(new QLabel("File Path:", metadata_window), 5, 0); mwLayout->addWidget(mw_artist = new QLabel(metadata_window), 0, 1); mwLayout->addWidget(mw_year = new QLabel(metadata_window), 1, 1); mwLayout->addWidget(mw_album = new QLabel(metadata_window), 2, 1); mwLayout->addWidget(mw_track_number = new QLabel(metadata_window), 3, 1); mwLayout->addWidget(mw_title = new QLabel(metadata_window), 4, 1); mwLayout->addWidget(mw_path = new QLabel(metadata_window), 5, 1); mwLayout->addWidget(mw_ok_button, 6, 0, 1, 2, Qt::AlignCenter); metadata_window->setLayout(mwLayout); //SETUP QUEUE EDITOR WINDOW queue_window = new QWidget(this, Qt::Dialog); queue_window->setWindowModality(Qt::WindowModal); queue_window->setWindowTitle("Track Queue Editor | Projekt 7"); qw_ok_button = new KPushButton(KIcon("dialog-ok-apply"), "OK", queue_window); qw_ok_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); QVBoxLayout *qw_buttons_layout = new QVBoxLayout; KPushButton *qw_top_button = new KPushButton(KIcon("go-top"), "", queue_window); KPushButton *qw_up_button = new KPushButton(KIcon("go-up"), "", queue_window); KPushButton *qw_down_button = new KPushButton(KIcon("go-down"), "", queue_window); KPushButton *qw_bottom_button = new KPushButton(KIcon("go-bottom"), "", queue_window); KPushButton *qw_remove_button = new KPushButton(KIcon("edit-delete"), "", queue_window); qw_buttons_layout->addWidget(qw_top_button); qw_buttons_layout->addWidget(qw_up_button); qw_buttons_layout->addWidget(qw_down_button); qw_buttons_layout->addWidget(qw_bottom_button); qw_buttons_layout->addWidget(qw_remove_button); QHBoxLayout *qw_list_buttons_layout = new QHBoxLayout; qw_queue_list = new KListWidget(queue_window); QWidget *qw_button_holder = new QWidget(queue_window); qw_button_holder->setLayout(qw_buttons_layout); qw_list_buttons_layout->addWidget(qw_queue_list); qw_list_buttons_layout->addWidget(qw_button_holder); QVBoxLayout *qwLayout = new QVBoxLayout; QWidget *qw_list_buttons = new QWidget(queue_window); qw_list_buttons->setLayout(qw_list_buttons_layout); qwLayout->addWidget(qw_list_buttons); qwLayout->addWidget(qw_ok_button, 0, Qt::AlignCenter); queue_window->setLayout(qwLayout); //SETUP ACTIONS KStandardAction::quit(kapp, SLOT(quit()), actionCollection()); connect(kapp, SIGNAL(aboutToQuit()), this, SLOT(quit())); connect(now_playing, SIGNAL(aboutToFinish()), this, SLOT(enqueueNext())); connect(now_playing, SIGNAL(totalTimeChanged(qint64)), this, SLOT(updateDuration(qint64))); connect(now_playing, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); KAction *openFilesAction = setupKAction("document-open", i18n("Open"), i18n("Load the selected files"), "files"); openFilesAction->setShortcut(QKeySequence::Open); connect(openFilesAction, SIGNAL(triggered(bool)), this, SLOT(loadFiles())); KAction *openDirectoryAction = setupKAction("document-open-folder", i18n("Open Directory..."), i18n("Load all files in the selected directory and its subdirectories"), "directory"); openDirectoryAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); connect(openDirectoryAction, SIGNAL(triggered(bool)), this, SLOT(loadDirectory())); KAction *previousAction = setupKAction("media-skip-backward", i18n("Previous"), previousHelpText, "previous"); previousAction->setShortcut(QKeySequence(Qt::Key_Z)); connect(previousAction, SIGNAL(triggered(bool)), this, SLOT(previous())); connect(tb_previousAction, SIGNAL(triggered(bool)), this, SLOT(previous())); KAction *pauseAction = setupKAction("media-playback-pause", i18n("Pause"), plauseHelpText, "pause"); pauseAction->setShortcut(QKeySequence(Qt::Key_C)); connect(pauseAction, SIGNAL(triggered(bool)), this, SLOT(pause())); connect(tb_pauseAction, SIGNAL(triggered(bool)), this, SLOT(pause())); KAction *playAction = setupKAction("media-playback-start", i18n("Play"), playHelpText, "play"); playAction->setShortcut(QKeySequence(Qt::Key_X)); connect(playAction, SIGNAL(triggered(bool)), this, SLOT(play())); connect(tb_playAction, SIGNAL(triggered(bool)), this, SLOT(play())); KAction *nextAction = setupKAction("media-skip-forward", i18n("Next"), nextHelpText, "next"); nextAction->setShortcut(QKeySequence(Qt::Key_V)); connect(nextAction, SIGNAL(triggered(bool)), this, SLOT(next())); connect(tb_nextAction, SIGNAL(triggered(bool)), this, SLOT(next())); KAction *queueAction = setupKAction("go-next-view", i18n("Queue Track"), "Enqueue the current track", "queue"); queueAction->setShortcut(QKeySequence(Qt::Key_Q)); connect(queueAction, SIGNAL(triggered(bool)), this, SLOT(queue())); shuffleAction = setupKAction("media-playlist-shuffle", i18n("Suffle"), "The next track will be random when checked", "shuffle"); shuffleAction->setCheckable(true); connect(shuffleAction, SIGNAL(triggered(bool)), this, SLOT(shuffle(bool))); KAction *viewCurrentTrackAction = setupKAction("go-last", i18n("Current Track"), i18n("Show the Current Track in the Playlist"), "current_track"); connect(viewCurrentTrackAction, SIGNAL(triggered(bool)), this, SLOT(viewCurrentTrack())); KAction *viewTrackDetailsAction = setupKAction("view-media-lyrics", i18n("Track Details"), i18n("View the playing track's metadata"), "track_details"); connect(viewTrackDetailsAction, SIGNAL(triggered(bool)), this, SLOT(viewTrackDetails())); KAction *viewTrackQueueAction = setupKAction("view-time-schedule-edit", i18n("Track Queue"), i18n("Edit the track queue"), "track_queue"); connect(viewTrackQueueAction, SIGNAL(triggered(bool)), this, SLOT(viewTrackQueue())); viewPlaylistAction = setupKAction("view-file-columns", i18n("Playlist"), i18n("Show/Hide the playlist"), "playlist"); viewPlaylistAction->setCheckable(true); connect(viewPlaylistAction, SIGNAL(triggered(bool)), this, SLOT(viewPlaylist(bool))); connect(artist_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(updateAlbumList(QListWidgetItem *, QListWidgetItem *))); connect(album_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(updateTitlesList(QListWidgetItem *, QListWidgetItem *))); connect(titles_list, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(showTrackInfo(QListWidgetItem *, QListWidgetItem *))); connect(titles_list, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(play(QListWidgetItem *))); connect(mw_ok_button, SIGNAL(clicked()), this, SLOT(hideTrackDetails())); connect(qw_top_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackToTop())); connect(qw_up_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackUp())); connect(qw_down_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackDown())); connect(qw_bottom_button, SIGNAL(clicked()), this, SLOT(moveQueuedTrackToBottom())); connect(qw_remove_button, SIGNAL(clicked()), this, SLOT(dequeueTrack())); connect(qw_ok_button, SIGNAL(clicked()), this, SLOT(hideTrackQueue())); //SETUP GUI qsrand(QDateTime::currentDateTime().toTime_t()); setupGUI(Default, "projekt7ui.rc"); updateArtistList(0); //READ CONFIG config = KGlobal::config(); KConfigGroup curTrackDetails(config, "curTrackDetails"); cur_artist = artist_list->item(curTrackDetails.readEntry("artist", QString()).toInt()); cur_album = curTrackDetails.readEntry("album", QString()).toInt(); cur_title = curTrackDetails.readEntry("title", QString()).toInt(); KConfigGroup applicationSettings(config, "applicationSettings"); viewPlaylistAction->setChecked(applicationSettings.readEntry("playlistVisible", QString()).toInt()); shuffle_tracks = applicationSettings.readEntry("shuffleTracks", QString()).toInt(); shuffleAction->setChecked(shuffle_tracks); viewCurrentTrack(); if (titles_list->count() > 0) { if (titles_list->currentRow() == -1) titles_list->setCurrentRow(0); play(titles_list->currentItem()->data(Qt::UserRole).toInt(), false, false); pause(); quint64 song_position = curTrackDetails.readEntry("tick", QString()).toLongLong(); now_playing->seek(song_position); tick(song_position); //TODO update the seekSlider's position to match the "tick" location of the song } }
void MyFracWindow::createWidgets() { KDockWidget* dockMain = createDockWidget("main", NULL); _tabWidget = new QTabWidget(dockMain); dockMain->setWidget(_tabWidget); _view2D = new ViewWidget(true, _tabWidget); _tabWidget->addTab(_view2D, SmallIconSet("frtab2d"), i18n("2D View")); _view3D = new View3DWidget(_tabWidget); _tabWidget->addTab(_view3D, SmallIconSet("frtab3d"), i18n("3D View")); _dockParams = createDockWidget("params", SmallIcon("frparams"), NULL, i18n("Parameters")); QWidget* params = createParamsDock(_dockParams); _dockParams->setWidget(params); _dockDisplay = createDockWidget("display", SmallIcon("frdisplay"), NULL, i18n("Display")); QWidget* display = createDisplayDock(_dockParams); _dockDisplay->setWidget(display); _dockPreview = createDockWidget("preview", SmallIcon("viewmag"), NULL, i18n("Preview")); ViewWidget* preview = new ViewWidget(false, _dockPreview); _dockPreview->setWidget(preview); dockMain->setDockSite(KDockWidget::DockCorner); dockMain->setEnableDocking(KDockWidget::DockNone); setView(dockMain); setMainDockWidget(dockMain); KDockWidget* dock1 = _dockDisplay->manualDock(_dockParams, KDockWidget::DockCenter); KDockWidget* dock2 = _dockPreview->manualDock(dock1, KDockWidget::DockBottom, 65); dock2->manualDock(dockMain, KDockWidget::DockRight, 65); connect(_tabWidget, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged())); connect(this, SIGNAL(view2DEnabled(bool)), _view2D, SLOT(setVisible(bool))); connect(this, SIGNAL(view3DEnabled(bool)), _view3D, SLOT(setVisible(bool))); connect(this, SIGNAL(previewEnabled(bool)), _view2D, SLOT(enablePreview(bool))); connect(this, SIGNAL(positionChanged(double, double, double, double)), _view2D, SLOT(setPosition(double, double, double, double))); connect(this, SIGNAL(positionChanged(double, double, double, double)), _view3D, SLOT(setPosition(double, double, double, double))); connect(this, SIGNAL(positionChanged(double, double, double, double)), preview, SLOT(setPreviewPosition(double, double, double, double))); connect(this, SIGNAL(modeChangedMandelbrot()), _view2D, SLOT(setMandelbrotMode())); connect(this, SIGNAL(modeChangedMandelbrot()), _view3D, SLOT(setMandelbrotMode())); connect(this, SIGNAL(modeChangedJulia(double, double)), _view2D, SLOT(setJuliaMode(double, double))); connect(this, SIGNAL(modeChangedJulia(double, double)), _view3D, SLOT(setJuliaMode(double, double))); connect(this, SIGNAL(precisionChanged(double, double)), _view2D, SLOT(setQuality(double, double))); connect(this, SIGNAL(precisionChanged(double, double)), _view3D, SLOT(setQuality(double, double))); connect(this, SIGNAL(precisionChanged(double, double)), preview, SLOT(setQuality(double, double))); connect(this, SIGNAL(backgroundChanged(QRgb)), _view2D, SLOT(setBackground(QRgb))); connect(this, SIGNAL(backgroundChanged(QRgb)), _view3D, SLOT(setBackground(QRgb))); connect(this, SIGNAL(backgroundChanged(QRgb)), preview, SLOT(setBackground(QRgb))); connect(this, SIGNAL(gradientChanged(const QRgb*, double, double)), _view2D, SLOT(setGradient(const QRgb*, double, double))); connect(this, SIGNAL(gradientChanged(const QRgb*, double, double)), _view3D, SLOT(setGradient(const QRgb*, double, double))); connect(this, SIGNAL(gradientChanged(const QRgb*, double, double)), preview, SLOT(setGradient(const QRgb*, double, double))); connect(_view2D, SIGNAL(previewVisible(bool)), preview, SLOT(setVisible(bool))); connect(_view2D, SIGNAL(previewPosition(double, double)), preview, SLOT(setJuliaMode(double, double))); connect(_view2D, SIGNAL(positionChanged(double, double, double, double)), this, SLOT(setPosition(double, double, double, double))); connect(_view2D, SIGNAL(previewDoubleClick(double, double)), this, SLOT(setJuliaMode(double, double))); connect(this, SIGNAL(gridSizeChanged(int, int)), _view3D, SLOT(setGridSize(int, int))); connect(this, SIGNAL(heightScaleChanged(double)), _view3D, SLOT(setHeightScale(double))); _view2D->enableTransform(true); KStatusBar* status = statusBar(); status->setSizeGripEnabled(false); QProgressBar* progress = new QProgressBar(100, status); progress->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); progress->setMaximumHeight(status->sizeHint().height() - 2); progress->setMinimumWidth(120); progress->setProgress(100); status->addWidget(progress, 0, true); connect(_view2D, SIGNAL(updateProgress(int)), progress, SLOT(setProgress(int))); connect(_view3D, SIGNAL(updateProgress(int)), progress, SLOT(setProgress(int))); }