예제 #1
0
파일: vis.cpp 프로젝트: greevex/bassplayer
void Vis::createActions(){
    for(int i = 0; i < this->libs->length(); i++){
        QAction *action = new QAction(this->libsinfo->value(i)->name, this);
        action->setData(i);
        action->setIcon(QIcon(":/res/icons/plugin.png"));
        connect(action, SIGNAL(triggered()), this, SLOT(changeVis()));
        this->actions->append(action);
    }
    QAction *about = new QAction("About", this);
    about->setIcon(QIcon(":/res/icons/information.png"));
    connect(about, SIGNAL(triggered()), this, SLOT(about()));
    this->actions->append(about);
    QAction *fs = new QAction("Toggle Fullscreen", this);
    fs->setIcon(QIcon(":/res/icons/fullscreen.png"));
    connect(fs, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
    this->actions->append(fs);
}
예제 #2
0
int QDeclarativeViewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: setDesignModeBehavior((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: sceneResized((*reinterpret_cast< QSize(*)>(_a[1]))); break;
        case 2: { bool _r = open((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 3: openFile(); break;
        case 4: openUrl(); break;
        case 5: reload(); break;
        case 6: takeSnapShot(); break;
        case 7: toggleRecording(); break;
        case 8: toggleRecordingWithSelection(); break;
        case 9: ffmpegFinished((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 10: showProxySettings(); break;
        case 11: proxySettingsChanged(); break;
        case 12: rotateOrientation(); break;
        case 13: statusChanged(); break;
        case 14: pauseAnimations(); break;
        case 15: stepAnimations(); break;
        case 16: setAnimationStep(); break;
        case 17: changeAnimationSpeed(); break;
        case 18: launch((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 19: appAboutToQuit(); break;
        case 20: autoStartRecording(); break;
        case 21: autoStopRecording(); break;
        case 22: recordFrame(); break;
        case 23: chooseRecordingOptions(); break;
        case 24: pickRecordingFile(); break;
        case 25: toggleFullScreen(); break;
        case 26: changeOrientation((*reinterpret_cast< QAction*(*)>(_a[1]))); break;
        case 27: orientationChanged(); break;
        case 28: animationSpeedChanged((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 29: showWarnings((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 30: warningsWidgetOpened(); break;
        case 31: warningsWidgetClosed(); break;
        default: ;
        }
        _id -= 32;
    }
    return _id;
}
예제 #3
0
	void ThymioVPLStandalone::setupWidgets()
	{
		// VPL part
		updateWindowTitle(false);
		vplLayout = new QVBoxLayout;
		#ifdef Q_WS_MACX
		vplLayout->setContentsMargins(0,0,0,0);
		#endif // Q_WS_MACX
		QWidget* vplContainer = new QWidget;
		vplContainer->setLayout(vplLayout);
		
		addWidget(vplContainer);
		
		// editor part
		editor = new AeslEditor;
		editor->setReadOnly(true);
		#ifdef ANDROID
		editor->setTextInteractionFlags(Qt::NoTextInteraction);
		editor->setStyleSheet(
			"QTextEdit { font-size: 10pt; font-family: \"Courrier\" }"
		);
		editor->setTabStopWidth(QFontMetrics(editor->font()).width(' '));
		#endif // ANDROID
		new AeslHighlighter(editor, editor->document());
		
		/*QVBoxLayout* layout = new QVBoxLayout;
		layout->addWidget(editor, 1);
		const QString text = tr("Aseba ver. %0 (build %1/protocol %2); Dashel ver. %3").
			arg(ASEBA_VERSION).
			arg(ASEBA_BUILD_VERSION).
			arg(ASEBA_PROTOCOL_VERSION).
			arg(DASHEL_VERSION);
		QLabel* label(new QLabel(text));
		label->setWordWrap(true);
		label->setStyleSheet("QLabel { font-size: 8pt; }");
		layout->addWidget(label);
		QWidget* textWidget = new QWidget;
		textWidget->setLayout(layout);*/
		
		addWidget(editor);
		
		// shortcut
		QShortcut * shwHide = new QShortcut(QKeySequence("Ctrl+f"), this);
		connect(shwHide, SIGNAL(activated()), SLOT(toggleFullScreen()));
	}
예제 #4
0
void GLWidget::keyPressEvent(QKeyEvent *event)
{
    if (event->key() == Qt::Key_Control) ctrl = true;
    if (event->key() == Qt::Key_Alt) alt = true;
    char cmd = event->key();
    if (fullScreen) {
        if (event->key()==Qt::Key_F2) emit toggleFullScreen(false);
    }
    const dReal S = 0.30;
    const dReal BallForce = 0.2;
    int R = robotIndex(Current_robot,Current_team);
    switch (cmd) {
    case 't': case 'T': ssl->robots[R]->incSpeed(0,-S);ssl->robots[R]->incSpeed(1,S);ssl->robots[R]->incSpeed(2,-S);ssl->robots[R]->incSpeed(3,S);break;
    case 'g': case 'G': ssl->robots[R]->incSpeed(0,S);ssl->robots[R]->incSpeed(1,-S);ssl->robots[R]->incSpeed(2,S);ssl->robots[R]->incSpeed(3,-S);break;
    case 'f': case 'F': ssl->robots[R]->incSpeed(0,S);ssl->robots[R]->incSpeed(1,S);ssl->robots[R]->incSpeed(2,S);ssl->robots[R]->incSpeed(3,S);break;
    case 'h': case 'H': ssl->robots[R]->incSpeed(0,-S);ssl->robots[R]->incSpeed(1,-S);ssl->robots[R]->incSpeed(2,-S);ssl->robots[R]->incSpeed(3,-S);break;
    case 'w': case 'W':dBodyAddForce(ssl->ball->body,0, BallForce,0);break;
    case 's': case 'S':dBodyAddForce(ssl->ball->body,0,-BallForce,0);break;
    case 'd': case 'D':dBodyAddForce(ssl->ball->body, BallForce,0,0);break;
    case 'a': case 'A':dBodyAddForce(ssl->ball->body,-BallForce,0,0);break;
    case 'k':case 'K': ssl->robots[R]->kicker->kick(4,0);break;
    case 'l':case 'L': ssl->robots[R]->kicker->kick(2,2);break;
    case 'j':case 'J': ssl->robots[R]->kicker->toggleRoller();break;
    case 'i':case 'I': dBodySetLinearVel(ssl->ball->body,2.0,0,0);dBodySetAngularVel(ssl->ball->body,0,2.0/cfg->v_BallRadius->getValue(),0);break;
    case ';':
        if (kickingball==false)
        {
            kickingball = true; logStatus(QString("Kick mode On"),QColor("blue"));
        }
        else
        {
            kickingball = false; logStatus(QString("Kick mode Off"),QColor("red"));
        }
        break;
    case ']': kickpower += 0.1; logStatus(QString("Kick power = %1").arg(kickpower),QColor("orange"));break;
    case '[': kickpower -= 0.1; logStatus(QString("Kick power = %1").arg(kickpower),QColor("cyan"));break;
    case ' ':
        ssl->robots[R]->resetSpeeds();
        break;
    case '`':
        dBodySetLinearVel(ssl->ball->body,0,0,0);
        dBodySetAngularVel(ssl->ball->body,0,0,0);
        break;
    }
}
예제 #5
0
void WindowsManager::keyboardAll(unsigned char key)
{
	switch(key)
	{
	case('F'):
	case('f'):	toggleFullScreen();
				break;
	case('G'):
	case('g'):	toggleSubWindow();
				break;
	case(' '):	m_dt.reset();
				break;
	case(27):	//glutDestroyWindow(m_window2);//Escape			
				//glutDestroyWindow(m_window1);
				//exit(0);
				break;
	}
}
예제 #6
0
파일: testApp.cpp 프로젝트: MrMdR/julapy
void testApp :: keyReleased( int key )
{
	if( key == 's' )
	{
		char str[255];
		sprintf( str, "tf_%02d%02d%02d_%02d%02d%02d.png", ofGetYear() % 1000, ofGetMonth(), ofGetDay(), ofGetHours(), ofGetMinutes(), ofGetSeconds() );
		
		tileSaver.finish( str, false );
	}
	
	if( key == 'm' )
	{
		if( screenGrabUtil.isRecording() )
		{
			screenGrabUtil.stop();
			
			audio->setFrameRateSync( false );
		}
		else
		{
			screenGrabUtil.start();
			
			audio->setFrameRateSync( true );
		}
	}
	
	if( key == 'd' )
	{
		showDebug = !showDebug;
		
		for( int i=0; i<fieldsTotal * 2; i++ )
		{
			colorPickers[ i ].setVisible( showDebug );
		}
		
		gui.toggleDraw();
	}
	
	if( key == 'f' )
		toggleFullScreen();
	
	if( key == 't' )
		trigger.writeToFile( "trigger_data.txt" );
}
예제 #7
0
파일: kard.cpp 프로젝트: KDE/kard
void Kard::setupActions()
{
    KStandardAction::quit(this, SLOT(slotQuit()), actionCollection());
            
    KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
    
    m_pFullScreen = KStandardAction::fullScreen( 0, 0, this, actionCollection());
    actionCollection()->addAction("full_screen", m_pFullScreen );
    connect( m_pFullScreen, SIGNAL( toggled( bool )), this, SLOT( slotUpdateFullScreen( bool )));

    m_soundAction = new KToggleAction(i18n("Soun&ds"), actionCollection());
    actionCollection()->addAction("sound", m_soundAction );
    connect(m_soundAction , SIGNAL(triggered()), this, SLOT(slotToggleSound()));

    //adding choice of number of cards action
    m_numAction = new KSelectAction(i18n("View"), actionCollection());
    actionCollection()->addAction("num", m_numAction );
    connect(m_numAction , SIGNAL(triggered(int)), this, SLOT(setNumber(int)));
    QStringList nums;
    nums+=i18np("%1 Card", "%1 Cards", 4);
    nums+=i18np("%1 Card", "%1 Cards", 8);
    nums+=i18np("%1 Card", "%1 Cards", 12);
    nums+=i18np("%1 Card", "%1 Cards", 16);
    nums+=i18np("%1 Card", "%1 Cards", 20);
    nums+=i18np("%1 Card", "%1 Cards", 24);
    m_numAction->setItems(nums);
    m_numAction->setToolTip( i18n( "Choose the number of cards" ) );
    m_numAction->setWhatsThis(  i18n( "Choose the level of difficulty by setting the number of cards from 4 (very easy) to 24 (more difficult)" ) );    

    //adding theme action
    m_themeAction = new KSelectAction(i18n("Themes"), actionCollection());
    actionCollection()->addAction("themes", m_themeAction );
    connect(m_themeAction , SIGNAL(triggered(int)), this, SLOT(slotSetTheme(int )));
    m_themeAction->setItems(KardThemeFactory::instance()->themeUiList());
    m_themeAction->setToolTip( i18n( "Choose the theme for the cards" ) );
    m_themeAction->setWhatsThis(  i18n( "You can choose here the theme for the backs of the cards" ) );
    KStandardAction::fullScreen(this, SLOT(toggleFullScreen()), this, actionCollection());
    setupGUI();
}
예제 #8
0
파일: testApp.cpp 프로젝트: MrMdR/julapy
void testApp :: keyReleased( int key )
{
	if( key == 's' )
	{
		char str[255];
		sprintf( str, "ribbons_%02d%02d%02d_%02d%02d%02d.png", ofGetYear() % 1000, ofGetMonth(), ofGetDay(), ofGetHours(), ofGetMinutes(), ofGetSeconds() );
		
		tileSaver.finish( str, false );
	}
	
	if( key == 'm' )
	{
		if( screenGrabUtil.isRecording() )
		{
			screenGrabUtil.stop();
		}
		else
		{
			screenGrabUtil.start();
		}
	}
	
	if( key == 'd' )
		debugMode = !debugMode;
	
	if( key == 'f' )
		toggleFullScreen();
	
	if( key == '-' )
		incDir = -1;
	
	if( key == '=' )
		incDir = 1;
	
	if( key == 't' )
	{
		ribbonAudio.setThreshold( ribbonAudio.getThreshold() + 0.05 * incDir );
	}
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: update(); break;
        case 1: updateRobotLabel(); break;
        case 2: showHideConfig((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 3: showHideSimulator((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: changeCurrentRobot(); break;
        case 5: changeCurrentTeam(); break;
        case 6: changeBallMass(); break;
        case 7: changeBallGroundSurface(); break;
        case 8: changeBallDamping(); break;
        case 9: changeGravity(); break;
        case 10: changeTimer(); break;
        case 11: restartSimulator(); break;
        case 12: ballMenuTriggered((*reinterpret_cast< QAction*(*)>(_a[1]))); break;
        case 13: toggleFullScreen((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 14: setCurrentRobotPosition(); break;
        case 15: takeSnapshot(); break;
        case 16: takeSnapshotToClipboard(); break;
        case 17: customFPS((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 18: showAbout(); break;
        case 19: reconnectCommandSocket(); break;
        case 20: reconnectYellowStatusSocket(); break;
        case 21: reconnectBlueStatusSocket(); break;
        case 22: reconnectVisionSocket(); break;
        case 23: recvActions(); break;
        default: ;
        }
        _id -= 24;
    }
    return _id;
}
예제 #10
0
//------------------------------------------------------------------------------
static void
keyboard(GLFWwindow *, int key, int /* scancode */, int event, int /* mods */) {

    if (event == GLFW_RELEASE) return;
    if (g_hud.KeyDown(tolower(key))) return;

    switch (key) {
        case 'Q': g_running = 0; break;
        case 'F': fitFrame(); break;

        case '[': if (g_currentPatch > 0) {
                      --g_currentPatch;
                      rebuildOsdMeshes();
                  } break;

        case ']': if (g_currentPatch < g_numPatches) {
                      ++g_currentPatch;
                      rebuildOsdMeshes();
                  } break;

        case GLFW_KEY_TAB: toggleFullScreen(); break;
        case GLFW_KEY_ESCAPE: g_hud.SetVisible(!g_hud.IsVisible()); break;
    }
}
예제 #11
0
void PtexViewer::menuAction(int i)
{
    switch (i)
    {
        case MENU_BGCOLOR :
            _options.bgColorLight = !_options.bgColorLight;
            break;
        case MENU_GRIDLINES :
            _options.showGridLines = !_options.showGridLines;
            break;
        case MENU_RESETVIEW :
            frameView(true);
            break;
        case MENU_FOCUSVIEW :
            frameView();
            break;
        case MENU_FULLSCREEN :
            toggleFullScreen();
            break;
        case MENU_QUIT :
            exit(EXIT_SUCCESS);
            break;
    }
}
예제 #12
0
int Keyboard::pollKey(SDL_Event event) {
    switch (event.key.keysym.sym) {
        case SDLK_ESCAPE :
            if (mode==0) { if (!gpJeu->getStop() && !gpJeu->getJoueur()->getImmo() 
            && gpJeu->getJoueur()->getVie()>0) 
                gpJeu->ecrit(421);
            } else if (mode<8 || mode==9 || mode==15 || mode==16 
            || (mode >18 && mode!=22 && mode!=23 && mode!=24 && mode!=25 
            && mode!=26 && mode!=27 && mode!=28)) return -1;
            break;
        case SDLK_F1 :
            if (mode == 0) {mode = 17; gpJeu->getGenerique()->initAide1(); 
                gpJeu->getAudio()->playSound(1);}
            break;
        case SDLK_F4 :
            if (event.key.keysym.mod & KMOD_ALT) return -1;
            break;
        case SDLK_RETURN :
            if (event.key.keysym.mod & KMOD_CTRL) toggleFullScreen();
            break;
        default : break;
    }
    return 0;
}
예제 #13
0
void MyVis::fKey()
{
	if ( !okienko )
		toggleFullScreen();
}
예제 #14
0
bool JokerWindow::eventFilter(QObject * sender, QEvent *event)
{
	/// The event filter catch the following event:
	switch (event->type()) {
	case QEvent::MouseMove: /// - Mouse move show the media panel
	case QEvent::HoverEnter:
	case QEvent::HoverMove:
		{
			fadeInMediaPanel();

			QMouseEvent * mouseEvent = (QMouseEvent*)event;
			// Check if it is near the video/strip border
			float stripHeight = this->height() * _settings->stripHeight();
			if((mouseEvent->pos().y() > (this->height() - stripHeight) - 10)
			   && (mouseEvent->pos().y() < (this->height() - stripHeight) + 10))
				QApplication::setOverrideCursor(Qt::SizeVerCursor);
			else
				QApplication::setOverrideCursor(Qt::ArrowCursor);

			if(_resizingStrip && (mouseEvent->buttons() & Qt::LeftButton)) {
				PHDEBUG << "resizing strip:" << mouseEvent->pos();
				_settings->setStripHeight(1.0 - ((float) mouseEvent->pos().y() /(float) this->height()));
			}
			break;
		}
	case QEvent::MouseButtonDblClick: /// - Double mouse click toggle fullscreen mode
		if(sender == this)
			toggleFullScreen();
		break;
	case QEvent::MouseButtonRelease:
		PHDEBUG << "end resizing strip";
		_resizingStrip = false;
		break;
	case QEvent::MouseButtonPress:
		{
			QMouseEvent *mouseEvent = (QMouseEvent*)event;
			if((sender == this) && (mouseEvent->buttons() & Qt::RightButton)) {
				/// - Right mouse click on the video open the video file dialog.
				if(mouseEvent->y() < this->height() * (1.0f - _settings->stripHeight()))
					on_actionOpen_Video_triggered();
				else /// - Left mouse click on the strip open the strip file dialog.
					on_actionOpen_triggered();
				return true;
			}
			float stripHeight = this->height() * _settings->stripHeight();
			if((mouseEvent->pos().y() > (this->height() - stripHeight) - 10)
			   && (mouseEvent->pos().y() < (this->height() - stripHeight) + 10)) {
				PHDEBUG << "start resizing strip";
				_resizingStrip = true;
			}
			break;
		}
	case QEvent::KeyPress:
		{
			QKeyEvent *keyEvent = (QKeyEvent*)event;
			if(keyEvent->key() == Qt::Key_Space) {
				on_actionPlay_pause_triggered();
			}
			break;
		}
	default:
		break;
	}

	return PhDocumentWindow::eventFilter(sender, event);
}
예제 #15
0
MediaWidget::MediaWidget(KMenu *menu_, KToolBar *toolBar, KActionCollection *collection,
	QWidget *parent) : QWidget(parent), menu(menu_), displayMode(NormalMode),
	automaticResize(ResizeOff), blockBackendUpdates(false), muted(false),
	screenSaverSuspended(false), showElapsedTime(true)
{
	dummySource.reset(new MediaSource());
	source = dummySource.data();

	QBoxLayout *layout = new QVBoxLayout(this);
	layout->setMargin(0);

	QPalette palette = QWidget::palette();
	palette.setColor(backgroundRole(), Qt::black);
	setPalette(palette);
	setAutoFillBackground(true);

	setAcceptDrops(true);
	setFocusPolicy(Qt::StrongFocus);

	backend = VlcMediaWidget::createVlcMediaWidget(this);

	if (backend == NULL) {
		backend = new DummyMediaWidget(this);
	}

	backend->connectToMediaWidget(this);
	layout->addWidget(backend);
	osdWidget = new OsdWidget(this);

	actionPrevious = new KAction(KIcon(QLatin1String("media-skip-backward")), i18n("Previous"), this);
	actionPrevious->setShortcut(KShortcut(Qt::Key_PageUp, Qt::Key_MediaPrevious));
	connect(actionPrevious, SIGNAL(triggered()), this, SLOT(previous()));
	toolBar->addAction(collection->addAction(QLatin1String("controls_previous"), actionPrevious));
	menu->addAction(actionPrevious);

	actionPlayPause = new KAction(this);
	actionPlayPause->setShortcut(KShortcut(Qt::Key_Space, Qt::Key_MediaPlay));
	textPlay = i18n("Play");
	textPause = i18n("Pause");
	iconPlay = KIcon(QLatin1String("media-playback-start"));
	iconPause = KIcon(QLatin1String("media-playback-pause"));
	connect(actionPlayPause, SIGNAL(triggered(bool)), this, SLOT(pausedChanged(bool)));
	toolBar->addAction(collection->addAction(QLatin1String("controls_play_pause"), actionPlayPause));
	menu->addAction(actionPlayPause);

	actionStop = new KAction(KIcon(QLatin1String("media-playback-stop")), i18n("Stop"), this);
	actionStop->setShortcut(KShortcut(Qt::Key_Backspace, Qt::Key_MediaStop));
	connect(actionStop, SIGNAL(triggered()), this, SLOT(stop()));
	toolBar->addAction(collection->addAction(QLatin1String("controls_stop"), actionStop));
	menu->addAction(actionStop);

	actionNext = new KAction(KIcon(QLatin1String("media-skip-forward")), i18n("Next"), this);
	actionNext->setShortcut(KShortcut(Qt::Key_PageDown, Qt::Key_MediaNext));
	connect(actionNext, SIGNAL(triggered()), this, SLOT(next()));
	toolBar->addAction(collection->addAction(QLatin1String("controls_next"), actionNext));
	menu->addAction(actionNext);
	menu->addSeparator();

    fullScreenAction = new KAction(KIcon(QLatin1String("view-fullscreen")),
		i18nc("'Playback' menu", "Full Screen Mode"), this);
	fullScreenAction->setShortcut(Qt::Key_F);
	connect(fullScreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
	menu->addAction(collection->addAction(QLatin1String("view_fullscreen"), fullScreenAction));

	minimalModeAction = new KAction(KIcon(QLatin1String("view-fullscreen")),
		i18nc("'Playback' menu", "Minimal Mode"), this);
	minimalModeAction->setShortcut(Qt::Key_Period);
	connect(minimalModeAction, SIGNAL(triggered()), this, SLOT(toggleMinimalMode()));
	menu->addAction(collection->addAction(QLatin1String("view_minimal_mode"), minimalModeAction));

	audioStreamBox = new KComboBox(toolBar);
	connect(audioStreamBox, SIGNAL(currentIndexChanged(int)),
		this, SLOT(currentAudioStreamChanged(int)));
	toolBar->addWidget(audioStreamBox);

	audioStreamModel = new QStringListModel(toolBar);
	audioStreamBox->setModel(audioStreamModel);

	subtitleBox = new KComboBox(toolBar);
	textSubtitlesOff = i18nc("subtitle selection entry", "off");
	connect(subtitleBox, SIGNAL(currentIndexChanged(int)),
		this, SLOT(currentSubtitleChanged(int)));
	toolBar->addWidget(subtitleBox);

	subtitleModel = new QStringListModel(toolBar);
	subtitleBox->setModel(subtitleModel);

	KMenu *audioMenu = new KMenu(i18nc("'Playback' menu", "Audio"), this);

	KAction *action = new KAction(KIcon(QLatin1String("audio-volume-high")),
		i18nc("'Audio' menu", "Increase Volume"), this);
	action->setShortcut(KShortcut(Qt::Key_Plus, Qt::Key_VolumeUp));
	connect(action, SIGNAL(triggered()), this, SLOT(increaseVolume()));
	audioMenu->addAction(collection->addAction(QLatin1String("controls_increase_volume"), action));

	action = new KAction(KIcon(QLatin1String("audio-volume-low")),
		i18nc("'Audio' menu", "Decrease Volume"), this);
	action->setShortcut(KShortcut(Qt::Key_Minus, Qt::Key_VolumeDown));
	connect(action, SIGNAL(triggered()), this, SLOT(decreaseVolume()));
	audioMenu->addAction(collection->addAction(QLatin1String("controls_decrease_volume"), action));

	muteAction = new KAction(i18nc("'Audio' menu", "Mute Volume"), this);
	mutedIcon = KIcon(QLatin1String("audio-volume-muted"));
	unmutedIcon = KIcon(QLatin1String("audio-volume-medium"));
	muteAction->setIcon(unmutedIcon);
	muteAction->setShortcut(KShortcut(Qt::Key_M, Qt::Key_VolumeMute));
	connect(muteAction, SIGNAL(triggered()), this, SLOT(mutedChanged()));
	toolBar->addAction(collection->addAction(QLatin1String("controls_mute_volume"), muteAction));
	audioMenu->addAction(muteAction);
	menu->addMenu(audioMenu);

	KMenu *videoMenu = new KMenu(i18nc("'Playback' menu", "Video"), this);
	menu->addMenu(videoMenu);
	menu->addSeparator();

	deinterlaceAction = new KAction(KIcon(QLatin1String("format-justify-center")),
		i18nc("'Video' menu", "Deinterlace"), this);
	deinterlaceAction->setCheckable(true);
	deinterlaceAction->setChecked(
		KGlobal::config()->group("MediaObject").readEntry("Deinterlace", true));
	deinterlaceAction->setShortcut(Qt::Key_I);
	connect(deinterlaceAction, SIGNAL(toggled(bool)), this, SLOT(deinterlacingChanged(bool)));
	backend->setDeinterlacing(deinterlaceAction->isChecked());
	videoMenu->addAction(collection->addAction(QLatin1String("controls_deinterlace"), deinterlaceAction));

	KMenu *aspectMenu = new KMenu(i18nc("'Video' menu", "Aspect Ratio"), this);
	QActionGroup *aspectGroup = new QActionGroup(this);
	connect(aspectGroup, SIGNAL(triggered(QAction*)),
		this, SLOT(aspectRatioChanged(QAction*)));

	action = new KAction(i18nc("'Aspect Ratio' menu", "Automatic"), aspectGroup);
	action->setCheckable(true);
	action->setChecked(true);
	action->setData(AspectRatioAuto);
	aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_auto"), action));

	action = new KAction(i18nc("'Aspect Ratio' menu", "Fit to Window"), aspectGroup);
	action->setCheckable(true);
	action->setData(AspectRatioWidget);
	aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_widget"), action));

	action = new KAction(i18nc("'Aspect Ratio' menu", "4:3"), aspectGroup);
	action->setCheckable(true);
	action->setData(AspectRatio4_3);
	aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_4_3"), action));

	action = new KAction(i18nc("'Aspect Ratio' menu", "16:9"), aspectGroup);
	action->setCheckable(true);
	action->setData(AspectRatio16_9);
	aspectMenu->addAction(collection->addAction(QLatin1String("controls_aspect_16_9"), action));

    // Changes aspect ratio "a la VLC"
    currentAspectRatio=AspectRatioAuto;
    action = new KAction(KIcon(QLatin1String("chainAspectRatio")),
        i18nc("'Aspect Ratio' menu", "Chain ratio"), this);
    action->setShortcut(Qt::CTRL+Qt::Key_A);
    connect(action, SIGNAL(triggered()), this, SLOT(chainAspectRatio()));
    aspectMenu->addAction(collection->addAction(QLatin1String("chainAspectRatio"), action));
    // Switches scale "a la VLC"
    currentAspectRatio=AspectRatioAuto;
    action = new KAction(KIcon(QLatin1String("switchScale")),
        i18nc("'Aspect Ratio' menu", "Switch scale"), this);
    action->setShortcut(Qt::SHIFT+Qt::Key_O);
    connect(action, SIGNAL(triggered()), this, SLOT(switchScale()));
    aspectMenu->addAction(collection->addAction(QLatin1String("switchScale"), action));

    videoMenu->addMenu(aspectMenu);

	KMenu *autoResizeMenu = new KMenu(i18n("Automatic Resize"), this);
	QActionGroup *autoResizeGroup = new QActionGroup(this);
	// we need an event even if you select the currently selected item
	autoResizeGroup->setExclusive(false);
	connect(autoResizeGroup, SIGNAL(triggered(QAction*)),
		this, SLOT(autoResizeTriggered(QAction*)));

	action = new KAction(i18nc("automatic resize", "Off"), autoResizeGroup);
	action->setCheckable(true);
	action->setData(0);
	autoResizeMenu->addAction(collection->addAction(QLatin1String("controls_autoresize_off"), action));

	action = new KAction(i18nc("automatic resize", "Original Size"), autoResizeGroup);
	action->setCheckable(true);
	action->setData(1);
	autoResizeMenu->addAction(collection->addAction(QLatin1String("controls_autoresize_original"), action));

	action = new KAction(i18nc("automatic resize", "Double Size"), autoResizeGroup);
	action->setCheckable(true);
	action->setData(2);
	autoResizeMenu->addAction(collection->addAction(QLatin1String("controls_autoresize_double"), action));

	int autoResizeFactor =
		KGlobal::config()->group("MediaObject").readEntry("AutoResizeFactor", 0);

	switch (autoResizeFactor) {
	case 1:
		automaticResize = OriginalSize;
		autoResizeGroup->actions().at(1)->setChecked(true);
		break;
	case 2:
		automaticResize = DoubleSize;
		autoResizeGroup->actions().at(2)->setChecked(true);
		break;
	default:
		automaticResize = ResizeOff;
		autoResizeGroup->actions().at(0)->setChecked(true);
		break;
	}

	videoMenu->addMenu(autoResizeMenu);

    action = new KAction(i18n("Volume Slider"), this);
	volumeSlider = new QSlider(toolBar);
	volumeSlider->setFocusPolicy(Qt::NoFocus);
	volumeSlider->setOrientation(Qt::Horizontal);
    volumeSlider->setRange(0, 100);
	volumeSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
	volumeSlider->setToolTip(action->text());
    volumeSlider->setValue(KGlobal::config()->group("MediaObject").readEntry("Volume", 100));
	connect(volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)));
	backend->setVolume(volumeSlider->value());
	action->setDefaultWidget(volumeSlider);
	toolBar->addAction(collection->addAction(QLatin1String("controls_volume_slider"), action));

	jumpToPositionAction = new KAction(KIcon(QLatin1String("go-jump")),
		i18nc("@action:inmenu", "Jump to Position..."), this);
	jumpToPositionAction->setShortcut(Qt::CTRL + Qt::Key_J);
	connect(jumpToPositionAction, SIGNAL(triggered()), this, SLOT(jumpToPosition()));
	menu->addAction(collection->addAction(QLatin1String("controls_jump_to_position"), jumpToPositionAction));

	navigationMenu = new KMenu(i18nc("playback menu", "Skip"), this);
	menu->addMenu(navigationMenu);
	menu->addSeparator();

	int shortSkipDuration = Configuration::instance()->getShortSkipDuration();
	int longSkipDuration = Configuration::instance()->getLongSkipDuration();
	connect(Configuration::instance(), SIGNAL(shortSkipDurationChanged(int)),
		this, SLOT(shortSkipDurationChanged(int)));
	connect(Configuration::instance(), SIGNAL(longSkipDurationChanged(int)),
		this, SLOT(longSkipDurationChanged(int)));

	longSkipBackwardAction = new KAction(KIcon(QLatin1String("media-skip-backward")),
		i18nc("submenu of 'Skip'", "Skip %1s Backward", longSkipDuration), this);
	longSkipBackwardAction->setShortcut(Qt::SHIFT + Qt::Key_Left);
	connect(longSkipBackwardAction, SIGNAL(triggered()), this, SLOT(longSkipBackward()));
	navigationMenu->addAction(
		collection->addAction(QLatin1String("controls_long_skip_backward"), longSkipBackwardAction));

	shortSkipBackwardAction = new KAction(KIcon(QLatin1String("media-skip-backward")),
		i18nc("submenu of 'Skip'", "Skip %1s Backward", shortSkipDuration), this);
	shortSkipBackwardAction->setShortcut(Qt::Key_Left);
	connect(shortSkipBackwardAction, SIGNAL(triggered()), this, SLOT(shortSkipBackward()));
	navigationMenu->addAction(
		collection->addAction(QLatin1String("controls_skip_backward"), shortSkipBackwardAction));

	shortSkipForwardAction = new KAction(KIcon(QLatin1String("media-skip-forward")),
		i18nc("submenu of 'Skip'", "Skip %1s Forward", shortSkipDuration), this);
	shortSkipForwardAction->setShortcut(Qt::Key_Right);
	connect(shortSkipForwardAction, SIGNAL(triggered()), this, SLOT(shortSkipForward()));
	navigationMenu->addAction(
		collection->addAction(QLatin1String("controls_skip_forward"), shortSkipForwardAction));

	longSkipForwardAction = new KAction(KIcon(QLatin1String("media-skip-forward")),
		i18nc("submenu of 'Skip'", "Skip %1s Forward", longSkipDuration), this);
	longSkipForwardAction->setShortcut(Qt::SHIFT + Qt::Key_Right);
	connect(longSkipForwardAction, SIGNAL(triggered()), this, SLOT(longSkipForward()));
	navigationMenu->addAction(
		collection->addAction(QLatin1String("controls_long_skip_forward"), longSkipForwardAction));

	toolBar->addAction(KIcon(QLatin1String("player-time")), i18n("Seek Slider"))->setEnabled(false);

	action = new KAction(i18n("Seek Slider"), this);
	seekSlider = new SeekSlider(toolBar);
	seekSlider->setFocusPolicy(Qt::NoFocus);
	seekSlider->setOrientation(Qt::Horizontal);
	seekSlider->setToolTip(action->text());
	connect(seekSlider, SIGNAL(valueChanged(int)), this, SLOT(seek(int)));
	action->setDefaultWidget(seekSlider);
	toolBar->addAction(collection->addAction(QLatin1String("controls_position_slider"), action));

	menuAction = new KAction(KIcon(QLatin1String("media-optical-video")),
		i18nc("dvd navigation", "DVD Menu"), this);
	connect(menuAction, SIGNAL(triggered()), this, SLOT(toggleMenu()));
	menu->addAction(collection->addAction(QLatin1String("controls_toggle_menu"), menuAction));

	titleMenu = new KMenu(i18nc("dvd navigation", "Title"), this);
	titleGroup = new QActionGroup(this);
	connect(titleGroup, SIGNAL(triggered(QAction*)),
		this, SLOT(currentTitleChanged(QAction*)));
	menu->addMenu(titleMenu);

	chapterMenu = new KMenu(i18nc("dvd navigation", "Chapter"), this);
	chapterGroup = new QActionGroup(this);
	connect(chapterGroup, SIGNAL(triggered(QAction*)),
		this, SLOT(currentChapterChanged(QAction*)));
	menu->addMenu(chapterMenu);

	angleMenu = new KMenu(i18nc("dvd navigation", "Angle"), this);
	angleGroup = new QActionGroup(this);
	connect(angleGroup, SIGNAL(triggered(QAction*)), this,
		SLOT(currentAngleChanged(QAction*)));
	menu->addMenu(angleMenu);

	action = new KAction(i18n("Switch between elapsed and remaining time display"), this);
	timeButton = new QPushButton(toolBar);
	timeButton->setFocusPolicy(Qt::NoFocus);
	timeButton->setToolTip(action->text());
	connect(timeButton, SIGNAL(clicked(bool)), this, SLOT(timeButtonClicked()));
	action->setDefaultWidget(timeButton);
	toolBar->addAction(collection->addAction(QLatin1String("controls_time_button"), action));

	QTimer *timer = new QTimer(this);
	timer->start(50000);
	connect(timer, SIGNAL(timeout()), this, SLOT(checkScreenSaver()));
}
예제 #16
0
bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
	switch ((int)event.type) {
	case Common::EVENT_KEYDOWN:
		if (event.kbd.hasFlags(Common::KBD_ALT)) {
			// Alt-Return and Alt-Enter toggle full screen mode
			if (event.kbd.keycode == Common::KEYCODE_RETURN ||
				event.kbd.keycode == (Common::KeyCode)SDLK_KP_ENTER) {
				toggleFullScreen(0);
				return true;
			}

			// Alt-S create a screenshot
			if (event.kbd.keycode == 's') {
				Common::String filename;

				for (int n = 0;; n++) {
					SDL_RWops *file;

					filename = Common::String::format("scummvm%05d.bmp", n);
					file = SDL_RWFromFile(filename.c_str(), "r");
					if (!file)
						break;
					SDL_RWclose(file);
				}
				if (saveScreenshot(filename.c_str()))
					debug("Saved screenshot '%s'", filename.c_str());
				else
					warning("Could not save screenshot");
				return true;
			}
		}

		if (event.kbd.hasFlags(Common::KBD_CTRL|Common::KBD_ALT)) {
			// Ctrl-Alt-Return and Ctrl-Alt-Enter switch between full screen modes
			if (event.kbd.keycode == Common::KEYCODE_RETURN ||
				event.kbd.keycode == (Common::KeyCode)SDLK_KP_ENTER) {
				toggleFullScreen(1);
				return true;
			}

			// Ctrl-Alt-a switch between display modes
			if (event.kbd.keycode == 'a') {
				beginGFXTransaction();
					setFeatureState(OSystem::kFeatureAspectRatioCorrection, !getFeatureState(OSystem::kFeatureAspectRatioCorrection));
				endGFXTransaction();
#ifdef USE_OSD
			Common::String osdMessage;
			if (getFeatureState(OSystem::kFeatureAspectRatioCorrection))
				osdMessage = Common::String::format("%s\n%d x %d -> %d x %d",
				        _("Enabled aspect ratio correction"),
				        _videoMode.screenWidth, _videoMode.screenHeight,
				        _hwscreen->w, _hwscreen->h);
			else
				osdMessage = Common::String::format("%s\n%d x %d -> %d x %d",
				        _("Disabled aspect ratio correction"),
				        _videoMode.screenWidth, _videoMode.screenHeight,
				        _hwscreen->w, _hwscreen->h);
			displayMessageOnOSD(osdMessage.c_str());
#endif
				internUpdateScreen();
				return true;
			}

			// Ctrl-Alt-f toggles antialiasing
			if (event.kbd.keycode == 'f') {
				beginGFXTransaction();
					toggleAntialiasing();
				endGFXTransaction();

#ifdef USE_OSD
				// TODO: This makes guesses about what internal antialiasing
				// modes we use, we might want to consider a better way of
				// displaying information to the user.
				if (getAntialiasingState())
					displayMessageOnOSD(_("Active filter mode: Linear"));
				else
					displayMessageOnOSD(_("Active filter mode: Nearest"));
#endif
				return true;
			}

			SDLKey sdlKey = (SDLKey)event.kbd.keycode;

			// Ctrl+Alt+Plus/Minus Increase/decrease the scale factor
			if ((sdlKey == SDLK_EQUALS || sdlKey == SDLK_PLUS || sdlKey == SDLK_MINUS ||
				sdlKey == SDLK_KP_PLUS || sdlKey == SDLK_KP_MINUS)) {
				int factor = getScale();
				factor += (sdlKey == SDLK_MINUS || sdlKey == SDLK_KP_MINUS) ? -1 : +1;
				if (0 < factor && factor < 4) {
					// Check if the desktop resolution has been detected
					if (_desktopWidth > 0 && _desktopHeight > 0)
						// If the new scale factor is too big, do not scale
						if (_videoMode.screenWidth * factor > _desktopWidth ||
							_videoMode.screenHeight * factor > _desktopHeight)
							return false;

					beginGFXTransaction();
						setScale(factor);
					endGFXTransaction();
#ifdef USE_OSD
					displayScaleChangedMsg();
#endif
					return true;
				}
			}

			const bool isNormalNumber = (SDLK_1 <= sdlKey && sdlKey <= SDLK_3);
			const bool isKeypadNumber = (SDLK_KP1 <= sdlKey && sdlKey <= SDLK_KP3);

			// Ctrl-Alt-<number key> will change the GFX mode
			if (isNormalNumber || isKeypadNumber) {
				if (sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1) <= 3) {
#ifdef USE_OSD
					int lastMode = _videoMode.mode;
#endif
					// We need to query the scale and set it up, because
					// setGraphicsMode sets the default scale to 2
					int oldScale = getScale();
					beginGFXTransaction();
						setGraphicsMode(sdlKey - (isNormalNumber ? SDLK_1 : SDLK_KP1));
						setScale(oldScale);
					endGFXTransaction();
#ifdef USE_OSD
					if (lastMode != _videoMode.mode)
						displayModeChangedMsg();
#endif
					internUpdateScreen();
				}
			}
		}

		if (event.kbd.hasFlags(Common::KBD_CTRL|Common::KBD_SHIFT)) {
			// Ctrl-Shift-Return and Ctrl-Shift-Enter switch backwards between full screen modes
			if (event.kbd.keycode == Common::KEYCODE_RETURN ||
				event.kbd.keycode == (Common::KeyCode)SDLK_KP_ENTER) {
				toggleFullScreen(-1);
				return true;
			}
		}
		break;

	case Common::EVENT_KEYUP:
		return isHotkey(event);

	default:
		break;
	}

	return false;
}
예제 #17
0
JokerWindow::JokerWindow(JokerSettings *settings) :
	PhDocumentWindow(settings),
	ui(new Ui::JokerWindow),
	_settings(settings),
	_strip(settings),
	_videoEngine(settings),
	_doc(_strip.doc()),
	_sonySlave(PhTimeCodeType25, settings),
	_mtcReader(PhTimeCodeType25),
	_ltcReader(settings),
	_mediaPanelAnimation(&_mediaPanel, "windowOpacity"),
	_firstDoc(true),
	_resizingStrip(false),
	_numberOfDraw(0)
{
	// Setting up UI
	ui->setupUi(this);

	// Due to translation, Qt might not be able to link automatically the menu
	ui->actionPreferences->setMenuRole(QAction::PreferencesRole);
	ui->actionAbout->setMenuRole(QAction::AboutRole);

	connect(ui->actionFullscreen, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));

	ui->videoStripView->setGraphicSettings(_settings);

	// Initialize the property dialog
	_propertyDialog.setDoc(_doc);
	_propertyDialog.setVideoEngine(&_videoEngine);

	// Initialize the synchronizer
	_synchronizer.setStripClock(_strip.clock());
	_synchronizer.setVideoClock(_videoEngine.clock());

	connect(&_sonySlave, &PhSonySlaveController::videoSync, this, &JokerWindow::onVideoSync);

	setupSyncProtocol();

	// Setting up the media panel
	_mediaPanel.setClock(_doc->videoTimeCodeType(), _strip.clock());
#warning /// @todo move to CSS file
	_mediaPanel.setStyleSheet(
	    "* {"
	    "	  color: white;"
	    "  }"
	    "  PhMediaPanel { "
	    "	  background: qlineargradient(x1: 1, y1: 0, x2: 1, y2: 1, stop: 0 rgb(40,40,40), stop: 1 black);"
	    "	  border-style: solid;                                                                          "
	    "	  border-width: 4px;                                                                            "
	    "	  border-radius: 3px;                                                                           "
	    "	  border-color: white;                                                                          "
	    "  }                                                                                                "
	    "  QPushButton, QComboBox{                                                                          "
	    "	  background: grey;                                                                             "
	    "	  border-style: outset;                                                                         "
	    "	  border-width: 2px;                                                                            "
	    "	  border-radius: 5px;                                                                           "
	    "	  border-color: white;                                                                          "
	    "  }                                                                                                "
	    "  QLabel#_timecodeLabel{                                                                           "
	    "	  padding: 10px;                                                                                "
	    "  }                                                                                                "
	    );

	this->setFocus();

	if(_settings->stripTestMode()) {
#warning /// @todo do we warn the user that test mode is on?
		ui->actionTest_mode->setChecked(true);
	}

#warning /// @todo move to PhDocumentWindow
	// This is for the drag and drop feature
	setAcceptDrops(true);

	ui->actionDisplay_the_cuts->setChecked(_settings->displayCuts());

	ui->actionInvert_colors->setChecked(_settings->invertColor());

	ui->actionShow_ruler->setChecked(_settings->displayRuler());

	ui->actionHide_the_rythmo->setChecked(_settings->hideStrip());

	_mediaPanel.show();
	_mediaPanelState = MediaPanelVisible;

	// Trigger a timer that will fade off the media panel after 3 seconds
	this->connect(&_mediaPanelTimer, SIGNAL(timeout()), this, SLOT(fadeOutMediaPanel()));
	_mediaPanelTimer.start(3000);

	this->connect(ui->videoStripView, &PhGraphicView::beforePaint, this, &JokerWindow::timeCounter);
	this->connect(ui->videoStripView, &PhGraphicView::beforePaint, _strip.clock(), &PhClock::tick);

	this->connect(ui->videoStripView, &PhGraphicView::paint, this, &JokerWindow::onPaint);

	_videoLogo.setFilename(QCoreApplication::applicationDirPath() + PATH_TO_RESSOURCES + "/phonations.png");
}
예제 #18
0
WikiOnBoard::WikiOnBoard(void* bgc, QWidget *parent) :
    QMainWindow(parent), m_bgc(bgc)

        {
        zimFileWrapper = new ZimFileWrapper(this);
	//For now assume that: S60 rd 3dition devices have no touch screen, all other devices have touch screen.
	// TODO Consider changing to QSystemDeviceInfo when Qt Mobility available for all supported devices
	hasTouchScreen = true;
	#ifdef Q_OS_SYMBIAN	
	if ((QSysInfo::s60Version()==QSysInfo::SV_S60_3_1) || (QSysInfo::s60Version()==QSysInfo::SV_S60_3_2)) {
		qDebug() << "S60 3rd edition device. Assume that no touchscreen is available.";
		hasTouchScreen = false;
	}
	#endif
        //Used by QSettings
        QCoreApplication::setOrganizationName(QLatin1String("Christian Puehringer"));
        QCoreApplication::setApplicationName(QLatin1String("WikiOnBoard"));

        #ifdef Q_OS_SYMBIAN
        // Save settings files to private application directory, to ensure
        // that uninstaller removes settings. (see also
        //  http://bugreports.qt.nokia.com/browse/QTBUG-16229)
            QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QCoreApplication::applicationDirPath());
            QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::applicationDirPath());
            QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QCoreApplication::applicationDirPath());
            QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QCoreApplication::applicationDirPath());
        #endif
        qDebug() << "WikiOnBoard::WikiOnBoard. Version: " << QString::fromLocal8Bit(__APPVERSIONSTRING__) << " QT Version: "<<qVersion();
	qDebug() << " hasTouchScreen: "<<hasTouchScreen;
	


	QSettings settings;
	settings.beginGroup(QLatin1String("ZimFile"));

	QString lastZimFile = settings.value(QLatin1String("lastZimFile")).toString();
	settings.endGroup();

	ui.setupUi(this);
        articleViewer = new ArticleViewer(ui.articlePage,zimFileWrapper,hasTouchScreen);
        ui.gridLayout_3->addWidget(articleViewer);
        indexList = new IndexList(ui.indexPage,zimFileWrapper, hasTouchScreen);
        ui.gridLayout_2->addWidget(indexList,1,0);
        setStatusBar(0); //Remove status bar to increase useable screen size.
	//TODO still not perfect, quite some distance between
        //  widget and menu.

        settings.beginGroup(QLatin1String("UISettings"));
        fullScreen = settings.value(QLatin1String("fullScreen"), false).toBool();
        settings.endGroup();
        if (connect(articleViewer,SIGNAL(sourceChanged(QUrl)),this, SLOT(on_articleViewer_sourceChanged(QUrl)))) {
            qDebug() << "Connected sourceChanged";
        } else {
            qWarning()<<"Could not connect sourceChanged";
        }
        if (connect(articleViewer,SIGNAL(articleOpened(QString)),this, SLOT(onArticleOpened(QString)))) {
            qDebug() << "Connected articleOpened";
        } else {
            qWarning()<<"Could not connect articleOpened";
        }

        if (connect(articleViewer,SIGNAL(openExternalLink(QUrl)),this, SLOT(openExternalLink(QUrl)))) {
            qDebug() << "Connected openExternalLink";
        } else {
            qWarning()<<"Could not connect openExternalLink";
        }
        connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(workAreaResized(int)));

	
#ifdef Q_OS_SYMBIAN
	//Enable Softkeys in fullscreen mode. 
    //New Flag in Qt 4.6.3. 
	//Workaround used for 4.6.2 (see main.cpp for details) 
	//not working anymore with Qt 4.6.3
	//However, 4.6.2 workaround keep, as perhaps still
	// working/required for 4.6.2. 
	Qt::WindowFlags flags = windowFlags();
	flags |= Qt::WindowSoftkeysVisibleHint;
	setWindowFlags(flags);
        //Hide toolbar to increase useable screen space (toolbar may be used for meego).
        ui.toolBar->hide();
#endif
	if (fullScreen)
		{
                showFullScreen();
		}
	else
		{
		showMaximized();
		}
        openZimFileDialogAction = new QAction(tr("Open Zimfile"), this);
	connect(openZimFileDialogAction, SIGNAL(triggered()), this,
			SLOT(openZimFileDialog()));

        showWelcomePageAction = new QAction(tr("show Welcomepage"), this);
        connect(showWelcomePageAction, SIGNAL(triggered()), this,
                        SLOT(switchToWelcomePage()));
	gotoHomepageAction = new QAction(tr("Goto Homepage"), this);
	connect(gotoHomepageAction, SIGNAL(triggered()), this,
			SLOT(gotoHomepage()));
	aboutCurrentZimFileAction = new QAction(tr("About current Zimfile"), this);
	connect(aboutCurrentZimFileAction, SIGNAL(triggered()), this, 
			SLOT(aboutCurrentZimFile()));
	aboutAction = new QAction(tr("About"), this);
	connect(aboutAction, SIGNAL(triggered()), this,
			SLOT(about()));
	aboutQtAction = new QAction(tr("About Qt"), this);
	connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
				
		
	//Define search action (populates article list view with articles found searching for article
	//name line edit.
	// 
	searchArticleAction = new QAction(tr("Search Article"), this);

	connect(searchArticleAction, SIGNAL(triggered()), this,
			SLOT(searchArticle()));
	//connect(ui.articleName, SIGNAL(textChanged(QString)), searchArticleAction,
	//		SIGNAL(triggered())); //Automatically search after text changed
	//TODO: this hangs, instead textEdited used. find out why not working 
	connect(ui.articleName, SIGNAL(textEdited(QString)), searchArticleAction,
			SIGNAL(triggered())); //Automatically search after text changed


	ui.articleName->addAction(searchArticleAction);
	//Capitalize first letter. In particular important as zimlib
	// search is case-sensitive and in wikipedia most articles start with
	// captial letter.
	// Somewhat strange that this work. (Actually defaullt should be Imhnone
	// anyway, but appearantly it is not on symbian. Just calling ImhNone,
	// does not do anything, because it thinks that nothing has changed. 
	// Setting something different (here ImhPreferUppercase) and then ImhNone,
	// sets it to the desired Abc mode.
	ui.articleName->setInputMethodHints(Qt::ImhPreferUppercase); 
	ui.articleName->setInputMethodHints(Qt::ImhNone);
	clearSearchAction = new QAction(tr("Clear"), this);
	connect(clearSearchAction, SIGNAL(triggered()), ui.articleName,
				SLOT(clear()));
	connect(clearSearchAction, SIGNAL(triggered()), searchArticleAction,
					SIGNAL(triggered())); //Automatically search after cleared.

	this->addAction(clearSearchAction);
		
	openArticleAction = new QAction(tr("Open Article"), this);

        connect(indexList, SIGNAL(itemClicked(QListWidgetItem*)), this,
                        SLOT(articleListOpenArticle(QListWidgetItem *))); //For touchscreen devices
        //slot just calls openArticlAction.trigger
        connect(openArticleAction, SIGNAL(triggered()), this,
                        SLOT(articleListOpenArticle()));


        //connect(indexList, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(articleListOpenArticle(QListWidgetItem *)));
        indexList->addAction(openArticleAction);

	//Open article when clicked or return key clicked. Note that for keypad phones return (amongst others) is
	// forwarded to articleListWidget, so that this works even if it has not focus.

	switchToIndexPageAction = new QAction(tr("Switch to index page"), this);
	connect(switchToIndexPageAction, SIGNAL(triggered()), this,
			SLOT(switchToIndexPage()));
	this->addAction(switchToIndexPageAction);

	//	ui.actionSearch->setSoftKeyRole(QAction::NegativeSoftKey); //Right softkey: return to search page
	///	ui.articlePage->addAction(ui.actionSearch);

	backArticleHistoryAction = new QAction(tr("Back"), this);
	connect(backArticleHistoryAction, SIGNAL(triggered()), this,
			SLOT(backArticleHistoryOrIndexPage()));
	this->addAction(backArticleHistoryAction); 
        emptyAction = new QAction( tr( "", "Empty. Displayed as right soft key if nothing opened"), this );
        addAction( emptyAction );

	toggleFullScreenAction = new QAction(tr("Toggle Fullscreen"), this); //TODO shortcut
	toggleFullScreenAction->setShortcutContext(Qt::ApplicationShortcut); //Or Qt::WindowShortcut?
	connect(toggleFullScreenAction, SIGNAL(triggered()), this,
			SLOT(toggleFullScreen()));
	this->addAction(toggleFullScreenAction);

        toggleImageDisplayAction = new QAction(tr("Show Images"), this);
        toggleImageDisplayAction->setCheckable(true);
        connect(toggleImageDisplayAction, SIGNAL(toggled(bool)), articleViewer,
                        SLOT(toggleImageDisplay(bool)));
        this->addAction(toggleImageDisplayAction);
        settings.beginGroup(QLatin1String("UISettings"));
        toggleImageDisplayAction->setChecked(settings.value(QLatin1String("showImages"), true).toBool());
        settings.endGroup();


	exitAction = new QAction(tr("Exit"), this);
	connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
	this->addAction(exitAction);

	zoomInAction = new QAction(tr("Zoom in"), this);
	zoomOutAction = new QAction(tr("Zoom out"), this);
        connect(zoomOutAction, SIGNAL(triggered()), articleViewer, SLOT(zoomOutOneStep()));
        connect(zoomInAction, SIGNAL(triggered()), articleViewer, SLOT(zoomInOneStep()));

        //Sub menus
        QMenu* optionsMenuIndexPage = new QMenu(tr("Options", "Option menu"),this);
        optionsMenuIndexPage->addAction(toggleFullScreenAction);
        optionsMenuIndexPage->addAction(toggleImageDisplayAction);
        QMenu* optionsMenuArticlePage = new QMenu(tr("Options", "Option menu"),this);
        optionsMenuArticlePage->addAction(zoomInAction);
        optionsMenuArticlePage->addAction(zoomOutAction);
        optionsMenuArticlePage->addAction(toggleFullScreenAction);
        optionsMenuArticlePage->addAction(toggleImageDisplayAction);
        QMenu* helpMenu = new QMenu(tr("Help", "Help menu"),this);
        helpMenu->addAction(showWelcomePageAction);
        helpMenu->addAction(gotoHomepageAction);
        helpMenu->addAction(aboutCurrentZimFileAction);
        helpMenu->addAction(aboutAction);
        helpMenu->addAction(aboutQtAction);


        menuIndexPage = new QMenu(this);
        menuIndexPage->addAction(openArticleAction);
        menuIndexPage->addAction(openZimFileDialogAction);
        menuIndexPage->addMenu(optionsMenuIndexPage);
        menuIndexPage->addMenu(helpMenu);
        menuIndexPage->addAction(exitAction);

        menuArticlePage = new QMenu(this);
        menuArticlePage->addAction(switchToIndexPageAction);
        menuArticlePage->addAction(openZimFileDialogAction);
        menuArticlePage->addMenu(optionsMenuArticlePage);
        menuArticlePage->addMenu(helpMenu);
        menuArticlePage->addAction(exitAction);

        menuArticlePageNoFileOpen = new QMenu(this);
        menuArticlePageNoFileOpen->addAction(openZimFileDialogAction);
        menuArticlePageNoFileOpen->addMenu(optionsMenuArticlePage);
        menuArticlePageNoFileOpen->addMenu(helpMenu);
        menuArticlePageNoFileOpen->addAction(exitAction);

        //Used to allow translation of softkey with menu.
        // (Actually should be translated automatically, but
        // appearantly not working, therefore just assign our
        // own (translatable) text)
        positiveSoftKeyActionMenuIndexPage = new QAction(tr("TRANLATOR Indexpage Menu Name"),this);
        positiveSoftKeyActionMenuIndexPage->setMenu(menuIndexPage);
        this->addAction(positiveSoftKeyActionMenuIndexPage);

        positiveSoftKeyActionMenuArticlePage = new QAction(tr("TRANLATOR Articlepage Menu Name"),this);
        positiveSoftKeyActionMenuArticlePage->setMenu(menuArticlePage);
        this->addAction(positiveSoftKeyActionMenuArticlePage);

        positiveSoftKeyActionMenuArticlePageNoFileOpen = new QAction(tr("TRANLATOR Articlepage (no zimfile open) Menu Name"),this);
        positiveSoftKeyActionMenuArticlePageNoFileOpen->setMenu(menuArticlePageNoFileOpen);
        this->addAction(positiveSoftKeyActionMenuArticlePageNoFileOpen);

         //Set welcome page
        QString zimDownloadUrl = QString(tr("http://cip.github.com/WikiOnBoard/Get-eBooks.html","Change link to page with localized zim files. (e.g http://cip.github.com/WikiOnBoard/Get-eBooks-DE.html"));
        QString getEBookLinkCaption = QString(tr("Download zimfile", "link"));
        QString zimDownloadUrlHtml = QString(tr("<a href=\"%1\">%2</a>", "DON'T translate this").arg(zimDownloadUrl,getEBookLinkCaption));
        QString informativeText = QString(tr("[TRANSLATOR] No zimfile selected. getEBook link  %1 opens url %3 with info where to get eBooks. Menu option %2 in option menu %4 opens zimfile on mobile", "Text is interpreted as HTML. Html for body and link (%1) automatically added. Other Html tags can be used if desired")).arg(zimDownloadUrlHtml,openZimFileDialogAction->text(),zimDownloadUrl, positiveSoftKeyActionMenuArticlePage->text());
        articleViewer->setWelcomePage(informativeText);

	// Set context menu policy for widgets to suppress the useless 'Actions' submenu
#ifdef Q_OS_SYMBIAN
	QWidgetList widgets = QApplication::allWidgets();
	QWidget* w = 0;
	foreach( w, widgets )
			{
			w->setContextMenuPolicy(Qt::NoContextMenu);
			}
예제 #19
0
TextRoom::TextRoom(QWidget *parent, Qt::WFlags f)
		: QWidget(parent, f), sentenceTally(0)
{
	setupUi(this);
	setObjectName("textroom");

// Set the default values for variables.
	numChanges = 0;
	prevLength = 0;
	wordcount = 0;
	alarm = 0;
	parasold = 0;
	isHighlighted = false;

#ifdef Q_OS_MACX
	// Find the path for the app path 
	QDir tmpDir = QDir(QCoreApplication::applicationDirPath());
	// go into Resources folder
	tmpDir.cdUp();
	tmpDir.cd("Resources");
	// get the full path for the resources
	resourcesDir = tmpDir.path();
#endif

// Create the dialog windows.
	optionsDialog = new OptionsDialog(this);
	helpDialog = new HelpDialog(this);
	selectFont = new SelectFont(this);
	aboutDialog = new AboutDialog(this);
	scratchDialog = new ScratchDialog(this);
	miniFlo = new MiniFlo(this);
	getAWord = new GetAWord(this);
	musicRoom = new MusicRoom(this);
	googleDocsDialog = new GoogleDocsDialog(this);	

// Read settings saved by Options Dialog.
#ifdef Q_OS_WIN32
	settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationName());
#else
	settings = new QSettings();
#endif
	readSettings();

// Sound adjustments.
	int audio_rate = 11025;
	Uint16 audio_format = AUDIO_S16SYS;
	int audio_channels = 2;
	int audio_buffers = 1024;
	
	if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
		fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);
	
	if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) {
		printf("Unable to initialize audio: %s\n", Mix_GetError());
		exit(1);
	}

// Load sounds.
#ifdef Q_OS_WIN32
	soundenter = Mix_LoadWAV("keyenter.wav");
#elif defined(Q_OS_MACX)
	QString tmp = resourcesDir;
	tmp.append("/sounds/keyenter.wav");
	soundenter = Mix_LoadWAV(tmp.toAscii());
#else
	soundenter = Mix_LoadWAV("/usr/share/sounds/keyenter.wav");
#endif
	if(soundenter == NULL) {
		printf("Unable to load WAV file: %s\n", Mix_GetError());
	}

#ifdef Q_OS_WIN32
	soundany = Mix_LoadWAV("keyany.wav");
#elif defined(Q_OS_MACX)
	tmp = resourcesDir;
	tmp.append("/sounds/keyany.wav");
	soundany = Mix_LoadWAV(tmp.toAscii());
#else
	soundany = Mix_LoadWAV("/usr/share/sounds/keyany.wav");
#endif
	if(soundany == NULL) {
		printf("Unable to load WAV file: %s\n", Mix_GetError());
	}
		
// Create the keyboard shortcuts.
	new QShortcut ( QKeySequence(QKeySequence::New), this, SLOT( newFile() ) );
	new QShortcut ( QKeySequence(QKeySequence::Open), this, SLOT( open() ) );
	new QShortcut ( QKeySequence(QKeySequence::Save), this, SLOT( save() ) );
	new QShortcut ( QKeySequence(QKeySequence::HelpContents), this, SLOT( help() ) );
#ifdef Q_OS_MACX
	new QShortcut ( QKeySequence(tr("F1", "Help")), this, SLOT( help() ) );
#endif
	new QShortcut ( QKeySequence(tr("F2", "Options")), this, SLOT( options() ) );
	new QShortcut ( QKeySequence(tr("F3", "About")), this, SLOT( about() ) );
	new QShortcut ( QKeySequence(tr("F5", "Spell Check")), this, SLOT( spellCheck() ) );
	new QShortcut ( QKeySequence(tr("F6", "Scratch Pad")), this, SLOT( showScratchPad() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+P", "Print")), this, SLOT( print() ) );
	new QShortcut ( QKeySequence(tr("Shift+Ctrl+S", "Save As")), this, SLOT( saveAs() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+D", "Insert Date")), this, SLOT( insertDate() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+T", "Insert Time")), this, SLOT( insertTime() ) );	
	new QShortcut ( QKeySequence(tr("Ctrl+Q", "Quit Application")) , this, SLOT( close() ) );
	new QShortcut ( QKeySequence(tr("Alt+F4", "Quit Application")) , this, SLOT( close() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+F", "Find Text")) , this, SLOT( find() ) );
	new QShortcut ( QKeySequence(tr("F11", "Toggle Fullscreen")) , this, SLOT( toggleFullScreen() ) );
	new QShortcut ( QKeySequence(tr("Esc", "Toggle Fullscreen")) , this, SLOT( toggleEscape() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+M", "Minimize TextRoom")) , this, SLOT( showMinimized() ) );
	new QShortcut ( QKeySequence(tr("F4", "Find Next")) , this, SLOT( find_next() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+F4", "Find Previous")) , this, SLOT( find_previous() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+B", "Bold")) , this, SLOT( textBold() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+I", "Italic")) , this, SLOT( textItalic() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+Up", "Increase Text Size")) , this, SLOT( textSizeUp() ) );
	new QShortcut ( QKeySequence(tr("Ctrl+Down", "Decrease Text Size")) , this, SLOT( textSizeDown() ) );	
	new QShortcut ( QKeySequence(tr("Ctrl+W", "Select Font")) , this, SLOT( changeFont() ) );	
        new QShortcut ( QKeySequence(tr("Ctrl+R", "Align Right")) , this, SLOT( alignRight() ) );
        new QShortcut ( QKeySequence(tr("Ctrl+L", "Align Left")) , this, SLOT( alignLeft() ) );
        new QShortcut ( QKeySequence(tr("Ctrl+J", "Align Justify")) , this, SLOT( alignJustify() ) );
        new QShortcut ( QKeySequence(tr("Ctrl+E", "Align Center")) , this, SLOT( alignCenter() ) );
        new QShortcut ( QKeySequence(tr("Ctrl+Alt+I", "Insert Image")) , this, SLOT( insertImage() ) );
        new QShortcut ( QKeySequence(tr("F7", "Show MiniFlo")) , this, SLOT( showMiniFlo() ) );
        new QShortcut ( QKeySequence(tr("F8", "Get A Word")) , this, SLOT( showGetAWord() ) );
        new QShortcut ( QKeySequence(tr("F9", "MusicRoom")) , this, SLOT( showMusicRoom() ) );
        new QShortcut ( QKeySequence(tr("F10", "Google Docs")) , this, SLOT( exportToGoogle() ) );
	// Service: show cursor
	new QShortcut ( QKeySequence(tr("Shift+F4", "Show Cursor")) , this, SLOT( sCursor() ) );

	//fw = new QFileSystemWatcher(this);
	//fw->addPath( settings->fileName() );

	// If file is changed, read the settings->
	//connect(fw, SIGNAL(fileChanged(const QString)),
	//		this, SLOT(readSettings()));
	// If the document is changed, do some stuff.
	connect(textEdit->document(), SIGNAL(contentsChanged()),
		this, SLOT(documentWasModified()));

	// If position is changed, scroll.
	connect(textEdit->verticalScrollBar(), SIGNAL(valueChanged(int)),
		this, SLOT(vPositionChanged()));
	// If horizontal scrollar is changed, scroll.
	connect(horizontalSlider, SIGNAL(valueChanged(int)),
		this, SLOT(hSliderPositionChanged()));
	connect(textEdit, SIGNAL(anchorClicked(QUrl)), this, SLOT(showScratchPad()));

	// check if we need to open some file at startup
	const QStringList args = QCoreApplication::arguments();
	if (args.count() == 2)
	{
		QFile file( args.at(1) );
		if ( file.exists() )
			curFile = args.at(1);
	}
	
	if (!curFile.isEmpty())
		loadFile(curFile);
	else
		newFile();


	// set cursor position
	if ( isSaveCursor )
	{
		textEdit->textCursor().setPosition(cPosition);
	}

	writeSettings();

// Refresh the file status every second.
	QTimer *timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(getFileStatus()));
	timer->start(1000);
}
예제 #20
0
void TextRoom::readSettings()
{
	QFile file( settings->fileName() );
	if ( !file.exists() )
	{
		toggleFullScreen();
		writeSettings();
		return;
	}

	if ( settings->value("WindowState/ShowFullScreen", true).toBool() )
	{
		if ( !isFullScreen() )
			showFullScreen();
   	}
	else
	{
		showNormal();
		QPoint pos = settings->value("WindowState/TopLeftPosition", QPoint(100, 100)).toPoint();
		QSize size = settings->value("WindowState/WindowSize", QSize(300, 200)).toSize();
		resize(size);
		move(pos);
	}

	QString foregroundColor = settings->value("Colors/FontColor", "#808080" ).toString();
	QString back = settings->value("Colors/Background", "#000000" ).toString();
	QString status_c = settings->value("Colors/StatusColor", "#202020" ).toString();

	// oxygen does weird stuff with the background
	QApplication::setStyle("plastique");

	QFont font;
	font.fromString( settings->value("StatusFont").toString());
	defaultFont.fromString( settings->value("DefaultFont").toString() );

	statsLabel->setFont( font );
	deadlineLabel->setFont ( font ) ;

	curDir = settings->value("RecentFiles/LastDir", curDir).toString();
	lastSearch = settings->value("TextSearch/LastPhrase", lastSearch).toString();

	QDateTime today = QDateTime::currentDateTime();
	QString todaytext = today.toString("yyyyMMdd");
	
// Read all the settings->
	isAutoSave = settings->value("AutoSave", false).toBool();
	isFlowMode = settings->value("FlowMode", false).toBool();
	isSound = settings->value("Sound", true).toBool();
	isPageCount = settings->value("PageCount", false).toBool();
	isCharacterCount = settings->value("CharacterCount", false).toBool();
	deadlinetext = settings->value("Deadline", todaytext).toString();
	deadline = QDate::fromString(deadlinetext, "yyyyMMdd");
	wordcount = settings->value("WordCount", 0).toInt();
	editorWidth = settings->value("EditorWidth", 800).toInt();
	editorTopSpace = settings->value("EditorTopSpace", 0).toInt();
	editorBottomSpace = settings->value("EditorBottomSpace", 0).toInt();
	alarm = settings->value("TimedWriting", 0).toInt();
	pageCountFormula = settings->value("PageCountFormula", 250).toInt();
	dateFormat = settings->value("DateFormat", "d MMMM yyyy dddd").toString();
	timeFormatBool = settings->value("24-Hour", true ).toBool();
	defaultDir = settings->value("DefaultDirectory", QDir::homePath()).toString();
	backgroundImage = settings->value("BackgroundImage", "").toString();
	isPlainText = settings->value("PlainText", false).toBool();
	language = settings->value("LanguageName", "en_US").toString();
	indentValue = settings->value("Indent", 50).toInt();
        paragraphSpacing = settings->value("ParagraphSpacing", 20).toInt();
        tabStopWidth = settings->value("TabStopWidth", 80).toInt();
	cursorWidth = settings->value("CursorWidth", 3).toInt();

        textEdit->setLayoutDirection(Qt::LayoutDirectionAuto);
        textEdit->setTabStopWidth(tabStopWidth);
	textEdit->setCursorWidth(cursorWidth);

	loadStyleSheet(foregroundColor, back, status_c);
	textEdit->setMaximumWidth(editorWidth);

	textEdit->document()->blockSignals(true);
	bool modified = textEdit->document()->isModified();
	if ( isPlainText )
	{
		QString text( textEdit->document()->toPlainText() );
		textEdit->document()->clear();
		textEdit->insertPlainText(text);
		textEdit->setAcceptRichText( false );
	}
	else
	{
		textEdit->setAcceptRichText( true );
	}

	indentLines(indentValue);

	setWindowModified(modified);
	textEdit->document()->setModified(modified);
	textEdit->document()->blockSignals(false);

	if ( timeFormatBool )
	{
		timeFormat = "h:mm";
	}
	else
	{
		timeFormat = "h:mm AP";
	}

	horizontalSlider->setVisible( settings->value("ScrollBar", true).toBool() );
	isScrollBarVisible = horizontalSlider->isVisible();
	vPositionChanged();

	topSpacer->changeSize(20, editorTopSpace, QSizePolicy::Maximum, QSizePolicy::Maximum);
	bottomSpacer->changeSize(20, editorBottomSpace, QSizePolicy::Maximum, QSizePolicy::Maximum);
	
	timeOut = alarm * 60000;
	if (alarm != 0)
	{
		QTimer::singleShot(timeOut, this, SLOT(alarmTime()));
	}
	
	if ( (optOpenLastFile = settings->value("RecentFiles/OpenLastFile", true).toBool()) )
	{
		curFile = settings->value("RecentFiles/LastFile", curFile).toString();
		if ( (isSaveCursor = settings->value("RecentFiles/SavePosition", true).toBool() ))
			cPosition = settings->value("RecentFiles/AtPosition", cPosition).toInt();
	}

	wordCountChanged = true;
	getFileStatus();
	sCursor();
}
예제 #21
0
int InputThreadEntryPoint(void *data) {
  SDL_Event event;
  SDL_Joystick *js;
  int num_js, i;

  char *threadname;

  threadname = (char *) data;


  /* by default keyboard repeat is disabled in SDL 
     use SDL_EnableKeyrepeat(delay, rate) to enable it */
  /* SDL_EnableKeyRepeat(350, 30); */
  
  num_js = SDL_NumJoysticks();
  if (num_js == 0) {
    fprintf(stderr, "No joysticks were detected.\n");
    myExit (-20);
  } /* if */

  js = SDL_JoystickOpen(0);
  if (js == NULL) {
    fprintf(stderr, "Unable to open joystick: %s\n.", SDL_GetError());
    myExit (-20);
  } /* if */

  while((!exit_flag) && (SDL_WaitEvent(&event) != 0)) {
    SDL_keysym keysym;
    
    /* SDL_WaitEvent has filled in our event structure with the next event.
       We check its type field to find out what has happened */
    
    switch(event.type) {
    case SDL_JOYAXISMOTION:
      if ((event.jaxis.which == 0) && (event.jaxis.axis <2))
	movePlayer(event.jaxis.axis, event.jaxis.value);
      break;
      
    case SDL_JOYBUTTONUP:
      break;

    case SDL_JOYBUTTONDOWN:
      if (event.jbutton.which == 0)
	switch(event.jbutton.button) {
	case 0:
	  delLetter();
	  break;
	case 2:
	  fireShot();
	  break;
	case 3:
	  scoreWord();
	  break;
	} /* switch */
      break;

    case SDL_KEYDOWN:
      keysym = event.key.keysym;

      /* toggle full screen mode */
      if (keysym.sym == SDLK_f) {
	fprintf(stderr, "'F' pressed, toggling fullscreen.\n");
	toggleFullScreen();
      } /* if */

      /* would you like a zombie? */
      if (keysym.sym == SDLK_z) {
	fprintf(stderr, "'Z' pressed, sending in a zombie.\n");
	newZombie();
      } /* if */
      
      /* did the user press the Q key? */
      if (keysym.sym == SDLK_q) {
	fprintf(stderr, "'Q' pressed, exiting.\n");
	myExit(0);
      } /* if */
      break;
      
    case SDL_KEYUP:
      break;
      
    case SDL_QUIT:
      fprintf(stderr, "Quit event. Bye.\n");
      exit_flag = 1;
      break;
    } /* switch */
  } /* while */
  SDL_JoystickClose(js);
  fprintf(stderr, "%s is now exiting.\n", threadname);
  
  myExit(1);
} /* InputThreadEntryPoint */
예제 #22
0
/**
 * function adds and set necessary widgets to main layout
 * @param mainLayout
 */
void MediaApp::createUI(QBoxLayout *mainLayout) {
    QVBoxLayout* appLayout = new QVBoxLayout;
    appLayout->setContentsMargins(0, 0, 0, 0);
    appLayout->addWidget(m_player);

    m_positionLabel = new QLabel();

    m_positionSlider = new QSlider(Qt::Horizontal);
    m_positionSlider->setTickPosition(QSlider::TicksBelow);
    m_positionSlider->setTickInterval(10);
    m_positionSlider->setMaximum(1000);

    connect(m_positionSlider, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int)));

    m_volumeSlider = new VolumeSlider(Qt::Horizontal);
    m_volumeSlider->setTickPosition(QSlider::TicksLeft);
    m_volumeSlider->setTickInterval(2);
    m_volumeSlider->setMaximum(10);
    m_volumeSlider->setMaximumSize(54, 22);

    connect(m_volumeSlider, SIGNAL(sliderMoved(int)), m_player, SLOT(setVolume(int)));

    QGridLayout* posLayout = new QGridLayout;
    posLayout->setContentsMargins(2, 0, 2, 0);
    posLayout->addWidget(m_positionLabel, 1, 0);
    posLayout->addWidget(m_positionSlider, 1, 1, 1, 2);
    appLayout->addLayout(posLayout);

    QHBoxLayout* btnLayout = new QHBoxLayout();
    btnLayout->addStretch();

    m_openButton = initButton(QStyle::SP_DialogOpenButton, tr("Open File"), this, SLOT(open()), btnLayout);
    m_prevButton = initButton(QStyle::SP_MediaSkipBackward, tr("Prev"), this, SLOT(prev()), btnLayout);
    m_playButton = initButton(QStyle::SP_MediaPlay, tr("Play"), m_player, SLOT(play()), btnLayout);
    m_pauseButton = initButton(QStyle::SP_MediaPause, tr("Pause"), m_player, SLOT(pause()), btnLayout);
    m_stopButton = initButton(QStyle::SP_MediaStop, tr("Stop"), m_player, SLOT(stop()), btnLayout);
    m_nextButton = initButton(QStyle::SP_MediaSkipForward, tr("Next"), this, SLOT(next()), btnLayout);
    m_openLibrary = initButton(QStyle::SP_DriveNetIcon, tr("Open Library"), this, SLOT(openLibrary()), btnLayout);
    m_fullScreenButton = initButton(QStyle::SP_TitleBarMaxButton, tr("Fullscreen"), this, SLOT(toggleFullScreen()), btnLayout);

    btnLayout->addStretch();

    m_volumeLabel = new QLabel();
    m_volumeLabel->setPixmap(style()->standardIcon(QStyle::SP_MediaVolume).pixmap(QSize(22, 22), QIcon::Normal, QIcon::On));

    btnLayout->addWidget(m_volumeLabel);
    btnLayout->addWidget(m_volumeSlider);

    appLayout->addLayout(btnLayout);
    mainLayout->addLayout(appLayout);
    m_playlist->setMaximumWidth(300);
    mainLayout->addWidget(m_playlist);
}
예제 #23
0
void VlcWidget::mouseDoubleClickEvent (QMouseEvent *event)
{
    toggleFullScreen ();
    event->accept ();
}
예제 #24
0
파일: Adapter.cpp 프로젝트: lorichen/xgame
// 在两个分辨间切换
// 返回:窗口模式返回TRUE,否则返回FALSE
bool Adapter::toggleMode(void* hwnd,bool bFullScreen,uint nWidth, uint nHeight, uint nColorDepth, uint nFrequency)
{
	static RECT mainRect;
	bool bOk = FALSE;

	RECT rc;
	GetClientRect((HWND)hwnd,&rc);
	DEVMODE dm;
	EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dm);

	if(m_bWndMode == !bFullScreen && nWidth == rc.right - rc.left && nHeight == rc.bottom - rc.top)
	{
		if(m_bWndMode)return true;
		else if(nColorDepth == dm.dmBitsPerPel && nFrequency == dm.dmDisplayFrequency)return true;
	}

	HWND hWnd = (HWND)hwnd;
	if(bFullScreen)
	{
		if(toggleFullScreen(nWidth,nHeight,nColorDepth,nFrequency))
		{
			GetWindowRect(hWnd,&mainRect);
			// remove the caption of the mainWnd:
			LONG style=::GetWindowLong(hWnd,GWL_STYLE);
			style &= ~WS_CAPTION;
			style &= ~WS_BORDER;
			style &= ~WS_SIZEBOX;
			::SetWindowLong(hWnd,GWL_STYLE,style);

			uint screenx=GetSystemMetrics(SM_CXSCREEN);
			uint screeny=GetSystemMetrics(SM_CYSCREEN);
			uint xTop = GetSystemMetrics(SM_CXDLGFRAME) + GetSystemMetrics(SM_CXBORDER) - 1;
			uint yTop = GetSystemMetrics(SM_CYDLGFRAME) + GetSystemMetrics(SM_CYBORDER) - 1;
			// resize:
			SetWindowPos(hWnd,NULL,/*-xTop*/0,/*-yTop*/0,screenx/*+8*/,screeny/*+8*/,SWP_NOZORDER);

			m_bWndMode = FALSE;
			bOk = TRUE;
		}
	}
	else
	{
		BOOL bOk = TRUE;
		if(!m_bWndMode)bOk = toggleBack();
		if(bOk)
		{
			LONG style=::GetWindowLong(hWnd,GWL_STYLE);
			style|=WS_CAPTION;
			style|=WS_BORDER;
			style|=WS_SIZEBOX;
			SetLastError(0);
			long l = ::SetWindowLong(hWnd,GWL_STYLE,style);
			DWORD dw = GetLastError();

			//MoveWindow(hWnd,mainRect.left,mainRect.top,mainRect.right - mainRect.left,mainRect.bottom - mainRect.top,TRUE);
			DWORD	dwScreenWidth=GetSystemMetrics(SM_CXSCREEN);
			DWORD	dwScreenHeight=GetSystemMetrics(SM_CYSCREEN);
			RECT rcWindow = {0,0,nWidth,nHeight};
			dw = GetWindowLong(hWnd,GWL_STYLE);
			HMENU h = GetMenu(hWnd);
			AdjustWindowRectEx(&rcWindow,GetWindowLong(hWnd,GWL_STYLE),GetMenu(hWnd) != 0,GetWindowLong(hWnd,GWL_EXSTYLE));
			rcWindow.right = rcWindow.right - rcWindow.left;
			rcWindow.bottom = rcWindow.bottom - rcWindow.top;
			rcWindow.left=(int)((int)dwScreenWidth-(int)rcWindow.right)/2;
			rcWindow.top=(int)((int)dwScreenHeight-(int)rcWindow.bottom)/2;
			rcWindow.right+=rcWindow.left;
			rcWindow.bottom+=rcWindow.top;
			
			MoveWindow(hWnd,rcWindow.left,rcWindow.top,rcWindow.right-rcWindow.left,rcWindow.bottom-rcWindow.top,TRUE);
			ShowWindow(hWnd,SW_SHOWNORMAL);	
			UpdateWindow(hWnd);

			m_bWndMode = TRUE;
			bOk = TRUE;
		}
	}
	return m_bWndMode;
}
예제 #25
0
bool JokerWindow::eventFilter(QObject * sender, QEvent *event)
{
	/// The event filter catch the following event:
	switch (event->type()) {
	case QEvent::FileOpen: /// - FileOpen : To process a file dragged on the application dock icon (MacOS)
		{
#warning /// @todo move to PhDocumentWindow
			QString filePath = static_cast<QFileOpenEvent *>(event)->file();
			QString fileType = filePath.split(".").last().toLower();
			// As the plist file list all the supported format
			// if the file is not a strip file, it's a video file, we don't need any protection
			if(_settings->stripFileType().contains(fileType)) {
				if(checkSaveFile())
					openDocument(filePath);
			}
			else if(_settings->videoFileType().contains(fileType))
				openVideoFile(filePath);
			break;
		}
	case QEvent::ApplicationDeactivate: /// - ApplicationDeactivate : to hide the mediapanel
		hideMediaPanel();
		break;
	case QEvent::MouseMove: /// - Mouse move show the media panel
		{
			fadeInMediaPanel();

			// Check if it is near the video/strip border
			QMouseEvent * mouseEvent = (QMouseEvent*)event;
			if(_resizingStrip) {
				QApplication::setOverrideCursor(Qt::SizeVerCursor);
				if(mouseEvent->buttons() & Qt::LeftButton)
					_settings->setStripHeight(1.0 - ((float) mouseEvent->pos().y() /(float) this->height()));
			}
			else
				QApplication::setOverrideCursor(Qt::ArrowCursor);
			break;
		}
	case QEvent::DragEnter: /// - Accept and process a file drop on the window
		event->accept();
		break;
	case QEvent::Drop:
		{
#warning /// @todo move to PhDocumentWindow
			const QMimeData* mimeData = static_cast<QDropEvent *>(event)->mimeData();

			// If there is one file (not more) we open it
			if (mimeData->urls().length() == 1) {
				QString filePath = mimeData->urls().first().toLocalFile();
				QString fileType = filePath.split(".").last().toLower();
				if(fileType == "detx" or fileType == "strip" or fileType == "joker") {
					if(checkSaveFile())
						openDocument(filePath);
				}
				else if (fileType == "avi" or fileType == "mov")
					openVideoFile(filePath);
			}
			break;
		}
	case QEvent::MouseButtonDblClick: /// - Double mouse click toggle fullscreen mode
		_resizingStrip = false;
		if(sender == this)
			toggleFullScreen();
		break;
	case QEvent::MouseButtonRelease:
		QApplication::setOverrideCursor(Qt::ArrowCursor);
		break;
	case QEvent::MouseButtonPress:
		{
			QMouseEvent *mouseEvent = (QMouseEvent*)event;
			if((sender == this) && (mouseEvent->buttons() & Qt::RightButton)) {
				/// - Right mouse click on the video open the video file dialog.
				if(mouseEvent->y() < this->height() * (1.0f - _settings->stripHeight()))
					on_actionOpen_Video_triggered();
				else /// - Left mouse click on the strip open the strip file dialog.
					on_actionOpen_triggered();
				return true;
			}
			float stripHeight = this->height() * _settings->stripHeight();
			if((mouseEvent->pos().y() > (this->height() - stripHeight) - 10)
			   && (mouseEvent->pos().y() < (this->height() - stripHeight) + 10)) {
				QApplication::setOverrideCursor(Qt::SizeVerCursor);
				_resizingStrip = true;
			}
		}
	default:
		break;
	}

	return PhDocumentWindow::eventFilter(sender, event);
}
예제 #26
0
void Viewer::on_toggleFullScreenAction_triggered(bool)
{
    toggleFullScreen();
}
예제 #27
0
파일: pdfpres.c 프로젝트: betagram/pdfPres
static gboolean onKeyPressed(GtkWidget *widget, GdkEventKey *ev,
		gpointer data)
{
	/* Unused parameters. */
	(void)data;

	guint key = ev->keyval;
	gchar *msg = NULL;

	/* When inside the note pad, don't do anything here. */
	if (isInsideNotePad)
		return FALSE;

	/* Jump command?
	 *
	 * Note: This works as long as the values of GDK keysyms satisfy:
	 *   1)  GDK_0 < GDK_1 < GDK_2 < ... < GDK_9
	 *   2)  All of them must be >= 0.
	 */
	key -= GDK_0;
	if (key <= 9)
	{
		/* The initial value is -1, so we have to reset this on the
		 * first key stroke. */
		if (target_page < 0)
			target_page = 0;

		/* Do a "decimal left shift" and add the given value. */
		target_page *= 10;
		target_page += (int)key;

		/* Catch overflow and announce what would happen. */
		if (target_page < 0)
		{
			target_page = -1;
			setStatusText_strdup("Invalid page.");
		}
		else
		{
			msg = g_strdup_printf("Jump to page: %d", target_page);
			setStatusText_strdup(msg);
			g_free(msg);
		}

		return FALSE;
	}

	gboolean changed = TRUE;
	saveCurrentNote();

	switch (ev->keyval)
	{
		case GDK_Right:
		case GDK_Down:
		case GDK_Page_Down:
		case GDK_space:
			nextSlide();
			break;

		case GDK_Left:
		case GDK_Up:
		case GDK_Page_Up:
			prevSlide();
			break;

		case GDK_F5:
			/* Switch to fullscreen (if needed) and start the timer
			 * (unless it's already running). */
			if (!isFullScreen)
				toggleFullScreen();
			if (timerMode != 1)
				toggleTimer();
			break;

		case GDK_F6:
			/* this shall trigger a hard refresh, so empty the cache. */
			clearCache();
			break;

		case GDK_w:
			runpref.fit_mode = FIT_WIDTH;
			break;

		case GDK_h:
			runpref.fit_mode = FIT_HEIGHT;
			break;

		case GDK_p:
			runpref.fit_mode = FIT_PAGE;
			break;

		case GDK_l:
			current_fixate();
			break;

		case GDK_L:
			current_release(FALSE);
			break;

		case GDK_J:
			current_release(TRUE);
			break;

		case GDK_f:
			toggleFullScreen();
			break;

		case GDK_s:
			toggleTimer();
			changed = FALSE;
			break;

		case GDK_c:
			toggleCurserVisibility();
			break;

		case GDK_r:
			resetTimer();
			changed = FALSE;
			break;

		case GDK_Escape:
		case GDK_q:
			if (prefs.q_exits_fullscreen && isFullScreen)
			{
				toggleFullScreen();
				if (prefs.stop_timer_on_fs)
				{
					toggleTimer();
				}
			}
			else
			{
				changed = FALSE;
				onQuit(NULL, NULL, NULL);
			}
			break;

		case GDK_i:
			/* This must not work when we're on the beamer window. */
			if (widget != win_beamer)
				setEditingState(TRUE);

			changed = FALSE;
			break;

		case GDK_Return:
			if (executeJump() == 0)
				nextSlide();
			break;

		case GDK_G:
			executeJump();
			break;

		case GDK_period:
		case GDK_b:
			toggleBlankBeamer();
			changed = FALSE;
			break;

		default:
			changed = FALSE;
	}

	if (changed == TRUE)
	{
		refreshPorts();
	}

	return TRUE;
}
예제 #28
0
void ImageViewer::contextMenuEvent(QContextMenuEvent *event) {
  if (!m_flipbook) return;

  QAction *action;

  if (m_isColorModel) {
    event->ignore();
    return;
  }

  QMenu *menu = new QMenu(this);

  if (m_flipbook->getPreviewedFx()) {
    if (!(windowState() & Qt::WindowFullScreen)) {
      action = menu->addAction(tr("Clone Preview"));
      action->setShortcut(QKeySequence(
          CommandManager::instance()->getKeyFromId(MI_ClonePreview)));
      connect(action, SIGNAL(triggered()), m_flipbook, SLOT(clonePreview()));
    }

    if (m_flipbook->isFreezed()) {
      action = menu->addAction(tr("Unfreeze Preview"));
      action->setShortcut(QKeySequence(
          CommandManager::instance()->getKeyFromId(MI_FreezePreview)));
      connect(action, SIGNAL(triggered()), m_flipbook, SLOT(unfreezePreview()));
    } else {
      action = menu->addAction(tr("Freeze Preview"));
      action->setShortcut(QKeySequence(
          CommandManager::instance()->getKeyFromId(MI_FreezePreview)));
      connect(action, SIGNAL(triggered()), m_flipbook, SLOT(freezePreview()));
    }

    action = menu->addAction(tr("Regenerate Preview"));
    action->setShortcut(QKeySequence(
        CommandManager::instance()->getKeyFromId(MI_RegeneratePreview)));
    connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerate()));

    action = menu->addAction(tr("Regenerate Frame Preview"));
    action->setShortcut(QKeySequence(
        CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr)));
    connect(action, SIGNAL(triggered()), m_flipbook, SLOT(regenerateFrame()));

    menu->addSeparator();
  }

  action = menu->addAction(tr("Load / Append Images"));
  connect(action, SIGNAL(triggered()), m_flipbook, SLOT(loadImages()));

  // history of the loaded paths of flipbook
  action = CommandManager::instance()->getAction(MI_LoadRecentImage);
  menu->addAction(action);
  action->setParent(m_flipbook);

  if (m_flipbook->isSavable()) {
    action = menu->addAction(tr("Save Images"));
    connect(action, SIGNAL(triggered()), m_flipbook, SLOT(saveImages()));
  }
  menu->addSeparator();

  QAction *reset = menu->addAction(tr("Reset View"));
  reset->setShortcut(
      QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomReset)));
  connect(reset, SIGNAL(triggered()), SLOT(resetView()));

  QAction *fit = menu->addAction(tr("Fit To Window"));
  fit->setShortcut(
      QKeySequence(CommandManager::instance()->getKeyFromId(V_ZoomFit)));
  connect(fit, SIGNAL(triggered()), SLOT(fitView()));

#ifdef _WIN32

  if (ImageUtils::FullScreenWidget *fsWidget =
          dynamic_cast<ImageUtils::FullScreenWidget *>(parentWidget())) {
    bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0;

    action = menu->addAction(isFullScreen ? tr("Exit Full Screen Mode")
                                          : tr("Full Screen Mode"));

    action->setShortcut(QKeySequence(
        CommandManager::instance()->getKeyFromId(V_ShowHideFullScreen)));
    connect(action, SIGNAL(triggered()), fsWidget, SLOT(toggleFullScreen()));
  }

#endif

  bool addedSep = false;

  if (m_isHistogramEnable &&
      visibleRegion().contains(event->pos() * getDevPixRatio())) {
    menu->addSeparator();
    addedSep = true;
    action   = menu->addAction(tr("Show Histogram"));
    connect(action, SIGNAL(triggered()), SLOT(showHistogram()));
  }

  if (m_visualSettings.m_doCompare) {
    if (!addedSep) menu->addSeparator();
    action = menu->addAction(tr("Swap Compared Images"));
    connect(action, SIGNAL(triggered()), SLOT(swapCompared()));
  }

  menu->exec(event->globalPos());

  action = CommandManager::instance()->getAction(MI_LoadRecentImage);
  action->setParent(0);

  delete menu;
  update();
}
예제 #29
0
int QGLViewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGLWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: viewerInitialized(); break;
        case 1: drawNeeded(); break;
        case 2: drawFinished((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 3: animateNeeded(); break;
        case 4: helpRequired(); break;
        case 5: axisIsDrawnChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: gridIsDrawnChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 7: FPSIsDisplayedChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 8: textIsEnabledChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 9: cameraIsEditedChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 10: stereoChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 11: pointSelected((*reinterpret_cast< const QMouseEvent*(*)>(_a[1]))); break;
        case 12: mouseGrabberChanged((*reinterpret_cast< qglviewer::MouseGrabber*(*)>(_a[1]))); break;
        case 13: setAxisIsDrawn((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 14: setAxisIsDrawn(); break;
        case 15: setGridIsDrawn((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 16: setGridIsDrawn(); break;
        case 17: setFPSIsDisplayed((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 18: setFPSIsDisplayed(); break;
        case 19: setTextIsEnabled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 20: setTextIsEnabled(); break;
        case 21: setCameraIsEdited((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 22: setCameraIsEdited(); break;
        case 23: toggleAxisIsDrawn(); break;
        case 24: toggleGridIsDrawn(); break;
        case 25: toggleFPSIsDisplayed(); break;
        case 26: toggleTextIsEnabled(); break;
        case 27: toggleCameraIsEdited(); break;
        case 28: setBackgroundColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break;
        case 29: setForegroundColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break;
        case 30: setSceneRadius((*reinterpret_cast< float(*)>(_a[1]))); break;
        case 31: setSceneCenter((*reinterpret_cast< const qglviewer::Vec(*)>(_a[1]))); break;
        case 32: setSceneBoundingBox((*reinterpret_cast< const qglviewer::Vec(*)>(_a[1])),(*reinterpret_cast< const qglviewer::Vec(*)>(_a[2]))); break;
        case 33: showEntireScene(); break;
        case 34: setCamera((*reinterpret_cast< qglviewer::Camera*const(*)>(_a[1]))); break;
        case 35: setManipulatedFrame((*reinterpret_cast< qglviewer::ManipulatedFrame*(*)>(_a[1]))); break;
        case 36: setMouseGrabber((*reinterpret_cast< qglviewer::MouseGrabber*(*)>(_a[1]))); break;
        case 37: setFullScreen((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 38: setFullScreen(); break;
        case 39: setStereoDisplay((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 40: setStereoDisplay(); break;
        case 41: toggleFullScreen(); break;
        case 42: toggleStereoDisplay(); break;
        case 43: toggleCameraMode(); break;
        case 44: saveSnapshot((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 45: saveSnapshot((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 46: saveSnapshot(); break;
        case 47: saveSnapshot((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 48: saveSnapshot((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 49: setSnapshotFileName((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 50: setSnapshotFormat((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 51: setSnapshotCounter((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 52: setSnapshotQuality((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 53: { bool _r = openSnapshotFormatDialog();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 54: snapshotToClipboard(); break;
        case 55: copyBufferToTexture((*reinterpret_cast< GLint(*)>(_a[1])),(*reinterpret_cast< GLenum(*)>(_a[2]))); break;
        case 56: copyBufferToTexture((*reinterpret_cast< GLint(*)>(_a[1]))); break;
        case 57: setAnimationPeriod((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 58: startAnimation(); break;
        case 59: stopAnimation(); break;
        case 60: animate(); break;
        case 61: toggleAnimation(); break;
        case 62: help(); break;
        case 63: aboutQGLViewer(); break;
        case 64: select((*reinterpret_cast< const QMouseEvent*(*)>(_a[1]))); break;
        case 65: select((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 66: setSelectBufferSize((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 67: setSelectRegionWidth((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 68: setSelectRegionHeight((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 69: setSelectedName((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 70: setShortcut((*reinterpret_cast< KeyboardAction(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 71: setKeyboardAccelerator((*reinterpret_cast< KeyboardAction(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 72: setKeyDescription((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 73: setKeyFrameKey((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 74: setPlayKeyFramePathStateKey((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 75: setPlayPathStateKey((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 76: setAddKeyFrameStateKey((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 77: setPathKey((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 78: setPathKey((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 79: setPlayPathKeyboardModifiers((*reinterpret_cast< QtKeyboardModifiers(*)>(_a[1]))); break;
        case 80: setAddKeyFrameKeyboardModifiers((*reinterpret_cast< QtKeyboardModifiers(*)>(_a[1]))); break;
        case 81: setMouseBinding((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< MouseHandler(*)>(_a[2])),(*reinterpret_cast< MouseAction(*)>(_a[3])),(*reinterpret_cast< bool(*)>(_a[4]))); break;
        case 82: setMouseBinding((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< MouseHandler(*)>(_a[2])),(*reinterpret_cast< MouseAction(*)>(_a[3]))); break;
        case 83: setWheelBinding((*reinterpret_cast< QtKeyboardModifiers(*)>(_a[1])),(*reinterpret_cast< MouseHandler(*)>(_a[2])),(*reinterpret_cast< MouseAction(*)>(_a[3])),(*reinterpret_cast< bool(*)>(_a[4]))); break;
        case 84: setWheelBinding((*reinterpret_cast< QtKeyboardModifiers(*)>(_a[1])),(*reinterpret_cast< MouseHandler(*)>(_a[2])),(*reinterpret_cast< MouseAction(*)>(_a[3]))); break;
        case 85: setHandlerKeyboardModifiers((*reinterpret_cast< MouseHandler(*)>(_a[1])),(*reinterpret_cast< QtKeyboardModifiers(*)>(_a[2]))); break;
        case 86: setHandlerStateKey((*reinterpret_cast< MouseHandler(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 87: setMouseStateKey((*reinterpret_cast< MouseHandler(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 88: initFromDOMElement((*reinterpret_cast< const QDomElement(*)>(_a[1]))); break;
        case 89: saveStateToFile(); break;
        case 90: { bool _r = restoreStateFromFile();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 91: setStateFileName((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 92: saveToFile((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 93: saveToFile(); break;
        case 94: { bool _r = restoreFromFile((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 95: { bool _r = restoreFromFile();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 96: resetVisualHints(); break;
        case 97: delayedFullScreen(); break;
        case 98: hideMessage(); break;
        default: ;
        }
        _id -= 99;
    }
    return _id;
}
예제 #30
0
LiveViewWindow::LiveViewWindow(DVRServerRepository *serverRepository, QWidget *parent, bool openfs, Qt::WindowFlags f)
    : QWidget(parent, f), m_liveView(0), m_serverRepository(serverRepository), m_savedLayouts(new QComboBox),
      m_lastLayoutIndex(-1), m_autoSized(false), m_isLayoutChanging(false),
	  m_wasOpenedFs(openfs)
{
    QBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);

	m_toolBar = new QToolBar(tr("Live View"));
	m_toolBar->setIconSize(QSize(16, 16));
	m_toolBar->setMovable(false);

#ifndef Q_OS_MAC
    //toolBar->setStyleSheet(QLatin1String("QToolBar { border: none; }"));
#endif

    m_liveView = new LiveViewArea(m_serverRepository);
    LiveViewLayout *viewLayout = m_liveView->layout();

    /* Saved layouts box */
    m_savedLayouts->setModel(SavedLayoutsModel::instance());
    m_savedLayouts->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    m_savedLayouts->setInsertPolicy(QComboBox::NoInsert);
    m_savedLayouts->setMinimumWidth(100);
    m_savedLayouts->setContextMenuPolicy(Qt::CustomContextMenu);
    m_savedLayouts->setCurrentIndex(-1);
    m_savedLayouts->setMaxVisibleItems(22);
	m_toolBar->addWidget(m_savedLayouts);

    QWidget *spacer = new QWidget;
    spacer->setFixedWidth(20);
	m_toolBar->addWidget(spacer);

	aNewLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/plus.png")), tr("New Layout"), this, SLOT(createNewLayout()));
	aRenameLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/pencil.png")), tr("Rename Layout"), this, SLOT(renameLayout()));
	aDelLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/cross.png")), tr("Delete Layout"), this, SLOT(deleteCurrentLayout()));

    aRenameLayout->setEnabled(false);
    aDelLayout->setEnabled(false);

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

    connect(m_savedLayouts, SIGNAL(currentIndexChanged(int)), SLOT(savedLayoutChanged(int)));
    connect(m_savedLayouts, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showLayoutMenu(QPoint)));

	m_addRowAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-split-vertical.png")),
                     tr("Add Row"), viewLayout, SLOT(appendRow()));
	m_removeRowAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-join-vertical.png")),
                        tr("Remove Row"), viewLayout, SLOT(removeRow()));

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

	m_addColumnAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-split.png")),
                        tr("Add Column"), viewLayout, SLOT(appendColumn()));
	m_removeColumnAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-join.png")),
                           tr("Remove Column"), viewLayout, SLOT(removeColumn()));

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

    QSignalMapper *mapper = new QSignalMapper(this);
    connect(mapper, SIGNAL(mapped(int)), viewLayout, SLOT(setGridSize(int)));

	m_singleAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout.png")),
                                    tr("Single"), mapper, SLOT(map()));
	mapper->setMapping(m_singleAction, 1);
	QAction *a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-4.png")),
                           tr("2x2"), mapper, SLOT(map()));
    mapper->setMapping(a, 2);
	a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-9.png")),
                           tr("3x3"), mapper, SLOT(map()));
    mapper->setMapping(a, 3);
	a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-16.png")),
                           tr("4x4"), mapper, SLOT(map()));
    mapper->setMapping(a, 4);

    spacer = new QWidget;
    spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
	m_toolBar->addWidget(spacer);

	m_fullscreenAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/application-resize-full.png")),
                       tr("Fullscreen"), this, SLOT(toggleFullScreen()));
	m_fullscreenAction->setShortcut(Qt::Key_F11);

    if (m_wasOpenedFs)
    {
		m_closeAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/cross.png")), tr("Exit"),
                           this, SLOT(close()));
        new QShortcut(Qt::Key_Escape, this, SLOT(close()), 0, Qt::WindowShortcut);
    }
    else
        new QShortcut(Qt::Key_Escape, this, SLOT(exitFullScreen()), 0, Qt::WindowShortcut);

    connect(m_liveView->layout(), SIGNAL(layoutChanged()), SLOT(updateLayoutActionStates()));
    connect(m_liveView->layout(), SIGNAL(layoutChanged()), SLOT(saveLayout()));

    QMainWindow *wnd = qobject_cast<QMainWindow*>(window());
    if (wnd)
		wnd->addToolBar(Qt::TopToolBarArea, m_toolBar);
    else
		layout->addWidget(m_toolBar);
    layout->addWidget(m_liveView);

    updateLayoutActionStates();
}