コード例 #1
0
void CWizEditorToolBar::buildMenu()
{
    if (!m_menuContext) {
        m_menuContext = new QMenu(this);
    }

    m_menuContext->clear();

    int index = 0;
    WizEditorContextMenuItem* arrayData = contextMenuData();
    MainWindow* mainWindow = qobject_cast<MainWindow *>(m_app.mainWindow());
    while (1) {
        WizEditorContextMenuItem& item = arrayData[index];
        if (item.label.isEmpty() && item.command.isEmpty() && item.execute.isEmpty()) {
            break;

        } else if (item.label == "-") {
            m_menuContext->addSeparator();

        } else if (item.execute == "+") {
            index = buildMenu(m_menuContext, index);

        } else if (item.command != "+" && !item.execute.isEmpty()) {
            if (!item.command.isEmpty()) {
                int value = mainWindow->web()->editorCommandQueryCommandState(item.command);
                if (value == -1) {
                    index++;
                    continue;
                }
            }

            QString strSlot = "1" + item.execute + "()";
            m_menuContext->addAction(item.label, mainWindow->web(), strSlot.toUtf8());
        } else if (item.command.isEmpty() && item.execute.isEmpty()) {
            index++;
            continue;
        } else {
            Q_ASSERT(0);
        }

        index++;
    }
}
コード例 #2
0
ファイル: ModulesHandle.cpp プロジェクト: pixlra/playuver
Void ModulesHandle::loadExternalModule()
{
    Bool bUpdate = false;
    QString supported = tr( "Supported Files (*.so)" );
    QStringList formatsList;
    formatsList << "Shared Libraries (*.so)";
    QStringList filter;
    filter << supported
           << formatsList
           << tr( "All Files (*)" );
    QStringList fileNames = QFileDialog::getOpenFileNames( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );

    for( Int i = 0; i < fileNames.size(); i++ )
    {
        bUpdate |= PlaYUVerModuleFactory::Get()->RegisterDl( fileNames.at( i ).toStdString().data() );
    }
    if( bUpdate )
        buildMenu();
}
コード例 #3
0
ファイル: menu.cpp プロジェクト: AReim1982/scummvm
void Menu::refreshMenus() {
	if (_objectBarStatus == MENU_OPEN) {
		buildMenu();
		for (uint8 cnt = 0; cnt < 16; cnt++) {
			if (_objects[cnt])
				_objects[cnt]->draw();
			else
				_screen->showFrame(cnt * 40, 0, 0xffffffff, 0);
		}
	}
	if (_subjectBarStatus == MENU_OPEN) {
		buildSubjects();
		for (uint8 cnt = 0; cnt < 16; cnt++) {
			if (_subjects[cnt])
				_subjects[cnt]->draw();
			else
				_screen->showFrame(cnt * 40, 440, 0xffffffff, 0);
		}
	}
}
コード例 #4
0
ファイル: MenuMainState.cpp プロジェクト: fallahn/xygine
MenuMainState::MenuMainState(xy::StateStack& stack, Context context)
    : State         (stack, context),
    m_messageBus    (context.appInstance.getMessageBus()),
    m_uiContainer   (m_messageBus)
{
    launchLoadingScreen();
    
    buildMenu();
    buildSettings();

    auto msg = m_messageBus.post<xy::Message::UIEvent>(xy::Message::UIMessage);
    msg->type = xy::Message::UIEvent::MenuOpened;
    msg->value = 0.f;
    msg->stateID = States::ID::MenuMain;

    xy::App::setMouseCursorVisible(true);
    getContext().renderWindow.setTitle("xy tools");

    quitLoadingScreen();
}
コード例 #5
0
void CWizActions::buildMenu(QMenu* menu, const QString& strFileName)
{
    CWizSettings settings(strFileName);

    int index = 0;
    while (true)
    {
        QString strKey = WizIntToStr(index);
        QString strAction = settings.GetString("MainMenu", strKey);

        if (strAction.isEmpty())
            break;

        if (strAction.startsWith("-"))
        {
            continue;
        }
        else if (strAction.startsWith("+"))
        {
            strAction.remove(0, 1);
            QString strLocalText = QObject::tr(strAction.toUtf8());
            QMenu* pMenu = menu->addMenu(strLocalText);

            buildMenu(pMenu, settings, strAction);
        }
        else
        {
            menu->addAction(actionFromName(strAction));
        }

        index++;
    }

    QAction * actionQuit = actionFromName("actionExit");
    QAction* actionOptions = actionFromName("actionPreference");

    menu->addSeparator();
    menu->addAction(actionOptions);
    menu->addSeparator();
    menu->addAction(actionQuit);
}
コード例 #6
0
ファイル: main.c プロジェクト: cioltanandrei/Metal-Idol
int main(int argc, char* argv[]) {
  SDL_Event e; // Un eveniment care s-a intamplat. Folosit pentru a detecta inchiderea programului
  char quit;
  Mix_Music *backgroundMusic;
  int option;

  if(!init()) { // Daca nu s-a petrecut nici o eroare la initializare
    quit = 0;
    hideCursor(); // Cursorul dispare
    //system("color 37"); // Seteaza culoarea de fundal
    fillBackgroundCollor(BG_CYAN + WHITE);
    if(!DEBUG) {
      putStr((getConsoleWidth() - 13) / 2, getConsoleHeight() / 2, "Se incarca...");
      Sleep(2500);
      putStr((getConsoleWidth() - 10) / 2, getConsoleHeight() / 2 + 1, "Degeaba...");
      Sleep(500);
    }
    clearScreen();
    backgroundMusic = Mix_LoadMUS(BACKGROUND_MUSIC_PATH);
    if(backgroundMusic == NULL)
      error("Nu s-a putut accesa fisierul cu melodia de fundal.");
    else
      Mix_PlayMusic(backgroundMusic, -1);
    option = buildMenu();
    if(option == 2)
      quit = 1;
    while(!quit) {
      while(SDL_PollEvent(&e) != 0) {
        if(e.type == SDL_QUIT)
          quit = 1;
      }
      if(getKey(VK_ESCAPE))
        quit = 1;
      Sleep(SLEEPCONST);
    }
    freeData();
  }
  return 0;
}
コード例 #7
0
ファイル: UI.cpp プロジェクト: critterandguitari/Organelle_UI
void UI::runSystemCommand(void){
    char cmd[256];
    if (!strcmp(menuItems[selectedEntry], "Reload")){
        printf("Reloading... \n");
        sprintf(cmd, "/root/scripts/mount.sh");
        system(cmd);
        buildMenu();
        drawPatchList();
    }
 
    else if (!strcmp(menuItems[selectedEntry], "Shutdown")){
        printf("Shutting down... \n");
        sprintf(cmd, "/root/scripts/shutdown.sh &");
        system(cmd);
    }
    
    else if (!strcmp(menuItems[selectedEntry], "Info")){
        printf("Displaying system info... \n");
        auxScreen.clear();
        auxScreen.drawNotification("     System Info     ");
        sprintf(cmd, "/root/scripts/info.sh &");
        system(cmd);

    }
     
    else if (!strcmp(menuItems[selectedEntry], "Eject")){
        printf("Ejecting USB drive... \n");
        sprintf(cmd, "/root/scripts/eject.sh &");
        system(cmd);
    }
     
    else if (!strcmp(menuItems[selectedEntry], "Save Preset")){
        printf("Saving Prest... \n");
        sprintf(cmd, "/root/scripts/savepre.sh \"%s\" &", currentPatch);
        system(cmd);
        printf("%s \n", cmd);
    }

}
コード例 #8
0
ファイル: razormainmenu.cpp プロジェクト: Wubbbi/razor-qt
void RazorMainMenu::showMenu()
{
    if (mXdgMenu.isOutDated())
        buildMenu();

    if (!mMenu)
        return;

    int x, y;

    switch (panel()->position())
    {
        case RazorPanel::PositionTop:
            x = mButton.mapToGlobal(QPoint(0, 0)).x();
            y = panel()->mapToGlobal(QPoint(0, panel()->sizeHint().height())).y();
            break;

        case RazorPanel::PositionBottom:
            x = mButton.mapToGlobal(QPoint(0, 0)).x();
            y = panel()->mapToGlobal(QPoint(0, 0)).y() - mMenu->sizeHint().height();
            break;

        case RazorPanel::PositionLeft:
            x = panel()->mapToGlobal(QPoint(panel()->sizeHint().width(), 0)).x();
            y = mButton.mapToGlobal(QPoint(0, 0)).y();
            break;

        case RazorPanel::PositionRight:
            x = panel()->mapToGlobal(QPoint(0, 0)).x() - mMenu->sizeHint().width();
            y = mButton.mapToGlobal(QPoint(0, 0)).y();
            break;

    }

    QPoint pos(x, y);
    mMenu->exec(pos);
}
コード例 #9
0
ファイル: kdatepickerpopup.cpp プロジェクト: KDE/knemo
void KDatePickerPopup::setItems( int items )
{
  mItems = items;
  buildMenu();
}
コード例 #10
0
ファイル: calendardemo.cpp プロジェクト: tmcguire/qt-mobility
QTM_USE_NAMESPACE

