Esempio n. 1
0
void KardView::slotMatch()
{
    kDebug() << "in slot match" << endl;
    tries++;
    
    emit signalChangeStatusbar(i18n("Tries: %1", tries), IDS_TRY);
    
    co=0;

    if (((theme == "colors") && (color[0]==color[1])) || ((theme == "syllables") && (mText[0]==mText[1])) )  {//if same color or same picture
	kardW[0]->slotDisappear(); //hide the 2 same cards
	kardW[1]->slotDisappear();
	count=count+2; //count the cards that are matched by pairs
	if (count==noc)  {
	    slotAll();
	    return;
	}
    }
    else if ((theme == "house" || theme == "opposites" ||  theme == "animals" ||  theme == "food") && (getRef[0]==getRef[1]))  {
	kardW[0]->slotDisappear(); //hide the 2 same cards
	kardW[1]->slotDisappear();
	count=count+2; //count the cards that are matched by pairs
	if (count==noc)  {
	    slotAll();
	    return;
	}
    }
    else {
	kardW[0]->slotShow();
	kardW[1]->slotShow();
    }

    slotConnect();
}
void K2sendPlayList::insertDroppedEvent(QDropEvent *event, QListViewItem *p, QListViewItem *after)
{
    KURL::List urls;
    if (KURLDrag::decode(event, urls) && !urls.isEmpty()){
        KURL::List::iterator it;
        for ( it = urls.begin(); it != urls.end(); ++it ){
            if ((*it).isLocalFile()){
                add((*it).path(),(K2sendPlayListItem*)after);
            }
        }
    }
    QString msg = QString("%1 Files").arg(this->childCount());
    emit signalChangeStatusbar(msg);
}
void K2sendPlayList::read(KConfig * config)
{
    QStrList list;
    config->setGroup("playlist");
    config->readListEntry ("files",list);
    if (list.count()){
        QStrListIterator it( list );
        while (it.current()) {
            QString file = QString::fromUtf8(it.current());
            K2sendPlayListItem * new_item = new K2sendPlayListItem((KListView*)this,file);
            if (new_item->valid()){
                this->insertItem (new_item);
                new_item->moveItem(lastChild());

            } else {
                delete new_item;
            }++it;
        }
    }
    QString msg = QString("%1 Files").arg(this->childCount());
    emit signalChangeStatusbar(msg);
}
Esempio n. 4
0
void KrecipesView::actionRecipe( int recipeID, int action )
{
	//FIXME: Don't use magic numbers, use enums instead
	switch ( action ) {
	case 0:  //Show
		{
			showRecipe( recipeID );
			break;
		}
	case 1:  // Edit
		{
			if ( !inputPanel->everythingSaved() )
			{
				switch ( KMessageBox::questionYesNoCancel( this,
					i18n( "A recipe contains unsaved changes.\n"
					"Do you want to save changes made to this recipe before editing another recipe?" ),
					i18n( "Unsaved changes" ) ) ) {
				case KMessageBox::Yes:
					inputPanel->save();
					break;
				case KMessageBox::No:
					break;
				case KMessageBox::Cancel:
					return ;
				}
			}

			inputPanel->loadRecipe( recipeID );
			slotSetPanel( RecipeEdit );
			break;
		}
	case 2:  //Remove (not used at the moment)
		{
			switch ( KMessageBox::questionYesNo( this,
				i18n( "Are you sure you want to permanently remove the recipe, %1?"  ,database->recipeTitle(recipeID)),
				i18n( "Confirm remove" ) ) )
			{
			case KMessageBox::Yes:
				database->removeRecipe( recipeID );
				break;
			case KMessageBox::No:
				break;
			}
			QWidget * vis_panel = rightPanel->visiblePanel();
			if ( vis_panel == selectPanel )
				selectPanel->getActionsHandler()->selectionChangedSlot();
			break;
		}
	case 3:  //Add to shopping list
		{
			shoppingListPanel->addRecipeToShoppingList( recipeID );
			break;
		}
	case 4: //Show text in status bar
		{
			Recipe r;
 			database->loadRecipe(&r,RecipeDB::Meta|RecipeDB::Noatime,recipeID );

			KLocale *locale = KGlobal::locale();

			QString statusText = QString("<b>%1</b> %2 <b>%3</b> %4 <b>%5</b> %6")
			.arg(i18nc("Recipe created", "Created:")).arg(locale->formatDateTime(r.ctime))
			.arg(i18nc("Recipe modified", "Modified:")).arg(locale->formatDateTime(r.mtime))
			.arg(i18nc("Recipe last accessed", "Last Accessed:")).arg(locale->formatDateTime(r.atime));

			emit signalChangeStatusbar( statusText );
			break;
		}
	case 5: //Clear text in status bar
		{
			emit signalChangeStatusbar( QString("") );
			break;
		}
	}
}
Esempio n. 5
0
// Function to switch panels
void KrecipesView::slotSetPanel( KrePanel p, bool highlightLeftButton )
{
	if (p != -1) {
		if ( (m_activePanel != RecipeEdit) && (m_activePanel != RecipeView) )
			m_previousActivePanel = m_activePanel;
		m_activePanel = p;
	}
	kDebug() << "current:" << m_activePanel << "previous" << m_previousActivePanel;

	switch ( p ) {
	case SelectP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button0 );
		rightPanel->setHeader( i18n( "Find/Edit Recipes" ), "system-search" );
		rightPanel->raise( selectPanel );
		selectPanel->reload( Load );
		break;
	case ShoppingP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button1 );
		rightPanel->setHeader( i18n( "Shopping List" ), "view-pim-tasks" );
		rightPanel->raise( shoppingListPanel );
		shoppingListPanel->reload( Load );
		emit signalChangeStatusbar( QString("") );
		break;
	case DietP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button7 );
		rightPanel->setHeader( i18n( "Diet Helper" ), "diet" );
		rightPanel->raise( dietPanel );
		dietPanel->reload( Load );
		emit signalChangeStatusbar( QString("") );
		break;
	case MatcherP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button8 );
		rightPanel->setHeader( i18n( "Ingredient Matcher" ), "view-filter" );
		rightPanel->raise( ingredientMatcherPanel );
		ingredientMatcherPanel->reload( Load );
		emit signalChangeStatusbar( QString("") );
		break;

	case IngredientsP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button2 );
		rightPanel->setHeader( i18n( "Ingredients" ), "ingredients" );
		rightPanel->raise( ingredientsPanel );
		ingredientsPanel->reload( Load );
		emit signalChangeStatusbar( QString("") );
		break;
	case PropertiesP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button3 );
		rightPanel->setHeader( i18n( "Properties" ), "properties" );
		rightPanel->raise( propertiesPanel );
		propertiesPanel->reload();
		emit signalChangeStatusbar( QString("") );
		break;
	case UnitsP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button4 );
		rightPanel->setHeader( i18n( "Units" ), "units" );
		rightPanel->raise( unitsPanel );
		unitsPanel->reload( Load );
		emit signalChangeStatusbar( QString("") );
		break;
	case PrepMethodsP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button9 );
		rightPanel->setHeader( i18n( "Preparation Methods" ), "methods" );
		rightPanel->raise( prepMethodsPanel );
		prepMethodsPanel->reload( Load );
		emit signalChangeStatusbar( QString("") );
		break;
	case CategoriesP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button5 );
		rightPanel->setHeader( i18n( "Categories" ), "folder-yellow" );
		rightPanel->raise( categoriesPanel );
		categoriesPanel->reload( Load );
		emit signalChangeStatusbar( QString("") );
		break;
	case AuthorsP:
		if ( highlightLeftButton )
			leftPanel->highlightButton( button6 );
		rightPanel->setHeader( i18n( "Authors" ), "authors" );
		rightPanel->raise( authorsPanel );
		authorsPanel->reload( Load );
		emit signalChangeStatusbar( QString("") );
		break;
	case RecipeEdit:
		rightPanel->setHeader( i18n( "Edit Recipe" ), "document-edit" );
		rightPanel->raise( inputPanel );
		emit signalChangeStatusbar( QString("") );
		break;
	case RecipeView:
		rightPanel->setHeader( i18n( "View Recipe" ), "system-search" );
		rightPanel->raise( viewPanel );
		emit signalChangeStatusbar( QString("") );
		break;
	}
}
void ksimoptsView::slotOnURL(const QString& url)
{
    emit signalChangeStatusbar(url);
}
Esempio n. 7
0
void alterobooksView::slotOnURL(const QString& url)
{
    emit signalChangeStatusbar(url);
}
Esempio n. 8
0
void KardView::game()
{
    co = 0;
    count = 0;
    tries = 0;
    emit signalChangeStatusbar(i18n("Tries: %1", tries), IDS_TRY);

    if (theme == "syllables")
	loadSyllables();
    else if (theme != "colors") {
	loadPixmaps();
    }
    m_listButtons.clear();

    switch ( noc )  {
	case 4:
		n=2;
		m=2;
	break;

	case 8:
		n=2;
		m=4;
	break;

	case 12:
		n=3;
		m=4;
	break;

	default:
	case 16:
		n=4;
		m=4;
	break;

	case 20:
		n=5;
		m=4;
	break;

	case 24:
		n=4;
		m=6;
	break;
    }
    setAutoFillBackground(true);
    //create the GUI
    grid = new QGridLayout;
    grid->setSpacing(3);
    grid->setMargin(2);
    //create the cards
    for (int i=0; i<n; i++)  {
	for (int j=0; j<m; j++)  {
	    k[i][j]=new KardWidget(this, "wid");
	    grid->addWidget( k[i][j], i, j );
	    m_listButtons.append(k[i][j]);
	    k[i][j]->m_kardW->setAutoFillBackground(true);
	    k[i][j]->m_gray->setAutoFillBackground(true);
	    k[i][j]->show();
	}
    }
    setLayout(grid);
    /*QPalette pal;
    pal.setBrush( QPalette::Window, Qt::darkGray);
    setPalette(pal);*/

    //choose the cards colors in random
    srand((unsigned int)time((time_t *)NULL));
    int p= rand()%24;       //p will be the first colour
    if (p%2==1) {
	p=(p+1)%24; //p must be even
    }
    //shuffle the cards
    for (int i=0; i<noc; i++)  {
	t[i]=rand()%(noc);
	for (int j=0; j<i; j++)  {
	    if (t[i]==t[j])
		    i=i-1;
	}
    }
    int ni=0;
    for (int i=0; i<n; i++)  {
	for (int j=0; j<m; j++)  {
	    shuffle[i][j]=(t[ni]+p)%24;
	    QPalette pal;
	    switch (KardSettings::kardTheme()) {
		case KardSettings::EnumKardTheme::colors:
		    pal.setColor(QPalette::Active, QPalette::Window, QColor(a[shuffle[i][j]]));
		    k[i][j]->m_kardW->setPalette(pal);
		    break;
		case KardSettings::EnumKardTheme::house:
		    k[i][j]->m_kardW->setPixmap(px[shuffle[i][j]]);
		    k[i][j]->m_kardW->setScaledContents(true);
		    break;
		case KardSettings::EnumKardTheme::opposites:
		    k[i][j]->m_kardW->setPixmap(px[shuffle[i][j]]);
		    k[i][j]->m_kardW->setScaledContents(true);
		    break;
		case KardSettings::EnumKardTheme::syllables:
		    k[i][j]->m_kardW->setText(text[shuffle[i][j]]);
		    k[i][j]->m_kardW->setFont(QFont(KGlobalSettings::generalFont().family(), 44, QFont::Bold));
		    k[i][j]->m_kardW->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
		    k[i][j]->m_kardW->setScaledContents(true);
		    break;
		case KardSettings::EnumKardTheme::animals:
		    k[i][j]->m_kardW->setPixmap(px[shuffle[i][j]]);
		    k[i][j]->m_kardW->setScaledContents(true);
		    break;
		case KardSettings::EnumKardTheme::food:
		    k[i][j]->m_kardW->setPixmap(px[shuffle[i][j]]);
		    k[i][j]->m_kardW->setScaledContents(true);
		    break;
	    }
	    ni++;
	}
    }
    //enable the connections
    slotConnect();
    updateGeometry();//this is very important
}