예제 #1
0
파일: mdb.c 프로젝트: varphone/appweb-4
static int mdbChangeColumn(Edi *edi, cchar *tableName, cchar *columnName, int type, int flags)
{
    Mdb         *mdb;
    MdbTable    *table;
    MdbCol      *col;

    mprAssert(edi);
    mprAssert(tableName && *tableName);
    mprAssert(columnName && *columnName);
    mprAssert(type);

    mdb = (Mdb*) edi;
    lock(mdb);
    if ((table = lookupTable(mdb, tableName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    if ((col = lookupColumn(table, columnName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    col->name = sclone(columnName);
    col->type = type;
    autoSave(mdb, table);
    unlock(mdb);
    return 0;
}
예제 #2
0
파일: mdb.c 프로젝트: varphone/appweb-4
static int mdbAddTable(Edi *edi, cchar *tableName)
{
    Mdb         *mdb;
    MdbTable    *table;

    mprAssert(edi);
    mprAssert(tableName && *tableName);

    mdb = (Mdb*) edi;
    lock(mdb);
    if ((table = lookupTable(mdb, tableName)) != 0) {
        unlock(mdb);
        return MPR_ERR_ALREADY_EXISTS;
    }
    if ((table = mprAllocObj(MdbTable, manageTable)) == 0) {
        unlock(mdb);
        return MPR_ERR_MEMORY;
    }
    if ((table->rows = mprCreateList(0, 0)) == 0) {
        unlock(mdb);
        return MPR_ERR_MEMORY;
    }
    table->name = sclone(tableName);
    if (mdb->tables == 0) {
        mdb->tables = mprCreateList(0, 0);
    }
    if (!growSchema(table)) {
        unlock(mdb);
        return MPR_ERR_MEMORY;
    }
    mprAddItem(mdb->tables, table);
    autoSave(mdb, lookupTable(mdb, tableName));
    unlock(mdb);
    return 0;
}
예제 #3
0
파일: mdb.c 프로젝트: varphone/appweb-4
static int mdbDeleteRow(Edi *edi, cchar *tableName, cchar *key)
{
    Mdb         *mdb;
    MdbTable    *table;
    int         r, rc;

    mprAssert(edi);
    mprAssert(tableName && *tableName);
    mprAssert(key && *key);

    mdb = (Mdb*) edi;
    lock(mdb);
    if ((table = lookupTable(mdb, tableName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    if ((r = lookupRow(table, key)) < 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    rc = mprRemoveItemAtPos(table->rows, r);
    if (table->index) {
        mprRemoveKey(table->index, key);
    }
    autoSave(mdb, table);
    unlock(mdb);
    return rc;
}
예제 #4
0
void TextRoom::documentWasModified()
{
// If document is modified, do stuff.
	setWindowModified(textEdit->document()->isModified());
	
	parasnew = textEdit->document()->blockCount();

	if (isAutoSave && numChanges++ > 200) {
		numChanges = 0;	
		autoSave();
	} 

	if ( isFlowMode && textEdit->document()->toPlainText().size() < prevLength ) {
		textEdit->undo();
	} 

	prevLength=textEdit->document()->toPlainText().size();

// If a new paragraph created, play keyenter, else play keyany.
	if (parasnew > parasold)
	{ playSound(soundenter); }
	else
	{ playSound(soundany);}

	parasold = parasnew;

	vPositionChanged();

	wordCountChanged = true;
}
예제 #5
0
TrackRecorder::TrackRecorder(QObject *parent) :
    QObject(parent)
{
    qDebug()<<"TrackRecorder constructor";
    m_distance = 0.0;
    m_accuracy = -1;
    m_tracking = false;
    m_isEmpty = true;
    m_applicationActive = true;
    m_autoSavePosition = 0;

    // Load autosaved track if left from previous session
    loadAutoSave();

    // Setup periodic autosave
    m_autoSaveTimer.setInterval(60000);
    connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));
    m_autoSaveTimer.start();

    m_posSrc = QGeoPositionInfoSource::createDefaultSource(0);
    if (m_posSrc) {
        m_posSrc->setUpdateInterval(1000);
        connect(m_posSrc, SIGNAL(positionUpdated(QGeoPositionInfo)),
                this, SLOT(positionUpdated(QGeoPositionInfo)));
        connect(m_posSrc, SIGNAL(error(QGeoPositionInfoSource::Error)),
                this, SLOT(positioningError(QGeoPositionInfoSource::Error)));
        // Position updates are started/stopped in setIsTracking(...)
    } else {
        qDebug()<<"Failed initializing PositionInfoSource!";
    }
}
예제 #6
0
파일: mdb.c 프로젝트: varphone/appweb-4
static int mdbAddColumn(Edi *edi, cchar *tableName, cchar *columnName, int type, int flags)
{
    Mdb         *mdb;
    MdbTable    *table;
    MdbCol      *col;

    mprAssert(edi);
    mprAssert(tableName && *tableName);
    mprAssert(columnName && *columnName);
    mprAssert(type);

    mdb = (Mdb*) edi;
    lock(mdb);
    if ((table = lookupTable(mdb, tableName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    if ((col = lookupColumn(table, columnName)) != 0) {
        unlock(mdb);
        return MPR_ERR_ALREADY_EXISTS;
    }
    if ((col = createCol(table, columnName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    col->type = type;
    col->flags = flags;
    autoSave(mdb, table);
    unlock(mdb);
    return 0;
}
예제 #7
0
파일: mdb.c 프로젝트: varphone/appweb-4
/*
    IndexName is not implemented yet
 */
static int mdbAddIndex(Edi *edi, cchar *tableName, cchar *columnName, cchar *indexName)
{
    Mdb         *mdb;
    MdbTable    *table;
    MdbCol      *col;

    mprAssert(edi);
    mprAssert(tableName && *tableName);
    mprAssert(columnName && *columnName);

    mdb = (Mdb*) edi;
    lock(mdb);
    if ((table = lookupTable(mdb, tableName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    if ((col = lookupColumn(table, columnName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    if ((table->index = mprCreateHash(0, MPR_HASH_STATIC_VALUES)) == 0) {
        unlock(mdb);
        return MPR_ERR_MEMORY;
    }
    table->indexCol = col;
    col->flags |= EDI_INDEX;
    autoSave(mdb, table);
    unlock(mdb);
    return 0;
}
예제 #8
0
OlvisExecGuiPlugin::OlvisExecGuiPlugin()
{
    mInterface = 0;
    mHilec = 0;
    connect(this, SIGNAL(pluginsWriteConfigReq(QXmlStreamWriter&)), SLOT(writeXmlConfig(QXmlStreamWriter&)), Qt::DirectConnection);
    connect(this, SIGNAL(pluginsReadConfigReq(QString)), SLOT(readXmlConfig(QString)), Qt::DirectConnection);
    mTimer.setInterval(5000);
    connect(&mTimer, SIGNAL(timeout()), SLOT(autoSave()));
}
예제 #9
0
void Core::checkAutoSave(bool first)
{
    if (_conf->getAutoSave())
    {
        // hack
        if (first)
        {
            if (_conf->getAutoSaveFirst())
                QTimer::singleShot(600, this, SLOT(autoSave()));
        }
        else
            autoSave();
    }
    else
    {
        if (!first)
        {
            StateNotifyMessage message(tr("New screen"), tr("New screen is getted!"));
            sendNotify(message);
        }
    }
}
예제 #10
0
KPROXY_API f8_int kproxy_shell_ex(
	const char * cmd, 
	__uint timeout, 
	void * reserved
	)
{
	f8_uuid	oldUuid;
	struct proxy_shell_param psp;
	int code;
	CArgsExA a;
	int i;

	oldUuid = sections->h.uuid;
	a.parse(cmd, ";", 256, strlen(cmd) + 1, __true);
	for(i=0; i<a.argc; i++){
		psp.timeout = timeout;	
		if(!shell_execute_ex(g_shell, a.argv[i], &psp, &code)){
			code = F8_UNKNOWN_COMMAND;
		}
	}
	
	if(F8_FAILED(code)){
		utils_error(
			"<* PROXY_SHELL:`%s' returns %d(%s) *>\n", 
			cmd, 
			code, 
			_errmsg(code)
			);
	}else if(!proxy_silent){
		utils_debug(
			"<* PROXY_SHELL:`%s' returns %d(%s) *>\n", 
			cmd,
			code, 
			_errmsg(code)
			);
	}

/* if executing inside on_play(), no autosave is made as that will
degrade performance */
	if(!proxy_silent)
		autoSave(0,0);
	
	if(oldUuid != sections->h.uuid){
		move_resource(&oldUuid, &sections->h.uuid);
	}
	
	return code;
}
예제 #11
0
//================================================//
//
//================================================//
GameScene::GameScene(int width, int height, QGraphicsView *parent)
    :QGraphicsScene(parent)
    ,maxRenderLen(15)
    ,gView(parent)
    ,inSence(false)
{
    setSceneRect(0,0,width,height);
    initGame();
    lastTime=QTime::currentTime();
    saveTime=lastTime;

    QTimer *timer=new QTimer;
    timer->setInterval(10);
    connect(timer,SIGNAL(timeout()),this,SLOT(update()));
    connect(timer,SIGNAL(timeout()),camera,SLOT(cMove()));
    connect(timer,SIGNAL(timeout()),world,SLOT(updateDraw()),Qt::DirectConnection);         //在主线程中执行
    connect(timer,SIGNAL(timeout()),this,SLOT(mouseMove()));
    connect(timer,SIGNAL(timeout()),this,SLOT(handleGameMessage()));
    connect(timer,SIGNAL(timeout()),this,SLOT(autoSave()));                                                     //
    timer->start();
}
예제 #12
0
파일: mdb.c 프로젝트: doghell/appweb-4
static int mdbAddColumn(Edi *edi, cchar *tableName, cchar *columnName, int type, int flags)
{
    Mdb         *mdb;
    MdbTable    *table;
    MdbCol      *col;

    assert(edi);
    assert(tableName && *tableName);
    assert(columnName && *columnName);
    assert(type);

    mdb = (Mdb*) edi;
    lock(mdb);
    if ((table = lookupTable(mdb, tableName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    if ((col = lookupColumn(table, columnName)) != 0) {
        unlock(mdb);
        return MPR_ERR_ALREADY_EXISTS;
    }
    if ((col = createCol(table, columnName)) == 0) {
        unlock(mdb);
        return MPR_ERR_CANT_FIND;
    }
    col->type = type;
    col->flags = flags;
    if (flags & EDI_INDEX) {
        if (table->index) {
            mprError("Index already specified in table %s, replacing.", tableName);
        }
        if ((table->index = mprCreateHash(0, MPR_HASH_STATIC_VALUES)) != 0) {
            table->indexCol = col;
        }
    }
    autoSave(mdb, table);
    unlock(mdb);
    return 0;

}
예제 #13
0
void VideoCapture::start()
{
    emit frameAvailable(frame); //TODO: no copy
    if (!frame.isValid() || !frame.constBits(0)) { // if frame is always cloned, then size is at least width*height
        qDebug("Captured frame from hardware decoder surface.");
    }
    CaptureTask *task = new CaptureTask(this);
    // copy properties so the task will not be affect even if VideoCapture properties changed
    task->save = autoSave();
    task->original_fmt = original_fmt;
    task->quality = qual;
    task->dir = dir;
    task->name = name;
    task->format = fmt;
    task->qfmt = qfmt;
    task->frame = frame; //copy here and it's safe in capture thread because start() is called immediatly after setVideoFrame
    if (isAsync()) {
        videoCaptureThreadPool()->start(task);
    } else {
        task->run();
        delete task;
    }
}
예제 #14
0
MainWindow::MainWindow() :
	m_workspace( NULL ),
	m_templatesMenu( NULL ),
	m_recentlyOpenedProjectsMenu( NULL ),
	m_toolsMenu( NULL ),
	m_autoSaveTimer( this ),
	m_viewMenu( NULL ),
	m_metronomeToggle( 0 ),
	m_session( Normal )
{
	setAttribute( Qt::WA_DeleteOnClose );

	QWidget * main_widget = new QWidget( this );
	QVBoxLayout * vbox = new QVBoxLayout( main_widget );
	vbox->setSpacing( 0 );
	vbox->setMargin( 0 );

	QWidget * w = new QWidget( main_widget );
	QHBoxLayout * hbox = new QHBoxLayout( w );
	hbox->setSpacing( 0 );
	hbox->setMargin( 0 );

	SideBar * sideBar = new SideBar( Qt::Vertical, w );

	QSplitter * splitter = new QSplitter( Qt::Horizontal, w );
	splitter->setChildrenCollapsible( false );

	ConfigManager* confMgr = ConfigManager::inst();

	emit initProgress(tr("Preparing plugin browser"));
	sideBar->appendTab( new PluginBrowser( splitter ) );
	emit initProgress(tr("Preparing file browsers"));
	sideBar->appendTab( new FileBrowser(
				confMgr->userProjectsDir() + "*" +
				confMgr->factoryProjectsDir(),
					"*.mmp *.mmpz *.xml *.mid",
							tr( "My Projects" ),
					embed::getIconPixmap( "project_file" ).transformed( QTransform().rotate( 90 ) ),
							splitter, false, true ) );
	sideBar->appendTab( new FileBrowser(
				confMgr->userSamplesDir() + "*" +
				confMgr->factorySamplesDir(),
					"*", tr( "My Samples" ),
					embed::getIconPixmap( "sample_file" ).transformed( QTransform().rotate( 90 ) ),
							splitter, false, true ) );
	sideBar->appendTab( new FileBrowser(
				confMgr->userPresetsDir() + "*" +
				confMgr->factoryPresetsDir(),
					"*.xpf *.cs.xml *.xiz",
					tr( "My Presets" ),
					embed::getIconPixmap( "preset_file" ).transformed( QTransform().rotate( 90 ) ),
							splitter , false, true  ) );
	sideBar->appendTab( new FileBrowser( QDir::homePath(), "*",
							tr( "My Home" ),
					embed::getIconPixmap( "home" ).transformed( QTransform().rotate( 90 ) ),
							splitter, false, false ) );


	QStringList root_paths;
	QString title = tr( "Root directory" );
	bool dirs_as_items = false;

#ifdef LMMS_BUILD_APPLE
	title = tr( "Volumes" );
	root_paths += "/Volumes";
#elif defined(LMMS_BUILD_WIN32)
	title = tr( "My Computer" );
	dirs_as_items = true;
#endif

#if ! defined(LMMS_BUILD_APPLE)
	QFileInfoList drives = QDir::drives();
	for( const QFileInfo & drive : drives )
	{
		root_paths += drive.absolutePath();
	}
#endif

	sideBar->appendTab( new FileBrowser( root_paths.join( "*" ), "*", title,
					embed::getIconPixmap( "computer" ).transformed( QTransform().rotate( 90 ) ),
							splitter, dirs_as_items) );

	m_workspace = new QMdiArea( splitter );

	// Load background
	emit initProgress(tr("Loading background artwork"));
	QString bgArtwork = ConfigManager::inst()->backgroundArtwork();
	QImage bgImage;
	if( !bgArtwork.isEmpty() )
	{
		bgImage = QImage( bgArtwork );
	}
	if( !bgImage.isNull() )
	{
		m_workspace->setBackground( bgImage );
	}
	else
	{
		m_workspace->setBackground( Qt::NoBrush );
	}

	m_workspace->setOption( QMdiArea::DontMaximizeSubWindowOnActivation );
	m_workspace->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
	m_workspace->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );

	hbox->addWidget( sideBar );
	hbox->addWidget( splitter );


	// create global-toolbar at the top of our window
	m_toolBar = new QWidget( main_widget );
	m_toolBar->setObjectName( "mainToolbar" );
	m_toolBar->setFixedHeight( 64 );
	m_toolBar->move( 0, 0 );

	// add layout for organizing quite complex toolbar-layouting
	m_toolBarLayout = new QGridLayout( m_toolBar/*, 2, 1*/ );
	m_toolBarLayout->setMargin( 0 );
	m_toolBarLayout->setSpacing( 0 );

	vbox->addWidget( m_toolBar );
	vbox->addWidget( w );
	setCentralWidget( main_widget );

	m_updateTimer.start( 1000 / 20, this );  // 20 fps

	if( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() )
	{
		// connect auto save
		connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));
		m_autoSaveInterval = ConfigManager::inst()->value(
					"ui", "saveinterval" ).toInt() < 1 ?
						DEFAULT_AUTO_SAVE_INTERVAL :
				ConfigManager::inst()->value(
					"ui", "saveinterval" ).toInt();

		// The auto save function mustn't run until there is a project
		// to save or it will run over recover.mmp if you hesitate at the
		// recover messagebox for a minute. It is now started in main.
		// See autoSaveTimerReset() in MainWindow.h
	}

	connect( Engine::getSong(), SIGNAL( playbackStateChanged() ),
				this, SLOT( updatePlayPauseIcons() ) );
}
예제 #15
0
파일: noteedit.cpp 프로젝트: tosky/basket
void FileEditor::validate()
{
    autoSave(/*toFileToo=*/true);
}
예제 #16
0
ImageArea::ImageArea(const bool &isOpen, const QString &filePath, QWidget *parent) :
    QWidget(parent), mIsEdited(false), mIsPaint(false), mIsResize(false)
{
    setMouseTracking(true);

    mRightButtonPressed = false;
    mFilePath.clear();
    makeFormatsFilters();
    initializeImage();
    mZoomFactor = 1;

    mAdditionalTools = new AdditionalTools(this);

    mUndoStack = new QUndoStack(this);
    mUndoStack->setUndoLimit(DataSingleton::Instance()->getHistoryDepth());

    if(isOpen && filePath.isEmpty())
    {
        open();
    }
    else if(isOpen && !filePath.isEmpty())
    {
        open(filePath);
    }
    else
    {
        QPainter *painter = new QPainter(mImage);
        painter->fillRect(0, 0,
                          DataSingleton::Instance()->getBaseSize().width(),
                          DataSingleton::Instance()->getBaseSize().height(),
                          Qt::white);
        painter->end();

        resize(mImage->rect().right() + 6,
               mImage->rect().bottom() + 6);
    }

    QTimer *autoSaveTimer = new QTimer(this);
    autoSaveTimer->setInterval(DataSingleton::Instance()->getAutoSaveInterval() * 1000);
    connect(autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));
    connect(mAdditionalTools, SIGNAL(sendNewImageSize(QSize)), this, SIGNAL(sendNewImageSize(QSize)));

    autoSaveTimer->start();

    SelectionInstrument *selectionInstrument = new SelectionInstrument(this);
    connect(selectionInstrument, SIGNAL(sendEnableCopyCutActions(bool)), this, SIGNAL(sendEnableCopyCutActions(bool)));
    connect(selectionInstrument, SIGNAL(sendEnableSelectionInstrument(bool)), this, SIGNAL(sendEnableSelectionInstrument(bool)));

    // Instruments handlers
    mInstrumentsHandlers.fill(0, (int)INSTRUMENTS_COUNT);
    mInstrumentsHandlers[CURSOR] = selectionInstrument;
    mInstrumentsHandlers[PEN] = new PencilInstrument(this);
    mInstrumentsHandlers[LINE] = new LineInstrument(this);
    mInstrumentsHandlers[ERASER] = new EraserInstrument(this);
    mInstrumentsHandlers[RECTANGLE] = new RectangleInstrument(this);
    mInstrumentsHandlers[ELLIPSE] = new EllipseInstrument(this);
    mInstrumentsHandlers[FILL] = new FillInstrument(this);
    mInstrumentsHandlers[SPRAY] = new SprayInstrument(this);
    mInstrumentsHandlers[MAGNIFIER] = new MagnifierInstrument(this);
    mInstrumentsHandlers[COLORPICKER] = new ColorpickerInstrument(this);
    mInstrumentsHandlers[CURVELINE] = new CurveLineInstrument(this);
    mInstrumentsHandlers[TEXT] = new TextInstrument(this);

    // Effects handlers
    mEffectsHandlers.fill(0, (int)EFFECTS_COUNT);
    mEffectsHandlers[NEGATIVE] = new NegativeEffect(this);
    mEffectsHandlers[GRAY] = new GrayEffect(this);
    mEffectsHandlers[BINARIZATION] = new BinarizationEffect(this);
    mEffectsHandlers[GAUSSIANBLUR] = new GaussianBlurEffect(this);
    mEffectsHandlers[GAMMA] = new GammaEffect(this);
    mEffectsHandlers[SHARPEN] = new SharpenEffect(this);
    mEffectsHandlers[CUSTOM] = new CustomEffect(this);
}
예제 #17
0
TrackRecorder::~TrackRecorder() {
    qDebug()<<"TrackRecorder destructor";
    autoSave();
}
예제 #18
0
//----------------------------------------------------------------------
// KJOTSMAIN
//----------------------------------------------------------------------
KJotsComponent::KJotsComponent(QWidget* parent, KActionCollection *collection) : QWidget(parent)
{
    actionCollection = collection;
    searchDialog = 0;
    activeAnchor.clear();

    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.registerObject("/KJotsComponent", this, QDBusConnection::ExportScriptableSlots);

    //
    // Main widget
    //

    splitter = new QSplitter(this);
    splitter->setOpaqueResize( KGlobalSettings::opaqueResize() );

    bookshelf = new Bookshelf(splitter);
    stackedWidget = new QStackedWidget(splitter);
    editor = new KJotsEdit(stackedWidget);
    editor->createActions(actionCollection);
    editor->setEnabled(false);
    stackedWidget->addWidget(editor);
    browser = new KJotsBrowser(stackedWidget);
    browser->setEnabled(false);
    stackedWidget->addWidget(browser);

    QVBoxLayout *bookGrid = new QVBoxLayout(this);
    bookGrid->setMargin(KDialog::marginHint());
    bookGrid->setSpacing(KDialog::spacingHint());
    bookGrid->addWidget(splitter, 0, 0);
    bookGrid->setMargin(0);

    splitter->setStretchFactor(1, 1);

    // I've moved as much I could into DelayedInitialization(), but the XML
    // gui builder won't insert things properly if they don't get in there early.
    KAction *action;
    action = actionCollection->addAction( "go_next_book");
    action->setText( i18n("Next Book") );
    action->setIcon(KIcon("go-down"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
    connect(action, SIGNAL(triggered()), bookshelf, SLOT(nextBook()));


    action = actionCollection->addAction( "go_prev_book");
    action->setText( i18n("Previous Book") );
    action->setIcon(KIcon("go-up"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D));
    connect(action, SIGNAL(triggered()), bookshelf, SLOT(prevBook()));

    action = actionCollection->addAction( "go_next_page");
    action->setText( i18n("Next Page") );
    action->setIcon(KIcon("go-next"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown));
    connect(action, SIGNAL(triggered()), bookshelf, SLOT(nextPage()));


    action = actionCollection->addAction( "go_prev_page" );
    action->setText( i18n("Previous Page") );
    action->setIcon(KIcon("go-previous"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageUp));
    connect(action, SIGNAL(triggered()), bookshelf, SLOT(prevPage()));

    action = actionCollection->addAction(  "new_page");
    action->setText( i18n("&New Page") );
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
    action->setIcon(KIcon("document-new"));
    connect(action, SIGNAL(triggered()), SLOT(newPage()));

    action = actionCollection->addAction("new_book");
    action->setText(i18n("New &Book..."));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_N));
    action->setIcon(KIcon("address-book-new"));
    connect(action, SIGNAL(triggered()), SLOT(createNewBook()));

    exportMenu = actionCollection->add<KActionMenu>("save_to");
    exportMenu->setText(i18n("Export"));
    exportMenu->setIcon(KIcon("document-export"));
    action = actionCollection->addAction("save_to_ascii");
    action->setText(i18n("To Text File..."));
    action->setIcon(KIcon("text-plain"));
    connect(action, SIGNAL(triggered()), SLOT(saveAscii()));
    exportMenu->menu()->addAction( action );

    action = actionCollection->addAction("save_to_html");
    action->setText(i18n("To HTML File..."));
    action->setIcon(KIcon("text-html"));
    connect(action, SIGNAL(triggered()), SLOT(saveHtml()));
    exportMenu->menu()->addAction( action );

    action = actionCollection->addAction("save_to_book");
    action->setText(i18n("To Book File..."));
    action->setIcon(KIcon("x-office-address-book"));
    connect(action, SIGNAL(triggered()), SLOT(saveNative()));
    exportMenu->menu()->addAction( action );

    action = actionCollection->addAction("import");
    action->setText(i18n("Import..."));
    action->setIcon(KIcon("document-import"));
    connect(action, SIGNAL(triggered()), SLOT(importBook()));

    action = actionCollection->addAction("del_page");
    action->setText(i18n("&Delete Page"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Delete));
    action->setIcon(KIcon("edit-delete-page"));
    connect(action, SIGNAL(triggered()), SLOT(deletePage()));

    action = actionCollection->addAction("del_folder");
    action->setText(i18n("Delete Boo&k"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Delete));
    action->setIcon(KIcon("edit-delete"));
    connect(action, SIGNAL(triggered()), SLOT(deleteBook()));

    action = actionCollection->addAction("del_mult");
    action->setText(i18n("Delete Selected"));
    action->setIcon(KIcon("edit-delete"));
    connect(action, SIGNAL(triggered()), SLOT(deleteMultiple()));

    action = actionCollection->addAction("manual_save");
    action->setText(i18n("Manual Save"));
    action->setIcon(KIcon("document-save"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
    connect(action, SIGNAL(triggered()), SLOT(saveAll()));

    action = actionCollection->addAction("auto_bullet");
    action->setText(i18n("Auto Bullets"));
    action->setIcon(KIcon("format-list-unordered"));
    action->setCheckable(true);

    action = actionCollection->addAction("auto_decimal");
    action->setText(i18n("Auto Decimal List"));
    action->setIcon(KIcon("format-list-ordered"));
    action->setCheckable(true);

    action = actionCollection->addAction("manage_link");
    action->setText(i18n("Link"));
    action->setIcon(KIcon("insert-link"));

    action = actionCollection->addAction("insert_checkmark");
    action->setText(i18n("Insert Checkmark"));
    action->setIcon(KIcon("checkmark"));
    action->setEnabled(false);

    KStandardAction::print(this, SLOT(onPrint()), actionCollection);

    action = KStandardAction::cut(editor, SLOT(cut()), actionCollection);
    connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool)));
    action->setEnabled(false);

    action = KStandardAction::copy(this, SLOT(copy()), actionCollection);
    connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool)));
    connect(browser, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool)));
    action->setEnabled(false);

    action = actionCollection->addAction("copyIntoTitle");
    action->setText(i18n("Copy &into Page Title"));
    action->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_T));
    action->setIcon(KIcon("edit-copy"));
    connect(action, SIGNAL(triggered()), SLOT(copySelection()));
    connect(editor, SIGNAL(copyAvailable(bool)), action, SLOT(setEnabled(bool)));
    action->setEnabled(false);

    KStandardAction::pasteText(editor, SLOT(paste()), actionCollection);

    KStandardAction::find( this, SLOT( onShowSearch() ), actionCollection );
    action = KStandardAction::findNext( this, SLOT( onRepeatSearch() ), actionCollection );
    action->setEnabled(false);
    KStandardAction::replace( this, SLOT( onShowReplace() ), actionCollection );

    action = actionCollection->addAction("rename_entry");
    action->setText(i18n("Rename..."));
    action->setIcon(KIcon("edit-rename"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
    connect(action, SIGNAL(triggered()), SLOT(onRenameEntry()));

    action = actionCollection->addAction("insert_date");
    action->setText(i18n("Insert Date"));
    action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
    action->setIcon(KIcon("view-calendar-time-spent"));
    connect(action, SIGNAL(triggered()), SLOT(insertDate()));

    action = actionCollection->addAction("change_color");
    action->setIcon(KIcon("format-fill-color"));
    action->setText(i18n("Change Color..."));
    // connected to protected slot in bookshelf.cpp

    action = actionCollection->addAction("copy_link_address");
    action->setText(i18n("Copy Link Address"));
    // connected to protected slot in bookshelf.cpp


    action = actionCollection->addAction("paste_plain_text");
    action->setText(i18nc("@action Paste the text in the clipboard without rich text formatting.", "Paste Plain Text"));
    connect(action, SIGNAL(triggered()), editor, SLOT(pastePlainText()));

    KStandardAction::preferences(this, SLOT(configure()), actionCollection);

    bookmarkMenu = actionCollection->add<KActionMenu>("bookmarks");
    bookmarkMenu->setText(i18n("&Bookmarks"));
    KJotsBookmarks* bookmarks = new KJotsBookmarks(bookshelf);
    /*KBookmarkMenu *bmm =*/ new KBookmarkMenu(
        KBookmarkManager::managerForFile(KStandardDirs::locateLocal("data","kjots/bookmarks.xml"), "kjots"),
        bookmarks, bookmarkMenu->menu(), actionCollection);

    m_autosaveTimer = new QTimer(this);

    //
    // Set startup size.
    //
    if (!KJotsSettings::splitterSizes().isEmpty())
    {
        splitter->setSizes(KJotsSettings::splitterSizes());
    }

    updateConfiguration();

    QTimer::singleShot(0, this, SLOT(DelayedInitialization()));

    //connect new slots
    connect(bookshelf, SIGNAL(itemSelectionChanged()), SLOT(updateCaption()));
    connect(bookshelf, SIGNAL(itemSelectionChanged()), SLOT(updateMenu()));
    connect(bookshelf, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onItemRenamed(QTreeWidgetItem*, int)));
    connect(m_autosaveTimer, SIGNAL(timeout()), SLOT(autoSave()));
}
예제 #19
0
Editor::Editor(int startX, int startY, int width, int height, QColor fontColor, int fontSize, QFont fontFamily,
               qreal gopacity, bool gclickMuted, bool gmusicMuted)
{
    clickObject = new Phonon::MediaObject(this);
    clickObject->setCurrentSource(currentClick);
    clickOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::createPath(clickObject, clickOutput);
    clickMuted = gclickMuted;
    musicObject = new Phonon::MediaObject(this);
    musicObject->setCurrentSource(currentMusic);
    musicOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::createPath(musicObject, musicOutput);
    connect(musicObject, SIGNAL(aboutToFinish()), this, SLOT(replayMusic(void)));
    musicMuted = gmusicMuted;
    timer = new QTimer(this);
    timer->start(60000*3); //autosave every 3 min
    currentFile = "";
    connect(timer, SIGNAL(timeout()), this, SLOT(autoSave()));
    saved = true;
    rect = QRect(startX,startY,width,height); //Default size of border
    opacity = gopacity;
    text = new QTextEdit(this);
    text->setGeometry(rect.x()+1,rect.y()+1,rect.width()-1,rect.height()-1); //Draw text edit 1 pixel smaller than border
    text->viewport()->setAutoFillBackground(false); //make trsparent background but not text
    text->setFrameShape(QFrame::NoFrame); //hide frame
/***************************************************************
    text->setStyleSheet(
            "QScrollBar:vertical {"
                  "border: 0px;"
                  "background: transparent;"
                  "width: 15px;"
                  "margin: 22px 0 22px 0;"
              "}"
              "QScrollBar::handle:vertical {"
                  "border: 1px solid" + currentTextColor.name() + ";"
                  "background: transparent;"
                  "min-height: 20px;"
              "}"
              "QScrollBar::add-line:vertical {"
                  "border: 0px;"
                  "background: transparent;"
                  "height: 20px;"
                  "subcontrol-position: bottom;"
                  "subcontrol-origin: margin;"
              "}"

              "QScrollBar::sub-line:vertical {"
                  "border: 0px;"
                  "background: transparent;"
                  "height: 20px;"
                  "subcontrol-position: top;"
                  "subcontrol-origin: margin;"
              "}"

              "QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {"
                  "border: 2px solid" + currentTextColor.name() + ";"
                  "width: 3px;"
                  "height: 3px;"
                  "background:" + currentTextColor.name() + ";"
              "}"

              "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
                  "background: none;"
              "}"

              "QScrollBar:horizontal {"
                  "border: 0px;"
                  "background: transparent;"
                  "height: 15px;"
                  "margin: 0px 22px 0 22px;"
              "}"

              "QScrollBar::handle:horizontal {"
                  "border: 1px solid" + currentTextColor.name() + ";"
                  "background: transparent;"
                  "min-width: 20px;"
              "}"

              "QScrollBar::add-line:horizontal {"
                  "border: 0px;"
                  "background: transparent;"
                  "width: 20px;"
                  "subcontrol-position: right;"
                  "subcontrol-origin: margin;"
              "}"

              "QScrollBar::sub-line:horizontal {"
                  "border: 0px;"
                  "background: transparent;"
                  "width: 20px;"
                  "subcontrol-position: left;"
                  "subcontrol-origin: margin;"
              "}"

              "QScrollBar::left-arrow:horizontal, QScrollBar::right-arrow:horizontal {"
                  "border: 2px solid" + currentTextColor.name() + ";"
                  "width: 3px;"
                  "height: 3px;"
                  "background:" + currentTextColor.name() + ";"
              "}"

              "QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {"
                   "background: none;"
              "}"
    );
*****************************************************************/
    text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //To make KoalaWriter behave like OmmWriter
    cursor = QCursor();
    this->setMouseTracking(true); //Permit mouse tracking also if no button is pressed

    //Define all handle 6x6 square center in the rect angle and in half side
    handleTL = QRect(QPoint(rect.topLeft().x()-3,rect.topLeft().y()-3),QSize(6,6));
    handleT = QRect(QPoint(rect.center().x()-3,rect.top()-3),QSize(6,6));
    handleTR = QRect(QPoint(rect.topRight().x()-3,rect.topRight().y()-3),QSize(6,6));
    handleL = QRect(QPoint(rect.left()-3,rect.center().y()-3),QSize(6,6));
    handleR = QRect(QPoint(rect.right()-3,rect.center().y()-3),QSize(6,6));
    handleBL = QRect(QPoint(rect.bottomLeft().x()-3,rect.bottomLeft().y()-3),QSize(6,6));
    handleB = QRect(QPoint(rect.center().x()-3,rect.bottom()-3),QSize(6,6));
    handleBR = QRect(QPoint(rect.bottomRight().x()-3,rect.bottomRight().y()-3),QSize(6,6));
    resizingTL = false;
    resizingTR = false;
    resizingBL = false;
    resizingBR = false;
    resizingT = false;
    resizingB = false;
    resizingL = false;
    resizingR = false;
    move = false;


    //Offset for spacing elements
    xOffset = 35;
    yOffset = 35;

    // Opacity slider
    slider = new QSlider(Qt::Horizontal, this);
    slider->setStyleSheet(
            "QSlider::groove:horizontal {"
                 "border: 2px solid white;"
                 "height: 6px;"
                 "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #424242, stop:1 black);"
                 "margin: 3px 0;"
                 "border-radius: 3px;"
             "}"

             "QSlider::handle:horizontal {"
                 "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #424242, stop:1 black);"
                 "border: 2px solid white;"
                 "width: 18px;"
                 "margin: -2px 0;"
                 "border-radius: 3px;"
             "}"
    );
    slider->setGeometry(rect.center().x()-60, rect.bottom()+10, 120, 20);
    slider->setRange(0, 10);
    slider->setValue(int(opacity*10));
    connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(setBackgroundOpacity(int)));

    //Draw all option button
    textB = new QPushButton(QIcon(":/buttons/Icons/text.png"),"", this);
    textB->setIconSize(QSize(32,32));
    textB->setGeometry(rect.right()+xOffset,startY,32,32);
    textB->setMouseTracking(true);

    fontComboBox = new QFontComboBox(this);
    fontComboBox->hide();
    fontComboBox->setStyleSheet(
            "QComboBox {"
                "border: 1px solid black;"
                "border-radius: 3px;"
             "}"

             "QComboBox::drop-down {"
                "width: 32px;"
                "border-top-right-radius: 3px;"
                "border-bottom-right-radius: 3px;"
             "}"

             "QComboBox::down-arrow {"
                "image: url(:/buttons/Icons/down_arrow.png);"
                "width: 32;"
                "height: 32;"
             "}"
    );
    fontComboBox->setGeometry(rect.right()+2*xOffset,startY,180,32);

    textColorB = new QPushButton(QIcon(":/buttons/Icons/color.png"),"", this);
    textColorB->hide();
    textColorB->setIconSize(QSize(32,32));
    textColorB->setGeometry(rect.right()+2*xOffset+183,startY,32,32);

    textBDimension = new QPushButton(QIcon(":/buttons/Icons/text_dimension.png"),"", this);
    textBDimension->setIconSize(QSize(32,32));
    textBDimension->setGeometry(rect.right()+xOffset,startY+yOffset,32,32);
    textBDimension->setMouseTracking(true);

    textLessB = new QPushButton(QIcon(":/buttons/Icons/text_less.png"),"", this);
    textLessB->hide();
    textLessB->setIconSize(QSize(32,32));
    textLessB->setGeometry(rect.right()+2*xOffset,startY+yOffset,32,32);

    textDefaultB = new QPushButton(QIcon(":/buttons/Icons/text_default.png"),"", this);
    textDefaultB->hide();
    textDefaultB->setIconSize(QSize(32,32));
    textDefaultB->setGeometry(rect.right()+3*xOffset,startY+yOffset,32,32);

    textMoreB = new QPushButton(QIcon(":/buttons/Icons/text_more.png"),"", this);
    textMoreB->hide();
    textMoreB->setIconSize(QSize(32,32));
    textMoreB->setGeometry(rect.right()+4*xOffset,startY+yOffset,32,32);

    backgroundB = new QPushButton(QIcon(":/buttons/Icons/background.png"),"", this);
    backgroundB->setIconSize(QSize(32,32));
    backgroundB->setGeometry(rect.right()+xOffset,startY+2*yOffset,32,32);
    backgroundB->setMouseTracking(true);

    backgroundPreviousB = new QPushButton(QIcon(":/buttons/Icons/sx.png"),"", this);
    backgroundPreviousB->hide();
    backgroundPreviousB->setIconSize(QSize(32,32));
    backgroundPreviousB->setGeometry(rect.right()+2*xOffset,startY+2*yOffset,32,32);

    backgroundNextB = new QPushButton(QIcon(":/buttons/Icons/dx.png"),"", this);
    backgroundNextB->hide();
    backgroundNextB->setIconSize(QSize(32,32));
    backgroundNextB->setGeometry(rect.right()+3*xOffset,startY+2*yOffset,32,32);

    backgroundColorB = new QPushButton(QIcon(":/buttons/Icons/color.png"),"", this);
    backgroundColorB->hide();
    backgroundColorB->setIconSize(QSize(32,32));
    backgroundColorB->setGeometry(rect.right()+4*xOffset,startY+2*yOffset,32,32);

    musicB = new QPushButton(QIcon(":/buttons/Icons/music.png"),"", this);
    musicB->setIconSize(QSize(32,32));
    musicB->setGeometry(rect.right()+xOffset,startY+3*yOffset,32,32);
    musicB->setMouseTracking(true);

    musicPreviousB = new QPushButton(QIcon(":/buttons/Icons/sx.png"),"", this);
    musicPreviousB->hide();
    musicPreviousB->setIconSize(QSize(32,32));
    musicPreviousB->setGeometry(rect.right()+2*xOffset,startY+3*yOffset,32,32);

    musicNextB = new QPushButton(QIcon(":/buttons/Icons/dx.png"),"", this);
    musicNextB->hide();
    musicNextB->setIconSize(QSize(32,32));
    musicNextB->setGeometry(rect.right()+3*xOffset,startY+3*yOffset,32,32);

    if(musicMuted)
        musicMuteB = new QPushButton(QIcon(":/buttons/Icons/mute_red.png"),"", this);
    else
        musicMuteB = new QPushButton(QIcon(":/buttons/Icons/mute.png"),"", this);
    musicMuteB->hide();
    musicMuteB->setIconSize(QSize(32,32));
    musicMuteB->setGeometry(rect.right()+4*xOffset,startY+3*yOffset,32,32);

    keyboardB = new QPushButton(QIcon(":/buttons/Icons/keyboard.png"),"", this);
    keyboardB->setIconSize(QSize(32,32));
    keyboardB->setGeometry(rect.right()+xOffset,startY+4*yOffset,32,32);
    keyboardB->setMouseTracking(true);

    keyboardPreviousB = new QPushButton(QIcon(":/buttons/Icons/sx.png"),"", this);
    keyboardPreviousB->hide();
    keyboardPreviousB->setIconSize(QSize(32,32));
    keyboardPreviousB->setGeometry(rect.right()+2*xOffset,startY+4*yOffset,32,32);

    keyboardNextB = new QPushButton(QIcon(":/buttons/Icons/dx.png"),"", this);
    keyboardNextB->hide();
    keyboardNextB->setIconSize(QSize(32,32));
    keyboardNextB->setGeometry(rect.right()+3*xOffset,startY+4*yOffset,32,32);

    if(clickMuted)
        keyboardMuteB = new QPushButton(QIcon(":/buttons/Icons/mute_red.png"),"", this);
    else
        keyboardMuteB = new QPushButton(QIcon(":/buttons/Icons/mute.png"),"", this);
    keyboardMuteB->hide();
    keyboardMuteB->setIconSize(QSize(32,32));
    keyboardMuteB->setGeometry(rect.right()+4*xOffset,startY+4*yOffset,32,32);

    fileB = new QPushButton(QIcon(":/buttons/Icons/file.png"),"", this);
    fileB->setIconSize(QSize(32,32));
    fileB->setGeometry(rect.right()+xOffset,startY+5*yOffset,32,32);
    fileB->setMouseTracking(true);

    loadB = new QPushButton(QIcon(":/buttons/Icons/load.png"),"", this);
    loadB->hide();
    loadB->setIconSize(QSize(32,32));
    loadB->setGeometry(rect.right()+2*xOffset,startY+5*yOffset,32,32);
    loadB->setMouseTracking(true);

    saveB = new QPushButton(QIcon(":/buttons/Icons/save.png"),"", this);
    saveB->hide();
    saveB->setIconSize(QSize(32,32));
    saveB->setGeometry(rect.right()+3*xOffset,startY+5*yOffset,32,32);

    saveAsB = new QPushButton(QIcon(":/buttons/Icons/save_as.png"),"", this);
    saveAsB->hide();
    saveAsB->setIconSize(QSize(32,32));
    saveAsB->setGeometry(rect.right()+4*xOffset,startY+5*yOffset,32,32);

    colorDialog = new QColorDialog();
    defaultTextDimension = 14;
    currentTextDimension = fontSize;
    currentFont = fontFamily;

    currentTextColor = fontColor;
    this->updateTextStyle();

    //Hidden interface
    hide = false;

    //Signals
    connect(text->document(), SIGNAL(contentsChanged()), this, SLOT(documentWasModified()));
    connect(fontComboBox, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(changeTextFont(const QFont&)));
    connect(textColorB,SIGNAL(clicked()),this,SLOT(showColorDialog(void)));
    connect(textLessB,SIGNAL(clicked()),this,SLOT(lessText(void)));
    connect(textDefaultB,SIGNAL(clicked()),this,SLOT(defaultText(void)));
    connect(textMoreB,SIGNAL(clicked()),this,SLOT(moreText(void)));
    connect(loadB,SIGNAL(clicked()),this,SLOT(open(void)));
    connect(saveB,SIGNAL(clicked()),this,SLOT(save(void)));
    connect(saveAsB,SIGNAL(clicked()),this,SLOT(saveAs(void)));
}
예제 #20
0
UEditorWindow::UEditorWindow(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::EditWindowClass),
      _confirmCloseMessageBox(0),
      _redoAction(0),
      _undoAction(0),
      _spaceNoteGeneration(false)
{

    this->setFocusPolicy(Qt::StrongFocus);
_startTime=0;
    _playViolon = false;
    _currentFile = NULL;
    _isPlaying=false;
setAcceptDrops(true);
USetting::Instance.init();

#ifdef QT_MODULE_NETWORK
UCheckUpdate * check = new UCheckUpdate(QUrl(URL_VERSION));
connect(check,SIGNAL(connected()),this,SLOT(onConnected()));
#endif


    setupAudio();
    setupUi();

            _currentFile = new UFile(this);// "songs/arkol - vingt ans/Arkol - vingt ans.txt");

            fileConnect();

            this->showSentenceWidget->setHScroll(0);

        connect(ui->vScroll,SIGNAL(valueChanged(int)),this,SLOT(onUpdateVScrollAndScale(int)));
        connect(ui->vSlider,SIGNAL(valueChanged(int)),this,SLOT(onUpdateVScrollAndScale(int)));
        connect(ui->vScroll,SIGNAL(sliderPressed()),this,SLOT(onUpdateVScrollAndScale()));
        connect(ui->vSlider,SIGNAL(sliderPressed()),this,SLOT(onUpdateVScrollAndScale()));
        //connect(ui->vScroll,SIGNAL(actionTriggered(int)),this,SLOT(changeVScroll(int)));

        connect(_hScroll,SIGNAL(valueChanged(int)),this,SLOT(changeHScroll(int)));
        //connect(ui->hSlider,SIGNAL(valueChanged(int)),this,SLOT(changeHSlider(int)));
        connect(_hScroll,SIGNAL(sliderPressed()),this,SLOT(changeHScroll()));
        //connect(ui->hSlider,SIGNAL(sliderPressed()),this,SLOT(changeHSlider()));
        connect(_hScroll,SIGNAL(pageStepChanged(int)),this,SLOT(changeHSlider(int)));





        connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openFile()));

        connect(ui->actionEditHeaders,SIGNAL(triggered()),this,SLOT(editHeader()));
        connect(ui->actionApplyOffset,SIGNAL(triggered()),this,SLOT(openTiming()));
        connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
        connect(playAction, SIGNAL(triggered()), this, SLOT(tooglePlay()));
        connect(pauseAction, SIGNAL(triggered()), this, SLOT(tooglePlay()));
        connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecord()));
        connect(showSentenceWidget,SIGNAL(haveToStop()), this, SLOT(tooglePlay()));

        connect(this->ui->offsetSpinBox, SIGNAL(valueChanged(int)), showSentenceWidget, SLOT(setPreviousDisplayed(int)));
        this->ui->offsetSpinBox->setValue(2);
        connect(ui->actionSetNormalNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setNormal()));
        connect(ui->actionSetFreeNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setFree()));
        connect(ui->actionSetGoldNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setGold()));

        connect(ui->actionMergeNotes,SIGNAL(triggered()),showSentenceWidget, SLOT(fusion()));
        connect(ui->actionSplitNote,SIGNAL(triggered()),showSentenceWidget, SLOT(split()));

        connect(ui->actionAddNote,SIGNAL(triggered()),showSentenceWidget, SLOT(nextClickAddNote()));
        connect(ui->actionAddSeparator,SIGNAL(triggered()),showSentenceWidget, SLOT(nextClickAddSeparator()));

        connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save()));
        connect(ui->actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAs()));
        connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newSong()));

        connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(close()));

        connect(&UInputManager::Instance,SIGNAL(spacePressEvent(void)),this,SLOT(tooglePlay()));

        connect(_wydget_timeline, SIGNAL(gapModified(double)),this, SLOT(gapModified(double)));

         connect(ui->actionDeleteNote,SIGNAL(triggered()),showSentenceWidget,SLOT(deleteNotes()));

        connect(ui->actionPreferences,SIGNAL(triggered()),&USetting::Instance,SLOT(showDialog()));

        connect(ui->actionMorphe,SIGNAL(triggered()),showSentenceWidget,SLOT(calquer()));


        connect(ui->actionLockTimings,SIGNAL(toggled(bool)),showSentenceWidget,SLOT(lockTime(bool)));

        connect(ui->actionCenter,SIGNAL(triggered()),this,SLOT(centerView()));

        connect(ui->actionHelp,SIGNAL(triggered()),this,SLOT(displayHelpScreen()));
        connect(ui->actionSendFeedback,SIGNAL(triggered()),this,SLOT(displayFeedback()));




        onUpdateVScrollAndScale();
        changeHScroll(0);


       // _currentFile = new UFile(this);
        this->showSentenceWidget->setLyrics(_currentFile->lyrics);
        _wydget_lyrics->setWidgetWords(showSentenceWidget);


        _undoAction = _currentFile->lyrics->history().createUndoAction(this->ui->menuEdit, tr("Annuler "));
        _undoAction->setShortcut(QKeySequence::Undo);
        _undoAction->setIcon(QIcon(":/images/undo.png"));
        this->ui->menuEdit->addAction(_undoAction);
        this->ui->toolBar->insertAction(this->ui->actionSetNormalNote, _undoAction);

        _redoAction = _currentFile->lyrics->history().createRedoAction(this->ui->menuEdit, tr("Refaire "));
        _redoAction->setShortcut(QKeySequence::Redo);
        _redoAction->setIcon(QIcon(":/images/redo.png"));
        this->ui->menuEdit->addAction(_redoAction);
        this->ui->toolBar->insertAction(this->ui->actionSetNormalNote, _redoAction);


        readLastFile();

        connect(ui->actionRecentFiles,SIGNAL(triggered()),this,SLOT(openLastFile()));



        readSettings();

        _spaceNote = new Recorder(this->showSentenceWidget);

        _autoSaveTimer = new QTimer(this);
          connect(_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));

          adaptNewFile();


}
예제 #21
0
파일: c2.c 프로젝트: chriskonnertz/c2-chess
/**
* Hauptmethode
*/
int main(int argc, char *argv[]) {
	hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	char o;
	char boardMode = 0; // 0/1
	char fullScreen = 1;
	char from[] = "??";
	char to[] = "??";
	char filename[255];
	char moves[28 * 16 * 2]; // keine Initialiserung!
	short movesCounter = 0;
	short board[120];
	int eval;
	int okay;
	int i;

	struct GameState gameState;
	struct GameState gameStateCopy;
	createStartBoard(board);
	setGameState(&gameState, board, 0, 3, 4);

	srand((unsigned int) time(NULL));  // Zufallsgenerator initialisieren

	if (fullScreen) system("cls");

	do {
		printf("\nSpieler: %i, Halbzug: %i\n", gameState.turnNumber % 2, gameState.turnNumber);
		printBoard(gameState.board, 0, boardMode);

		COLOR(128);
		printf("\n> Kommando:");
		COLOR(COLOR_DEFAULT);
		printf(" ");
        scanf("%c", &o); // Auf Char scannen
        fflush(stdin);

        if (fullScreen && o != 'm') system("cls");

        switch (o) {
        	case 'x':
        		// "magic" move - alles ist moeglich. Auch, Fehler zu produzieren.
        	case 'm':
        		printf("Zug von: ");
        		scanf("%s", from);
        		fflush(stdin);

        		printf("Zug nach: ");
        		scanf("%s", to);
        		fflush(stdin);

        		if (strlen(from) != 2 || strlen(to) != 2) {
        			printError("Ungueltige Koordinaten!\n");
        		} else {
        			autoSave(&gameState);
        			if (o == 'x') {
						doMovePartial(&gameState, convertCoordToIndex(from), convertCoordToIndex(to));
						doMoveFinal(&gameState, convertCoordToIndex(from), convertCoordToIndex(to));
        			} else {
        				if (doUserMove(&gameState, convertCoordToIndex(from), convertCoordToIndex(to))) system("cls");
        			}
        		}
        		break;
        	case 'n':
        		gameState.turnNumber--;
				printInfo("Zug zurueck.\n");
        		break;
        	case 'a':
        		do {
        			autoSave(&gameState);
        			okay = aiMove(&gameState, 0);
        		} while (autoMode && okay && ((gameState.turnNumber % 2 == 0 && gameState.ai0) || (gameState.turnNumber % 2 == 1 && gameState.ai1)));
        		break;
        	case 'c':
        		printInfo("Schach: %i\n", isCheck(&gameState));
        		break;
        	case 'h':
        		printHistory();
        		break;
        	case 'g':
        		generateMoves(&gameState, moves, &movesCounter);
        		printInfo("%i moegliche Zuege (ohne Beruecksichtigung von Schach).\n", movesCounter / 2);
				for (i = 0; i < movesCounter; i += 2) {
					printf("Zug mit %i von %i nach %i.\n", gameState.board[moves[i]], moves[i], moves[i + 1]);
				}
        		break;
        	case 'v':
        		eval = evaluateBoard(gameState.board);
        		printInfo("Evaluation (aus Sicht von weiss): %i\n", eval);
        		break;
        	case 't':
        		copyGameState(&gameState, &gameStateCopy);
    			okay = aiMove(&gameStateCopy, 3);
        		break;
        	case 'o':
        		okay = loadOpeningBookMove(&gameState, from, to);
        		if (okay) {
        			printInfo("Zugvorschlag aus dem Eroeffnungsbuch: mit %c von %s nach %s", getPieceSymbolAsChar(gameState.board[convertCoordToIndex(from)]), from, to);
        		} else {
        			printInfo("Das Eroeffnungsbuch enthaelt keinen passenden Zug!");
        		}
        		break;
        	case 's':
        		saveGame(&gameState, "quicksave", 1);
        		break;
        	case 'r':
				loadGame(&gameState, "quicksave");
        		break;
        	case 'l':
        		system("dir savegames\\*.sav /B");
				printf("\nLade Datei (Endung nicht angeben):\n");
				scanf("%s", filename);
				fflush(stdin);

				loadGame(&gameState, filename);
        		break;
        	case 'u':
        		loadAutoSave(&gameState);
        		break;
        	case 'b':
        		boardMode = (1 - boardMode);
        		printInfo("Brettdarstellung gewechselt auf: %i\n", boardMode);
        		break;
        	case 'd':
        		debugMode = (1 - debugMode);
        		printInfo("Debugmodus gewechselt auf: %i\n", debugMode);
        		break;
        	case '?':
        		printf("m (move)\tEinen Zug durchfuehren.\n");
        		printf("n (next)\tDen Spieler wechseln (ohne Zug, regelwidrig!)\n");
        		printf("a (ai)\t\tKI einen Zug durchfuehren lassen.\n");
        		printf("h (history)\tDen Spielverlauf anzeigen.\n");
        		printf("c (check)\tStellung auf Schach pruefen.\n");
        		printf("g (generate)\tMoegliche Zuege anzeigen lassen.\n");
        		printf("v (value)\tBewertung der Stellung anzeigen lassen.\n");
        		printf("t (tip)\t\tDie KI einen Zug-Tip anzeigen lassen.\n");
        		printf("s (save)\tQuicksave-Spielstand anlegen.\n");
        		printf("r (reload)\tQuicksave-Spielstand laden.\n");
        		printf("l (load)\tSpielstand laden (Dateiname angeben).\n");
        		printf("u (undo)\tLetzten Zug zuruecknehmen.\n");
        		printf("b (board)\tBrettdarstellung wechseln (fuer Debuggging).\n");
        		printf("d (open)\tDebugausgaben aktivieren/deaktivieren.\n");
        		printf("? (help)\tDiese Hilfe zu den Kommandos anzeigen lassen.\n");
        		printf("e (exit)\tDas Programm beenden.\n");
        		break;
        	case 'e':
        		// do nothing
        		break;
        	case '\n':
        		// do nothing
        		break;
        	default:
        		printError("Unbekannter Operator: %c\n", o);
        		break;
        }
        fflush(stdin);
	} while (o != 'e');

	return 0;
}
예제 #22
0
void TupMainWindow::setWorkSpace(const QStringList &users)
{
    #ifdef K_DEBUG
           T_FUNCINFO;
    #endif

    if (m_projectManager->isOpen()) {

        if (TupMainWindow::requestType == NewLocalProject || TupMainWindow::requestType == NewNetProject)
            TOsd::self()->display(tr("Information"), tr("Opening a new document..."));

        contextMode = TupProject::FRAMES_EDITION;

        // Setting undo/redo actions
        setUndoRedoActions();

        drawingTab = new TupViewDocument(m_projectManager->project(), this, isNetworked, users);

        TCONFIG->beginGroup("Network");
        QString server = TCONFIG->value("Server").toString();
        if (isNetworked && server.compare("tupitube.com") == 0) {
            connect(drawingTab, SIGNAL(requestExportImageToServer(int, int, const QString &, const QString &, const QString &)),                         
                    netProjectManagerHandler, SLOT(sendExportImageRequestToServer(int, int, const QString &, const QString &, const QString &)));
        }

        drawingTab->setWindowTitle(tr("Animation"));
        addWidget(drawingTab);

        connectToDisplays(drawingTab);
        connectWidgetToManager(drawingTab);
        connectWidgetToLocalManager(drawingTab);
        connect(drawingTab, SIGNAL(modeHasChanged(int)), this, SLOT(expandExposureView(int))); 
        connect(drawingTab, SIGNAL(expandColorPanel()), this, SLOT(expandColorView()));

        connect(drawingTab, SIGNAL(updateColorFromFullScreen(const QColor &)), this, SLOT(updatePenColor(const QColor &)));
        connect(drawingTab, SIGNAL(updatePenFromFullScreen(const QPen &)), this, SLOT(updatePenThickness(const QPen &)));
      
        drawingTab->setAntialiasing(true);

        int width = drawingTab->workSpaceSize().width();
        int height = drawingTab->workSpaceSize().height();
        int pWidth = m_projectManager->project()->dimension().width();
        int pHeight = m_projectManager->project()->dimension().height();

        /*
        tError() << "W: " << width;
        tError() << "H: " << height;
        tError() << "Pw: " << pWidth;
        tError() << "Ph: " << pHeight;
        */

        double proportion = 1;

        if (pWidth > pHeight)
            proportion = (double) width / (double) pWidth;
        else
            proportion = (double) height / (double) pHeight;

        if (proportion <= 0.5) {
            drawingTab->setZoomView("20");
        } else if (proportion > 0.5 && proportion <= 0.75) {
                   drawingTab->setZoomView("25");
        } else if (proportion > 0.75 && proportion <= 1.5) {
                   drawingTab->setZoomView("50");
        } else if (proportion > 1.5 && proportion < 2) {
                   drawingTab->setZoomView("75");
        }

        // TupViewCamera *
        viewCamera = new TupViewCamera(m_projectManager->project(), isNetworked);
        connectWidgetToManager(viewCamera);

        m_libraryWidget->setNetworking(isNetworked);

        if (isNetworked) {
            connect(viewCamera, SIGNAL(requestForExportVideoToServer(const QString &, const QString &, const QString &, int, const QList<int>)), 
                    this, SLOT(postVideo(const QString &, const QString &, const QString &, int, const QList<int>)));
            connect(viewCamera, SIGNAL(requestForExportStoryboardToServer(const QString &, const QString &, const QString &, const QList<int>)),
                    this, SLOT(postStoryboard(const QString &, const QString &, const QString &, const QList<int>)));
        } else {
            connect(drawingTab, SIGNAL(autoSave()), this, SLOT(callSave()));
        }

        animationTab = new TupAnimationspace(viewCamera);
        animationTab->setWindowIcon(QIcon(THEME_DIR + "icons/play_small.png"));
        animationTab->setWindowTitle(tr("Player"));
        addWidget(animationTab);

        helpTab = new TupHelpBrowser(this);
        helpTab->setDataDirs(QStringList() << m_helper->helpPath());

        QString lang = (QLocale::system().name()).left(2);
        if (lang.length() < 2)  
            lang = "en";

        QString helpPath = SHARE_DIR + "data/help/" + QString(lang + "/cover.html");

        QFile file(helpPath);
        if (!file.exists())
            helpPath = SHARE_DIR + "data/help/" + QString("en/cover.html");

        helpTab->setSource(helpPath);

        addWidget(helpTab);

        QString twitterPath = QDir::homePath() + "/." + QCoreApplication::applicationName() 
                              + "/twitter.html";

        if (QFile::exists(twitterPath)) {
            internetOn = true;
            newsTab = new TupTwitterWidget(this); 
            newsTab->setSource(twitterPath);
            addWidget(newsTab);
        } 

        connect(this, SIGNAL(tabHasChanged(int)), this, SLOT(updateCurrentTab(int)));

        exposureView->expandDock(true);

        // if (!isNetworked)
        //     connect(drawingTab, SIGNAL(autoSave()), this, SLOT(callSave()));

        m_projectManager->undoModified();

        // SQA: Check if this instruction is really required
        m_colorPalette->init();

        TCONFIG->beginGroup("PenParameters");
        int thicknessValue = TCONFIG->value("Thickness", -1).toInt();
        m_penWidget->init();
        m_penWidget->setThickness(thicknessValue);

        if (TupMainWindow::requestType == OpenLocalProject || TupMainWindow::requestType == OpenNetProject)
            TOsd::self()->display(tr("Information"), tr("Project <b>%1</b> opened!").arg(m_projectManager->project()->projectName()));

        connect(m_projectManager, SIGNAL(modified(bool)), this, SLOT(updatePlayer(bool)));

        m_exposureSheet->setScene(0);
    }