CalendarDemo::CalendarDemo(QWidget *parent)
    :QMainWindow(parent),
    m_stackedWidget(0),
    m_monthPage(0),
    m_dayPage(0),
    m_eventEditPage(0),
    m_eventOccurrenceEditPage(0)
{
    m_stackedWidget = new QStackedWidget(this);

    m_dayPage = new DayPage(m_stackedWidget);
    m_monthPage = new MonthPage(m_stackedWidget);
    m_eventEditPage = new EventEditPage(m_stackedWidget);
    m_todoEditPage = new TodoEditPage(m_stackedWidget);
    m_journalEditPage = new JournalEditPage(m_stackedWidget);
    m_eventOccurrenceEditPage = new EventOccurrenceEditPage(m_stackedWidget);
    m_addCalendarPage = new AddCalendarPage(m_stackedWidget);
    m_editCalendarsPage = new EditCalendarsPage(m_stackedWidget);

    //qRegisterMetaType<QOrganizerManager>("QOrganizerManager");
    qRegisterMetaType<QOrganizerItem>("QOrganizerItem");
    qRegisterMetaType<QOrganizerItemId>("QOrganizerItemId");
    qRegisterMetaType<QOrganizerCollection>("QOrganizerCollection");
    qRegisterMetaType<QOrganizerAbstractRequest::State>("QOrganizerAbstractRequest::State");

    connect(m_monthPage, SIGNAL(showDayPage(QDate)), this, SLOT(activateDayPage()), Qt::QueuedConnection);
    connect(m_monthPage, SIGNAL(showEditPage(const QOrganizerItem &)), this, SLOT(activateEditPage(const QOrganizerItem &)), Qt::QueuedConnection);
    connect(m_monthPage, SIGNAL(addNewEvent()), this, SLOT(addNewEvent()), Qt::QueuedConnection);
    connect(m_monthPage, SIGNAL(addNewTodo()), this, SLOT(addNewTodo()), Qt::QueuedConnection);
    connect(m_monthPage, SIGNAL(managerChanged(QOrganizerManager*)), this, SLOT(changeManager(QOrganizerManager*)), Qt::QueuedConnection);
    connect(m_monthPage, SIGNAL(managerChanged(QOrganizerManager*)), m_dayPage, SLOT(changeManager(QOrganizerManager*)), Qt::QueuedConnection);
    connect(m_monthPage, SIGNAL(currentDayChanged(QDate)), this, SLOT(updateSelectedDay(QDate)));
    connect(m_dayPage, SIGNAL(showMonthPage()), this, SLOT(activateMonthPage()), Qt::QueuedConnection);
    connect(m_dayPage, SIGNAL(showEditPage(const QOrganizerItem &)), this, SLOT(activateEditPage(const QOrganizerItem &)), Qt::QueuedConnection);
    connect(m_dayPage, SIGNAL(addNewEvent()), this, SLOT(addNewEvent()), Qt::QueuedConnection);
    connect(m_dayPage, SIGNAL(addNewTodo()), this, SLOT(addNewTodo()), Qt::QueuedConnection);
    connect(m_eventEditPage, SIGNAL(showDayPage()), this, SLOT(activateDayPage()), Qt::QueuedConnection);
    connect(m_todoEditPage, SIGNAL(showDayPage()), this, SLOT(activateDayPage()), Qt::QueuedConnection);
    connect(m_journalEditPage, SIGNAL(showDayPage()), this, SLOT(activateDayPage()), Qt::QueuedConnection);
    connect(m_eventOccurrenceEditPage, SIGNAL(showDayPage()), this, SLOT(activateDayPage()), Qt::QueuedConnection);
    connect(m_addCalendarPage, SIGNAL(showPreviousPage()), this, SLOT(activatePreviousPage()), Qt::QueuedConnection);
    connect(m_editCalendarsPage, SIGNAL(showAddCalendarPage(QOrganizerManager*,QOrganizerCollection*)), this, SLOT(editExistingCalendar(QOrganizerManager*,QOrganizerCollection*)), Qt::QueuedConnection);
    connect(m_editCalendarsPage, SIGNAL(showPreviousPage()), this, SLOT(activateMonthPage()), Qt::QueuedConnection);
    connect(m_editCalendarsPage, SIGNAL(addClicked()), this, SLOT(addCalendar()), Qt::QueuedConnection);

    // Connect to the save and remove request status change signals
    connect(&m_saveReq, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)),
            this, SLOT(saveReqStateChanged(QOrganizerAbstractRequest::State)));
    connect(&m_remReq, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)),
            this, SLOT(removeReqStateChanged(QOrganizerAbstractRequest::State)));

    m_monthPage->init();
    
    m_stackedWidget->addWidget(m_monthPage);
    m_stackedWidget->addWidget(m_dayPage);
    m_stackedWidget->addWidget(m_eventEditPage);
    m_stackedWidget->addWidget(m_todoEditPage);
    m_stackedWidget->addWidget(m_journalEditPage);
    m_stackedWidget->addWidget(m_eventOccurrenceEditPage);
    m_stackedWidget->addWidget(m_addCalendarPage);
    m_stackedWidget->addWidget(m_editCalendarsPage);
    m_stackedWidget->setCurrentIndex(0);

    setCentralWidget(m_stackedWidget);
    buildMenu();

    activateMonthPage();
}
コード例 #11
0
ファイル: krbookmarkhandler.cpp プロジェクト: aremai/krusader
void KrBookmarkHandler::buildMenu(KrBookmark *parent, QMenu *menu)
{
    static int inSecondaryMenu = 0; // used to know if we're on the top menu

    // run the loop twice, in order to put the folders on top. stupid but easy :-)
    // note: this code drops the separators put there by the user
    QListIterator<KrBookmark *> it(parent->children());
    while (it.hasNext()) {
        KrBookmark *bm = it.next();

        if (!bm->isFolder()) continue;
        QMenu *newMenu = new QMenu(menu);
        newMenu->setIcon(QIcon(krLoader->loadIcon(bm->iconName(), KIconLoader::Small)));
        newMenu->setTitle(bm->text());
        QAction *menuAction = menu->addMenu(newMenu);
        QVariant v;
        v.setValue<KrBookmark *>(bm);
        menuAction->setData(v);

        ++inSecondaryMenu;
        buildMenu(bm, newMenu);
        --inSecondaryMenu;
    }

    it.toFront();
    while (it.hasNext()) {
        KrBookmark *bm = it.next();
        if (bm->isFolder()) continue;
        if (bm->isSeparator()) {
            menu->addSeparator();
            continue;
        }
        menu->addAction(bm);
        CONNECT_BM(bm);
    }

    if (!inSecondaryMenu) {
        KConfigGroup group(krConfig, "Private");
        bool hasPopularURLs = group.readEntry("BM Popular URLs", true);
        bool hasTrash       = group.readEntry("BM Trash",        true);
        bool hasLan         = group.readEntry("BM Lan",          true);
        bool hasVirtualFS   = group.readEntry("BM Virtual FS",   true);
        bool hasJumpback    = group.readEntry("BM Jumpback",     true);

        if (hasPopularURLs) {
            menu->addSeparator();

            // add the popular links submenu
            QMenu *newMenu = new QMenu(menu);
            newMenu->setTitle(i18n("Popular URLs"));
            newMenu->setIcon(QIcon(krLoader->loadIcon("folder-bookmark", KIconLoader::Small)));
            QAction *bmfAct  = menu->addMenu(newMenu);
            _specialBookmarks.append(bmfAct);
            // add the top 15 urls
#define MAX 15
            QList<QUrl> list = _mainWindow->popularUrls()->getMostPopularUrls(MAX);
            QList<QUrl>::Iterator it;
            for (it = list.begin(); it != list.end(); ++it) {
                QString name;
                if ((*it).isLocalFile()) name = (*it).path();
                else name = (*it).toDisplayString();
                // note: these bookmark are put into the private collection
                // as to not spam the general collection
                KrBookmark *bm = KrBookmark::getExistingBookmark(name, _privateCollection);
                if (!bm)
                    bm = new KrBookmark(name, *it, _privateCollection);
                newMenu->addAction(bm);
                CONNECT_BM(bm);
            }

            newMenu->addSeparator();
            newMenu->addAction(krPopularUrls);
            newMenu->installEventFilter(this);
        }

        // do we need to add special bookmarks?
        if (SPECIAL_BOOKMARKS) {
            if (hasTrash || hasLan || hasVirtualFS || hasJumpback)
                menu->addSeparator();

            KrBookmark *bm;

            // note: special bookmarks are not kept inside the _bookmarks list and added ad-hoc
            if (hasTrash) {
                bm = KrBookmark::trash(_collection);
                menu->addAction(bm);
                _specialBookmarks.append(bm);
                CONNECT_BM(bm);
            }

            if (hasLan) {
                bm = KrBookmark::lan(_collection);
                menu->addAction(bm);
                _specialBookmarks.append(bm);
                CONNECT_BM(bm);
            }

            if (hasVirtualFS) {
                bm = KrBookmark::virt(_collection);
                menu->addAction(bm);
                _specialBookmarks.append(bm);
                CONNECT_BM(bm);
            }

            if (hasJumpback) {
                // add the jump-back button
                ListPanelActions *actions = _mainWindow->listPanelActions();
                menu->addAction(actions->actJumpBack);
                _specialBookmarks.append(actions->actJumpBack);
                menu->addSeparator();
                menu->addAction(actions->actSetJumpBack);
                _specialBookmarks.append(actions->actSetJumpBack);
            }
        }

        if (!hasJumpback)
            menu->addSeparator();

        menu->addAction(KrActions::actAddBookmark);
        _specialBookmarks.append(KrActions::actAddBookmark);
        QAction *bmAct = menu->addAction(krLoader->loadIcon("bookmarks", KIconLoader::Small),
                                         i18n("Manage Bookmarks"), manager, SLOT(slotEditBookmarks()));
        _specialBookmarks.append(bmAct);

        // make sure the menu is connected to us
        disconnect(menu, SIGNAL(triggered(QAction *)), 0, 0);
    }
コード例 #12
0
ファイル: proRataGraphPane.cpp プロジェクト: chongle/prorata
ProRataGraphPane::ProRataGraphPane( QWidget * qwParent )
		: QWidget( qwParent )
{

	/*
	pripProteinPane = new ProRataImagePane;

	priLikehoodImage = new ProRataImage( "../images/Radis1.jpeg" );
	priLikehoodImage->setTitle( "Likehood Curve" );

	priCoverageImage = new ProRataImage( "../images/Radis2.jpeg" );
	priCoverageImage->setTitle( "Sequence Coverage" );

	pripProteinPane->addImage( priLikehoodImage );
	pripProteinPane->addImage( priCoverageImage );

	pripPeptidePane = new ProRataImagePane;

	priChromatogram = new ProRataImage( "../images/Radis3.jpeg" );
	priChromatogram->setTitle( "Chromatogram" );

	priPCA = new ProRataImage( "../images/Radis4.jpeg" );
	priPCA->setTitle( "Prinicipal Component Analysis" );

	pripPeptidePane->addImage( priChromatogram );
	pripPeptidePane->addImage( priPCA );

	qsPaneDivider = new QSplitter;
	qsPaneDivider->setOrientation( Qt::Vertical );
	
	qsPaneDivider->addWidget( pripProteinPane );
	qsPaneDivider->addWidget( pripPeptidePane );

	qvbMainLayout = new QVBoxLayout;
	qvbMainLayout->addWidget( qsPaneDivider );
	*/

	buildMenu();

	qvbMainLayout = new QVBoxLayout;

	qtwGraphTab = new QTabWidget;
//	connect( qtwGraphTab, SIGNAL( currentChanged( int ) ),
//		this, SLOT( currentSelected(int) ) );
	qvbMainLayout->addWidget( qtwGraphTab );

	qszDialogSize.setWidth( 600 );
	qszDialogSize.setHeight( 600 );

	qpDialogPosition.setX( 0 );
	qpDialogPosition.setY( 0 );

//	qiSeen = QIcon( QPixmap( nonUpdated_xpm ) );
//	qiUpdated = QIcon( QPixmap( updated_xpm ) );

	/*
	qszDialogSize = new QSize( 600, 600 );
	qpDialogPosition = new QPoint( 0, 0 );
	*/

	setLayout( qvbMainLayout );
}
コード例 #13
0
void MSAEditorConsensusArea::sl_buildContextMenu(GObjectView * /*view*/, QMenu *menu) {
    buildMenu(menu);
}
コード例 #14
0
void SlotMachine::spin(int bet, Player &player) //spin reels, calculate win, adjust balance accordingly
{
	system("CLS");

	bool win = false;
	
	int winnings = 0;

	static int row[3][3] = { 1, 1, 1, 2, 2, 2, 3, 3, 3 };

	string symbols[10] = {
		"Horseshoe   ", "Diamond    ", "Spade     ", "Heart     ", "Bell      ",
		"Cherry     ", "Coin      ", "Star      ", "Clover     ", "Bar      " };

	// deduct bet amount from player balance
	player.debitPlayer(bet);

	line();
	line("SLOT MACHINE");
	line();

	// Generate wheel positions for next spin
	for (int k = 0; k < 3; k++)
	{
		row[0][k] = NumberGenerator.generate();
		row[1][k] = ((row[0][k] + 1) % 10);
		row[2][k] = ((row[0][k] + 2) % 10);
		NumberGenerator.generate();
		NumberGenerator.generate();
	}


	// display wheels
	for (int r = 0; r < 3; r++)
	{
		for (int i = 0; i < 3; i++)
		{
			cout << "| ";
			cout << setw(14) << symbols[row[r][i]];
		}
		cout << " |";
		cout << endl;
	}
	line();
	spacerLine();


	// detect win

	// check 3 like symbols in center row
	if ((row[1][0] == row[1][1]) && (row[1][0] == row[1][2]))
	{
		line("WINNER    -  3 IN A ROW  -    WINNER");
		win = true;
		player.creditPlayer(bet * 300);
		winnings = 300;
	}

	// check if 2 like symbols in center row
	
	else if ((row[1][0] == row[1][1]) || (row[1][0] == row[1][2]) || (row[1][1] == row[1][2])) 
	{
		line("WINNER    -  2 IN A ROW  -    WINNER");
		win = true;
		player.creditPlayer(bet * 30);
		winnings = 30;
	}
	
	else
	{

		// count frequency of symbols
		int frequency[10] = { 0 };

		for (int num = 0; num < 10; num++)
		{
			for (int x = 0; x < 3; x++)
			{
				for (int y = 0; y < 3; y++)
				{
					if (row[x][y] == num)
					{
						frequency[num]++;
					}
				}
			}
		}


		// check for 3 matching symbols on the screen
		for (int count = 0; count < 10; count++)
		{
			if (frequency[count] == 3)
			{
				line("WINNER   - 3 SYMBOL MATCH -   WINNER");
				win = true;
				player.creditPlayer(bet * 5);
				winnings = 5;
				break;
			}
		}


		// check for 2 matching symbols on the screen
		if (!win)
		{
			for (int count = 0; count < 10; count++)
			{
				if (frequency[count] == 2)
				{
					line("WINNER   - 2 SYMBOL MATCH -   WINNER");
					win = true;
					player.creditPlayer(bet * 2);
					winnings = 2;
					break;
				}
			}
		}
	}

	if (!win)
	{
		line("YOU  LOSE!");
	}

	spacerLine();
	buildMenu(player.getBalance(), bet, winnings*bet);

}
コード例 #15
0
ファイル: wbdlg.cpp プロジェクト: Masterblaster0815/psi
WbDlg::WbDlg(SxeSession* session, PsiAccount* pa) {
	groupChat_ = session->groupChat();
	pending_ = 0;
	keepOpen_ = false;
	allowEdits_ = true;

	selfDestruct_ = 0;
	setAttribute(Qt::WA_DeleteOnClose, false); // we want deferred endSession call and delete from manager

	setWindowTitle(CAP(tr("Whiteboard (%1)").arg(pa->jid().bare())));
	QVBoxLayout *vb1 = new QVBoxLayout(this);

	// first row
	le_jid_ = new QLineEdit(this);
	le_jid_->setReadOnly(true);
	le_jid_->setFocusPolicy(Qt::NoFocus);
	le_jid_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
	lb_ident_ = new AccountLabel(this);
	lb_ident_->setAccount(pa);
	lb_ident_->setShowJid(false);
	lb_ident_->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
	QHBoxLayout *hb1 = new QHBoxLayout();
	hb1->addWidget(le_jid_);
	hb1->addWidget(lb_ident_);
	vb1->addLayout(hb1);

	// mid area
	wbWidget_ = new WbWidget(session, this);
	wbWidget_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
	vb1->addWidget(wbWidget_);

	// Bottom (tool) area
	act_save_ = new IconAction(tr("Save session"), "psi/saveBoard", tr("Save the contents of the whiteboard"), 0, this );
	act_geometry_ = new IconAction(tr("Change the geometry"), "psi/whiteboard", tr("Change the geometry"), 0, this );
	act_clear_ = new IconAction(tr("End session"), "psi/clearChat", tr("Clear the whiteboard"), 0, this );
	act_end_ = new IconAction(tr("End session"), "psi/closetab", tr("End session"), 0, this );

	// Black is the default color
	QPixmap pixmap(16, 16);
	pixmap.fill(QColor(Qt::black));
	act_color_ = new QAction(QIcon(pixmap), tr("Stroke color"), this);
	pixmap.fill(QColor(Qt::lightGray));
	act_fill_ = new IconAction(tr("Fill color"), "psi/select", tr("Fill color"),0, this, 0, true);
	act_fill_->setIcon(QIcon(pixmap));
	act_fill_->setChecked(false);

	act_widths_ = new IconAction(tr("Stroke width" ), "psi/drawPaths", tr("Stroke width"), 0, this );
	act_modes_ = new IconAction(tr("Edit mode" ), "psi/select", tr("Edit mode"), 0, this );
	group_widths_ = new QActionGroup(this);
	group_modes_ = new QActionGroup(this);

	connect(act_color_, SIGNAL(triggered()), SLOT(setStrokeColor()));
	connect(act_fill_, SIGNAL(triggered(bool)), SLOT(setFillColor(bool)));
	connect(group_widths_, SIGNAL(triggered(QAction *)), SLOT(setStrokeWidth(QAction *)));
	connect(group_modes_, SIGNAL(triggered(QAction *)), SLOT(setMode(QAction *)));
	connect(act_save_, SIGNAL(triggered()), SLOT(save()));
	connect(act_geometry_, SIGNAL(triggered()), SLOT(setGeometry()));
	connect(act_clear_, SIGNAL(triggered()), wbWidget_, SLOT(clear()));
	connect(act_end_, SIGNAL(triggered()), SLOT(endSession()));

	pixmap = QPixmap(2, 2);
	pixmap.fill(QColor(Qt::black));
	QAction* widthaction = new QAction(QIcon(pixmap), tr("Thin stroke"), group_widths_);
	widthaction->setData(QVariant(1));
	widthaction->setCheckable(true);
	widthaction->trigger();
	pixmap = QPixmap(6, 6);
	pixmap.fill(QColor(Qt::black));
	widthaction = new QAction(QIcon(pixmap), tr("Medium stroke"), group_widths_);
	widthaction->setData(QVariant(3));
	widthaction->setCheckable(true);
	pixmap = QPixmap(12, 12);
	pixmap.fill(QColor(Qt::black));
	widthaction = new QAction(QIcon(pixmap), tr("Thick stroke"), group_widths_);
	widthaction->setData(QVariant(6));
	widthaction->setCheckable(true);

	IconAction* action;
	action = new IconAction(tr("Select"), "psi/select", tr("Select"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Select));
	action->setCheckable(true);
	action = new IconAction(tr( "Translate"), "psi/translate", tr("Translate"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Translate));
	action->setCheckable(true);
	action = new IconAction(tr( "Rotate"), "psi/rotate", tr("Rotate"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Rotate));
	action->setCheckable(true);
	action = new IconAction(tr( "Scale"), "psi/scale", tr("Scale"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Scale));
	action->setCheckable(true);
	action = new IconAction(tr( "Erase"), "psi/erase", tr("Erase"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Erase));
	action->setCheckable(true);
	QAction *separator = new QAction(group_modes_);
	separator->setSeparator(true);
	action = new IconAction(tr( "Scroll view"), "psi/scroll", tr("Scroll"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::Scroll));
	action->setCheckable(true);
	separator = new QAction(group_modes_);
	separator->setSeparator(true);
	action = new IconAction(tr( "Draw paths"), "psi/drawPaths", tr("Draw paths"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::DrawPath));
	action->setCheckable(true);
	action->trigger();
	// action = new IconAction(tr( "Draw lines"), "psi/drawLines", tr("Draw lines"), 0, group_modes_ );
	// action->setData(QVariant(WbWidget::DrawLine));
	// action->setCheckable(true);
	// action = new IconAction(tr( "Draw ellipses"), "psi/drawEllipses", tr("Draw ellipses"), 0, group_modes_ );
	// action->setData(QVariant(WbWidget::DrawEllipse));
	// action->setCheckable(true);
	// action = new IconAction(tr( "Draw circles"), "psi/drawCircles", tr("Draw circles"), 0, group_modes_ );
	// action->setData(QVariant(WbWidget::DrawCircle));
	// action->setCheckable(true);
	// action = new IconAction(tr( "Draw rectangles"), "psi/drawRectangles", tr("Draw rectangles"), 0, group_modes_ );
	// action->setData(QVariant(WbWidget::DrawRectangle));
	// action->setCheckable(true);
	// 	action = new IconAction(tr( "Add text"), "psi/addText", tr("Add text"), 0, group_modes_ );
	// 	action->setData(QVariant(WbWidget::DrawText));
	// 	action->setCheckable(true);
	action = new IconAction(tr( "Add images"), "psi/addImage", tr("Add images"), 0, group_modes_ );
	action->setData(QVariant(WbWidget::DrawImage));
	action->setCheckable(true);

	menu_widths_ = new QMenu(this);
	menu_widths_->addActions(group_widths_->actions());
	act_widths_->setMenu(menu_widths_);

	menu_modes_ = new QMenu(this);
	menu_modes_->addActions(group_modes_->actions());
	act_modes_->setMenu(menu_modes_);

	toolbar_ = new QToolBar(tr("Whiteboard toolbar"), this);
	toolbar_->setIconSize(QSize(16,16));
	toolbar_->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
	toolbar_->addAction(act_end_);
	toolbar_->addAction(act_clear_);
	toolbar_->addAction(act_save_);
	toolbar_->addAction(act_geometry_);
	toolbar_->addWidget(new StretchWidget(this));
	toolbar_->addAction(act_fill_);
	toolbar_->addAction(act_color_);
	QToolButton *bw = new QToolButton;
	bw->setIcon(IconsetFactory::icon("psi/drawPaths").icon());
	bw->setMenu(menu_widths_);
	bw->setPopupMode(QToolButton::InstantPopup);
	toolbar_->addWidget(bw);
	QToolButton *bm = new QToolButton;
	bm->setIcon(IconsetFactory::icon("psi/select").icon());
	bm->setMenu(menu_modes_);
	bm->setPopupMode(QToolButton::InstantPopup);
	toolbar_->addWidget(bm);
	vb1->addWidget(toolbar_);

	// Context menu
	pm_settings_ = new QMenu(this);
	connect(pm_settings_, SIGNAL(aboutToShow()), SLOT(buildMenu()));

	X11WM_CLASS("whiteboard");

	// set the Jid -> le_jid.
	le_jid_->setText(QString("%1 (session: %2)").arg(session->target().full()).arg(session->session()));
	le_jid_->setCursorPosition(0);
	le_jid_->setToolTip(session->target().full());

	// update the widget icon
#ifndef Q_OS_MAC
	setWindowIcon(IconsetFactory::icon("psi/whiteboard").icon());
#endif
	
	setWindowOpacity(double(qMax(MINIMUM_OPACITY, PsiOptions::instance()->getOption("options.ui.chat.opacity").toInt())) / 100);

	setGeometryOptionPath(geometryOption);
}
コード例 #16
0
void CWizEditorToolBar::resetContextMenuAndPop(const QPoint& pos)
{
    buildMenu();
    m_menuContext->popup(pos);
}
コード例 #17
0
ファイル: ModulesHandle.cpp プロジェクト: pixlra/playuver
QMenu* ModulesHandle::createMenu()
{
    m_pcModulesMenu = new QMenu( "&Modules", this );
    buildMenu();
    return m_pcModulesMenu;
}
コード例 #18
0
ファイル: backscene.cpp プロジェクト: ideallx/Hexagon
void BackScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
    HeroItem* hi = ic->getHeroByPoint(oldPoint);
    if (hi != NULL) {
        emit buildMenu(hi, this->views()[0]->mapFromScene(event->scenePos()));
    }
}
コード例 #19
0
ファイル: MainWindow.cpp プロジェクト: duyanning/shutters
MainWindow::MainWindow()
{
	setText(L"MDI Demo");
	buildMenu();
	setMdiMenu(mainMenuBar, 0);
}
コード例 #20
0
ファイル: desktopscene.cpp プロジェクト: kenfallon/razor-qt
DesktopScene::DesktopScene(QObject * parent)
    : QGraphicsScene(parent),
      m_wheelDesktopSwitch(false),
      m_menu(0),
      m_activePlugin(0)
{
    m_power = new PowerManager(this);
    m_screenSaver = new ScreenSaver(this);

    DesktopConfig::instance()->config->beginGroup("razor");
    QStringList plugins =  DesktopConfig::instance()->config->value("plugins").toStringList();
    m_menuFile = DesktopConfig::instance()->config->value("menu_file", "").toString();
    m_wheelDesktopSwitch = DesktopConfig::instance()->config->value("mouse_wheel_desktop_switch", false).toBool();
    DesktopConfig::instance()->config->endGroup();
    if (m_menuFile.isEmpty())
        m_menuFile = XdgMenu::getMenuFileName();

    m_xdgMenu.setEnvironments(QStringList() << "X-RAZOR" << "Razor");
    bool res = m_xdgMenu.read(m_menuFile);
    connect(&m_xdgMenu, SIGNAL(changed()), this, SLOT(buildMenu()));

    if (res)
    {
        QTimer::singleShot(1000, this, SLOT(buildMenu()));
    }
    else
    {
        QMessageBox::warning(0, "Menu Parse error", m_xdgMenu.errorString());
        return;
    }

    m_actArrangeWidgets = new QAction(tr("Unlock Desktop..."), this);
    m_actArrangeWidgets->setIcon(XdgIcon::fromTheme("object-locked"));
    m_actArrangeWidgets->setCheckable(true);
    connect(m_actArrangeWidgets, SIGNAL(toggled(bool)),
            this, SLOT(arrangeWidgets(bool)));

    m_actAddNewPlugin = new QAction(tr("Add New Desktop Widget..."), this);
    connect(m_actAddNewPlugin, SIGNAL(triggered()),
            this, SLOT(showAddPluginDialog()));

    m_actRemovePlugin = new QAction(tr("Remove Plugin..."), this);
    connect(m_actRemovePlugin, SIGNAL(triggered()),
            this, SLOT(removePlugin()));

    m_actConfigurePlugin = new QAction(tr("Configure Plugin..."), this);
    connect(m_actConfigurePlugin, SIGNAL(triggered()),
            this, SLOT(configurePlugin()));

    m_actSetbackground = new QAction(tr("Set Desktop Background..."), this);
    m_actSetbackground->setIcon(XdgIcon::fromTheme("preferences-desktop-wallpaper"));
    connect(m_actSetbackground, SIGNAL(triggered()),
            this, SLOT(setDesktopBackground()));

    m_actAbout = new QAction(tr("About Razor..."), this);
    m_actAbout->setIcon(XdgIcon::fromTheme("help-browser"));
    connect(m_actAbout, SIGNAL(triggered()), this, SLOT(about()));

    // load plugins
    QStringList desktopDirs = pluginDesktopDirs();
    foreach (QString configId, plugins)
    {
        DesktopConfig::instance()->config->beginGroup(configId);
        QString libName(DesktopConfig::instance()->config->value("plugin", "").toString());

        qreal x = DesktopConfig::instance()->config->value("x", 10.0).toReal();
        qreal y = DesktopConfig::instance()->config->value("y", 10.0).toReal();
        qreal w = DesktopConfig::instance()->config->value("w", 10.0).toReal();
        qreal h = DesktopConfig::instance()->config->value("h", 10.0).toReal();
        QPointF position(x, y);
        QSizeF size(w, h);
        DesktopConfig::instance()->config->endGroup();

        RazorPluginInfoList list = RazorPluginInfo::search(desktopDirs, "RazorDesktop/Plugin", QString("%1.desktop").arg(libName));
        if( !list.count())
        {
            qWarning() << QString("Plugin \"%1\" not found.").arg(libName);
            continue;
        }
        QLibrary* lib = loadPluginLib(list.first());
        if (!lib)
        {
            qWarning() << "RazorWorkSpace::setConfig() Library" << libName << "is not loaded";
            continue;
        }

        DesktopWidgetPlugin * item = m_plugins[configId];
        if (!item)
        {
            item = loadPlugin(lib, configId);
            m_plugins.insert(configId, item);
        }

        item->setSizeAndPosition(position, size);
    }
コード例 #21
0
ファイル: main.c プロジェクト: hanzhaogang/chromium-1
static void 
crutInitServer(char *mothership, int argc, char *argv[])
{
    char response[8096];
#ifndef WINDOWS
    int drawable;
#endif
    int displayMode;

    crNetInit( NULL/*crutServerRecv*/, crutServerClose );

    crutInitAPI( &crut_api, mothership ); /* here? */

    crMothershipIdentifyCRUTServer( crut_api.mothershipConn, response );

    crutGetWindowParams( &crut_api );
    
    /* set up GLUT window */
    glutInit(&argc, argv);

    displayMode = GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA;
    if (crut_api.compositeAlpha)
       displayMode |= GLUT_ALPHA;
    if (crut_api.compositeDepth)
       displayMode |= GLUT_STENCIL;
    glutInitDisplayMode(displayMode);

    glutInitWindowPosition( crut_api.winX,crut_api.winY );
    glutInitWindowSize( crut_api.winWidth,crut_api.winHeight );
    
    glutCreateWindow("CRUTServer Interactive Window"); 
    
    glutDisplayFunc(showWin);
    
    /* give window id to mothership */
#ifndef WINDOWS
#ifdef DARWIN
    /* XXX \todo crut get current drawable (this only gets glut win_num) */
    drawable = glutGetWindow();
#else
    /* XXX is this cast safe? */
    drawable = (int) glXGetCurrentDrawable();
#endif
    crutSetWindowID( &crut_api, drawable);
#endif

    /* use API to connect to clients */
    crutConnectToClients( &crut_api );

    /* Retrieve events to send out */
    crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_mouse", response );
    crut_server.callbacks.mouse = crStrToInt(response);

    crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_keyboard", response );
    crut_server.callbacks.keyboard = crStrToInt(response);

    crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_motion", response );
    crut_server.callbacks.motion = crStrToInt(response);

    crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_passivemotion", response );
    crut_server.callbacks.passivemotion = crStrToInt(response);

    crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_reshape", response );
    crut_server.callbacks.reshape = crStrToInt(response);

    crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_visibility", response );
    crut_server.callbacks.visibility = crStrToInt(response);

    crMothershipGetParam( crut_api.mothershipConn, "crut_callbacks_menu", response );
    crut_server.callbacks.menu = crStrToInt(response);

    /* Exit flag */
    crMothershipGetCRUTServerParam( crut_api.mothershipConn, response, "exit_on_escape");
    crut_server.exit_on_escape = crStrToInt(response);

#ifdef USE_CRUT_MENUS
    crutGetMenuXML();

    buildMenu();
#endif
 
}