示例#1
0
void MainWindow::newGame(int player, const Game * game)
{
	gameStartTimestamp = QDateTime::currentMSecsSinceEpoch();

	if (player < 0)
	{
		qDebug("New game started with players:");
		for (Player const * p : game->getPlayers())
			qDebug() << p->getTypeName();
		qDebug();
	}

	boardUi->newGame(player, game);

	if (isSetUp)
		return;
	isSetUp = true;

	qDeleteAll(playerInfos);
	playerInfos.clear();
	for (uint i = 0; i < game->getPlayerCount(); ++i)
	{
		PlayerInfoView * pi = new PlayerInfoView(i, game, &imgFactory);
		ui->playerInfoLayout->insertWidget(i, pi);
		connect(this, SIGNAL(updateNeeded()), pi, SLOT(updateView()));
		connect(this, SIGNAL(tileDrawn(int,int)), pi, SLOT(displayTile(int,int)));
		playerInfos.push_back(pi);
	}

	emit gameEvent(tr("New game started"));

	ui->remainingTiles->setUp(game, &imgFactory);
	connect(this, SIGNAL(updateNeeded()), ui->remainingTiles, SLOT(updateView()));


	QSettings settings;
	settings.beginGroup("games");
	int size = settings.beginReadArray("game");
	settings.endArray();

	settings.beginWriteArray("game");
	settings.setArrayIndex(size);

	settings.setValue("appRevision", APP_REVISION_STR);
	settings.setValue("qtCompileVersion", QT_VERSION_STR);
	settings.setValue("qtRuntimeVersionn", qVersion());
	settings.setValue("timestamp", gameStartTimestamp);
	settings.beginWriteArray("players");
	auto const & players = game->getPlayers();
	for (size_t i = 0; i < players.size(); ++i)
	{
		settings.setArrayIndex((int)i);
		settings.setValue("type", players[i]->getTypeName());
	}
	settings.endArray();

	settings.endArray();
	settings.endGroup();
}
示例#2
0
void SvgItem::setSvg(Plasma::Svg *svg)
{
    if (m_svg) {
        disconnect(m_svg.data(), 0, this, 0);
    }
    m_svg = svg;
    updateDevicePixelRatio();

    if (svg) {
        connect(svg, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
        connect(svg, SIGNAL(repaintNeeded()), this, SIGNAL(naturalSizeChanged()));
        connect(svg, SIGNAL(sizeChanged()), this, SIGNAL(naturalSizeChanged()));
    }

    if (implicitWidth() <= 0) {
        setImplicitWidth(naturalSize().width());
    }
    if (implicitHeight() <= 0) {
        setImplicitHeight(naturalSize().height());
    }

    scheduleImageUpdate();

    emit svgChanged();
    emit naturalSizeChanged();
}
示例#3
0
void QLineEditPrivate::init(const QString& txt)
{
    Q_Q(QLineEdit);
    control = new QWidgetLineControl(txt);
    control->setParent(q);
    control->setFont(q->font());
    QObject::connect(control, SIGNAL(textChanged(QString)),
            q, SIGNAL(textChanged(QString)));
    QObject::connect(control, SIGNAL(textEdited(QString)),
            q, SLOT(_q_textEdited(QString)));
    QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
            q, SLOT(_q_cursorPositionChanged(int,int)));
    QObject::connect(control, SIGNAL(selectionChanged()),
            q, SLOT(_q_selectionChanged()));
    QObject::connect(control, SIGNAL(accepted()),
            q, SIGNAL(returnPressed()));
    QObject::connect(control, SIGNAL(editingFinished()),
            q, SIGNAL(editingFinished()));
#ifdef QT_KEYPAD_NAVIGATION
    QObject::connect(control, SIGNAL(editFocusChange(bool)),
            q, SLOT(_q_editFocusChange(bool)));
#endif
    QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
            q, SLOT(updateMicroFocus()));

    QObject::connect(control, SIGNAL(textChanged(QString)),
            q, SLOT(updateMicroFocus()));

    // for now, going completely overboard with updates.
    QObject::connect(control, SIGNAL(selectionChanged()),
            q, SLOT(update()));

    QObject::connect(control, SIGNAL(selectionChanged()),
            q, SLOT(updateMicroFocus()));

    QObject::connect(control, SIGNAL(displayTextChanged(QString)),
            q, SLOT(update()));

    QObject::connect(control, SIGNAL(updateNeeded(QRect)),
            q, SLOT(_q_updateNeeded(QRect)));

    QStyleOptionFrame opt;
    q->initStyleOption(&opt);
    control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q));
    control->setPasswordMaskDelay(q->style()->styleHint(QStyle::SH_LineEdit_PasswordMaskDelay, &opt, q));
