void GUI::setupActions() { KActionCollection* ac = actionCollection(); KAction* new_action = KStandardAction::openNew(this, SLOT(createTorrent()), ac); new_action->setToolTip(i18n("Create a new torrent")); KAction* open_action = KStandardAction::open(this, SLOT(openTorrent()), ac); open_action->setToolTip(i18n("Open a torrent")); paste_action = KStandardAction::paste(this, SLOT(paste()), ac); open_silently_action = new KAction(KIcon(open_action->icon()), i18n("Open Silently"), this); open_silently_action->setToolTip(i18n("Open a torrent without asking any questions")); connect(open_silently_action, SIGNAL(triggered()), this, SLOT(openTorrentSilently())); ac->addAction("file_open_silently", open_silently_action); KStandardAction::quit(this, SLOT(quit()), ac); show_status_bar_action = KStandardAction::showStatusbar(this, SLOT(showStatusBar()), ac); show_status_bar_action->setIcon(KIcon("kt-show-statusbar")); show_menu_bar_action = KStandardAction::showMenubar(this, SLOT(showMenuBar()), ac); KStandardAction::preferences(this, SLOT(showPrefDialog()), ac); KStandardAction::keyBindings(this, SLOT(configureKeys()), ac); KStandardAction::configureToolbars(this, SLOT(configureToolbars()), ac); KStandardAction::configureNotifications(this, SLOT(configureNotifications()), ac); paste_url_action = new KAction(KIcon("document-open-remote"), i18n("Open URL"), this); paste_url_action->setToolTip(i18n("Open a URL which points to a torrent, magnet links are supported")); paste_url_action->setShortcut(KShortcut(Qt::CTRL + Qt::Key_P)); connect(paste_url_action, SIGNAL(triggered()), this, SLOT(pasteURL())); ac->addAction("paste_url", paste_url_action); ipfilter_action = new KAction(KIcon("view-filter"), i18n("IP Filter"), this); ipfilter_action->setToolTip(i18n("Show the list of blocked IP addresses")); ipfilter_action->setShortcut(KShortcut(Qt::CTRL + Qt::Key_I)); connect(ipfilter_action, SIGNAL(triggered()), this, SLOT(showIPFilter())); ac->addAction("ipfilter_action", ipfilter_action); import_action = new KAction(KIcon("document-import"), i18n("Import Torrent"), this); import_action->setToolTip(i18n("Import a torrent")); import_action->setShortcut(KShortcut(Qt::SHIFT + Qt::Key_I)); connect(import_action, SIGNAL(triggered()), this, SLOT(import())); ac->addAction("import", import_action); show_kt_action = new KAction(KIcon("kt-show-hide"), i18n("Show/Hide KTorrent"), this); connect(show_kt_action, SIGNAL(triggered()), this, SLOT(showOrHide())); ac->addAction("show_kt", show_kt_action); show_kt_action->setGlobalShortcut(KShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_T)); setStandardToolBarMenuEnabled(true); }
MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent) , m_gameState(new KDiamond::GameState) , m_game(0) , m_view(new KDiamond::View) , m_infoBar(0) , m_newAct(new KActionMenu(KIcon( QLatin1String( "document-new") ), i18nc("new game", "&New" ), this)) , m_newTimedAct(new KAction(i18n("Timed game"), this)) , m_newUntimedAct(new KAction(i18n("Untimed game"), this)) , m_selector(KDiamond::renderer()->themeProvider(), KgThemeSelector::EnableNewStuffDownload) { KDiamond::renderer()->setDefaultPrimaryView(m_view); //init GUI - "New Action" m_newAct->setShortcut(KStandardShortcut::openNew()); m_newAct->setToolTip(i18n("Start a new game")); m_newAct->setWhatsThis(i18n("Start a new game.")); actionCollection()->addAction( QLatin1String( "game_new" ), m_newAct); connect(m_newAct, SIGNAL(triggered()), this, SLOT(startGameDispatcher())); m_newAct->addAction(m_newTimedAct); connect(m_newTimedAct, SIGNAL(triggered()), this, SLOT(startGameDispatcher())); m_newAct->addAction(m_newUntimedAct); connect(m_newUntimedAct, SIGNAL(triggered()), this, SLOT(startGameDispatcher())); //init GUI - the other actions KStandardGameAction::highscores(this, SLOT(showHighscores()), actionCollection()); m_pauseAct = KStandardGameAction::pause(this, SLOT(pausedAction(bool)), actionCollection()); KStandardGameAction::quit(kapp, SLOT(quit()), actionCollection()); m_hintAct = KStandardGameAction::hint(0, 0, actionCollection()); KStandardAction::preferences(&m_selector, SLOT(showAsDialog()), actionCollection()); KStandardAction::configureNotifications(this, SLOT(configureNotifications()), actionCollection()); //difficulty KgDifficultyGUI::init(this); connect(Kg::difficulty(), SIGNAL(currentLevelChanged(const KgDifficultyLevel*)), SLOT(startGameDispatcher())); //late GUI initialisation setupGUI(QSize(300, 400)); //TODO: find better solution for a minimum size setCaption(i18nc("The application's name", "KDiamond")); setCentralWidget(m_view); //init statusbar m_infoBar = new KDiamond::InfoBar(statusBar()); connect(m_gameState, SIGNAL(stateChanged(KDiamond::State)), this, SLOT(stateChange(KDiamond::State))); connect(m_gameState, SIGNAL(pointsChanged(int)), m_infoBar, SLOT(updatePoints(int))); connect(m_gameState, SIGNAL(leftTimeChanged(int)), m_infoBar, SLOT(updateRemainingTime(int))); //init game startGameDispatcher(); }
/** * Constructor. Connect all of the object and the job control. */ KAudioCreator::KAudioCreator( QWidget* parent, const char* name) : KMainWindow(parent, name) { janusWidget = new KJanusWidget(this, name, KJanusWidget::Tabbed); setCentralWidget(janusWidget); QVBox *frame = janusWidget->addVBoxPage(i18n("&CD Tracks"), QString::null, SmallIcon("cdaudio_unmount", 32)); tracks = new TracksImp(frame, "Tracks"); ripper = new Ripper ( frame, "Rip" ); encoder = new Encoder( frame, "Encoder" ); frame = janusWidget->addVBoxPage( i18n("&Jobs"), QString::null, SmallIcon( "run", 32 ) ); jobQue = new JobQueImp( frame, "Que" ); resize(500, 440); /*KAction *eject = */new KAction( i18n("&Eject CD"), 0, tracks, SLOT( eject() ), actionCollection(), "eject" ); (void)new KAction( i18n("&Configure KAudioCreator..."), 0, this, SLOT( showSettings() ), actionCollection(), "configure_kaudiocreator" ); KAction *selectAll = new KAction( i18n( "Select &All Tracks"), 0, tracks, SLOT( selectAllTracks() ), actionCollection(), "select_all" ) ; KAction *deselectAll = new KAction( i18n( "Deselect &All Tracks"), 0, tracks, SLOT( deselectAllTracks() ), actionCollection(), "deselect_all" ); selectAll->setEnabled( false ); deselectAll->setEnabled( false ); KActionMenu *actActionMenu = new KActionMenu( i18n("Rip &Selection"), "rip", actionCollection(), "rip" ); actActionMenu->setDelayed(true); //needed for checking "all accounts" actActionMenu->setEnabled( false ); connect( actActionMenu, SIGNAL( activated() ), tracks, SLOT( startSession() ) ); ripMenu = actActionMenu->popupMenu(); connect( ripMenu, SIGNAL( activated(int) ), this, SLOT( slotRipSelection(int)) ); connect( ripMenu, SIGNAL( aboutToShow() ), this, SLOT( getRipMenu()) ); KAction *rip = new KAction( i18n( "Rip &Selection" ), 0, tracks, SLOT( startSession() ), actionCollection(), "rip_selected" ); rip->setEnabled( false ); connect( jobQue, SIGNAL( removeJob(int) ), this, SLOT( updateStatus() ) ); connect( jobQue, SIGNAL( removeJob(int) ), ripper, SLOT( removeJob(int) ) ); connect( jobQue, SIGNAL( removeJob(int) ), encoder, SLOT( removeJob(int)) ); connect( ripper, SIGNAL( updateProgress(int, int) ) , jobQue, SLOT( updateProgress(int,int) ) ); connect( ripper, SIGNAL( addJob(Job*, const QString &) ), jobQue, SLOT( addJob(Job*, const QString &)) ); connect( ripper, SIGNAL( eject(const QString &) ) , tracks, SLOT( ejectDevice(const QString &)) ); connect( ripper, SIGNAL( encodeWav(Job *) ) , encoder, SLOT( encodeWav(Job *)) ); connect( ripper, SIGNAL( jobsChanged() ) , this, SLOT( updateStatus() ) ); connect( encoder, SIGNAL( updateProgress(int, int) ) , jobQue, SLOT( updateProgress(int,int)) ); connect( encoder, SIGNAL( addJob(Job*, const QString&)), jobQue, SLOT( addJob(Job*, const QString &)) ); connect( encoder, SIGNAL( jobsChanged() ) , this, SLOT( updateStatus() ) ); connect( tracks, SIGNAL( hasCD(bool) ) , this, SLOT( hasCD(bool) ) ); connect( tracks, SIGNAL( ripTrack(Job *) ), ripper, SLOT( ripTrack(Job *)) ); connect( tracks, SIGNAL( hasTracks(bool) ), rip, SLOT( setEnabled(bool)) ); connect( tracks, SIGNAL( hasTracks(bool) ), actActionMenu, SLOT( setEnabled(bool)) ); connect( tracks, SIGNAL( hasTracks(bool) ), deselectAll, SLOT( setEnabled(bool)) ); connect( tracks, SIGNAL( hasTracks(bool) ), selectAll, SLOT( setEnabled(bool)) ); (void)new KAction(i18n("Remove &Completed Jobs"), 0, jobQue, SLOT(clearDoneJobs()), actionCollection(), "clear_done_jobs" ); KAction *edit = new KAction(i18n("&Edit Album..."), 0, tracks, SLOT(editInformation()), actionCollection(), "edit_cd"); connect(tracks, SIGNAL(hasCD(bool)), edit, SLOT(setEnabled(bool))); edit->setEnabled( false ); (void)new KAction(i18n("Encode &File..."), 0, this, SLOT(encodeFile()), actionCollection(), "encode_file"); KAction *cddb = new KAction(i18n("&CDDB Lookup"), 0, tracks, SLOT(performCDDB()), actionCollection(), "cddb_now"); connect(tracks, SIGNAL(hasCD(bool)), cddb, SLOT(setEnabled(bool))); cddb->setEnabled( false ); KStdAction::configureNotifications(this, SLOT(configureNotifications()), actionCollection()); KStdAction::quit( this, SLOT(close()), actionCollection(), "quit" ); // Init statusbar statusBar()->insertItem(i18n("No Audio CD detected"), 0 ); hasCD(tracks->hasCD()); setupGUI(); }