~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to kmid/kdisptext.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
    You should have received a copy of the GNU General Public License
17
17
    along with this program; if not, write to the Free Software
18
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
19
 
20
20
    Send comments and bug fixes to larrosa@kde.org
21
21
    or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
26
26
#include <qfont.h>
27
27
#include <qfontmetrics.h>
28
28
#include <qrect.h>
 
29
#include <qtextcodec.h>
 
30
 
 
31
#include <kconfig.h>
29
32
#include <kglobal.h>
 
33
#include <kglobalsettings.h>
30
34
#include <kinstance.h>
31
 
#include <kconfig.h>
 
35
#include <klocale.h>
32
36
#include "version.h"
33
37
 
34
38
 
48
52
  first_line=NULL;
49
53
  cursor=NULL;
50
54
  nlines=0;
 
55
  lyrics_codec=KGlobal::locale()->codecForEncoding();
 
56
 
51
57
  viewport()->setBackgroundColor(QColor (110,110,110));
52
58
//  setBackgroundMode(NoBackground);
53
59
  KConfig *kcfg=KGlobal::instance()->config();
54
60
  kcfg->setGroup("KMid");
55
61
  typeoftextevents=kcfg->readNumEntry("TypeOfTextEvents",1);
56
 
  QFont *qtextfontdefault=new QFont("courier",22);
 
62
  QFont *qtextfontdefault=new QFont(KGlobalSettings::fixedFont().family(),22);
57
63
  qtextfont=new QFont(kcfg->readFontEntry("KaraokeFont",qtextfontdefault));
58
64
  delete qtextfontdefault;
59
65
  qfmetr=new QFontMetrics(*qtextfont);
208
214
                        tmpx=5;
209
215
 
210
216
                        tmp->xpos=tmpx;
211
 
                        if (tmp->spev->text[0]!=0) tmpw=qfmetr->width(&tmp->spev->text[1]);
 
217
                        if (tmp->spev->text[0]!=0) tmpw=qfmetr->width(lyrics_codec->toUnicode(&tmp->spev->text[1]));
212
218
                                else tmpw=0;
213
 
                        tmp->r=qfmetr->boundingRect(&tmp->spev->text[1]);
 
219
                        tmp->r=qfmetr->boundingRect(lyrics_codec->toUnicode(&tmp->spev->text[1]));
214
220
                    }
215
221
                    else
216
222
                    {
217
223
                        tmp->xpos=tmpx;
218
 
                        tmpw=qfmetr->width(tmp->spev->text);
219
 
                        tmp->r=qfmetr->boundingRect(tmp->spev->text);
 
224
                        tmpw=qfmetr->width(lyrics_codec->toUnicode(tmp->spev->text));
 
225
                        tmp->r=qfmetr->boundingRect(lyrics_codec->toUnicode(tmp->spev->text));
220
226
                    }
221
227
        // We add 5 pixels above, below and to the right because of a
222
228
        // problem with latest released Xft
235
241
        maxX[(typeoftextevents==1)?0:1]=maxx+10;
236
242
        maxY[(typeoftextevents==1)?0:1]=
237
243
                nlines_[(typeoftextevents==1)?0:1]*lineSpacing+descent+10;
238
 
 
 
244
 
239
245
        if (typeoftextevents==1) typeoftextevents=5;
240
246
        else fin=1;
241
247
    }
253
259
   t=t->next;
254
260
   };
255
261
return start;
256
 
};
 
262
}
257
263
 
258
 
void KDisplayText::drawContents(QPainter *p,int clipx,int clipy,int clipw,int cliph)
 
264
void KDisplayText::drawContents(QPainter *p, int /*clipx*/, int clipy, int /*clipw*/, int cliph)
259
265
{
260
266
    p->setFont(*qtextfont);
261
267
    if (linked_list==NULL) return;
278
284
       nlinestodraw++;
279
285
       t=t->next;
280
286
       }
281
 
    
 
287
 
282
288
    i=0;
283
289
    while ((i<nlinestodraw)&&(tmpl!=NULL))
284
290
    {
286
292
        while ((tmp!=NULL)&&(tmp->spev->type!=typeoftextevents)) tmp=tmp->next;
287
293
        while (tmp!=NULL)
288
294
        {
289
 
            if ( colorplayed && 
 
295
            if ( colorplayed &&
290
296
                 //     (tmp->spev->absmilliseconds>=cursor->spev->absmilliseconds))
291
297
                 (tmp->spev->id>=cursor->spev->id))
292
298
            {
293
299
                p->setPen(black);
294
300
                colorplayed=0;
295
 
            }   
296
 
            
 
301
            }
 
302
 
297
303
            if (IsLineFeed(tmp->spev->text[0],tmp->spev->type))
298
 
                p->drawText(tmp->xpos,tmpl->ypos,&tmp->spev->text[1]);
 
304
                p->drawText(tmp->xpos,tmpl->ypos,lyrics_codec->toUnicode(&tmp->spev->text[1]));
299
305
            else
300
 
                p->drawText(tmp->xpos,tmpl->ypos,tmp->spev->text);
 
306
                p->drawText(tmp->xpos,tmpl->ypos,lyrics_codec->toUnicode(tmp->spev->text));
301
307
 
302
308
#ifdef DRAW_BOUNDING_RECTS
303
309
            p->setPen(red);
310
316
        i++;
311
317
        tmpl=tmpl->next;
312
318
    }
313
 
    
 
319
 
314
320
}
315
321
 
316
322
 
317
323
void KDisplayText::resizeEvent(QResizeEvent *e)
318
324
{
319
 
    QScrollView::resizeEvent(e);  
 
325
    QScrollView::resizeEvent(e);
320
326
    nvisiblelines=visibleHeight()/qfmetr->lineSpacing();
321
327
    if ( (nlines>nvisiblelines) || (nvisiblelines==0) )
322
328
        resizeContents(maxX[(typeoftextevents==1)?0:1],maxY[(typeoftextevents==1)?0:1]);
613
619
    
614
620
}
615
621
 
616
 
 
617
 
/*QSize KDisplayText::sizeHint()
 
622
void KDisplayText::setLyricsEncoding(const QString &enc)
618
623
{
619
 
return QSize(400,200);
620
 
}*/
 
624
  QTextCodec *newcodec;
 
625
  if (enc.isEmpty())
 
626
    newcodec=KGlobal::locale()->codecForEncoding();
 
627
  else
 
628
    newcodec=QTextCodec::codecForName(enc.latin1()); 
 
629
 
 
630
  if (newcodec!=lyrics_codec)
 
631
  {
 
632
    if (newcodec)
 
633
    {
 
634
      lyrics_codec=newcodec;
 
635
      fontChanged();
 
636
    }
 
637
  }      
 
638
}
 
639
 
621
640
#include "kdisptext.moc"