#ifndef QT_NO_CURSOR
    q->setCursor(Qt::IBeamCursor);
#endif
    q->setFocusPolicy(Qt::StrongFocus);
    q->setAttribute(Qt::WA_InputMethodEnabled);
    //   Specifies that this widget can use more, but is able to survive on
    //   less, horizontal space; and is fixed vertically.
    q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::LineEdit));
    q->setBackgroundRole(QPalette::Base);
    q->setAttribute(Qt::WA_KeyCompression);
    q->setMouseTracking(true);
    q->setAcceptDrops(true);

    q->setAttribute(Qt::WA_MacShowFocusRect);
}
示例#4
0
void GraphPropertiesWidget::on__graphDelete_clicked()
{
    bool createNewGraph = false;
    bool isActive = false;

    if( _graph == _mainWindow->graph() )
    {
        isActive = true;
    }

    GraphDocument* gd = qobject_cast<GraphDocument*>( _graph->parent() );

    if( gd->size() == 1 )
    {
        createNewGraph = true;
    }


    if( isActive ) emit updateNeeded();
    radio()->group()->removeButton( radio() );


    /*! remove this graph from the document. */
    emit removeGraph();

    if( createNewGraph )
    {
        emit addGraph( i18n( "Untitled0" ) );
    }

    deleteLater();
}
示例#5
0
void MainWindow::endGame()
{
	isSetUp = false;
	emit updateNeeded();
	boardUi->endGame();

	emit gameEvent(tr("Game ended."));

	QSettings settings;
	settings.beginGroup("games");
	int size = settings.beginReadArray("game");
	settings.endArray();

	settings.beginWriteArray("game");
	settings.setArrayIndex(size-1);

	settings.beginWriteArray("result");
	int playerCount = game->getPlayerCount();
	for (int i = 0; i < playerCount; ++i)
	{
		settings.setArrayIndex(i);
		settings.setValue("score", game->getPlayerScore(i));
	}
	settings.endArray();

	settings.endArray();
	settings.endGroup();
}
void ThreadProperties::saveChanges() {
    int oldMessagesCount = thread->getMessagesCount();

    if(ui->thMessagesPerThread->value() != oldMessagesCount) {
        thread->setGetMessagesCount(ui->thMessagesPerThread->value());
        // If count is LESS than before, delete extra messages!
        if(thread->getMessagesCount() < oldMessagesCount) {
            QList<ForumMessage*> messagesToDelete;
            for(ForumMessage *msg : *thread) {
                if(msg->ordernum() >= thread->getMessagesCount())
                    messagesToDelete.prepend(msg);
            }
            for(ForumMessage *msg : messagesToDelete) {
                thread->removeMessage(msg);
            }
            thread->setHasMoreMessages(true);
        } else { // If count is MORE than before, mark thread&group needing update
            thread->markToBeUpdated();
            thread->group()->markToBeUpdated();
        }
        thread->commitChanges();
        thread->group()->commitChanges();
        emit updateNeeded(thread->group()->subscription());
    }
    deleteLater();
}
/*! This method set flag isUpdateOnce() to true, and emit changed()
 */
