void MainWindow::initToolsMenu() { if (!m_toolsMenu) return; m_toolsMenu->menu()->clear(); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find))); QAction *action = actionByName(KStandardAction::name(KStandardAction::Zoom)); action->setCheckable(true); connect (m_zoomBar, SIGNAL(visibilityChanged(bool)), action, SLOT(setChecked(bool))); m_toolsMenu->addAction(action); m_toolsMenu->addAction(actionByName(QL1S("encodings"))); m_toolsMenu->addSeparator(); m_toolsMenu->addAction(actionByName(QL1S("private_browsing"))); m_toolsMenu->addAction(actionByName(QL1S("clear_private_data"))); m_toolsMenu->addSeparator(); KActionMenu *webMenu = new KActionMenu(KIcon("applications-development-web"), i18n("Development"), this); webMenu->addAction(actionByName(QL1S("web_inspector"))); webMenu->addAction(actionByName(QL1S("page_source"))); webMenu->addAction(actionByName(QL1S("net_analyzer"))); m_toolsMenu->addAction(webMenu); m_toolsMenu->addSeparator(); action = m_bookmarksBar->toolBar()->toggleViewAction(); action->setText(i18n("Bookmarks Toolbar")); action->setIcon(KIcon("bookmarks-bar")); m_toolsMenu->addAction(action); m_toolsMenu->addAction(actionByName(QL1S("show_history_panel"))); m_toolsMenu->addAction(actionByName(QL1S("show_bookmarks_panel"))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen))); m_toolsMenu->addSeparator(); this->setHelpMenuEnabled(true); helpMenu()->setIcon(KIcon("help-browser")); m_toolsMenu->addAction(helpMenu()->menuAction()); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences))); }
imageCompareBase::imageCompareBase(windowManager* windowMgr) : imageSaverWindow(tr("Colors"), windowMgr), leftImageSavedSize_(QSize()), rightImageSavedSize_(QSize()) { constructScrolling(); splitter_ = new QSplitter; splitter_->addWidget(leftScroll_); splitter_->addWidget(rightScroll_); setCentralWidget(splitter_); leftFocusAction_ = new QAction(QIcon(":leftImage.png"), tr("Focus left side"), this); rightFocusAction_ = new QAction(QIcon(":rightImage.png"), tr("Focus right side"), this); leftImageListBox_ = new comboBox(this); leftImageListBox_->setToolTip(tr("Select the left side image")); rightImageListBox_ = new comboBox(this); rightImageListBox_->setToolTip(tr("Select the right side image")); addZoomActionsToImageMenu(); //: Whether zooming zooms both images at once, or just one dualZoomingAction_ = new QAction(tr("Dual zooming"), this); dualZoomingAction_->setCheckable(true); dualZoomingAction_->setChecked(true); imageMenu()->addAction(dualZoomingAction_); imageMenu()->addAction(dualScrollingAction_); switchAction_ = imageMenu()->addAction(tr("Switch sides")); centerSplitterAction_ = imageMenu()->addAction(tr("Center splitter")); leftImageMenu_ = new QMenu(tr("&Left Image"), this); menuBar()->insertMenu(helpMenu()->menuAction(), leftImageMenu_); leftShowHide_ = leftImageMenu_->addAction(tr("Show left image")); leftShowHide_->setCheckable(true); leftDelete_ = leftImageMenu_->addAction(tr("Delete left image")); leftImageMenu_->addSeparator(); rightImageMenu_ = new QMenu(tr("&Right Image"), this); menuBar()->insertMenu(helpMenu()->menuAction(), rightImageMenu_); rightShowHide_ = rightImageMenu_->addAction(tr("Show right image")); rightShowHide_->setCheckable(true); rightDelete_ = rightImageMenu_->addAction(tr("Delete right image")); rightImageMenu_->addSeparator(); setConnections(); }
MyMainWindow::MyMainWindow() : KMainWindow(0) { text = new QLabel(i18n("<h1>Hello, World!</h1>"), this); setCentralWidget(text); QPopupMenu *filePopup = new QPopupMenu(this); KAction *quitAction = KStdAction::quit(this, SLOT(fileQuit()), actionCollection()); clearAction = new KAction(i18n("&Clear"), "stop", Qt::CTRL + Qt::Key_X, this, SLOT(fileClear()), actionCollection(), "file_clear"); clearAction->plug(filePopup); clearAction->plug(toolBar()); quitAction->plug(filePopup); quitAction->plug(toolBar()); menuBar()->insertItem(i18n("&File"), filePopup); menuBar()->insertSeparator(); menuBar()->insertItem(i18n("&Help"), helpMenu()); statusBar()->insertItem("Line xxx", 1); statusBar()->insertItem("Column xxx", 2); statusBar()->insertItem("Zoom: 100%", 3); //statusBar()->message("Ready..."); falls Statuszeile nur aus einem Feld besteht //statusBar()->message("Ready...", 2000); zeige Nachricht fuer 2000 Millisekunden }
MyMainWindow::MyMainWindow() : KMainWindow(0) { text = new QLabel(i18n("<h1>Hello, World!</h1>"), this); setCentralWidget(text); QPopupMenu *filePopup = new QPopupMenu(this); KAction *quitAction = KStdAction::quit(this, SLOT(fileQuit()), actionCollection()); clearAction = new KAction(i18n("&Clear"), "stop", Qt::CTRL + Qt::Key_X, this, SLOT(fileClear()), actionCollection(), "file_clear"); KToggleAction *toolbarAction = new KToggleAction(i18n("Show &Toolbar"), 0, actionCollection(), "settings_show_toolbar"); toolbarAction->setChecked(true); connect(toolbarAction, SIGNAL(toggled(bool)), this, SLOT(toggleToolBar(bool))); QPopupMenu *settingsMenu = new QPopupMenu(); toolbarAction->plug(settingsMenu); clearAction->plug(filePopup); clearAction->plug(toolBar()); quitAction->plug(filePopup); quitAction->plug(toolBar()); menuBar()->insertItem(i18n("&File"), filePopup); menuBar()->insertSeparator(); menuBar()->insertItem("&Settings", settingsMenu); menuBar()->insertSeparator(); menuBar()->insertItem(i18n("&Help"), helpMenu()); }
void patternWindow::constructMenus() { imageMenu()->addAction(switchAction_); imageMenu()->addAction(zoomInAction()); imageMenu()->addAction(zoomOutAction()); imageMenu()->addAction(originalSizeAction()); imageMenu()->addAction(gridAction_); imageMenu()->addAction(gridColorAction_); imageMenu()->addAction(imageInfoAction()); helpMenu()->addAction(setPdfViewerAction_); imageListMenu_ = new QMenu(tr("I&mages"), this); menuBar()->insertMenu(helpMenu()->menuAction(), imageListMenu_); connect(imageListMenu_, SIGNAL(triggered(QAction* )), this, SLOT(processImageListMenu(QAction* ))); imageListMenu_->addAction(deleteImageAction_); imageListMenu_->addSeparator(); }
KUI_project::KUI_project(QWidget* parent): KMainWindow(parent) { model = 0; trayIcon = new KSystemTrayIcon("media-playback-stop", 0 ); connect(trayIcon, SIGNAL( activated(QSystemTrayIcon::ActivationReason)), this, SLOT( unhideSlot() ) ); path.append( QDir::homePath() ); recArea.setCoords( 0, 0, 0, 0); setupConfig(); this->resize( 700, 300 ); collection = new KActionCollection(this); setupCentralWidget(); menuBar = new KMenuBar; setupMenuFile(); setupMenuWindow(); setupMenuSettings(); menuBar->addMenu(helpMenu()); this->setMenuBar(menuBar); setupActions(); KToolBar *tools = new KToolBar(i18n("&Tools"), this); tools->addAction(collection->action("new_file")); tools->addAction(collection->action("open_file")); tools->addAction(collection->action("add")); collection->action("add")->setEnabled( false ); tools->addAction(collection->action("remove")); collection->action("remove")->setEnabled( false ); //tools->addAction(collection->action("save_file")); tools->setToolButtonStyle(Qt::ToolButtonIconOnly); playBar = new MainToolBar( collection, this); playBar->setAccessibleDescription("Play Bar"); this->addToolBar(Qt::BottomToolBarArea, playBar); connect( playBar->timeSlider, SIGNAL( sliderMoved(int) ), this, SLOT( seekSlot(int) ) ); }
void Browse::menuSelected( const MIMenuID & id ) //---------------------------------------------- { switch( id.mainID() ) { case MMFile: fileMenu( id.subID() ); break; case MMHelp: helpMenu( id.subID() ); break; default: NODEFAULT; } }
void KSlovar::addMenu() { KPopupMenu * filemenu = new KPopupMenu; m_newDictionary->plug(filemenu); m_openDictionary->plug(filemenu); filemenu->insertSeparator(); m_print->plug(filemenu); filemenu->insertSeparator(); m_close->plug(filemenu); m_quit->plug(filemenu); KPopupMenu *editmenu=new KPopupMenu; m_editDictionary->plug(editmenu); m_selectAll->plug(editmenu); editmenu->insertSeparator(); m_addPhrase->plug(editmenu); m_editPhrase->plug(editmenu); m_removePhrase->plug(editmenu); editmenu->insertSeparator(); m_find->plug(editmenu); m_findNext->plug(editmenu); m_literalSearch->plug(editmenu); m_backSearch->plug(editmenu); KPopupMenu *gomenu=new KPopupMenu; m_back->plug(gomenu); m_forward->plug(gomenu); m_home->plug(gomenu); KPopupMenu *setmenu=new KPopupMenu; m_config->plug(setmenu); m_conversion->plug(setmenu); m_update->plug(setmenu); m_wizard->plug(setmenu); KPopupMenu *help = helpMenu(); KMenuBar * menu = menuBar(); menu->insertItem( i18n( "&File" ), filemenu ); menu->insertItem(i18n("&Edit"), editmenu); menu->insertItem(i18n("&Go"), gomenu); menu->insertItem(i18n("&Settings"), setmenu); menu->insertItem( i18n( "&Help" ), help ); }
void RoyalSocietyApp::setup() { mySurface_ = new Surface(appWidth, appHeight, false); help_ = true; helpMenu(); my_List_ = new List; // Creates sentinel_ node my_List_->sentinel_ = new Node; my_List_->sentinel_->next_ = my_List_->sentinel_; my_List_->sentinel_->prev_ = my_List_->sentinel_; // Inserts new nodes Node* lastNode; Rect* r; r = new Rect(100, 100, 50, 50, Color8u(255, 0, 0)); lastNode = my_List_->insertAfter(my_List_->sentinel_, r); r = new Rect(100, 100, 50, 50, Color8u(0, 255, 0)); lastNode = my_List_->insertAfter(lastNode, r); r = new Rect(100, 100, 50, 50, Color8u(0, 0, 255)); lastNode = my_List_->insertAfter(lastNode, r); }
MMain::MMain() { _filemenu = new QPopupMenu; _filemenu->insertItem(i18n("&Start Session"),this,SLOT(startSession())); _filemenu->insertItem(i18n("&Connect to Session"),this,SLOT(connectSession())); _filemenu->insertSeparator(); _filemenu->insertItem(i18n("C&ontrol Center"),this,SLOT(controlCenter())); _filemenu->insertSeparator(); _filemenu->insertItem(i18n("&Exit"),this,SIGNAL(exit())); _optmenu = new QPopupMenu; _optmenu->insertItem(i18n("Options ...."),yni); _helpmenu = helpMenu(this); QMenuBar*menubar=menuBar(); menubar->insertItem(i18n("&Session"),_filemenu); menubar->insertItem(i18n("&Options"),_optmenu); menubar->insertSeparator(); menubar->insertItem(i18n("&Help"),_helpmenu); menubar->show(); QStatusBar*statusbar=statusBar(); statusbar->message("Yet no session loaded"); QVBox*vb=new QVBox(this); vb->setMinimumSize(400,50); vb->setFrameStyle(QFrame::Panel|QFrame::Sunken); vb->setMargin(2); ((QBoxLayout*)vb->layout())->setDirection(QBoxLayout::TopToBottom); setCentralWidget(vb); mDebug("GUI: starting automatic session\n"); startSession(); }
/** * Opens Umbrello handbook. Is called when help button is pressed. */ void ClassWizard::showHelp() { KHelpMenu helpMenu(this); helpMenu.appHelpActivated(); }
void MainWindow::CreateMenuBar() { //------------------------------------------------------------------ // File menu _fileMenu = menuBar()->addMenu(tr("&Quest")); // Open item _fileMenu->addAction(QIcon(":/menu/open"), tr("Open game..."), this, SLOT(OnOpenGame()), QKeySequence(Qt::ALT + Qt::Key_O)); // New game item _fileMenu->addAction(QIcon(":/menu/new"),tr("Restart game"), this, SLOT(OnRestartGame()), QKeySequence(Qt::ALT + Qt::Key_N)); _fileMenu->addSeparator(); // Exit item _fileMenu->addAction(QIcon(":/menu/exit"), tr("Exit"), this, SLOT(close()), QKeySequence(Qt::ALT + Qt::Key_X)); //------------------------------------------------------------------ // Game menu _gameMenu = menuBar()->addMenu(tr("&Game")); // Open saved game item _gameMenu->addAction(QIcon(":/menu/statusopen"), tr("Open saved game..."), this, SLOT(OnOpenSavedGame()), QKeySequence(Qt::CTRL + Qt::Key_O)); // Save game item _gameMenu->addAction(QIcon(":/menu/statussave"), tr("Save game..."), this, SLOT(OnSaveGame()), QKeySequence(Qt::CTRL + Qt::Key_S)); //------------------------------------------------------------------ // Settings menu _settingsMenu = menuBar()->addMenu(tr("&Settings")); // Show / Hide submenu _showHideMenu = _settingsMenu->addMenu(tr("Show / Hide")); // Objects item QAction* action = _objectsWidget->toggleViewAction(); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1)); _showHideMenu->addAction(action); // Actions item action = _actionsWidget->toggleViewAction(); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_2)); _showHideMenu->addAction(action); // Additional desc item action = _descWidget->toggleViewAction(); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_3)); _showHideMenu->addAction(action); // Input area item action = _inputWidget->toggleViewAction(); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_4)); _showHideMenu->addAction(action); _showHideMenu->addSeparator(); // Captions item _showHideMenu->addAction(tr("Captions"), this, SLOT(OnToggleCaptions()), QKeySequence(Qt::CTRL + Qt::Key_5)); // Hotkeys for actions item _showHideMenu->addAction(tr("Hotkeys for actions"), this, SLOT(OnToggleHotkeys()), QKeySequence(Qt::CTRL + Qt::Key_6)); // Sound volume item _settingsMenu->addAction(tr("Sound volume..."), this, SLOT(OnChangeSoundVolume()), QKeySequence(Qt::ALT + Qt::Key_V)); // Window / Fullscreen mode item _settingsMenu->addAction(QIcon(":/menu/windowmode"), tr("Window / Fullscreen mode"), this, SLOT(OnToggleWinMode()), QKeySequence(Qt::ALT + Qt::Key_Enter)); _settingsMenu->addSeparator(); // Options item _settingsMenu->addAction(tr("Options..."), this, SLOT(OnOptions()), QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_O)); //------------------------------------------------------------------ // Help menu QMenu* helpMenu(menuBar()->addMenu(tr("&Help"))); // About item helpMenu->addAction(QIcon(":/menu/about"), tr("About..."), this, SLOT(OnAbout()), QKeySequence(Qt::CTRL + Qt::Key_H)); }
void Kpacman::menu() { gamePopup = new QPopupMenu(); CHECK_PTR( gamePopup ); newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); pauseID = gamePopup->insertItem(tr("&Pause"), this, SLOT(pauseKpacman()), Key_F3); hofID = gamePopup->insertItem(tr("&Hall of fame"), this, SLOT(toggleHallOfFame()), Key_F4); gamePopup->insertSeparator(); gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); gamePopup->setCheckable(TRUE); optionsPopup = new QPopupMenu(); CHECK_PTR(optionsPopup); modesPopup = new QPopupMenu(); CHECK_PTR(modesPopup); hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), this, SLOT(toggleHideMouseCursor()), CTRL+Key_H); optionsPopup->insertSeparator(); if (lookupSchemes() > 0) { optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); optionsPopup->insertSeparator(); } focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), this, SLOT(toggleFocusOutPause())); focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), this, SLOT(toggleFocusInContinue())); optionsPopup->insertSeparator(); optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys())); #ifndef QPE_PORT QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n" "Joerg Thoennissen ([email protected])\n\n" "A pacman game for the KDE Desktop\n\n" "The program based on the source of ksnake\n" "by Michel Filippi ([email protected]).\n" "The design was strongly influenced by the pacman\n" "(c) 1980 MIDWAY MFG.CO.\n\n" "I like to thank my girlfriend Elke Krueers for\n" "the last 10 years of her friendship.\n"); aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE); aboutText.replace(QRegExp("@VERSION@"), VERSION); QPopupMenu *helpPopup = helpMenu(aboutText, FALSE); #endif //_menuBar = new KMenuBar(this); //CHECK_PTR( _menuBar ); //_menuBar->insertItem(tr("&Game"), gamePopup); //_menuBar->insertItem(tr("&Options"), optionsPopup); //_menuBar->insertSeparator(); #ifndef QPE_PORT _menuBar->insertItem(tr("&Help"), helpPopup); #endif }
int main(int args, char *argv[]) { int isOnline = 1; struct hostent* he; struct sockaddr_in server; int sock_fd; int playerAnswer; int quesReceived = 0; int choice, i; int help_choice[HELP_CHOICES]; int clientId = UNDEFINED; char clientName[40]; char c; Question ques; StatusType clientStatus; MainPlayerData toPlayerData; CandidateData toCandidateData; createCashPrizeList(); if (args != 3) { printf("Usage : %s <IP> <PORT>\n", argv[0]); exit(-1); } if ((he = gethostbyname(argv[1])) == NULL ) { printf("Cannot get the server !\n"); exit(-1); } server.sin_family = AF_INET; server.sin_port = htons(atoi(argv[2])); server.sin_addr = *((struct in_addr*) he->h_addr); bzero(&(server.sin_zero), 8); // create a socket to server if ((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { printf("Cannot create a socket !\n"); exit(-1); } if (connect(sock_fd, (struct sockaddr*) &server, sizeof(struct sockaddr)) == -1) { printf("error connect"); exit(1); } recv(sock_fd, &clientId, sizeof clientId, 0); if (clientId == NULL_ID) { printf(CLIENT_FULL_MESSAGE); close(sock_fd); exit(-1); } //printf("Get the id : %d\n", clientId); printf("=====WELCOME TO THE WHO WANT TO BE A MILLIONAIRE\n"); printf("Enter your name : "); //get the user name gets(clientName); toCandidateData.status = CONNECTED; //send the data to server to let server know you name send(sock_fd, &toCandidateData, sizeof toCandidateData, 0); send(sock_fd, clientName, sizeof clientName, 0); // get the data back then display message for the first time join to game (this time a welcome message) recv(sock_fd, &toCandidateData, sizeof toCandidateData, 0); displayCandidateMessage(toCandidateData); clientStatus = toCandidateData.status; // print the client's status // printf("The client %d has status : ", clientId); // toString(clientStatus); //playerAnswer = RIGHT; /*handle data sent from server according to client role */ while (isOnline) { switch (clientStatus) { case WAITING: recv(sock_fd, &toCandidateData, sizeof toCandidateData, 0); clientStatus = toCandidateData.status; if (clientStatus == WAITING) { displayCandidateMessage(toCandidateData); } copyQuestion(&ques, toCandidateData.question); break; case COMPETING: //displayCandidateMessage(toCandidateData); //displayQuestion(ques); compete(&toCandidateData, ques); printf("Waiting for result....!\n"); sleep(1); //fflush(stdout); //endwin(); // send answer to server // send(sock_fd, &toCandidateData, sizeof toCandidateData, 0); //receive the result and change the status of client according to result recv(sock_fd, &toCandidateData, sizeof toCandidateData, 0); displayAnswer(ques); sleep(1); displayCandidateMessage(toCandidateData); clientStatus = toCandidateData.status; // printf("The client %d has status : ", clientId); // toString(clientStatus); //fflush(stdout); // return 0; // exit(0); break; case JOINING: ques = toPlayerData.ques; recv(sock_fd, &toPlayerData, sizeof toPlayerData, 0); if (quesReceived == 1) { displayAnswer(ques); } sleep(1); if (toPlayerData.status == FINISHED) { displayPlayerMessage(toPlayerData); exit(1); } broadTheGame(toPlayerData); quesReceived = 1; break; case PLAYING: //fflush(stdout); for (i = 0; i < HELP_CHOICES; i++) { help_choice[i] = AVAILABLE; } do { while (getchar() != '\n') ; recv(sock_fd, &toPlayerData, sizeof toPlayerData, 0); if (toPlayerData.status == FINISHED) { displayPlayerMessage(toPlayerData); exit(1); } sleep(1); displayPlayerMessage(toPlayerData); sleep(1); broadTheGame(toPlayerData); printf( "\n>>Your choice (press 'H' to get help or 'L' to leave the game): "); c = getchar(); choice = handleAnswer(c); //if the player has his own answer while (1) { if (choice != HELP_MODE) {//neu nguoi choi ko chon tro giup playerAnswer = checkAnswer(choice, toPlayerData.ques.ans); send(sock_fd, &playerAnswer, sizeof playerAnswer, 0); break; } //else if he needs help else { //xu ly tro giup helpMenu(&toPlayerData, help_choice); printf( "\n>>Your choice (press 'H' to get help or 'L' to leave the game): "); while (getchar() != '\n') ; c = getchar(); choice = handleAnswer(c); } } } while (playerAnswer == RIGHT); if (playerAnswer == WRONG || playerAnswer == END) { recv(sock_fd, &toPlayerData, sizeof toPlayerData, 0); sleep(1); displayAnswer(toPlayerData.ques); displayPlayerMessage(toPlayerData); isOnline = 0; clientStatus = FINISHED; close(sock_fd); exit(-1); } //fflush(stdout); break; default: printf("We will handle soon ...\n"); break; } //fflush(stdout); } return 0; }
// 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); }
void iDraw() { int m,n; iClear(); iSetcolor(1,1,1); iFilledRectangle(1,1,width-19,height-18); //draw text box iSetcolor(0,0,0); iRectangle(1,1,width-19,height-19); //draw text boundary if (selflag) { for (int l=selSI; l<=selEI; l++) { int sx = (l==selSI)?( (selSJ==0)?3:selSJ*charSpace) : 3; int sy = height - 17 - (l+1-s)*lineSpace - 5; int w; if (l==selSI) w = (selSI == selEI) ? selEJ-selSJ : strlen(str+l*charMax*sizeof(char))-selSJ; else if (l==selEI) w = selEJ; else w = (strlen(str+l*charMax*sizeof(char))==0)?1:strlen(str+l*charMax*sizeof(char)); iSetcolor(.8,.8,.9); iFilledRectangle(sx,sy,w*charSpace,lineSpace); } } iSetcolor(0,0,0); for (m=height-17-lineSpace, n=s; n<=imax; m-=lineSpace, n++) { iText(3, m, str+n*charMax*sizeof(char),font); //print text } if (fOpen) { fileopen(); iSetcolor(0,0,0); iText((width-15)/2-135,(height-19)/2+62,subTemp+r); //print file open text } else if (fsave) { filesave(); iSetcolor(0,0,0); iText((width-15)/2-135,(height-19)/2+62,subTemp+r); //print file save as text } else if (aboutR) { aboutRword(); } cursor(); //draw cursor iSetcolor(.9,.9,.9); iFilledRectangle(3,height-17,width-19,17); iSetcolor(0,0,0); iLine(2,height-18,width-19,height-18); iSetcolor(0,0,0); iText(5,height-12,"File",GLUT_BITMAP_HELVETICA_12); iSetcolor(0,0,0); iText(45,height-12,"Edit",GLUT_BITMAP_HELVETICA_12); iSetcolor(0,0,0); iText(85,height-12,"Format",GLUT_BITMAP_HELVETICA_12); iSetcolor(0,0,0); iText(141,height-12,"Help",GLUT_BITMAP_HELVETICA_12); //draw menus if (menuflag == 1) { fileMenu(); //draw file drop down menu } else if (menuflag == 2) { editMenu(); //draw edit drop down menu } else if (menuflag == 3) { formatMenu(); //draw format drop down menu } else if (menuflag == 4) { helpMenu(); //draw help drop down menu } if (fontflag) { fontlist(); //draw font list } else if (saveM) { saveMessage(); //message box while exitting } scrollbar(); // draw scrollbar if (load) loading(); //load window }
/* * Draws & initializes all the widgets of the main window */ void MainWindow::initWidgets() { setPlainCaption("QtKam"); /* Construct Actions */ saveAction = KStdAction::save(this, SLOT(saveSelected()),this); quitAction = KStdAction::quit(this, SLOT(close()),this); deleteAction = new KAction(i18n("Delete"), "edittrash", Key_Delete, this, SLOT(deleteSelected()), this); downloadThumbsAction = new KAction(i18n("Download Thumbs"), "queue", CTRL + Key_T, this, SLOT(downloadThumbs()), this); selectAllAction = new KAction(i18n("Select &All"), SHIFT + Key_A, this, SLOT(selectAll()), this); invertSelectionAction = new KAction(i18n("&Invert Selection"), SHIFT + Key_I, this, SLOT(selectInverse()), this); clearSelectionAction = new KAction(i18n("&Clear Selection"), SHIFT + Key_N, this, SLOT(selectNone()), this); selectCameraAction = new KAction(i18n("Select &Camera"), CTRL + Key_C, this, SLOT(selectCamera()), this); initCameraAction = new KAction(i18n("Reset Camera"), "connect_creating", CTRL + Key_R, this, SLOT(initCamera()), this); configureCameraAction = new KAction(i18n("&Configure"), 0, this, SLOT(configureCamera()), this); cameraInformationAction = new KAction(i18n("&Information"), 0, this, SLOT(cameraInformation()), this); cameraManualAction = new KAction(i18n("&Manual"), 0, this, SLOT(cameraManual()), this); cameraAboutAction = new KAction(i18n("&About the driver"), 0, this, SLOT(cameraAbout()), this); /* Initialize actions */ saveAction->setEnabled(false); deleteAction->setEnabled(false); /* Create & initialize icon view */ iconView = new KIconView(this); iconView->setMode(KIconView::Select); iconView->setSelectionMode(KIconView::Multi); iconView->setItemsMovable(false); iconView->setResizeMode(KIconView::Adjust); connect(iconView,SIGNAL(selectionChanged()), this,SLOT(selectionChanged())); setCentralWidget(iconView); /* Create file menu */ fileMenu = new KPopupMenu(); saveAction->plug(fileMenu); deleteAction->plug(fileMenu); fileMenu->insertSeparator(); quitAction->plug(fileMenu); /* Create edit menu */ editMenu = new KPopupMenu(); selectAllAction->plug(editMenu); invertSelectionAction->plug(editMenu); clearSelectionAction->plug(editMenu); /* Create command menu */ commandMenu = new KPopupMenu(); initCameraAction->plug(commandMenu); downloadThumbsAction->plug(commandMenu); /* Camera menu */ cameraMenu = new KPopupMenu(); selectCameraAction->plug(cameraMenu); cameraMenu->insertSeparator(); configureCameraAction->plug(cameraMenu); cameraInformationAction->plug(cameraMenu); cameraManualAction->plug(cameraMenu); cameraAboutAction->plug(cameraMenu); /* Help menu */ help = helpMenu(); /* Menu Bar */ menuBar()->insertItem(i18n("&File"), fileMenu); menuBar()->insertItem(i18n("&Edit"), editMenu); menuBar()->insertItem(i18n("&Command"),commandMenu); menuBar()->insertItem(i18n("C&amera"),cameraMenu); menuBar()->insertItem(i18n("&Help"), help); /* Create toolbar */ downloadThumbsAction->plug(toolBar()); saveAction->plug(toolBar()); deleteAction->plug(toolBar()); }
int main() { char replIn; int isLoaded = 0; int size = 0; char **questions; char **answers; /* REPL OPTIONS c: create s: start x: clear screen h: help q: quit NOTE: I'd like to add some more features later, I doubt file input and output would be too crazy. */ printf("welcome to my quiz program!\n"); printf("This program was made by WPV for CISP300!\n"); helpMenu(); replIn = getchar(); //printf("\n"); while( replIn != 'q' ) { //create quiz if (replIn == 'c') { printf("Enter your question and answer pool size: \n"); scanf("%d", &size); //the number of elements questions = malloc(size * sizeof(char*)); answers = malloc(size * sizeof(char*)); initQs(questions, size); initAs(answers, size); isLoaded = 1; } //print help if (replIn == 'h') { helpMenu(); } //take quiz or error if ( (replIn == 's') && (isLoaded == 0) ) { printf("Error! No quiz has been created. \n"); } else if ( (replIn == 's') && (isLoaded == 1) ) { printf("Beginning test.. \n"); beginTest(questions, answers, size); } //screen clearing hack (maybe cross platform???) if (replIn == 'x') { clearScreen(); } printf(">"); replIn = getchar(); } //be sure to free at the end.. //I might be doing this wrong but memory leaks wont kill me //plus valgrind says im good and I don't segfault this way for(int i = 0; i < (size - 1); i++) { free(answers[i]); } for(int i = 0; i < (size - 1); i++) { free(questions[i]); } return 0; }