void QseAbstractPlot::setUpdateOnce(bool need)
{
    if (m_updateOnce != need) {
        m_updateOnce = need;
        if (m_updateOnce) {
            emit updateNeeded();
        }
    }
}
示例#8
0
void addBackEnd::activatedAddMenu(int id)
{
	kdDebug() << "activatedAddMenu: " << QString("%1").arg(id) << endl;
	if (((uint)id) == libNames.size())
		doRollBack();
	if(((uint)id) >= libNames.size())
		return;

	KLibLoader *loader = KLibLoader::self();

        // try to load the library
	QString libname = *libNames.at(id);
        KLibrary *lib = loader->library(QFile::encodeName(libname));
        if (lib)
       	{
		// get the create_ function
		QString factory("add_");
		factory = factory+(*libNames.at(id));
		void *add = lib->symbol(QFile::encodeName(factory));

		if (add)
		{
			//call the add function
			bool (*func)(QString*, QString*, QMap<QString,QString> *);
			QMap<QString,QString> map;
			func = (bool (*)(QString*, QString*, QMap<QString,QString> *)) add;
			QString *tmp = new QString("");
			if (func(tmp,libParam.at(id),&map))
			{
				QString myFile = findFileName(tmp,m_universal,m_currentProfile);

				if (!myFile.isEmpty())
				{
					kdDebug() <<"trying to save to file: "<<myFile << endl;
					KSimpleConfig scf(myFile,false);
					scf.setGroup("Desktop Entry");
					for (QMap<QString,QString>::ConstIterator it = map.begin(); it != map.end(); ++it) {
						kdDebug() <<"writing:"<<it.key()<<" / "<<it.data()<<endl;
						scf.writePathEntry(it.key(), it.data());
					}
					scf.sync();
					emit updateNeeded();

				} else {
					kdWarning() << "No unique filename found" << endl;
				}
			} else {
				kdWarning() << "No new entry (error?)" << endl;
			}
			delete tmp;
		}
	} else {
		kdWarning() << "libname:" << libNames.at(id)
			<< " doesn't specify a library!" << endl;
	}
}
示例#9
0
void MainWindow::undoneMove(const MoveHistoryEntry & move)
{
	emit updateNeeded();
	boardUi->undoneMove(move);

	emit gameEventPop();

	QString const & dataLoc = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
	QDir dir = QDir(dataLoc).absoluteFilePath("games");
	if (dir.mkpath(".") && gameStartTimestamp != -1)
		game->storeToFile(dir.absoluteFilePath(QString::number(gameStartTimestamp)));
}
示例#10
0
void MainWindow::playerMoved(int player, const Tile * tile, const MoveHistoryEntry & move)
{
	emit updateNeeded();
	boardUi->playerMoved(player, tile, move);

	if (move.move.tileMove.isNull())
		emit gameEvent(tr("A non-suitable tile was drawn and discarded."));
	else
		emit gameEvent(tr("Player %1 moved.").arg(player+1));

//	QSettings settings;
//	settings.beginGroup("games");
//	int size = settings.beginReadArray("game");
//	settings.endArray(); //game

//	settings.beginWriteArray("game");
//	settings.setArrayIndex(size-1);

//	int moveSize = settings.beginReadArray("moves");
//	settings.endArray(); //moves

//	auto const & history = game->getMoveHistory();
//	settings.beginWriteArray("moves");
//	for (size_t i = moveSize; i < history.size(); ++i)
//	{
//		settings.setArrayIndex((int)i);
//		MoveHistoryEntry const & m = history[i];
//		settings.setValue("tile", m.tile);
//		settings.setValue("x", m.move.tileMove.x);
//		settings.setValue("y", m.move.tileMove.y);
//		settings.setValue("orientation", m.move.tileMove.orientation);
//		settings.setValue("meeple", m.move.meepleMove.nodeIndex);
//	}
//	settings.endArray(); //moves

//	settings.endArray(); //game
//	settings.endGroup(); //games

	QString const & dataLoc = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
	QDir dir = QDir(dataLoc).absoluteFilePath("games");
	if (dir.mkpath(".") && gameStartTimestamp != -1)
		game->storeToFile(dir.absoluteFilePath(QString::number(gameStartTimestamp)));
}
示例#11
0
// -----------------------------------------------------------------------------
// ShowTypedQueryL
// Shows list query and returns the user selection.
// -----------------------------------------------------------------------------
//
TUid CSendUiImpl::ShowTypedQueryL(
    CSendUi::TSendUiMenuType    aMenuType,
    const CMessageData*         aMessageData,
    TSendingCapabilities        aRequiredCapabilities,
    CArrayFix<TUid>*            aServicesToDim,
    const TDesC&                aTitleText )
{
    // Implemented for CR # 401-1806 >>
    // This section to enable/disable features (supported by feature manager) at run time, is to be revised,
    // once an observer class is available from feature manager side to intimate about feature state

    CRepository* repository = CRepository::NewLC( KCRUidSendUi );
    TInt oldFeatures(0);
    TInt newFeatures(0);
    TBool updateNeeded( EFalse );

    if ( repository->Get( KKeySendUiFeatureManagerServices, oldFeatures ) != KErrNone )
    {
        updateNeeded = ETrue;
    }
    FeatureManager::InitializeLibL();
    FeatureStatus( KFeatureIdMmsPostcard, newFeatures, KSendUiPostcard );
    FeatureStatus( KFeatureIdAudioMessaging, newFeatures, KSendUiAudioMessage );
    FeatureStatus( KFeatureIdSenduiMmsUpload, newFeatures, KSendUiMmsUpload );
    FeatureManager::UnInitializeLib();
    if ( newFeatures != oldFeatures )
    {
        repository->Set( KKeySendUiFeatureManagerServices, newFeatures );
        updateNeeded = ETrue;
    }

    CleanupStack::PopAndDestroy( repository );

    RProperty propertyUpdateOperation;
    TRequestStatus status;
    if ( updateNeeded )
    {
        RProperty::Set(
            KPSUidSendUiProperty,
            KSendUiUpdateRequest,
            KSendUiUpdateRequested );
        User::LeaveIfError( propertyUpdateOperation.Attach( KPSUidSendUiProperty, KSendUiUpdateRequest ));
        propertyUpdateOperation.Subscribe( status );
        User::WaitForRequest(status);
        TInt value = KErrNone;
        if(propertyUpdateOperation.Get( value ) !=KErrNotFound && value == KSendUiUpdated )
        {
            TRAPD( err, GetServicesL() );
            if ( err )
            {
#ifdef _DEBUG
                TBuf<256> buf;
                buf.Format(_L("SendUi err"));
                User::InfoPrint(buf);
#endif
                TUid serviceId( KNullUid );
                return serviceId;
            }
        }
        propertyUpdateOperation.Close();
    }
    // Implemented for CR # 401-1806 <<
    // List items for list query.
    CDesCArrayFlat* listItems = new (ELeave) CDesCArrayFlat( KArrayGranularity );
    CleanupStack::PushL( listItems);

    // This array is used to map user selection to correct service.
    CArrayFix<TUid>* listItemUids =
        new ( ELeave ) CArrayFixFlat<TUid>( KArrayGranularity );
    CleanupStack::PushL( listItemUids );

    iServicesToDim->Reset();

    TInt i = 0;
    if ( aServicesToDim )
    {
        for ( i = 0; i < aServicesToDim->Count(); i++  )
        {
            iServicesToDim->AppendL( (*aServicesToDim)[i] );
        }
    }

    // Get and filter ECom based services.
    FilterServicesL(
        *listItems,
        *listItemUids,
        aRequiredCapabilities,
        aMessageData,
        aMenuType );

    TUid serviceId( KNullUid );
    if ( listItems->Count() > 0 )
    {
        // Show list query.
        SortListL( *listItems, *listItemUids );

        serviceId = ShowListQueryL(
                        listItems,
                        *listItemUids,
                        aTitleText,
                        aMenuType );
    }

    CleanupStack::PopAndDestroy( 2, listItems );  // listItemUids, listItems

    return serviceId;
}
示例#12
0
Sidebar_Widget::Sidebar_Widget(QWidget *parent, KParts::ReadOnlyPart *par, const char *name,bool universalMode, const QString &currentProfile)
	:QWidget(parent,name),m_universalMode(universalMode),m_partParent(par),m_currentProfile(currentProfile)
{
	m_somethingVisible = false;
	m_initial = true;
	m_noUpdate = false;
	m_layout = 0;
	m_currentButton = 0;
	m_activeModule = 0;
	m_userMovedSplitter = false;
        //kdDebug() << "**** Sidebar_Widget:SidebarWidget()"<<endl;
	if (universalMode)
	{
		m_relPath = "konqsidebartng/kicker_entries/";
	}
	else
	{
		m_relPath = "konqsidebartng/" + currentProfile + "/entries/";
	}
	m_path = KGlobal::dirs()->saveLocation("data", m_relPath, true);
	m_buttons.setAutoDelete(true);
	m_hasStoredUrl = false;
	m_latestViewed = -1;
	setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));

	QSplitter *splitterWidget = splitter();
	if (splitterWidget) {
		splitterWidget->setResizeMode(parent, QSplitter::FollowSizeHint);
		splitterWidget->setOpaqueResize( false );
		connect(splitterWidget,SIGNAL(setRubberbandCalled()),SLOT(userMovedSplitter()));
	}
		
	m_area = new KDockArea(this);
	m_area->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
	m_mainDockWidget = m_area->createDockWidget("free", 0);
	m_mainDockWidget->setWidget(new QWidget(m_mainDockWidget));
	m_area->setMainDockWidget(m_mainDockWidget);
	m_area->setMinimumWidth(0);
	m_mainDockWidget->setDockSite(KDockWidget::DockTop);
	m_mainDockWidget->setEnableDocking(KDockWidget::DockNone);

	m_buttonBar = new KMultiTabBar(KMultiTabBar::Vertical,this);
	m_buttonBar->showActiveTabTexts(true);

	m_menu = new QPopupMenu(this, "Sidebar_Widget::Menu");
	QPopupMenu *addMenu = new QPopupMenu(this, "Sidebar_Widget::addPopup");
	m_menu->insertItem(i18n("Add New"), addMenu, 0);
	m_menu->insertItem(i18n("Multiple Views"), 1);
	m_menu->insertItem(i18n("Show Tabs Left"), 2);
	m_menu->insertItem(i18n("Show Configuration Button"), 3);
	if (!m_universalMode) {
		m_menu->insertItem(SmallIconSet("remove"),
                                   i18n("Close Navigation Panel"),
				par, SLOT(deleteLater()));
	}
        connect(m_menu, SIGNAL(aboutToShow()),
		this, SLOT(aboutToShowConfigMenu()));
	connect(m_menu, SIGNAL(activated(int)),
		this, SLOT(activatedMenu(int)));

	m_buttonPopup = 0;
	addBackEnd *ab = new addBackEnd(this, addMenu, universalMode,
                                        currentProfile,
                                        "Sidebar_Widget-addBackEnd");

	connect(ab, SIGNAL(updateNeeded()),
		this, SLOT(updateButtons()));
	connect(ab, SIGNAL(initialCopyNeeded()),
		this, SLOT(finishRollBack()));

	initialCopy();

        if (universalMode)
        {
                m_config = new KConfig("konqsidebartng_kicker.rc");
        }
        else
        {
                m_config = new KConfig("konqsidebartng.rc");
                m_config->setGroup(currentProfile);
        }
        readConfig();

        // Disable stuff (useful for Kiosk mode)!
        m_menu->setItemVisible(1, !m_immutableSingleWidgetMode);
        m_menu->setItemVisible(2, !m_immutableShowTabsLeft);
        m_menu->setItemVisible(3, !m_immutableShowExtraButtons);

	connect(&m_configTimer, SIGNAL(timeout()),
		this, SLOT(saveConfig()));
	m_somethingVisible = !m_openViews.isEmpty();
	doLayout();
	QTimer::singleShot(0,this,SLOT(createButtons()));
	connect(m_area, SIGNAL(dockWidgetHasUndocked(KDockWidget*)),
		this, SLOT(dockWidgetHasUndocked(KDockWidget*)));
}